Merge branch 'correccion-sin-SPIFFS'
This commit is contained in:
commit
08d7bc42f7
23
README.md
23
README.md
|
|
@ -8,6 +8,15 @@ This LORA APRS Tracker will work with very cheep hardware (amazon, ebay or aliex
|
|||
This project uses Enconded APRS GPS packet to extends range by saving bytes (increased battery life, higher chances of good packet reception (increased range), lower probability of packet collisions (more channel capacity) and 1 Watt LoRa Module (over the usual 0.1 Watt in commercial boards like the LILYGO T-Beam V.1).
|
||||
|
||||
Achievements:
|
||||
______________________________________________________________________
|
||||
|
||||
Achievements:
|
||||
|
||||
- changing CALLSINGs with the "long" push of a button.
|
||||
- custom smartbeacon values for each CALLSIGN
|
||||
- force Tx with the "short" push of a button.
|
||||
- send enconded GPS data packet for shorter and realiable comunication.
|
||||
- Select to send "Course + Speed" or "Altitude + Speed" in encoded APRS data packet
|
||||
|
||||
- configurations saved on ESP32 memory (SPIFFS).
|
||||
- changing CALLSINGs with the "long" push of a button.
|
||||
|
|
@ -23,18 +32,24 @@ To add (shortly) working on it
|
|||
- Send Status: for a GPS position or distance to certain GPS point
|
||||
- Send Message to anothe APRS capable Radio/Handy/tracker/iGate or even Twitter ;)
|
||||
- Battery Monitoring (voltage, consumption, low_battery warning, charging?)
|
||||
To add (shortly) working on it
|
||||
|
||||
- turn_slope for course angle smartbeacon
|
||||
- oled screen (allready bought ... and waiting.. )
|
||||
- SendAltitude: encoded instead of just "Course+Speed" without adding lenght to the APRS packet.
|
||||
- SendComment: for a GPS position or distance to certain GPS point
|
||||
- Send Status: for a GPS position or distance to certain GPS point
|
||||
- Send Message to anothe APRS capable Radio/Handy/tracker/iGate or even Twitter ;)
|
||||
- Battery Monitoring (voltage, consumption, low_battery warning, charging?)
|
||||
|
||||
|
||||
______________________________________________________________________
|
||||
This Repository is based on lots of other Lora APRS Tracker ideas like:
|
||||
|
||||
- https://github.com/lora-aprs/LoRa_APRS_Tracker (the start with LILYGO T-BEAM v.1)
|
||||
- https://github.com/aprs434/lora.tracker (the great encoding position modification)
|
||||
- https://github.com/Mane76/lora.tracker (great ideas about changing callsign and other mods)
|
||||
- https://github.com/sh123/esp32_loraprs (inspiration for accesing the Lora Module with Radiolib library)
|
||||
|
||||
|
||||
|
||||
______________________________________________________________________
|
||||
|
||||
things to do (also):
|
||||
- add wiki
|
||||
|
|
|
|||
|
|
@ -14,36 +14,33 @@ https://github.com/sh123/esp32_loraprs
|
|||
#include <RadioLib.h>
|
||||
#include <WiFi.h>
|
||||
#include <OneButton.h>
|
||||
#include "BeaconManager.h"
|
||||
#include "pins.h"
|
||||
#include "pins_config.h"
|
||||
#include "lora_config.h"
|
||||
#include "beacon_config.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#define VERSION "2023.01.28" // BETA still!!!
|
||||
#define VERSION "2023.01.28" // BETA!!!
|
||||
|
||||
SX1268 radio = new Module(NSS, DIO1, NRST, BUSY);
|
||||
HardwareSerial neo6m_gps(1);
|
||||
TinyGPSPlus gps;
|
||||
OneButton UserButton1 = OneButton(BUTTON1_PIN, true, true);
|
||||
Configuration Config;
|
||||
BeaconManager BeaconMan;
|
||||
|
||||
|
||||
String CurrentUser[10];
|
||||
static bool send_update = true;
|
||||
|
||||
void load_config() {
|
||||
ConfigurationManagement confmg("/tracker.json");
|
||||
Config = confmg.readConfiguration();
|
||||
BeaconMan.loadConfig(Config.beacons);
|
||||
if (BeaconMan.getCurrentBeaconConfig()->callsign == "NOCALL-10") {
|
||||
Serial.println("You have to change your settings in 'data/tracker.json' and "
|
||||
"upload it via \"Upload File System image\"!");
|
||||
while (true) {
|
||||
}
|
||||
} else {
|
||||
Serial.println("##### (Configuration Loaded) #####");
|
||||
}
|
||||
}
|
||||
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() {
|
||||
|
|
@ -62,32 +59,58 @@ void setup_gps_module() {
|
|||
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() {
|
||||
Serial.println("Forced Beacon Tx");
|
||||
send_update = true;
|
||||
}
|
||||
|
||||
static void HandleNextBeacon() {
|
||||
BeaconMan.loadNextBeacon();
|
||||
Serial.print("Changing CALLSIGN --> ");
|
||||
Serial.println(BeaconMan.getCurrentBeaconConfig()->callsign);
|
||||
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() {
|
||||
Serial.begin(115200);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
load_config();
|
||||
Serial.print("LoRa tracker " __DATE__ " " __TIME__ " / Callsign ------> ");
|
||||
Serial.println(BeaconMan.getCurrentBeaconConfig()->callsign);
|
||||
setup_lora_module();
|
||||
setup_gps_module();
|
||||
UserButton1.attachClick(ForcedBeaconTx);
|
||||
UserButton1.attachLongPressStart(HandleNextBeacon);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
Serial.print("(Version = "); Serial.print(VERSION); Serial.println(")");
|
||||
Serial.println("Transmission Start ---->");
|
||||
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);
|
||||
setup_first_user();
|
||||
setup_lora_module();
|
||||
setup_gps_module();
|
||||
Serial.println("---Transmission Start ---");
|
||||
}
|
||||
|
||||
uint8_t tx_buffer[256];
|
||||
|
|
@ -123,24 +146,28 @@ void loop() {
|
|||
//static int speed_zero_sent = 0;
|
||||
|
||||
|
||||
|
||||
String mensaje_test = "nada";
|
||||
String mensaje_test = "0";
|
||||
if (!send_update && gps_loc_update) {
|
||||
uint32_t lastTx = millis() - lastTxTime;
|
||||
currentHeading = gps.course.deg();
|
||||
lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLatitude, lastTxLongitude);
|
||||
uint32_t lastTx = millis() - lastTxTime;
|
||||
int MinimumDistanceTx = CurrentUser[6].toInt();
|
||||
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 (lastTxDistance > BeaconMan.getCurrentBeaconConfig()->smart_beacon.min_tx_dist) {
|
||||
if (lastTxDistance > MinimumDistanceTx) {
|
||||
send_update = true;
|
||||
mensaje_test = "Dist: " + String(lastTxDistance) + " Int: " + String(txInterval);
|
||||
mensaje_test = "D:" + String(lastTxDistance) + " I:" + String(txInterval);
|
||||
}
|
||||
}
|
||||
if (!send_update) {
|
||||
double headingDelta = abs(previousHeading - currentHeading);
|
||||
if (lastTx > BeaconMan.getCurrentBeaconConfig()->smart_beacon.min_bcn * 1000) {
|
||||
if (headingDelta > BeaconMan.getCurrentBeaconConfig()->smart_beacon.turn_min && lastTxDistance > BeaconMan.getCurrentBeaconConfig()->smart_beacon.min_tx_dist) {
|
||||
if (lastTx > MinimumTimeDeltaBeacon * 1000) {
|
||||
if (headingDelta > TurnDegrees && lastTxDistance > MinimumDistanceTx) {
|
||||
send_update = true;
|
||||
mensaje_test = "Delta: " + String(headingDelta) + " Dist: " + String(lastTxDistance) + " Int: " + String(txInterval);
|
||||
mensaje_test = "C:" + String(headingDelta) + " D:" + String(lastTxDistance) + " I:" + String(txInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -168,7 +195,7 @@ void loop() {
|
|||
if(Tlon < 0) { Tlon= -Tlon; }
|
||||
|
||||
String AprsPacketMsg = "!";
|
||||
AprsPacketMsg += BeaconMan.getCurrentBeaconConfig()->overlay;
|
||||
AprsPacketMsg += AprsOverlay;
|
||||
char helper_base91[] = {"0000\0"};
|
||||
int i;
|
||||
ax25_base91enc(helper_base91, 4, aprs_lat);
|
||||
|
|
@ -180,7 +207,7 @@ void loop() {
|
|||
AprsPacketMsg += helper_base91[i];
|
||||
}
|
||||
|
||||
AprsPacketMsg += BeaconMan.getCurrentBeaconConfig()->symbol;
|
||||
AprsPacketMsg += CurrentUser[1]; // Symbol
|
||||
|
||||
if (SendAltitude) { // Send Altitude or... (APRS calculates Speed also)
|
||||
int Alt1, Alt2;
|
||||
|
|
@ -206,11 +233,8 @@ void loop() {
|
|||
}
|
||||
|
||||
if (SendComment) {
|
||||
//AprsPacketMsg += "Lora Tracker 1W";
|
||||
|
||||
//AprsPacketMsg += APRS_COMMENT;
|
||||
AprsPacketMsg += mensaje_test;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Serial.print(F("GPS coordinates: ")); // Only for Serial Monitor
|
||||
|
|
@ -221,7 +245,7 @@ void loop() {
|
|||
memset(tx_buffer, 0x00, sizeof tx_buffer);
|
||||
uint16_t size = 0;
|
||||
|
||||
size = snprintf(reinterpret_cast<char *>(tx_buffer), sizeof tx_buffer, "\x3c\xff\x01%s>%s:%s", BeaconMan.getCurrentBeaconConfig()->callsign, BeaconMan.getCurrentBeaconConfig()->path, 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(F(" transmitting: "));
|
||||
|
|
@ -240,14 +264,19 @@ void loop() {
|
|||
send_update = false;
|
||||
}
|
||||
|
||||
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();
|
||||
if (curr_speed < BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_speed) {
|
||||
txInterval = BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_rate * 1000;
|
||||
} else if (curr_speed > BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_speed) {
|
||||
txInterval = BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_rate * 1000;
|
||||
if (curr_speed < SlowSpeed) {
|
||||
txInterval = SlowRate * 1000;
|
||||
} else if (curr_speed > FastSpeed) {
|
||||
txInterval = FastRate * 1000;
|
||||
} else {
|
||||
txInterval = min(BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_rate, (BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_speed * BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_rate / curr_speed)) * 1000;
|
||||
txInterval = min(SlowRate, (FastSpeed * FastRate / curr_speed)) * 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,55 @@
|
|||
#ifndef BEACON_CONFIG_H_
|
||||
#define BEACON_CONFIG_H_
|
||||
|
||||
#define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed
|
||||
#define SendComment true // "true" adds comment to the APRS packet/message
|
||||
//#define SlowRate 120 // Seg
|
||||
//#define SlowSpeed 10 // Km/h (3 Runner , 5 Bike, 10 Car)
|
||||
//#define FastRate 60 // Seg
|
||||
//#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 MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike)
|
||||
//#define MinimumTimeDeltaBeacon 5 // Seg between Tx
|
||||
|
||||
#define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed
|
||||
#define SendComment true // "true" adds comment to the APRS packet/message
|
||||
|
||||
#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")
|
||||
#define AprsOverlay "/"
|
||||
|
||||
#define User1_Callsign "CD2RXU-7"
|
||||
#define User1_Symbol "[" // Runner
|
||||
#define User1_SlowRate 120
|
||||
#define User1_SlowSpeed 3
|
||||
#define User1_FastRate 60
|
||||
#define User1_FastSpeed 20
|
||||
#define User1_MinDistTx 5 // debe ser 50 pero esta 5 por pruebas
|
||||
#define User1_MinDeltaBcn 20
|
||||
#define User1_TurnMin 8
|
||||
#define User1_TurnSlope 60
|
||||
|
||||
#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
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PINS_H_
|
||||
#define PINS_H_
|
||||
#ifndef PINS_CONFIG_H_
|
||||
#define PINS_CONFIG_H_
|
||||
|
||||
#define GPS_TXD 16 // Conection Pinout for GPS
|
||||
#define GPS_RXD 17
|
||||
Loading…
Reference in New Issue