Update ebyte_lora.cpp

This commit is contained in:
Daniël Koek 2024-03-29 13:45:50 +00:00
parent 3ce9c5d0b5
commit ae8cb94bd2

View file

@ -5,15 +5,16 @@ static const uint8_t SWITCH_PUSH = 0x55;
static const uint8_t SWITCH_INFO = 0x66; static const uint8_t SWITCH_INFO = 0x66;
static const uint8_t PROGRAM_CONF = 0xC1; static const uint8_t PROGRAM_CONF = 0xC1;
void EbyteLoraComponent::update() { void EbyteLoraComponent::update() {
if (get_mode_() != NORMAL) {
if (this->config.command == 0) { if (this->config.command == 0) {
ESP_LOGD(TAG, "Config not set yet!, gonna request it now!"); ESP_LOGD(TAG, "Config not set yet!, gonna request it now!");
get_current_config_(); get_current_config_();
return; return;
} }
if (get_mode_() != NORMAL) {
ESP_LOGD(TAG, "Mode was not set right"); ESP_LOGD(TAG, "Mode was not set right");
set_mode_(NORMAL); set_mode_(NORMAL);
} }
send_switch_info_(); send_switch_info_();
} }
void EbyteLoraComponent::setup() { void EbyteLoraComponent::setup() {
@ -59,19 +60,19 @@ ModeType EbyteLoraComponent::get_mode_() {
bool pin1 = this->pin_m0_->digital_read(); bool pin1 = this->pin_m0_->digital_read();
bool pin2 = this->pin_m1_->digital_read(); bool pin2 = this->pin_m1_->digital_read();
if (!pin1 && !pin2) { if (!pin1 && !pin2) {
ESP_LOGD(TAG, "MODE NORMAL!"); // ESP_LOGD(TAG, "MODE NORMAL!");
internalMode = NORMAL; internalMode = NORMAL;
} }
if (pin1 && !pin2) { if (pin1 && !pin2) {
ESP_LOGD(TAG, "MODE WOR!"); // ESP_LOGD(TAG, "MODE WOR!");
internalMode = WOR_SEND; internalMode = WOR_SEND;
} }
if (!pin1 && pin2) { if (!pin1 && pin2) {
ESP_LOGD(TAG, "MODE WOR!"); // ESP_LOGD(TAG, "MODE WOR!");
internalMode = WOR_RECEIVER; internalMode = WOR_RECEIVER;
} }
if (pin1 && pin2) { if (pin1 && pin2) {
ESP_LOGD(TAG, "MODE Conf!"); // ESP_LOGD(TAG, "MODE Conf!");
internalMode = CONFIGURATION; internalMode = CONFIGURATION;
} }
if (internalMode != this->mode_) { if (internalMode != this->mode_) {