mirror of
https://github.com/esphome/esphome.git
synced 2025-01-21 20:06:01 +01:00
Give 100 ms to do some checks before it starts going
This commit is contained in:
parent
3231e42565
commit
39b707ffaa
2 changed files with 8 additions and 2 deletions
|
@ -388,11 +388,13 @@ bool EbyteLoraComponent::can_send_message_(const char *info) {
|
|||
return true;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Can't sent it right now for %s", info);
|
||||
delay(20);
|
||||
this->busy_till_ = millis() + 100;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void EbyteLoraComponent::update() {
|
||||
if (millis() < this->busy_till_)
|
||||
return;
|
||||
if (!this->current_config_.config_set) {
|
||||
ESP_LOGD(TAG, "Config not set yet! Requesting");
|
||||
this->request_current_config_();
|
||||
|
@ -422,6 +424,8 @@ void EbyteLoraComponent::update() {
|
|||
}
|
||||
}
|
||||
void EbyteLoraComponent::loop() {
|
||||
if (millis() < this->busy_till_)
|
||||
return;
|
||||
if (this->available()) {
|
||||
std::vector<uint8_t> data;
|
||||
ESP_LOGD(TAG, "Reading serial");
|
||||
|
@ -435,9 +439,9 @@ void EbyteLoraComponent::loop() {
|
|||
}
|
||||
this->process_(data);
|
||||
}
|
||||
|
||||
if (this->request_repeater_info_update_needed_) {
|
||||
this->request_repeater_info_();
|
||||
return;
|
||||
}
|
||||
if (this->need_send_info) {
|
||||
this->send_data_(true);
|
||||
|
|
|
@ -114,6 +114,8 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
|||
// for now do it every 600s
|
||||
uint32_t recyle_time_ = 600;
|
||||
uint32_t last_key_time_{};
|
||||
// auto delay doing anything
|
||||
uint32_t busy_till_ = 0;
|
||||
void setup_conf_(std::vector<uint8_t> conf);
|
||||
void process_(std::vector<uint8_t> data);
|
||||
void repeat_message_(std::vector<uint8_t> data);
|
||||
|
|
Loading…
Reference in a new issue