LoRa_APRS_iGate/src/LoRa_APRS_iGate.cpp

78 lines
2.5 KiB
C++
Raw Normal View History

2023-03-02 08:51:38 -03:00
#include <Arduino.h>
#include <LoRa.h>
#include <WiFi.h>
2023-05-19 18:52:59 -04:00
#include <vector>
2023-06-06 11:21:59 -04:00
#include "configuration.h"
2023-06-06 11:30:32 -04:00
#include "aprs_is_utils.h"
2023-06-06 14:26:17 -04:00
#include "station_utils.h"
2023-06-12 01:31:18 -04:00
#include "syslog_utils.h"
2023-06-08 00:58:10 -04:00
#include "pins_config.h"
2023-06-06 15:53:06 -04:00
#include "query_utils.h"
2023-06-08 00:58:10 -04:00
#include "lora_utils.h"
#include "wifi_utils.h"
2023-06-07 17:25:50 -04:00
#include "digi_utils.h"
2023-06-08 00:58:10 -04:00
#include "gps_utils.h"
2023-06-17 18:28:40 -04:00
#include "bme_utils.h"
2023-06-08 00:58:10 -04:00
#include "display.h"
2023-06-04 14:54:11 -04:00
#include "utils.h"
2023-06-04 23:02:25 -04:00
2023-06-08 00:44:13 -04:00
Configuration Config;
2023-03-26 13:19:01 -03:00
WiFiClient espClient;
2023-06-12 01:31:18 -04:00
2023-06-19 01:39:20 -04:00
String versionDate = "2023.06.19";
2023-06-06 11:21:59 -04:00
int myWiFiAPIndex = 0;
2023-06-04 11:23:26 -04:00
int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
2023-03-26 13:19:01 -03:00
2023-06-13 00:02:25 -04:00
int stationMode = Config.stationMode;
bool statusAfterBoot = true;
2023-06-07 23:55:31 -04:00
bool beacon_update = true;
uint32_t lastBeaconTx = 0;
2023-06-09 01:12:13 -04:00
uint32_t previousWiFiMillis = 0;
2023-06-07 23:55:31 -04:00
uint32_t lastScreenOn = millis();
2023-05-19 18:52:59 -04:00
std::vector<String> lastHeardStation;
2023-05-25 10:27:46 -04:00
std::vector<String> lastHeardStation_temp;
2023-05-10 00:59:00 -04:00
2023-06-18 10:56:53 -04:00
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket;
2023-03-02 08:51:38 -03:00
void setup() {
Serial.begin(115200);
2023-06-09 20:20:39 -04:00
pinMode(greenLed, OUTPUT);
2023-06-04 15:05:48 -04:00
delay(1000);
2023-06-12 01:31:18 -04:00
Utils::setupDiplay();
2023-06-08 17:09:05 -04:00
WIFI_Utils::setup();
2023-06-07 17:25:50 -04:00
LoRa_Utils::setup();
2023-06-12 01:31:18 -04:00
Utils::validateDigiFreqs();
2023-06-08 17:09:05 -04:00
iGateBeaconPacket = GPS_Utils::generateBeacon();
2023-06-12 01:31:18 -04:00
Utils::startOTAServer();
SYSLOG_Utils::setup();
2023-06-17 18:28:40 -04:00
BME_Utils::setup();
2023-06-07 17:25:50 -04:00
}
2023-03-02 20:40:59 -03:00
2023-06-07 17:25:50 -04:00
void loop() {
2023-06-11 21:28:12 -04:00
if (stationMode==1 || stationMode==2 ) { // iGate (1 Only Rx / 2 Rx+Tx)
2023-06-09 01:12:13 -04:00
WIFI_Utils::checkWiFi();
2023-06-07 17:25:50 -04:00
if (!espClient.connected()) {
APRS_IS_Utils::connect();
2023-06-04 14:54:11 -04:00
}
2023-06-16 19:08:25 -04:00
APRS_IS_Utils::checkStatus();
2023-06-18 10:56:53 -04:00
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
2023-06-07 17:25:50 -04:00
while (espClient.connected()) {
2023-06-12 01:31:18 -04:00
Utils::checkDisplayInterval();
Utils::checkBeaconInterval();
2023-06-07 23:55:31 -04:00
APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket());
2023-06-07 17:25:50 -04:00
if (espClient.available()) {
2023-06-09 08:34:34 -04:00
String aprsisPacket;
2023-06-09 01:17:45 -04:00
aprsisPacket.concat(espClient.readStringUntil('\r'));
2023-06-09 01:12:13 -04:00
APRS_IS_Utils::processAPRSISPacket(aprsisPacket);
2023-06-07 17:25:50 -04:00
}
2023-03-02 22:31:22 -03:00
}
2023-06-11 21:28:12 -04:00
} else if (stationMode==3 || stationMode==4) { // DigiRepeater (3 RxFreq=TxFreq / 4 RxFreq!=TxFreq)
2023-06-12 01:31:18 -04:00
Utils::checkDisplayInterval();
Utils::checkBeaconInterval();
2023-06-19 00:52:40 -04:00
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
2023-06-11 21:28:12 -04:00
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
2023-03-02 20:40:59 -03:00
}
2023-03-26 09:12:27 -03:00
}