mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 16:01:43 +01:00
and update
This commit is contained in:
parent
3d4e589bcb
commit
752fdeff90
2 changed files with 6 additions and 0 deletions
|
@ -3,12 +3,16 @@
|
|||
namespace esphome {
|
||||
namespace lora {
|
||||
void Lora::update() {
|
||||
if (!this->update_needed_)
|
||||
return;
|
||||
if (this->rssi_sensor_ != nullptr)
|
||||
this->rssi_sensor_->publish_state(this->rssi_);
|
||||
|
||||
// raw info
|
||||
if (this->message_text_sensor_ != nullptr)
|
||||
this->message_text_sensor_->publish_state(this->raw_message_);
|
||||
// reset the updater
|
||||
this->update_needed_ = false;
|
||||
}
|
||||
void Lora::setup() {
|
||||
this->pin_aux_->setup();
|
||||
|
@ -157,6 +161,7 @@ void Lora::loop() {
|
|||
data.push_back(c);
|
||||
}
|
||||
}
|
||||
this->update_needed_ = true;
|
||||
ESP_LOGD(TAG, "Got %s", buffer.c_str());
|
||||
if (!data.empty()) {
|
||||
ESP_LOGD(TAG, "Found pin data!");
|
||||
|
|
|
@ -54,6 +54,7 @@ class Lora : public PollingComponent, public uart::UARTDevice {
|
|||
bool send_pin_info_(uint8_t pin, bool value);
|
||||
|
||||
protected:
|
||||
bool update_needed_ = false;
|
||||
int rssi_ = 0;
|
||||
float latitude_ = -1;
|
||||
float longitude_ = -1;
|
||||
|
|
Loading…
Reference in a new issue