1.5.1 - fixes some bugs in 1.5.0

This commit is contained in:
proddy
2019-02-04 00:32:50 +01:00
parent 4c41f61c24
commit 2b66688710
7 changed files with 61 additions and 27 deletions

View File

@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.5.1] 2019-02-03
### Fixed
- issue with Serial monitoring conflicting with UART when both running
### Changed
- `thermostat temp` now except floats (e.g. 20.5). Some thermostats may round up or down if they use 0.5 intervals.
## [1.5.0] 2019-02-03 ## [1.5.0] 2019-02-03
### Added ### Added

View File

@@ -102,6 +102,11 @@ void MyESP::myDebug_P(PGM_P format_P, ...) {
delete[] buffer; delete[] buffer;
} }
// use Serial?
bool MyESP::getUseSerial() {
return (_use_serial);
}
// called when WiFi is connected, and used to start MDNS // called when WiFi is connected, and used to start MDNS
void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) { void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
if ((code == MESSAGE_CONNECTED)) { if ((code == MESSAGE_CONNECTED)) {
@@ -629,6 +634,9 @@ void MyESP::_telnetHandle() {
if (charsRead > 0) { if (charsRead > 0) {
charsRead = 0; // is static, so have to reset charsRead = 0; // is static, so have to reset
_suspendOutput = false; _suspendOutput = false;
if (_use_serial) {
SerialAndTelnet.println(); // force newline if in Telnet
}
_telnetCommand(_command); _telnetCommand(_command);
} }
break; break;
@@ -814,9 +822,10 @@ void MyESP::_fs_printConfig() {
// format File System // format File System
void MyESP::_fs_eraseConfig() { void MyESP::_fs_eraseConfig() {
myDebug_P(PSTR("[FS] Erasing settings, please wait. ESP will automatically restart when finished.")); myDebug_P(PSTR("[FS] Erasing settings, please wait a few seconds. ESP will automatically restart when finished."));
if (SPIFFS.format()) { if (SPIFFS.format()) {
delay(2000); // wait 2 seconds
resetESP(); resetESP();
} }
} }
@@ -833,7 +842,7 @@ bool MyESP::_fs_loadConfig() {
myDebug_P(PSTR("[FS] Failed to open config file")); myDebug_P(PSTR("[FS] Failed to open config file"));
// file does not exist, so assume its the first install. Set serial to on // file does not exist, so assume its the first install. Set serial to on
_use_serial = true; _use_serial = true;
return false; return false; // this will trigger a new file being created
} }
size_t size = configFile.size(); size_t size = configFile.size();

View File

@@ -113,6 +113,7 @@ class MyESP {
void myDebug(const char * format, ...); void myDebug(const char * format, ...);
void myDebug_P(PGM_P format_P, ...); void myDebug_P(PGM_P format_P, ...);
void setTelnet(command_t * cmds, uint8_t count, telnetcommand_callback_f callback_cmd, telnet_callback_f callback); void setTelnet(command_t * cmds, uint8_t count, telnetcommand_callback_f callback_cmd, telnet_callback_f callback);
bool getUseSerial();
// FS // FS
void setSettings(fs_callback_f callback, fs_settings_callback_f fs_settings_callback); void setSettings(fs_callback_f callback, fs_settings_callback_f fs_settings_callback);

View File

@@ -10,7 +10,7 @@ build_flags = -g -w
wifi_settings = wifi_settings =
; hard code if you prefer. Recommendation is to set from within the app when in Serial or AP mode ; hard code if you prefer. Recommendation is to set from within the app when in Serial or AP mode
;wifi_settings = -DWIFI_SSID="your_ssid" -DWIFI_PASSWORD="your_pw" ;wifi_settings = '-DWIFI_SSID="XXXX"' '-DWIFI_PASSWORD="XXXX"'
lib_deps = lib_deps =
CRC32 CRC32

View File

@@ -78,7 +78,7 @@ typedef struct {
command_t PROGMEM project_cmds[] = { command_t PROGMEM project_cmds[] = {
{"set led <on | off>", "toggle status LED on/off"}, {"set led <on | off>", "toggle status LED on/off"},
{"set led_gpio <pin>", "set the LED pin (onboard=2)"}, {"set led_gpio <pin>", "set the LED pin (onboard=16)"},
{"set dallas_gpio <pin>", "set the pin for the external Dallas temperature sensor (D5=14)"}, {"set dallas_gpio <pin>", "set the pin for the external Dallas temperature sensor (D5=14)"},
{"set thermostat_type <hex type ID>", "set the thermostat type id (e.g. 10 for 0x10)"}, {"set thermostat_type <hex type ID>", "set the thermostat type id (e.g. 10 for 0x10)"},
{"set boiler_type <hex type ID>", "set the boiler type id (e.g. 8 for 0x08)"}, {"set boiler_type <hex type ID>", "set the boiler type id (e.g. 8 for 0x08)"},
@@ -384,10 +384,9 @@ void showInfo() {
myDebug(" Mode is set to ?"); myDebug(" Mode is set to ?");
} }
} }
myDebug(""); // newline
} }
myDebug(""); // newline
// Dallas // Dallas
if (EMSESP_Status.dallas_sensors != 0) { if (EMSESP_Status.dallas_sensors != 0) {
myDebug("%sExternal temperature sensors:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF); myDebug("%sExternal temperature sensors:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
@@ -396,10 +395,9 @@ void showInfo() {
snprintf(s, sizeof(s), "Sensor #%d", i + 1); snprintf(s, sizeof(s), "Sensor #%d", i + 1);
_renderFloatValue(s, "C", ds18.getValue(i)); _renderFloatValue(s, "C", ds18.getValue(i));
} }
myDebug(""); // newline
} }
myDebug(""); // newline
// show the Shower Info // show the Shower Info
if (EMSESP_Status.shower_timer) { if (EMSESP_Status.shower_timer) {
myDebug("%sShower stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF); myDebug("%sShower stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
@@ -545,6 +543,15 @@ uint8_t _readIntNumber() {
return atoi(numTextPtr); return atoi(numTextPtr);
} }
// used to read the next string from an input buffer and convert to a double
float _readFloatNumber() {
char * numTextPtr = strtok(NULL, ", \n");
if (numTextPtr == nullptr) {
return 0;
}
return atof(numTextPtr);
}
// used to read the next string from an input buffer as a hex value and convert to an 8 bit int // used to read the next string from an input buffer as a hex value and convert to an 8 bit int
uint8_t _readHexNumber() { uint8_t _readHexNumber() {
char * numTextPtr = strtok(NULL, ", \n"); char * numTextPtr = strtok(NULL, ", \n");
@@ -572,7 +579,6 @@ void startThermostatScan(uint8_t start) {
scanThermostat.attach(SCANTHERMOSTAT_TIME, do_scanThermostat); scanThermostat.attach(SCANTHERMOSTAT_TIME, do_scanThermostat);
} }
// callback for loading/saving settings to the file system (SPIFFS) // callback for loading/saving settings to the file system (SPIFFS)
bool FSCallback(MYESP_FSACTION action, JsonObject & json) { bool FSCallback(MYESP_FSACTION action, JsonObject & json) {
bool ok = true; bool ok = true;
@@ -581,21 +587,24 @@ bool FSCallback(MYESP_FSACTION action, JsonObject & json) {
if (json.containsKey("led")) { if (json.containsKey("led")) {
EMSESP_Status.led_enabled = (bool)json["led"]; EMSESP_Status.led_enabled = (bool)json["led"];
} else { } else {
ok = false; EMSESP_Status.led_enabled = LED_BUILTIN; // default value
ok = false;
} }
// led_gpio // led_gpio
if (json.containsKey("led_gpio")) { if (json.containsKey("led_gpio")) {
EMSESP_Status.led_gpio = json["led_gpio"]; EMSESP_Status.led_gpio = json["led_gpio"];
} else { } else {
ok = false; EMSESP_Status.led_gpio = EMSESP_LED_GPIO; // default value
ok = false;
} }
// dallas_gpio // dallas_gpio
if (json.containsKey("dallas_gpio")) { if (json.containsKey("dallas_gpio")) {
EMSESP_Status.dallas_gpio = json["dallas_gpio"]; EMSESP_Status.dallas_gpio = json["dallas_gpio"];
} else { } else {
ok = false; EMSESP_Status.dallas_gpio = EMSESP_DALLAS_GPIO; // default value
ok = false;
} }
// thermostat_type // thermostat_type
@@ -780,7 +789,7 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
if (wc == 3) { if (wc == 3) {
char * second_cmd = _readWord(); char * second_cmd = _readWord();
if (strcmp(second_cmd, "temp") == 0) { if (strcmp(second_cmd, "temp") == 0) {
ems_setThermostatTemp(_readIntNumber()); ems_setThermostatTemp(_readFloatNumber());
ok = true; ok = true;
} else if (strcmp(second_cmd, "mode") == 0) { } else if (strcmp(second_cmd, "mode") == 0) {
ems_setThermostatMode(_readIntNumber()); ems_setThermostatMode(_readIntNumber());
@@ -910,11 +919,14 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
void WIFICallback() { void WIFICallback() {
// This is where we enable the UART service to scan the incoming serial Tx/Rx bus signals // This is where we enable the UART service to scan the incoming serial Tx/Rx bus signals
// This is done after we have a WiFi signal to avoid any resource conflicts // This is done after we have a WiFi signal to avoid any resource conflicts
emsuart_init(); if (myESP.getUseSerial()) {
myDebug("[UART] Opened Rx/Tx connection"); myDebug("EMS UART disabled when in Serial mode. Use 'set serial off' to change.");
} else {
// go and find the boiler and thermostat types emsuart_init();
ems_discoverModels(); myDebug("[UART] Opened Rx/Tx connection");
// go and find the boiler and thermostat types
ems_discoverModels();
}
} }
// Initialize the boiler settings and shower settings // Initialize the boiler settings and shower settings
@@ -922,7 +934,7 @@ void initEMSESP() {
// general settings // general settings
EMSESP_Status.shower_timer = BOILER_SHOWER_TIMER; EMSESP_Status.shower_timer = BOILER_SHOWER_TIMER;
EMSESP_Status.shower_alert = BOILER_SHOWER_ALERT; EMSESP_Status.shower_alert = BOILER_SHOWER_ALERT;
EMSESP_Status.led_enabled = false; EMSESP_Status.led_enabled = true; // LED is on by default
EMSESP_Status.timestamp = millis(); EMSESP_Status.timestamp = millis();
EMSESP_Status.dallas_sensors = 0; EMSESP_Status.dallas_sensors = 0;
@@ -939,7 +951,7 @@ void initEMSESP() {
// call PublishValues without forcing, so using CRC to see if we really need to publish // call PublishValues without forcing, so using CRC to see if we really need to publish
void do_publishValues() { void do_publishValues() {
// don't publish if we're not connected to the EMS bus // don't publish if we're not connected to the EMS bus
if (ems_getBusConnected()) { if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
publishValues(false); publishValues(false);
} }
} }
@@ -959,14 +971,16 @@ void do_ledcheck() {
// Thermostat scan // Thermostat scan
void do_scanThermostat() { void do_scanThermostat() {
myDebug("> Scanning thermostat message type #0x%02X..", scanThermostat_count); if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
ems_doReadCommand(scanThermostat_count, EMS_Thermostat.type_id); myDebug("> Scanning thermostat message type #0x%02X..", scanThermostat_count);
scanThermostat_count++; ems_doReadCommand(scanThermostat_count, EMS_Thermostat.type_id);
scanThermostat_count++;
}
} }
// do a system health check every now and then to see if we all connections // do a system health check every now and then to see if we all connections
void do_systemCheck() { void do_systemCheck() {
if (!ems_getBusConnected()) { if ((!ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebug("Error! Unable to read from EMS bus. Retrying in %d seconds...", SYSTEMCHECK_TIME); myDebug("Error! Unable to read from EMS bus. Retrying in %d seconds...", SYSTEMCHECK_TIME);
} }
} }
@@ -974,7 +988,7 @@ void do_systemCheck() {
// force calls to get data from EMS for the types that aren't sent as broadcasts // force calls to get data from EMS for the types that aren't sent as broadcasts
// only if we have a EMS connection // only if we have a EMS connection
void do_regularUpdates() { void do_regularUpdates() {
if (ems_getBusConnected()) { if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
myDebugLog("Calling scheduled data refresh from EMS devices.."); myDebugLog("Calling scheduled data refresh from EMS devices..");
ems_getThermostatValues(); ems_getThermostatValues();
ems_getBoilerValues(); ems_getBoilerValues();

View File

@@ -975,7 +975,7 @@ void _process_UBAMonitorSlow(uint8_t type, uint8_t * data, uint8_t length) {
*/ */
void _process_RC10StatusMessage(uint8_t type, uint8_t * data, uint8_t length) { void _process_RC10StatusMessage(uint8_t type, uint8_t * data, uint8_t length) {
EMS_Thermostat.setpoint_roomTemp = ((float)data[EMS_TYPE_RC10StatusMessage_setpoint]) / (float)2; EMS_Thermostat.setpoint_roomTemp = ((float)data[EMS_TYPE_RC10StatusMessage_setpoint]) / (float)2;
EMS_Thermostat.curr_roomTemp = _toFloat(EMS_TYPE_RC10StatusMessage_curr, data); EMS_Thermostat.curr_roomTemp = ((float)data[EMS_TYPE_RC10StatusMessage_curr]) / (float)10;
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
} }

View File

@@ -6,5 +6,5 @@
#pragma once #pragma once
#define APP_NAME "EMS-ESP" #define APP_NAME "EMS-ESP"
#define APP_VERSION "1.5.0" #define APP_VERSION "1.5.1"
#define APP_HOSTNAME "ems-esp" #define APP_HOSTNAME "ems-esp"