mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
w5100 reset, soft reset, refactoring
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
||||||
export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
||||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
export FLAGS="$FLAGS -DDHT_DISABLE"
|
||||||
export FLAGS="$FLAGS -DRESET_PIN=5"
|
export FLAGS="$FLAGS -DW5100_RESET_PIN=5"
|
||||||
|
export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
||||||
export PLATFORMIO_BUILD_FLAGS="$FLAGS"
|
export PLATFORMIO_BUILD_FLAGS="$FLAGS"
|
||||||
echo PLATFORMIO_BUILD_FLAGS=$PLATFORMIO_BUILD_FLAGS
|
echo PLATFORMIO_BUILD_FLAGS=$PLATFORMIO_BUILD_FLAGS
|
||||||
echo "==============================================Custom build flags END====================================================="
|
echo "==============================================Custom build flags END====================================================="
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ aJsonObject *dmxArr = NULL;
|
|||||||
|
|
||||||
unsigned long nextPollingCheck = 0;
|
unsigned long nextPollingCheck = 0;
|
||||||
unsigned long nextInputCheck = 0;
|
unsigned long nextInputCheck = 0;
|
||||||
unsigned long lanCheck = 0;
|
unsigned long nextLanCheckTime = 0;
|
||||||
unsigned long nextThermostatCheck = 0;
|
unsigned long nextThermostatCheck = 0;
|
||||||
|
|
||||||
aJsonObject *pollingItem = NULL;
|
aJsonObject *pollingItem = NULL;
|
||||||
@@ -119,7 +119,7 @@ PubSubClient mqttClient(ethClient);
|
|||||||
|
|
||||||
bool wifiInitialized;
|
bool wifiInitialized;
|
||||||
|
|
||||||
int mqtt_error_rate;
|
int mqttErrorRate;
|
||||||
|
|
||||||
void watchdogSetup(void) {
|
void watchdogSetup(void) {
|
||||||
//Serial.begin(115200);
|
//Serial.begin(115200);
|
||||||
@@ -154,7 +154,7 @@ void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean retaining = (lanStatus == 4); //Todo - named constant
|
boolean retaining = (lanStatus == RETAINING_COLLECTING);
|
||||||
//Check if topic = Command topic
|
//Check if topic = Command topic
|
||||||
short intopic = 0;
|
short intopic = 0;
|
||||||
{
|
{
|
||||||
@@ -209,76 +209,18 @@ void restoreState() {
|
|||||||
//mqttClient.publish("/myhome/out/RestoreState", "ON");
|
//mqttClient.publish("/myhome/out/RestoreState", "ON");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lan_status lanLoop() {
|
lan_status lanLoop() {
|
||||||
|
|
||||||
#ifdef NOETHER
|
#ifdef NOETHER
|
||||||
lanStatus=-14;
|
lanStatus=DO_NOTHING;//-14;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (lanStatus) {
|
switch (lanStatus) {
|
||||||
case INITIAL_STATE:
|
case INITIAL_STATE: {
|
||||||
{
|
onInitialStateInitLAN();
|
||||||
#ifdef __ESP__
|
|
||||||
if(!wifiInitialized) {
|
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
Serial.print(F("WIFI AP/Password:"));
|
|
||||||
Serial.print(QUOTE(ESP_WIFI_AP));
|
|
||||||
Serial.print(F("/"));
|
|
||||||
Serial.println(QUOTE(ESP_WIFI_PWD));
|
|
||||||
wifi_set_macaddr(STATION_IF,mac);
|
|
||||||
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
|
||||||
wifiInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
|
||||||
Serial.println("WiFi connected");
|
|
||||||
Serial.println("IP address: ");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
lanStatus=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
IPAddress ip;
|
|
||||||
IPAddress dns;
|
|
||||||
IPAddress gw;
|
|
||||||
IPAddress mask;
|
|
||||||
int res = 1;
|
|
||||||
Serial.println(F("Starting lan"));
|
|
||||||
if (loadFlash(OFFSET_IP, ip))
|
|
||||||
if (loadFlash(OFFSET_DNS, dns))
|
|
||||||
if (loadFlash(OFFSET_GW, gw))
|
|
||||||
if (loadFlash(OFFSET_MASK, mask)) Ethernet.begin(mac, ip, dns, gw, mask);
|
|
||||||
else Ethernet.begin(mac, ip, dns, gw);
|
|
||||||
else Ethernet.begin(mac, ip, dns);
|
|
||||||
else Ethernet.begin(mac, ip);
|
|
||||||
else {
|
|
||||||
wdt_dis();
|
|
||||||
res = Ethernet.begin(mac, 12000);
|
|
||||||
wdt_en();
|
|
||||||
wdt_res();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (res == 0) {
|
|
||||||
Serial.println(F("Failed to configure Ethernet using DHCP. You can set ip manually!"));
|
|
||||||
Serial.print(F("'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"));
|
|
||||||
lanStatus = AWAITING_ADDRESS;//-10;
|
|
||||||
lanCheck = millis() + 60000;
|
|
||||||
#ifdef RESET_PIN
|
|
||||||
resetFunc();
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
printIPAddress();
|
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case HAVE_IP_ADDRESS:
|
case HAVE_IP_ADDRESS:
|
||||||
if (!configOk)
|
if (!configOk)
|
||||||
lanStatus = getConfig(0, NULL); //got config from server or load from NVRAM
|
lanStatus = getConfig(0, NULL); //got config from server or load from NVRAM
|
||||||
@@ -286,11 +228,103 @@ lan_status lanLoop() {
|
|||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->begin();
|
if (artnet) artnet->begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
||||||
wdt_res();
|
wdt_res();
|
||||||
|
ip_ready_config_loaded_connecting_to_broker();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RETAINING_COLLECTING:
|
||||||
|
if (millis() > nextLanCheckTime) {
|
||||||
|
char buf[MQTT_TOPIC_LENGTH];
|
||||||
|
|
||||||
|
//Unsubscribe from status topics..
|
||||||
|
strncpy_P(buf, outprefix, sizeof(buf));
|
||||||
|
strncat(buf, "#", sizeof(buf));
|
||||||
|
mqttClient.unsubscribe(buf);
|
||||||
|
|
||||||
|
lanStatus = OPERATION;//3;
|
||||||
|
Serial.println(F("Accepting commands..."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OPERATION:
|
||||||
|
if (!mqttClient.connected()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AWAITING_ADDRESS:
|
||||||
|
if (millis() > nextLanCheckTime)
|
||||||
|
lanStatus = INITIAL_STATE;//0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RECONNECT:
|
||||||
|
if (millis() > nextLanCheckTime)
|
||||||
|
|
||||||
|
lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case READ_RE_CONFIG:
|
||||||
|
if (loadConfigFromEEPROM(0, NULL)) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
||||||
|
else {
|
||||||
|
nextLanCheckTime = millis() + 5000;
|
||||||
|
lanStatus = AWAITING_ADDRESS;//-10;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DO_NOTHING:;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#ifndef __ESP__
|
||||||
|
wdt_dis();
|
||||||
|
if (lanStatus > 0)
|
||||||
|
switch (Ethernet.maintain()) {
|
||||||
|
case NO_LINK:
|
||||||
|
Serial.println(F("No link"));
|
||||||
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
nextLanCheckTime = millis() + 30000;
|
||||||
|
lanStatus = AWAITING_ADDRESS;//-10;
|
||||||
|
break;
|
||||||
|
case DHCP_CHECK_RENEW_FAIL:
|
||||||
|
Serial.println(F("Error: renewed fail"));
|
||||||
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
nextLanCheckTime = millis() + 1000;
|
||||||
|
lanStatus = AWAITING_ADDRESS;//-10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DHCP_CHECK_RENEW_OK:
|
||||||
|
Serial.println(F("Renewed success"));
|
||||||
|
printIPAddress();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DHCP_CHECK_REBIND_FAIL:
|
||||||
|
Serial.println(F("Error: rebind fail"));
|
||||||
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
|
nextLanCheckTime = millis() + 1000;
|
||||||
|
lanStatus = AWAITING_ADDRESS;//-10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DHCP_CHECK_REBIND_OK:
|
||||||
|
Serial.println(F("Rebind success"));
|
||||||
|
printIPAddress();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wdt_en();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return lanStatus;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ip_ready_config_loaded_connecting_to_broker() {
|
||||||
short n = 0;
|
short n = 0;
|
||||||
int port = 1883;
|
int port = 1883;
|
||||||
char empty = 0;
|
char empty = 0;
|
||||||
@@ -322,7 +356,7 @@ lan_status lanLoop() {
|
|||||||
|
|
||||||
wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
||||||
if (mqttClient.connect(client_id, user, password)) {
|
if (mqttClient.connect(client_id, user, password)) {
|
||||||
mqtt_error_rate = 0;
|
mqttErrorRate = 0;
|
||||||
Serial.print(F("connected as "));
|
Serial.print(F("connected as "));
|
||||||
Serial.println(client_id);
|
Serial.println(client_id);
|
||||||
wdt_en();
|
wdt_en();
|
||||||
@@ -342,131 +376,97 @@ lan_status lanLoop() {
|
|||||||
//restoreState();
|
//restoreState();
|
||||||
// if (_once) {DMXput(); _once=0;}
|
// if (_once) {DMXput(); _once=0;}
|
||||||
lanStatus = RETAINING_COLLECTING;//4;
|
lanStatus = RETAINING_COLLECTING;//4;
|
||||||
lanCheck = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
Serial.println(F("Awaiting for retained topics"));
|
Serial.println(F("Awaiting for retained topics"));
|
||||||
} else {
|
} else {
|
||||||
Serial.print(F("failed, rc="));
|
Serial.print(F("failed, rc="));
|
||||||
Serial.print(mqttClient.state());
|
Serial.print(mqttClient.state());
|
||||||
Serial.println(F(" try again in 5 seconds"));
|
Serial.println(F(" try again in 5 seconds"));
|
||||||
lanCheck = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
#ifdef RESET_PIN
|
#ifdef W5100_RESET_PIN
|
||||||
mqtt_error_rate++;
|
mqttErrorRate++;
|
||||||
if(mqtt_error_rate>50){
|
if(mqttErrorRate>50){
|
||||||
Serial.print(F("Too many MQTT connection errors. Resetting."));
|
Serial.print(F("Too many MQTT connection errors. Restart LAN"));
|
||||||
resetFunc();
|
mqttErrorRate=0;
|
||||||
|
resetW5100();
|
||||||
|
lanStatus=INITIAL_STATE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lanStatus = RECONNECT;//12;
|
lanStatus = RECONNECT;//12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case RETAINING_COLLECTING:
|
void onInitialStateInitLAN() {
|
||||||
if (millis() > lanCheck) {
|
#ifdef __ESP__
|
||||||
char buf[MQTT_TOPIC_LENGTH];
|
if(!wifiInitialized) {
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
//Unsubscribe from status topics..
|
Serial.print(F("WIFI AP/Password:"));
|
||||||
strncpy_P(buf, outprefix, sizeof(buf));
|
Serial.print(QUOTE(ESP_WIFI_AP));
|
||||||
strncat(buf, "#", sizeof(buf));
|
Serial.print(F("/"));
|
||||||
mqttClient.unsubscribe(buf);
|
Serial.println(QUOTE(ESP_WIFI_PWD));
|
||||||
|
wifi_set_macaddr(STATION_IF,mac);
|
||||||
lanStatus = OPERATION;//3;
|
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
|
||||||
Serial.println(F("Accepting commands..."));
|
wifiInitialized = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case OPERATION:
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
if (!mqttClient.connected()) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
Serial.println("WiFi connected");
|
||||||
break;
|
Serial.println("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
lanStatus=1;
|
||||||
|
}
|
||||||
|
|
||||||
case AWAITING_ADDRESS:
|
|
||||||
if (millis() > lanCheck)
|
|
||||||
lanStatus = INITIAL_STATE;//0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RECONNECT:
|
#else
|
||||||
if (millis() > lanCheck)
|
IPAddress ip,dns,gw,mask;
|
||||||
|
int res = 1;
|
||||||
lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
Serial.println(F("Starting lan"));
|
||||||
break;
|
if (loadFlash(OFFSET_IP, ip))
|
||||||
case READ_RE_CONFIG:
|
if (loadFlash(OFFSET_DNS, dns))
|
||||||
if (loadConfigFromEEPROM(0, NULL)) lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;//2;
|
if (loadFlash(OFFSET_GW, gw))
|
||||||
|
if (loadFlash(OFFSET_MASK, mask)) Ethernet.begin(mac, ip, dns, gw, mask);
|
||||||
|
else Ethernet.begin(mac, ip, dns, gw);
|
||||||
|
else Ethernet.begin(mac, ip, dns);
|
||||||
|
else Ethernet.begin(mac, ip);
|
||||||
else {
|
else {
|
||||||
lanCheck = millis() + 5000;
|
|
||||||
lanStatus = AWAITING_ADDRESS;//-10;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DO_NOTHING:;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
#ifndef __ESP__
|
|
||||||
wdt_dis();
|
wdt_dis();
|
||||||
if (lanStatus > 0)
|
res = Ethernet.begin(mac, 12000);
|
||||||
switch (Ethernet.maintain()) {
|
|
||||||
case NO_LINK:
|
|
||||||
Serial.println(F("No link"));
|
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
|
||||||
lanCheck = millis() + 30000;
|
|
||||||
lanStatus = AWAITING_ADDRESS;//-10;
|
|
||||||
break;
|
|
||||||
case DHCP_CHECK_RENEW_FAIL:
|
|
||||||
//renewed fail
|
|
||||||
Serial.println(F("Error: renewed fail"));
|
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
|
||||||
lanCheck = millis() + 1000;
|
|
||||||
lanStatus = AWAITING_ADDRESS;//-10;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DHCP_CHECK_RENEW_OK:
|
|
||||||
Serial.println(F("Renewed success"));
|
|
||||||
printIPAddress();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DHCP_CHECK_REBIND_FAIL:
|
|
||||||
Serial.println(F("Error: rebind fail"));
|
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
|
||||||
lanCheck = millis() + 1000;
|
|
||||||
lanStatus = AWAITING_ADDRESS;//-10;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DHCP_CHECK_REBIND_OK:
|
|
||||||
Serial.println(F("Rebind success"));
|
|
||||||
printIPAddress();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
//nothing happened
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wdt_en();
|
wdt_en();
|
||||||
|
wdt_res();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 0) {
|
||||||
|
Serial.println(F("Failed to configure Ethernet using DHCP. You can set ip manually!"));
|
||||||
|
Serial.print(F("'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"));
|
||||||
|
lanStatus = AWAITING_ADDRESS;//-10;
|
||||||
|
nextLanCheckTime = millis() + DHCP_RETRY_INTERVAL;
|
||||||
|
#ifdef W5100_RESET_PIN
|
||||||
|
resetW5100();
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
printIPAddress();
|
||||||
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return lanStatus;
|
void (*softRebootFunc)(void) = 0;
|
||||||
|
|
||||||
}
|
void resetW5100() {
|
||||||
|
#ifdef W5100_RESET_PIN
|
||||||
void (*softResetFunc)(void) = 0;
|
Serial.print(F("Reset Wiznet5100 shield with digital pin "));
|
||||||
|
Serial.println(QUOTE(W5100_RESET_PIN));
|
||||||
void resetFunc() {
|
delay(50);
|
||||||
#ifdef RESET_PIN
|
pinMode(W5100_RESET_PIN, OUTPUT);
|
||||||
Serial.print(F("Reset arduino with digital pin "));
|
digitalWrite(W5100_RESET_PIN,LOW);
|
||||||
Serial.println(QUOTE(RESET_PIN));
|
delay(25);
|
||||||
delay(1000);
|
digitalWrite(W5100_RESET_PIN,HIGH);
|
||||||
pinMode(RESET_PIN, OUTPUT);
|
delay(500);
|
||||||
digitalWrite(RESET_PIN,LOW);
|
|
||||||
delay(1000);
|
|
||||||
digitalWrite(RESET_PIN,HIGH);
|
|
||||||
#endif
|
#endif
|
||||||
Serial.println(F("Hardware reset not working! Use soft reset... "));
|
|
||||||
delay(1000);
|
|
||||||
softResetFunc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
@@ -533,8 +533,8 @@ void cmdFunctionKill(int arg_cnt, char **args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionReboot(int arg_cnt, char **args) {
|
void cmdFunctionReboot(int arg_cnt, char **args) {
|
||||||
Serial.println(F("Rebooting..."));
|
Serial.println(F("Soft rebooting..."));
|
||||||
resetFunc();
|
softRebootFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyConfig() {
|
void applyConfig() {
|
||||||
@@ -847,7 +847,7 @@ lan_status getConfig(int arg_cnt, char **args)
|
|||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
Serial.println(F("Config parsing failed"));
|
Serial.println(F("Config parsing failed"));
|
||||||
lanCheck = millis() + 15000;
|
nextLanCheckTime = millis() + 15000;
|
||||||
return -11;
|
return -11;
|
||||||
} else {
|
} else {
|
||||||
// char *outstr = aJson.print(root);
|
// char *outstr = aJson.print(root);
|
||||||
@@ -862,14 +862,14 @@ lan_status getConfig(int arg_cnt, char **args)
|
|||||||
} else {
|
} else {
|
||||||
Serial.print(F("ERROR: Server returned "));
|
Serial.print(F("ERROR: Server returned "));
|
||||||
Serial.println(responseStatusCode);
|
Serial.println(responseStatusCode);
|
||||||
lanCheck = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
return READ_RE_CONFIG;//-11;
|
return READ_RE_CONFIG;//-11;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Serial.println(F("failed to connect"));
|
Serial.println(F("failed to connect"));
|
||||||
Serial.println(F(" try again in 5 seconds"));
|
Serial.println(F(" try again in 5 seconds"));
|
||||||
lanCheck = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
return READ_RE_CONFIG;//-11;
|
return READ_RE_CONFIG;//-11;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -901,7 +901,7 @@ lan_status getConfig(int arg_cnt, char **args)
|
|||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
Serial.println(F("Config parsing failed"));
|
Serial.println(F("Config parsing failed"));
|
||||||
// lanCheck=millis()+15000;
|
// nextLanCheckTime=millis()+15000;
|
||||||
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@@ -916,7 +916,7 @@ lan_status getConfig(int arg_cnt, char **args)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.println(F("Config retrieving failed"));
|
Serial.println(F("Config retrieving failed"));
|
||||||
//lanCheck=millis()+15000;
|
//nextLanCheckTime=millis()+15000;
|
||||||
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1081,9 +1081,9 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
Serial.println(F("(+)SDCARD"));
|
Serial.println(F("(+)SDCARD"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RESET_PIN
|
#ifdef W5100_RESET_PIN
|
||||||
Serial.print(F("(+)HARDRESET on pin="));
|
Serial.print(F("(+)HARDRESET on pin="));
|
||||||
Serial.println(F(QUOTE(RESET_PIN)));
|
Serial.println(F(QUOTE(W5100_RESET_PIN)));
|
||||||
#else
|
#else
|
||||||
Serial.println("(-)HARDRESET, using soft");
|
Serial.println("(-)HARDRESET, using soft");
|
||||||
#endif
|
#endif
|
||||||
@@ -1153,7 +1153,7 @@ void loop_main() {
|
|||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
#ifndef MODBUS_DISABLE
|
#ifndef MODBUS_DISABLE
|
||||||
if (lanStatus != 4) pollingLoop();
|
if (lanStatus != RETAINING_COLLECTING) pollingLoop();
|
||||||
#endif
|
#endif
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
thermoLoop();
|
thermoLoop();
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
#define wdt_dis()
|
#define wdt_dis()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DHCP_RETRY_INTERVAL
|
||||||
|
#define DHCP_RETRY_INTERVAL 60000
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
#define wdt_en() wdt_enable(WDTO_8S)
|
#define wdt_en() wdt_enable(WDTO_8S)
|
||||||
#define wdt_dis() wdt_disable()
|
#define wdt_dis() wdt_disable()
|
||||||
@@ -195,6 +199,10 @@ bool IsThermostat(const aJsonObject *item);
|
|||||||
|
|
||||||
bool disabledDisconnected(const aJsonObject *thermoExtensionArray, int thermoLatestCommand);
|
bool disabledDisconnected(const aJsonObject *thermoExtensionArray, int thermoLatestCommand);
|
||||||
|
|
||||||
void resetFunc();
|
void resetW5100();
|
||||||
|
|
||||||
|
void onInitialStateInitLAN();
|
||||||
|
|
||||||
|
void ip_ready_config_loaded_connecting_to_broker();
|
||||||
|
|
||||||
#endif //LIGHTHUB_MAIN_H
|
#endif //LIGHTHUB_MAIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user