mirror of
https://github.com/esphome/esphome.git
synced 2024-12-28 08:21:44 +01:00
Update lora.cpp
This commit is contained in:
parent
850280a582
commit
6cb48460b6
1 changed files with 11 additions and 11 deletions
|
@ -126,23 +126,23 @@ void Lora::dump_config() {
|
||||||
};
|
};
|
||||||
void Lora::digital_write(uint8_t pin, bool value) { this->sendPinInfo(pin, value); }
|
void Lora::digital_write(uint8_t pin, bool value) { this->sendPinInfo(pin, value); }
|
||||||
bool Lora::sendPinInfo(uint8_t pin, bool value) {
|
bool Lora::sendPinInfo(uint8_t pin, bool value) {
|
||||||
uint8_t request_message[3];
|
uint8_t data[3];
|
||||||
request_message[1] = 0xA5; // just some bit to indicate, yo this is pin info
|
data[1] = 0xA5; // just some bit to indicate, yo this is pin info
|
||||||
request_message[1] = pin; // Pin to send
|
data[1] = pin; // Pin to send
|
||||||
request_message[2] = value; // high or low
|
data[2] = value; // high or low
|
||||||
this->write_array(request_message, sizeof(request_message));
|
ESP_LOGD(TAG, "Sending message");
|
||||||
this->flush();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
void Lora::loop() {
|
void Lora::loop() {
|
||||||
if (!available()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
bool pin_data_found = false;
|
bool pin_data_found = false;
|
||||||
ESP_LOGD(TAG, "Starting to read message");
|
ESP_LOGD(TAG, "Starting to check for messages");
|
||||||
while (available()) {
|
while (this->available()) {
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
if (this->read_byte(&c)) {
|
if (this->read_byte(&c)) {
|
||||||
buffer += (char) c;
|
buffer += (char) c;
|
||||||
|
|
Loading…
Reference in a new issue