mayor code cleaning
This commit is contained in:
parent
794cc0640f
commit
0be60b76b0
|
|
@ -345,9 +345,7 @@
|
|||
WiFi Access
|
||||
</h5>
|
||||
<small
|
||||
>Add all Wi-Fi Networks intended to be used,
|
||||
and their respective coordinates to
|
||||
georeference the iGate location.</small
|
||||
>Add all Wi-Fi Networks intended to be used.</small
|
||||
>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-12">
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ default_envs = ttgo-lora32-v21
|
|||
|
||||
[env]
|
||||
platform = espressif32 @ 6.3.1
|
||||
board_build.partitions = min_spiffs.csv
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
board_build.embed_files =
|
||||
|
|
|
|||
|
|
@ -37,41 +37,31 @@ ________________________________________________________________________________
|
|||
#include "A7670_utils.h"
|
||||
#endif
|
||||
|
||||
|
||||
String versionDate = "2024.05.14";
|
||||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
|
||||
String versionDate = "2024.05.13";
|
||||
uint8_t myWiFiAPIndex = 0;
|
||||
int myWiFiAPSize = Config.wifiAPs.size();
|
||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
||||
bool isUpdatingOTA = false;
|
||||
bool statusAfterBoot = true;
|
||||
bool beaconUpdate = true;
|
||||
uint32_t lastBeaconTx = 0;
|
||||
uint32_t previousWiFiMillis = 0;
|
||||
uint32_t lastScreenOn = millis();
|
||||
|
||||
uint32_t lastWiFiCheck = 0;
|
||||
bool WiFiConnect = true;
|
||||
bool WiFiConnected = false;
|
||||
|
||||
bool WiFiAutoAPStarted = false;
|
||||
long WiFiAutoAPTime = false;
|
||||
|
||||
uint32_t lastBatteryCheck = 0;
|
||||
|
||||
String batteryVoltage;
|
||||
|
||||
uint32_t lastTxTime = millis();
|
||||
uint32_t lastRxTime = millis();
|
||||
|
||||
std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
bool modemLoggedToAPRSIS = false;
|
||||
|
||||
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
||||
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine;
|
||||
|
||||
//#define STARTUP_DELAY 5 //min
|
||||
|
||||
|
|
@ -82,8 +72,7 @@ void setup() {
|
|||
Config.check();
|
||||
LoRa_Utils::setup();
|
||||
Utils::validateFreqs();
|
||||
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||
iGateLoRaBeaconPacket = GPS_Utils::generateiGateLoRaBeacon();
|
||||
GPS_Utils::generateBeacons();
|
||||
|
||||
#ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers
|
||||
show_display("", " STARTUP DELAY ...", "", "", 0);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,10 @@ extern String fourthLine;
|
|||
extern String fifthLine;
|
||||
extern String sixthLine;
|
||||
extern String seventhLine;
|
||||
|
||||
extern std::vector<String> outputPacketBuffer;
|
||||
extern uint32_t lastRxTime;
|
||||
|
||||
extern bool modemLoggedToAPRSIS;
|
||||
|
||||
uint32_t lastRxTime = millis();
|
||||
|
||||
#ifdef ESP32_DIY_LoRa_A7670
|
||||
extern bool stationBeacon;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@
|
|||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
#define CORRECTION_FACTOR (8.2296) // for meters
|
||||
|
||||
extern Configuration Config;
|
||||
extern String fifthLine;
|
||||
|
||||
float newHum, newTemp, newPress, newGas;
|
||||
extern Configuration Config;
|
||||
extern String fifthLine;
|
||||
|
||||
int wxModuleType = 0;
|
||||
uint8_t wxModuleAddress = 0x00;
|
||||
|
||||
float newHum, newTemp, newPress, newGas;
|
||||
|
||||
|
||||
Adafruit_BME280 bme280;
|
||||
Adafruit_BME680 bme680;
|
||||
#ifdef HELTEC_V3_GPS
|
||||
|
|
@ -23,7 +24,6 @@ Adafruit_BMP280 bmp280;
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
namespace BME_Utils {
|
||||
|
||||
void getWxModuleAddres() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "configuration.h"
|
||||
#include "display.h"
|
||||
|
||||
|
||||
void Configuration::check() {
|
||||
if (reload) {
|
||||
show_display("------- UPDATE ------", "config is old", "device will update", "and then reboot", 1000);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ extern String fifthLine;
|
|||
extern String sixthLine;
|
||||
extern String seventhLine;
|
||||
|
||||
extern std::vector<String> outputPacketBuffer;
|
||||
|
||||
|
||||
namespace DIGI_Utils {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
extern Configuration Config;
|
||||
extern WiFiClient espClient;
|
||||
String distance;
|
||||
String distance, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
||||
|
||||
|
||||
namespace GPS_Utils {
|
||||
|
|
@ -47,17 +47,14 @@ namespace GPS_Utils {
|
|||
return encodedData;
|
||||
}
|
||||
|
||||
String generateBeacon() {
|
||||
String beaconPacket = Config.callsign + ">APLRG1," + Config.beacon.path;
|
||||
|
||||
if (Config.aprs_is.active && Config.digi.mode == 0) { // If APRSIS enabled and Digi disabled
|
||||
beaconPacket += ",qAC";
|
||||
}
|
||||
return beaconPacket + ":!" + encodeGPS(Config.beacon.latitude, Config.beacon.longitude, Config.beacon.overlay, Config.beacon.symbol);;
|
||||
}
|
||||
|
||||
String generateiGateLoRaBeacon() {
|
||||
return Config.callsign + ">APLRG1," + Config.beacon.path + ":!" + encodeGPS(Config.beacon.latitude, Config.beacon.longitude, Config.beacon.overlay, Config.beacon.symbol);
|
||||
void generateBeacons() {
|
||||
String beaconPacket = Config.callsign + ">APLRG1";
|
||||
if (Config.beacon.path != "") {
|
||||
beaconPacket += "," + Config.beacon.path;
|
||||
}
|
||||
String encodedGPS = encodeGPS(Config.beacon.latitude, Config.beacon.longitude, Config.beacon.overlay, Config.beacon.symbol);
|
||||
iGateBeaconPacket = beaconPacket + ",qAC:!" + encodedGPS;
|
||||
iGateLoRaBeaconPacket = beaconPacket + ":!" + encodedGPS;
|
||||
}
|
||||
|
||||
double calculateDistanceTo(double latitude, double longitude) {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ namespace GPS_Utils {
|
|||
|
||||
char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
|
||||
String encodeGPS(float latitude, float longitude, String overlay, String symbol);
|
||||
String generateBeacon();
|
||||
String generateiGateLoRaBeacon();
|
||||
void generateBeacons();
|
||||
double calculateDistanceCourse(double latitude, double longitude);
|
||||
String decodeEncodedGPS(String packet);
|
||||
String getReceivedGPS(String packet);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
extern Configuration Config;
|
||||
extern uint32_t lastRxTime;
|
||||
|
||||
|
||||
extern std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
bool transmissionFlag = true;
|
||||
|
|
|
|||
|
|
@ -20,10 +20,6 @@ extern Configuration Config;
|
|||
|
||||
namespace POWER_Utils {
|
||||
|
||||
bool BatteryIsConnected = false;
|
||||
String batteryVoltage = "";
|
||||
String batteryChargeDischargeCurrent = "";
|
||||
|
||||
void activateMeasurement() {
|
||||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
PMU.disableTSPinMeasure();
|
||||
|
|
@ -138,7 +134,7 @@ namespace POWER_Utils {
|
|||
}
|
||||
|
||||
#ifdef VEXT_CTRL
|
||||
pinMode(VEXT_CTRL,OUTPUT); // this is for GPS and TFT screen on Wireless_Tracker and only for Oled in Heltec V3
|
||||
pinMode(VEXT_CTRL,OUTPUT); // GPS + TFT on HELTEC Wireless_Tracker and only for Oled in HELTEC V3
|
||||
digitalWrite(VEXT_CTRL, HIGH);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
#include "utils.h"
|
||||
#include <vector>
|
||||
|
||||
extern Configuration Config;
|
||||
extern uint32_t lastTxTime;
|
||||
extern uint32_t lastRxTime;
|
||||
extern String fourthLine;
|
||||
extern Configuration Config;
|
||||
extern uint32_t lastRxTime;
|
||||
extern String fourthLine;
|
||||
|
||||
uint32_t lastTxTime = millis();
|
||||
std::vector<String> lastHeardStation;
|
||||
std::vector<String> outputPacketBuffer;
|
||||
std::vector<String> packet25SegBuffer;
|
||||
|
|
@ -70,7 +70,6 @@ namespace STATION_Utils {
|
|||
String deltaTimeString = packet25SegBuffer[0].substring(0, packet25SegBuffer[0].indexOf(","));
|
||||
uint32_t deltaTime = deltaTimeString.toInt();
|
||||
if ((millis() - deltaTime) > 25 * 1000) {
|
||||
//Serial.print("Borrando : "); Serial.println(packet25SegBuffer[0]);
|
||||
packet25SegBuffer.erase(packet25SegBuffer.begin());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include "utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
extern std::vector<String> outputPacketBuffer;
|
||||
|
||||
#define MAX_CLIENTS 4
|
||||
#define INPUT_BUFFER_SIZE (2 + MAX_CLIENTS)
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@
|
|||
#include "display.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern WiFiClient espClient;
|
||||
extern Configuration Config;
|
||||
extern WiFiClient espClient;
|
||||
extern String versionDate;
|
||||
extern bool statusAfterBoot;
|
||||
extern String firstLine;
|
||||
extern String secondLine;
|
||||
extern String thirdLine;
|
||||
|
|
@ -23,9 +22,7 @@ extern String fourthLine;
|
|||
extern String fifthLine;
|
||||
extern String sixthLine;
|
||||
extern String seventhLine;
|
||||
extern uint32_t lastBeaconTx;
|
||||
extern uint32_t lastScreenOn;
|
||||
extern bool beaconUpdate;
|
||||
extern String iGateBeaconPacket;
|
||||
extern String iGateLoRaBeaconPacket;
|
||||
extern std::vector<String> lastHeardStation;
|
||||
|
|
@ -38,6 +35,10 @@ extern bool WiFiConnect;
|
|||
extern bool WiFiConnected;
|
||||
extern int wxModuleType;
|
||||
|
||||
bool statusAfterBoot = true;
|
||||
bool beaconUpdate = true;
|
||||
uint32_t lastBeaconTx = 0;
|
||||
|
||||
|
||||
namespace Utils {
|
||||
|
||||
|
|
@ -169,14 +170,14 @@ namespace Utils {
|
|||
|
||||
void checkWiFiInterval() {
|
||||
uint32_t WiFiCheck = millis() - lastWiFiCheck;
|
||||
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15*60*1000) {
|
||||
WiFiConnect = true;
|
||||
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
|
||||
WiFiConnect = true;
|
||||
}
|
||||
if (WiFiConnect) {
|
||||
Serial.println("\nConnecting to WiFi ...");
|
||||
WIFI_Utils::startWiFi();
|
||||
lastWiFiCheck = millis();
|
||||
WiFiConnect = false;
|
||||
Serial.println("\nConnecting to WiFi ...");
|
||||
WIFI_Utils::startWiFi();
|
||||
lastWiFiCheck = millis();
|
||||
WiFiConnect = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include "utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
|
||||
extern uint32_t lastBeaconTx;
|
||||
extern std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ extern bool WiFiAutoAPStarted;
|
|||
namespace WIFI_Utils {
|
||||
|
||||
void checkWiFi() {
|
||||
if ((WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30*1000) && !WiFiAutoAPStarted) {
|
||||
if ((WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) {
|
||||
Serial.print(millis());
|
||||
Serial.println("Reconnecting to WiFi...");
|
||||
WiFi.disconnect();
|
||||
|
|
|
|||
Loading…
Reference in New Issue