Moved things to a FreeRTOS task so that we can garunte that we are meeting timings

This commit is contained in:
2026-08-08 21:31:54 -06:00
parent ea34c399d7
commit 3946e464c9
4 changed files with 106 additions and 7 deletions
+13 -5
View File
@@ -1,36 +1,44 @@
// Nathan Hinton
// Main file for the hub node. Starting with the WIFI initialization.
#include <Arduino.h>
#include "services/service_manager.h"
#include "services/wifi_service.h"
#include "services/web_service.h"
#include "services/ota_service.h"
#include "services/web_service.h"
#include "tasks/system_task.h"
ServiceManager services;
WiFiService wifi;
WebService web;
OTAService ota;
WebService web;
SystemTask systemTask(services);
void setup()
{
Serial.begin(115200);
services.add(&wifi);
services.add(&ota);
services.add(&web);
services.begin();
systemTask.start();
}
void loop()
{
services.update();
// Nothing here.
}
+2 -2
View File
@@ -1,6 +1,6 @@
#include "web_service.h"
#define FIRMWARE_VERSION "1.0.0"
#define FIRMWARE_VERSION "1.0.1"
WebService::WebService()
:
@@ -100,7 +100,7 @@ window.onload = getVersion;
<div id="uptime">Loading...</div>
</div>
<footer>
<div id="firmware_version">Loading...</div>
Firmware Version: <div id="firmware_version">Loading...</div>
</footer>
</body>
</html>
+65
View File
@@ -0,0 +1,65 @@
#include "system_task.h"
SystemTask::SystemTask(ServiceManager& manager)
:
serviceManager(manager),
taskHandle(nullptr)
{
}
// xTaskCreatePinnedToCore(
// function,
// name,
// stack size,
// parameter,
// priority,
// handle,
// core
// );
void SystemTask::start()
{
xTaskCreatePinnedToCore(
taskEntry,
"SystemTask",
4096,
this,
2,
&taskHandle,
1
);
}
void SystemTask::taskEntry(void* parameter)
{
SystemTask* task =
static_cast<SystemTask*>(parameter);
task->run();
}
void SystemTask::run()
{
serviceManager.begin();
TickType_t lastWakeTime =
xTaskGetTickCount();
while(true)
{
serviceManager.update();
vTaskDelayUntil(
&lastWakeTime,
pdMS_TO_TICKS(10)
);
}
}
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include <Arduino.h>
#include "../services/service_manager.h"
class SystemTask
{
public:
SystemTask(ServiceManager& manager);
void start();
private:
static void taskEntry(void* parameter);
void run();
ServiceManager& serviceManager;
TaskHandle_t taskHandle;
};