From 630ec062c16f0755752b4dfee0d331546c71f403 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 14 May 2024 09:23:22 -0400 Subject: [PATCH] HT_CT_62 beaconPacket fix --- src/LoRa_APRS_iGate.cpp | 35 ++++------------------------------- src/gps_utils.cpp | 4 ++++ src/gps_utils.h | 1 + 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index a89f73b..2e1736a 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -83,66 +83,39 @@ void setup() { if (Config.lowPowerMode) { gpio_wakeup_enable(GPIO_NUM_3, GPIO_INTR_HIGH_LEVEL); esp_deep_sleep_enable_gpio_wakeup(GPIO_NUM_3, ESP_GPIO_WAKEUP_GPIO_HIGH); - long lastBeacon = 0; - LoRa_Utils::startReceive(); - while (true) { auto wakeup_reason = esp_sleep_get_wakeup_cause(); - if (wakeup_reason == 7) { // packet received Serial.println("Received packet"); - String packet = LoRa_Utils::receivePacket(); - Serial.println(packet); - - if (Config.digi.mode == 2) { // If Digi enabled - DIGI_Utils::processLoRaPacket(packet); // Send received packet to Digi - } + if (Config.digi.mode == 2) DIGI_Utils::processLoRaPacket(packet); if (packet.indexOf(Config.callsign + ":?APRSELP{") != -1) { // Send `?APRSELP` to exit low power Serial.println("Got ?APRSELP message, exiting from low power mode"); break; }; } - long time = esp_timer_get_time() / 1000000; - if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) { Serial.println("Sending beacon"); - String comment = Config.beacon.comment; - - if (Config.sendBatteryVoltage) { - comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; - } - - if (Config.externalVoltageMeasurement) { - comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V"; - } - - STATION_Utils::addToOutputPacketBuffer(iGateLoRaBeaconPacket + comment); - //LoRa_Utils::sendNewPacket("APRS", iGateLoRaBeaconPacket + comment); - + if (Config.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; + if (Config.externalVoltageMeasurement) comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V"; + STATION_Utils::addToOutputPacketBuffer(GPS_Utils::getiGateLoRaBeaconPacket() + comment); lastBeacon = time; } LoRa_Utils::startReceive(); - Serial.println("Sleeping"); - long sleep = (Config.beacon.interval * 60) - (time - lastBeacon); - Serial.flush(); - esp_sleep_enable_timer_wakeup(sleep * 1000000); esp_light_sleep_start(); - Serial.println("Waked up"); } - Config.loramodule.rxActive = false; } #endif diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index 0494821..cae403e 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -10,6 +10,10 @@ String distance, iGateBeaconPacket, iGateLoRaBeaconPacket; namespace GPS_Utils { + String getiGateLoRaBeaconPacket() { + return iGateLoRaBeaconPacket; + } + char *ax25_base91enc(char *s, uint8_t n, uint32_t v) { for(s += n, *s = '\0'; n; n--) { *(--s) = v % 91 + 33; diff --git a/src/gps_utils.h b/src/gps_utils.h index 8c8ae3e..d90586c 100644 --- a/src/gps_utils.h +++ b/src/gps_utils.h @@ -6,6 +6,7 @@ namespace GPS_Utils { + String getiGateLoRaBeaconPacket(); char *ax25_base91enc(char *s, uint8_t n, uint32_t v); String encodeGPS(float latitude, float longitude, String overlay, String symbol); void generateBeacons();