optimized Type detection on incoming telegrams

This commit is contained in:
proddy
2019-03-21 23:47:31 +01:00
parent 190082155e
commit 590abfa4b9
2 changed files with 14 additions and 14 deletions

View File

@@ -32,7 +32,7 @@ DS18 ds18;
#define myDebug_P(...) myESP.myDebug_P(__VA_ARGS__) #define myDebug_P(...) myESP.myDebug_P(__VA_ARGS__)
// set to value >0 if the ESP is overheating or there are timing issues. Recommend a value of 1. // set to value >0 if the ESP is overheating or there are timing issues. Recommend a value of 1.
#define EMSESP_DELAY 0 // initially set to 0 for no delay #define EMSESP_DELAY 1 // initially set to 0 for no delay
// timers, all values are in seconds // timers, all values are in seconds
#define DEFAULT_PUBLISHWAIT 120 // every 2 minutes publish MQTT values, including Dallas sensors #define DEFAULT_PUBLISHWAIT 120 // every 2 minutes publish MQTT values, including Dallas sensors
@@ -1204,7 +1204,7 @@ void do_ledcheck() {
// Thermostat scan // Thermostat scan
void do_scanThermostat() { void do_scanThermostat() {
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) { if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebug("> Scanning thermostat message type #0x%02X..", scanThermostat_count); myDebug("> Scanning thermostat message type #0x%02X...", scanThermostat_count);
ems_doReadCommand(scanThermostat_count, EMS_Thermostat.type_id); ems_doReadCommand(scanThermostat_count, EMS_Thermostat.type_id);
scanThermostat_count++; scanThermostat_count++;
} }
@@ -1221,7 +1221,7 @@ void do_systemCheck() {
// only if we have a EMS connection // only if we have a EMS connection
void do_regularUpdates() { void do_regularUpdates() {
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) { if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebugLog("Calling scheduled data refresh from EMS devices.."); myDebugLog("Calling scheduled data refresh from EMS devices...");
ems_getThermostatValues(); ems_getThermostatValues();
ems_getBoilerValues(); ems_getBoilerValues();
ems_getOtherValues(); ems_getOtherValues();

View File

@@ -759,25 +759,25 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
} }
// see if we recognize the type first by scanning our known EMS types list // see if we recognize the type first by scanning our known EMS types list
// trying to match the type ID
bool commonType = false;
bool typeFound = false; bool typeFound = false;
bool forUs = false; uint8_t i = 0;
int i = 0;
while (i < _EMS_Types_max) { while (i < _EMS_Types_max) {
if (EMS_Types[i].type == type) { if (EMS_Types[i].type == type) {
// is it common type for everyone?
// is it for us? So the src must match with either the boiler, thermostat or other devices
if ((EMS_Types[i].model_id == EMS_MODEL_ALL)
|| ((src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id) || (src == EMS_ID_SM10))) {
typeFound = true; typeFound = true;
commonType = (EMS_Types[i].model_id == EMS_MODEL_ALL); // is it common type for everyone?
forUs = (src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id); // is it for us? So the src must match
break; break;
} }
}
i++; i++;
} }
// if it's a common type (across ems devices) or something specifically for us process it. // if it's a common type (across ems devices) or something specifically for us process it.
// dest will be EMS_ID_NONE and offset 0x00 for a broadcast message // dest will be EMS_ID_NONE and offset 0x00 for a broadcast message
if (typeFound && (commonType || forUs)) { if (typeFound) {
if ((EMS_Types[i].processType_cb) != (void *)NULL) { if ((EMS_Types[i].processType_cb) != (void *)NULL) {
// print non-verbose message // print non-verbose message
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) { if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) {
@@ -785,7 +785,7 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
} }
// call callback function to process it // call callback function to process it
// as we only handle complete telegrams (not partial) check that the offset is 0 // as we only handle complete telegrams (not partial) check that the offset is 0
if (offset == EMS_ID_NONE) { if (offset == 0) {
(void)EMS_Types[i].processType_cb(src, data, EMS_RxTelegram->length - 5); (void)EMS_Types[i].processType_cb(src, data, EMS_RxTelegram->length - 5);
} }
} }