mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-04-04 22:18:58 +00:00
adding display support and many other stuff
This commit is contained in:
parent
3585af057a
commit
5eec516fb9
35 changed files with 4519 additions and 1479 deletions
|
|
@ -20,6 +20,8 @@
|
|||
#include "TaskOTA.h"
|
||||
#include "TaskWifi.h"
|
||||
|
||||
#define VERSION "20.49.0-dev"
|
||||
|
||||
String create_lat_aprs(double lat);
|
||||
String create_long_aprs(double lng);
|
||||
|
||||
|
|
@ -33,6 +35,8 @@ void setup()
|
|||
Serial.begin(115200);
|
||||
Logger::instance().setSerial(&Serial);
|
||||
delay(500);
|
||||
logPrintlnW("LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||
logPrintlnW("Version: " VERSION);
|
||||
|
||||
ProjectConfigurationManagement confmg;
|
||||
userConfig = confmg.readConfiguration();
|
||||
|
|
@ -69,10 +73,9 @@ void setup()
|
|||
|
||||
if(boardConfig->Type == eTTGO_T_Beam_V1_0)
|
||||
{
|
||||
TwoWire wire(0);
|
||||
wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
||||
Wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
||||
std::shared_ptr<PowerManagement> powerManagement = std::shared_ptr<PowerManagement>(new PowerManagement);
|
||||
if (!powerManagement->begin(wire))
|
||||
if (!powerManagement->begin(Wire))
|
||||
{
|
||||
logPrintlnI("AXP192 init done!");
|
||||
}
|
||||
|
|
@ -85,11 +88,6 @@ void setup()
|
|||
powerManagement->deactivateGPS();
|
||||
}
|
||||
|
||||
logPrintlnW("LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||
logPrintlnW("Version: 20.49.0-dev");
|
||||
//setup_display(boardConfig);
|
||||
//show_display("OE5BPA", "LoRa APRS iGate", "by Peter Buchegger", "20.49.0-dev", 3000);
|
||||
|
||||
load_config(boardConfig);
|
||||
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new DisplayTask()));
|
||||
|
|
@ -101,18 +99,23 @@ void setup()
|
|||
TaskManager::instance().addTask(std::shared_ptr<Task>(new WifiTask()));
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new OTATask()));
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new NTPTask()));
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new FTPTask()));
|
||||
if(userConfig->ftp.active)
|
||||
{
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new FTPTask()));
|
||||
}
|
||||
TaskManager::instance().addTask(std::shared_ptr<Task>(new AprsIsTask()));
|
||||
|
||||
TaskManager::instance().setup(userConfig, boardConfig);
|
||||
|
||||
Display::instance().showSpashScreen("LoRa APRS iGate", VERSION);
|
||||
|
||||
if(userConfig->display.overwritePin != 0)
|
||||
{
|
||||
pinMode(userConfig->display.overwritePin, INPUT);
|
||||
pinMode(userConfig->display.overwritePin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
delay(5000);
|
||||
logPrintlnI("setup done...");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
enum TaskNames
|
||||
{
|
||||
TaskDisplay,
|
||||
TaskAprsIs,
|
||||
TaskAprsIs = 1,
|
||||
TaskEth,
|
||||
TaskFtp,
|
||||
TaskLora,
|
||||
|
|
@ -16,7 +15,6 @@ enum TaskNames
|
|||
|
||||
//char const * const getTaskName(TaskNames task);
|
||||
|
||||
#define TASK_DISPLAY "DisplayTask"
|
||||
#define TASK_APRS_IS "AprsIsTask"
|
||||
#define TASK_ETH "EthTask"
|
||||
#define TASK_FTP "FTPTask"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,15 @@ bool AprsIsTask::loop(std::shared_ptr<Configuration> config)
|
|||
{
|
||||
if(!_aprs_is->connected())
|
||||
{
|
||||
return connect(config);
|
||||
if(!connect(config))
|
||||
{
|
||||
_stateInfo = "not connected";
|
||||
_state = Error;
|
||||
return false;
|
||||
}
|
||||
_stateInfo = "connected";
|
||||
_state = Okay;
|
||||
return false;
|
||||
}
|
||||
|
||||
_aprs_is->getAPRSMessage();
|
||||
|
|
@ -50,8 +58,12 @@ bool AprsIsTask::loop(std::shared_ptr<Configuration> config)
|
|||
logPrintD("[" + timeString() + "] ");
|
||||
logPrintlnD(_beaconMsg->encode());
|
||||
_aprs_is->sendMessage(_beaconMsg);
|
||||
Display::instance().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("BEACON", _beaconMsg->toString())));
|
||||
_beacon_next_time = now() + config->beacon.timeout * 60UL;
|
||||
}
|
||||
time_t diff = _beacon_next_time - now();
|
||||
_stateInfo = "beacon " + String(minute(diff)) + ":" + String(second(diff));
|
||||
_state = Okay;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#include <logger.h>
|
||||
#include <TimeLib.h>
|
||||
#include "project_configuration.h"
|
||||
#include "TaskDisplay.h"
|
||||
#include "Task.h"
|
||||
|
||||
DisplayTask::DisplayTask()
|
||||
: Task(TASK_DISPLAY, TaskDisplay), _beginCalled(false)
|
||||
{
|
||||
}
|
||||
|
||||
DisplayTask::~DisplayTask()
|
||||
{
|
||||
}
|
||||
|
||||
bool DisplayTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<BoardConfig> boardConfig)
|
||||
{
|
||||
Display::instance().setup(boardConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisplayTask::loop(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
if(!_beginCalled)
|
||||
{
|
||||
_beginCalled = true;
|
||||
}
|
||||
Display::instance().update();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef TASK_DISPLAY_H_
|
||||
#define TASK_DISPLAY_H_
|
||||
|
||||
#include <Display.h>
|
||||
#include <TaskManager.h>
|
||||
|
||||
class DisplayTask : public Task
|
||||
{
|
||||
public:
|
||||
DisplayTask();
|
||||
virtual ~DisplayTask();
|
||||
|
||||
virtual bool setup(std::shared_ptr<Configuration> config, std::shared_ptr<BoardConfig> boardConfig) override;
|
||||
virtual bool loop(std::shared_ptr<Configuration> config) override;
|
||||
|
||||
private:
|
||||
bool _beginCalled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -17,40 +17,36 @@ FTPTask::~FTPTask()
|
|||
bool FTPTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<BoardConfig> boardConfig)
|
||||
{
|
||||
_ftpServer = std::shared_ptr<FTPServer>(new FTPServer());
|
||||
if(config->ftp.active)
|
||||
for(Configuration::Ftp::User user : config->ftp.users)
|
||||
{
|
||||
for(Configuration::Ftp::User user : config->ftp.users)
|
||||
{
|
||||
logPrintD("Adding user to FTP Server: ");
|
||||
logPrintlnD(user.name);
|
||||
_ftpServer->addUser(user.name, user.password);
|
||||
}
|
||||
_ftpServer->addFilesystem("SPIFFS", &SPIFFS);
|
||||
logPrintD("Adding user to FTP Server: ");
|
||||
logPrintlnD(user.name);
|
||||
_ftpServer->addUser(user.name, user.password);
|
||||
}
|
||||
_ftpServer->addFilesystem("SPIFFS", &SPIFFS);
|
||||
_stateInfo = "waiting";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FTPTask::loop(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
if(config->ftp.active)
|
||||
if(!_beginCalled)
|
||||
{
|
||||
if(!_beginCalled)
|
||||
{
|
||||
_ftpServer->begin();
|
||||
_beginCalled = true;
|
||||
}
|
||||
_ftpServer->handle();
|
||||
static bool configWasOpen = false;
|
||||
if(configWasOpen && _ftpServer->countConnections() == 0)
|
||||
{
|
||||
logPrintlnW("Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
||||
logPrintlnW("");
|
||||
ESP.restart();
|
||||
}
|
||||
if(_ftpServer->countConnections() > 0)
|
||||
{
|
||||
configWasOpen = true;
|
||||
}
|
||||
_ftpServer->begin();
|
||||
_beginCalled = true;
|
||||
}
|
||||
_ftpServer->handle();
|
||||
static bool configWasOpen = false;
|
||||
if(configWasOpen && _ftpServer->countConnections() == 0)
|
||||
{
|
||||
logPrintlnW("Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
||||
logPrintlnW("");
|
||||
ESP.restart();
|
||||
}
|
||||
if(_ftpServer->countConnections() > 0)
|
||||
{
|
||||
configWasOpen = true;
|
||||
_stateInfo = "has connection";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ bool LoraTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Boar
|
|||
if(!_lora_aprs->begin(_lora_aprs->getRxFrequency()))
|
||||
{
|
||||
logPrintlnE("Starting LoRa failed!");
|
||||
_stateInfo = "LoRa-Modem failed";
|
||||
_state = Error;
|
||||
while(true);
|
||||
}
|
||||
_lora_aprs->setRxFrequency(config->lora.frequencyRx);
|
||||
|
|
@ -30,6 +32,7 @@ bool LoraTask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Boar
|
|||
_lora_aprs->setCodingRate4(config->lora.codingRate4);
|
||||
_lora_aprs->enableCrc();
|
||||
|
||||
_stateInfo = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +51,7 @@ bool LoraTask::loop(std::shared_ptr<Configuration> config)
|
|||
logPrintlnD(String(_lora_aprs->packetSnr()));
|
||||
std::shared_ptr<AprsIsTask> is_thread = std::static_pointer_cast<AprsIsTask>(TaskManager::instance().getTask(TASK_APRS_IS));
|
||||
is_thread->inputQueue.addElement(msg);
|
||||
Display::instance().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("LoRa", msg->toString())));
|
||||
}
|
||||
|
||||
if(!inputQueue.empty())
|
||||
|
|
|
|||
|
|
@ -32,5 +32,7 @@ bool NTPTask::loop(std::shared_ptr<Configuration> config)
|
|||
logPrintI("Current time: ");
|
||||
logPrintlnI(_ntpClient->getFormattedTime());
|
||||
}
|
||||
_stateInfo = _ntpClient->getFormattedTime();
|
||||
_state = Okay;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ bool OTATask::setup(std::shared_ptr<Configuration> config, std::shared_ptr<Board
|
|||
else if (error == OTA_END_ERROR) logPrintlnE("End Failed");
|
||||
});
|
||||
_ota->setHostname(config->callsign.c_str());
|
||||
_stateInfo = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ bool WifiTask::loop(std::shared_ptr<Configuration> config)
|
|||
{
|
||||
logPrintlnE("WiFi not connected!");
|
||||
_oldWifiStatus = wifi_status;
|
||||
_stateInfo = "WiFi not connected";
|
||||
_state = Error;
|
||||
return false;
|
||||
}
|
||||
else if(wifi_status != _oldWifiStatus)
|
||||
|
|
@ -41,6 +43,9 @@ bool WifiTask::loop(std::shared_ptr<Configuration> config)
|
|||
logPrintD("IP address: ");
|
||||
logPrintlnD(WiFi.localIP().toString());
|
||||
_oldWifiStatus = wifi_status;
|
||||
return false;
|
||||
}
|
||||
_stateInfo = WiFi.localIP().toString();
|
||||
_state = Okay;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue