mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-02-01 21:34:14 +01:00
some task management updates
This commit is contained in:
parent
b0345cceed
commit
8b2e8f3c14
|
|
@ -12,28 +12,29 @@
|
|||
class Task
|
||||
{
|
||||
public:
|
||||
Task(String & name) : _name(name) {}
|
||||
Task(const char * name) : _name(name) {}
|
||||
Task(String & name, int taskId) : _name(name), _taskId(taskId) {}
|
||||
Task(const char * name, int taskId) : _name(name), _taskId(taskId) {}
|
||||
virtual ~Task() {}
|
||||
|
||||
String getName() const { return _name; }
|
||||
int getTaskId() const { return _taskId; }
|
||||
|
||||
virtual bool setup(std::shared_ptr<Configuration> config, std::shared_ptr<BoardConfig> boardConfig) = 0;
|
||||
virtual bool loop(std::shared_ptr<Configuration> config) = 0;
|
||||
|
||||
private:
|
||||
String _name;
|
||||
int _taskId;
|
||||
};
|
||||
|
||||
class TaskManager
|
||||
{
|
||||
public:
|
||||
|
||||
static TaskManager & instance()
|
||||
{
|
||||
static TaskManager _instance;
|
||||
return _instance;
|
||||
}
|
||||
{
|
||||
static TaskManager _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
~TaskManager() {}
|
||||
|
||||
|
|
|
|||
26
src/Task.cpp
Normal file
26
src/Task.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "Task.h"
|
||||
|
||||
char const * const getTaskName(TaskNames task)
|
||||
{
|
||||
switch (task)
|
||||
{
|
||||
case TaskDisplay:
|
||||
return "Display";
|
||||
case TaskAprsIs:
|
||||
return "APRS-IS";
|
||||
case TaskEth:
|
||||
return "ETH";
|
||||
case TaskFtp:
|
||||
return "FTP";
|
||||
case TaskLora:
|
||||
return "LORA";
|
||||
case TaskNtp:
|
||||
return "NTP";
|
||||
case TaskOta:
|
||||
return "OTA";
|
||||
case TaskWifi:
|
||||
return "WIFI";
|
||||
default:
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
16
src/Task.h
16
src/Task.h
|
|
@ -1,6 +1,22 @@
|
|||
#ifndef TASK_H_
|
||||
#define TASK_H_
|
||||
|
||||
enum TaskNames
|
||||
{
|
||||
TaskDisplay,
|
||||
TaskAprsIs,
|
||||
TaskEth,
|
||||
TaskFtp,
|
||||
TaskLora,
|
||||
TaskNtp,
|
||||
TaskOta,
|
||||
TaskWifi,
|
||||
TaskSize,
|
||||
};
|
||||
|
||||
char const * const getTaskName(TaskNames task);
|
||||
|
||||
#define TASK_DISPLAY "DisplayTask"
|
||||
#define TASK_APRS_IS "AprsIsTask"
|
||||
#define TASK_ETH "EthTask"
|
||||
#define TASK_FTP "FTPTask"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ String create_lat_aprs(double lat);
|
|||
String create_long_aprs(double lng);
|
||||
|
||||
AprsIsTask::AprsIsTask()
|
||||
: Task(TASK_APRS_IS), _beacon_next_time(0)
|
||||
: Task(TASK_APRS_IS, TaskAprsIs), _beacon_next_time(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -47,11 +47,9 @@ bool AprsIsTask::loop(std::shared_ptr<Configuration> config)
|
|||
|
||||
if(_beacon_next_time < now())
|
||||
{
|
||||
//show_display(userConfig->callsign, "Beacon to APRS-IS Server...");
|
||||
logPrintD("[" + timeString() + "] ");
|
||||
logPrintlnD(_beaconMsg->encode());
|
||||
_aprs_is->sendMessage(_beaconMsg);
|
||||
//show_display(userConfig->callsign, "Standby...");
|
||||
_beacon_next_time = now() + config->beacon.timeout * 60UL;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -63,7 +61,6 @@ bool AprsIsTask::connect(std::shared_ptr<Configuration> config)
|
|||
logPrintI(config->aprs_is.server);
|
||||
logPrintI(" on port: ");
|
||||
logPrintlnI(String(config->aprs_is.port));
|
||||
//show_display("INFO", "Connecting to APRS-IS server");
|
||||
if(!_aprs_is->connect(config->aprs_is.server, config->aprs_is.port))
|
||||
{
|
||||
logPrintlnE("Connection failed.");
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static void WiFiEvent(WiFiEvent_t event)
|
|||
}
|
||||
|
||||
EthTask::EthTask()
|
||||
: Task(TASK_ETH)
|
||||
: Task(TASK_ETH, TaskEth)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "Task.h"
|
||||
|
||||
FTPTask::FTPTask()
|
||||
: Task(TASK_FTP), _beginCalled(false)
|
||||
: Task(TASK_FTP, TaskFtp), _beginCalled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "Task.h"
|
||||
|
||||
LoraTask::LoraTask()
|
||||
: Task(TASK_LORA)
|
||||
: Task(TASK_LORA, TaskLora)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,6 @@ bool LoraTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Boar
|
|||
if(!_lora_aprs->begin(_lora_aprs->getRxFrequency()))
|
||||
{
|
||||
logPrintlnE("Starting LoRa failed!");
|
||||
//show_display("ERROR", "Starting LoRa failed!");
|
||||
while(true);
|
||||
}
|
||||
_lora_aprs->setRxFrequency(config->lora.frequencyRx);
|
||||
|
|
@ -30,7 +29,6 @@ bool LoraTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Boar
|
|||
_lora_aprs->setSignalBandwidth(config->lora.signalBandwidth);
|
||||
_lora_aprs->setCodingRate4(config->lora.codingRate4);
|
||||
_lora_aprs->enableCrc();
|
||||
//show_display("INFO", "LoRa init done!", 2000);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "Task.h"
|
||||
|
||||
NTPTask::NTPTask()
|
||||
: Task(TASK_NTP), _beginCalled(false)
|
||||
: Task(TASK_NTP, TaskNtp), _beginCalled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "Task.h"
|
||||
|
||||
OTATask::OTATask()
|
||||
: Task(TASK_OTA), _beginCalled(false)
|
||||
: Task(TASK_OTA, TaskOta), _beginCalled(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +23,6 @@ bool OTATask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Board
|
|||
else // U_SPIFFS
|
||||
type = "filesystem";
|
||||
logPrintlnI("Start updating " + type);
|
||||
//show_display("OTA UPDATE", "Start update", type);
|
||||
})
|
||||
.onEnd([]()
|
||||
{
|
||||
|
|
@ -35,7 +34,6 @@ bool OTATask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Board
|
|||
logPrintI("Progress: ");
|
||||
logPrintI(String(progress / (total / 100)));
|
||||
logPrintlnI("%");
|
||||
//show_display("OTA UPDATE", "Progress: ", String(progress / (total / 100)) + "%");
|
||||
})
|
||||
.onError([](ota_error_t error)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "Task.h"
|
||||
|
||||
WifiTask::WifiTask()
|
||||
: Task(TASK_WIFI), _oldWifiStatus(WL_IDLE_STATUS)
|
||||
: Task(TASK_WIFI, TaskWifi), _oldWifiStatus(WL_IDLE_STATUS)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue