From 5be241d1c09ea6f8aca4ee7bd07a38c5e63ccd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Mon, 8 Apr 2024 19:37:39 +0100 Subject: [PATCH] not sure if this is it! --- esphome/components/ebyte_lora/config.h | 6 +++--- esphome/components/ebyte_lora/ebyte_lora.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/esphome/components/ebyte_lora/config.h b/esphome/components/ebyte_lora/config.h index 916852e808..7b11faf55e 100644 --- a/esphome/components/ebyte_lora/config.h +++ b/esphome/components/ebyte_lora/config.h @@ -56,8 +56,8 @@ struct RegisterConfig { uint8_t command : 8; uint8_t starting_address : 8; uint8_t length : 8; - int addh : 8; - int addl : 8; + uint8_t addh : 8; + uint8_t addl : 8; struct { uint8_t air_data_rate : 3; uint8_t parity : 2; @@ -71,7 +71,7 @@ struct RegisterConfig { uint8_t sub_packet : 2; } reg_1; // reg2 - int channel : 8; + uint8_t channel : 8; struct { uint8_t wor_period : 3; uint8_t reserve1 : 1; diff --git a/esphome/components/ebyte_lora/ebyte_lora.cpp b/esphome/components/ebyte_lora/ebyte_lora.cpp index ee6e6e46e0..f7cb751399 100644 --- a/esphome/components/ebyte_lora/ebyte_lora.cpp +++ b/esphome/components/ebyte_lora/ebyte_lora.cpp @@ -350,7 +350,9 @@ void EbyteLoraComponent::loop() { } if (data[0] == PROGRAM_CONF) { ESP_LOGD(TAG, "GOT PROGRAM_CONF"); - memcpy(&this->config, &data, data.size()); + auto *sbuff = reinterpret_cast(&data); + memset(&this->config, 0, sizeof(RegisterConfig)); + memcpy(&this->config, sbuff, sbuff->length); set_mode_(NORMAL); } }