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-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"
|
|
|
|
|
#include "display.h"
|
2023-06-04 14:54:11 -04:00
|
|
|
#include "utils.h"
|
2023-06-06 11:21:59 -04:00
|
|
|
/*#include <AsyncTCP.h>
|
2023-06-04 23:02:25 -04:00
|
|
|
#include <ESPAsyncWebServer.h>
|
2023-06-06 11:21:59 -04:00
|
|
|
#include <AsyncElegantOTA.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-06 11:21:59 -04:00
|
|
|
//AsyncWebServer server(80);
|
2023-03-26 13:19:01 -03:00
|
|
|
|
2023-06-09 20:20:39 -04:00
|
|
|
String versionDate = "2023.06.09";
|
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-06-09 00:23:11 -04:00
|
|
|
bool statusAfterBoot = true;
|
2023-06-07 17:25:50 -04:00
|
|
|
int stationMode = Config.stationMode;
|
2023-03-26 13:19:01 -03:00
|
|
|
|
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-06 12:37:22 -04:00
|
|
|
String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket;
|
2023-03-02 08:51:38 -03:00
|
|
|
|
2023-06-10 18:41:40 -04:00
|
|
|
// agregar automatic restart cada X horas?
|
|
|
|
|
|
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-07 23:55:31 -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-08 17:09:05 -04:00
|
|
|
utils::validateDigiFreqs();
|
|
|
|
|
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
2023-06-06 11:21:59 -04:00
|
|
|
/*server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
2023-06-04 23:02:25 -04:00
|
|
|
request->send(200, "text/plain", "Hi! I am ESP32.");
|
|
|
|
|
});
|
|
|
|
|
AsyncElegantOTA.begin(&server); // Start ElegantOTA
|
|
|
|
|
server.begin();
|
2023-06-09 20:20:39 -04:00
|
|
|
Serial.println("HTTP server started");*/
|
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-07 21:04:20 -04:00
|
|
|
if (stationMode==3 || stationMode==4) { // DigiRepeater (3 RxFreq=TxFreq / 4 RxFreq!=TxFreq)
|
2023-06-07 23:55:31 -04:00
|
|
|
utils::checkDisplayInterval();
|
|
|
|
|
utils::checkBeaconInterval();
|
2023-06-07 17:25:50 -04:00
|
|
|
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
2023-06-07 21:25:31 -04:00
|
|
|
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
2023-06-07 21:04:20 -04:00
|
|
|
} else 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-07 17:25:50 -04:00
|
|
|
secondLine = APRS_IS_Utils::checkStatus();
|
2023-06-09 08:45:20 -04:00
|
|
|
show_display(firstLine, secondLine, thirdLine, fourthLine, 0);
|
2023-06-07 17:25:50 -04:00
|
|
|
while (espClient.connected()) {
|
2023-06-07 23:55:31 -04:00
|
|
|
utils::checkDisplayInterval();
|
|
|
|
|
utils::checkBeaconInterval();
|
|
|
|
|
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-03-02 20:40:59 -03:00
|
|
|
}
|
2023-03-26 09:12:27 -03:00
|
|
|
}
|