mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
tidy up debugging
This commit is contained in:
28
src/ems.cpp
28
src/ems.cpp
@@ -269,18 +269,11 @@ void _debugPrintTelegram(const char * prefix, uint8_t * data, uint8_t len, const
|
|||||||
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_VERBOSE)
|
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_VERBOSE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool crcok = (data[len - 1] == _crcCalculator(data, len));
|
myDebug("%s%s len=%d, telegram: ", color, prefix, len);
|
||||||
if (crcok) {
|
|
||||||
myDebug(color);
|
|
||||||
} else {
|
|
||||||
myDebug(COLOR_RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
myDebug("%s len=%d, data: ", prefix, len);
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
myDebug("%02x ", data[i]);
|
myDebug("%02x ", data[i]);
|
||||||
}
|
}
|
||||||
myDebug("(%s) %s\n", crcok ? "OK" : "BAD", COLOR_RESET);
|
myDebug("%s\n", COLOR_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the contents of the Tx buffer
|
// send the contents of the Tx buffer
|
||||||
@@ -497,6 +490,16 @@ void _processType(uint8_t * telegram, uint8_t length) {
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the data at the position we wrote to and compare
|
||||||
|
// when validating we always return a single value
|
||||||
|
if (EMS_TxTelegram.checkValue == data[offset]) {
|
||||||
|
// there is a match, so successful send
|
||||||
|
EMS_Sys_Status.emsRefreshed = true; // flag this so values are sent back to HA via MQTT
|
||||||
|
EMS_TxTelegram.action = EMS_TX_NONE; // no more sends
|
||||||
|
}
|
||||||
|
|
||||||
|
// some debug messages
|
||||||
|
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_NONE) {
|
||||||
// look up the ID and fetch string
|
// look up the ID and fetch string
|
||||||
int i = ems_findType(EMS_TxTelegram.type);
|
int i = ems_findType(EMS_TxTelegram.type);
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
@@ -509,17 +512,14 @@ void _processType(uint8_t * telegram, uint8_t length) {
|
|||||||
myDebug("---> ?(0x%02x) sent with value %d at offset %d ", type, EMS_TxTelegram.checkValue, offset);
|
myDebug("---> ?(0x%02x) sent with value %d at offset %d ", type, EMS_TxTelegram.checkValue, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the data at the position we wrote to and compare
|
|
||||||
// when validating we always return a single value
|
|
||||||
if (EMS_TxTelegram.checkValue == data[offset]) {
|
if (EMS_TxTelegram.checkValue == data[offset]) {
|
||||||
myDebug("(successful)\n");
|
myDebug("(successful)\n");
|
||||||
EMS_Sys_Status.emsRefreshed = true; // flag this so values are sent back to HA via MQTT
|
|
||||||
EMS_TxTelegram.action = EMS_TX_NONE; // no more sends
|
|
||||||
} else {
|
} else {
|
||||||
myDebug("(failed, received %d)\n", data[offset]);
|
myDebug("(failed, received %d)\n", data[offset]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Report back true if there is a package pending a write in the queue
|
* Report back true if there is a package pending a write in the queue
|
||||||
@@ -773,7 +773,7 @@ void ems_setThermostatTemp(float temperature) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the thermostat working mode (0=low, 1=manual, 2=clock/auto)
|
* Set the thermostat working mode (0=low, 1=manual, 2=auto)
|
||||||
*/
|
*/
|
||||||
void ems_setThermostatMode(uint8_t mode) {
|
void ems_setThermostatMode(uint8_t mode) {
|
||||||
if (_checkWriteQueueFull())
|
if (_checkWriteQueueFull())
|
||||||
|
|||||||
Reference in New Issue
Block a user