kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
commit
065c97ada4
|
@ -29,7 +29,7 @@
|
||||||
"latitude": 0.000000,
|
"latitude": 0.000000,
|
||||||
"longitude": 0.000000
|
"longitude": 0.000000
|
||||||
},
|
},
|
||||||
"gps": true,
|
"use_gps": false,
|
||||||
"timeout": 15
|
"timeout": 15
|
||||||
},
|
},
|
||||||
"aprs_is": {
|
"aprs_is": {
|
||||||
|
|
|
@ -95,7 +95,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
powerManagement.activateLoRa();
|
powerManagement.activateLoRa();
|
||||||
powerManagement.activateOLED();
|
powerManagement.activateOLED();
|
||||||
if (userConfig.beacon.gps) {
|
if (userConfig.beacon.use_gps) {
|
||||||
powerManagement.activateGPS();
|
powerManagement.activateGPS();
|
||||||
} else {
|
} else {
|
||||||
powerManagement.deactivateGPS();
|
powerManagement.deactivateGPS();
|
||||||
|
|
|
@ -6,22 +6,21 @@
|
||||||
#include "TaskBeacon.h"
|
#include "TaskBeacon.h"
|
||||||
#include "project_configuration.h"
|
#include "project_configuration.h"
|
||||||
|
|
||||||
BeaconTask::BeaconTask(TaskQueue<std::shared_ptr<APRSMessage>> &toModem, TaskQueue<std::shared_ptr<APRSMessage>> &toAprsIs) : Task(TASK_BEACON, TaskBeacon), _toModem(toModem), _toAprsIs(toAprsIs), ss(1), gpsok(false) {
|
BeaconTask::BeaconTask(TaskQueue<std::shared_ptr<APRSMessage>> &toModem, TaskQueue<std::shared_ptr<APRSMessage>> &toAprsIs) : Task(TASK_BEACON, TaskBeacon), _toModem(toModem), _toAprsIs(toAprsIs), _ss(1), _useGps(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BeaconTask::~BeaconTask() {
|
BeaconTask::~BeaconTask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeaconTask::setup(System &system) {
|
bool BeaconTask::setup(System &system) {
|
||||||
gpsok = system.getUserConfig()->beacon.gps;
|
_useGps = system.getUserConfig()->beacon.use_gps;
|
||||||
|
|
||||||
// Setup GPS
|
if (_useGps) {
|
||||||
if (gpsok) {
|
|
||||||
if (system.getBoardConfig()->GpsRx != 0) {
|
if (system.getBoardConfig()->GpsRx != 0) {
|
||||||
ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx);
|
_ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx);
|
||||||
} else {
|
} else {
|
||||||
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found.");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found.");
|
||||||
gpsok = false;
|
_useGps = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// setup beacon
|
// setup beacon
|
||||||
|
@ -35,17 +34,16 @@ bool BeaconTask::setup(System &system) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeaconTask::loop(System &system) {
|
bool BeaconTask::loop(System &system) {
|
||||||
|
if (_useGps) {
|
||||||
if (gpsok) {
|
while (_ss.available() > 0) {
|
||||||
while (ss.available() > 0) {
|
char c = _ss.read();
|
||||||
char c = ss.read();
|
_gps.encode(c);
|
||||||
gps.encode(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for beacon
|
// check for beacon
|
||||||
if (_beacon_timer.check()) {
|
if (_beacon_timer.check()) {
|
||||||
if (setBeacon(system)) {
|
if (sendBeacon(system)) {
|
||||||
_beacon_timer.start();
|
_beacon_timer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,27 +78,25 @@ String create_long_aprs(double lng) {
|
||||||
return lng_str;
|
return lng_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BeaconTask::setBeacon(System &system) {
|
bool BeaconTask::sendBeacon(System &system) {
|
||||||
|
double lat = system.getUserConfig()->beacon.positionLatitude;
|
||||||
|
double lng = system.getUserConfig()->beacon.positionLongitude;
|
||||||
|
|
||||||
double lat, lng;
|
if (_useGps) {
|
||||||
|
if (_gps.location.isUpdated()) {
|
||||||
if (gpsok) {
|
lat = _gps.location.lat();
|
||||||
if (gps.location.isUpdated()) {
|
lng = _gps.location.lng();
|
||||||
lat = gps.location.lat();
|
|
||||||
lng = gps.location.lng();
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
lat = system.getUserConfig()->beacon.positionLatitude;
|
|
||||||
lng = system.getUserConfig()->beacon.positionLongitude;
|
|
||||||
}
|
}
|
||||||
_beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message);
|
_beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message);
|
||||||
|
|
||||||
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s] %s", timeString().c_str(), _beaconMsg->encode().c_str());
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s] %s", timeString().c_str(), _beaconMsg->encode().c_str());
|
||||||
|
|
||||||
if (system.getUserConfig()->aprs_is.active)
|
if (system.getUserConfig()->aprs_is.active) {
|
||||||
_toAprsIs.addElement(_beaconMsg);
|
_toAprsIs.addElement(_beaconMsg);
|
||||||
|
}
|
||||||
|
|
||||||
if (system.getUserConfig()->digi.beacon) {
|
if (system.getUserConfig()->digi.beacon) {
|
||||||
_toModem.addElement(_beaconMsg);
|
_toModem.addElement(_beaconMsg);
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
|
|
||||||
virtual bool setup(System &system) override;
|
virtual bool setup(System &system) override;
|
||||||
virtual bool loop(System &system) override;
|
virtual bool loop(System &system) override;
|
||||||
bool setBeacon(System &system);
|
bool sendBeacon(System &system);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaskQueue<std::shared_ptr<APRSMessage>> &_toModem;
|
TaskQueue<std::shared_ptr<APRSMessage>> &_toModem;
|
||||||
|
@ -23,9 +23,9 @@ private:
|
||||||
std::shared_ptr<APRSMessage> _beaconMsg;
|
std::shared_ptr<APRSMessage> _beaconMsg;
|
||||||
Timer _beacon_timer;
|
Timer _beacon_timer;
|
||||||
|
|
||||||
HardwareSerial ss;
|
HardwareSerial _ss;
|
||||||
TinyGPSPlus gps;
|
TinyGPSPlus _gps;
|
||||||
bool gpsok;
|
bool _useGps;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,7 +41,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
conf.beacon.message = data["beacon"]["message"].as<String>();
|
conf.beacon.message = data["beacon"]["message"].as<String>();
|
||||||
conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
||||||
conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0;
|
conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0;
|
||||||
conf.beacon.gps = data["beacon"]["gps"] | false;
|
conf.beacon.use_gps = data["beacon"]["use_gps"] | false;
|
||||||
conf.beacon.timeout = data["beacon"]["timeout"] | 15;
|
conf.beacon.timeout = data["beacon"]["timeout"] | 15;
|
||||||
conf.aprs_is.active = data["aprs_is"]["active"] | true;
|
conf.aprs_is.active = data["aprs_is"]["active"] | true;
|
||||||
if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("passcode"))
|
if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("passcode"))
|
||||||
|
@ -123,7 +123,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co
|
||||||
data["beacon"]["message"] = conf.beacon.message;
|
data["beacon"]["message"] = conf.beacon.message;
|
||||||
data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude;
|
data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude;
|
||||||
data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude;
|
data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude;
|
||||||
data["beacon"]["gps"] = conf.beacon.gps;
|
data["beacon"]["use_gps"] = conf.beacon.use_gps;
|
||||||
data["beacon"]["timeout"] = conf.beacon.timeout;
|
data["beacon"]["timeout"] = conf.beacon.timeout;
|
||||||
data["aprs_is"]["active"] = conf.aprs_is.active;
|
data["aprs_is"]["active"] = conf.aprs_is.active;
|
||||||
data["aprs_is"]["passcode"] = conf.aprs_is.passcode;
|
data["aprs_is"]["passcode"] = conf.aprs_is.passcode;
|
||||||
|
|
|
@ -48,13 +48,13 @@ public:
|
||||||
|
|
||||||
class Beacon {
|
class Beacon {
|
||||||
public:
|
public:
|
||||||
Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), gps(false), timeout(15) {
|
Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), use_gps(false), timeout(15) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
double positionLatitude;
|
double positionLatitude;
|
||||||
double positionLongitude;
|
double positionLongitude;
|
||||||
bool gps;
|
bool use_gps;
|
||||||
int timeout;
|
int timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue