diff --git a/esphome/components/ebyte_lora/ebyte_lora.cpp b/esphome/components/ebyte_lora/ebyte_lora.cpp index 9890a76f75..df82c27028 100644 --- a/esphome/components/ebyte_lora/ebyte_lora.cpp +++ b/esphome/components/ebyte_lora/ebyte_lora.cpp @@ -10,151 +10,7 @@ void EbyteLoraComponent::update() { this->get_current_config_(); return; } else { - ESP_LOGD(TAG, "Got a config:"); - switch (this->current_config_.air_data_rate) { - case AIR_2_4KB: - ESP_LOGD(TAG, "air_data_rate: 2.4kb"); - break; - case AIR_4_8KB: - ESP_LOGD(TAG, "air_data_rate: 4.8kb"); - break; - case AIR_9_6KB: - ESP_LOGD(TAG, "air_data_rate: 9.6kb"); - break; - case AIR_19_2KB: - ESP_LOGD(TAG, "air_data_rate: 19.2kb"); - break; - case AIR_38_4KB: - ESP_LOGD(TAG, "air_data_rate: 38.4kb"); - break; - case AIR_62_5KB: - ESP_LOGD(TAG, "air_data_rate: 62.5kb"); - break; - } - switch (this->current_config_.uart_baud) { - case UART_1200: - ESP_LOGD(TAG, "uart_baud: 1200"); - break; - case UART_2400: - ESP_LOGD(TAG, "uart_baud: 2400"); - break; - case UART_4800: - ESP_LOGD(TAG, "uart_baud: 4800"); - break; - case UART_9600: - ESP_LOGD(TAG, "uart_baud: 9600"); - break; - case UART_19200: - ESP_LOGD(TAG, "uart_baud: 19200"); - break; - case UART_38400: - ESP_LOGD(TAG, "uart_baud: 38400"); - break; - case UART_57600: - ESP_LOGD(TAG, "uart_baud: 57600"); - break; - case UART_115200: - ESP_LOGD(TAG, "uart_baud: 115200"); - break; - } - switch (this->current_config_.parity) { - case EBYTE_UART_8N1: - ESP_LOGD(TAG, "uart_parity: 8N1"); - break; - case EBYTE_UART_8O1: - ESP_LOGD(TAG, "uart_parity: 8O1"); - break; - case EBYTE_UART_8E1: - ESP_LOGD(TAG, "uart_parity: 8E1"); - break; - } - switch (this->current_config_.rssi_noise) { - case EBYTE_ENABLED: - ESP_LOGD(TAG, "rssi_noise: ENABLED"); - break; - case EBYTE_DISABLED: - ESP_LOGD(TAG, "rssi_noise: DISABLED"); - break; - } - switch (this->current_config_.sub_packet) { - case SUB_200B: - ESP_LOGD(TAG, "sub_packet: 200 bytes"); - break; - case SUB_128B: - ESP_LOGD(TAG, "sub_packet: 128 bytes"); - break; - case SUB_64B: - ESP_LOGD(TAG, "sub_packet: 64 bytes"); - break; - case SUB_32B: - ESP_LOGD(TAG, "sub_packet: 32 bytes"); - break; - } - switch (this->current_config_.transmission_power) { - case TX_DEFAULT_MAX: - ESP_LOGD(TAG, "transmission_power: default or max"); - break; - case TX_LOWER: - ESP_LOGD(TAG, "transmission_power: lower"); - break; - case TX_EVEN_LOWER: - ESP_LOGD(TAG, "transmission_power: even lower"); - break; - case TX_LOWEST: - ESP_LOGD(TAG, "transmission_power: Lowest"); - break; - } - ESP_LOGD(TAG, "channel: %u", this->current_config_.channel); - switch (this->current_config_.enable_lbt) { - case EBYTE_ENABLED: - ESP_LOGD(TAG, "enable_lbt: ENABLED"); - break; - case EBYTE_DISABLED: - ESP_LOGD(TAG, "enable_lbt: DISABLED"); - break; - } - switch (this->current_config_.transmission_mode) { - case TRANSPARENT: - ESP_LOGD(TAG, "transmission_type: TRANSPARENT"); - break; - case FIXED: - ESP_LOGD(TAG, "transmission_type: FIXED"); - break; - } - switch (this->current_config_.enable_rssi) { - case EBYTE_ENABLED: - ESP_LOGD(TAG, "enable_rssi: ENABLED"); - break; - case EBYTE_DISABLED: - ESP_LOGD(TAG, "enable_rssi: DISABLED"); - break; - } - switch (this->current_config_.wor_period) { - case WOR_500: - ESP_LOGD(TAG, "wor_period: 500"); - break; - case WOR_1000: - ESP_LOGD(TAG, "wor_period: 1000"); - break; - case WOR_1500: - ESP_LOGD(TAG, "wor_period: 1500"); - break; - case WOR_2000: - ESP_LOGD(TAG, "wor_period: 2000"); - break; - case WOR_2500: - ESP_LOGD(TAG, "wor_period: 2500"); - break; - case WOR_3000: - ESP_LOGD(TAG, "wor_period: 3000"); - break; - case WOR_3500: - ESP_LOGD(TAG, "wor_period: 3500"); - break; - case WOR_4000: - ESP_LOGD(TAG, "wor_period: 4000"); - break; - } + ESP_LOGD(TAG, "Checking config"); } if (this->get_mode_() != NORMAL) { ESP_LOGD(TAG, "Mode was not set right"); @@ -279,6 +135,150 @@ void EbyteLoraComponent::setup_wait_response_(uint32_t timeout) { } void EbyteLoraComponent::dump_config() { ESP_LOGCONFIG(TAG, "Ebyte Lora E220"); + switch (this->current_config_.air_data_rate) { + case AIR_2_4KB: + ESP_LOGD(TAG, "air_data_rate: 2.4kb"); + break; + case AIR_4_8KB: + ESP_LOGD(TAG, "air_data_rate: 4.8kb"); + break; + case AIR_9_6KB: + ESP_LOGD(TAG, "air_data_rate: 9.6kb"); + break; + case AIR_19_2KB: + ESP_LOGD(TAG, "air_data_rate: 19.2kb"); + break; + case AIR_38_4KB: + ESP_LOGD(TAG, "air_data_rate: 38.4kb"); + break; + case AIR_62_5KB: + ESP_LOGD(TAG, "air_data_rate: 62.5kb"); + break; + } + switch (this->current_config_.uart_baud) { + case UART_1200: + ESP_LOGD(TAG, "uart_baud: 1200"); + break; + case UART_2400: + ESP_LOGD(TAG, "uart_baud: 2400"); + break; + case UART_4800: + ESP_LOGD(TAG, "uart_baud: 4800"); + break; + case UART_9600: + ESP_LOGD(TAG, "uart_baud: 9600"); + break; + case UART_19200: + ESP_LOGD(TAG, "uart_baud: 19200"); + break; + case UART_38400: + ESP_LOGD(TAG, "uart_baud: 38400"); + break; + case UART_57600: + ESP_LOGD(TAG, "uart_baud: 57600"); + break; + case UART_115200: + ESP_LOGD(TAG, "uart_baud: 115200"); + break; + } + switch (this->current_config_.parity) { + case EBYTE_UART_8N1: + ESP_LOGD(TAG, "uart_parity: 8N1"); + break; + case EBYTE_UART_8O1: + ESP_LOGD(TAG, "uart_parity: 8O1"); + break; + case EBYTE_UART_8E1: + ESP_LOGD(TAG, "uart_parity: 8E1"); + break; + } + switch (this->current_config_.rssi_noise) { + case EBYTE_ENABLED: + ESP_LOGD(TAG, "rssi_noise: ENABLED"); + break; + case EBYTE_DISABLED: + ESP_LOGD(TAG, "rssi_noise: DISABLED"); + break; + } + switch (this->current_config_.sub_packet) { + case SUB_200B: + ESP_LOGD(TAG, "sub_packet: 200 bytes"); + break; + case SUB_128B: + ESP_LOGD(TAG, "sub_packet: 128 bytes"); + break; + case SUB_64B: + ESP_LOGD(TAG, "sub_packet: 64 bytes"); + break; + case SUB_32B: + ESP_LOGD(TAG, "sub_packet: 32 bytes"); + break; + } + switch (this->current_config_.transmission_power) { + case TX_DEFAULT_MAX: + ESP_LOGD(TAG, "transmission_power: default or max"); + break; + case TX_LOWER: + ESP_LOGD(TAG, "transmission_power: lower"); + break; + case TX_EVEN_LOWER: + ESP_LOGD(TAG, "transmission_power: even lower"); + break; + case TX_LOWEST: + ESP_LOGD(TAG, "transmission_power: Lowest"); + break; + } + ESP_LOGD(TAG, "channel: %u", this->current_config_.channel); + switch (this->current_config_.enable_lbt) { + case EBYTE_ENABLED: + ESP_LOGD(TAG, "enable_lbt: ENABLED"); + break; + case EBYTE_DISABLED: + ESP_LOGD(TAG, "enable_lbt: DISABLED"); + break; + } + switch (this->current_config_.transmission_mode) { + case TRANSPARENT: + ESP_LOGD(TAG, "transmission_type: TRANSPARENT"); + break; + case FIXED: + ESP_LOGD(TAG, "transmission_type: FIXED"); + break; + } + switch (this->current_config_.enable_rssi) { + case EBYTE_ENABLED: + ESP_LOGD(TAG, "enable_rssi: ENABLED"); + break; + case EBYTE_DISABLED: + ESP_LOGD(TAG, "enable_rssi: DISABLED"); + break; + } + switch (this->current_config_.wor_period) { + case WOR_500: + ESP_LOGD(TAG, "wor_period: 500"); + break; + case WOR_1000: + ESP_LOGD(TAG, "wor_period: 1000"); + break; + case WOR_1500: + ESP_LOGD(TAG, "wor_period: 1500"); + break; + case WOR_2000: + ESP_LOGD(TAG, "wor_period: 2000"); + break; + case WOR_2500: + ESP_LOGD(TAG, "wor_period: 2500"); + break; + case WOR_3000: + ESP_LOGD(TAG, "wor_period: 3000"); + break; + case WOR_3500: + ESP_LOGD(TAG, "wor_period: 3500"); + break; + case WOR_4000: + ESP_LOGD(TAG, "wor_period: 4000"); + break; + } LOG_PIN("Aux pin:", this->pin_aux_); LOG_PIN("M0 Pin:", this->pin_m0_); LOG_PIN("M1 Pin:", this->pin_m1_); @@ -312,12 +312,12 @@ void EbyteLoraComponent::loop() { } // if it is only push info if (data[0] == SWITCH_PUSH) { - ESP_LOGD(TAG, "GOT SWITCH PUSH", data.size()); + ESP_LOGD(TAG, "GOT SWITCH PUSH"); ESP_LOGD(TAG, "Total: %u", data.size()); ESP_LOGD(TAG, "Start bit: %u", data[0]); ESP_LOGD(TAG, "PIN: %u", data[1]); ESP_LOGD(TAG, "VALUE: %u", data[2]); - ESP_LOGD(TAG, "RSSI: %f %", (data[3] / 255.0) * 100); + ESP_LOGD(TAG, "RSSI: %f", (data[3] / 255.0) * 100); if (this->rssi_sensor_ != nullptr) this->rssi_sensor_->publish_state((data[3] / 255.0) * 100); @@ -333,7 +333,7 @@ void EbyteLoraComponent::loop() { if (data[0] == SWITCH_INFO) { for (int i = 0; i < data.size(); i++) { if (data[i] == SWITCH_INFO) { - ESP_LOGD(TAG, "GOT INFO", data.size()); + ESP_LOGD(TAG, "GOT INFO"); uint8_t pin = data[i + 1]; bool value = data[i + 2]; for (auto *sensor : this->sensors_) { @@ -344,7 +344,7 @@ void EbyteLoraComponent::loop() { } } this->rssi_sensor_->publish_state((data[data.size() - 1] / 255.0) * 100); - ESP_LOGD(TAG, "RSSI: %f %", (data[data.size() - 1] / 255.0) * 100); + ESP_LOGD(TAG, "RSSI: %f", (data[data.size() - 1] / 255.0) * 100); } if (data[0] == PROGRAM_CONF) { ESP_LOGD(TAG, "GOT PROGRAM_CONF");