mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
reworks because of 'tx_mode 2' and protocol issues
° added markers (GIO12, GPIO14) for logic analyzer debugging
° change UART initialisation
- set RxFIFO full to 1 char, so we can detect active telegram on EMS-Bus
- set RxTOT to 1 char for the same reason
° in ems_parseTelegram: ignore telegram if emsRxStatus != EMS_RX_STATUS_IDLE
because we missed to respond in a timely manner
° ems_tx_buffer is not void anymore, instead we return the Tx status
° extended the emsTxStatus
- EMS_TX_WTD_TIMEOUT: timeout while waiting for echo of last Tx byte
out telegram was ignored by the bus master, so the byte wasn't echoed
- EMS_TX_BRK_DETECT: BRK detected while sending the telegram
bus master send us a break because of protocol violation
° add burnStarts, burnWorkMin and heatWorkMin to MQTT boiler message
TODO:
+ take care of ems_tx_buffer return code
+ accept direct telegram in ems_parse_telegram and do a proper acknowledge
+ split the heartbeat in static (version, IP-address) and dynamic (RSS etc)
+ change the hearbeat to a JSON structure so we can easier pick the uptime
This commit is contained in:
21
src/ems.cpp
21
src/ems.cpp
@@ -724,9 +724,23 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
||||
EMS_RxTelegram.timestamp = millis();
|
||||
EMS_RxTelegram.length = length;
|
||||
|
||||
// check if we just received a single byte
|
||||
// it could well be a Poll request from the boiler for us, which will have a value of 0x8B (0x0B | 0x80)
|
||||
// or either a return code like 0x01 or 0x04 from the last Write command
|
||||
/*
|
||||
* check if we just received a single byte
|
||||
* it could well be a Poll request from the boiler for us, which will have a value of 0x8B (0x0B | 0x80)
|
||||
* or either a return code like 0x01 or 0x04 from the last Write command
|
||||
* Roger Wilco: we have different types here:
|
||||
* EMS_ID_ME && length == 1 && EMS_TX_STATUS_IDLE && EMS_RX_STATUS_IDLE: polling request
|
||||
* EMS_ID_ME && length > 1 && EMS_TX_STATUS_IDLE && EMS_RX_STATUS_IDLE: direct telegram
|
||||
* (EMS_TX_SUCCESS || EMS_TX_ERROR) && EMS_TX_STATUS_WAIT: response, free the EMS bus
|
||||
*
|
||||
* In addition, it may happen that we where interrupted (f.e. by WIFI activity) and the
|
||||
* buffer isn't valid anymore, so we must not answer at all...
|
||||
*/
|
||||
if (EMS_Sys_Status.emsRxStatus != EMS_RX_STATUS_IDLE) {
|
||||
myDebug_P(PSTR("** We missed the bus - Rx non-idle!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (length == 1) {
|
||||
uint8_t value = telegram[0]; // 1st byte of data package
|
||||
|
||||
@@ -816,6 +830,7 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
||||
// Assume at this point we have something that vaguely resembles a telegram in the format [src] [dest] [type] [offset] [data] [crc]
|
||||
// validate the CRC, if it's bad ignore it
|
||||
if (telegram[length - 1] != _crcCalculator(telegram, length)) {
|
||||
LA_PULSE(200);
|
||||
EMS_Sys_Status.emxCrcErr++;
|
||||
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
|
||||
_debugPrintTelegram("Corrupt telegram: ", &EMS_RxTelegram, COLOR_RED, true);
|
||||
|
||||
Reference in New Issue
Block a user