mirror of
https://github.com/anklimov/lighthub
synced 2025-12-08 20:59:49 +03:00
Post-merge fix: no local item control without emit tag, i2c scan fixed and removed
significant stability improvements: config re-load cleanup, MQTT submit only if connected (ESPx very sensetive on it) new: negative relay pin# - output invertion
This commit is contained in:
@@ -32,6 +32,7 @@ e-mail anklimov@gmail.com
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
extern aJsonObject *root;
|
||||||
|
|
||||||
#if !defined(DHT_DISABLE) || !defined(COUNTER_DISABLE)
|
#if !defined(DHT_DISABLE) || !defined(COUNTER_DISABLE)
|
||||||
static volatile unsigned long nextPollMillisValue[5];
|
static volatile unsigned long nextPollMillisValue[5];
|
||||||
@@ -93,7 +94,7 @@ void Input::Parse()
|
|||||||
store = NULL;
|
store = NULL;
|
||||||
inType = 0;
|
inType = 0;
|
||||||
pin = 0;
|
pin = 0;
|
||||||
if (inputObj && (inputObj->type == aJson_Object)) {
|
if (inputObj && (inputObj->type == aJson_Object) && root) {
|
||||||
aJsonObject *itemBuffer;
|
aJsonObject *itemBuffer;
|
||||||
itemBuffer = aJson.getObjectItem(inputObj, "T");
|
itemBuffer = aJson.getObjectItem(inputObj, "T");
|
||||||
if (itemBuffer) inType = static_cast<uint8_t>(itemBuffer->valueint);
|
if (itemBuffer) inType = static_cast<uint8_t>(itemBuffer->valueint);
|
||||||
@@ -110,7 +111,7 @@ void Input::Parse()
|
|||||||
|
|
||||||
void Input::setup()
|
void Input::setup()
|
||||||
{
|
{
|
||||||
if (!isValid()) return;
|
if (!isValid() || (!root)) return;
|
||||||
|
|
||||||
#ifndef CSSHDC_DISABLE
|
#ifndef CSSHDC_DISABLE
|
||||||
in_ccs811 ccs811(this);
|
in_ccs811 ccs811(this);
|
||||||
@@ -222,6 +223,7 @@ void Input::counterPoll() {
|
|||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
sprintf(valstr, "%d", counterValue);
|
sprintf(valstr, "%d", counterValue);
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
||||||
@@ -285,6 +287,7 @@ void Input::uptimePoll() {
|
|||||||
char valstr[11];
|
char valstr[11];
|
||||||
// printUlongValueToStr(valstr,millis());
|
// printUlongValueToStr(valstr,millis());
|
||||||
printUlongValueToStr(valstr, millis());
|
printUlongValueToStr(valstr, millis());
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(emit->valuestring, valstr);
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
}
|
}
|
||||||
setNextPollTime(millis() + UPTIME_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + UPTIME_POLL_DELAY_DEFAULT);
|
||||||
@@ -384,9 +387,11 @@ void Input::dht22Poll() {
|
|||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
strcat(addrstr, "T");
|
strcat(addrstr, "T");
|
||||||
printFloatValueToStr(temp, valstr);
|
printFloatValueToStr(temp, valstr);
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
addrstr[strlen(addrstr) - 1] = 'H';
|
addrstr[strlen(addrstr) - 1] = 'H';
|
||||||
printFloatValueToStr(humidity, valstr);
|
printFloatValueToStr(humidity, valstr);
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
|
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
@@ -512,7 +517,8 @@ void Input::onContactChanged(int newValue) {
|
|||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
if (emit) {
|
if (emit) {
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
if (getIdxField()) { (newValue) ? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}",
|
if (getIdxField())
|
||||||
|
{ (newValue) ? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}",
|
||||||
: publishDataToDomoticz(0,emit,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",getIdxField()); getIdxField())
|
: publishDataToDomoticz(0,emit,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",getIdxField()); getIdxField())
|
||||||
: publishDataToDomoticz(0, emit,
|
: publishDataToDomoticz(0, emit,
|
||||||
"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",
|
"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",
|
||||||
@@ -522,6 +528,8 @@ void Input::onContactChanged(int newValue) {
|
|||||||
{
|
{
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
|
if (mqttClient.connected())
|
||||||
|
{
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
if (newValue) { //send set command
|
if (newValue) { //send set command
|
||||||
if (!scmd) mqttClient.publish(addrstr, "ON", true);
|
if (!scmd) mqttClient.publish(addrstr, "ON", true);
|
||||||
@@ -532,8 +540,10 @@ if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestri
|
|||||||
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} // emit
|
||||||
if (item) {
|
if (item) {
|
||||||
|
//debugSerial <<F("Controlled item:")<< item->valuestring <<endl;
|
||||||
Item it(item->valuestring);
|
Item it(item->valuestring);
|
||||||
if (it.isValid()) {
|
if (it.isValid()) {
|
||||||
if (newValue) { //send set command
|
if (newValue) { //send set command
|
||||||
@@ -548,7 +558,6 @@ if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Input::onAnalogChanged(int newValue) {
|
void Input::onAnalogChanged(int newValue) {
|
||||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||||
@@ -569,6 +578,7 @@ void Input::onAnalogChanged(int newValue) {
|
|||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
char strVal[16];
|
char strVal[16];
|
||||||
itoa(newValue,strVal,10);
|
itoa(newValue,strVal,10);
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, strVal, true);
|
mqttClient.publish(addrstr, strVal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,6 +601,7 @@ bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, cons
|
|||||||
vsnprintf(valstr, sizeof(valstr) - 1, format, args);
|
vsnprintf(valstr, sizeof(valstr) - 1, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
debugSerial << valstr;
|
debugSerial << valstr;
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(emit->valuestring, valstr);
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
if (pollTimeIncrement)
|
if (pollTimeIncrement)
|
||||||
setNextPollTime(millis() + pollTimeIncrement);
|
setNextPollTime(millis() + pollTimeIncrement);
|
||||||
|
|||||||
@@ -656,7 +656,17 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int subItemN)
|
|||||||
break;
|
break;
|
||||||
case CH_RELAY: {
|
case CH_RELAY: {
|
||||||
int k;
|
int k;
|
||||||
|
short inverse = 0;
|
||||||
|
|
||||||
|
if (iaddr < 0) {
|
||||||
|
iaddr = -iaddr;
|
||||||
|
inverse = 1;
|
||||||
|
}
|
||||||
pinMode(iaddr, OUTPUT);
|
pinMode(iaddr, OUTPUT);
|
||||||
|
|
||||||
|
if (inverse)
|
||||||
|
digitalWrite(iaddr, k = ((cmd == CMD_ON || cmd == CMD_XON) ? LOW : HIGH));
|
||||||
|
else
|
||||||
digitalWrite(iaddr, k = ((cmd == CMD_ON || cmd == CMD_XON) ? HIGH : LOW));
|
digitalWrite(iaddr, k = ((cmd == CMD_ON || cmd == CMD_XON) ? HIGH : LOW));
|
||||||
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
||||||
break;
|
break;
|
||||||
@@ -667,6 +677,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int subItemN)
|
|||||||
case CH_PWM: {
|
case CH_PWM: {
|
||||||
int k;
|
int k;
|
||||||
short inverse = 0;
|
short inverse = 0;
|
||||||
|
|
||||||
if (iaddr < 0) {
|
if (iaddr < 0) {
|
||||||
iaddr = -iaddr;
|
iaddr = -iaddr;
|
||||||
inverse = 1;
|
inverse = 1;
|
||||||
@@ -1038,12 +1049,14 @@ int Item::checkFM() {
|
|||||||
else aJson.addNumberToObject(out, "pwr", 0);
|
else aJson.addNumberToObject(out, "pwr", 0);
|
||||||
|
|
||||||
if (ftemp > FM_OVERHEAT_CELSIUS && set) {
|
if (ftemp > FM_OVERHEAT_CELSIUS && set) {
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish("/alarm/ovrht", itemArr->name);
|
mqttClient.publish("/alarm/ovrht", itemArr->name);
|
||||||
Ctrl(CMD_OFF); //Shut down
|
Ctrl(CMD_OFF); //Shut down
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
debugSerial << F("Modbus polling error=") << _HEX(result);
|
debugSerial << F("Modbus polling error=") << _HEX(result);
|
||||||
outch = aJson.print(out);
|
outch = aJson.print(out);
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, outch);
|
mqttClient.publish(addrstr, outch);
|
||||||
free(outch);
|
free(outch);
|
||||||
aJson.deleteItem(out);
|
aJson.deleteItem(out);
|
||||||
@@ -1283,6 +1296,7 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<valstr<<endl;
|
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<valstr<<endl;
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, valstr,true);
|
mqttClient.publish(addrstr, valstr,true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,24 @@ int mqttErrorRate;
|
|||||||
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
|
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void cleanConf()
|
||||||
|
{
|
||||||
|
root = NULL;
|
||||||
|
inputs = NULL;
|
||||||
|
items = NULL;
|
||||||
|
topics = NULL;
|
||||||
|
mqttArr = NULL;
|
||||||
|
#ifndef DMX_DISABLE
|
||||||
|
dmxArr = NULL;
|
||||||
|
#endif
|
||||||
|
#ifndef OWIRE_DISABLE
|
||||||
|
owArr = NULL;
|
||||||
|
#endif
|
||||||
|
#ifndef MODBUS_DISABLE
|
||||||
|
modbusArr = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
||||||
debugSerial<<F("\n[")<<topic<<F("] ");
|
debugSerial<<F("\n[")<<topic<<F("] ");
|
||||||
if (!payload) return;
|
if (!payload) return;
|
||||||
@@ -739,7 +757,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
|
|
||||||
SetBytes(addr, 8, addrstr);
|
SetBytes(addr, 8, addrstr);
|
||||||
addrstr[17] = 0;
|
addrstr[17] = 0;
|
||||||
|
if (!root) return;
|
||||||
printFloatValueToStr(currentTemp,valstr);
|
printFloatValueToStr(currentTemp,valstr);
|
||||||
debugSerial<<endl<<F("T:")<<valstr<<F("<");
|
debugSerial<<endl<<F("T:")<<valstr<<F("<");
|
||||||
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
||||||
@@ -758,6 +776,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
char valstr[50];
|
char valstr[50];
|
||||||
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
|
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
|
||||||
debugSerial << valstr;
|
debugSerial << valstr;
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(owEmitString, valstr);
|
mqttClient.publish(owEmitString, valstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -766,6 +785,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
//strcpy_P(addrstr, outprefix);
|
//strcpy_P(addrstr, outprefix);
|
||||||
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
setTopic(addrstr,sizeof(addrstr),T_OUT);
|
||||||
strncat(addrstr, owEmitString, sizeof(addrstr));
|
strncat(addrstr, owEmitString, sizeof(addrstr));
|
||||||
|
if (mqttClient.connected())
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
}
|
}
|
||||||
// And translate temp to internal items
|
// And translate temp to internal items
|
||||||
@@ -870,8 +890,9 @@ void applyConfig() {
|
|||||||
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
||||||
Item it(item);
|
Item it(item);
|
||||||
if (it.isValid()) {
|
if (it.isValid()) {
|
||||||
|
short inverse = 0;
|
||||||
int pin=it.getArg();
|
int pin=it.getArg();
|
||||||
if (pin<0) pin=-pin;
|
if (pin<0) {pin=-pin; inverse = 1;}
|
||||||
int cmd = it.getCmd();
|
int cmd = it.getCmd();
|
||||||
switch (it.itemType) {
|
switch (it.itemType) {
|
||||||
case CH_THERMO:
|
case CH_THERMO:
|
||||||
@@ -880,6 +901,9 @@ void applyConfig() {
|
|||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
pinMode(pin, OUTPUT);
|
pinMode(pin, OUTPUT);
|
||||||
|
if (inverse)
|
||||||
|
digitalWrite(pin, k = ((cmd == CMD_ON) ? LOW : HIGH));
|
||||||
|
else
|
||||||
digitalWrite(pin, k = ((cmd == CMD_ON) ? HIGH : LOW));
|
digitalWrite(pin, k = ((cmd == CMD_ON) ? HIGH : LOW));
|
||||||
debugSerial<<F("Pin:")<<pin<<F("=")<<k<<F(",");
|
debugSerial<<F("Pin:")<<pin<<F("=")<<k<<F(",");
|
||||||
}
|
}
|
||||||
@@ -927,26 +951,28 @@ void cmdFunctionLoad(int arg_cnt, char **args) {
|
|||||||
// restoreState();
|
// restoreState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int loadConfigFromEEPROM()
|
int loadConfigFromEEPROM()
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
debugSerial<<F("loading Config");
|
debugSerial<<F("Loading Config from EEPROM")<<endl;
|
||||||
|
|
||||||
ch = EEPROM.read(EEPROM_offset);
|
ch = EEPROM.read(EEPROM_offset);
|
||||||
if (ch == '{') {
|
if (ch == '{') {
|
||||||
aJsonEEPROMStream as = aJsonEEPROMStream(EEPROM_offset);
|
aJsonEEPROMStream as = aJsonEEPROMStream(EEPROM_offset);
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
|
cleanConf();
|
||||||
root = aJson.parse(&as);
|
root = aJson.parse(&as);
|
||||||
if (!root) {
|
if (!root) {
|
||||||
debugSerial<<F("\nload failed\n");
|
debugSerial<<F("load failed")<<endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
debugSerial<<F("\nLoaded\n");
|
debugSerial<<F("Loaded")<<endl;
|
||||||
applyConfig();
|
applyConfig();
|
||||||
ethClient.stop(); //Refresh MQTT connect to get retained info
|
ethClient.stop(); //Refresh MQTT connect to get retained info
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
debugSerial<<F("\nNo stored config\n");
|
debugSerial<<F("No stored config")<<endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1134,9 +1160,10 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
//byte hserver[] = { 192,168,88,2 };
|
//byte hserver[] = { 192,168,88,2 };
|
||||||
wdt_dis();
|
wdt_dis();
|
||||||
HTTPClient hclient(configServer, 80);
|
HTTPClient hclient(configServer, 80);
|
||||||
HTTPClient hclientPrint(configServer, 80);
|
//HTTPClient hclientPrint(configServer, 80);
|
||||||
// FILE is the return STREAM type of the HTTPClient
|
// FILE is the return STREAM type of the HTTPClient
|
||||||
configStream = hclient.getURI(URI);
|
configStream = hclient.getURI(URI);
|
||||||
|
Serial.println("got--");delay(500);
|
||||||
responseStatusCode = hclient.getLastReturnCode();
|
responseStatusCode = hclient.getLastReturnCode();
|
||||||
wdt_en();
|
wdt_en();
|
||||||
|
|
||||||
@@ -1148,6 +1175,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
aJsonFileStream as = aJsonFileStream(configStream);
|
aJsonFileStream as = aJsonFileStream(configStream);
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
|
cleanConf();
|
||||||
root = aJson.parse(&as);
|
root = aJson.parse(&as);
|
||||||
interrupts();
|
interrupts();
|
||||||
// debugSerial<<F("Parsed."));
|
// debugSerial<<F("Parsed."));
|
||||||
@@ -1210,6 +1238,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
|
|
||||||
if (responseStatusCode == 200) {
|
if (responseStatusCode == 200) {
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
|
cleanConf()
|
||||||
root = aJson.parse((char *) response.c_str());
|
root = aJson.parse((char *) response.c_str());
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
@@ -1242,6 +1271,7 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
String response = httpClient.getString();
|
String response = httpClient.getString();
|
||||||
debugSerial<<response;
|
debugSerial<<response;
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
|
cleanConf()
|
||||||
root = aJson.parse((char *) response.c_str());
|
root = aJson.parse((char *) response.c_str());
|
||||||
if (!root) {
|
if (!root) {
|
||||||
debugSerial<<F("Config parsing failed\n");
|
debugSerial<<F("Config parsing failed\n");
|
||||||
@@ -1290,7 +1320,7 @@ void setup_main() {
|
|||||||
setupCmdArduino();
|
setupCmdArduino();
|
||||||
printFirmwareVersionAndBuildOptions();
|
printFirmwareVersionAndBuildOptions();
|
||||||
|
|
||||||
scan_i2c_bus();
|
// scan_i2c_bus();
|
||||||
|
|
||||||
#ifdef SD_CARD_INSERTED
|
#ifdef SD_CARD_INSERTED
|
||||||
sd_card_w5100_setup();
|
sd_card_w5100_setup();
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ void scan_i2c_bus() {
|
|||||||
byte error, address;
|
byte error, address;
|
||||||
int nDevices;
|
int nDevices;
|
||||||
|
|
||||||
debugSerial<<("Scanning...\n");
|
debugSerial<<(F("Scanning...\n"));
|
||||||
|
|
||||||
nDevices = 0;
|
nDevices = 0;
|
||||||
for(address = 1; address < 127; address++ )
|
for(address = 1; address < 127; address++ )
|
||||||
@@ -448,26 +448,25 @@ void scan_i2c_bus() {
|
|||||||
|
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
debugSerial<<("\nI2C device found at address 0x");
|
debugSerial<<(F("\nI2C device found at address "));
|
||||||
if (address<16)
|
// if (address<16)
|
||||||
debugSerial<<("0");
|
// debugSerial<<("0");
|
||||||
debugSerial<<(address,HEX);
|
debugSerial<<(address);
|
||||||
debugSerial<<(" !");
|
|
||||||
|
|
||||||
nDevices++;
|
nDevices++;
|
||||||
}
|
}
|
||||||
else if (error==4)
|
else if (error==4)
|
||||||
{
|
{
|
||||||
debugSerial<<("\nUnknow error at address 0x");
|
debugSerial<<(F("\nUnknow error at address "));
|
||||||
if (address<16)
|
// if (address<16)
|
||||||
debugSerial<<("0");
|
// debugSerial<<("0");
|
||||||
debugSerial<<(address,HEX);
|
debugSerial<<(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nDevices == 0)
|
if (nDevices == 0)
|
||||||
debugSerial<<("No I2C devices found\n");
|
debugSerial<<(F("No I2C devices found\n"));
|
||||||
else
|
else
|
||||||
debugSerial<<("done\n");
|
debugSerial<<(F("done\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user