kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
update
rodzic
d5c015f4b9
commit
47a4455145
|
@ -13,15 +13,14 @@
|
|||
{
|
||||
"latitude":0.000000,
|
||||
"longitude":0.000000
|
||||
}
|
||||
},
|
||||
"timeout":15
|
||||
},
|
||||
"aprs_is":
|
||||
{
|
||||
"password":"",
|
||||
"passcode":"",
|
||||
"server":"euro.aprs2.net",
|
||||
"port":14580,
|
||||
"beacon":true,
|
||||
"beacon_timeout":15
|
||||
"port":14580
|
||||
},
|
||||
"lora":
|
||||
{
|
||||
|
|
|
@ -24,8 +24,21 @@ bool APRS_IS::connect_(const String & server, const int port, const String & log
|
|||
return false;
|
||||
}
|
||||
sendMessage(login_line);
|
||||
// TODO: implement check if auth was successfull!
|
||||
//while(!available());
|
||||
while(true)
|
||||
{
|
||||
String line = _client.readStringUntil('\n');
|
||||
if(line.indexOf("logresp") != -1)
|
||||
{
|
||||
if(line.indexOf("unverified") == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -81,7 +94,12 @@ std::shared_ptr<APRSMessage> APRS_IS::getAPRSMessage()
|
|||
{
|
||||
line = _client.readStringUntil('\n');
|
||||
}
|
||||
if(line.length() == 0 || line.startsWith("#"))
|
||||
if(line.startsWith("#"))
|
||||
{
|
||||
//logPrintlnD(line);
|
||||
return 0;
|
||||
}
|
||||
if(line.length() == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ void setup()
|
|||
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"));
|
||||
aprs_is = setup_aprs_is(userConfig);
|
||||
|
||||
if(userConfig->display.overwritePin != 0)
|
||||
{
|
||||
|
@ -126,7 +126,6 @@ void setup()
|
|||
// cppcheck-suppress unusedFunction
|
||||
void loop()
|
||||
{
|
||||
static bool beacon_aprs_is = true;
|
||||
if(userConfig->ftp.active)
|
||||
{
|
||||
ftpServer->handle();
|
||||
|
@ -160,10 +159,7 @@ void loop()
|
|||
|
||||
if(!aprs_is->connected())
|
||||
{
|
||||
logPrintI("connecting to APRS-IS server: ");
|
||||
logPrintI(userConfig->aprs_is.server);
|
||||
logPrintI(" on port: ");
|
||||
logPrintlnI(String(userConfig->aprs_is.port));
|
||||
logPrintI("connecting to APRS-IS server...");
|
||||
show_display("INFO", "Connecting to APRS-IS server");
|
||||
if(!aprs_is->connect(userConfig->aprs_is.server, userConfig->aprs_is.port))
|
||||
{
|
||||
|
@ -179,14 +175,15 @@ void loop()
|
|||
aprs_is->getAPRSMessage();
|
||||
lora_aprs->checkMessage();
|
||||
|
||||
if(false) //beacon_aprs_is
|
||||
static time_t beacon_next_time = 0;
|
||||
if(beacon_next_time < now())
|
||||
{
|
||||
beacon_aprs_is = false;
|
||||
show_display(userConfig->callsign, "Beacon to APRS-IS Server...");
|
||||
logPrintD("[" + ntpClient->getFormattedTime() + "] ");
|
||||
logPrintlnD(BeaconMsg->encode());
|
||||
aprs_is->sendMessage(BeaconMsg);
|
||||
show_display(userConfig->callsign, "Standby...");
|
||||
beacon_next_time = now() + userConfig->beacon.timeout * 60UL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <SPIFFS.h>
|
||||
#include <logger.h>
|
||||
#include <TimeLib.h>
|
||||
#include <APRS-IS.h>
|
||||
|
||||
#include "connection.h"
|
||||
|
||||
|
@ -181,3 +182,22 @@ std::shared_ptr<FTPServer> setup_ftp(std::shared_ptr<Configuration> config)
|
|||
}
|
||||
return ftpServer;
|
||||
}
|
||||
|
||||
std::shared_ptr<APRS_IS> setup_aprs_is(std::shared_ptr<Configuration> config)
|
||||
{
|
||||
std::shared_ptr<APRS_IS> aprs_is = std::shared_ptr<APRS_IS>(new APRS_IS(config->callsign, config->aprs_is.passcode , "ESP32-APRS-IS", "0.1"));
|
||||
logPrintI("connecting to APRS-IS server: ");
|
||||
logPrintI(config->aprs_is.server);
|
||||
logPrintI(" on port: ");
|
||||
logPrintlnI(String(config->aprs_is.port));
|
||||
//show_display("INFO", "Connecting to APRS-IS server");
|
||||
while(!aprs_is->connect(config->aprs_is.server, config->aprs_is.port))
|
||||
{
|
||||
logPrintlnE("Connection failed.");
|
||||
logPrintlnI("Waiting 1 seconds before retrying...");
|
||||
//show_display("ERROR", "Server connection failed!", "waiting 5 sec");
|
||||
delay(1000);
|
||||
}
|
||||
logPrintlnI("Connected to APRS-IS server!");
|
||||
return aprs_is;
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@ 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);
|
||||
std::shared_ptr<APRS_IS> setup_aprs_is(std::shared_ptr<Configuration> config);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,13 +21,12 @@ std::shared_ptr<Configuration> ProjectConfigurationManagement::readProjectConfig
|
|||
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;
|
||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("password"))
|
||||
conf->aprs_is.password = data["aprs_is"]["password"].as<String>();
|
||||
conf->beacon.timeout = data["beacon"]["timeout"] | 15;
|
||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("passcode"))
|
||||
conf->aprs_is.passcode = data["aprs_is"]["passcode"].as<String>();
|
||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("server"))
|
||||
conf->aprs_is.server = data["aprs_is"]["server"].as<String>();
|
||||
conf->aprs_is.port = data["aprs_is"]["port"] | 14580;
|
||||
conf->aprs_is.beacon = data["aprs_is"]["beacon"] | true;
|
||||
conf->aprs_is.beaconTimeout = data["aprs_is"]["beacon_timeout"] | 15;
|
||||
|
||||
conf->lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000;
|
||||
conf->lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000;
|
||||
|
@ -77,11 +76,10 @@ void ProjectConfigurationManagement::writeProjectConfiguration(std::shared_ptr<C
|
|||
data["beacon"]["message"] = conf->beacon.message;
|
||||
data["beacon"]["position"]["latitude"] = conf->beacon.positionLatitude;
|
||||
data["beacon"]["position"]["longitude"] = conf->beacon.positionLongitude;
|
||||
data["aprs_is"]["password"] = conf->aprs_is.password;
|
||||
data["beacon"]["timeout"] = conf->beacon.timeout;
|
||||
data["aprs_is"]["passcode"] = conf->aprs_is.passcode;
|
||||
data["aprs_is"]["server"] = conf->aprs_is.server;
|
||||
data["aprs_is"]["port"] = conf->aprs_is.port;
|
||||
data["aprs_is"]["beacon"] = conf->aprs_is.beacon;
|
||||
data["aprs_is"]["beacon_timeout"] = conf->aprs_is.beaconTimeout;
|
||||
data["lora"]["frequency_rx"] = conf->lora.frequencyRx;
|
||||
data["lora"]["frequency_tx"] = conf->lora.frequencyTx;
|
||||
data["lora"]["power"] = conf->lora.power;
|
||||
|
|
|
@ -25,23 +25,22 @@ public:
|
|||
class Beacon
|
||||
{
|
||||
public:
|
||||
Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0) {}
|
||||
Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), timeout(15) {}
|
||||
|
||||
String message;
|
||||
double positionLatitude;
|
||||
double positionLongitude;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
class APRS_IS
|
||||
{
|
||||
public:
|
||||
APRS_IS() : server("euro.aprs2.net"), port(14580), beacon(true), beaconTimeout(15) {}
|
||||
APRS_IS() : server("euro.aprs2.net"), port(14580) {}
|
||||
|
||||
String password;
|
||||
String passcode;
|
||||
String server;
|
||||
int port;
|
||||
bool beacon;
|
||||
int beaconTimeout;
|
||||
};
|
||||
|
||||
class LoRa
|
||||
|
|
Ładowanie…
Reference in New Issue