mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 09:44:12 +01:00
Update lora.cpp
This commit is contained in:
parent
d2ba9e9a07
commit
2ed4d2d69b
1 changed files with 10 additions and 21 deletions
|
@ -3,21 +3,7 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace lora {
|
namespace lora {
|
||||||
void Lora::update() {
|
void Lora::update() {
|
||||||
// High means no more information is needed
|
can_send_message_();
|
||||||
if (this->pin_aux_->digital_read()) {
|
|
||||||
if (!this->starting_to_check_ == 0 && !this->time_out_after_ == 0) {
|
|
||||||
this->starting_to_check_ = 0;
|
|
||||||
this->time_out_after_ = 0;
|
|
||||||
ESP_LOGD(TAG, "Aux pin is High! Can send again!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// it has taken too long to complete, error out!
|
|
||||||
if ((millis() - this->starting_to_check_) > this->time_out_after_) {
|
|
||||||
ESP_LOGD(TAG, "Timeout error! Resetting timers");
|
|
||||||
this->starting_to_check_ = 0;
|
|
||||||
this->time_out_after_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get_mode_();
|
get_mode_();
|
||||||
if (!this->update_needed_)
|
if (!this->update_needed_)
|
||||||
return;
|
return;
|
||||||
|
@ -111,18 +97,21 @@ void Lora::set_mode_(ModeType mode) {
|
||||||
ESP_LOGD(TAG, "Mode is going to be set");
|
ESP_LOGD(TAG, "Mode is going to be set");
|
||||||
}
|
}
|
||||||
bool Lora::can_send_message_() {
|
bool Lora::can_send_message_() {
|
||||||
|
// High means no more information is needed
|
||||||
if (this->pin_aux_->digital_read()) {
|
if (this->pin_aux_->digital_read()) {
|
||||||
// If it is high then all good and settings have been saved
|
if (!this->starting_to_check_ == 0 && !this->time_out_after_ == 0) {
|
||||||
if (this->starting_to_check_ != 0) {
|
|
||||||
this->starting_to_check_ = 0;
|
this->starting_to_check_ = 0;
|
||||||
}
|
|
||||||
if (this->time_out_after_ != 0) {
|
|
||||||
this->time_out_after_ = 0;
|
this->time_out_after_ = 0;
|
||||||
|
ESP_LOGD(TAG, "Aux pin is High! Can send again!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "Aux pin is still LOW! Have to wait before sending message");
|
// it has taken too long to complete, error out!
|
||||||
|
if ((millis() - this->starting_to_check_) > this->time_out_after_) {
|
||||||
|
ESP_LOGD(TAG, "Timeout error! Resetting timers");
|
||||||
|
this->starting_to_check_ = 0;
|
||||||
|
this->time_out_after_ = 0;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue