Sync with upstream/dev

This commit is contained in:
MichaelDvP
2020-01-12 18:41:53 +01:00
parent db4fa83c3c
commit 0fb9019c51
5 changed files with 33 additions and 29 deletions

View File

@@ -78,6 +78,7 @@ MyESP::MyESP() {
_mqtt_will_topic = strdup(MQTT_WILL_TOPIC); _mqtt_will_topic = strdup(MQTT_WILL_TOPIC);
_mqtt_will_online_payload = strdup(MQTT_WILL_ONLINE_PAYLOAD); _mqtt_will_online_payload = strdup(MQTT_WILL_ONLINE_PAYLOAD);
_mqtt_will_offline_payload = strdup(MQTT_WILL_OFFLINE_PAYLOAD); _mqtt_will_offline_payload = strdup(MQTT_WILL_OFFLINE_PAYLOAD);
_mqtt_publish_fails = 0; // count of number of failed MQTT topic publishes
// network // network
_network_password = nullptr; _network_password = nullptr;
@@ -425,9 +426,19 @@ bool MyESP::mqttPublish(const char * topic, const char * payload, bool retain) {
if (packet_id) { if (packet_id) {
_addMQTTLog(topic, payload, MYESP_MQTTLOGTYPE_PUBLISH); // add to the log _addMQTTLog(topic, payload, MYESP_MQTTLOGTYPE_PUBLISH); // add to the log
return true; return true;
} else {
myDebug_P(PSTR("[MQTT] Error publishing to %s with payload %s [error %d]"), _mqttTopic(topic), payload, packet_id);
} }
// it failed, try again https://github.com/proddy/EMS-ESP/issues/264
delay(100); // this is blocking and probably not a good idea
packet_id = mqttClient.publish(_mqttTopic(topic), _mqtt_qos, retain, payload);
if (packet_id) {
_addMQTTLog(topic, payload, MYESP_MQTTLOGTYPE_PUBLISH); // add to the log
return true; // ok this time
}
// it didn't work again, will return false
myDebug_P(PSTR("[MQTT] Error publishing to %s with payload %s [error %d]"), _mqttTopic(topic), payload, packet_id);
_mqtt_publish_fails++; // increment failure counter
} }
return false; // failed return false; // failed
@@ -1372,6 +1383,7 @@ void MyESP::showSystemStats() {
if (isMQTTConnected()) { if (isMQTTConnected()) {
myDebug_P(PSTR(" [MQTT] is connected (heartbeat %s)"), getHeartbeat() ? "enabled" : "disabled"); myDebug_P(PSTR(" [MQTT] is connected (heartbeat %s)"), getHeartbeat() ? "enabled" : "disabled");
myDebug_P(PSTR(" [MQTT] # failed topic publishes: %d"), _mqtt_publish_fails);
} else { } else {
myDebug_P(PSTR(" [MQTT] is disconnected")); myDebug_P(PSTR(" [MQTT] is disconnected"));
} }

View File

@@ -335,12 +335,12 @@ class MyESP {
private: private:
// mqtt // mqtt
void _mqttOnMessage(char * topic, char * payload, size_t len); void _mqttOnMessage(char * topic, char * payload, size_t len);
void _mqttConnect(); void _mqttConnect();
void _mqtt_setup(); void _mqtt_setup();
void _mqttOnConnect(); void _mqttOnConnect();
void _sendStart(); void _sendStart();
char * _mqttTopic(const char * topic); char * _mqttTopic(const char * topic);
// mqtt log // mqtt log
_MQTT_Log_t MQTT_log[MYESP_MQTTLOG_MAX]; // log for publish and subscribe messages _MQTT_Log_t MQTT_log[MYESP_MQTTLOG_MAX]; // log for publish and subscribe messages
@@ -366,6 +366,7 @@ class MyESP {
uint32_t _mqtt_last_connection; uint32_t _mqtt_last_connection;
bool _mqtt_connecting; bool _mqtt_connecting;
bool _mqtt_heartbeat; bool _mqtt_heartbeat;
uint16_t _mqtt_publish_fails;
// wifi // wifi
void _wifiCallback(justwifi_messages_t code, char * parameter); void _wifiCallback(justwifi_messages_t code, char * parameter);

View File

@@ -480,17 +480,17 @@ void showInfo() {
myDebug_P(PSTR("")); // newline myDebug_P(PSTR("")); // newline
myDebug_P(PSTR("%sMixing module stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF); myDebug_P(PSTR("%sMixing module stats:%s"), COLOR_BOLD_ON, COLOR_BOLD_OFF);
myDebug_P(PSTR(" Mixing: %s"), ems_getDeviceDescription(EMS_DEVICE_TYPE_MIXING, buffer_type,false)); myDebug_P(PSTR(" Mixing: %s"), ems_getDeviceDescription(EMS_DEVICE_TYPE_MIXING, buffer_type,false));
//if (EMS_Boiler.switchTemp > EMS_VALUE_SHORT_NOTSET) if (EMS_Boiler.switchTemp < EMS_VALUE_USHORT_NOTSET)
_renderShortValue("Switch temperature", "C", EMS_Boiler.switchTemp); _renderShortValue("Switch temperature", "C", EMS_Boiler.switchTemp);
for (uint8_t hc_num = 1; hc_num <= EMS_THERMOSTAT_MAXHC; hc_num++) { for (uint8_t hc_num = 1; hc_num <= EMS_THERMOSTAT_MAXHC; hc_num++) {
if (EMS_Mixing.hc[hc_num - 1].active) { if (EMS_Mixing.hc[hc_num - 1].active) {
myDebug_P(PSTR(" Mixing Circuit %d"), hc_num); myDebug_P(PSTR(" Mixing Circuit %d"), hc_num);
//if (EMS_Mixing.hc[hc_num - 1].flowTemp > EMS_VALUE_SHORT_NOTSET) if (EMS_Mixing.hc[hc_num - 1].flowTemp < EMS_VALUE_USHORT_NOTSET)
_renderShortValue(" Current flow temperature", "C", EMS_Mixing.hc[hc_num - 1].flowTemp); _renderUShortValue(" Current flow temperature", "C", EMS_Mixing.hc[hc_num - 1].flowTemp);
//if (EMS_Mixing.hc[hc_num - 1].flowSetTemp != EMS_VALUE_INT_NOTSET) if (EMS_Mixing.hc[hc_num - 1].flowSetTemp != EMS_VALUE_INT_NOTSET)
_renderIntValue(" Setpoint flow temperature", "C", EMS_Mixing.hc[hc_num - 1].flowSetTemp); _renderIntValue(" Setpoint flow temperature", "C", EMS_Mixing.hc[hc_num - 1].flowSetTemp);
//if (EMS_Mixing.hc[hc_num - 1].pumpMod != EMS_VALUE_INT_NOTSET) if (EMS_Mixing.hc[hc_num - 1].pumpMod != EMS_VALUE_INT_NOTSET)
_renderIntValue(" Current pump modulation", "%", EMS_Mixing.hc[hc_num - 1].pumpMod); _renderIntValue(" Current pump modulation", "%", EMS_Mixing.hc[hc_num - 1].pumpMod);
if (EMS_Mixing.hc[hc_num - 1].valveStatus != EMS_VALUE_INT_NOTSET) if (EMS_Mixing.hc[hc_num - 1].valveStatus != EMS_VALUE_INT_NOTSET)
_renderIntValue(" Current valve status", "", EMS_Mixing.hc[hc_num - 1].valveStatus); _renderIntValue(" Current valve status", "", EMS_Mixing.hc[hc_num - 1].valveStatus);
@@ -612,7 +612,7 @@ void publishEMSValues(bool force) {
rootBoiler["curFlowTemp"] = (float)EMS_Boiler.curFlowTemp / 10; rootBoiler["curFlowTemp"] = (float)EMS_Boiler.curFlowTemp / 10;
if (EMS_Boiler.retTemp < EMS_VALUE_USHORT_NOTSET) if (EMS_Boiler.retTemp < EMS_VALUE_USHORT_NOTSET)
rootBoiler["retTemp"] = (float)EMS_Boiler.retTemp / 10; rootBoiler["retTemp"] = (float)EMS_Boiler.retTemp / 10;
if (EMS_Boiler.switchTemp > EMS_VALUE_SHORT_NOTSET) if (EMS_Boiler.switchTemp < EMS_VALUE_USHORT_NOTSET)
rootBoiler["switchTemp"] = (float)EMS_Boiler.switchTemp / 10; rootBoiler["switchTemp"] = (float)EMS_Boiler.switchTemp / 10;
if (EMS_Boiler.sysPress != EMS_VALUE_INT_NOTSET) if (EMS_Boiler.sysPress != EMS_VALUE_INT_NOTSET)
rootBoiler["sysPress"] = (float)EMS_Boiler.sysPress / 10; rootBoiler["sysPress"] = (float)EMS_Boiler.sysPress / 10;
@@ -668,7 +668,7 @@ void publishEMSValues(bool force) {
if (abs(EMS_Boiler.heatWorkMin) != EMS_VALUE_LONG_NOTSET) if (abs(EMS_Boiler.heatWorkMin) != EMS_VALUE_LONG_NOTSET)
rootBoiler["heatWorkMin"] = (float)EMS_Boiler.heatWorkMin; rootBoiler["heatWorkMin"] = (float)EMS_Boiler.heatWorkMin;
if (EMS_Boiler.serviceCode < EMS_VALUE_USHORT_NOTSET) { if (EMS_Boiler.serviceCode != EMS_VALUE_USHORT_NOTSET) {
rootBoiler["ServiceCode"] = EMS_Boiler.serviceCodeChar; rootBoiler["ServiceCode"] = EMS_Boiler.serviceCodeChar;
rootBoiler["ServiceCodeNumber"] = EMS_Boiler.serviceCode; rootBoiler["ServiceCodeNumber"] = EMS_Boiler.serviceCode;
} }
@@ -778,11 +778,7 @@ void publishEMSValues(bool force) {
strlcat(hc, _int_to_char(s, mixing->hc), sizeof(hc)); strlcat(hc, _int_to_char(s, mixing->hc), sizeof(hc));
JsonObject dataMixing = rootMixing.createNestedObject(hc); JsonObject dataMixing = rootMixing.createNestedObject(hc);
<<<<<<< HEAD if (mixing->flowTemp < EMS_VALUE_USHORT_NOTSET)
if (mixing->flowTemp > EMS_VALUE_SHORT_NOTSET)
=======
if (mixing->flowTemp != EMS_VALUE_USHORT_NOTSET)
>>>>>>> upstream/dev
dataMixing["flowTemp"] = (float)mixing->flowTemp / 10; dataMixing["flowTemp"] = (float)mixing->flowTemp / 10;
if (mixing->flowSetTemp != EMS_VALUE_INT_NOTSET) if (mixing->flowSetTemp != EMS_VALUE_INT_NOTSET)
dataMixing["setflowTemp"] = mixing->flowSetTemp; dataMixing["setflowTemp"] = mixing->flowSetTemp;

View File

@@ -123,7 +123,7 @@ void ems_init() {
// init all mixing modules // init all mixing modules
for (uint8_t i = 0; i < EMS_THERMOSTAT_MAXHC; i++) { for (uint8_t i = 0; i < EMS_THERMOSTAT_MAXHC; i++) {
EMS_Mixing.hc[i].hc = i + 1; EMS_Mixing.hc[i].hc = i + 1;
EMS_Mixing.hc[i].flowTemp = EMS_VALUE_SHORT_NOTSET; EMS_Mixing.hc[i].flowTemp = EMS_VALUE_USHORT_NOTSET;
EMS_Mixing.hc[i].pumpMod = EMS_VALUE_INT_NOTSET; EMS_Mixing.hc[i].pumpMod = EMS_VALUE_INT_NOTSET;
EMS_Mixing.hc[i].valveStatus = EMS_VALUE_INT_NOTSET; EMS_Mixing.hc[i].valveStatus = EMS_VALUE_INT_NOTSET;
EMS_Mixing.hc[i].flowSetTemp = EMS_VALUE_INT_NOTSET; EMS_Mixing.hc[i].flowSetTemp = EMS_VALUE_INT_NOTSET;
@@ -161,7 +161,7 @@ void ems_init() {
EMS_Boiler.burnStarts = EMS_VALUE_LONG_NOTSET; // # burner restarts EMS_Boiler.burnStarts = EMS_VALUE_LONG_NOTSET; // # burner restarts
EMS_Boiler.burnWorkMin = EMS_VALUE_LONG_NOTSET; // Total burner operating time EMS_Boiler.burnWorkMin = EMS_VALUE_LONG_NOTSET; // Total burner operating time
EMS_Boiler.heatWorkMin = EMS_VALUE_LONG_NOTSET; // Total heat operating time EMS_Boiler.heatWorkMin = EMS_VALUE_LONG_NOTSET; // Total heat operating time
EMS_Boiler.switchTemp = EMS_VALUE_SHORT_NOTSET; EMS_Boiler.switchTemp = EMS_VALUE_USHORT_NOTSET;
// UBAMonitorWWMessage // UBAMonitorWWMessage
EMS_Boiler.wWCurTmp = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature EMS_Boiler.wWCurTmp = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature
@@ -1273,11 +1273,7 @@ void _process_MMPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
// Mixer - 0xAB // Mixer - 0xAB
void _process_MMStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) { void _process_MMStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
<<<<<<< HEAD
uint8_t hc = 1; // fixed, for 0xAB uint8_t hc = 1; // fixed, for 0xAB
=======
uint8_t hc = 0; // fixed, for 0xAB (HC1 only
>>>>>>> upstream/dev
EMS_Mixing.hc[hc].active = true; EMS_Mixing.hc[hc].active = true;
_setValue(EMS_RxTelegram, &EMS_Mixing.hc[hc].flowTemp, EMS_OFFSET_MMStatusMessage_flow_temp); _setValue(EMS_RxTelegram, &EMS_Mixing.hc[hc].flowTemp, EMS_OFFSET_MMStatusMessage_flow_temp);
@@ -2865,7 +2861,6 @@ const _EMS_Type EMS_Types[] = {
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC1, "MMPLUSStatusMessage_HC1", _process_MMPLUSStatusMessage}, {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC1, "MMPLUSStatusMessage_HC1", _process_MMPLUSStatusMessage},
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC2, "MMPLUSStatusMessage_HC2", _process_MMPLUSStatusMessage}, {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMPLUSStatusMessage_HC2, "MMPLUSStatusMessage_HC2", _process_MMPLUSStatusMessage},
{EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMStatusMessage, "MMStatusMessage", _process_MMStatusMessage} {EMS_DEVICE_UPDATE_FLAG_MIXING, EMS_TYPE_MMStatusMessage, "MMStatusMessage", _process_MMStatusMessage}
}; };
// calculate sizes of arrays at compile time // calculate sizes of arrays at compile time

View File

@@ -298,7 +298,7 @@ typedef struct {
uint32_t burnStarts; // # burner starts uint32_t burnStarts; // # burner starts
uint32_t burnWorkMin; // Total burner operating time uint32_t burnWorkMin; // Total burner operating time
uint32_t heatWorkMin; // Total heat operating time uint32_t heatWorkMin; // Total heat operating time
int16_t switchTemp; // Switch temperature uint16_t switchTemp; // Switch temperature
// UBAMonitorWWMessage // UBAMonitorWWMessage
uint16_t wWCurTmp; // Warm Water current temperature uint16_t wWCurTmp; // Warm Water current temperature
@@ -338,7 +338,7 @@ typedef struct {
typedef struct { typedef struct {
uint8_t hc; // heating circuit 1, 2, 3 or 4 uint8_t hc; // heating circuit 1, 2, 3 or 4
bool active; // true if there is data for this HC bool active; // true if there is data for this HC
int16_t flowTemp; uint16_t flowTemp;
uint8_t pumpMod; uint8_t pumpMod;
uint8_t valveStatus; uint8_t valveStatus;
uint8_t flowSetTemp; uint8_t flowSetTemp;