starting with library test

This commit is contained in:
richonguzman 2023-11-04 13:12:58 -03:00
parent 236437532f
commit 47283e8e57
5 changed files with 46 additions and 16 deletions

View File

@ -0,0 +1,23 @@
#include "APRSPacketLib.h"
namespace APRSPacketLib {
String generateStatusPacket(String callsign, String tocall, String path, String status) {
String packet = callsign + ">" + tocall;
if (path != "") {
packet += "," + path;
}
packet += ":>" + status;
return packet;
}
String generateGPSBeaconPacket(String callsign, String tocall, String path, String overlay, String gps) {
String packet = callsign + ">" + tocall;
if (path != "") {
packet += "," + path;
}
packet += ":!" + overlay + gps;
return packet;
}
}

View File

@ -0,0 +1,13 @@
#ifndef APRSPACKETLIB_H
#define APRSPACKETLIB_H
#include <Arduino.h>
namespace APRSPacketLib {
String generateStatusPacket(String callsign, String tocall, String path, String status);
String generateGPSBeaconPacket(String callsign, String tocall, String path, String overlay, String gpsData);
}
#endif

View File

@ -23,6 +23,8 @@
#include "SPIFFS.h"
#include "utils.h"
#include "APRSPacketLib.h"
Configuration Config;
PowerManagement powerManagement;
@ -31,7 +33,7 @@ TinyGPSPlus gps;
BluetoothSerial SerialBT;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
String versionDate = "2023.10.24";
String versionDate = "2023.11.04";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();

View File

@ -12,6 +12,8 @@
#include "logger.h"
#include "utils.h"
#include "APRSPacketLib.h"
extern Configuration Config;
extern Beacon *currentBeacon;
extern logging::Logger logger;
@ -387,18 +389,12 @@ namespace STATION_Utils {
}
void sendBeacon(String type) {
String packet = currentBeacon->callsign + ">APLRT1";
if (Config.path != "") {
packet += "," + Config.path;
}
packet += ":!";
String packet;
if (Config.bme.sendTelemetry && type == "Wx") {
packet += "/";
packet += GPS_Utils::encondeGPS("Wx");
packet = APRSPacketLib::generateGPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, "/", GPS_Utils::encondeGPS("Wx"));
packet += BME_Utils::readDataSensor("APRS");
} else {
packet += currentBeacon->overlay;
packet += GPS_Utils::encondeGPS("GPS");
packet = APRSPacketLib::generateGPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, currentBeacon->overlay, GPS_Utils::encondeGPS("GPS"));
}
if (currentBeacon->comment != "") {

View File

@ -2,6 +2,7 @@
#include "lora_utils.h"
#include "display.h"
#include "utils.h"
#include "APRSPacketLib.h"
extern Beacon *currentBeacon;
extern Configuration Config;
@ -89,12 +90,7 @@ namespace utils {
lastTx = millis() - lastTxTime;
uint32_t statusTx = millis() - statusTime;
if (statusTx > 15*60*1000 && lastTx > 10*1000) {
String packet = currentBeacon->callsign + ">APLRT1";
if (Config.path != "") {
packet += "," + Config.path;
}
packet += ":>https://github.com/richonguzman/LoRa_APRS_Tracker " + versionDate;
LoRa_Utils::sendNewPacket(packet);
LoRa_Utils::sendNewPacket(APRSPacketLib::generateStatusPacket(currentBeacon->callsign, "APLRT1", Config.path, "https://github.com/richonguzman/LoRa_APRS_Tracker " + versionDate));
statusState = false;
lastTx = millis();
}