mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 07:58:09 +01:00
more stuff for the repeater
This commit is contained in:
parent
38b68aec1d
commit
80375e6a07
2 changed files with 11 additions and 1 deletions
|
@ -405,12 +405,15 @@ void EbyteLoraComponent::loop() {
|
|||
ESP_LOGD(TAG, "%u", data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// starting info loop
|
||||
if (data[0] == SWITCH_INFO) {
|
||||
if (this->repeater_) {
|
||||
this->repeat_message(data);
|
||||
}
|
||||
// it is it's own info
|
||||
// only configs with switches should sent too
|
||||
#ifdef USE_SWITCH
|
||||
// Make sure it is not itself
|
||||
if (network_id != data[1]) {
|
||||
ESP_LOGD(TAG, "Got switch info");
|
||||
for (int i = 2; i < data.size(); i = i + 2) {
|
||||
|
@ -422,6 +425,7 @@ void EbyteLoraComponent::loop() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
this->rssi_sensor_->publish_state((data[data.size() - 1] / 255.0) * 100);
|
||||
ESP_LOGD(TAG, "RSSI: %f", (data[data.size() - 1] / 255.0) * 100);
|
||||
|
@ -475,6 +479,7 @@ void EbyteLoraComponent::setup_conf_(std::vector<uint8_t> data) {
|
|||
}
|
||||
|
||||
void EbyteLoraComponent::send_switch_info_() {
|
||||
#ifdef USE_SWITCH
|
||||
if (!this->can_send_message_()) {
|
||||
return;
|
||||
}
|
||||
|
@ -488,6 +493,7 @@ void EbyteLoraComponent::send_switch_info_() {
|
|||
ESP_LOGD(TAG, "Sending switch info");
|
||||
this->write_array(data);
|
||||
this->setup_wait_response_(5000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EbyteLoraComponent::send_repeater_info() {
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include "esphome/components/uart/uart.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_SWITCH
|
||||
#include "esphome/components/switch/switch.h"
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace ebyte_lora {
|
||||
|
@ -88,6 +90,7 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
|||
InternalGPIOPin *pin_m0_{nullptr};
|
||||
InternalGPIOPin *pin_m1_{nullptr};
|
||||
};
|
||||
#ifdef USE_SWITCH
|
||||
class EbyteLoraSwitch : public switch_::Switch, public Parented<EbyteLoraComponent> {
|
||||
public:
|
||||
void set_pin(uint8_t pin) { pin_ = pin; }
|
||||
|
@ -97,5 +100,6 @@ class EbyteLoraSwitch : public switch_::Switch, public Parented<EbyteLoraCompone
|
|||
void write_state(bool state) override { this->parent_->send_switch_info_(); }
|
||||
uint8_t pin_;
|
||||
};
|
||||
#endif
|
||||
} // namespace ebyte_lora
|
||||
} // namespace esphome
|
||||
|
|
Loading…
Reference in a new issue