Set info receiver!

This commit is contained in:
Daniël Koek 2024-05-17 21:26:11 +01:00
parent a7575a1f73
commit 2bb9061fe1
3 changed files with 7 additions and 4 deletions

View file

@ -101,7 +101,7 @@ CONF_ENABLE_LBT = "enable_lbt"
CONF_RSSI_NOISE = "rssi_noise"
CONF_UART_PARITY = "uart_parity"
CONF_SUB_PACKET = "sub_packet"
CONF_SWITCH_INFO_RECEIVER = "switch_info_receiver"
CONFIG_SCHEMA = (
cv.Schema(
{
@ -112,6 +112,7 @@ CONFIG_SCHEMA = (
cv.Required(CONF_PIN_M0): pins.internal_gpio_output_pin_schema,
# for communication set the mode
cv.Required(CONF_PIN_M1): pins.internal_gpio_output_pin_schema,
cv.Optional(CONF_SWITCH_INFO_RECEIVER, default=False): cv.boolean,
# if you want to see the rssi
cv.Optional(CONF_LORA_RSSI): sensor.sensor_schema(
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
@ -174,6 +175,7 @@ async def to_code(config):
cg.add(var.set_pin_m0(pin_m0))
pin_m1 = await cg.gpio_pin_expression(config[CONF_PIN_M1])
cg.add(var.set_pin_m1(pin_m1))
cg.add(var.set_switch_info_receiver(config[CONF_SWITCH_INFO_RECEIVER]))
cg.add(var.set_addh(config[CONF_ADDH]))
cg.add(var.set_addl(config[CONF_ADDL]))
cg.add(var.set_air_data_rate(config[CONF_AIR_DATA_RATE]))

View file

@ -224,8 +224,8 @@ void EbyteLoraComponent::update() {
ESP_LOGD(TAG, "Mode is not set right");
this->set_mode_(NORMAL);
}
this->send_switch_info_();
if (!this->switch_info_receiver_)
this->send_switch_info_();
}
void EbyteLoraComponent::set_config_() {
uint8_t data[11];
@ -423,7 +423,6 @@ void EbyteLoraComponent::loop() {
sensor->publish_state(data[2]);
}
}
send_switch_info_();
}
// starting info loop
if (data[0] == SWITCH_INFO) {

View file

@ -48,6 +48,7 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
void set_enable_lbt(EnableByte enable) { expected_config_.enable_lbt = enable; }
void set_transmission_mode(TransmissionMode mode) { expected_config_.transmission_mode = mode; }
void set_enable_rssi(EnableByte enable) { expected_config_.enable_rssi = enable; }
void set_switch_info_receiver(bool enable) { switch_info_receiver_ = enable; }
private:
std::vector<EbyteLoraSwitch *> sensors_;
@ -67,6 +68,7 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
protected:
bool update_needed_ = false;
bool switch_info_receiver_ = false;
int rssi_ = 0;
uint32_t starting_to_check_;
uint32_t time_out_after_;