diff --git a/data/tracker_config.json b/data/tracker_config.json index 0c7b0f7..bda7ee2 100644 --- a/data/tracker_config.json +++ b/data/tracker_config.json @@ -1,7 +1,7 @@ { "beacons": [ { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": "[", "overlay": "/", "comment": "", @@ -18,7 +18,7 @@ } }, { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": ">", "overlay": "/", "comment": "", @@ -35,7 +35,7 @@ } }, { - "callsign": "NOCALL-7", + "callsign": "CD2RXU-6", "symbol": "j", "overlay": "/", "comment": "", @@ -83,20 +83,22 @@ "reverse": false }, "bme": { - "active": false + "active": true, + "sendTelemetry": true, + "heightCorrection": 0 }, "notification": { - "ledTx": true, + "ledTx": false, "ledTxPin": 13, - "ledMessage": true, + "ledMessage": false, "ledMessagePin": 2, - "buzzerActive": true, + "buzzerActive": false, "buzzerPinTone": 33, "buzzerPinVcc": 25, - "bootUpBeep": true, - "txBeep": true, - "messageRxBeep": true, - "stationBeep": true, - "lowBatteryBeep": true + "bootUpBeep": false, + "txBeep": false, + "messageRxBeep": false, + "stationBeep": false, + "lowBatteryBeep": false } } \ No newline at end of file diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 7962c68..975f2d2 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -30,7 +30,7 @@ TinyGPSPlus gps; BluetoothSerial SerialBT; OneButton userButton = OneButton(BUTTON_PIN, true, true); -String versionDate = "2023.09.26"; +String versionDate = "2023.09.29"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -57,6 +57,9 @@ bool messageLed = false; uint32_t messageLedTime = millis(); int lowBatteryPercent = 21; +uint32_t lastTelemetryTx = millis(); +uint32_t telemetryTx = millis(); + uint32_t lastTx = 0.0; uint32_t txInterval = 60000L; uint32_t lastTxTime = millis(); @@ -148,6 +151,10 @@ void loop() { int currentSpeed = (int) gps.speed.kmph(); lastTx = millis() - lastTxTime; + if (gps_loc_update) { + utils::checkStatus(); + STATION_Utils::checkTelemetryTx(); + } if (!sendUpdate && gps_loc_update && currentBeacon->smartBeaconState) { GPS_Utils::calculateDistanceTraveled(); if (!sendUpdate) { @@ -157,14 +164,12 @@ void loop() { } STATION_Utils::checkSmartBeaconState(); if (sendUpdate && gps_loc_update) { - STATION_Utils::sendBeacon(); + STATION_Utils::sendBeacon("GPS"); } if (gps_time_update) { STATION_Utils::checkSmartBeaconInterval(currentSpeed); } - if (gps_loc_update) { - utils::checkStatus(); - } + if (millis() - refreshDisplayTime >= 1000 || gps_time_update) { GPS_Utils::checkStartUpFrames(); MENU_Utils::showOnScreen(); diff --git a/src/bme_utils.cpp b/src/bme_utils.cpp index 0448b80..d86d311 100644 --- a/src/bme_utils.cpp +++ b/src/bme_utils.cpp @@ -5,8 +5,7 @@ #include #define SEALEVELPRESSURE_HPA (1013.25) -#define HEIGHT_CORRECTION 0 // in meters -#define CORRECTION_FACTOR (8.2296) // for meters +#define CORRECTION_FACTOR (8.2296) // for each meter extern Configuration Config; extern logging::Logger logger; @@ -149,7 +148,7 @@ namespace BME_Utils { } else { tempStr = generateTempString(newTemp, type); humStr = generateHumString(newHum, type); - presStr = generatePresString(newPress + (HEIGHT_CORRECTION/CORRECTION_FACTOR), type); + presStr = generatePresString(newPress + (Config.bme.heightCorrection/CORRECTION_FACTOR), type); if (type == "OLED") { wx = tempStr + "C " + humStr + "% " + presStr + "hPa"; } else { diff --git a/src/configuration.cpp b/src/configuration.cpp index 2163445..a131a43 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -58,6 +58,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { ptt.reverse = data["pttTrigger"]["reverse"].as(); bme.active = data["bme"]["active"].as(); + bme.sendTelemetry = data["bme"]["sendTelemetry"].as(); + bme.heightCorrection = data["bme"]["heightCorrection"].as(); notification.ledTx = data["notification"]["ledTx"].as(); notification.ledTxPin = data["notification"]["ledTxPin"].as(); diff --git a/src/configuration.h b/src/configuration.h index d261f96..4715ec2 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -43,6 +43,8 @@ public: class BME { public: bool active; + bool sendTelemetry; + int heightCorrection; }; class Notification { diff --git a/src/gps_utils.cpp b/src/gps_utils.cpp index b5034d6..8801b9e 100644 --- a/src/gps_utils.cpp +++ b/src/gps_utils.cpp @@ -160,7 +160,7 @@ namespace GPS_Utils { } } - String encondeGPS() { + String encondeGPS(String type) { String encodedData; float Tlat, Tlon; float Tspeed=0, Tcourse=0; @@ -192,8 +192,11 @@ namespace GPS_Utils { for (i=0; i<4; i++) { encodedData += helper_base91[i]; } - - encodedData += currentBeacon->symbol; + if (type=="Wx") { + encodedData += "_"; + } else { + encodedData += currentBeacon->symbol; + } if (Config.sendAltitude) { // Send Altitude or... (APRS calculates Speed also) int Alt1, Alt2; diff --git a/src/gps_utils.h b/src/gps_utils.h index d7c7a9f..afe1eb7 100644 --- a/src/gps_utils.h +++ b/src/gps_utils.h @@ -14,7 +14,7 @@ void setDateFromData(); void calculateDistanceTraveled(); void calculateHeadingDelta(int speed); void checkStartUpFrames(); -String encondeGPS(); +String encondeGPS(String type); } diff --git a/src/menu_utils.cpp b/src/menu_utils.cpp index d24fa3c..5fae5d0 100644 --- a/src/menu_utils.cpp +++ b/src/menu_utils.cpp @@ -122,9 +122,6 @@ namespace MENU_Utils { fourthRowMainMenu = "A=" + fourthRowAlt + "m " + fourthRowSpeed + "km/h " + fourthRowCourse; } else { fourthRowMainMenu = BME_Utils::readDataSensor("OLED"); - // - Serial.println(BME_Utils::readDataSensor("APRS")); - // } } else { fourthRowMainMenu = "A=" + fourthRowAlt + "m " + fourthRowSpeed + "km/h " + fourthRowCourse; diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 008d221..5690416 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -6,6 +6,7 @@ #include "power_utils.h" #include "lora_utils.h" #include "msg_utils.h" +#include "bme_utils.h" #include "gps_utils.h" #include "display.h" #include "logger.h" @@ -29,6 +30,9 @@ extern String fourthNearTracker; extern uint32_t lastDeleteListenedTracker; extern uint32_t lastTxTime; +extern uint32_t telemetryTx; +extern uint32_t lastTelemetryTx; + extern bool sendUpdate; extern int updateCounter; extern bool sendStandingUpdate; @@ -62,7 +66,6 @@ namespace STATION_Utils { return String(fourthNearTracker.substring(0,fourthNearTracker.indexOf(","))); } - void deleteListenedTrackersbyTime() { String firstNearTrackermillis, secondNearTrackermillis, thirdNearTrackermillis, fourthNearTrackermillis; uint32_t firstTrackermillis, secondTrackermillis, thirdTrackermillis, fourthTrackermillis; @@ -382,13 +385,20 @@ namespace STATION_Utils { } } - void sendBeacon() { + void sendBeacon(String type) { String packet = currentBeacon->callsign + ">APLRT1"; if (Config.path != "") { packet += "," + Config.path; } - packet += ":!" + currentBeacon->overlay; - packet += GPS_Utils::encondeGPS(); + packet += ":!"; + if (Config.bme.sendTelemetry && type == "Wx") { + packet += "L"; + packet += GPS_Utils::encondeGPS("Wx"); + packet += BME_Utils::readDataSensor("APRS"); + } else { + packet += currentBeacon->overlay; + packet += GPS_Utils::encondeGPS("GPS"); + } if (currentBeacon->comment != "") { updateCounter++; @@ -423,6 +433,16 @@ namespace STATION_Utils { sendUpdate = false; } + void checkTelemetryTx() { + if (Config.bme.active && Config.bme.sendTelemetry) { + telemetryTx = millis() - lastTelemetryTx; + if (telemetryTx > 10*60*1000 && lastTx > 10*1000) { + sendBeacon("Wx"); + lastTelemetryTx = millis(); + } + } + } + void saveCallsingIndex(int index) { File fileCallsignIndex = SPIFFS.open("/callsignIndex.txt", "w"); if(!fileCallsignIndex){ diff --git a/src/station_utils.h b/src/station_utils.h index 066d86f..3c46f54 100644 --- a/src/station_utils.h +++ b/src/station_utils.h @@ -16,7 +16,8 @@ void orderListenedTrackersByDistance(String callsign, float distance, float cour void checkSmartBeaconInterval(int speed); void checkStandingUpdateTime(); void checkSmartBeaconState(); -void sendBeacon(); +void sendBeacon(String type); +void checkTelemetryTx(); void saveCallsingIndex(int index); void loadCallsignIndex(); diff --git a/src/utils.cpp b/src/utils.cpp index 0dc711f..81857de 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -7,6 +7,7 @@ extern Beacon *currentBeacon; extern Configuration Config; extern bool statusState; extern uint32_t statusTime; +extern uint32_t lastTx; extern bool displayEcoMode; extern uint32_t displayTime; @@ -85,7 +86,7 @@ namespace utils { void checkStatus() { if (statusState) { uint32_t statusTx = millis() - statusTime; - if (statusTx > 15*60*1000) { + if (statusTx > 15*60*1000 && lastTx > 10*1000) { String packet = currentBeacon->callsign + ">APLRT1"; if (Config.path != "") { packet += "," + Config.path; @@ -93,6 +94,7 @@ namespace utils { packet += ":>https://github.com/richonguzman/LoRa_APRS_Tracker " + versionDate; LoRa_Utils::sendNewPacket(packet); statusState = false; + lastTx = millis(); } } }