mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
ESP32 Rx fixes - (v2) ESP8266 & ESP32 UART optimizations #398
This commit is contained in:
@@ -811,11 +811,12 @@ void EMSESP::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
system_.loop(); // does LED and checks system health, and syslog service
|
system_.loop(); // does LED and checks system health, and syslog service
|
||||||
shower_.loop(); // check for shower on/off
|
shower_.loop(); // check for shower on/off
|
||||||
sensors_.loop(); // this will also send out via MQTT
|
sensors_.loop(); // this will also send out via MQTT
|
||||||
mqtt_.loop(); // sends out anything in the queue via MQTT
|
mqtt_.loop(); // sends out anything in the queue via MQTT
|
||||||
console_.loop(); // telnet/serial console
|
console_.loop(); // telnet/serial console
|
||||||
|
rxservice_.loop(); // process any incoming Rx telegrams
|
||||||
|
|
||||||
// force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
// force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
||||||
if ((uuid::get_uptime() - last_fetch_ > EMS_FETCH_FREQUENCY)) {
|
if ((uuid::get_uptime() - last_fetch_ > EMS_FETCH_FREQUENCY)) {
|
||||||
|
|||||||
@@ -127,6 +127,15 @@ std::string Telegram::to_string_message() const {
|
|||||||
return Helpers::data_to_hex(this->message_data, this->message_length);
|
return Helpers::data_to_hex(this->message_data, this->message_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checks if we have an Rx telegram that needs processing
|
||||||
|
void RxService::loop() {
|
||||||
|
if (rx_telegram) {
|
||||||
|
EMSESP::process_telegram(rx_telegram);
|
||||||
|
rx_telegram = nullptr; // telegram has been processed, reset
|
||||||
|
increment_telegram_count(); // increase rx count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add a new rx telegram object
|
// add a new rx telegram object
|
||||||
// data is the whole telegram, assuming last byte holds the CRC
|
// data is the whole telegram, assuming last byte holds the CRC
|
||||||
// length includes the CRC
|
// length includes the CRC
|
||||||
@@ -205,10 +214,6 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
|||||||
|
|
||||||
// create the telegram
|
// create the telegram
|
||||||
rx_telegram = std::make_shared<Telegram>(Telegram::Operation::RX, src, dest, type_id, offset, message_data, message_length);
|
rx_telegram = std::make_shared<Telegram>(Telegram::Operation::RX, src, dest, type_id, offset, message_data, message_length);
|
||||||
|
|
||||||
// process it immediately
|
|
||||||
EMSESP::process_telegram(rx_telegram); // further process the telegram
|
|
||||||
increment_telegram_count(); // increase count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of
|
|||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
// creates a telegram
|
|
||||||
// from Rx (receiving one) or Tx for preparing one for sending
|
|
||||||
class Telegram {
|
class Telegram {
|
||||||
public:
|
public:
|
||||||
Telegram(const uint8_t operation,
|
Telegram(const uint8_t operation,
|
||||||
@@ -198,6 +196,8 @@ class RxService : public EMSbus {
|
|||||||
RxService() = default;
|
RxService() = default;
|
||||||
~RxService() = default;
|
~RxService() = default;
|
||||||
|
|
||||||
|
void loop();
|
||||||
|
|
||||||
void add(uint8_t * data, uint8_t length);
|
void add(uint8_t * data, uint8_t length);
|
||||||
|
|
||||||
uint16_t telegram_count() const {
|
uint16_t telegram_count() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user