Moved things to a FreeRTOS task so that we can garunte that we are meeting timings
This commit is contained in:
+13
-5
@@ -1,36 +1,44 @@
|
|||||||
// Nathan Hinton
|
// Nathan Hinton
|
||||||
// Main file for the hub node. Starting with the WIFI initialization.
|
// Main file for the hub node. Starting with the WIFI initialization.
|
||||||
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "services/service_manager.h"
|
#include "services/service_manager.h"
|
||||||
|
|
||||||
#include "services/wifi_service.h"
|
#include "services/wifi_service.h"
|
||||||
#include "services/web_service.h"
|
|
||||||
#include "services/ota_service.h"
|
#include "services/ota_service.h"
|
||||||
|
#include "services/web_service.h"
|
||||||
|
|
||||||
|
#include "tasks/system_task.h"
|
||||||
|
|
||||||
|
|
||||||
ServiceManager services;
|
ServiceManager services;
|
||||||
|
|
||||||
|
|
||||||
WiFiService wifi;
|
WiFiService wifi;
|
||||||
WebService web;
|
|
||||||
OTAService ota;
|
OTAService ota;
|
||||||
|
WebService web;
|
||||||
|
|
||||||
|
|
||||||
|
SystemTask systemTask(services);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
|
||||||
services.add(&wifi);
|
services.add(&wifi);
|
||||||
services.add(&ota);
|
services.add(&ota);
|
||||||
services.add(&web);
|
services.add(&web);
|
||||||
|
|
||||||
services.begin();
|
|
||||||
|
systemTask.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
services.update();
|
// Nothing here.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "web_service.h"
|
#include "web_service.h"
|
||||||
|
|
||||||
#define FIRMWARE_VERSION "1.0.0"
|
#define FIRMWARE_VERSION "1.0.1"
|
||||||
|
|
||||||
WebService::WebService()
|
WebService::WebService()
|
||||||
:
|
:
|
||||||
@@ -100,7 +100,7 @@ window.onload = getVersion;
|
|||||||
<div id="uptime">Loading...</div>
|
<div id="uptime">Loading...</div>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<div id="firmware_version">Loading...</div>
|
Firmware Version: <div id="firmware_version">Loading...</div>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user