diff --git a/include/coreids.h b/include/coreids.h new file mode 100644 index 0000000..60b78a5 --- /dev/null +++ b/include/coreids.h @@ -0,0 +1,5 @@ +#pragma once + +#define CORE_ID_LED 1 +#define CORE_ID_WEBSERVER 0 +#define CORE_ID_UPDATESERVER 0 diff --git a/src/UpdateServer.cpp b/src/UpdateServer.cpp index dd6c2a1..5edf711 100644 --- a/src/UpdateServer.cpp +++ b/src/UpdateServer.cpp @@ -6,19 +6,22 @@ #include "UpdateServer.h" +#include "coreids.h" + UpdateServer::UpdateServer(const std::string &pw) : m_cr(pw) {} void UpdateServer::start(void) { - xTaskCreate( + xTaskCreatePinnedToCore( updateTask, /* Task function. */ "Update Task", /* name of task. */ 10000, /* Stack size of task */ this, /* parameter of the task */ 2, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_UPDATESERVER); } static void sendMessage(WiFiClient *client, bool success, const char *message) diff --git a/src/WebServer.cpp b/src/WebServer.cpp index fed5684..1f39968 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -10,6 +10,8 @@ #include "Fader.h" #include "Animation/AnimationController.h" +#include "coreids.h" + WebServer::WebServer(void) : m_cr(Config::instance().getCRPassword()), m_fader(NULL) { @@ -274,13 +276,14 @@ void WebServer::serverTask(void *arg) bool WebServer::start(void) { - xTaskCreate( + xTaskCreatePinnedToCore( WebServer::serverTask, /* Task function. */ "HTTP Server Task", /* name of task. */ 6144, /* Stack size of task */ NULL, /* parameter of the task */ 1, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_WEBSERVER); return true; } diff --git a/src/main.cpp b/src/main.cpp index 9c9410a..39c5070 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -221,13 +221,14 @@ void setup() animController.changeAnimation(std::unique_ptr(new ConnectingAnimation(&ledFader)), false); - xTaskCreate( + xTaskCreatePinnedToCore( ledTask, /* Task function. */ "LED Task", /* name of task. */ 10000, /* Stack size of task */ NULL, /* parameter of the task */ 3, /* priority of the task */ - NULL); /* Task handle to keep track of created task */ + NULL, /* Task handle to keep track of created task */ + CORE_ID_LED); // Connect the WiFi network (or start an AP if that doesn't work) for (auto &net : Config::instance().getWLANList())