From fac660bb9843fea61f70e405867da9c7bab342e2 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 28 Apr 2019 10:45:00 +0200 Subject: [PATCH] minor updates --- CHANGELOG.md | 2 ++ src/ems-esp.cpp | 35 ++++++++++++++++++----------------- src/ems.cpp | 19 +++++++++++++------ src/ems.h | 4 +++- src/ems_devices.h | 5 +++-- src/version.h | 2 +- 6 files changed, 40 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfc2f60f..7eb359eab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,11 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - nefit proline hrc 24 cw4 thermostat - support for Buderus RC300 and RC310 thermostats [(issue 37)](https://github.com/proddy/EMS-ESP/issues/37) - added a test harness to try out response to various telegrams +- EMS_ID_GATEWAY for Buderus Web Gateway KM200 ### Changed - `types` renamed to `devices` to also show all detected devices - EMS Plus logic optimized +- `silent_mode` to `listen_mode` ## [1.6.0] 2019-03-24 diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index 157cbae1d..1cec44dd8 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -77,7 +77,7 @@ typedef struct { bool shower_timer; // true if we want to report back on shower times bool shower_alert; // true if we want the alert of cold water bool led; // LED on/off - bool silent_mode; // stop automatic Tx on/off + bool listen_mode; // stop automatic Tx on/off uint16_t publish_wait; // frequency of MQTT publish in seconds uint8_t led_gpio; // pin for LED uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors @@ -101,7 +101,7 @@ command_t PROGMEM project_cmds[] = { {true, "dallas_parasite ", "set to on if powering Dallas via parasite"}, {true, "thermostat_type ", "set the thermostat type id (e.g. 10 for 0x10)"}, {true, "boiler_type ", "set the boiler type id (e.g. 8 for 0x08)"}, - {true, "silent_mode ", "when on all automatic Tx is disabled"}, + {true, "listen_mode ", "when on all automatic Tx is disabled"}, {true, "shower_timer ", "notify via MQTT all shower durations"}, {true, "shower_alert ", "send a warning of cold water after shower time is exceeded"}, {true, "publish_wait ", "set frequency for publishing to MQTT"}, @@ -324,7 +324,7 @@ void showInfo() { myDebug(" System logging set to None"); } - myDebug(" LED is %s, Silent mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.silent_mode ? "on" : "off"); + myDebug(" LED is %s, Silent mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.listen_mode ? "on" : "off"); if (EMSESP_Status.dallas_sensors > 0) { myDebug(" %d external temperature sensor%s found", EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors == 1) ? "" : "s"); } @@ -936,6 +936,7 @@ void runUnitTest(uint8_t test_num) { publishValuesTimer.detach(); systemCheckTimer.detach(); regularUpdatesTimer.detach(); + EMSESP_Status.listen_mode = true; // temporary go into listen mode to disable Tx if (test_num >= 1 && test_num <= 10) { ems_testTelegram(test_num); } @@ -973,8 +974,8 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) { } // silent mode - EMSESP_Status.silent_mode = json["silent_mode"]; - ems_setTxDisabled(EMSESP_Status.silent_mode); + EMSESP_Status.listen_mode = json["listen_mode"]; + ems_setTxDisabled(EMSESP_Status.listen_mode); // shower_timer EMSESP_Status.shower_timer = json["shower_timer"]; @@ -1006,7 +1007,7 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) { json["led_gpio"] = EMSESP_Status.led_gpio; json["dallas_gpio"] = EMSESP_Status.dallas_gpio; json["dallas_parasite"] = EMSESP_Status.dallas_parasite; - json["silent_mode"] = EMSESP_Status.silent_mode; + json["listen_mode"] = EMSESP_Status.listen_mode; json["shower_timer"] = EMSESP_Status.shower_timer; json["shower_alert"] = EMSESP_Status.shower_alert; json["publish_wait"] = EMSESP_Status.publish_wait; @@ -1042,19 +1043,19 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c } // test mode - if ((strcmp(setting, "silent_mode") == 0) && (wc == 2)) { + if ((strcmp(setting, "listen_mode") == 0) && (wc == 2)) { if (strcmp(value, "on") == 0) { - EMSESP_Status.silent_mode = true; + EMSESP_Status.listen_mode = true; ok = true; - myDebug("* in Silent mode. All Tx is disabled."); + myDebug("* in listen mode. All Tx is disabled."); ems_setTxDisabled(true); } else if (strcmp(value, "off") == 0) { - EMSESP_Status.silent_mode = false; + EMSESP_Status.listen_mode = false; ok = true; ems_setTxDisabled(false); - myDebug("* out of Silent mode. Tx is enabled."); + myDebug("* out of listen mode. Tx is enabled."); } else { - myDebug("Error. Usage: set silent_mode "); + myDebug("Error. Usage: set listen_mode "); } } @@ -1176,7 +1177,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c myDebug(" boiler_type=%02X", EMS_Boiler.device_id); } - myDebug(" silent_mode=%s", EMSESP_Status.silent_mode ? "on" : "off"); + myDebug(" listen_mode=%s", EMSESP_Status.listen_mode ? "on" : "off"); myDebug(" shower_timer=%s", EMSESP_Status.shower_timer ? "on" : "off"); myDebug(" shower_alert=%s", EMSESP_Status.shower_alert ? "on" : "off"); myDebug(" publish_wait=%d", EMSESP_Status.publish_wait); @@ -1512,7 +1513,7 @@ void WIFICallback() { } else { emsuart_init(); myDebug("[UART] Opened Rx/Tx connection"); - if (!EMSESP_Status.silent_mode) { + if (!EMSESP_Status.listen_mode) { // go and find the boiler and thermostat types, if not in silent mode ems_discoverModels(); } @@ -1526,7 +1527,7 @@ void initEMSESP() { EMSESP_Status.shower_timer = false; EMSESP_Status.shower_alert = false; EMSESP_Status.led = true; // LED is on by default - EMSESP_Status.silent_mode = false; + EMSESP_Status.listen_mode = false; EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT; EMSESP_Status.timestamp = millis(); EMSESP_Status.dallas_sensors = 0; @@ -1643,7 +1644,7 @@ void setup() { // at this point we have all the settings from our internall SPIFFS config file // enable regular checks if not in test mode - if (!EMSESP_Status.silent_mode) { + if (!EMSESP_Status.listen_mode) { publishValuesTimer.attach(EMSESP_Status.publish_wait, do_publishValues); // post MQTT EMS values publishSensorValuesTimer.attach(EMSESP_Status.publish_wait, do_publishSensorValues); // post MQTT sensor values regularUpdatesTimer.attach(REGULARUPDATES_TIME, do_regularUpdates); // regular reads from the EMS @@ -1677,7 +1678,7 @@ void loop() { // publish the values to MQTT, only if the values have changed // although we don't want to publish when doing a deep scan of the thermostat - if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.silent_mode)) { + if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.listen_mode)) { publishValues(false); ems_setEmsRefreshed(false); // reset } diff --git a/src/ems.cpp b/src/ems.cpp index f50a28994..097a8e6ab 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -617,7 +617,7 @@ void _createValidate() { /* * Entry point triggered by an interrupt in emsuart.cpp - * length is size of all the data bytes with CRC, excluding the BRK at the end + * length is size of all the telegram bytes including the CRC, excluding the BRK at the end * Read commands are asynchronous as they're handled by the interrupt * When a telegram is processed we forcefully erase it from the stack to prevent overflow */ @@ -633,7 +633,7 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) { /** * the main logic that parses the telegram message * When we receive a Poll Request we need to send any Tx packages quickly within a 200ms window - * length is total number of bytes of the telegram excluding the CRC byte at the end + * length is total number of bytes of the telegram including the CRC byte at the end if it exists */ void _ems_readTelegram(uint8_t * telegram, uint8_t length) { // create the Rx package @@ -704,7 +704,11 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) { EMS_RxTelegram.emsplus = true; EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6 EMS_RxTelegram.data = telegram + 6; - EMS_RxTelegram.length = length - 8; // remove 5 bytes header plus CRC + length byte + 0x00 at end + if (length <= 7) { + EMS_RxTelegram.length = 0; // special broadcast on ems+ have no data values + } else { + EMS_RxTelegram.length = length - 8; // remove 5 bytes header plus CRC + length byte + 0x00 at end + } } else { EMS_RxTelegram.emsplus = false; EMS_RxTelegram.type = telegram[2]; // 3rd byte @@ -763,6 +767,8 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) { strlcpy(output_str, "Thermostat", sizeof(output_str)); } else if (src == EMS_ID_SM) { strlcpy(output_str, "SM", sizeof(output_str)); + } else if (src == EMS_ID_GATEWAY) { + strlcpy(output_str, "Gateway", sizeof(output_str)); } else { strlcpy(output_str, "0x", sizeof(output_str)); strlcat(output_str, _hextoa(src, buffer), sizeof(output_str)); @@ -2212,7 +2218,7 @@ void ems_testTelegram(uint8_t test_num) { if (test_num == 0) return; - static const char tests[9][200] = { + static const char tests[10][200] = { "08 00 34 00 3E 02 1D 80 00 31 00 00 01 00 01 0B AE 02", // test 1 "10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00", // test 2 - RC310 ems+ @@ -2222,7 +2228,8 @@ void ems_testTelegram(uint8_t test_num) { "18 00 FF 00 01 A5 00 DD 21 23 00 00 23 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00", // test 6 - RC300 "90 00 FF 00 00 6F 01 01 00 46 00 B9", // test 7 - FR10 "30 00 FF 00 02 62 01 FB 01 9E 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 2B", // test 8 - SM100 - "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9" // test 9 - SM100 + "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9", // test 9 - SM100 + "30 09 FF 00 00 01" // test 10 }; @@ -2259,7 +2266,7 @@ void ems_testTelegram(uint8_t test_num) { length++; // this is the total amount of bytes telegram[length] = _crcCalculator(telegram, length + 1); // add the CRC - myDebug("[TEST %d] Injecting telegram %s (length %d)", test_num, tests[test_num - 1], length); + myDebug("[TEST %d] Injecting telegram %s (data length %d)", test_num, tests[test_num - 1], length); // go an parse it _ems_readTelegram(telegram, length + 1); // include CRC in length diff --git a/src/ems.h b/src/ems.h index 67032a788..17773fa13 100644 --- a/src/ems.h +++ b/src/ems.h @@ -17,7 +17,9 @@ #define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty device IDs #define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key" #define EMS_ID_DEFAULT_BOILER 0x08 -#define EMS_ID_SM 0x30 // Solar Module SM10 and SM100 +#define EMS_ID_SM 0x30 // Solar Module SM10 and SM100 +#define EMS_ID_GATEWAY 0x48 // KM200 Web Gateway + #define EMS_MIN_TELEGRAM_LENGTH 6 // minimal length for a validation telegram, including CRC diff --git a/src/ems_devices.h b/src/ems_devices.h index eda4c2a7a..e743a10a2 100644 --- a/src/ems_devices.h +++ b/src/ems_devices.h @@ -149,7 +149,7 @@ const _Other_Type Other_Types[] = { {EMS_MODEL_OTHER, 251, 0x21, "MM10 Mixer Module"}, // warning, fake product id! {EMS_MODEL_OTHER, 250, 0x11, "WM10 Switch Module"}, // warning, fake product id! - {EMS_MODEL_OTHER, 160, 0x20, "MM100 Mixing Module"}, + {EMS_MODEL_OTHER, 160, 0x20, "MM100 Mixing Module"}, {EMS_MODEL_OTHER, 160, 0x21, "MM100 Mixing Module"}, {EMS_MODEL_OTHER, 68, 0x09, "BC10/RFM20 Receiver"}, {EMS_MODEL_OTHER, 190, 0x09, "BC10 Base Controller"}, @@ -158,7 +158,8 @@ const _Other_Type Other_Types[] = { {EMS_MODEL_OTHER, 205, 0x02, "Nefit Moduline Easy Connect"}, {EMS_MODEL_OTHER, 73, EMS_ID_SM, "SM10 Solar Module"}, {EMS_MODEL_OTHER, 163, EMS_ID_SM, "SM100 Solar Module"}, - {EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"} + {EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"}, + {EMS_MODEL_OTHER, 252, EMS_ID_GATEWAY, "Web Gateway KM200"} // warning, fake product id! }; diff --git a/src/version.h b/src/version.h index f05e94f96..595fc19b6 100644 --- a/src/version.h +++ b/src/version.h @@ -6,5 +6,5 @@ #pragma once #define APP_NAME "EMS-ESP" -#define APP_VERSION "1.7.0b10" +#define APP_VERSION "1.7.0b11" #define APP_HOSTNAME "ems-esp"