From 4901f12fcd0aec0af4acc5ce6048ee134063a24e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 6 Nov 2021 02:40:49 +0100 Subject: [PATCH] make own task on core0 for WifiESP::loop() on ESP32 --- CommandStation-EX.ino | 3 ++- WifiESP32.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 71c1d67..57b281b 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -124,7 +124,8 @@ void loop() #if WIFI_ON #ifndef ESP_FAMILY WifiInterface::loop(); -#else +#endif +#if defined(ARDUINO_ARCH_ESP8266) // on ESP32 own task WifiESP::loop(); #endif #endif //WIFI_ON diff --git a/WifiESP32.cpp b/WifiESP32.cpp index c907448..0aaacd3 100644 --- a/WifiESP32.cpp +++ b/WifiESP32.cpp @@ -69,6 +69,12 @@ static WiFiServer *server = NULL; static RingStream *outboundRing = new RingStream(2048); static bool APmode = false; +void wifiLoop(void *){ + for(;;){ + WifiESP::loop(); + } +} + bool WifiESP::setup(const char *SSid, const char *password, const char *hostname, @@ -139,6 +145,13 @@ bool WifiESP::setup(const char *SSid, server->begin(); DIAG(F("Server up port %d"),port); + xTaskCreatePinnedToCore(wifiLoop, /* Task function. */ + "wifiLoop",/* name of task. */ + 10000, /* Stack size of task */ + NULL, /* parameter of the task */ + 1, /* priority of the task */ + NULL, /* Task handle to keep track of created task */ + 0); /* pin task to core 0 */ return true; return false; }