mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 16:59:50 +03:00
move ESPHelper to src
This commit is contained in:
13
README.md
13
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 "<my_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 "<broker_password>"
|
||||
```
|
||||
* 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 `<lib>` with `"lib"`
|
||||
* cross your fingers and CTRL-R to compile...
|
||||
|
||||
# Your comments and feedback
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -19,8 +19,8 @@
|
||||
along with ESPHelper. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ESP_HELPER_H
|
||||
#define __ESP_HELPER_H
|
||||
#ifndef __ESPHelper_H
|
||||
#define __ESPHelper_H
|
||||
|
||||
#include <ArduinoOTA.h>
|
||||
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
|
||||
@@ -209,4 +209,4 @@ class ESPHelper : public Print {
|
||||
char bufferPrint[BUFFER_PRINT];
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
|
||||
// local libraries
|
||||
#include "ESPHelper.h"
|
||||
#include "ems.h"
|
||||
#include "emsuart.h"
|
||||
|
||||
// private libraries
|
||||
#include <ESPHelper.h>
|
||||
|
||||
// public libraries
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ticker.h> // https://github.com/esp8266/Arduino/tree/master/libraries/Ticker
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "ems.h"
|
||||
#include "ESPHelper.h"
|
||||
#include "emsuart.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESPHelper.h>
|
||||
#include <TimeLib.h>
|
||||
|
||||
_EMS_Sys_Status EMS_Sys_Status; // EMS Status
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user