Removed extra debug lines, and fixed netwrks scripts running multiple times

This commit is contained in:
Ben Suffolk 2022-06-08 21:08:58 +01:00
parent 6643bf031f
commit ac93c70bc1
4 changed files with 17 additions and 15 deletions

View File

@ -120,8 +120,8 @@ void setup()
delay(20);
if(!oobe) {
dispatch_exec(NULL, "L:/boot.cmd", TAG_HASP);
#if HASP_USE_WIFI > 0
wifi_run_scripts();
#if HASP_USE_WIFI > 0 || HASP_USE_ETHERNET > 0
network_run_scripts();
#endif
}
mainLastLoopTime = -1000; // reset loop counter

View File

@ -53,8 +53,6 @@ void EthernetEvent(WiFiEvent_t event)
void ethernetSetup()
{
LOG_TRACE(TAG_ETH, F("ethernetSetup()"));
#if HASP_USE_WIFI == 0
// Need to make sure we get the Ethernet Events
WiFi.begin();
@ -62,10 +60,7 @@ void ethernetSetup()
#endif
WiFi.onEvent(EthernetEvent);
bool started = ETHSPI.begin();
if(started)
LOG_TRACE(TAG_ETH, F("ETHSPI Started "));
ETHSPI.begin();
}
IRAM_ATTR void ethernetLoop(void)

View File

@ -26,8 +26,6 @@ void networkStart(void)
#if HASP_USE_MDNS > 0
mdnsStart();
#endif // HASP_USE_MDNS
dispatch_exec(NULL, "L:/online.cmd", TAG_WIFI);
}
void networkStop(void)
@ -43,14 +41,10 @@ void networkStop(void)
#if HASP_USE_MDNS > 0
mdnsStop();
#endif
dispatch_exec(NULL, "L:/offline.cmd", TAG_WIFI);
}
void networkSetup()
{
dispatch_exec(NULL, "L:/offline.cmd", TAG_WIFI);
#if HASP_USE_ETHERNET > 0
ethernetSetup();
#endif
@ -60,6 +54,14 @@ void networkSetup()
#endif
}
void network_run_scripts()
{
if(haspOnline)
dispatch_exec(NULL, "L:/online.cmd", TAG_WIFI);
else
dispatch_exec(NULL, "L:/offline.cmd", TAG_WIFI);
}
IRAM_ATTR void networkLoop(void)
{
#if HASP_USE_ETHERNET > 0
@ -107,6 +109,8 @@ bool networkEvery5Seconds(void)
} else {
networkStop();
}
network_run_scripts();
}
return haspOnline;
@ -122,6 +126,8 @@ bool networkEvery5Seconds(void)
} else {
networkStop();
}
network_run_scripts();
}
return haspOnline;
@ -203,4 +209,4 @@ void network_get_info(JsonDocument& doc)
#endif
}
#endif
#endif

View File

@ -13,6 +13,7 @@ void networkStart(void);
void networkStop(void);
/* ===== Special Event Processors ===== */
void network_run_scripts();
/* ===== Getter and Setter Functions ===== */
void network_get_statusupdate(char* buffer, size_t len);