code suggestions

This commit is contained in:
Daniël Koek 2024-04-25 10:38:35 +01:00
parent eb3d5b8953
commit 6d4f491b49

View file

@ -270,7 +270,7 @@ bool EbyteLoraComponent::can_send_message_() {
} }
void EbyteLoraComponent::setup_wait_response_(uint32_t timeout) { void EbyteLoraComponent::setup_wait_response_(uint32_t timeout) {
if (this->starting_to_check_ != 0 || this->time_out_after_ != 0) { if (!(this->starting_to_check_ == 0) && !(this->time_out_after_ == 0)) {
ESP_LOGD(TAG, "Wait response already set!! %u", timeout); ESP_LOGD(TAG, "Wait response already set!! %u", timeout);
} }
ESP_LOGD(TAG, "Setting a timer for %u", timeout); ESP_LOGD(TAG, "Setting a timer for %u", timeout);
@ -314,10 +314,10 @@ void EbyteLoraComponent::loop() {
if (data[0] == SWITCH_PUSH) { if (data[0] == SWITCH_PUSH) {
ESP_LOGD(TAG, "GOT SWITCH PUSH", data.size()); ESP_LOGD(TAG, "GOT SWITCH PUSH", data.size());
ESP_LOGD(TAG, "Total: %u", data.size()); ESP_LOGD(TAG, "Total: %u", data.size());
ESP_LOGD(TAG, "Start bit: ", data[0]); ESP_LOGD(TAG, "Start bit: %u", data[0]);
ESP_LOGD(TAG, "PIN: %u", data[1]); ESP_LOGD(TAG, "PIN: %u", data[1]);
ESP_LOGD(TAG, "VALUE: %u", data[2]); ESP_LOGD(TAG, "VALUE: %u", data[2]);
ESP_LOGD(TAG, "RSSI: %u % ", (data[3] / 255.0) * 100); ESP_LOGD(TAG, "RSSI: %f %", (data[3] / 255.0) * 100);
if (this->rssi_sensor_ != nullptr) if (this->rssi_sensor_ != nullptr)
this->rssi_sensor_->publish_state((data[3] / 255.0) * 100); this->rssi_sensor_->publish_state((data[3] / 255.0) * 100);
@ -344,7 +344,7 @@ void EbyteLoraComponent::loop() {
} }
} }
this->rssi_sensor_->publish_state((data[data.size() - 1] / 255.0) * 100); this->rssi_sensor_->publish_state((data[data.size() - 1] / 255.0) * 100);
ESP_LOGD(TAG, "RSSI: %u % ", (data[data.size() - 1] / 255.0) * 100); ESP_LOGD(TAG, "RSSI: %f %", (data[data.size() - 1] / 255.0) * 100);
} }
if (data[0] == PROGRAM_CONF) { if (data[0] == PROGRAM_CONF) {
ESP_LOGD(TAG, "GOT PROGRAM_CONF"); ESP_LOGD(TAG, "GOT PROGRAM_CONF");