LoRa_APRS_iGate/src/utils.cpp

83 lines
2.5 KiB
C++
Raw Normal View History

2023-06-04 20:54:11 +02:00
#include <WiFi.h>
2023-06-06 17:21:59 +02:00
#include "configuration.h"
2023-06-07 23:25:50 +02:00
#include "wifi_utils.h"
2023-06-08 05:55:31 +02:00
#include "lora_utils.h"
#include "display.h"
2023-06-04 20:18:30 +02:00
#include "utils.h"
2023-06-08 05:55:31 +02:00
extern WiFiClient espClient;
extern Configuration Config;
extern bool statusAfterBoot;
extern String firstLine;
extern String secondLine;
extern String thirdLine;
extern String fourthLine;
extern uint32_t lastBeaconTx;
extern uint32_t lastScreenOn;
extern bool beacon_update;
extern int stationMode;
extern String iGateBeaconPacket;
2023-06-04 20:18:30 +02:00
2023-06-04 20:54:11 +02:00
namespace utils {
2023-06-04 20:18:30 +02:00
2023-06-04 20:54:11 +02:00
void processStatus() {
2023-06-08 06:44:13 +02:00
String status = Config.callsign + ">APLRG1";
if (stationMode==1 || stationMode==2) {
delay(1000);
status += ",qAC:>" + Config.defaultStatus;
espClient.write((status + "\n").c_str());
} else {
delay(5000);
status += ":>" + Config.defaultStatus;
LoRa_Utils::sendNewPacket("APRS", status);
}
2023-06-04 20:54:11 +02:00
statusAfterBoot = false;
2023-06-04 20:18:30 +02:00
}
2023-06-08 05:55:31 +02:00
void setupDiplay() {
setup_display();
firstLine = "LoRa iGate: " + Config.callsign;
if (stationMode==3 || stationMode==4) {
secondLine = "<DigiRepeater Active>";
} else {
secondLine = "";
}
thirdLine = " LoRa Module Ready";
fourthLine = " listening...";
}
void checkBeaconInterval() {
uint32_t lastTx = millis() - lastBeaconTx;
if (lastTx >= Config.beaconInterval*60*1000) {
beacon_update = true;
}
if (beacon_update) {
display_toggle(true);
thirdLine = "";
Serial.println("---- Sending iGate Beacon ----");
if (stationMode==3 || stationMode==4) {
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 0);
fourthLine = " listening...";
LoRa_Utils::sendNewPacket("APRS",iGateBeaconPacket);
} else if (stationMode==1 || stationMode==2) {
show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 1000);
fourthLine = " listening...";
espClient.write((iGateBeaconPacket + "\n").c_str());
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
}
lastBeaconTx = millis();
lastScreenOn = millis();
beacon_update = false;
}
}
void checkDisplayInterval() {
uint32_t lastDisplayTime = millis() - lastScreenOn;
if (!Config.display.alwaysOn) {
if (lastDisplayTime >= Config.display.timeout*1000) {
display_toggle(false);
}
}
}
2023-06-04 20:18:30 +02:00
}