memory optimizations, strings to flash mem

This commit is contained in:
proddy
2019-05-09 22:35:09 +02:00
parent 796cae7235
commit ad0ee185ef
4 changed files with 246 additions and 237 deletions

View File

@@ -1424,15 +1424,15 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack
void MyESP::crashTest(uint8_t t) {
if (t == 1) {
myDebug("[CRASH] Attempting to divide by zero ...");
myDebug_P(PSTR("[CRASH] Attempting to divide by zero ..."));
int result, zero;
zero = 0;
result = 1 / zero;
myDebug("Result = %d", result);
myDebug_P(PSTR("Result = %d"), result);
}
if (t == 2) {
myDebug("[CRASH] Attempting to read through a pointer to no object ...");
myDebug_P(PSTR("[CRASH] Attempting to read through a pointer to no object ..."));
int * nullPointer;
nullPointer = NULL;
// null pointer dereference - read
@@ -1441,7 +1441,7 @@ void MyESP::crashTest(uint8_t t) {
}
if (t == 3) {
Serial.printf("[CRASH] Crashing with hardware WDT (%ld ms) ...\n", millis());
myDebug_P(PSTR("[CRASH] Crashing with hardware WDT (%ld ms) ...\n"), millis());
ESP.wdtDisable();
while (true) {
// stay in an infinite loop doing nothing
@@ -1454,7 +1454,7 @@ void MyESP::crashTest(uint8_t t) {
}
if (t == 4) {
Serial.printf("[CRASH] Crashing with software WDT (%ld ms) ...\n", millis());
myDebug_P(PSTR("[CRASH] Crashing with software WDT (%ld ms) ...\n"), millis());
while (true) {
// stay in an infinite loop doing nothing
// this way other process can not be executed
@@ -1508,7 +1508,7 @@ void MyESP::crashDump() {
uint32_t stack_trace;
myDebug(">>>stack>>>");
myDebug_P(PSTR(">>>stack>>>"));
for (int16_t i = 0; i < stack_len; i += 0x10) {
SerialAndTelnet.printf("%08x: ", stack_start + i);
@@ -1519,7 +1519,7 @@ void MyESP::crashDump() {
}
SerialAndTelnet.println();
}
myDebug("<<<stack<<<");
myDebug_P(PSTR("<<<stack<<<"));
}
#else
void MyESP::crashTest(uint8_t t) {

View File

@@ -8,7 +8,7 @@ flash_mode = dout
build_flags = -g -w
; for debug use these...
; build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH
; build_flags = -g -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -DCRASH -DTESTS
wifi_settings =
; hard code if you prefer. Recommendation is to set from within the app when in Serial or AP mode
@@ -35,4 +35,4 @@ monitor_speed = 115200
; for OTA comment out these sections
;upload_protocol = espota
;upload_port = ems-esp.local
;upload_port = <add here your ip of the device>
;upload_port = <or add here the IP of the ESP8266>

View File

@@ -41,7 +41,7 @@ DS18 ds18;
Ticker publishValuesTimer;
Ticker publishSensorValuesTimer;
#define SYSTEMCHECK_TIME 20 // every 20 seconds check if Boiler is online
#define SYSTEMCHECK_TIME 10 // every 10 seconds check if EMS can be reached
Ticker systemCheckTimer;
#define REGULARUPDATES_TIME 60 // every minute a call is made to fetch data from EMS devices manually
@@ -145,10 +145,6 @@ char * _float_to_char(char * a, float f, uint8_t precision = 2) {
long p[] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
char * ret = a;
// check for 0x8000 (sensor missing)
if (f == EMS_VALUE_SHORT_NOTSET) {
strlcpy(ret, "?", sizeof(ret));
} else {
long whole = (long)f;
itoa(whole, a, 10);
while (*a != '\0')
@@ -156,7 +152,7 @@ char * _float_to_char(char * a, float f, uint8_t precision = 2) {
*a++ = '.';
long decimal = abs((long)((f - whole) * p[precision]));
itoa(decimal, a, 10);
}
return ret;
}
@@ -315,59 +311,59 @@ void showInfo() {
static char buffer_type[128] = {0};
myDebug("%sEMS-ESP system stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR("%sEMS-ESP system stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
_EMS_SYS_LOGGING sysLog = ems_getLogging();
if (sysLog == EMS_SYS_LOGGING_BASIC) {
myDebug(" System logging set to Basic");
myDebug_P(PSTR(" System logging set to Basic"));
} else if (sysLog == EMS_SYS_LOGGING_VERBOSE) {
myDebug(" System logging set to Verbose");
myDebug_P(PSTR(" System logging set to Verbose"));
} else if (sysLog == EMS_SYS_LOGGING_THERMOSTAT) {
myDebug(" System logging set to Thermostat only");
myDebug_P(PSTR(" System logging set to Thermostat only"));
} else {
myDebug(" System logging set to None");
myDebug_P(PSTR(" System logging set to None"));
}
myDebug(" LED is %s, Listen mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.listen_mode ? "on" : "off");
myDebug_P(PSTR(" LED is %s, Listen 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");
myDebug_P(PSTR(" %d external temperature sensor%s found"), EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors == 1) ? "" : "s");
}
myDebug(" Thermostat is %s, Boiler is %s, Shower Timer is %s, Shower Alert is %s",
myDebug_P(PSTR(" Thermostat is %s, Boiler is %s, Shower Timer is %s, Shower Alert is %s"),
(ems_getThermostatEnabled() ? "enabled" : "disabled"),
(ems_getBoilerEnabled() ? "enabled" : "disabled"),
((EMSESP_Status.shower_timer) ? "enabled" : "disabled"),
((EMSESP_Status.shower_alert) ? "enabled" : "disabled"));
myDebug("\n%sEMS Bus stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR("\n%sEMS Bus stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
if (ems_getBusConnected()) {
myDebug(" Bus is connected");
myDebug_P(PSTR(" Bus is connected"));
myDebug(" Rx: Poll=%d ms, # Rx telegrams read=%d, # CRC errors=%d", ems_getPollFrequency(), EMS_Sys_Status.emsRxPgks, EMS_Sys_Status.emxCrcErr);
myDebug_P(PSTR(" Rx: Poll=%d ms, # Rx telegrams read=%d, # CRC errors=%d"), ems_getPollFrequency(), EMS_Sys_Status.emsRxPgks, EMS_Sys_Status.emxCrcErr);
if (ems_getTxCapable()) {
myDebug(" Tx: available, Tx delay is %s, # Tx telegrams sent=%d", (ems_getTxDelay() ? "on" : "off"), EMS_Sys_Status.emsTxPkgs);
myDebug_P(PSTR(" Tx: available, Tx delay is %s, # Tx telegrams sent=%d"), (ems_getTxDelay() ? "on" : "off"), EMS_Sys_Status.emsTxPkgs);
} else {
myDebug(" Tx: no signal");
myDebug_P(PSTR(" Tx: no signal"));
}
} else {
myDebug(" No connection can be made to the EMS bus");
myDebug_P(PSTR(" No connection can be made to the EMS bus"));
}
myDebug("");
myDebug("%sBoiler stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR(""));
myDebug_P(PSTR("%sBoiler stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
// version details
myDebug(" Boiler: %s", ems_getBoilerDescription(buffer_type));
myDebug_P(PSTR(" Boiler: %s"), ems_getBoilerDescription(buffer_type));
// active stats
if (ems_getBusConnected()) {
if (EMS_Boiler.tapwaterActive != EMS_VALUE_INT_NOTSET) {
myDebug(" Hot tap water: %s", EMS_Boiler.tapwaterActive ? "running" : "off");
myDebug_P(PSTR(" Hot tap water: %s"), EMS_Boiler.tapwaterActive ? "running" : "off");
}
if (EMS_Boiler.heatingActive != EMS_VALUE_INT_NOTSET) {
myDebug(" Central heating: %s", EMS_Boiler.heatingActive ? "active" : "off");
myDebug_P(PSTR(" Central heating: %s"), EMS_Boiler.heatingActive ? "active" : "off");
}
}
@@ -375,11 +371,11 @@ void showInfo() {
_renderBoolValue("Warm Water activated", EMS_Boiler.wWActivated);
_renderBoolValue("Warm Water circulation pump available", EMS_Boiler.wWCircPump);
if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Hot) {
myDebug(" Warm Water comfort setting: Hot");
myDebug_P(PSTR(" Warm Water comfort setting: Hot"));
} else if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Eco) {
myDebug(" Warm Water comfort setting: Eco");
myDebug_P(PSTR(" Warm Water comfort setting: Eco"));
} else if (EMS_Boiler.wWComfort == EMS_VALUE_UBAParameterWW_wwComfort_Intelligent) {
myDebug(" Warm Water comfort setting: Intelligent");
myDebug_P(PSTR(" Warm Water comfort setting: Intelligent"));
}
_renderIntValue("Warm Water selected temperature", "C", EMS_Boiler.wWSelTemp);
@@ -390,7 +386,10 @@ void showInfo() {
_renderIntValue("Warm Water current tap water flow", "l/min", EMS_Boiler.wWCurFlow, 10);
_renderLongValue("Warm Water # starts", "times", EMS_Boiler.wWStarts);
if (EMS_Boiler.wWWorkM != EMS_VALUE_LONG_NOTSET) {
myDebug(" Warm Water active time: %d days %d hours %d minutes", EMS_Boiler.wWWorkM / 1440, (EMS_Boiler.wWWorkM % 1440) / 60, EMS_Boiler.wWWorkM % 60);
myDebug_P(PSTR(" Warm Water active time: %d days %d hours %d minutes"),
EMS_Boiler.wWWorkM / 1440,
(EMS_Boiler.wWWorkM % 1440) / 60,
EMS_Boiler.wWWorkM % 60);
}
_renderBoolValue("Warm Water 3-way valve", EMS_Boiler.wWHeat);
@@ -408,9 +407,9 @@ void showInfo() {
_renderShortValue("Flame current", "uA", EMS_Boiler.flameCurr);
_renderIntValue("System pressure", "bar", EMS_Boiler.sysPress, 10);
if (EMS_Boiler.serviceCode == EMS_VALUE_SHORT_NOTSET) {
myDebug(" System service code: %s", EMS_Boiler.serviceCodeChar);
myDebug_P(PSTR(" System service code: %s"), EMS_Boiler.serviceCodeChar);
} else {
myDebug(" System service code: %s (%d)", EMS_Boiler.serviceCodeChar, EMS_Boiler.serviceCode);
myDebug_P(PSTR(" System service code: %s (%d)"), EMS_Boiler.serviceCodeChar, EMS_Boiler.serviceCode);
}
// UBAParametersMessage
@@ -426,25 +425,28 @@ void showInfo() {
_renderIntValue("Pump modulation", "%", EMS_Boiler.pumpMod);
_renderLongValue("Burner # starts", "times", EMS_Boiler.burnStarts);
if (EMS_Boiler.burnWorkMin != EMS_VALUE_LONG_NOTSET) {
myDebug(" Total burner operating time: %d days %d hours %d minutes",
myDebug_P(PSTR(" Total burner operating time: %d days %d hours %d minutes"),
EMS_Boiler.burnWorkMin / 1440,
(EMS_Boiler.burnWorkMin % 1440) / 60,
EMS_Boiler.burnWorkMin % 60);
}
if (EMS_Boiler.heatWorkMin != EMS_VALUE_LONG_NOTSET) {
myDebug(" Total heat operating time: %d days %d hours %d minutes",
myDebug_P(PSTR(" Total heat operating time: %d days %d hours %d minutes"),
EMS_Boiler.heatWorkMin / 1440,
(EMS_Boiler.heatWorkMin % 1440) / 60,
EMS_Boiler.heatWorkMin % 60);
}
if (EMS_Boiler.UBAuptime != EMS_VALUE_LONG_NOTSET) {
myDebug(" Total UBA working time: %d days %d hours %d minutes", EMS_Boiler.UBAuptime / 1440, (EMS_Boiler.UBAuptime % 1440) / 60, EMS_Boiler.UBAuptime % 60);
myDebug_P(PSTR(" Total UBA working time: %d days %d hours %d minutes"),
EMS_Boiler.UBAuptime / 1440,
(EMS_Boiler.UBAuptime % 1440) / 60,
EMS_Boiler.UBAuptime % 60);
}
// For SM10/SM100 Solar Module
if (EMS_Other.SM) {
myDebug(""); // newline
myDebug("%sSolar Module stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR("")); // newline
myDebug_P(PSTR("%sSolar Module stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
_renderShortValue(" Collector temperature", "C", EMS_Other.SMcollectorTemp);
_renderShortValue(" Bottom temperature", "C", EMS_Other.SMbottomTemp);
_renderIntValue(" Pump modulation", "%", EMS_Other.SMpumpModulation);
@@ -456,9 +458,9 @@ void showInfo() {
// Thermostat stats
if (ems_getThermostatEnabled()) {
myDebug(""); // newline
myDebug("%sThermostat stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug(" Thermostat: %s", ems_getThermostatDescription(buffer_type));
myDebug_P(PSTR("")); // newline
myDebug_P(PSTR("%sThermostat stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR(" Thermostat: %s"), ems_getThermostatDescription(buffer_type));
if ((ems_getThermostatModel() == EMS_MODEL_EASY) || (ems_getThermostatModel() == EMS_MODEL_BOSCHEASY)) {
// for easy temps are * 100, also we don't have the time or mode
_renderShortValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10); // *100
@@ -486,7 +488,7 @@ void showInfo() {
_renderIntValue("Vacation temperature", "C", EMS_Thermostat.holidaytemp, 2); // convert to a single byte * 2
}
myDebug(" Thermostat time is %02d:%02d:%02d %d/%d/%d",
myDebug_P(PSTR(" Thermostat time is %02d:%02d:%02d %d/%d/%d"),
EMS_Thermostat.hour,
EMS_Thermostat.minute,
EMS_Thermostat.second,
@@ -495,36 +497,36 @@ void showInfo() {
EMS_Thermostat.year + 2000);
if (EMS_Thermostat.mode == 0) {
myDebug(" Mode is set to low");
myDebug_P(PSTR(" Mode is set to low"));
} else if (EMS_Thermostat.mode == 1) {
myDebug(" Mode is set to manual");
myDebug_P(PSTR(" Mode is set to manual"));
} else if (EMS_Thermostat.mode == 2) {
myDebug(" Mode is set to auto");
myDebug_P(PSTR(" Mode is set to auto"));
} else {
myDebug(" Mode is set to ?");
myDebug_P(PSTR(" Mode is set to ?"));
}
}
}
// Dallas
if (EMSESP_Status.dallas_sensors != 0) {
myDebug(""); // newline
myDebug_P(PSTR("")); // newline
char buffer[128] = {0};
char valuestr[8] = {0}; // for formatting temp
myDebug("%sExternal temperature sensors:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR("%sExternal temperature sensors:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
for (uint8_t i = 0; i < EMSESP_Status.dallas_sensors; i++) {
myDebug(" Sensor #%d %s: %s C", i + 1, ds18.getDeviceString(buffer, i), _float_to_char(valuestr, ds18.getValue(i)));
myDebug_P(PSTR(" Sensor #%d %s: %s C"), i + 1, ds18.getDeviceString(buffer, i), _float_to_char(valuestr, ds18.getValue(i)));
}
}
// show the Shower Info
if (EMSESP_Status.shower_timer) {
myDebug(""); // newline
myDebug("%sShower stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug(" Shower is %s", (EMSESP_Shower.showerOn ? "running" : "off"));
myDebug_P(PSTR("")); // newline
myDebug_P(PSTR("%sShower stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR(" Shower is %s"), (EMSESP_Shower.showerOn ? "running" : "off"));
}
myDebug(""); // newline
myDebug_P(PSTR("")); // newline
}
// send all dallas sensor values as a JSON package to MQTT
@@ -797,14 +799,14 @@ void publishValues(bool force) {
// sets the shower timer on/off
void set_showerTimer() {
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
myDebug("Shower timer has been set to %s", EMSESP_Status.shower_timer ? "enabled" : "disabled");
myDebug_P(PSTR("Shower timer has been set to %s"), EMSESP_Status.shower_timer ? "enabled" : "disabled");
}
}
// sets the shower alert on/off
void set_showerAlert() {
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
myDebug("Shower alert has been set to %s", EMSESP_Status.shower_alert ? "enabled" : "disabled");
myDebug_P(PSTR("Shower alert has been set to %s"), EMSESP_Status.shower_alert ? "enabled" : "disabled");
}
}
@@ -872,7 +874,7 @@ void do_ledcheck() {
// Thermostat scan
void do_scanThermostat() {
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebug("> Scanning thermostat message type #0x%02X...", scanThermostat_count);
myDebug_P(PSTR("> Scanning thermostat message type #0x%02X..."), scanThermostat_count);
ems_doReadCommand(scanThermostat_count, EMS_Thermostat.device_id);
scanThermostat_count++;
}
@@ -881,7 +883,7 @@ void do_scanThermostat() {
// do a system health check every now and then to see if we all connections
void do_systemCheck() {
if ((!ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebug("Error! Unable to read the EMS bus. Retrying in %d seconds...", SYSTEMCHECK_TIME);
myDebug_P(PSTR("Error! Unable to read the EMS bus."));
}
}
@@ -910,7 +912,7 @@ void stopDeviceScan() {
void do_scanDevices() {
if (scanDevices_count == 0) {
// we're at the finish line
myDebug("Finished the deep EMS device scan.");
myDebug_P(PSTR("Finished the deep EMS device scan."));
stopDeviceScan();
ems_printDevices();
ems_setLogging(EMS_SYS_LOGGING_NONE);
@@ -918,7 +920,6 @@ void do_scanDevices() {
}
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
// myDebug("> Scanning EMS bus for a device type 0x%02X...", scanDevices_count);
ems_doReadCommand(EMS_TYPE_Version, scanDevices_count++); // ask for version
}
}
@@ -931,7 +932,7 @@ void startDeviceScan() {
publishSensorValuesTimer.detach();
scanDevices_count = 1; // starts at 1
ems_setLogging(EMS_SYS_LOGGING_NONE);
myDebug("Starting a deep EMS device scan. This can take up to 2 minutes. Please wait...");
myDebug_P(PSTR("Starting a deep EMS device scan. This can take up to 2 minutes. Please wait..."));
scanThermostat.attach_ms(SCANDEVICES_TIME, do_scanDevices);
}
@@ -943,7 +944,7 @@ void startThermostatScan(uint8_t start) {
systemCheckTimer.detach();
regularUpdatesTimer.detach();
scanThermostat_count = start;
myDebug("Starting a deep message scan on thermostat");
myDebug_P(PSTR("Starting a deep message scan on thermostat"));
scanThermostat.attach(SCANTHERMOSTAT_TIME, do_scanThermostat);
}
@@ -1074,7 +1075,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
// let's make sure LED is really off - For onboard high=off
digitalWrite(EMSESP_Status.led_gpio, (EMSESP_Status.led_gpio == LED_BUILTIN) ? HIGH : LOW);
} else {
myDebug("Error. Usage: set led <on | off>");
myDebug_P(PSTR("Error. Usage: set led <on | off>"));
}
}
@@ -1083,15 +1084,15 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
if (strcmp(value, "on") == 0) {
EMSESP_Status.listen_mode = true;
ok = true;
myDebug("* in listen mode. All Tx is disabled.");
myDebug_P(PSTR("* in listen mode. All Tx is disabled."));
ems_setTxDisabled(true);
} else if (strcmp(value, "off") == 0) {
EMSESP_Status.listen_mode = false;
ok = true;
ems_setTxDisabled(false);
myDebug("* out of listen mode. Tx is enabled.");
myDebug_P(PSTR("* out of listen mode. Tx is enabled."));
} else {
myDebug("Error. Usage: set listen_mode <on | off>");
myDebug_P(PSTR("Error. Usage: set listen_mode <on | off>"));
}
}
@@ -1119,7 +1120,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.dallas_parasite = false;
ok = true;
} else {
myDebug("Error. Usage: set dallas_parasite <on | off>");
myDebug_P(PSTR("Error. Usage: set dallas_parasite <on | off>"));
}
}
@@ -1144,7 +1145,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.shower_timer = false;
ok = true;
} else {
myDebug("Error. Usage: set shower_timer <on | off>");
myDebug_P(PSTR("Error. Usage: set shower_timer <on | off>"));
}
}
@@ -1157,7 +1158,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
EMSESP_Status.shower_alert = false;
ok = true;
} else {
myDebug("Error. Usage: set shower_alert <on | off>");
myDebug_P(PSTR("Error. Usage: set shower_alert <on | off>"));
}
}
@@ -1175,7 +1176,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
ems_setThermostatHC(hc);
ok = true;
} else {
myDebug("Error. Usage: set heating_circuit <1 | 2>");
myDebug_P(PSTR("Error. Usage: set heating_circuit <1 | 2>"));
}
}
@@ -1188,36 +1189,36 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
ems_setTxDelay(false);
ok = true;
} else {
myDebug("Error. Usage: set tx_delay <on | off>");
myDebug_P(PSTR("Error. Usage: set tx_delay <on | off>"));
}
}
}
if (action == MYESP_FSACTION_LIST) {
myDebug(" led=%s", EMSESP_Status.led ? "on" : "off");
myDebug(" led_gpio=%d", EMSESP_Status.led_gpio);
myDebug(" dallas_gpio=%d", EMSESP_Status.dallas_gpio);
myDebug(" dallas_parasite=%s", EMSESP_Status.dallas_parasite ? "on" : "off");
myDebug_P(PSTR(" led=%s"), EMSESP_Status.led ? "on" : "off");
myDebug_P(PSTR(" led_gpio=%d"), EMSESP_Status.led_gpio);
myDebug_P(PSTR(" dallas_gpio=%d"), EMSESP_Status.dallas_gpio);
myDebug_P(PSTR(" dallas_parasite=%s"), EMSESP_Status.dallas_parasite ? "on" : "off");
if (EMS_Thermostat.device_id == EMS_ID_NONE) {
myDebug(" thermostat_type=<not set>");
myDebug_P(PSTR(" thermostat_type=<not set>"));
} else {
myDebug(" thermostat_type=%02X", EMS_Thermostat.device_id);
myDebug_P(PSTR(" thermostat_type=%02X"), EMS_Thermostat.device_id);
}
myDebug(" heating_circuit=%d", EMSESP_Status.heating_circuit);
myDebug_P(PSTR(" heating_circuit=%d"), EMSESP_Status.heating_circuit);
if (EMS_Boiler.device_id == EMS_ID_NONE) {
myDebug(" boiler_type=<not set>");
myDebug_P(PSTR(" boiler_type=<not set>"));
} else {
myDebug(" boiler_type=%02X", EMS_Boiler.device_id);
myDebug_P(PSTR(" boiler_type=%02X"), EMS_Boiler.device_id);
}
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);
myDebug(" tx_delay=%s", ems_getTxDelay() ? "on" : "off");
myDebug_P(PSTR(" listen_mode=%s"), EMSESP_Status.listen_mode ? "on" : "off");
myDebug_P(PSTR(" shower_timer=%s"), EMSESP_Status.shower_timer ? "on" : "off");
myDebug_P(PSTR(" shower_alert=%s"), EMSESP_Status.shower_alert ? "on" : "off");
myDebug_P(PSTR(" publish_wait=%d"), EMSESP_Status.publish_wait);
myDebug_P(PSTR(" tx_delay=%s"), ems_getTxDelay() ? "on" : "off");
}
return ok;
@@ -1251,7 +1252,7 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
}
if (strcmp(first_cmd, "refresh") == 0) {
myDebug("Fetching data from EMS devices...");
myDebug_P(PSTR("Fetching data from EMS devices..."));
do_regularUpdates();
ok = true;
}
@@ -1431,14 +1432,14 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_TEMP) == 0) {
float f = strtof((char *)message, 0);
char s[10] = {0};
myDebug("MQTT topic: thermostat temperature value %s", _float_to_char(s, f));
myDebug_P(PSTR("MQTT topic: thermostat temperature value %s"), _float_to_char(s, f));
ems_setThermostatTemp(f);
publishValues(true); // publish back immediately, can't remember why I do this?!
}
// thermostat mode changes
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_MODE) == 0) {
myDebug("MQTT topic: thermostat mode value %s", message);
myDebug_P(PSTR("MQTT topic: thermostat mode value %s"), message);
if (strcmp((char *)message, "auto") == 0) {
ems_setThermostatMode(2);
} else if (strcmp((char *)message, "day") == 0 || strcmp((char *)message, "manual") == 0) {
@@ -1450,7 +1451,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
// thermostat heating circuit change
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_HC) == 0) {
myDebug("MQTT topic: thermostat heating circuit value %s", message);
myDebug_P(PSTR("MQTT topic: thermostat heating circuit value %s"), message);
uint8_t hc = atoi((char *)message);
if ((hc >= 1) && (hc <= 2)) {
EMSESP_Status.heating_circuit = hc;
@@ -1463,7 +1464,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_NIGHTTEMP) == 0) {
float f = strtof((char *)message, 0);
char s[10] = {0};
myDebug("MQTT topic: new thermostat night temperature value %s", _float_to_char(s, f));
myDebug_P(PSTR("MQTT topic: new thermostat night temperature value %s"), _float_to_char(s, f));
ems_setThermostatTemp(f, 1);
}
@@ -1471,7 +1472,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_DAYTEMP) == 0) {
float f = strtof((char *)message, 0);
char s[10] = {0};
myDebug("MQTT topic: new thermostat day temperature value %s", _float_to_char(s, f));
myDebug_P(PSTR("MQTT topic: new thermostat day temperature value %s"), _float_to_char(s, f));
ems_setThermostatTemp(f, 2);
}
@@ -1479,7 +1480,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (strcmp(topic, TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP) == 0) {
float f = strtof((char *)message, 0);
char s[10] = {0};
myDebug("MQTT topic: new thermostat holiday temperature value %s", _float_to_char(s, f));
myDebug_P(PSTR("MQTT topic: new thermostat holiday temperature value %s"), _float_to_char(s, f));
ems_setThermostatTemp(f, 3);
}
@@ -1495,14 +1496,14 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
// boiler wwtemp changes
if (strcmp(topic, TOPIC_BOILER_CMD_WWTEMP) == 0) {
uint8_t t = atoi((char *)message);
myDebug("MQTT topic: boiler warm water temperature value %d", t);
myDebug_P(PSTR("MQTT topic: boiler warm water temperature value %d"), t);
ems_setWarmWaterTemp(t);
publishValues(true); // publish back immediately, can't remember why I do this?!
}
// boiler ww comfort setting
if (strcmp(topic, TOPIC_BOILER_CMD_COMFORT) == 0) {
myDebug("MQTT topic: boiler warm water comfort value is %s", message);
myDebug_P(PSTR("MQTT topic: boiler warm water comfort value is %s"), message);
if (strcmp((char *)message, "hot") == 0) {
ems_setWarmWaterModeComfort(1);
} else if (strcmp((char *)message, "comfort") == 0) {
@@ -1545,10 +1546,10 @@ void WIFICallback() {
// This is done after we have a WiFi signal to avoid any resource conflicts
if (myESP.getUseSerial()) {
myDebug("Warning! EMS bus disabled when in Serial mode. Use 'set serial off' to start EMS.");
myDebug_P(PSTR("Warning! EMS bus disabled when in Serial mode. Use 'set serial off' to start EMS."));
} else {
emsuart_init();
myDebug("[UART] Opened Rx/Tx connection");
myDebug_P(PSTR("[UART] Opened Rx/Tx connection"));
if (!EMSESP_Status.listen_mode) {
// go and find the boiler and thermostat types, if not in listen mode
ems_discoverModels();
@@ -1628,7 +1629,7 @@ void showerCheck() {
strlcat(s, itoa((uint8_t)((EMSESP_Shower.duration / 1000) % 60), buffer, 10), sizeof(s));
strlcat(s, " seconds", sizeof(s));
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
myDebug("[Shower] finished with duration %s", s);
myDebug_P(PSTR("[Shower] finished with duration %s"), s);
}
myESP.mqttPublish(TOPIC_SHOWERTIME, s); // publish to MQTT
}

View File

@@ -21,6 +21,7 @@ uint8_t _TEST_DATA_max = ArraySize(TEST_DATA);
// myESP for logging to telnet and serial
#define myDebug(...) myESP.myDebug(__VA_ARGS__)
#define myDebug_P(...) myESP.myDebug_P(__VA_ARGS__)
_EMS_Sys_Status EMS_Sys_Status; // EMS Status
@@ -321,7 +322,7 @@ void ems_init() {
// Getters and Setters for parameters
void ems_setPoll(bool b) {
EMS_Sys_Status.emsPollEnabled = b;
myDebug("EMS Bus Poll is set to %s", EMS_Sys_Status.emsPollEnabled ? "enabled" : "disabled");
myDebug_P(PSTR("EMS Bus Poll is set to %s"), EMS_Sys_Status.emsPollEnabled ? "enabled" : "disabled");
}
bool ems_getPoll() {
@@ -330,7 +331,7 @@ bool ems_getPoll() {
void ems_setTxDelay(bool b) {
EMS_Sys_Status.emsTxDelay = b;
myDebug("EMS Tx delay is %s", EMS_Sys_Status.emsTxDelay ? "enabled" : "disabled");
myDebug_P(PSTR("EMS Tx delay is %s"), EMS_Sys_Status.emsTxDelay ? "enabled" : "disabled");
}
bool ems_getTxDelay() {
@@ -391,15 +392,15 @@ void ems_setLogging(_EMS_SYS_LOGGING loglevel) {
if (loglevel <= EMS_SYS_LOGGING_VERBOSE) {
EMS_Sys_Status.emsLogging = loglevel;
if (loglevel == EMS_SYS_LOGGING_NONE) {
myDebug("System Logging set to None");
myDebug_P(PSTR("System Logging set to None"));
} else if (loglevel == EMS_SYS_LOGGING_BASIC) {
myDebug("System Logging set to Basic");
myDebug_P(PSTR("System Logging set to Basic"));
} else if (loglevel == EMS_SYS_LOGGING_VERBOSE) {
myDebug("System Logging set to Verbose");
myDebug_P(PSTR("System Logging set to Verbose"));
} else if (loglevel == EMS_SYS_LOGGING_THERMOSTAT) {
myDebug("System Logging set to Thermostat only");
myDebug_P(PSTR("System Logging set to Thermostat only"));
} else if (loglevel == EMS_SYS_LOGGING_RAW) {
myDebug("System Logging set to Raw mode");
myDebug_P(PSTR("System Logging set to Raw mode"));
}
}
}
@@ -709,7 +710,7 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
} else if (value == EMS_TX_ERROR) {
// last write failed (04), delete it from queue and dont bother to retry
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE) {
myDebug("** Write command failed from host");
myDebug_P(PSTR("** Write command failed from host"));
}
emsaurt_tx_poll(); // send a poll to free the EMS bus
_removeTxQueue(); // remove from queue
@@ -912,7 +913,7 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
if ((EMS_Types[i].processType_cb) != (void *)NULL) {
// print non-verbose message
if ((EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_BASIC) || (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_VERBOSE)) {
myDebug("<--- %s(0x%02X)", EMS_Types[i].typeString, type);
myDebug_P(PSTR("<--- %s(0x%02X)"), EMS_Types[i].typeString, type);
}
// call callback function to process the telegram, only if there is data
if (EMS_RxTelegram->emsplus) {
@@ -990,7 +991,6 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// all checks out, read was successful, remove tx from queue and continue to process telegram
_removeTxQueue();
EMS_Sys_Status.emsRxPgks++; // increment counter
// myDebug("** Read from 0x%02X ok", type);
ems_setEmsRefreshed(EMS_TxTelegram.forceRefresh); // does mqtt need refreshing?
} else {
// read not OK, we didn't get back a telegram we expected
@@ -999,12 +999,12 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// if retried too many times, give up and remove it
if (EMS_Sys_Status.txRetryCount >= TX_WRITE_TIMEOUT_COUNT) {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("Read failed. Giving up, removing from queue");
myDebug_P(PSTR("Read failed. Giving up, removing from queue"));
}
_removeTxQueue();
} else {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("...Retrying read. Attempt %d/%d...", EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
myDebug_P(PSTR("...Retrying read. Attempt %d/%d..."), EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
}
}
}
@@ -1013,7 +1013,7 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_WRITE) {
// should not get here, since this is handled earlier receiving a 01 or 04
myDebug("** Error ! Write - should not be here");
myDebug_P(PSTR("** Error ! Write - should not be here"));
}
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_VALIDATE) {
@@ -1024,24 +1024,24 @@ void _processType(_EMS_RxTelegram * EMS_RxTelegram) {
// validate was successful, the write changed the value
_removeTxQueue(); // now we can remove the Tx validate command the queue
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("Write to 0x%02X was successful", EMS_TxTelegram.dest);
myDebug_P(PSTR("Write to 0x%02X was successful"), EMS_TxTelegram.dest);
}
// follow up with the post read command
ems_doReadCommand(EMS_TxTelegram.comparisonPostRead, EMS_TxTelegram.dest, true);
} else {
// write failed
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("Last write failed. Compared set value 0x%02X with received value 0x%02X", EMS_TxTelegram.comparisonValue, dataReceived);
myDebug_P(PSTR("Last write failed. Compared set value 0x%02X with received value 0x%02X"), EMS_TxTelegram.comparisonValue, dataReceived);
}
if (++EMS_Sys_Status.txRetryCount > TX_WRITE_TIMEOUT_COUNT) {
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("Write failed. Giving up, removing from queue");
myDebug_P(PSTR("Write failed. Giving up, removing from queue"));
}
_removeTxQueue();
} else {
// retry, turn the validate back into a write and try again
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("...Retrying write. Attempt %d/%d...", EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
myDebug_P(PSTR("...Retrying write. Attempt %d/%d..."), EMS_Sys_Status.txRetryCount, TX_WRITE_TIMEOUT_COUNT);
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
EMS_TxTelegram.dataValue = EMS_TxTelegram.comparisonValue; // restore old value
@@ -1443,10 +1443,10 @@ void _process_SetPoints(_EMS_RxTelegram * EMS_RxTelegram) {
strlcpy(s, itoa(setpoint >> 1, s2, 10), 5);
strlcat(s, ".", sizeof(s));
strlcat(s, ((setpoint & 0x01) ? "5" : "0"), 5);
myDebug(" Boiler flow temp %s C, Warm Water power %d %", s, ww_power);
myDebug_P(PSTR(" Boiler flow temp %s C, Warm Water power %d %"), s, ww_power);
*/
myDebug(" Boiler flow temperature is %d C", setpoint);
myDebug_P(PSTR(" Boiler flow temperature is %d C"), setpoint);
}
}
}
@@ -1518,7 +1518,11 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) {
// its a boiler
myDebug("Boiler found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)", Boiler_Types[i].model_string, Boiler_Types[i].device_id, product_id, version);
myDebug_P(PSTR("Boiler found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
Boiler_Types[i].model_string,
Boiler_Types[i].device_id,
product_id,
version);
// add to list
_addDevice(product_id, Boiler_Types[i].device_id, version, Boiler_Types[i].model_string);
@@ -1526,7 +1530,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// if its a boiler set it, unless it already has been set by checking for a productID
// it will take the first one found in the list
if (((EMS_Boiler.device_id == EMS_ID_NONE) || (EMS_Boiler.device_id == Boiler_Types[i].device_id)) && EMS_Boiler.product_id == EMS_ID_NONE) {
myDebug("* Setting Boiler to model %s (DeviceID:0x%02X ProductID:%d Version:%s)",
myDebug_P(PSTR("* Setting Boiler to model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
Boiler_Types[i].model_string,
Boiler_Types[i].device_id,
product_id,
@@ -1556,7 +1560,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (typeFound) {
// its a known thermostat
if (EMS_Sys_Status.emsLogging >= EMS_SYS_LOGGING_BASIC) {
myDebug("Thermostat found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)",
myDebug_P(PSTR("Thermostat found. Model %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
Thermostat_Types[i].model_string,
Thermostat_Types[i].device_id,
product_id,
@@ -1570,7 +1574,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
if (((EMS_Thermostat.device_id == EMS_ID_NONE) || (EMS_Thermostat.model_id == EMS_MODEL_NONE)
|| (EMS_Thermostat.device_id == Thermostat_Types[i].device_id))
&& EMS_Thermostat.product_id == EMS_ID_NONE) {
myDebug("* Setting Thermostat model to %s (DeviceID:0x%02X ProductID:%d Version:%s)",
myDebug_P(PSTR("* Setting Thermostat model to %s (DeviceID:0x%02X ProductID:%d Version:%s)"),
Thermostat_Types[i].model_string,
Thermostat_Types[i].device_id,
product_id,
@@ -1601,7 +1605,11 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
}
if (typeFound) {
myDebug("Device found. Model %s with DeviceID 0x%02X, ProductID %d, Version %s", Other_Types[i].model_string, Other_Types[i].device_id, product_id, version);
myDebug_P(PSTR("Device found. Model %s with DeviceID 0x%02X, ProductID %d, Version %s"),
Other_Types[i].model_string,
Other_Types[i].device_id,
product_id,
version);
// add to list
_addDevice(product_id, Other_Types[i].device_id, version, Other_Types[i].model_string);
@@ -1609,7 +1617,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
// see if this is a Solar Module SM10
if (Other_Types[i].device_id == EMS_ID_SM) {
EMS_Other.SM = true; // we have detected a SM10
myDebug("SM10 Solar Module support enabled.");
myDebug_P(PSTR("SM10 Solar Module support enabled."));
}
// fetch other values
@@ -1617,7 +1625,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
return;
} else {
myDebug("Unrecognized device found. DeviceID 0x%02X, ProductID %d, Version %s", EMS_RxTelegram->src, product_id, version);
myDebug_P(PSTR("Unrecognized device found. DeviceID 0x%02X, ProductID %d, Version %s"), EMS_RxTelegram->src, product_id, version);
// add to list
_addDevice(product_id, EMS_RxTelegram->src, version, "unknown?");
@@ -1628,7 +1636,7 @@ void _process_Version(_EMS_RxTelegram * EMS_RxTelegram) {
* Figure out the boiler and thermostat types
*/
void ems_discoverModels() {
myDebug("Starting auto discover of EMS devices...");
myDebug_P(PSTR("Starting auto discover of EMS devices..."));
// boiler
ems_doReadCommand(EMS_TYPE_Version, EMS_Boiler.device_id); // get version details of boiler
@@ -1654,11 +1662,11 @@ void ems_printTxQueue() {
char sType[20] = {0};
if (EMS_TxQueue.size() == 0) {
myDebug("Tx queue is empty");
myDebug_P(PSTR("Tx queue is empty"));
return;
}
myDebug("Tx queue (%d/%d)", EMS_TxQueue.size(), EMS_TxQueue.capacity);
myDebug_P(PSTR("Tx queue (%d/%d)"), EMS_TxQueue.size(), EMS_TxQueue.capacity);
for (byte i = 0; i < EMS_TxQueue.size(); i++) {
EMS_TxTelegram = EMS_TxQueue[i]; // retrieves the i-th element from the buffer without removing it
@@ -1683,8 +1691,8 @@ void ems_printTxQueue() {
(uint8_t)((upt / (1000 * 60)) % 60),
(uint8_t)((upt / 1000) % 60));
myDebug(" [%d] action=%s dest=0x%02x type=0x%02x offset=%d length=%d dataValue=%d "
"comparisonValue=%d type_validate=0x%02x comparisonPostRead=0x%02x @ %s",
myDebug_P(PSTR(" [%d] action=%s dest=0x%02x type=0x%02x offset=%d length=%d dataValue=%d "
"comparisonValue=%d type_validate=0x%02x comparisonPostRead=0x%02x @ %s"),
i + 1,
sType,
EMS_TxTelegram.dest & 0x7F,
@@ -1839,7 +1847,7 @@ char * ems_getBoilerDescription(char * buffer) {
* Find the versions of our connected devices
*/
void ems_scanDevices() {
myDebug("Started scan on EMS bus for known devices");
myDebug_P(PSTR("Started scan on EMS bus for known devices"));
std::list<uint8_t> Device_Ids; // create a new list
@@ -1875,9 +1883,9 @@ void ems_scanDevices() {
void ems_printAllDevices() {
uint8_t i;
myDebug("\nThese %d devices are supported as boiler units:", _Boiler_Types_max);
myDebug_P(PSTR("\nThese %d devices are supported as boiler units:"), _Boiler_Types_max);
for (i = 0; i < _Boiler_Types_max; i++) {
myDebug(" %s%s%s (DeviceID:0x%02X ProductID:%d)",
myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d)"),
COLOR_BOLD_ON,
Boiler_Types[i].model_string,
COLOR_BOLD_OFF,
@@ -1885,9 +1893,9 @@ void ems_printAllDevices() {
Boiler_Types[i].product_id);
}
myDebug("\nThese %d devices are supported as other known EMS devices:", _Other_Types_max);
myDebug_P(PSTR("\nThese %d devices are supported as other known EMS devices:"), _Other_Types_max);
for (i = 0; i < _Other_Types_max; i++) {
myDebug(" %s%s%s (DeviceID:0x%02X ProductID:%d)",
myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d)"),
COLOR_BOLD_ON,
Other_Types[i].model_string,
COLOR_BOLD_OFF,
@@ -1895,16 +1903,16 @@ void ems_printAllDevices() {
Other_Types[i].product_id);
}
myDebug("\nThe following telegram type IDs are supported:");
myDebug_P(PSTR("\nThe following telegram type IDs are supported:"));
for (i = 0; i < _EMS_Types_max; i++) {
if ((EMS_Types[i].model_id == EMS_MODEL_ALL) || (EMS_Types[i].model_id == EMS_MODEL_UBA)) {
myDebug(" type %02X (%s)", EMS_Types[i].type, EMS_Types[i].typeString);
myDebug_P(PSTR(" type %02X (%s)"), EMS_Types[i].type, EMS_Types[i].typeString);
}
}
myDebug("\nThese %d thermostat devices are supported:", _Thermostat_Types_max);
myDebug_P(PSTR("\nThese %d thermostat devices are supported:"), _Thermostat_Types_max);
for (i = 0; i < _Thermostat_Types_max; i++) {
myDebug(" %s%s%s (DeviceID:0x%02X ProductID:%d) can write:%c",
myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d) can write:%c"),
COLOR_BOLD_ON,
Thermostat_Types[i].model_string,
COLOR_BOLD_OFF,
@@ -1916,7 +1924,7 @@ void ems_printAllDevices() {
// print out known devices
ems_printDevices();
myDebug(""); // newline
myDebug_P(PSTR("")); // newline
}
/**
@@ -1924,9 +1932,9 @@ void ems_printAllDevices() {
*/
void ems_printDevices() {
if (Devices.size() != 0) {
myDebug("\nThese %d EMS devices were detected:", Devices.size());
myDebug_P(PSTR("\nThese %d EMS devices were detected:"), Devices.size());
for (std::list<_Generic_Type>::iterator it = Devices.begin(); it != Devices.end(); it++) {
myDebug(" %s%s%s (DeviceID:0x%02X ProductID:%d Version:%s)",
myDebug_P(PSTR(" %s%s%s (DeviceID:0x%02X ProductID:%d Version:%s)"),
COLOR_BOLD_ON,
(it)->model_string,
COLOR_BOLD_OFF,
@@ -1935,8 +1943,8 @@ void ems_printDevices() {
(it)->version);
}
myDebug("\nNote: if any devices are marked as 'unknown?' please report this as a GitHub issue so the EMS devices list can be "
"updated.\n");
myDebug_P(PSTR("\nNote: if any devices are marked as 'unknown?' please report this as a GitHub issue so the EMS devices list can be "
"updated.\n"));
}
}
@@ -1952,7 +1960,7 @@ void ems_doReadCommand(uint16_t type, uint8_t dest, bool forceRefresh) {
// if we're preventing all outbound traffic, quit
if (EMS_Sys_Status.emsTxDisabled) {
myDebug("in Listen Mode. All Tx is disabled.");
myDebug_P(PSTR("in Listen Mode. All Tx is disabled."));
return;
}
@@ -1965,9 +1973,9 @@ void ems_doReadCommand(uint16_t type, uint8_t dest, bool forceRefresh) {
if ((ems_getLogging() == EMS_SYS_LOGGING_BASIC) || (ems_getLogging() == EMS_SYS_LOGGING_VERBOSE)) {
if (i == -1) {
myDebug("Requesting type (0x%02X) from dest 0x%02X", type, dest);
myDebug_P(PSTR("Requesting type (0x%02X) from dest 0x%02X"), type, dest);
} else {
myDebug("Requesting type %s(0x%02X) from dest 0x%02X", EMS_Types[i].typeString, type, dest);
myDebug_P(PSTR("Requesting type %s(0x%02X) from dest 0x%02X"), EMS_Types[i].typeString, type, dest);
}
}
EMS_TxTelegram.action = EMS_TX_TELEGRAM_READ; // read command
@@ -2046,7 +2054,7 @@ void ems_setThermostatTemp(float temperature, uint8_t temptype) {
}
if (!EMS_Thermostat.write_supported) {
myDebug("Write not supported for this model Thermostat");
myDebug_P(PSTR("Write not supported for this model Thermostat"));
return;
}
@@ -2061,7 +2069,7 @@ void ems_setThermostatTemp(float temperature, uint8_t temptype) {
EMS_TxTelegram.action = EMS_TX_TELEGRAM_WRITE;
EMS_TxTelegram.dest = type;
myDebug("Setting new thermostat temperature");
myDebug_P(PSTR("Setting new thermostat temperature"));
// when doing a comparison to validate the new temperature we call a different type
@@ -2129,7 +2137,7 @@ void ems_setThermostatMode(uint8_t mode) {
}
if (!EMS_Thermostat.write_supported) {
myDebug("Write not supported for this model Thermostat");
myDebug_P(PSTR("Write not supported for this model Thermostat"));
return;
}
@@ -2137,7 +2145,7 @@ void ems_setThermostatMode(uint8_t mode) {
uint8_t type = EMS_Thermostat.device_id;
uint8_t hc = EMS_Thermostat.hc;
myDebug("Setting thermostat mode to %d", mode);
myDebug_P(PSTR("Setting thermostat mode to %d"), mode);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -2178,7 +2186,7 @@ void ems_setWarmWaterTemp(uint8_t temperature) {
return;
}
myDebug("Setting boiler warm water temperature to %d C", temperature);
myDebug_P(PSTR("Setting boiler warm water temperature to %d C"), temperature);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -2204,7 +2212,7 @@ void ems_setWarmWaterTemp(uint8_t temperature) {
* Set the boiler flow temp
*/
void ems_setFlowTemp(uint8_t temperature) {
myDebug("Setting boiler flow temperature to %d C", temperature);
myDebug_P(PSTR("Setting boiler flow temperature to %d C"), temperature);
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -2236,13 +2244,13 @@ void ems_setWarmWaterModeComfort(uint8_t comfort) {
EMS_Sys_Status.txRetryCount = 0; // reset retry counter
if (comfort == 1) {
myDebug("Setting boiler warm water comfort mode to Hot");
myDebug_P(PSTR("Setting boiler warm water comfort mode to Hot"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Hot;
} else if (comfort == 2) {
myDebug("Setting boiler warm water comfort mode to Eco");
myDebug_P(PSTR("Setting boiler warm water comfort mode to Eco"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Eco;
} else if (comfort == 3) {
myDebug("Setting boiler warm water comfort mode to Intelligent");
myDebug_P(PSTR("Setting boiler warm water comfort mode to Intelligent"));
EMS_TxTelegram.dataValue = EMS_VALUE_UBAParameterWW_wwComfort_Intelligent;
} else {
return; // invalid comfort value
@@ -2263,7 +2271,7 @@ void ems_setWarmWaterModeComfort(uint8_t comfort) {
* true = on, false = off
*/
void ems_setWarmWaterActivated(bool activated) {
myDebug("Setting boiler warm water %s", activated ? "on" : "off");
myDebug_P(PSTR("Setting boiler warm water %s"), activated ? "on" : "off");
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -2286,7 +2294,7 @@ void ems_setWarmWaterActivated(bool activated) {
* Using the type 0x1D to put the boiler into Test mode. This may be shown on the boiler with a flashing 'T'
*/
void ems_setWarmTapWaterActivated(bool activated) {
myDebug("Setting boiler warm tap water %s", activated ? "on" : "off");
myDebug_P(PSTR("Setting boiler warm tap water %s"), activated ? "on" : "off");
_EMS_TxTelegram EMS_TxTelegram = EMS_TX_TELEGRAM_NEW; // create new Tx
EMS_TxTelegram.timestamp = millis(); // set timestamp
@@ -2335,10 +2343,10 @@ void ems_setWarmTapWaterActivated(bool activated) {
*/
void ems_startupTelegrams() {
if ((EMS_Sys_Status.emsTxDisabled) || (!EMS_Sys_Status.emsBusConnected)) {
myDebug("Unable to send startup sequence when in listen mode or the bus is disabled");
myDebug_P(PSTR("Unable to send startup sequence when in listen mode or the bus is disabled"));
}
myDebug("Sending startup sequence...");
myDebug_P(PSTR("Sending startup sequence..."));
char s[20] = {0};
// Write type 0x1D to get out of function test mode
@@ -2356,7 +2364,7 @@ void ems_startupTelegrams() {
void ems_testTelegram(uint8_t test_num) {
#ifdef TESTS
if ((test_num == 0) || (test_num > _TEST_DATA_max)) {
myDebug("Invalid test. Pick between 1 and %d", _TEST_DATA_max);
myDebug_P(PSTR("Invalid test. Pick between 1 and %d"), _TEST_DATA_max);
return;
}
@@ -2393,11 +2401,11 @@ 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", test_num, TEST_DATA[test_num - 1]);
myDebug_P(PSTR("[TEST %d] Injecting telegram %s"), test_num, TEST_DATA[test_num - 1]);
// go an parse it
_ems_readTelegram(telegram, length + 1); // include CRC in length
#else
myDebug("Firmware not compiled with test data set");
myDebug_P(PSTR("Firmware not compiled with test data set"));
#endif
}