first test for Wx telemetry in tracker

This commit is contained in:
richonguzman 2023-09-29 01:13:03 -03:00
parent 9bc07aad0d
commit f8a9238c2e
11 changed files with 66 additions and 33 deletions

View File

@ -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
}
}

View File

@ -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();

View File

@ -5,8 +5,7 @@
#include <logger.h>
#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 {

View File

@ -58,6 +58,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
ptt.reverse = data["pttTrigger"]["reverse"].as<bool>();
bme.active = data["bme"]["active"].as<bool>();
bme.sendTelemetry = data["bme"]["sendTelemetry"].as<bool>();
bme.heightCorrection = data["bme"]["heightCorrection"].as<int>();
notification.ledTx = data["notification"]["ledTx"].as<bool>();
notification.ledTxPin = data["notification"]["ledTxPin"].as<int>();

View File

@ -43,6 +43,8 @@ public:
class BME {
public:
bool active;
bool sendTelemetry;
int heightCorrection;
};
class Notification {

View File

@ -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;

View File

@ -14,7 +14,7 @@ void setDateFromData();
void calculateDistanceTraveled();
void calculateHeadingDelta(int speed);
void checkStartUpFrames();
String encondeGPS();
String encondeGPS(String type);
}

View File

@ -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;

View File

@ -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){

View File

@ -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();

View File

@ -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();
}
}
}