mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-04-04 22:18:58 +00:00
push a lot of changes...
This commit is contained in:
parent
295feb98cc
commit
d5c015f4b9
29 changed files with 2907 additions and 391 deletions
|
|
@ -1,65 +1,37 @@
|
|||
#include <map>
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ETH.h>
|
||||
#include <WiFiMulti.h>
|
||||
#include <NTPClient.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <logger.h>
|
||||
#include <APRS-IS.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <ESP-FTP-Server-Lib.h>
|
||||
#include <FTPFilesystem.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include <TimeLib.h>
|
||||
#include "SignalSlot.h"
|
||||
#include "BoardFinder.h"
|
||||
#include "LoRa_APRS.h"
|
||||
#include "pins.h"
|
||||
#include "display.h"
|
||||
#include "project_configuration.h"
|
||||
|
||||
#ifdef NO_GLOBAL_INSTANCES
|
||||
HardwareSerial Serial(0);
|
||||
ArduinoOTAClass ArduinoOTA;
|
||||
#endif
|
||||
|
||||
#include "power_management.h"
|
||||
PowerManagement powerManagement;
|
||||
#include "project_configuration.h"
|
||||
#include "connection.h"
|
||||
|
||||
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
|
||||
hw_timer_t * timer = NULL;
|
||||
volatile uint secondsSinceLastAPRSISBeacon = 0;
|
||||
volatile uint secondsSinceStartup = 0;
|
||||
volatile uint secondsSinceDisplay = 0;
|
||||
HardwareSerial Serial(0);
|
||||
|
||||
WiFiMulti WiFiMulti;
|
||||
WiFiUDP ntpUDP;
|
||||
NTPClient * timeClient;
|
||||
FTPServer ftpServer;
|
||||
Configuration * Config;
|
||||
std::shared_ptr<ArduinoOTAClass> OTA;
|
||||
std::shared_ptr<PowerManagement> powerManagement;
|
||||
std::shared_ptr<WiFiMulti> WiFiMulti;
|
||||
std::shared_ptr<NTPClient> ntpClient;
|
||||
std::shared_ptr<FTPServer> ftpServer;
|
||||
std::shared_ptr<Configuration> userConfig;
|
||||
std::shared_ptr<BoardConfig> boardConfig;
|
||||
APRS_IS * aprs_is = 0;
|
||||
LoRa_APRS * lora_aprs;
|
||||
std::shared_ptr<APRS_IS> aprs_is;
|
||||
std::shared_ptr<LoRa_APRS> lora_aprs;
|
||||
std::shared_ptr<APRSMessage> BeaconMsg;
|
||||
|
||||
volatile bool eth_connected = false;
|
||||
|
||||
String create_lat_aprs(double lat);
|
||||
String create_long_aprs(double lng);
|
||||
|
||||
void setup_eth();
|
||||
void setup_wifi();
|
||||
std::shared_ptr<LoRa_APRS> setup_lora();
|
||||
|
||||
void load_config();
|
||||
void setup_wifi();
|
||||
void setup_ota();
|
||||
void setup_lora();
|
||||
void setup_ntp();
|
||||
void setup_aprs_is();
|
||||
void setup_timer();
|
||||
void setup_ftp();
|
||||
|
||||
std::map<uint, std::shared_ptr<APRSMessage>> lastMessages;
|
||||
PrintMessageToConsole printMessageConsole;
|
||||
bool ethEnabled = false;
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void setup()
|
||||
|
|
@ -69,22 +41,31 @@ void setup()
|
|||
delay(500);
|
||||
|
||||
ProjectConfigurationManagement confmg;
|
||||
Config = confmg.readConfiguration();
|
||||
userConfig = confmg.readConfiguration();
|
||||
|
||||
BoardFinder finder;
|
||||
boardConfig = finder.getBoardConfig(Config->board);
|
||||
std::list<std::shared_ptr<BoardConfig>> boardConfigs;
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true, true)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26)));
|
||||
boardConfigs.push_back(std::shared_ptr<BoardConfig>(new BoardConfig("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26)));
|
||||
|
||||
BoardFinder finder(boardConfigs);
|
||||
boardConfig = finder.getBoardConfig(userConfig->board);
|
||||
if(boardConfig == 0)
|
||||
{
|
||||
boardConfig = finder.searchBoardConfig();
|
||||
if(boardConfig == 0)
|
||||
{
|
||||
logPrintlnE("Board config not set and search failed!");
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
while(true)
|
||||
{}
|
||||
}
|
||||
Config->board = boardConfig->Name;
|
||||
confmg.writeConfiguration(Config);
|
||||
userConfig->board = boardConfig->Name;
|
||||
confmg.writeConfiguration(userConfig);
|
||||
logPrintlnI("will restart board now!");
|
||||
ESP.restart();
|
||||
}
|
||||
|
|
@ -96,7 +77,8 @@ void setup()
|
|||
{
|
||||
TwoWire wire(0);
|
||||
wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
||||
if (!powerManagement.begin(wire))
|
||||
std::shared_ptr<PowerManagement> powerManagement = std::shared_ptr<PowerManagement>(new PowerManagement);
|
||||
if (!powerManagement->begin(wire))
|
||||
{
|
||||
logPrintlnI("AXP192 init done!");
|
||||
}
|
||||
|
|
@ -104,9 +86,9 @@ void setup()
|
|||
{
|
||||
logPrintlnE("AXP192 init failed!");
|
||||
}
|
||||
powerManagement.activateLoRa();
|
||||
powerManagement.activateOLED();
|
||||
powerManagement.deactivateGPS();
|
||||
powerManagement->activateLoRa();
|
||||
powerManagement->activateOLED();
|
||||
powerManagement->deactivateGPS();
|
||||
}
|
||||
|
||||
logPrintlnW("LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||
|
|
@ -114,107 +96,76 @@ void setup()
|
|||
setup_display(boardConfig);
|
||||
show_display("OE5BPA", "LoRa APRS iGate", "by Peter Buchegger", "20.49.0-dev", 3000);
|
||||
|
||||
load_config();
|
||||
setup_lora();
|
||||
timeClient = new NTPClient(ntpUDP, Config->ntpServer.c_str());
|
||||
load_config(boardConfig);
|
||||
lora_aprs = setup_lora();
|
||||
if(boardConfig->Type == eETH_BOARD)
|
||||
{
|
||||
setup_eth();
|
||||
setup_ota();
|
||||
setup_ntp();
|
||||
setup_ftp();
|
||||
setup_aprs_is();
|
||||
ethEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Config->wifi.active)
|
||||
{
|
||||
setup_wifi();
|
||||
setup_ota();
|
||||
setup_ntp();
|
||||
setup_ftp();
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure wifi and bt is off if we don't need it:
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
}
|
||||
if(Config->aprs_is.active) setup_aprs_is();
|
||||
}
|
||||
setup_timer();
|
||||
WiFiMulti = setup_wifi(userConfig);
|
||||
OTA = setup_ota(userConfig);
|
||||
ntpClient = setup_ntp(userConfig);
|
||||
ftpServer = setup_ftp(userConfig);
|
||||
aprs_is = std::shared_ptr<APRS_IS>(new APRS_IS(userConfig->callsign, userConfig->aprs_is.password , "ESP32-APRS-IS", "0.1"));
|
||||
|
||||
if(Config->display.overwritePin != 0)
|
||||
if(userConfig->display.overwritePin != 0)
|
||||
{
|
||||
pinMode(Config->display.overwritePin, INPUT);
|
||||
pinMode(Config->display.overwritePin, INPUT_PULLUP);
|
||||
pinMode(userConfig->display.overwritePin, INPUT);
|
||||
pinMode(userConfig->display.overwritePin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
logPrintlnD("connect objects...");
|
||||
lora_aprs->connectSlot(&printMessageConsole);
|
||||
lora_aprs->connectSlot(aprs_is.get());
|
||||
|
||||
delay(500);
|
||||
logPrintlnI("setup done...");
|
||||
secondsSinceDisplay = 0;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void loop()
|
||||
{
|
||||
static bool display_is_on = true;
|
||||
if(Config->display.overwritePin != 0 && !digitalRead(Config->display.overwritePin))
|
||||
static bool beacon_aprs_is = true;
|
||||
if(userConfig->ftp.active)
|
||||
{
|
||||
secondsSinceDisplay = 0;
|
||||
display_is_on = true;
|
||||
setup_display(boardConfig);
|
||||
} else
|
||||
if(!Config->display.alwaysOn && secondsSinceDisplay > Config->display.timeout && display_is_on)
|
||||
{
|
||||
turn_off_display();
|
||||
display_is_on = false;
|
||||
}
|
||||
|
||||
static bool beacon_aprs_is = Config->aprs_is.active && Config->aprs_is.beacon;
|
||||
|
||||
if(Config->aprs_is.active && Config->aprs_is.beacon && secondsSinceLastAPRSISBeacon >= (Config->aprs_is.beaconTimeout*60))
|
||||
{
|
||||
portENTER_CRITICAL(&timerMux);
|
||||
secondsSinceLastAPRSISBeacon -= (Config->aprs_is.beaconTimeout*60);
|
||||
portEXIT_CRITICAL(&timerMux);
|
||||
beacon_aprs_is = true;
|
||||
}
|
||||
|
||||
if(Config->ftp.active)
|
||||
{
|
||||
ftpServer.handle();
|
||||
ftpServer->handle();
|
||||
static bool configWasOpen = false;
|
||||
if(configWasOpen && ftpServer.countConnections() == 0)
|
||||
if(configWasOpen && ftpServer->countConnections() == 0)
|
||||
{
|
||||
logPrintlnW("Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
||||
Serial.println();
|
||||
ESP.restart();
|
||||
}
|
||||
if(ftpServer.countConnections() > 0)
|
||||
if(ftpServer->countConnections() > 0)
|
||||
{
|
||||
configWasOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(Config->wifi.active || eth_connected) ArduinoOTA.handle();
|
||||
if(Config->wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
||||
const uint8_t wifi_status = WiFiMulti->run();
|
||||
if(!ethEnabled && wifi_status != WL_CONNECTED)
|
||||
{
|
||||
setup_display(boardConfig); secondsSinceDisplay = 0; display_is_on = true;
|
||||
logPrintlnE("WiFi not connected!");
|
||||
show_display("ERROR", "WiFi not connected!");
|
||||
delay(1000);
|
||||
return;
|
||||
}
|
||||
if((eth_connected && !aprs_is->connected()) || (Config->aprs_is.active && !aprs_is->connected()))
|
||||
|
||||
OTA->handle();
|
||||
if(ntpClient->update())
|
||||
{
|
||||
setTime(ntpClient->getEpochTime());
|
||||
}
|
||||
|
||||
if(!aprs_is->connected())
|
||||
{
|
||||
setup_display(boardConfig); secondsSinceDisplay = 0; display_is_on = true;
|
||||
logPrintI("connecting to APRS-IS server: ");
|
||||
logPrintI(Config->aprs_is.server);
|
||||
logPrintI(userConfig->aprs_is.server);
|
||||
logPrintI(" on port: ");
|
||||
logPrintlnI(String(Config->aprs_is.port));
|
||||
logPrintlnI(String(userConfig->aprs_is.port));
|
||||
show_display("INFO", "Connecting to APRS-IS server");
|
||||
if(!aprs_is->connect(Config->aprs_is.server, Config->aprs_is.port))
|
||||
if(!aprs_is->connect(userConfig->aprs_is.server, userConfig->aprs_is.port))
|
||||
{
|
||||
logPrintlnE("Connection failed.");
|
||||
logPrintlnI("Waiting 5 seconds before retrying...");
|
||||
|
|
@ -224,274 +175,48 @@ void loop()
|
|||
}
|
||||
logPrintlnI("Connected to APRS-IS server!");
|
||||
}
|
||||
if(Config->aprs_is.active && aprs_is->available() > 0)
|
||||
{
|
||||
String str = aprs_is->getMessage();
|
||||
logPrintD("[" + timeClient->getFormattedTime() + "] ");
|
||||
logPrintlnD(str);
|
||||
}
|
||||
if(lora_aprs->hasMessage())
|
||||
{
|
||||
std::shared_ptr<APRSMessage> msg = lora_aprs->getMessage();
|
||||
|
||||
setup_display(boardConfig); secondsSinceDisplay = 0; display_is_on = true;
|
||||
show_display(Config->callsign, timeClient->getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs->packetRssi()) + ", SNR: " + String(lora_aprs->packetSnr()), msg->toString());
|
||||
logPrintD("[" + timeClient->getFormattedTime() + "] ");
|
||||
logPrintD(" Received packet '");
|
||||
logPrintD(msg->toString());
|
||||
logPrintD("' with RSSI ");
|
||||
logPrintD(String(lora_aprs->packetRssi()));
|
||||
logPrintD(" and SNR ");
|
||||
logPrintlnD(String(lora_aprs->packetSnr()));
|
||||
|
||||
if(Config->aprs_is.active)
|
||||
{
|
||||
aprs_is->sendMessage(msg->encode());
|
||||
}
|
||||
}
|
||||
if(beacon_aprs_is)
|
||||
aprs_is->getAPRSMessage();
|
||||
lora_aprs->checkMessage();
|
||||
|
||||
if(false) //beacon_aprs_is
|
||||
{
|
||||
beacon_aprs_is = false;
|
||||
setup_display(boardConfig); secondsSinceDisplay = 0; display_is_on = true;
|
||||
show_display(Config->callsign, "Beacon to APRS-IS Server...");
|
||||
logPrintD("[" + timeClient->getFormattedTime() + "] ");
|
||||
show_display(userConfig->callsign, "Beacon to APRS-IS Server...");
|
||||
logPrintD("[" + ntpClient->getFormattedTime() + "] ");
|
||||
logPrintlnD(BeaconMsg->encode());
|
||||
aprs_is->sendMessage(BeaconMsg);
|
||||
show_display(Config->callsign, "Standby...");
|
||||
show_display(userConfig->callsign, "Standby...");
|
||||
}
|
||||
}
|
||||
|
||||
void load_config()
|
||||
std::shared_ptr<LoRa_APRS> setup_lora()
|
||||
{
|
||||
ProjectConfigurationManagement confmg;
|
||||
Config = confmg.readConfiguration();
|
||||
if(Config->callsign == "NOCALL-10")
|
||||
{
|
||||
logPrintlnE("You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||
show_display("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||
while (true)
|
||||
{}
|
||||
}
|
||||
|
||||
if(boardConfig->Type != eETH_BOARD && Config->aprs_is.active && !Config->wifi.active)
|
||||
{
|
||||
logPrintlnE("You have to activate Wifi for APRS IS to work, please check your settings!");
|
||||
show_display("ERROR", "You have to activate Wifi for APRS IS to work, please check your settings!");
|
||||
while (true)
|
||||
{}
|
||||
}
|
||||
|
||||
if(KEY_BUILTIN != 0 && Config->display.overwritePin == 0)
|
||||
{
|
||||
Config->display.overwritePin = KEY_BUILTIN;
|
||||
}
|
||||
logPrintlnI("Configuration loaded!");
|
||||
}
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case SYSTEM_EVENT_ETH_START:
|
||||
logPrintlnI("ETH Started");
|
||||
ETH.setHostname("esp32-ethernet");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||
logPrintlnI("ETH Connected");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
logPrintI("ETH MAC: ");
|
||||
logPrintI(ETH.macAddress());
|
||||
logPrintI(", IPv4: ");
|
||||
logPrintI(ETH.localIP().toString());
|
||||
if (ETH.fullDuplex()) {
|
||||
logPrintI(", FULL_DUPLEX");
|
||||
}
|
||||
logPrintI(", ");
|
||||
logPrintI(String(ETH.linkSpeed()));
|
||||
logPrintlnI("Mbps");
|
||||
eth_connected = true;
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||
logPrintlnW("ETH Disconnected");
|
||||
eth_connected = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_STOP:
|
||||
logPrintlnW("ETH Stopped");
|
||||
eth_connected = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup_eth()
|
||||
{
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
#define ETH_POWER_PIN -1
|
||||
#define ETH_TYPE ETH_PHY_LAN8720
|
||||
#define ETH_ADDR 0
|
||||
#define ETH_MDC_PIN 23
|
||||
#define ETH_MDIO_PIN 18
|
||||
#define ETH_NRST 5
|
||||
#define ETH_CLK ETH_CLOCK_GPIO17_OUT // TTGO PoE V1.0
|
||||
//#define ETH_CLK ETH_CLOCK_GPIO0_OUT // TTGO PoE V1.2
|
||||
|
||||
pinMode(ETH_NRST, OUTPUT);
|
||||
digitalWrite(ETH_NRST, 0);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 1);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 0);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 1);
|
||||
|
||||
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK);
|
||||
while(!eth_connected)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
void setup_wifi()
|
||||
{
|
||||
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
WiFi.setHostname(Config->callsign.c_str());
|
||||
for(Configuration::Wifi::AP ap : Config->wifi.APs)
|
||||
{
|
||||
logPrintD("Looking for AP: ");
|
||||
logPrintlnD(ap.SSID);
|
||||
WiFiMulti.addAP(ap.SSID.c_str(), ap.password.c_str());
|
||||
}
|
||||
logPrintlnI("Waiting for WiFi");
|
||||
show_display("INFO", "Waiting for WiFi");
|
||||
while(WiFiMulti.run() != WL_CONNECTED)
|
||||
{
|
||||
show_display("INFO", "Waiting for WiFi", "....");
|
||||
delay(500);
|
||||
}
|
||||
logPrintlnI("WiFi connected");
|
||||
logPrintD("IP address: ");
|
||||
logPrintlnD(WiFi.localIP().toString());
|
||||
show_display("INFO", "WiFi connected", "IP: ", WiFi.localIP().toString(), 2000);
|
||||
}
|
||||
|
||||
void setup_ota()
|
||||
{
|
||||
ArduinoOTA
|
||||
.onStart([]()
|
||||
{
|
||||
String type;
|
||||
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||
type = "sketch";
|
||||
else // U_SPIFFS
|
||||
type = "filesystem";
|
||||
Serial.println("Start updating " + type);
|
||||
show_display("OTA UPDATE", "Start update", type);
|
||||
})
|
||||
.onEnd([]()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.println("End");
|
||||
})
|
||||
.onProgress([](unsigned int progress, unsigned int total)
|
||||
{
|
||||
Serial.print("Progress: ");
|
||||
Serial.print(progress / (total / 100));
|
||||
Serial.println("%");
|
||||
show_display("OTA UPDATE", "Progress: ", String(progress / (total / 100)) + "%");
|
||||
})
|
||||
.onError([](ota_error_t error) {
|
||||
Serial.print("Error[");
|
||||
Serial.print(error);
|
||||
Serial.print("]: ");
|
||||
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
|
||||
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
|
||||
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
|
||||
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
|
||||
else if (error == OTA_END_ERROR) Serial.println("End Failed");
|
||||
});
|
||||
ArduinoOTA.setHostname(Config->callsign.c_str());
|
||||
ArduinoOTA.begin();
|
||||
logPrintlnI("OTA init done!");
|
||||
}
|
||||
|
||||
void setup_lora()
|
||||
{
|
||||
lora_aprs = new LoRa_APRS(boardConfig);
|
||||
if (!lora_aprs->begin(lora_aprs->getRxFrequency()))
|
||||
std::shared_ptr<LoRa_APRS> lora_aprs = std::shared_ptr<LoRa_APRS>(new LoRa_APRS(boardConfig));
|
||||
if(!lora_aprs->begin(lora_aprs->getRxFrequency()))
|
||||
{
|
||||
logPrintlnE("Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (1);
|
||||
while(true);
|
||||
}
|
||||
lora_aprs->setRxFrequency(Config->lora.frequencyRx);
|
||||
lora_aprs->setTxFrequency(Config->lora.frequencyTx);
|
||||
lora_aprs->setTxPower(Config->lora.power);
|
||||
lora_aprs->setSpreadingFactor(Config->lora.spreadingFactor);
|
||||
lora_aprs->setSignalBandwidth(Config->lora.signalBandwidth);
|
||||
lora_aprs->setCodingRate4(Config->lora.codingRate4);
|
||||
lora_aprs->setRxFrequency(userConfig->lora.frequencyRx);
|
||||
lora_aprs->setTxFrequency(userConfig->lora.frequencyTx);
|
||||
lora_aprs->setTxPower(userConfig->lora.power);
|
||||
lora_aprs->setSpreadingFactor(userConfig->lora.spreadingFactor);
|
||||
lora_aprs->setSignalBandwidth(userConfig->lora.signalBandwidth);
|
||||
lora_aprs->setCodingRate4(userConfig->lora.codingRate4);
|
||||
lora_aprs->enableCrc();
|
||||
logPrintlnI("LoRa init done!");
|
||||
show_display("INFO", "LoRa init done!", 2000);
|
||||
|
||||
BeaconMsg = std::shared_ptr<APRSMessage>(new APRSMessage());
|
||||
BeaconMsg->setSource(Config->callsign);
|
||||
BeaconMsg->setSource(userConfig->callsign);
|
||||
BeaconMsg->setDestination("APLG0");
|
||||
String lat = create_lat_aprs(Config->beacon.positionLatitude);
|
||||
String lng = create_long_aprs(Config->beacon.positionLongitude);
|
||||
BeaconMsg->getAPRSBody()->setData(String("=") + lat + "I" + lng + "&" + Config->beacon.message);
|
||||
}
|
||||
String lat = create_lat_aprs(userConfig->beacon.positionLatitude);
|
||||
String lng = create_long_aprs(userConfig->beacon.positionLongitude);
|
||||
BeaconMsg->getAPRSBody()->setData(String("=") + lat + "I" + lng + "&" + userConfig->beacon.message);
|
||||
|
||||
void setup_ntp()
|
||||
{
|
||||
timeClient->begin();
|
||||
while(!timeClient->forceUpdate())
|
||||
{
|
||||
logPrintlnW("NTP Client force update issue! Waiting 1 sek...");
|
||||
show_display("WARN", "NTP Client force update issue! Waiting 1 sek...", 1000);
|
||||
}
|
||||
logPrintlnI("NTP Client init done!");
|
||||
show_display("INFO", "NTP Client init done!", 2000);
|
||||
}
|
||||
|
||||
void setup_aprs_is()
|
||||
{
|
||||
aprs_is = new APRS_IS(Config->callsign, Config->aprs_is.password , "ESP32-APRS-IS", "0.1");
|
||||
}
|
||||
|
||||
void IRAM_ATTR onTimer()
|
||||
{
|
||||
portENTER_CRITICAL_ISR(&timerMux);
|
||||
secondsSinceLastAPRSISBeacon++;
|
||||
secondsSinceStartup++;
|
||||
secondsSinceDisplay++;
|
||||
portEXIT_CRITICAL_ISR(&timerMux);
|
||||
}
|
||||
|
||||
void setup_timer()
|
||||
{
|
||||
timer = timerBegin(0, 80, true);
|
||||
timerAlarmWrite(timer, 1000000, true);
|
||||
timerAttachInterrupt(timer, &onTimer, true);
|
||||
timerAlarmEnable(timer);
|
||||
}
|
||||
|
||||
void setup_ftp()
|
||||
{
|
||||
if(!Config->ftp.active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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);
|
||||
ftpServer.begin();
|
||||
logPrintlnI("FTP Server init done!");
|
||||
return lora_aprs;
|
||||
}
|
||||
|
||||
String create_lat_aprs(double lat)
|
||||
|
|
|
|||
183
src/connection.cpp
Normal file
183
src/connection.cpp
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
#include <ETH.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <logger.h>
|
||||
#include <TimeLib.h>
|
||||
|
||||
#include "connection.h"
|
||||
|
||||
volatile bool eth_connected = false;
|
||||
|
||||
static void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case SYSTEM_EVENT_ETH_START:
|
||||
logPrintlnI("ETH Started");
|
||||
ETH.setHostname("esp32-ethernet");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||
logPrintlnI("ETH Connected");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
logPrintI("ETH MAC: ");
|
||||
logPrintI(ETH.macAddress());
|
||||
logPrintI(", IPv4: ");
|
||||
logPrintI(ETH.localIP().toString());
|
||||
if (ETH.fullDuplex()) {
|
||||
logPrintI(", FULL_DUPLEX");
|
||||
}
|
||||
logPrintI(", ");
|
||||
logPrintI(String(ETH.linkSpeed()));
|
||||
logPrintlnI("Mbps");
|
||||
eth_connected = true;
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||
logPrintlnW("ETH Disconnected");
|
||||
eth_connected = false;
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_STOP:
|
||||
logPrintlnW("ETH Stopped");
|
||||
eth_connected = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool isEthConnected()
|
||||
{
|
||||
return eth_connected;
|
||||
}
|
||||
|
||||
void setup_eth()
|
||||
{
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
#define ETH_POWER_PIN -1
|
||||
#define ETH_TYPE ETH_PHY_LAN8720
|
||||
#define ETH_ADDR 0
|
||||
#define ETH_MDC_PIN 23
|
||||
#define ETH_MDIO_PIN 18
|
||||
#define ETH_NRST 5
|
||||
#define ETH_CLK ETH_CLOCK_GPIO17_OUT // TTGO PoE V1.0
|
||||
//#define ETH_CLK ETH_CLOCK_GPIO0_OUT // TTGO PoE V1.2
|
||||
|
||||
pinMode(ETH_NRST, OUTPUT);
|
||||
digitalWrite(ETH_NRST, 0);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 1);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 0);
|
||||
delay(200);
|
||||
digitalWrite(ETH_NRST, 1);
|
||||
|
||||
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK);
|
||||
while(!eth_connected)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<WiFiMulti> setup_wifi(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
//WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||
WiFi.setHostname(config->callsign.c_str());
|
||||
std::shared_ptr<WiFiMulti> wiFiMulti = std::shared_ptr<WiFiMulti>(new WiFiMulti());;
|
||||
for(Configuration::Wifi::AP ap : config->wifi.APs)
|
||||
{
|
||||
logPrintD("Looking for AP: ");
|
||||
logPrintlnD(ap.SSID);
|
||||
wiFiMulti->addAP(ap.SSID.c_str(), ap.password.c_str());
|
||||
}
|
||||
logPrintlnI("Waiting for WiFi");
|
||||
//show_display("INFO", "Waiting for WiFi");
|
||||
while(wiFiMulti->run() != WL_CONNECTED)
|
||||
{
|
||||
//show_display("INFO", "Waiting for WiFi", "....");
|
||||
delay(500);
|
||||
}
|
||||
logPrintlnI("WiFi connected");
|
||||
logPrintD("IP address: ");
|
||||
logPrintlnD(WiFi.localIP().toString());
|
||||
//show_display("INFO", "WiFi connected", "IP: ", WiFi.localIP().toString(), 2000);
|
||||
return wiFiMulti;
|
||||
}
|
||||
|
||||
std::shared_ptr<ArduinoOTAClass> setup_ota(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
std::shared_ptr<ArduinoOTAClass> ota = std::shared_ptr<ArduinoOTAClass>(new ArduinoOTAClass());
|
||||
ota->onStart([&]()
|
||||
{
|
||||
String type;
|
||||
if (ota->getCommand() == U_FLASH)
|
||||
type = "sketch";
|
||||
else // U_SPIFFS
|
||||
type = "filesystem";
|
||||
logPrintlnI("Start updating " + type);
|
||||
//show_display("OTA UPDATE", "Start update", type);
|
||||
})
|
||||
.onEnd([]()
|
||||
{
|
||||
logPrintlnI("");
|
||||
logPrintlnI("OTA End");
|
||||
})
|
||||
.onProgress([](unsigned int progress, unsigned int total)
|
||||
{
|
||||
logPrintI("Progress: ");
|
||||
logPrintI(String(progress / (total / 100)));
|
||||
logPrintlnI("%");
|
||||
//show_display("OTA UPDATE", "Progress: ", String(progress / (total / 100)) + "%");
|
||||
})
|
||||
.onError([](ota_error_t error)
|
||||
{
|
||||
logPrintE("Error[");
|
||||
logPrintE(String(error));
|
||||
logPrintE("]: ");
|
||||
if (error == OTA_AUTH_ERROR) logPrintlnE("Auth Failed");
|
||||
else if (error == OTA_BEGIN_ERROR) logPrintlnE("Begin Failed");
|
||||
else if (error == OTA_CONNECT_ERROR) logPrintlnE("Connect Failed");
|
||||
else if (error == OTA_RECEIVE_ERROR) logPrintlnE("Receive Failed");
|
||||
else if (error == OTA_END_ERROR) logPrintlnE("End Failed");
|
||||
});
|
||||
ota->setHostname(config->callsign.c_str());
|
||||
ota->begin();
|
||||
logPrintlnI("OTA init done!");
|
||||
return ota;
|
||||
}
|
||||
|
||||
std::shared_ptr<NTPClient> setup_ntp(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
std::shared_ptr<NTPClient> ntpClient = std::shared_ptr<NTPClient>(new NTPClient(config->ntpServer.c_str()));
|
||||
ntpClient->begin();
|
||||
while(!ntpClient->forceUpdate())
|
||||
{
|
||||
logPrintlnW("NTP Client force update issue! Waiting 1 sek...");
|
||||
logPrintlnD(ntpClient->getFormattedTime());
|
||||
//show_display("WARN", "NTP Client force update issue! Waiting 1 sek...", 1000);
|
||||
sleep(1);
|
||||
}
|
||||
setTime(ntpClient->getEpochTime());
|
||||
logPrintlnI("NTP Client init done!");
|
||||
//show_display("INFO", "NTP Client init done!", 2000);
|
||||
return ntpClient;
|
||||
}
|
||||
|
||||
std::shared_ptr<FTPServer> setup_ftp(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
std::shared_ptr<FTPServer> ftpServer = std::shared_ptr<FTPServer>(new FTPServer());
|
||||
if(config->ftp.active)
|
||||
{
|
||||
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);
|
||||
ftpServer->begin();
|
||||
logPrintlnI("FTP Server init done!");
|
||||
}
|
||||
return ftpServer;
|
||||
}
|
||||
19
src/connection.h
Normal file
19
src/connection.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
#ifndef CONNECTION_H_
|
||||
#define CONNECTION_H_
|
||||
|
||||
#include <ArduinoOTA.h>
|
||||
#include <WiFiMulti.h>
|
||||
#include <ESP-FTP-Server-Lib.h>
|
||||
#include <FTPFilesystem.h>
|
||||
#include <NTPClient.h>
|
||||
#include "project_configuration.h"
|
||||
|
||||
bool isEthConnected();
|
||||
void setup_eth();
|
||||
std::shared_ptr<WiFiMulti> setup_wifi(std::shared_ptr<Configuration> config);
|
||||
std::shared_ptr<ArduinoOTAClass> setup_ota(std::shared_ptr<Configuration> config);
|
||||
std::shared_ptr<NTPClient> setup_ntp(std::shared_ptr<Configuration> config);
|
||||
std::shared_ptr<FTPServer> setup_ftp(std::shared_ptr<Configuration> config);
|
||||
|
||||
#endif
|
||||
142
src/display.cpp
Normal file
142
src/display.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#include "BoardFinder.h"
|
||||
#include "display.h"
|
||||
#include "logger.h"
|
||||
|
||||
Adafruit_SSD1306 * display = 0;
|
||||
TwoWire * wire = 0;
|
||||
|
||||
void setup_display(std::shared_ptr<BoardConfig> boardConfig)
|
||||
{
|
||||
if(display == 0)
|
||||
{
|
||||
wire = new TwoWire(0);
|
||||
wire->begin(boardConfig->OledSda, boardConfig->OledScl);
|
||||
if(boardConfig->OledReset > 0)
|
||||
{
|
||||
display = new Adafruit_SSD1306(128, 64, wire, boardConfig->OledReset);
|
||||
logPrintlnI("with reset");
|
||||
}
|
||||
else
|
||||
{
|
||||
display = new Adafruit_SSD1306(128, 64, wire);
|
||||
logPrintlnI("with NO reset");
|
||||
}
|
||||
}
|
||||
if(!display->begin(SSD1306_SWITCHCAPVCC, boardConfig->OledAddr, false, false))
|
||||
{
|
||||
logPrintlnE("SSD1306 allocation failed");
|
||||
while (1);
|
||||
}
|
||||
logPrintlnI("Display init done!");
|
||||
}
|
||||
|
||||
void turn_off_display()
|
||||
{
|
||||
display->ssd1306_command(SSD1306_DISPLAYOFF);
|
||||
}
|
||||
|
||||
void show_display(String header, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->setTextSize(1);
|
||||
display->setCursor(0,16);
|
||||
display->println(line1);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->setTextSize(1);
|
||||
display->setCursor(0,16);
|
||||
display->println(line1);
|
||||
display->setCursor(0,26);
|
||||
display->println(line2);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->setTextSize(1);
|
||||
display->setCursor(0,16);
|
||||
display->println(line1);
|
||||
display->setCursor(0,26);
|
||||
display->println(line2);
|
||||
display->setCursor(0,36);
|
||||
display->println(line3);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->setTextSize(1);
|
||||
display->setCursor(0,16);
|
||||
display->println(line1);
|
||||
display->setCursor(0,26);
|
||||
display->println(line2);
|
||||
display->setCursor(0,36);
|
||||
display->println(line3);
|
||||
display->setCursor(0,46);
|
||||
display->println(line4);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait)
|
||||
{
|
||||
display->clearDisplay();
|
||||
display->setTextColor(WHITE);
|
||||
display->setTextSize(2);
|
||||
display->setCursor(0,0);
|
||||
display->println(header);
|
||||
display->setTextSize(1);
|
||||
display->setCursor(0,16);
|
||||
display->println(line1);
|
||||
display->setCursor(0,26);
|
||||
display->println(line2);
|
||||
display->setCursor(0,36);
|
||||
display->println(line3);
|
||||
display->setCursor(0,46);
|
||||
display->println(line4);
|
||||
display->setCursor(0,56);
|
||||
display->println(line5);
|
||||
display->display();
|
||||
delay(wait);
|
||||
}
|
||||
47
src/display.h
Normal file
47
src/display.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
#ifndef DISPLAY_H_
|
||||
#define DISPLAY_H_
|
||||
|
||||
void setup_display(std::shared_ptr<BoardConfig> boardConfig);
|
||||
void turn_off_display();
|
||||
|
||||
void show_display(String header, int wait = 0);
|
||||
void show_display(String header, String line1, int wait = 0);
|
||||
void show_display(String header, String line1, String line2, int wait = 0);
|
||||
void show_display(String header, String line1, String line2, String line3, int wait = 0);
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, int wait = 0);
|
||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait = 0);
|
||||
|
||||
#include <APRSMessage.h>
|
||||
#include "SignalSlot.h"
|
||||
#include "TimeLib.h"
|
||||
#include "logger.h"
|
||||
|
||||
class PrintMessageToConsole : public Slot1<std::shared_ptr<APRSMessage>>, public Slot3<std::shared_ptr<APRSMessage>, int, float>
|
||||
{
|
||||
public:
|
||||
void action(std::shared_ptr<APRSMessage> msg, int rssi, float snr) override
|
||||
{
|
||||
//setup_display(boardConfig); secondsSinceDisplay = 0; //display_is_on = true;
|
||||
//show_display(Config->callsign, timeClient->getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs->packetRssi()) + ", SNR: " + String(lora_aprs->packetSnr()), elem->toString());
|
||||
logPrintD("[" + timeString() + "] ");
|
||||
logPrintD("Received packet '");
|
||||
logPrintD(msg->toString());
|
||||
logPrintD("' with RSSI ");
|
||||
logPrintD(String(rssi));
|
||||
logPrintD(" and SNR ");
|
||||
logPrintlnD(String(snr));
|
||||
}
|
||||
|
||||
void action(std::shared_ptr<APRSMessage> msg) override
|
||||
{
|
||||
//setup_display(boardConfig); secondsSinceDisplay = 0; //display_is_on = true;
|
||||
//show_display(Config->callsign, timeClient->getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs->packetRssi()) + ", SNR: " + String(lora_aprs->packetSnr()), elem->toString());
|
||||
logPrintD("[" + timeString() + "] ");
|
||||
logPrintD("Received packet '");
|
||||
logPrintD(msg->toString());
|
||||
logPrintD("'");
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -3,13 +3,12 @@
|
|||
#include "project_configuration.h"
|
||||
#include "logger.h"
|
||||
|
||||
Configuration * ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocument & data)
|
||||
std::shared_ptr<Configuration> ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocument & data)
|
||||
{
|
||||
Configuration * conf = new Configuration;
|
||||
std::shared_ptr<Configuration> conf = std::shared_ptr<Configuration>(new Configuration);
|
||||
if(data.containsKey("callsign"))
|
||||
conf->callsign = data["callsign"].as<String>();
|
||||
|
||||
conf->wifi.active = data["wifi"]["active"] | false;
|
||||
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
||||
for(JsonVariant v : aps)
|
||||
{
|
||||
|
|
@ -22,7 +21,6 @@ Configuration * ProjectConfigurationManagement::readProjectConfiguration(Dynamic
|
|||
conf->beacon.message = data["beacon"]["message"].as<String>();
|
||||
conf->beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
||||
conf->beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0;
|
||||
conf->aprs_is.active = data["aprs_is"]["active"] | false;
|
||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("password"))
|
||||
conf->aprs_is.password = data["aprs_is"]["password"].as<String>();
|
||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("server"))
|
||||
|
|
@ -66,10 +64,9 @@ Configuration * ProjectConfigurationManagement::readProjectConfiguration(Dynamic
|
|||
return conf;
|
||||
}
|
||||
|
||||
void ProjectConfigurationManagement::writeProjectConfiguration(Configuration * conf, DynamicJsonDocument & data)
|
||||
void ProjectConfigurationManagement::writeProjectConfiguration(std::shared_ptr<Configuration> conf, DynamicJsonDocument & data)
|
||||
{
|
||||
data["callsign"] = conf->callsign;
|
||||
data["wifi"]["active"] = conf->wifi.active;
|
||||
JsonArray aps = data["wifi"].createNestedArray("AP");
|
||||
for(Configuration::Wifi::AP ap : conf->wifi.APs)
|
||||
{
|
||||
|
|
@ -80,7 +77,6 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration * c
|
|||
data["beacon"]["message"] = conf->beacon.message;
|
||||
data["beacon"]["position"]["latitude"] = conf->beacon.positionLatitude;
|
||||
data["beacon"]["position"]["longitude"] = conf->beacon.positionLongitude;
|
||||
data["aprs_is"]["active"] = conf->aprs_is.active;
|
||||
data["aprs_is"]["password"] = conf->aprs_is.password;
|
||||
data["aprs_is"]["server"] = conf->aprs_is.server;
|
||||
data["aprs_is"]["port"] = conf->aprs_is.port;
|
||||
|
|
@ -107,3 +103,23 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration * c
|
|||
|
||||
data["board"] = conf->board;
|
||||
}
|
||||
|
||||
std::shared_ptr<Configuration> load_config(std::shared_ptr<BoardConfig> boardConfig)
|
||||
{
|
||||
ProjectConfigurationManagement confmg;
|
||||
std::shared_ptr<Configuration> config = confmg.readConfiguration();
|
||||
if(config->callsign == "NOCALL-10")
|
||||
{
|
||||
logPrintlnE("You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||
//show_display("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||
while (true)
|
||||
{}
|
||||
}
|
||||
|
||||
/*if(KEY_BUILTIN != 0 && Config->display.overwritePin == 0)
|
||||
{
|
||||
Config->display.overwritePin = KEY_BUILTIN;
|
||||
}*/
|
||||
logPrintlnI("Configuration loaded!");
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define PROJECT_CONFIGURATION_H_
|
||||
|
||||
#include "configuration.h"
|
||||
#include "BoardFinder.h"
|
||||
|
||||
class Configuration
|
||||
{
|
||||
|
|
@ -16,9 +17,8 @@ public:
|
|||
String password;
|
||||
};
|
||||
|
||||
Wifi() : active(false) {}
|
||||
Wifi() {}
|
||||
|
||||
bool active;
|
||||
std::list<AP> APs;
|
||||
};
|
||||
|
||||
|
|
@ -35,9 +35,8 @@ public:
|
|||
class APRS_IS
|
||||
{
|
||||
public:
|
||||
APRS_IS() : active(false), server("euro.aprs2.net"), port(14580), beacon(true), beaconTimeout(15) {}
|
||||
APRS_IS() : server("euro.aprs2.net"), port(14580), beacon(true), beaconTimeout(15) {}
|
||||
|
||||
bool active;
|
||||
String password;
|
||||
String server;
|
||||
int port;
|
||||
|
|
@ -104,8 +103,10 @@ public:
|
|||
virtual ~ProjectConfigurationManagement() {}
|
||||
|
||||
private:
|
||||
virtual Configuration * readProjectConfiguration(DynamicJsonDocument & data) override;
|
||||
virtual void writeProjectConfiguration(Configuration * conf, DynamicJsonDocument & data) override;
|
||||
virtual std::shared_ptr<Configuration> readProjectConfiguration(DynamicJsonDocument & data) override;
|
||||
virtual void writeProjectConfiguration(std::shared_ptr<Configuration> conf, DynamicJsonDocument & data) override;
|
||||
};
|
||||
|
||||
std::shared_ptr<Configuration> load_config(std::shared_ptr<BoardConfig> boardConfig);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue