mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge branch 'v2' of https://github.com/proddy/EMS-ESP into v2
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,7 +16,4 @@ scripts/stackdmp.txt
|
|||||||
firmware
|
firmware
|
||||||
*.bin
|
*.bin
|
||||||
emsesp
|
emsesp
|
||||||
doc/github.txt
|
|
||||||
doc/test_data.txt
|
|
||||||
|
|
||||||
/src/uart/uart_proddy.txt
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# EMS-ESP version 2.0 (alpha)
|
# EMS-ESP version 2.0 (alpha)
|
||||||
|
|
||||||
*Warning: this is a snapshot from my EMS-ESP2 development repo and still in early stages of it's development. Not all features have been fully tested. Use at your own risk!*
|
*Warning: this is still in early stages of it's development. Not all features have been fully tested. Use at your own risk!*
|
||||||
|
|
||||||
Note: Version 2.0 is not backward compatible with v1.0. The File system structure is different. When coming from version 1.9.x its best if you first erase the flash on the ESP and upload using USB. `esptool.py erase_flash` will clean the flash and `esptool.py -p COM6 -b 921600 write_flash 0x00000 firmware.bin` is an example of how to upload the firmware over USB.
|
Note: Version 2.0 is not backward compatible with v1.0. The File system structure is different. When coming from version 1.9.x its best if you first erase the flash on the ESP and upload using USB. `esptool.py erase_flash` will clean the flash and `esptool.py -p COM6 -b 921600 write_flash 0x00000 firmware.bin` is an example of how to upload the firmware over USB.
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ Note: Version 2.0 is not backward compatible with v1.0. The File system structur
|
|||||||
common commands available in all contexts:
|
common commands available in all contexts:
|
||||||
exit
|
exit
|
||||||
help
|
help
|
||||||
log [level] [raw] [trace ID]
|
log [level] [full|raw] [trace ID]
|
||||||
su
|
su
|
||||||
|
|
||||||
(top level)
|
(top level)
|
||||||
@@ -125,8 +125,6 @@ thermostat
|
|||||||
|
|
||||||
```
|
```
|
||||||
TODO ESP32 - when saving SPIFFS the UART stop and restart() functions need to flush queue to avoid miss fires
|
TODO ESP32 - when saving SPIFFS the UART stop and restart() functions need to flush queue to avoid miss fires
|
||||||
TODO network issues with ESP8266 - can take a while to get an IP address. DNS issue?
|
|
||||||
TODO figure out why sometimes telnet on ESP32 (and sometimes ESP8266) has slow response times. After a manual reset it seems to fix itself. Perhaps the telnet service needs to start after the wifi is up & running.
|
|
||||||
TODO sometimes with tx_mode 0 there are a few CRC errors due to collision when waiting for a BRK signal.
|
TODO sometimes with tx_mode 0 there are a few CRC errors due to collision when waiting for a BRK signal.
|
||||||
TODO console auto-complete with 'set' command in the system context is not showing all commands, only the hostname.
|
TODO console auto-complete with 'set' command in the system context is not showing all commands, only the hostname.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
; PlatformIO Project Configuration File
|
; PlatformIO Project Configuration File for EMS-ESP
|
||||||
; For EMS-ESP
|
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = esp8266
|
default_envs = esp8266
|
||||||
@@ -80,6 +79,7 @@ build_type = release
|
|||||||
platform = espressif8266 ; https://github.com/platformio/platform-espressif8266/releases
|
platform = espressif8266 ; https://github.com/platformio/platform-espressif8266/releases
|
||||||
;platform = espressif8266@2.4.0 ; Arduino core 2.6.3
|
;platform = espressif8266@2.4.0 ; Arduino core 2.6.3
|
||||||
board = esp12e
|
board = esp12e
|
||||||
|
board_build.flash_mode = dout
|
||||||
; board = d1_mini ; https://github.com/platformio/platform-espressif8266/blob/master/boards/d1_mini.json
|
; board = d1_mini ; https://github.com/platformio/platform-espressif8266/blob/master/boards/d1_mini.json
|
||||||
lib_deps = ${common.libs_core} ${common.libs_esp8266}
|
lib_deps = ${common.libs_core} ${common.libs_esp8266}
|
||||||
board_build.f_cpu = 160000000L ; 160MHz
|
board_build.f_cpu = 160000000L ; 160MHz
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ void Console::start() {
|
|||||||
// note, this must be started after the network/wifi for ESP32 otherwise it'll crash
|
// note, this must be started after the network/wifi for ESP32 otherwise it'll crash
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
telnet_.start();
|
telnet_.start();
|
||||||
// telnet_.default_write_timeout(1000); // in ms, socket timeout 1 second
|
telnet_.default_write_timeout(1000); // in ms, socket timeout 1 second
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
{208, DeviceType::BOILER, F("Logamax plus/GB192/Condens GC9000"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
{208, DeviceType::BOILER, F("Logamax plus/GB192/Condens GC9000"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
{234, DeviceType::BOILER, F("Logamax Plus GB122"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
{234, DeviceType::BOILER, F("Logamax Plus GB122"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
|
|
||||||
// Solar Modules - 0x30
|
// Solar Modules - 0x30
|
||||||
{ 73, DeviceType::SOLAR, F("SM10"), DeviceFlags::EMS_DEVICE_FLAG_SM10},
|
{ 73, DeviceType::SOLAR, F("SM10"), DeviceFlags::EMS_DEVICE_FLAG_SM10},
|
||||||
{101, DeviceType::SOLAR, F("ISM1"), DeviceFlags::EMS_DEVICE_FLAG_SM100},
|
{101, DeviceType::SOLAR, F("ISM1"), DeviceFlags::EMS_DEVICE_FLAG_SM100},
|
||||||
@@ -58,7 +57,7 @@
|
|||||||
{252, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
{252, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
// Switches - 0x11
|
// Switches - 0x11
|
||||||
{ 71, DeviceType::SWITCH, F("WM10"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x11
|
{ 71, DeviceType::SWITCH, F("WM10"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
// Controllers - 0x09 / 0x10 / 0x50
|
// Controllers - 0x09 / 0x10 / 0x50
|
||||||
{ 68, DeviceType::CONTROLLER, F("BC10/RFM20"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
{ 68, DeviceType::CONTROLLER, F("BC10/RFM20"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||||
@@ -75,11 +74,10 @@
|
|||||||
{230, DeviceType::CONTROLLER, F("BC Base"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
{230, DeviceType::CONTROLLER, F("BC Base"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||||
{241, DeviceType::CONTROLLER, F("Condens 5000i"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
{241, DeviceType::CONTROLLER, F("Condens 5000i"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||||
|
|
||||||
|
|
||||||
// Connect devices - 0x02
|
// Connect devices - 0x02
|
||||||
{171, DeviceType::CONNECT, F("OpenTherm Converter"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x02
|
{171, DeviceType::CONNECT, F("OpenTherm Converter"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
{205, DeviceType::CONNECT, F("Moduline Easy Connect"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x02
|
{205, DeviceType::CONNECT, F("Moduline Easy Connect"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
{206, DeviceType::CONNECT, F("Easy Connect"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x02
|
{206, DeviceType::CONNECT, F("Easy Connect"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
// Gateways - 0x48 / 0x18
|
// Gateways - 0x48 / 0x18
|
||||||
{ 94, DeviceType::GATEWAY, F("RFM20 Remote Base for RC20RF"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x18
|
{ 94, DeviceType::GATEWAY, F("RFM20 Remote Base for RC20RF"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x18
|
||||||
|
|||||||
@@ -247,7 +247,6 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// get the type name, any match will do
|
// get the type name, any match will do
|
||||||
if (type_name.empty()) {
|
if (type_name.empty()) {
|
||||||
type_name = emsdevice->telegram_type_name(telegram);
|
type_name = emsdevice->telegram_type_name(telegram);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,11 +363,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
|
|||||||
|
|
||||||
// get version as XX.XX
|
// get version as XX.XX
|
||||||
std::string version(5, '\0');
|
std::string version(5, '\0');
|
||||||
snprintf_P(&version[0],
|
snprintf_P(&version[0], version.capacity() + 1, PSTR("%02d.%02d"), telegram->message_data[offset + 1], telegram->message_data[offset + 2]);
|
||||||
version.capacity() + 1,
|
|
||||||
PSTR("%02d.%02d"),
|
|
||||||
telegram->message_data[offset + 1],
|
|
||||||
telegram->message_data[offset + 2]);
|
|
||||||
|
|
||||||
// some devices store the protocol type (HT3, Buderus) in the last byte
|
// some devices store the protocol type (HT3, Buderus) in the last byte
|
||||||
uint8_t brand;
|
uint8_t brand;
|
||||||
@@ -786,7 +781,7 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
|
|||||||
Settings settings;
|
Settings settings;
|
||||||
shell.printfln(F_(tx_mode_fmt), settings.ems_tx_mode());
|
shell.printfln(F_(tx_mode_fmt), settings.ems_tx_mode());
|
||||||
shell.printfln(F_(bus_id_fmt), settings.ems_bus_id());
|
shell.printfln(F_(bus_id_fmt), settings.ems_bus_id());
|
||||||
shell.printfln(F_(read_only_fmt), settings.ems_read_only() ? F_(enabled) : F_(disabled));
|
shell.printfln(F_(read_only_fmt), settings.ems_read_only() ? F_(on) : F_(off));
|
||||||
});
|
});
|
||||||
|
|
||||||
// enter the context
|
// enter the context
|
||||||
@@ -801,8 +796,8 @@ void EMSESP::start() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system_.start();
|
system_.start();
|
||||||
network_.start();
|
|
||||||
console_.start();
|
console_.start();
|
||||||
|
network_.start();
|
||||||
sensors_.start();
|
sensors_.start();
|
||||||
rxservice_.start();
|
rxservice_.start();
|
||||||
txservice_.start();
|
txservice_.start();
|
||||||
@@ -817,20 +812,24 @@ void EMSESP::loop() {
|
|||||||
// network returns false if an OTA is being carried out
|
// network returns false if an OTA is being carried out
|
||||||
// so we disable all services when an OTA is happening
|
// so we disable all services when an OTA is happening
|
||||||
if (network_.loop()) {
|
if (network_.loop()) {
|
||||||
console_.loop(); // telnet/serial console
|
|
||||||
system_.loop(); // does LED and checks system health, and syslog service
|
system_.loop(); // does LED and checks system health, and syslog service
|
||||||
mqtt_.loop(); // starts mqtt, and sends out anything in the queue
|
mqtt_.loop(); // starts mqtt, and sends out anything in the queue
|
||||||
rxservice_.loop(); // process what ever is in the rx queue
|
rxservice_.loop(); // process what ever is in the rx queue
|
||||||
txservice_.loop(); // check that the Tx is all ok
|
txservice_.loop(); // check that the Tx is all ok
|
||||||
shower_.loop(); // check for shower on/off
|
shower_.loop(); // check for shower on/off
|
||||||
sensors_.loop(); // this will also send out via MQTT
|
sensors_.loop(); // this will also send out via MQTT
|
||||||
delay(MYESP_DELAY); // some time to WiFi and everything else to catch up, calls yield, and also prevent overheating
|
console_.loop(); // telnet/serial console
|
||||||
|
delay(ESP_DELAY); // some time to WiFi and everything else to catch up, calls yield, and also prevent overheating
|
||||||
|
|
||||||
// force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
// force a query on the EMS devices to fetch latest data at a set interval (1 min)
|
||||||
if ((uuid::get_uptime() - last_fetch_ > EMS_FETCH_FREQUENCY)) {
|
if ((uuid::get_uptime() - last_fetch_ > EMS_FETCH_FREQUENCY)) {
|
||||||
last_fetch_ = uuid::get_uptime();
|
last_fetch_ = uuid::get_uptime();
|
||||||
fetch_device_values();
|
fetch_device_values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helps ease wifi outages
|
||||||
|
// https://github.com/esp8266/Arduino/blob/e721089e601985e633641ab7323f81a84ea0cd1b/cores/esp8266/core_esp8266_wiring.cpp#L41-L57
|
||||||
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include "shower.h"
|
#include "shower.h"
|
||||||
|
|
||||||
#define LOG_TRACE_WATCH_NONE 0 // no watch set
|
#define LOG_TRACE_WATCH_NONE 0 // no watch set
|
||||||
#define MYESP_DELAY 1
|
#define ESP_DELAY 1
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ class Mixing : public EMSdevice {
|
|||||||
uint8_t status_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t status_ = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t flowSetTemp_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t flowSetTemp_ = EMS_VALUE_UINT_NOTSET;
|
||||||
Type type_ = Type::NONE;
|
Type type_ = Type::NONE;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ void Network::start() {
|
|||||||
sta_mode_disconnected_ = WiFi.onStationModeDisconnected(std::bind(&Network::sta_mode_disconnected, this, _1));
|
sta_mode_disconnected_ = WiFi.onStationModeDisconnected(std::bind(&Network::sta_mode_disconnected, this, _1));
|
||||||
sta_mode_got_ip_ = WiFi.onStationModeGotIP(std::bind(&Network::sta_mode_got_ip, this, _1));
|
sta_mode_got_ip_ = WiFi.onStationModeGotIP(std::bind(&Network::sta_mode_got_ip, this, _1));
|
||||||
|
|
||||||
|
WiFi.setSleepMode(WIFI_NONE_SLEEP); // added to possibly fix wifi dropouts in arduino core 2.5.0
|
||||||
|
// ref: https://github.com/esp8266/Arduino/issues/6471
|
||||||
|
// ref: https://github.com/esp8266/Arduino/issues/6366
|
||||||
|
// high tx power causing weird behavior, slightly lowering from 20.5 to 20.0 may help stability
|
||||||
|
// WiFi.setOutputPower(20.0); // in DBM
|
||||||
|
|
||||||
connect(); // connect to WiFi
|
connect(); // connect to WiFi
|
||||||
ota_setup(); // initialize OTA
|
ota_setup(); // initialize OTA
|
||||||
|
|
||||||
@@ -164,9 +170,8 @@ void Network::connect() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.wifi_ssid().empty()) {
|
LOG_INFO(F("Connecting to wifi ssid %s..."), settings.wifi_ssid().c_str());
|
||||||
WiFi.begin(settings.wifi_ssid().c_str(), settings.wifi_password().c_str());
|
WiFi.begin(settings.wifi_ssid().c_str(), settings.wifi_password().c_str());
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "emsesp.h" // for send_raw_telegram() command
|
#include "emsesp.h" // for send_raw_telegram() command
|
||||||
|
|
||||||
MAKE_PSTR_WORD(syslog)
|
MAKE_PSTR_WORD(syslog)
|
||||||
MAKE_PSTR_WORD(interval)
|
|
||||||
MAKE_PSTR_WORD(mark)
|
MAKE_PSTR_WORD(mark)
|
||||||
MAKE_PSTR_WORD(level)
|
MAKE_PSTR_WORD(level)
|
||||||
MAKE_PSTR_WORD(host)
|
MAKE_PSTR_WORD(host)
|
||||||
@@ -85,7 +84,6 @@ void System::mqtt_commands(const char * message) {
|
|||||||
// restart EMS-ESP
|
// restart EMS-ESP
|
||||||
// mode = safe mode. true to enable on next boot
|
// mode = safe mode. true to enable on next boot
|
||||||
void System::restart(bool mode) {
|
void System::restart(bool mode) {
|
||||||
|
|
||||||
// check for safe mode
|
// check for safe mode
|
||||||
if (mode) {
|
if (mode) {
|
||||||
LOG_NOTICE("Restarting system in safe mode...");
|
LOG_NOTICE("Restarting system in safe mode...");
|
||||||
|
|||||||
@@ -35,6 +35,15 @@ void EMSESP::run_test(uuid::console::Shell & shell, const std::string & command)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == "unknown2") {
|
||||||
|
// simulate getting version information back from an unknown device
|
||||||
|
uint8_t t[] = {0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02, 0x5A}; // product id is 90
|
||||||
|
rxservice_.add(t, sizeof(t));
|
||||||
|
rxservice_.loop();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (command == "thermostats") {
|
if (command == "thermostats") {
|
||||||
shell.printfln(F("Testing adding devices on the EMS bus..."));
|
shell.printfln(F("Testing adding devices on the EMS bus..."));
|
||||||
|
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ void Thermostat::publish_values() {
|
|||||||
if (hc->designtemp != EMS_VALUE_UINT_NOTSET) {
|
if (hc->designtemp != EMS_VALUE_UINT_NOTSET) {
|
||||||
dataThermostat["designtemp"] = hc->designtemp;
|
dataThermostat["designtemp"] = hc->designtemp;
|
||||||
}
|
}
|
||||||
if (hc->designtemp != EMS_VALUE_UINT_NOTSET) {
|
if (hc->summertemp != EMS_VALUE_UINT_NOTSET) {
|
||||||
dataThermostat["summertemp"] = hc->summertemp;
|
dataThermostat["summertemp"] = hc->summertemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +832,6 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags == EMS_DEVICE_FLAG_RC35 || flags == EMS_DEVICE_FLAG_RC30_1) {
|
if (flags == EMS_DEVICE_FLAG_RC35 || flags == EMS_DEVICE_FLAG_RC30_1) {
|
||||||
|
|
||||||
if (ibaCalIntTemperature != EMS_VALUE_INT_NOTSET) {
|
if (ibaCalIntTemperature != EMS_VALUE_INT_NOTSET) {
|
||||||
print_value(shell, 2, F("Offset int. temperature"), F_(degrees), Helpers::render_value(buffer, ibaCalIntTemperature, 2));
|
print_value(shell, 2, F("Offset int. temperature"), F_(degrees), Helpers::render_value(buffer, ibaCalIntTemperature, 2));
|
||||||
}
|
}
|
||||||
@@ -1460,7 +1459,6 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
|||||||
flash_string_vector{F_(degrees_mandatory), F_(hc_optional),F_(mode_optional)},
|
flash_string_vector{F_(degrees_mandatory), F_(hc_optional),F_(mode_optional)},
|
||||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||||
uint8_t hc = (arguments.size() >= 2) ? arguments[1].at(0) - '0' : DEFAULT_HEATING_CIRCUIT;
|
uint8_t hc = (arguments.size() >= 2) ? arguments[1].at(0) - '0' : DEFAULT_HEATING_CIRCUIT;
|
||||||
//uint8_t mode = (arguments.size() == 3) ? atoi(arguments.back().c_str()) : HeatingCircuit::Mode::AUTO;
|
|
||||||
if ((arguments.size() == 3)) {
|
if ((arguments.size() == 3)) {
|
||||||
set_temperature(atof(arguments.front().c_str()), arguments.back().c_str(), hc);
|
set_temperature(atof(arguments.front().c_str()), arguments.back().c_str(), hc);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "2.0.0a11"
|
#define EMSESP_APP_VERSION "2.0.0a12"
|
||||||
|
|||||||
Reference in New Issue
Block a user