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