Improved logic to threat unknown 1-wire device (some PnP)

artnet disabled by default for due since some execution blocking in
artnet->read()
This commit is contained in:
2019-02-09 22:38:47 +03:00
parent ecb11ce3a5
commit e7f376196c
2 changed files with 13 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
#! /bin/bash #! /bin/bash
export FLAGS="$FLAGS -DWiz5500" export FLAGS="$FLAGS -DWiz5500"
export FLAGS="$FLAGS -DARTNET_ENABLE" #export FLAGS="$FLAGS -DARTNET_ENABLE"
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
source $CUSTOM_BUILD_FLAGS_FILE source $CUSTOM_BUILD_FLAGS_FILE

View File

@@ -673,15 +673,16 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
SetBytes(addr, 8, addrstr); SetBytes(addr, 8, addrstr);
addrstr[17] = 0; addrstr[17] = 0;
printFloatValueToStr(currentTemp,valstr);
debugSerial<<endl<<F("T:")<<valstr<<F("<");
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr); aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
if (owObj) { if (owObj) {
owEmitString = aJson.getObjectItem(owObj, "emit")->valuestring; owEmitString = aJson.getObjectItem(owObj, "emit")->valuestring;
debugSerial<<owEmitString<<F(">")<<endl;
if (owEmitString) { if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
printFloatValueToStr(currentTemp,valstr); {
debugSerial<<owEmitString<<F("=")<<valstr<<endl; if (owEmitString) // publish temperature to MQTT if configured
if ((currentTemp == -127.0) || (currentTemp == 85.0) || (currentTemp == 0.0)) //ToDo: 1-w short circuit mapped to "0" celsium {
return;
#ifdef WITH_DOMOTICZ #ifdef WITH_DOMOTICZ
aJsonObject *idx = aJson.getObjectItem(owObj, "idx"); aJsonObject *idx = aJson.getObjectItem(owObj, "idx");
@@ -699,12 +700,14 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
strncat(addrstr, owEmitString, sizeof(addrstr)); strncat(addrstr, owEmitString, sizeof(addrstr));
mqttClient.publish(addrstr, valstr); mqttClient.publish(addrstr, valstr);
} }
// And translate temp to internal items
owItem = aJson.getObjectItem(owObj, "item")->valuestring; owItem = aJson.getObjectItem(owObj, "item")->valuestring;
if (owItem) if (owItem)
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
} // if valid temperature
} // if Address in config
else debugSerial<<addrstr<<F(">")<<endl; // No item found
else debugSerial<<F("1w-item not found in config")<<endl;
}
} }
#endif //_owire #endif //_owire
@@ -1392,7 +1395,7 @@ void loop_main() {
if (lanLoop() > HAVE_IP_ADDRESS) { if (lanLoop() > HAVE_IP_ADDRESS) {
mqttClient.loop(); mqttClient.loop();
#ifdef _artnet #ifdef _artnet
if (artnet) artnet->read(); if (artnet) artnet->read(); ///hung
#endif #endif
} }