fixing router task

This commit is contained in:
Peter Buchegger 2022-03-19 22:36:33 +01:00
parent 9c2fb18d1b
commit 00603fe2c3

View file

@ -16,7 +16,6 @@ RouterTask::~RouterTask() {
} }
bool RouterTask::setup(System &system) { bool RouterTask::setup(System &system) {
// setup beacon
_beacon_timer.setTimeout(system.getUserConfig()->beacon.timeout * 60 * 1000); _beacon_timer.setTimeout(system.getUserConfig()->beacon.timeout * 60 * 1000);
_beaconMsg = std::shared_ptr<APRSMessage>(new APRSMessage()); _beaconMsg = std::shared_ptr<APRSMessage>(new APRSMessage());
@ -30,7 +29,6 @@ bool RouterTask::setup(System &system) {
} }
bool RouterTask::loop(System &system) { bool RouterTask::loop(System &system) {
// do routing
if (!_fromModem.empty()) { if (!_fromModem.empty()) {
std::shared_ptr<APRSMessage> modemMsg = _fromModem.getElement(); std::shared_ptr<APRSMessage> modemMsg = _fromModem.getElement();
@ -49,18 +47,19 @@ bool RouterTask::loop(System &system) {
aprsIsMsg->setPath(path + "qAO," + system.getUserConfig()->callsign); aprsIsMsg->setPath(path + "qAO," + system.getUserConfig()->callsign);
logPrintD("APRS-IS: "); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: %s", aprsIsMsg->toString());
logPrintlnD(aprsIsMsg->toString());
_toAprsIs.addElement(aprsIsMsg); _toAprsIs.addElement(aprsIsMsg);
} else { } else {
logPrintlnD("APRS-IS: no forward => RFonly"); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: no forward => RFonly");
} }
} else { } else {
if (!system.getUserConfig()->aprs_is.active) if (!system.getUserConfig()->aprs_is.active) {
logPrintlnD("APRS-IS: disabled"); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: disabled");
}
if (modemMsg->getSource() == system.getUserConfig()->callsign) if (modemMsg->getSource() == system.getUserConfig()->callsign) {
logPrintlnD("APRS-IS: no forward => own packet received"); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: no forward => own packet received");
}
} }
if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) { if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) {
@ -72,8 +71,7 @@ bool RouterTask::loop(System &system) {
// fixme // fixme
digiMsg->setPath(system.getUserConfig()->callsign + "*"); digiMsg->setPath(system.getUserConfig()->callsign + "*");
logPrintD("DIGI: "); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "DIGI: %s", digiMsg->toString());
logPrintlnD(digiMsg->toString());
_toModem.addElement(digiMsg); _toModem.addElement(digiMsg);
} }
@ -82,8 +80,7 @@ bool RouterTask::loop(System &system) {
// check for beacon // check for beacon
if (_beacon_timer.check()) { if (_beacon_timer.check()) {
logPrintD("[" + timeString() + "] "); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s] %s", timeString(), _beaconMsg->encode());
logPrintlnD(_beaconMsg->encode());
if (system.getUserConfig()->aprs_is.active) if (system.getUserConfig()->aprs_is.active)
_toAprsIs.addElement(_beaconMsg); _toAprsIs.addElement(_beaconMsg);
@ -93,7 +90,6 @@ bool RouterTask::loop(System &system) {
} }
system.getDisplay().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("BEACON", _beaconMsg->toString()))); system.getDisplay().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("BEACON", _beaconMsg->toString())));
_beacon_timer.start(); _beacon_timer.start();
} }