1.1.3
This commit is contained in:
parent
ddee75e95b
commit
5ee4418d5b
|
|
@ -5,7 +5,7 @@
|
||||||
"wifi": {
|
"wifi": {
|
||||||
"AP": [
|
"AP": [
|
||||||
{ "ssid": "Richon",
|
{ "ssid": "Richon",
|
||||||
"password": "k4fPnmg5qny",
|
"password": "k4fPnmg5qnyf",
|
||||||
"latitude": -33.0337313,
|
"latitude": -33.0337313,
|
||||||
"longitude": -71.5737261
|
"longitude": -71.5737261
|
||||||
},
|
},
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"longitude": -71.1202063
|
"longitude": -71.1202063
|
||||||
},
|
},
|
||||||
"aprs_is": {
|
"aprs_is": {
|
||||||
"passcode": "23201",
|
"passcode": "23202",
|
||||||
"server": "euro.aprs2.net",
|
"server": "euro.aprs2.net",
|
||||||
"port": 14580,
|
"port": 14580,
|
||||||
"reportingDistance": 30
|
"reportingDistance": 30
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,21 @@
|
||||||
Configuration Config;
|
Configuration Config;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
|
||||||
String versionDate = "2023.07.30";
|
String versionDate = "2023.07.30";
|
||||||
int myWiFiAPIndex = 0;
|
int myWiFiAPIndex = 0;
|
||||||
int myWiFiAPSize = Config.wifiAPs.size();
|
int myWiFiAPSize = Config.wifiAPs.size();
|
||||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||||
|
|
||||||
int stationMode = Config.stationMode;
|
int stationMode = Config.stationMode;
|
||||||
bool statusAfterBoot = true;
|
bool statusAfterBoot = true;
|
||||||
bool beaconUpdate = true;
|
bool beaconUpdate = true;
|
||||||
uint32_t lastBeaconTx = 0;
|
uint32_t lastBeaconTx = 0;
|
||||||
uint32_t previousWiFiMillis = 0;
|
uint32_t previousWiFiMillis = 0;
|
||||||
uint32_t lastScreenOn = millis();
|
uint32_t lastScreenOn = millis();
|
||||||
|
|
||||||
uint32_t lastWiFiCheck = 0;
|
uint32_t lastWiFiCheck = 0;
|
||||||
bool WiFiConnect = true;
|
bool WiFiConnect = true;
|
||||||
|
int lastStationModeState = 1;
|
||||||
|
|
||||||
String batteryVoltage;
|
String batteryVoltage;
|
||||||
|
|
||||||
|
|
@ -82,7 +83,7 @@ void loop() {
|
||||||
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
DIGI_Utils::processPacket(LoRa_Utils::receivePacket());
|
||||||
} else if (stationMode==5) {
|
} else if (stationMode==5) {
|
||||||
uint32_t WiFiCheck = millis() - lastWiFiCheck;
|
uint32_t WiFiCheck = millis() - lastWiFiCheck;
|
||||||
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*33*1000) {
|
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= Config.lastWiFiCheck*4*1000) {
|
||||||
WiFiConnect = true;
|
WiFiConnect = true;
|
||||||
}
|
}
|
||||||
if (WiFiConnect) {
|
if (WiFiConnect) {
|
||||||
|
|
@ -91,17 +92,33 @@ void loop() {
|
||||||
lastWiFiCheck = millis();
|
lastWiFiCheck = millis();
|
||||||
WiFiConnect = false;
|
WiFiConnect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WiFi.status() == WL_CONNECTED) { // Modo iGate
|
if (WiFi.status() == WL_CONNECTED) { // Modo iGate
|
||||||
Serial.println("conectado a Wifi: " + currentWiFi->ssid);
|
thirdLine = Utils::getLocalIP();
|
||||||
// probar si pierde wifi que pasa...
|
if (!espClient.connected()) {
|
||||||
|
APRS_IS_Utils::connect();
|
||||||
// cuanto tiene wifi , tratar de conectarse a APRS IS
|
}
|
||||||
// si lo logra --> igate
|
if (lastStationModeState == 1) {
|
||||||
// si no --------> digirepeater
|
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||||
|
lastStationModeState = 0;
|
||||||
|
}
|
||||||
|
APRS_IS_Utils::checkStatus();
|
||||||
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||||
|
while (espClient.connected()) {
|
||||||
|
Utils::checkDisplayInterval();
|
||||||
|
Utils::checkBeaconInterval();
|
||||||
|
APRS_IS_Utils::processLoRaPacket(LoRa_Utils::receivePacket());
|
||||||
|
if (espClient.available()) {
|
||||||
|
String aprsisPacket;
|
||||||
|
aprsisPacket.concat(espClient.readStringUntil('\r'));
|
||||||
|
APRS_IS_Utils::processAPRSISPacket(aprsisPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else { // Modo DigiRepeater
|
} else { // Modo DigiRepeater
|
||||||
|
if (lastStationModeState == 0) {
|
||||||
|
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||||
|
lastStationModeState = 1;
|
||||||
|
thirdLine = "<< DigiRepeater >>";
|
||||||
|
}
|
||||||
Utils::checkDisplayInterval();
|
Utils::checkDisplayInterval();
|
||||||
Utils::checkBeaconInterval();
|
Utils::checkBeaconInterval();
|
||||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
#include <TinyGPS++.h>
|
#include <TinyGPS++.h>
|
||||||
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "gps_utils.h"
|
#include "gps_utils.h"
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
extern WiFi_AP *currentWiFi;
|
extern WiFi_AP *currentWiFi;
|
||||||
|
extern WiFiClient espClient;
|
||||||
extern int stationMode;
|
extern int stationMode;
|
||||||
String distance;
|
String distance;
|
||||||
|
|
||||||
|
|
@ -78,7 +80,7 @@ String processLongitudeAPRS(double lon) {
|
||||||
|
|
||||||
String generateBeacon() {
|
String generateBeacon() {
|
||||||
String stationLatitude, stationLongitude, beaconPacket;
|
String stationLatitude, stationLongitude, beaconPacket;
|
||||||
if (stationMode==1 || stationMode==2) {
|
if (stationMode==1 || stationMode==2 || (stationMode==5 && WiFi.status() == WL_CONNECTED && espClient.connected())) {
|
||||||
stationLatitude = processLatitudeAPRS(currentWiFi->latitude);
|
stationLatitude = processLatitudeAPRS(currentWiFi->latitude);
|
||||||
stationLongitude = processLongitudeAPRS(currentWiFi->longitude);
|
stationLongitude = processLongitudeAPRS(currentWiFi->longitude);
|
||||||
beaconPacket = Config.callsign + ">APLRG1,qAC:=" + stationLatitude + "L" + stationLongitude;
|
beaconPacket = Config.callsign + ">APLRG1,qAC:=" + stationLatitude + "L" + stationLongitude;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "station_utils.h"
|
#include "station_utils.h"
|
||||||
#include "battery_utils.h"
|
#include "battery_utils.h"
|
||||||
|
#include "aprs_is_utils.h"
|
||||||
#include "syslog_utils.h"
|
#include "syslog_utils.h"
|
||||||
#include "pins_config.h"
|
#include "pins_config.h"
|
||||||
#include "wifi_utils.h"
|
#include "wifi_utils.h"
|
||||||
|
|
@ -75,9 +76,9 @@ void setupDisplay() {
|
||||||
show_display(" LoRa APRS", " ( iGate )", "", " Richonguzman", " -- CD2RXU --", "", " " + versionDate, 4000);
|
show_display(" LoRa APRS", " ( iGate )", "", " Richonguzman", " -- CD2RXU --", "", " " + versionDate, 4000);
|
||||||
digitalWrite(greenLed,LOW);
|
digitalWrite(greenLed,LOW);
|
||||||
firstLine = Config.callsign;
|
firstLine = Config.callsign;
|
||||||
if (stationMode==3 || stationMode==4) {
|
/*if (stationMode==3 || stationMode==4) {
|
||||||
thirdLine = "<< DigiRepeater >>";
|
thirdLine = "<< DigiRepeater >>";
|
||||||
}
|
}*/
|
||||||
seventhLine = " listening...";
|
seventhLine = " listening...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +93,7 @@ void activeStations() {
|
||||||
void checkBeaconInterval() {
|
void checkBeaconInterval() {
|
||||||
uint32_t lastTx = millis() - lastBeaconTx;
|
uint32_t lastTx = millis() - lastBeaconTx;
|
||||||
String beaconPacket;
|
String beaconPacket;
|
||||||
if (lastTx >= Config.beaconInterval*60*1000) {
|
if (lastTx >= Config.beaconInterval*12*1000) { // 60!!!
|
||||||
beaconUpdate = true;
|
beaconUpdate = true;
|
||||||
}
|
}
|
||||||
if (beaconUpdate) {
|
if (beaconUpdate) {
|
||||||
|
|
@ -130,6 +131,7 @@ void checkBeaconInterval() {
|
||||||
secondLine = "Rx:" + String(Rx.substring(0,3)) + "." + String(Rx.substring(3,6));
|
secondLine = "Rx:" + String(Rx.substring(0,3)) + "." + String(Rx.substring(3,6));
|
||||||
}
|
}
|
||||||
secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
||||||
|
thirdLine = "<< DigiRepeater >>";
|
||||||
fifthLine = "";
|
fifthLine = "";
|
||||||
sixthLine = "";
|
sixthLine = "";
|
||||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
|
||||||
|
|
@ -145,10 +147,25 @@ void checkBeaconInterval() {
|
||||||
LoRa_Utils::changeFreqRx();
|
LoRa_Utils::changeFreqRx();
|
||||||
}
|
}
|
||||||
} else if (stationMode==5) {
|
} else if (stationMode==5) {
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED && espClient.connected()) {
|
||||||
|
APRS_IS_Utils::checkStatus();
|
||||||
|
thirdLine = getLocalIP();
|
||||||
|
if (!Config.bme.active) {
|
||||||
|
fifthLine = "";
|
||||||
|
}
|
||||||
|
sixthLine = "";
|
||||||
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 1000);
|
||||||
|
if (Config.sendBatteryVoltage) {
|
||||||
|
sixthLine = " (Batt=" + String(BATTERY_Utils::checkVoltages(),2) + "V)";
|
||||||
|
}
|
||||||
|
seventhLine = " listening...";
|
||||||
|
espClient.write((beaconPacket + "\n").c_str());
|
||||||
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||||
|
} else {
|
||||||
String Tx = String(Config.loramodule.digirepeaterTxFreq);
|
String Tx = String(Config.loramodule.digirepeaterTxFreq);
|
||||||
secondLine = "Rx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
secondLine = "Rx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
||||||
secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
secondLine += " Tx:" + String(Tx.substring(0,3)) + "." + String(Tx.substring(3,6));
|
||||||
|
thirdLine = "<< DigiRepeater >>";
|
||||||
fifthLine = "";
|
fifthLine = "";
|
||||||
sixthLine = "";
|
sixthLine = "";
|
||||||
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
|
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING iGate BEACON", 0);
|
||||||
|
|
@ -157,8 +174,6 @@ void checkBeaconInterval() {
|
||||||
}
|
}
|
||||||
seventhLine = " listening...";
|
seventhLine = " listening...";
|
||||||
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
LoRa_Utils::sendNewPacket("APRS", beaconPacket);
|
||||||
} else {
|
|
||||||
Serial.println("enviando beacon por APRS WIFI");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastBeaconTx = millis();
|
lastBeaconTx = millis();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue