HT_CT_62 beaconPacket fix

This commit is contained in:
richonguzman 2024-05-14 09:23:22 -04:00
parent dc39eec941
commit 630ec062c1
3 changed files with 9 additions and 31 deletions

View File

@ -83,66 +83,39 @@ void setup() {
if (Config.lowPowerMode) { if (Config.lowPowerMode) {
gpio_wakeup_enable(GPIO_NUM_3, GPIO_INTR_HIGH_LEVEL); gpio_wakeup_enable(GPIO_NUM_3, GPIO_INTR_HIGH_LEVEL);
esp_deep_sleep_enable_gpio_wakeup(GPIO_NUM_3, ESP_GPIO_WAKEUP_GPIO_HIGH); esp_deep_sleep_enable_gpio_wakeup(GPIO_NUM_3, ESP_GPIO_WAKEUP_GPIO_HIGH);
long lastBeacon = 0; long lastBeacon = 0;
LoRa_Utils::startReceive(); LoRa_Utils::startReceive();
while (true) { while (true) {
auto wakeup_reason = esp_sleep_get_wakeup_cause(); auto wakeup_reason = esp_sleep_get_wakeup_cause();
if (wakeup_reason == 7) { // packet received if (wakeup_reason == 7) { // packet received
Serial.println("Received packet"); Serial.println("Received packet");
String packet = LoRa_Utils::receivePacket(); String packet = LoRa_Utils::receivePacket();
Serial.println(packet); Serial.println(packet);
if (Config.digi.mode == 2) DIGI_Utils::processLoRaPacket(packet);
if (Config.digi.mode == 2) { // If Digi enabled
DIGI_Utils::processLoRaPacket(packet); // Send received packet to Digi
}
if (packet.indexOf(Config.callsign + ":?APRSELP{") != -1) { // Send `?APRSELP` to exit low power if (packet.indexOf(Config.callsign + ":?APRSELP{") != -1) { // Send `?APRSELP` to exit low power
Serial.println("Got ?APRSELP message, exiting from low power mode"); Serial.println("Got ?APRSELP message, exiting from low power mode");
break; break;
}; };
} }
long time = esp_timer_get_time() / 1000000; long time = esp_timer_get_time() / 1000000;
if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) { if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) {
Serial.println("Sending beacon"); Serial.println("Sending beacon");
String comment = Config.beacon.comment; String comment = Config.beacon.comment;
if (Config.sendBatteryVoltage) comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
if (Config.sendBatteryVoltage) { if (Config.externalVoltageMeasurement) comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
comment += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; STATION_Utils::addToOutputPacketBuffer(GPS_Utils::getiGateLoRaBeaconPacket() + comment);
}
if (Config.externalVoltageMeasurement) {
comment += " Ext=" + String(BATTERY_Utils::checkExternalVoltage(),2) + "V";
}
STATION_Utils::addToOutputPacketBuffer(iGateLoRaBeaconPacket + comment);
//LoRa_Utils::sendNewPacket("APRS", iGateLoRaBeaconPacket + comment);
lastBeacon = time; lastBeacon = time;
} }
LoRa_Utils::startReceive(); LoRa_Utils::startReceive();
Serial.println("Sleeping"); Serial.println("Sleeping");
long sleep = (Config.beacon.interval * 60) - (time - lastBeacon); long sleep = (Config.beacon.interval * 60) - (time - lastBeacon);
Serial.flush(); Serial.flush();
esp_sleep_enable_timer_wakeup(sleep * 1000000); esp_sleep_enable_timer_wakeup(sleep * 1000000);
esp_light_sleep_start(); esp_light_sleep_start();
Serial.println("Waked up"); Serial.println("Waked up");
} }
Config.loramodule.rxActive = false; Config.loramodule.rxActive = false;
} }
#endif #endif

View File

@ -10,6 +10,10 @@ String distance, iGateBeaconPacket, iGateLoRaBeaconPacket;
namespace GPS_Utils { namespace GPS_Utils {
String getiGateLoRaBeaconPacket() {
return iGateLoRaBeaconPacket;
}
char *ax25_base91enc(char *s, uint8_t n, uint32_t v) { char *ax25_base91enc(char *s, uint8_t n, uint32_t v) {
for(s += n, *s = '\0'; n; n--) { for(s += n, *s = '\0'; n; n--) {
*(--s) = v % 91 + 33; *(--s) = v % 91 + 33;

View File

@ -6,6 +6,7 @@
namespace GPS_Utils { namespace GPS_Utils {
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, String overlay, String symbol); String encodeGPS(float latitude, float longitude, String overlay, String symbol);
void generateBeacons(); void generateBeacons();