GPS for iGate
This commit is contained in:
parent
c0641986aa
commit
00db358cc3
|
|
@ -540,6 +540,36 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 mt-3">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="beacon.gpsActive"
|
||||||
|
id="beacon.gpsActive"
|
||||||
|
class="form-check-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
for="beacon.gpsActive"
|
||||||
|
class="form-label"
|
||||||
|
>Send Real GPS Beacon <small>(For Boards with GPS Modules)</small>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="beacon.gpsAmbiguity"
|
||||||
|
id="beacon.gpsAmbiguity"
|
||||||
|
class="form-check-input"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
for="beacon.gpsAmbiguity"
|
||||||
|
class="form-label"
|
||||||
|
>Send Real GPS Beacon with Ambiguity
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,9 @@ function loadSettings(settings) {
|
||||||
document.getElementById("beacon.sendViaAPRSIS").checked = settings.beacon.sendViaAPRSIS;
|
document.getElementById("beacon.sendViaAPRSIS").checked = settings.beacon.sendViaAPRSIS;
|
||||||
document.getElementById("beacon.sendViaRF").checked = settings.beacon.sendViaRF;
|
document.getElementById("beacon.sendViaRF").checked = settings.beacon.sendViaRF;
|
||||||
|
|
||||||
|
document.getElementById("beacon.gpsActive").checked = settings.beacon.gpsActive;
|
||||||
|
document.getElementById("beacon.gpsAmbiguity").checked = settings.beacon.gpsAmbiguity;
|
||||||
|
|
||||||
// Digi
|
// Digi
|
||||||
document.getElementById("digi.mode").value = settings.digi.mode;
|
document.getElementById("digi.mode").value = settings.digi.mode;
|
||||||
document.getElementById("digi.ecoMode").checked = settings.digi.ecoMode;
|
document.getElementById("digi.ecoMode").checked = settings.digi.ecoMode;
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ build_flags =
|
||||||
-Werror -Wall
|
-Werror -Wall
|
||||||
-DHELTEC_WSL_V3
|
-DHELTEC_WSL_V3
|
||||||
-DHAS_SX1262
|
-DHAS_SX1262
|
||||||
|
-DHAS_GPS
|
||||||
|
-DGPS_BAUDRATE=115200
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -212,6 +214,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_2
|
-DTTGO_T_Beam_V1_2
|
||||||
-DHAS_SX1278
|
-DHAS_SX1278
|
||||||
-DHAS_AXP2101
|
-DHAS_AXP2101
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -226,6 +229,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_2_915
|
-DTTGO_T_Beam_V1_2_915
|
||||||
-DHAS_SX1276
|
-DHAS_SX1276
|
||||||
-DHAS_AXP2101
|
-DHAS_AXP2101
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -240,6 +244,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_0
|
-DTTGO_T_Beam_V1_0
|
||||||
-DHAS_SX1278
|
-DHAS_SX1278
|
||||||
-DHAS_AXP192
|
-DHAS_AXP192
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -254,6 +259,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_0_915
|
-DTTGO_T_Beam_V1_0_915
|
||||||
-DHAS_SX1276
|
-DHAS_SX1276
|
||||||
-DHAS_AXP192
|
-DHAS_AXP192
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -268,6 +274,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_0_SX1268
|
-DTTGO_T_Beam_V1_0_SX1268
|
||||||
-DHAS_SX1268
|
-DHAS_SX1268
|
||||||
-DHAS_AXP192
|
-DHAS_AXP192
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
@ -282,6 +289,7 @@ build_flags =
|
||||||
-DTTGO_T_Beam_V1_2_SX1262
|
-DTTGO_T_Beam_V1_2_SX1262
|
||||||
-DHAS_SX1262
|
-DHAS_SX1262
|
||||||
-DHAS_AXP2101
|
-DHAS_AXP2101
|
||||||
|
-DHAS_GPS
|
||||||
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps}
|
${common.lib_deps}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
______________________________________________________________________________________________________________*/
|
______________________________________________________________________________________________________________*/
|
||||||
|
|
||||||
#include <ElegantOTA.h>
|
#include <ElegantOTA.h>
|
||||||
|
#include <TinyGPS++.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -39,19 +40,23 @@ ________________________________________________________________________________
|
||||||
#include "A7670_utils.h"
|
#include "A7670_utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String versionDate = "2024.10.14";
|
String versionDate = "2024.10.14";
|
||||||
Configuration Config;
|
Configuration Config;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
HardwareSerial gpsSerial(1);
|
||||||
|
TinyGPSPlus gps;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t myWiFiAPIndex = 0;
|
uint8_t myWiFiAPIndex = 0;
|
||||||
int myWiFiAPSize = Config.wifiAPs.size();
|
int myWiFiAPSize = Config.wifiAPs.size();
|
||||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||||
|
|
||||||
bool isUpdatingOTA = false;
|
bool isUpdatingOTA = false;
|
||||||
uint32_t lastBatteryCheck = 0;
|
uint32_t lastBatteryCheck = 0;
|
||||||
|
|
||||||
bool backUpDigiMode = false;
|
bool backUpDigiMode = false;
|
||||||
bool modemLoggedToAPRSIS = false;
|
bool modemLoggedToAPRSIS = false;
|
||||||
|
|
||||||
std::vector<ReceivedPacket> receivedPackets;
|
std::vector<ReceivedPacket> receivedPackets;
|
||||||
|
|
||||||
|
|
@ -65,7 +70,7 @@ void setup() {
|
||||||
Utils::setupDisplay();
|
Utils::setupDisplay();
|
||||||
LoRa_Utils::setup();
|
LoRa_Utils::setup();
|
||||||
Utils::validateFreqs();
|
Utils::validateFreqs();
|
||||||
GPS_Utils::generateBeacons();
|
GPS_Utils::setup();
|
||||||
|
|
||||||
#ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers
|
#ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers
|
||||||
displayShow("", " STARTUP DELAY ...", "", "", 0);
|
displayShow("", " STARTUP DELAY ...", "", "", 0);
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,16 @@
|
||||||
#define RADIO_BUSY_PIN 8
|
#define RADIO_BUSY_PIN 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_2_915) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_915) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
|
||||||
|
#define GPS_RX 12
|
||||||
|
#define GPS_TX 34
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined( HELTEC_WIRELESS_TRACKER)
|
||||||
|
#define GPS_RX 34
|
||||||
|
#define GPS_TX 33
|
||||||
|
#endif
|
||||||
|
|
||||||
/* (Same pins for LILYGO LoRa32 and ESP32 Wroom Dev )
|
/* (Same pins for LILYGO LoRa32 and ESP32 Wroom Dev )
|
||||||
SX1278-------------------> ESP32 ttgo-lora32-v21 and ESP32 WROOM Dev
|
SX1278-------------------> ESP32 ttgo-lora32-v21 and ESP32 WROOM Dev
|
||||||
GND GND
|
GND GND
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ void Configuration::writeFile() {
|
||||||
data["beacon"]["sendViaRF"] = beacon.sendViaRF;
|
data["beacon"]["sendViaRF"] = beacon.sendViaRF;
|
||||||
data["beacon"]["path"] = beacon.path;
|
data["beacon"]["path"] = beacon.path;
|
||||||
|
|
||||||
|
data["beacon"]["gpsActive"] = beacon.gpsActive;
|
||||||
|
data["beacon"]["gpsAmbiguity"] = beacon.gpsAmbiguity;
|
||||||
|
|
||||||
data["digi"]["mode"] = digi.mode;
|
data["digi"]["mode"] = digi.mode;
|
||||||
data["digi"]["ecoMode"] = digi.ecoMode;
|
data["digi"]["ecoMode"] = digi.ecoMode;
|
||||||
|
|
||||||
|
|
@ -146,6 +149,9 @@ bool Configuration::readFile() {
|
||||||
beacon.path = data["beacon"]["path"] | "WIDE1-1";
|
beacon.path = data["beacon"]["path"] | "WIDE1-1";
|
||||||
beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"] | false;
|
beacon.sendViaAPRSIS = data["beacon"]["sendViaAPRSIS"] | false;
|
||||||
beacon.sendViaRF = data["beacon"]["sendViaRF"] | false;
|
beacon.sendViaRF = data["beacon"]["sendViaRF"] | false;
|
||||||
|
|
||||||
|
beacon.gpsActive = data["beacon"]["gpsActive"] | false;
|
||||||
|
beacon.gpsAmbiguity = data["beacon"]["gpsAmbiguity"] | false;
|
||||||
|
|
||||||
aprs_is.active = data["aprs_is"]["active"] | false;
|
aprs_is.active = data["aprs_is"]["active"] | false;
|
||||||
aprs_is.passcode = data["aprs_is"]["passcode"] | "XYZWV";
|
aprs_is.passcode = data["aprs_is"]["passcode"] | "XYZWV";
|
||||||
|
|
@ -253,6 +259,9 @@ void Configuration::init() {
|
||||||
beacon.sendViaAPRSIS = true;
|
beacon.sendViaAPRSIS = true;
|
||||||
beacon.sendViaRF = false;
|
beacon.sendViaRF = false;
|
||||||
beacon.path = "WIDE1-1";
|
beacon.path = "WIDE1-1";
|
||||||
|
|
||||||
|
beacon.gpsActive = false;
|
||||||
|
beacon.gpsAmbiguity = false;
|
||||||
|
|
||||||
digi.mode = 0;
|
digi.mode = 0;
|
||||||
digi.ecoMode = false;
|
digi.ecoMode = false;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ public:
|
||||||
String path;
|
String path;
|
||||||
bool sendViaRF;
|
bool sendViaRF;
|
||||||
bool sendViaAPRSIS;
|
bool sendViaAPRSIS;
|
||||||
|
bool gpsActive;
|
||||||
|
bool gpsAmbiguity;
|
||||||
};
|
};
|
||||||
|
|
||||||
class APRS_IS {
|
class APRS_IS {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,22 @@
|
||||||
#include <TinyGPS++.h>
|
#include <TinyGPS++.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "boards_pinout.h"
|
||||||
#include "gps_utils.h"
|
#include "gps_utils.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
extern Configuration Config;
|
#ifdef GPS_BAUDRATE
|
||||||
extern WiFiClient espClient;
|
#define GPS_BAUD GPS_BAUDRATE
|
||||||
String distance, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
#else
|
||||||
|
#define GPS_BAUD 9600
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern Configuration Config;
|
||||||
|
extern WiFiClient espClient;
|
||||||
|
extern HardwareSerial gpsSerial;
|
||||||
|
extern TinyGPSPlus gps;
|
||||||
|
String distance, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
||||||
|
|
||||||
|
|
||||||
namespace GPS_Utils {
|
namespace GPS_Utils {
|
||||||
|
|
@ -24,20 +33,32 @@ namespace GPS_Utils {
|
||||||
return(s);
|
return(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float roundToTwoDecimals(float degrees) {
|
||||||
|
return round(degrees * 100) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol) {
|
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol) {
|
||||||
String encodedData = overlay;
|
String encodedData = overlay;
|
||||||
uint32_t aprs_lat, aprs_lon;
|
uint32_t aprs_lat, aprs_lon;
|
||||||
aprs_lat = 900000000 - latitude * 10000000;
|
|
||||||
|
float processedLatitude = latitude;
|
||||||
|
float processedLongitude = longitude;
|
||||||
|
if (Config.beacon.gpsActive && Config.beacon.gpsAmbiguity) {
|
||||||
|
processedLatitude = roundToTwoDecimals(latitude);
|
||||||
|
processedLongitude = roundToTwoDecimals(longitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
aprs_lat = 900000000 - processedLatitude * 10000000;
|
||||||
aprs_lat = aprs_lat / 26 - aprs_lat / 2710 + aprs_lat / 15384615;
|
aprs_lat = aprs_lat / 26 - aprs_lat / 2710 + aprs_lat / 15384615;
|
||||||
aprs_lon = 900000000 + longitude * 10000000 / 2;
|
aprs_lon = 900000000 + processedLongitude * 10000000 / 2;
|
||||||
aprs_lon = aprs_lon / 26 - aprs_lon / 2710 + aprs_lon / 15384615;
|
aprs_lon = aprs_lon / 26 - aprs_lon / 2710 + aprs_lon / 15384615;
|
||||||
|
|
||||||
String Ns, Ew, helper;
|
String Ns, Ew, helper;
|
||||||
if(latitude < 0) { Ns = "S"; } else { Ns = "N"; }
|
if(processedLatitude < 0) { Ns = "S"; } else { Ns = "N"; }
|
||||||
if(latitude < 0) { latitude= -latitude; }
|
if(processedLatitude < 0) { processedLatitude = -processedLatitude; }
|
||||||
|
|
||||||
if(longitude < 0) { Ew = "W"; } else { Ew = "E"; }
|
if(processedLongitude < 0) { Ew = "W"; } else { Ew = "E"; }
|
||||||
if(longitude < 0) { longitude= -longitude; }
|
if(processedLongitude < 0) { processedLongitude = -processedLongitude; }
|
||||||
|
|
||||||
char helper_base91[] = {"0000\0"};
|
char helper_base91[] = {"0000\0"};
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -55,6 +76,19 @@ namespace GPS_Utils {
|
||||||
return encodedData;
|
return encodedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generateBeaconFirstPart() {
|
||||||
|
String beaconPacket = Config.callsign;
|
||||||
|
beaconPacket += ">APLRG1";
|
||||||
|
if (Config.beacon.path.indexOf("WIDE") == 0) {
|
||||||
|
beaconPacket += ",";
|
||||||
|
beaconPacket += Config.beacon.path;
|
||||||
|
}
|
||||||
|
iGateBeaconPacket = beaconPacket;
|
||||||
|
iGateBeaconPacket += ",qAC:!";
|
||||||
|
iGateLoRaBeaconPacket = beaconPacket;
|
||||||
|
iGateLoRaBeaconPacket += ":!";
|
||||||
|
}
|
||||||
|
|
||||||
void generateBeacons() {
|
void generateBeacons() {
|
||||||
if (Config.callsign.indexOf("NOCALL-10") != 0 && !Utils::checkValidCallsign(Config.callsign)) {
|
if (Config.callsign.indexOf("NOCALL-10") != 0 && !Utils::checkValidCallsign(Config.callsign)) {
|
||||||
displayShow("***** ERROR ******", "CALLSIGN = NOT VALID!", "", "Only Rx Mode Active", 3000);
|
displayShow("***** ERROR ******", "CALLSIGN = NOT VALID!", "", "Only Rx Mode Active", 3000);
|
||||||
|
|
@ -64,19 +98,8 @@ namespace GPS_Utils {
|
||||||
Config.beacon.sendViaRF = false;
|
Config.beacon.sendViaRF = false;
|
||||||
Config.digi.mode = 0;
|
Config.digi.mode = 0;
|
||||||
Config.backupDigiMode = false;
|
Config.backupDigiMode = false;
|
||||||
}
|
|
||||||
String beaconPacket = Config.callsign;
|
|
||||||
beaconPacket += ">APLRG1";
|
|
||||||
if (Config.beacon.path.indexOf("WIDE") == 0) {
|
|
||||||
beaconPacket += ",";
|
|
||||||
beaconPacket += Config.beacon.path;
|
|
||||||
}
|
}
|
||||||
|
generateBeaconFirstPart();
|
||||||
iGateBeaconPacket = beaconPacket;
|
|
||||||
iGateBeaconPacket += ",qAC:!";
|
|
||||||
iGateLoRaBeaconPacket = beaconPacket;
|
|
||||||
iGateLoRaBeaconPacket += ":!";
|
|
||||||
|
|
||||||
String encodedGPS = encodeGPS(Config.beacon.latitude, Config.beacon.longitude, Config.beacon.overlay, Config.beacon.symbol);
|
String encodedGPS = encodeGPS(Config.beacon.latitude, Config.beacon.longitude, Config.beacon.overlay, Config.beacon.symbol);
|
||||||
iGateBeaconPacket += encodedGPS;
|
iGateBeaconPacket += encodedGPS;
|
||||||
iGateLoRaBeaconPacket += encodedGPS;
|
iGateLoRaBeaconPacket += encodedGPS;
|
||||||
|
|
@ -184,4 +207,19 @@ namespace GPS_Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
if (Config.beacon.gpsActive) {
|
||||||
|
gpsSerial.begin(GPS_BAUD, SERIAL_8N1, GPS_TX, GPS_RX);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
generateBeacons();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getData() {
|
||||||
|
while (gpsSerial.available() > 0) {
|
||||||
|
gps.encode(gpsSerial.read());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -5,16 +5,19 @@
|
||||||
|
|
||||||
|
|
||||||
namespace GPS_Utils {
|
namespace GPS_Utils {
|
||||||
|
|
||||||
String getiGateLoRaBeaconPacket();
|
String getiGateLoRaBeaconPacket();
|
||||||
char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
|
char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
|
||||||
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol);
|
String encodeGPS(float latitude, float longitude, const String& overlay, const String& symbol);
|
||||||
|
void generateBeaconFirstPart();
|
||||||
void generateBeacons();
|
void generateBeacons();
|
||||||
//double calculateDistanceCourse(double latitude, double longitude);
|
|
||||||
String decodeEncodedGPS(const String& packet);
|
String decodeEncodedGPS(const String& packet);
|
||||||
String getReceivedGPS(const String& packet);
|
String getReceivedGPS(const String& packet);
|
||||||
String getDistanceAndComment(const String& packet);
|
String getDistanceAndComment(const String& packet);
|
||||||
|
|
||||||
|
void setup();
|
||||||
|
void getData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "ntp_utils.h"
|
#include "ntp_utils.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
@ -14,7 +15,7 @@ NTPClient timeClient(ntpUDP, "pool.ntp.org", 0, 15 * 60 * 1000); // Update in
|
||||||
namespace NTP_Utils {
|
namespace NTP_Utils {
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
if (!Config.digi.ecoMode && Config.callsign != "NOCALL-10") {
|
if (WiFi.status() == WL_CONNECTED && !Config.digi.ecoMode && Config.callsign != "NOCALL-10") {
|
||||||
int gmt = Config.ntp.gmtCorrection * 3600;
|
int gmt = Config.ntp.gmtCorrection * 3600;
|
||||||
timeClient.setTimeOffset(gmt);
|
timeClient.setTimeOffset(gmt);
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
|
|
@ -22,7 +23,7 @@ namespace NTP_Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
if (!Config.digi.ecoMode && Config.callsign != "NOCALL-10") timeClient.update();
|
if (WiFi.status() == WL_CONNECTED && !Config.digi.ecoMode && Config.callsign != "NOCALL-10") timeClient.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getFormatedTime() {
|
String getFormatedTime() {
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,36 @@ namespace POWER_Utils {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void activateGPS() {
|
||||||
|
#ifdef HAS_AXP192
|
||||||
|
PMU.setLDO3Voltage(3300);
|
||||||
|
PMU.enableLDO3();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_AXP2101
|
||||||
|
PMU.setALDO3Voltage(3300);
|
||||||
|
PMU.enableALDO3();
|
||||||
|
#endif
|
||||||
|
#ifdef HELTEC_WIRELESS_TRACKER
|
||||||
|
digitalWrite(VEXT_CTRL, HIGH);
|
||||||
|
#endif
|
||||||
|
//gpsIsActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void deactivateGPS() {
|
||||||
|
#ifdef HAS_AXP192
|
||||||
|
PMU.disableLDO3();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_AXP2101
|
||||||
|
PMU.disableALDO3();
|
||||||
|
#endif
|
||||||
|
#ifdef HELTEC_WIRELESS_TRACKER
|
||||||
|
digitalWrite(VEXT_CTRL, LOW);
|
||||||
|
#endif
|
||||||
|
//gpsIsActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
void activateLoRa() {
|
void activateLoRa() {
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_AXP192
|
||||||
PMU.setLDO2Voltage(3300);
|
PMU.setLDO2Voltage(3300);
|
||||||
|
|
@ -159,6 +189,10 @@ namespace POWER_Utils {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
if (Config.beacon.gpsActive) activateGPS();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ADC_CTRL
|
#ifdef ADC_CTRL
|
||||||
pinMode(ADC_CTRL, OUTPUT);
|
pinMode(ADC_CTRL, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ namespace POWER_Utils {
|
||||||
double getBatteryVoltage();
|
double getBatteryVoltage();
|
||||||
bool isBatteryConnected();
|
bool isBatteryConnected();
|
||||||
void activateMeasurement();
|
void activateMeasurement();
|
||||||
|
void activateGPS();
|
||||||
|
void deactivateGPS();
|
||||||
void activateLoRa();
|
void activateLoRa();
|
||||||
void deactivateLoRa();
|
void deactivateLoRa();
|
||||||
bool begin(TwoWire &port);
|
bool begin(TwoWire &port);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <TinyGPS++.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "station_utils.h"
|
#include "station_utils.h"
|
||||||
|
|
@ -13,8 +14,10 @@
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
extern WiFiClient espClient;
|
extern WiFiClient espClient;
|
||||||
|
extern TinyGPSPlus gps;
|
||||||
extern String versionDate;
|
extern String versionDate;
|
||||||
extern String firstLine;
|
extern String firstLine;
|
||||||
extern String secondLine;
|
extern String secondLine;
|
||||||
|
|
@ -195,8 +198,20 @@ namespace Utils {
|
||||||
|
|
||||||
activeStations();
|
activeStations();
|
||||||
|
|
||||||
String beaconPacket = iGateBeaconPacket;
|
String beaconPacket = iGateBeaconPacket;
|
||||||
String secondaryBeaconPacket = iGateLoRaBeaconPacket;
|
String secondaryBeaconPacket = iGateLoRaBeaconPacket;
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
if (Config.beacon.gpsActive && !Config.digi.ecoMode) {
|
||||||
|
GPS_Utils::getData();
|
||||||
|
if (gps.location.isUpdated()) {
|
||||||
|
GPS_Utils::generateBeaconFirstPart();
|
||||||
|
String encodedGPS = GPS_Utils::encodeGPS(gps.location.lat(), gps.location.lng(), Config.beacon.overlay, Config.beacon.symbol);
|
||||||
|
beaconPacket = iGateBeaconPacket + encodedGPS;
|
||||||
|
secondaryBeaconPacket = iGateLoRaBeaconPacket + encodedGPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (Config.wxsensor.active && wxModuleType != 0) {
|
if (Config.wxsensor.active && wxModuleType != 0) {
|
||||||
String sensorData = WX_Utils::readDataSensor();
|
String sensorData = WX_Utils::readDataSensor();
|
||||||
beaconPacket += sensorData;
|
beaconPacket += sensorData;
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,9 @@ namespace WEB_Utils {
|
||||||
Config.beacon.symbol = request->getParam("beacon.symbol", true)->value();
|
Config.beacon.symbol = request->getParam("beacon.symbol", true)->value();
|
||||||
Config.beacon.path = request->getParam("beacon.path", true)->value();
|
Config.beacon.path = request->getParam("beacon.path", true)->value();
|
||||||
|
|
||||||
|
Config.beacon.gpsActive = request->hasParam("beacon.gpsActive", true);
|
||||||
|
Config.beacon.gpsAmbiguity = request->hasParam("beacon.gpsAmbiguity", true);
|
||||||
|
|
||||||
|
|
||||||
Config.digi.mode = request->getParam("digi.mode", true)->value().toInt();
|
Config.digi.mode = request->getParam("digi.mode", true)->value().toInt();
|
||||||
Config.digi.ecoMode = request->hasParam("digi.ecoMode", true);
|
Config.digi.ecoMode = request->hasParam("digi.ecoMode", true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue