mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
1wire error handling
This commit is contained in:
@@ -1825,7 +1825,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
}
|
}
|
||||||
//publish to MQTT - OpenHab Legacy style to myhome/s_out/item flat values
|
//publish to MQTT - OpenHab Legacy style to myhome/s_out/item flat values
|
||||||
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
||||||
strncat(addrstr, itemArr->name, sizeof(addrstr));
|
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
|
||||||
|
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
@@ -1855,7 +1855,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
if (sendFlags & SEND_PARAMETERS)
|
if (sendFlags & SEND_PARAMETERS)
|
||||||
{
|
{
|
||||||
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
||||||
strncat(addrstr, itemArr->name, sizeof(addrstr));
|
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
|
||||||
strncat(addrstr, "/", sizeof(addrstr));
|
strncat(addrstr, "/", sizeof(addrstr));
|
||||||
strncat_P(addrstr, SET_P, sizeof(addrstr));
|
strncat_P(addrstr, SET_P, sizeof(addrstr));
|
||||||
|
|
||||||
@@ -1893,7 +1893,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
||||||
strncat(addrstr, itemArr->name, sizeof(addrstr));
|
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
|
||||||
strncat(addrstr, "/", sizeof(addrstr));
|
strncat(addrstr, "/", sizeof(addrstr));
|
||||||
strncat_P(addrstr, CMD_P, sizeof(addrstr));
|
strncat_P(addrstr, CMD_P, sizeof(addrstr));
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,13 @@ owChangedType owChanged;
|
|||||||
int owUpdate() {
|
int owUpdate() {
|
||||||
#ifndef OWIRE_DISABLE
|
#ifndef OWIRE_DISABLE
|
||||||
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
||||||
short sr;
|
/*
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire shorted.")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
Serial.println(F("Searching"));
|
Serial.println(F("Searching"));
|
||||||
if (oneWire) oneWire->reset_search();
|
if (oneWire) oneWire->reset_search();
|
||||||
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
|
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
|
||||||
@@ -78,6 +82,7 @@ int owUpdate() {
|
|||||||
|
|
||||||
debugSerial<<F("1-wire count: ")<<t_count<<endl;
|
debugSerial<<F("1-wire count: ")<<t_count<<endl;
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,6 +124,12 @@ int owSetup(owChangedType owCh) {
|
|||||||
if (oneWire->wireReset())
|
if (oneWire->wireReset())
|
||||||
debugSerial.println(F("\tReset done"));
|
debugSerial.println(F("\tReset done"));
|
||||||
|
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire shorted.")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sensors->begin();
|
sensors->begin();
|
||||||
owChanged = owCh;
|
owChanged = owCh;
|
||||||
//owUpdate();
|
//owUpdate();
|
||||||
@@ -141,7 +152,13 @@ int owSetup(owChangedType owCh) {
|
|||||||
|
|
||||||
|
|
||||||
int sensors_loop(void) {
|
int sensors_loop(void) {
|
||||||
if (!sensors) return -1;
|
if (!sensors) return 100000;
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire disabled (shorted)")<<endl;
|
||||||
|
return 100000;
|
||||||
|
}
|
||||||
|
|
||||||
if (si >= t_count) {
|
if (si >= t_count) {
|
||||||
owUpdate(); //every check circle - scan for new devices
|
owUpdate(); //every check circle - scan for new devices
|
||||||
si = 0;
|
si = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user