mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
commit
21da478f2c
|
|
@ -47,5 +47,12 @@
|
||||||
"always_on": true,
|
"always_on": true,
|
||||||
"timeout":10,
|
"timeout":10,
|
||||||
"overwrite_pin":0
|
"overwrite_pin":0
|
||||||
|
},
|
||||||
|
"ftp":
|
||||||
|
{
|
||||||
|
"active":false,
|
||||||
|
"user": [
|
||||||
|
{ "name":"ftp", "password":"ftp" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ lib_deps =
|
||||||
sandeepmistry/LoRa @ 0.7.2
|
sandeepmistry/LoRa @ 0.7.2
|
||||||
peterus/APRS-Decoder-Lib @ 0.0.5
|
peterus/APRS-Decoder-Lib @ 0.0.5
|
||||||
peterus/APRS-IS-Lib @ 0.0.7
|
peterus/APRS-IS-Lib @ 0.0.7
|
||||||
|
https://github.com/peterus/ESP-FTP-Server-Lib @ 0.9.3
|
||||||
peterus/LoRa-APRS-Lib @ 0.0.5
|
peterus/LoRa-APRS-Lib @ 0.0.5
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_flags =
|
check_flags =
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <APRS-IS.h>
|
#include <APRS-IS.h>
|
||||||
|
#include <SPIFFS.h>
|
||||||
|
#include <ESP-FTP-Server-Lib.h>
|
||||||
|
#include <FTPFilesystem.h>
|
||||||
|
|
||||||
#include "LoRa_APRS.h"
|
#include "LoRa_APRS.h"
|
||||||
|
|
||||||
|
|
@ -28,6 +31,7 @@ volatile uint secondsSinceDisplay = 0;
|
||||||
WiFiMulti WiFiMulti;
|
WiFiMulti WiFiMulti;
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, 60*60);
|
NTPClient timeClient(ntpUDP, 60*60);
|
||||||
|
FTPServer ftpServer;
|
||||||
Configuration Config;
|
Configuration Config;
|
||||||
APRS_IS * aprs_is = 0;
|
APRS_IS * aprs_is = 0;
|
||||||
LoRa_APRS lora_aprs;
|
LoRa_APRS lora_aprs;
|
||||||
|
|
@ -43,6 +47,7 @@ void setup_lora();
|
||||||
void setup_ntp();
|
void setup_ntp();
|
||||||
void setup_aprs_is();
|
void setup_aprs_is();
|
||||||
void setup_timer();
|
void setup_timer();
|
||||||
|
void setup_ftp();
|
||||||
|
|
||||||
std::map<uint, std::shared_ptr<APRSMessage>> lastMessages;
|
std::map<uint, std::shared_ptr<APRSMessage>> lastMessages;
|
||||||
|
|
||||||
|
|
@ -77,6 +82,7 @@ void setup()
|
||||||
setup_wifi();
|
setup_wifi();
|
||||||
setup_ota();
|
setup_ota();
|
||||||
setup_ntp();
|
setup_ntp();
|
||||||
|
setup_ftp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -133,6 +139,22 @@ void loop()
|
||||||
beacon_digi = true;
|
beacon_digi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Config.ftp.active)
|
||||||
|
{
|
||||||
|
ftpServer.handle();
|
||||||
|
static bool configWasOpen = false;
|
||||||
|
if(configWasOpen && ftpServer.countConnections() == 0)
|
||||||
|
{
|
||||||
|
Serial.println("[WARN] Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
||||||
|
Serial.println();
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
if(ftpServer.countConnections() > 0)
|
||||||
|
{
|
||||||
|
configWasOpen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(Config.wifi.active) ArduinoOTA.handle();
|
if(Config.wifi.active) ArduinoOTA.handle();
|
||||||
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
|
|
@ -424,6 +446,23 @@ void setup_timer()
|
||||||
timerAlarmEnable(timer);
|
timerAlarmEnable(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setup_ftp()
|
||||||
|
{
|
||||||
|
if(!Config.ftp.active)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(Configuration::Ftp::User user : Config.ftp.users)
|
||||||
|
{
|
||||||
|
Serial.print("[INFO] Adding user to FTP Server: ");
|
||||||
|
Serial.println(user.name);
|
||||||
|
ftpServer.addUser(user.name, user.password);
|
||||||
|
}
|
||||||
|
ftpServer.addFilesystem("SPIFFS", &SPIFFS);
|
||||||
|
ftpServer.begin();
|
||||||
|
Serial.println("[INFO] FTP Server init done!");
|
||||||
|
}
|
||||||
|
|
||||||
String create_lat_aprs(double lat)
|
String create_lat_aprs(double lat)
|
||||||
{
|
{
|
||||||
char str[20];
|
char str[20];
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@ Configuration ConfigurationManagement::readConfiguration()
|
||||||
Serial.println("Failed to open file for reading...");
|
Serial.println("Failed to open file for reading...");
|
||||||
return Configuration();
|
return Configuration();
|
||||||
}
|
}
|
||||||
DynamicJsonDocument data(1024);
|
DynamicJsonDocument data(2048);
|
||||||
deserializeJson(data, file);
|
deserializeJson(data, file);
|
||||||
|
//serializeJson(data, Serial);
|
||||||
|
//Serial.println();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
Configuration conf;
|
Configuration conf;
|
||||||
|
|
@ -75,6 +77,18 @@ Configuration ConfigurationManagement::readConfiguration()
|
||||||
conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"];
|
conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"];
|
||||||
conf.lora.codingRate4 = data["lora"]["coding_rate4"];
|
conf.lora.codingRate4 = data["lora"]["coding_rate4"];
|
||||||
}
|
}
|
||||||
|
if(data["version"] >= 4)
|
||||||
|
{
|
||||||
|
conf.ftp.active = data["ftp"]["active"];
|
||||||
|
JsonArray users = data["ftp"]["user"].as<JsonArray>();
|
||||||
|
for(JsonVariant u : users)
|
||||||
|
{
|
||||||
|
Configuration::Ftp::User us;
|
||||||
|
us.name = u["name"].as<String>();
|
||||||
|
us.password = u["password"].as<String>();
|
||||||
|
conf.ftp.users.push_back(us);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update config in memory to get the new fields:
|
// update config in memory to get the new fields:
|
||||||
writeConfiguration(conf);
|
writeConfiguration(conf);
|
||||||
|
|
@ -90,7 +104,7 @@ void ConfigurationManagement::writeConfiguration(Configuration conf)
|
||||||
Serial.println("Failed to open file for writing...");
|
Serial.println("Failed to open file for writing...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DynamicJsonDocument data(1024);
|
DynamicJsonDocument data(2048);
|
||||||
|
|
||||||
data["version"] = conf.version;
|
data["version"] = conf.version;
|
||||||
data["callsign"] = conf.callsign;
|
data["callsign"] = conf.callsign;
|
||||||
|
|
@ -124,6 +138,14 @@ void ConfigurationManagement::writeConfiguration(Configuration conf)
|
||||||
data["display"]["always_on"] = conf.display.alwaysOn;
|
data["display"]["always_on"] = conf.display.alwaysOn;
|
||||||
data["display"]["timeout"] = conf.display.timeout;
|
data["display"]["timeout"] = conf.display.timeout;
|
||||||
data["display"]["overwrite_pin"] = conf.display.overwritePin;
|
data["display"]["overwrite_pin"] = conf.display.overwritePin;
|
||||||
|
data["ftp"]["active"] = conf.ftp.active;
|
||||||
|
JsonArray users = data["ftp"].createNestedArray("user");
|
||||||
|
for(Configuration::Ftp::User u : conf.ftp.users)
|
||||||
|
{
|
||||||
|
JsonObject v = users.createNestedObject();
|
||||||
|
v["name"] = u.name;
|
||||||
|
v["password"] = u.password;
|
||||||
|
}
|
||||||
|
|
||||||
serializeJson(data, file);
|
serializeJson(data, file);
|
||||||
//serializeJson(data, Serial);
|
//serializeJson(data, Serial);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,23 @@ public:
|
||||||
int overwritePin;
|
int overwritePin;
|
||||||
};
|
};
|
||||||
|
|
||||||
Configuration() : version(3), callsign("NOCALL-10") {};
|
class Ftp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
String name;
|
||||||
|
String password;
|
||||||
|
};
|
||||||
|
|
||||||
|
Ftp() : active(false) {}
|
||||||
|
|
||||||
|
bool active;
|
||||||
|
std::list<User> users;
|
||||||
|
};
|
||||||
|
|
||||||
|
Configuration() : version(4), callsign("NOCALL-10") {};
|
||||||
|
|
||||||
int version;
|
int version;
|
||||||
String callsign;
|
String callsign;
|
||||||
|
|
@ -92,6 +108,7 @@ public:
|
||||||
Digi digi;
|
Digi digi;
|
||||||
LoRa lora;
|
LoRa lora;
|
||||||
Display display;
|
Display display;
|
||||||
|
Ftp ftp;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigurationManagement
|
class ConfigurationManagement
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue