1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-13 22:28:14 +00:00

Async dump config

This commit is contained in:
Otto Winter 2019-06-03 10:50:27 +02:00
parent f647e99479
commit a8c5f0c610
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 10 additions and 14 deletions

View File

@ -57,14 +57,7 @@ void Application::setup() {
}
ESP_LOGI(TAG, "setup() finished successfully!");
this->dump_config();
}
void Application::dump_config() {
ESP_LOGI(TAG, "esphome version " ESPHOME_VERSION " compiled on %s", this->compilation_time_.c_str());
for (auto component : this->components_) {
component->dump_config();
}
this->schedule_dump_config();
}
void Application::loop() {
uint32_t new_app_state = 0;
@ -97,9 +90,13 @@ void Application::loop() {
}
this->last_loop_ = now;
if (this->dump_config_scheduled_) {
this->dump_config();
this->dump_config_scheduled_ = false;
if (this->dump_config_at_ >= 0 && this->dump_config_at_ < this->components_.size()) {
if (this->dump_config_at_ == 0) {
ESP_LOGI(TAG, "esphome version " ESPHOME_VERSION " compiled on %s", this->compilation_time_.c_str());
}
this->components_[this->dump_config_at_]->dump_config();
this->dump_config_at_++;
}
}

View File

@ -109,8 +109,7 @@ class Application {
*/
void set_loop_interval(uint32_t loop_interval) { this->loop_interval_ = loop_interval; }
void dump_config();
void schedule_dump_config() { this->dump_config_scheduled_ = true; }
void schedule_dump_config() { this->dump_config_at_ = 0; }
void feed_wdt();
@ -234,7 +233,7 @@ class Application {
std::string compilation_time_;
uint32_t last_loop_{0};
uint32_t loop_interval_{16};
bool dump_config_scheduled_{false};
int dump_config_at_{-1};
uint32_t app_state_{0};
};