From 6cb48460b69aab35432087764470d2eaadac6a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Sun, 24 Mar 2024 17:53:59 +0000 Subject: [PATCH] Update lora.cpp --- esphome/components/lora/lora.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/esphome/components/lora/lora.cpp b/esphome/components/lora/lora.cpp index d1d5f41edf..efa9533aea 100644 --- a/esphome/components/lora/lora.cpp +++ b/esphome/components/lora/lora.cpp @@ -126,23 +126,23 @@ void Lora::dump_config() { }; void Lora::digital_write(uint8_t pin, bool value) { this->sendPinInfo(pin, value); } bool Lora::sendPinInfo(uint8_t pin, bool value) { - uint8_t request_message[3]; - request_message[1] = 0xA5; // just some bit to indicate, yo this is pin info - request_message[1] = pin; // Pin to send - request_message[2] = value; // high or low - this->write_array(request_message, sizeof(request_message)); - this->flush(); + uint8_t data[3]; + data[1] = 0xA5; // just some bit to indicate, yo this is pin info + data[1] = pin; // Pin to send + data[2] = value; // high or low + ESP_LOGD(TAG, "Sending message"); + ESP_LOGD(TAG, "PIN: %u ", data[1]); + ESP_LOGD(TAG, "VALUE: %u ", data[2]); + this->write_array(data, sizeof(data)); + bool result = this->waitCompleteResponse(5000, 5000); return true; } void Lora::loop() { - if (!available()) { - return; - } std::string buffer; std::vector data; bool pin_data_found = false; - ESP_LOGD(TAG, "Starting to read message"); - while (available()) { + ESP_LOGD(TAG, "Starting to check for messages"); + while (this->available()) { uint8_t c; if (this->read_byte(&c)) { buffer += (char) c;