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); delay(20);
if(!oobe) { if(!oobe) {
dispatch_exec(NULL, "L:/boot.cmd", TAG_HASP); dispatch_exec(NULL, "L:/boot.cmd", TAG_HASP);
#if HASP_USE_WIFI > 0 #if HASP_USE_WIFI > 0 || HASP_USE_ETHERNET > 0
wifi_run_scripts(); network_run_scripts();
#endif #endif
} }
mainLastLoopTime = -1000; // reset loop counter mainLastLoopTime = -1000; // reset loop counter

View File

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

View File

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

View File

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