change beacon 2.0

This commit is contained in:
richonguzman 2023-01-28 19:54:42 -03:00
parent 818d7a422c
commit 72414cd40d
5 changed files with 127 additions and 51 deletions

View File

@ -15,7 +15,10 @@ Achievements:
- custom smartbeacon values for each CALLSIGN - custom smartbeacon values for each CALLSIGN
- force Tx with the "short" push of a button. - force Tx with the "short" push of a button.
- send enconded GPS data packet for shorter and realiable comunication. - send enconded GPS data packet for shorter and realiable comunication.
- To add (shortly) working on it - Select to send "Course + Speed" or "Altitude + Speed" in encoded APRS data packet
To add (shortly) working on it
- turn_slope for course angle smartbeacon - turn_slope for course angle smartbeacon
- oled screen (allready bought ... and waiting.. ) - oled screen (allready bought ... and waiting.. )

View File

@ -14,8 +14,7 @@ https://github.com/sh123/esp32_loraprs
#include <RadioLib.h> #include <RadioLib.h>
#include <WiFi.h> #include <WiFi.h>
#include <OneButton.h> #include <OneButton.h>
#include "user_config.h" #include "pins_config.h"
#include "pins.h"
#include "lora_config.h" #include "lora_config.h"
#include "beacon_config.h" #include "beacon_config.h"
@ -26,8 +25,23 @@ HardwareSerial neo6m_gps(1);
TinyGPSPlus gps; TinyGPSPlus gps;
OneButton UserButton1 = OneButton(BUTTON1_PIN, true, true); OneButton UserButton1 = OneButton(BUTTON1_PIN, true, true);
String CurrentUser[10];
static bool send_update = true; static bool send_update = true;
String CALLSIGN_CONFIG_1[10] = {User1_Callsign,User1_Symbol,String(User1_SlowRate),String(User1_SlowSpeed),
String(User1_FastRate),String(User1_FastSpeed),String(User1_MinDistTx),
String(User1_MinDeltaBcn),String(User1_TurnMin),String(User1_TurnSlope)};
String CALLSIGN_CONFIG_2[10] = {User2_Callsign,User2_Symbol,String(User2_SlowRate),String(User2_SlowSpeed),
String(User2_FastRate),String(User2_FastSpeed),String(User2_MinDistTx),
String(User2_MinDeltaBcn),String(User2_TurnMin),String(User2_TurnSlope)};
String CALLSIGN_CONFIG_3[10] = {User3_Callsign,User3_Symbol,String(User3_SlowRate),String(User3_SlowSpeed),
String(User3_FastRate),String(User3_FastSpeed),String(User3_MinDistTx),
String(User3_MinDeltaBcn),String(User3_TurnMin),String(User3_TurnSlope)};
void setup_lora_module() { void setup_lora_module() {
int state = radio.begin(LoraFreqTx, LoraBandWidth, LoraSpreadingFactor, LoraCodingRate, LoraSyncWord, LoraOutro, LoraPreampbleLenght); int state = radio.begin(LoraFreqTx, LoraBandWidth, LoraSpreadingFactor, LoraCodingRate, LoraSyncWord, LoraOutro, LoraPreampbleLenght);
radio.setOutputPower(Lora_Power); radio.setOutputPower(Lora_Power);
@ -44,24 +58,58 @@ void setup_gps_module() {
neo6m_gps.begin(9600, SERIAL_8N1, GPS_TXD, GPS_RXD); neo6m_gps.begin(9600, SERIAL_8N1, GPS_TXD, GPS_RXD);
} }
void setup_first_user() {
for (int i = 0; i<10; i++ ) {
CurrentUser[i] = CALLSIGN_CONFIG_1[i];
}
Serial.print("Current User --> ");
Serial.println(CurrentUser[0]);
}
static void ForcedBeaconTx() { static void ForcedBeaconTx() {
Serial.println("Forced Beacon Tx"); Serial.println("Forced Beacon Tx");
send_update = true; send_update = true;
} }
static void HandleNextBeacon() {
if (CurrentUser[0] == CALLSIGN_CONFIG_1[0]){
Serial.print("Changing CALLSIGN to --> ");
Serial.println(CALLSIGN_CONFIG_2[0]);
for (int i = 0; i<10; i++ ) {
CurrentUser[i] = CALLSIGN_CONFIG_2[i];
}
} else if (CurrentUser[0] == CALLSIGN_CONFIG_2[0]){
Serial.print("Changing CALLSIGN to --> ");
Serial.println(CALLSIGN_CONFIG_3[0]);
for (int i = 0; i<10; i++ ) {
CurrentUser[i] = CALLSIGN_CONFIG_3[i];
}
} else if (CurrentUser[0] == CALLSIGN_CONFIG_3[0]){
Serial.print("Changing CALLSIGN to --> ");
Serial.println(CALLSIGN_CONFIG_1[0]);
for (int i = 0; i<10; i++ ) {
CurrentUser[i] = CALLSIGN_CONFIG_1[i];
}
}
}
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println(F("LoRa tracker " __DATE__ " " __TIME__ " / Callsign ------> " SRC_CALLSIGN));
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_BUILTIN, LOW);
setup_lora_module();
setup_gps_module();
UserButton1.attachClick(ForcedBeaconTx);
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
btStop(); btStop();
Serial.print("Version = "); UserButton1.attachClick(ForcedBeaconTx);
UserButton1.attachLongPressStart(HandleNextBeacon);
Serial.println("");
Serial.println("****** LoRa APRS Tracker ******");
Serial.println("https://github.com/richonguzman/LoRa_1W_APRS_Tracker");
Serial.print("Version -------> ");
Serial.println(VERSION); Serial.println(VERSION);
Serial.println("Transmission Start ---->"); setup_first_user();
setup_lora_module();
setup_gps_module();
Serial.println("---Transmission Start ---");
} }
uint8_t tx_buffer[256]; uint8_t tx_buffer[256];
@ -97,9 +145,14 @@ void loop() {
//static int speed_zero_sent = 0; //static int speed_zero_sent = 0;
if (!send_update && gps_loc_update) { if (!send_update && gps_loc_update) {
uint32_t lastTx = millis() - lastTxTime; uint32_t lastTx = millis() - lastTxTime;
currentHeading = gps.course.deg(); int MinimumDistanceTx = CurrentUser[6].toInt();
lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLatitude, lastTxLongitude); int MinimumTimeDeltaBeacon = CurrentUser[7].toInt();
int TurnDegrees = CurrentUser[8].toInt();
int TurnSlope = CurrentUser[9].toInt();
currentHeading = gps.course.deg();
lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLatitude, lastTxLongitude);
if (lastTx >= txInterval) { if (lastTx >= txInterval) {
if (lastTxDistance > MinimumDistanceTx) { if (lastTxDistance > MinimumDistanceTx) {
send_update = true; send_update = true;
@ -137,7 +190,7 @@ void loop() {
if(Tlon < 0) { Tlon= -Tlon; } if(Tlon < 0) { Tlon= -Tlon; }
String AprsPacketMsg = "!"; String AprsPacketMsg = "!";
AprsPacketMsg += "/"; AprsPacketMsg += AprsOverlay;
char helper_base91[] = {"0000\0"}; char helper_base91[] = {"0000\0"};
int i; int i;
ax25_base91enc(helper_base91, 4, aprs_lat); ax25_base91enc(helper_base91, 4, aprs_lat);
@ -149,7 +202,7 @@ void loop() {
AprsPacketMsg += helper_base91[i]; AprsPacketMsg += helper_base91[i];
} }
AprsPacketMsg += SYMBOL; AprsPacketMsg += CurrentUser[1]; // Symbol
if (SendAltitude) { // Send Altitude or... (APRS calculates Speed also) if (SendAltitude) { // Send Altitude or... (APRS calculates Speed also)
int Alt1, Alt2; int Alt1, Alt2;
@ -186,7 +239,7 @@ void loop() {
memset(tx_buffer, 0x00, sizeof tx_buffer); memset(tx_buffer, 0x00, sizeof tx_buffer);
uint16_t size = 0; uint16_t size = 0;
size = snprintf(reinterpret_cast<char *>(tx_buffer), sizeof tx_buffer, "\x3c\xff\x01%s>%s:%s", SRC_CALLSIGN, DST_CALLSIGN, AprsPacketMsg.c_str()); size = snprintf(reinterpret_cast<char *>(tx_buffer), sizeof tx_buffer, "\x3c\xff\x01%s>%s:%s", CurrentUser[0], AprsPath, AprsPacketMsg.c_str());
Serial.print(millis()); // Only for Serial Monitor Serial.print(millis()); // Only for Serial Monitor
Serial.print(F(" transmitting: ")); Serial.print(F(" transmitting: "));
@ -206,6 +259,11 @@ void loop() {
} }
if (gps_time_update) { // updating txInterval between Slow and FastRate or in between if (gps_time_update) { // updating txInterval between Slow and FastRate or in between
int SlowRate = CurrentUser[2].toInt();
int SlowSpeed = CurrentUser[3].toInt();
int FastRate = CurrentUser[4].toInt();
int FastSpeed = CurrentUser[5].toInt();
int curr_speed = (int)gps.speed.kmph(); int curr_speed = (int)gps.speed.kmph();
if (curr_speed < SlowSpeed) { if (curr_speed < SlowSpeed) {
txInterval = SlowRate * 1000; txInterval = SlowRate * 1000;

View File

@ -1,31 +1,55 @@
#ifndef BEACON_CONFIG_H_ #ifndef BEACON_CONFIG_H_
#define BEACON_CONFIG_H_ #define BEACON_CONFIG_H_
#define SlowRate 120 // Seg //#define SlowRate 120 // Seg
#define SlowSpeed 10 // Km/h (3 Runner , 5 Bike, 10 Car) //#define SlowSpeed 10 // Km/h (3 Runner , 5 Bike, 10 Car)
#define FastRate 60 // Seg //#define FastRate 60 // Seg
#define FastSpeed 20 // Km/h (20 Runner y Bike, 70 Car) //#define FastSpeed 20 // Km/h (20 Runner y Bike, 70 Car)
#define TurnDegrees 20 // Degrees before Forced Beacon Tx (20 Car , 15 Bike/Runner) //#define TurnDegrees 20 // Degrees before Forced Beacon Tx (20 Car , 15 Bike/Runner)
#define MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike) //#define MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike)
#define MinimumTimeDeltaBeacon 5 // Seg between Tx //#define MinimumTimeDeltaBeacon 5 // Seg between Tx
#define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed #define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed
#define SendComment false // "true" adds comment to the APRS packet/message #define SendComment false // "true" adds comment to the APRS packet/message
#endif #define APRS_COMMENT "Lora Tracker 1W" // if you want to send any comment change the APRS_COMMENT
// and also beacon_config.h > SendComment = true
/* #define AprsPath "AP" // APRS Destination (could be also "WIDE1-1")
"callsign": "NOCALL-10", #define AprsOverlay "/"
"timeout": 1,
"symbol": "b", #define User1_Callsign "CD2RXU-7"
"overlay": "/", #define User1_Symbol "[" // Runner
"smart_beacon": { #define User1_SlowRate 120
"active": true, #define User1_SlowSpeed 3
"turn_min": 15, #define User1_FastRate 60
"slow_rate": 120, #define User1_FastSpeed 20
"slow_speed": 5, #define User1_MinDistTx 50
"fast_rate": 60, #define User1_MinDeltaBcn 20
"fast_speed": 20, #define User1_TurnMin 8
"min_tx_dist": 100, #define User1_TurnSlope 60
"min_bcn": 5
*/ #define User2_Callsign "CD2RXU-8"
#define User2_Symbol "b" // Bike
#define User2_SlowRate 180
#define User2_SlowSpeed 5
#define User2_FastRate 60
#define User2_FastSpeed 40
#define User2_MinDistTx 70
#define User2_MinDeltaBcn 12
#define User2_TurnMin 12
#define User2_TurnSlope 80
#define User3_Callsign "CD2RXU-9"
#define User3_Symbol ">" // Car
#define User3_SlowRate 120
#define User3_SlowSpeed 10
#define User3_FastRate 60
#define User3_FastSpeed 70
#define User3_MinDistTx 100
#define User3_MinDeltaBcn 10
#define User3_TurnMin 15
#define User3_TurnSlope 80
#endif

View File

@ -1,5 +1,5 @@
#ifndef PINS_H_ #ifndef PINS_CONFIG_H_
#define PINS_H_ #define PINS_CONFIG_H_
#define GPS_TXD 16 // Conection Pinout for GPS #define GPS_TXD 16 // Conection Pinout for GPS
#define GPS_RXD 17 #define GPS_RXD 17

View File

@ -1,9 +0,0 @@
#ifndef USER_CONFIG_H_
#define USER_CONFIG_H_
#define SRC_CALLSIGN "CD2RXU-7" // Change "CD2RXU-7" to your CALLSIGN-SSID you would use in APRS
#define DST_CALLSIGN "AP" // APRS Destination (could be also "WIDE1-1")
#define SYMBOL "[" // APRS Symbol: "[" Runner, "b" Bike, ">" Auto/Car
#define APRS_COMMENT "Lora Tracker 1W" // if you want to send any comment change the APRS_COMMENT
// and also beacon_config.h > SendComment = true
#endif