mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 09:44:12 +01:00
More stuff to try
This commit is contained in:
parent
2640bd873f
commit
6b224112d6
2 changed files with 10 additions and 15 deletions
|
@ -125,21 +125,16 @@ void Lora::dump_config() {
|
||||||
LOG_PIN("M1 Pin:", this->pin_m1);
|
LOG_PIN("M1 Pin:", this->pin_m1);
|
||||||
};
|
};
|
||||||
void Lora::digital_write(uint8_t pin, bool value) {
|
void Lora::digital_write(uint8_t pin, bool value) {
|
||||||
ESP_LOGD(TAG, "Starting to write message");
|
ESP_LOGD(TAG, "Setting internal state");
|
||||||
std::string message = str_snprintf("%02x%02x", 9, pin, value);
|
this->sendPinInfo(pin, value);
|
||||||
this->sendMessage(message);
|
|
||||||
}
|
}
|
||||||
bool Lora::sendMessage(std::string message) {
|
bool Lora::sendPinInfo(uint8_t pin, bool value) {
|
||||||
uint8_t size = message.length();
|
uint8_t request_message[3];
|
||||||
char messageFixed[size];
|
request_message[1] = 0xA5; // just some bit to indicate, yo this is pin info
|
||||||
memcpy(messageFixed, message.c_str(), size);
|
request_message[1] = pin; // Pin to send
|
||||||
if (size > MAX_SIZE_TX_PACKET + 2) {
|
request_message[2] = value; // high or low
|
||||||
ESP_LOGD(TAG, "Package to big");
|
this->write_array(request_message, sizeof(request_message));
|
||||||
return false;
|
this->flush();
|
||||||
}
|
|
||||||
ESP_LOGD(TAG, "Sending: %s", message);
|
|
||||||
this->write_array((uint8_t *) &messageFixed, size);
|
|
||||||
// bool result = this->waitCompleteResponse(5000, 5000);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void Lora::loop() {
|
void Lora::loop() {
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Lora : public PollingComponent, public uart::UARTDevice {
|
||||||
bool setMode(MODE_TYPE type);
|
bool setMode(MODE_TYPE type);
|
||||||
// checks the aux port to see if it is done setting
|
// checks the aux port to see if it is done setting
|
||||||
bool waitCompleteResponse(unsigned long timeout = 1000, unsigned int waitNoAux = 100);
|
bool waitCompleteResponse(unsigned long timeout = 1000, unsigned int waitNoAux = 100);
|
||||||
bool sendMessage(std::string message);
|
bool sendPinInfo(uint8_t pin, bool value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int rssi_ = 0;
|
int rssi_ = 0;
|
||||||
|
|
Loading…
Reference in a new issue