diff --git a/README.md b/README.md index 7615cb2fa..4c928dc26 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ The Boiler (ID 0x08) will send out these broadcast telegrams regularly: And a thermostat (ID 0x17 for a RC20) would broadcast these messages regularly: | Type | Description | -| ---- | ----------- | undefined |undefined |undefined |undefined |undefined | +| ---- | ----------- | undefined |undefined |undefined |undefined |undefined |undefined |undefined |undefined | | 0x06 | time on thermostat Y,M,H,D,M,S,wd | Refer to the code in `ems.cpp` for further explanation on how to parse these message types and also reference the EMS Wiki. @@ -212,13 +212,13 @@ Every telegram sent is echo'd back to Rx. * PubSubClient http://pubsubclient.knolleary.net * ArduinoJson https://github.com/bblanchon/ArduinoJson - `src\emsuart.cpp` handles the low level UART read and write logic. You shouldn't need to touch this. All receive commands from the EMS bus are handled asynchronously using a circular buffer via an interrupt. A separate function processes the buffer and extracts the telegrams. Since we don't send too many write commands this is done sequentially. I couldn't use the standard Arduino Serial implementation because of the 11-bit break signal causes a frame-error which gets ignored. + `emsuart.cpp` handles the low level UART read and write logic. You shouldn't need to touch this. All receive commands from the EMS bus are handled asynchronously using a circular buffer via an interrupt. A separate function processes the buffer and extracts the telegrams. Since we don't send too many write commands this is done sequentially. I couldn't use the standard Arduino Serial implementation because of the 11-bit break signal causes a frame-error which gets ignored. - `src\ems.cpp` is the logic to read the EMS packets (telegrams), validates them and process them based on the type. + `ems.cpp` is the logic to read the EMS packets (telegrams), validates them and process them based on the type. - `src\boiler.ino` is the Arduino code for the ESP8266 that kicks it all off. This is where we have specific logic such as the code to monitor and alert on the Shower timer and light up the LEDs. + `boiler.ino` is the Arduino code for the ESP8266 that kicks it all off. This is where we have specific logic such as the code to monitor and alert on the Shower timer and light up the LEDs. - `lib\ESPHelper` is my customized version of [ESPHelper](https://github.com/ItKindaWorks/ESPHelper) with added Telnet support and some other minor tweaking. + `ESPHelper.cpp` is my customized version of [ESPHelper](https://github.com/ItKindaWorks/ESPHelper) with added Telnet support and some other minor tweaking. ### Supported EMS Types @@ -438,7 +438,7 @@ Porting to the Arduino is tricky and messy (which is one of the reasons I don't * Add the ESP8266 boards (from Preferences add Additional Board URL http://arduino.esp8266.com/stable/package_esp8266com_index.json) * Go to Boards Manager and install ESP8266 2.4.x platform * Select your ESP8266 from Tools->Boards and the correct port with Tools->Port -* From the Library Manager install ArduinoJson 5.13.x, PubSubClient 2.6.0 +* From the Library Manager install ArduinoJson 5.13.x, PubSubClient 2.6.x * The Arduino IDE doesn't have a common way to set build flags (ugh!) so you'll need to uncomment these lines in `boiler.ino`: ``` #define WIFI_SSID "" @@ -448,7 +448,6 @@ Porting to the Arduino is tricky and messy (which is one of the reasons I don't #define MQTT_PASS "" ``` * Put all the files in a single sketch folder (`ESPHelper.*, boiler.ino, ems.*, emsuart.*`) -* Possibly change some the #includes to use the local files, replacing `` with `"lib"` * cross your fingers and CTRL-R to compile... # Your comments and feedback diff --git a/platformio.ini-example b/platformio.ini-example index 55fdac432..c06178b8a 100644 --- a/platformio.ini-example +++ b/platformio.ini-example @@ -1,10 +1,10 @@ [platformio] env_default = nodemcuv2 -#env_default = d1_mini +; env_default = d1_mini [common] platform = espressif8266 -build_flags = -g -DMQTT_MAX_PACKET_SIZE=300 +build_flags = -DMQTT_MAX_PACKET_SIZE=300 build_flags_custom = '-DWIFI_SSID="my_ssid"' '-DWIFI_PASSWORD="my_password"' '-DMQTT_IP="my_broker_ip"' '-DMQTT_USER="my_broker_username"' '-DMQTT_PASS="my_broker_password"' lib_deps = Time diff --git a/lib/ESPHelper/ESPHelper.cpp b/src/ESPHelper.cpp similarity index 99% rename from lib/ESPHelper/ESPHelper.cpp rename to src/ESPHelper.cpp index 102e80ae6..86e0fb2e1 100644 --- a/lib/ESPHelper/ESPHelper.cpp +++ b/src/ESPHelper.cpp @@ -159,7 +159,7 @@ bool ESPHelper::begin(const char * hostname) { //initially attempt to connect to wifi when we begin (but only block for 2 seconds before timing out) uint8_t timeout = 0; //counter for begin connection attempts while (((!client.connected() && _mqttSet) || WiFi.status() != WL_CONNECTED) - && timeout < 200) { //max 2 sec before timeout + && timeout < 200) { //max 2 sec before timeout reconnect(); timeout++; } @@ -445,7 +445,7 @@ uint8_t ESPHelper::setConnectionStatus() { //if connected to wifi set the mode to wifi only and run the callback if needed if (WiFi.status() == WL_CONNECTED) { if (_connectionStatus < WIFI_ONLY - && _wifiCallbackSet) { //if the wifi previously wasn't connected but now is, run the callback + && _wifiCallbackSet) { //if the wifi previously wasn't connected but now is, run the callback _wifiCallback(); } returnVal = WIFI_ONLY; diff --git a/lib/ESPHelper/ESPHelper.h b/src/ESPHelper.h similarity index 99% rename from lib/ESPHelper/ESPHelper.h rename to src/ESPHelper.h index 7bf440f38..81eeb55a2 100644 --- a/lib/ESPHelper/ESPHelper.h +++ b/src/ESPHelper.h @@ -19,8 +19,8 @@ along with ESPHelper. If not, see . */ -#ifndef __ESP_HELPER_H -#define __ESP_HELPER_H +#ifndef __ESPHelper_H +#define __ESPHelper_H #include #include //https://github.com/esp8266/Arduino @@ -209,4 +209,4 @@ class ESPHelper : public Print { char bufferPrint[BUFFER_PRINT]; }; -#endif +#endif \ No newline at end of file diff --git a/src/boiler.ino b/src/boiler.ino index f8d43c53a..5e044265a 100644 --- a/src/boiler.ino +++ b/src/boiler.ino @@ -6,12 +6,10 @@ */ // local libraries +#include "ESPHelper.h" #include "ems.h" #include "emsuart.h" -// private libraries -#include - // public libraries #include #include // https://github.com/esp8266/Arduino/tree/master/libraries/Ticker diff --git a/src/ems.cpp b/src/ems.cpp index 27308304e..7e7832581 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -6,10 +6,10 @@ */ #include "ems.h" +#include "ESPHelper.h" #include "emsuart.h" #include -#include #include _EMS_Sys_Status EMS_Sys_Status; // EMS Status diff --git a/src/ems.h b/src/ems.h index fc56c9759..6940e9d48 100644 --- a/src/ems.h +++ b/src/ems.h @@ -15,7 +15,7 @@ #define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as "Service Key" // EMS Telegram Types -#define EMS_TYPE_NONE 0x00 // none +#define EMS_TYPE_NONE 0x00 // none #define EMS_TYPE_UBAMonitorFast 0x18 // is an automatic monitor broadcast #define EMS_TYPE_UBAMonitorSlow 0x19 // is an automatic monitor broadcast