mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
templates, I2C/1Wire reset tune, bins
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -127,8 +127,8 @@ int owSetup() {
|
|||||||
if (oneWire) return true; // Already initialized
|
if (oneWire) return true; // Already initialized
|
||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
|
|
||||||
debugSerial<<F("DS2482_100_I2C_TO_1W_BRIDGE init")<<endl;
|
debugSerial<<F("1WT: DS2482_100_I2C_TO_1W_BRIDGE init")<<endl;
|
||||||
debugSerial<<F("Free:")<<freeRam()<<endl;
|
//debugSerial<<F("Free:")<<freeRam()<<endl;
|
||||||
oneWire = new OneWire;
|
oneWire = new OneWire;
|
||||||
#else
|
#else
|
||||||
debugSerial.print(F("One wire setup on PIN:"));
|
debugSerial.print(F("One wire setup on PIN:"));
|
||||||
@@ -146,7 +146,7 @@ if (!oneWire)
|
|||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
if (oneWire->checkPresence()) {
|
if (oneWire->checkPresence()) {
|
||||||
infoSerial.println(F("1WT: DS2482-100 present"));
|
infoSerial.println(F("1WT: DS2482-100 present, reset"));
|
||||||
oneWire->deviceReset();
|
oneWire->deviceReset();
|
||||||
#ifdef APU_OFF
|
#ifdef APU_OFF
|
||||||
debugSerial.println(F("APU off"));
|
debugSerial.println(F("APU off"));
|
||||||
@@ -154,11 +154,11 @@ if (!oneWire)
|
|||||||
oneWire->setActivePullup();
|
oneWire->setActivePullup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
debugSerial.println(F("\tChecking for 1-Wire devices..."));
|
// debugSerial.println(F("\tChecking for 1-Wire devices..."));
|
||||||
if (oneWire->wireReset())
|
if (oneWire->wireReset())
|
||||||
debugSerial.println(F("\tReset done"));
|
debugSerial.println(F("1WT: Bus Reset done"));
|
||||||
else
|
else
|
||||||
debugSerial.println(F("\tDS2482 reset error"));
|
debugSerial.println(F("1WT: Bus reset error"));
|
||||||
//return true;
|
//return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -229,22 +229,22 @@ int sensors_loop(void) {
|
|||||||
i2cReset();
|
i2cReset();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DS2482_ERROR_TIMEOUT:
|
case DS2482_ERROR_TIMEOUT: //Busy over time
|
||||||
errorSerial<<F("1WT: timeout")<<endl;
|
errorSerial<<F("1WT: BUSY timeout")<<endl;
|
||||||
oneWire->wireReset();
|
i2cReset();
|
||||||
return INTERVAL_1W;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errorSerial<<F("1WT: error")<<endl;
|
break;
|
||||||
oneWire->wireReset();
|
|
||||||
return INTERVAL_1W;
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (!oneWire->checkPresence())
|
if (!oneWire->checkPresence())
|
||||||
{
|
{
|
||||||
infoSerial.println(F("1WT: lost DS2482-100"));
|
infoSerial.println(F("1WT: lost DS2482-100"));
|
||||||
i2cReset();
|
i2cReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#define _TEMPLATE_STREAM_H_
|
#define _TEMPLATE_STREAM_H_
|
||||||
|
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
#include <aJSON.h>
|
||||||
|
#include <streamlog.h>
|
||||||
//#define KEYLEN 8
|
//#define KEYLEN 8
|
||||||
extern aJsonObject * topics;
|
extern aJsonObject * topics;
|
||||||
|
|
||||||
@@ -30,6 +32,7 @@ public:
|
|||||||
{
|
{
|
||||||
str[pos+2+i]='\0';
|
str[pos+2+i]='\0';
|
||||||
val=resolveKey(str+pos+2);
|
val=resolveKey(str+pos+2);
|
||||||
|
valpos=0;
|
||||||
str[pos+2+i]='}';
|
str[pos+2+i]='}';
|
||||||
pos+=3+i;
|
pos+=3+i;
|
||||||
}
|
}
|
||||||
@@ -83,8 +86,9 @@ public:
|
|||||||
if (valObj->type == aJson_String) return valObj->valuestring;
|
if (valObj->type == aJson_String) return valObj->valuestring;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (suffix && (suffix<=suffixNum) && !strcmp(key,"sfx"))
|
if (suffix && (suffix<suffixNum) && !strcmp(key,"sfx"))
|
||||||
{
|
{
|
||||||
|
//debugSerial<<F("Template: Suffix=")<<suffix<<endl;
|
||||||
buffer[0]='/';
|
buffer[0]='/';
|
||||||
strncpy_P(buffer+1,suffix_P[suffix],sizeof(buffer)-2);
|
strncpy_P(buffer+1,suffix_P[suffix],sizeof(buffer)-2);
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|||||||
@@ -701,6 +701,11 @@ switch (cmdType)
|
|||||||
// dict = aJson.createObject();
|
// dict = aJson.createObject();
|
||||||
// aJson.addStringToObject(dict, "sfx", )
|
// aJson.addStringToObject(dict, "sfx", )
|
||||||
suffix=_itemCmd.getSuffix();
|
suffix=_itemCmd.getSuffix();
|
||||||
|
if (!suffix)
|
||||||
|
{
|
||||||
|
if (_itemCmd.isCommand()) suffix=S_CMD;
|
||||||
|
else if (_itemCmd.isValue()) suffix = S_SET;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//debugSerial << F("IN:") << (pin) << F(" : ") <<endl;
|
//debugSerial << F("IN:") << (pin) << F(" : ") <<endl;
|
||||||
@@ -720,7 +725,7 @@ switch (cmdType)
|
|||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
//ts.setTimeout(0);
|
//ts.setTimeout(0);
|
||||||
addrstr[ts.readBytesUntil('\0',addrstr,sizeof(addrstr))]='\0';
|
addrstr[ts.readBytesUntil('\0',addrstr,sizeof(addrstr))]='\0';
|
||||||
debugSerial << F("Emit: ")<<emit->valuestring<<" "<<addrstr<< F(" -> ")<<emitCommand<<endl;
|
debugSerial << F("Emit: <")<<emit->valuestring<<"> "<<addrstr<< F(" -> ")<<emitCommand<<endl;
|
||||||
/*
|
/*
|
||||||
TODO implement
|
TODO implement
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
@@ -895,7 +900,7 @@ bool checkToken(char * token, char * data)
|
|||||||
|
|
||||||
|
|
||||||
bool i2cReset(){
|
bool i2cReset(){
|
||||||
debugSerial.println("I2C Reset");
|
debugSerial.println(F("I2C Reset"));
|
||||||
|
|
||||||
Wire.endTransmission(true);
|
Wire.endTransmission(true);
|
||||||
#if !defined(ARDUINO_ARCH_ESP8266)
|
#if !defined(ARDUINO_ARCH_ESP8266)
|
||||||
@@ -911,19 +916,22 @@ pinMode(SDA,INPUT);
|
|||||||
pulse=!pulse;
|
pulse=!pulse;
|
||||||
delay(10);//10us мкс
|
delay(10);//10us мкс
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay(20);
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
if (oneWire && oneWire->checkPresence())
|
if (oneWire && oneWire->checkPresence())
|
||||||
{
|
{
|
||||||
oneWire->deviceReset();
|
oneWire->deviceReset();
|
||||||
|
debugSerial.println(F("1WT: DS2482 present, reset"));
|
||||||
#ifndef APU_OFF
|
#ifndef APU_OFF
|
||||||
oneWire->setActivePullup();
|
oneWire->setActivePullup();
|
||||||
#endif
|
#endif
|
||||||
if (oneWire->wireReset())
|
if (oneWire->wireReset())
|
||||||
debugSerial.println(F("\tReset done"));
|
debugSerial.println(F("1WT: Bus Reset done"));
|
||||||
else
|
else
|
||||||
debugSerial.println(F("\tDS2482 reset error"));
|
debugSerial.println(F("1WT: Bus reset error"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user