Merge from dev to master

# Conflicts:
#	platformio.ini
pull/1/head
US1GHQ 2 years ago
commit 6a88781eb0

@ -43,6 +43,9 @@
<article>
<form action="/save_aprs_cfg" method="post">
<div class="grid-container quarters">
<div class="grid-container full">
<h5 class="u-full-width">Station Settings</h5>
</div>
<div>
<label for="aprs_callsign">Callsign and SSID</label>
<input class="u-full-width" type="text" minlength="3" name="aprs_callsign" placeholder="NOCALL-1" id="aprs_callsign" title="your callsign with SSID">
@ -74,6 +77,9 @@
<div>
<label for="aprs_batt">Show Battery</label>
<input name="aprs_batt" id="aprs_batt" type="checkbox" value="1" title=" show battery voltage after personal comment">
</div>
<div class="grid-container full">
<h5 class="u-full-width">Fixed Beaconing Settings</h5>
</div>
</div>
<div class="grid-container quarters">
@ -82,7 +88,7 @@
<input name="aprs_fixed_beac" id="aprs_fixed_beac" type="checkbox" value="1" title="enable fixed beacon when GPS is disabled or no fix">
</div>
<div>
<label for="aprs_fb_interv">Fixed Beacon Interval (s)</label>
<label for="aprs_fb_interv">Fixed Beacon Interval [s]</label>
<input name="aprs_fb_interv" id="aprs_fb_interv" type="number" min="120" title="time between sending a beacon if Fixed Beacon option is selected ">
</div>
<div>
@ -93,6 +99,27 @@
<label for="aprs_lon_p">Longitude Preset</label>
<input class="u-full-width" type="text" minlength="0" name="aprs_lon_p" id="aprs_lon_p" title="longtitude for fixed bicon, APRS format for example 02050.59E">
</div>
</div>
<div class="grid-container full">
<h5 class="u-full-width">Smart Beaconing Settings</h5>
</div>
<div class="grid-container quarters">
<div>
<label for="sb_min_interv">Min interval [s]</label>
<input name="sb_min_interv" id="sb_min_interv" type="number" min="60" title="Minimal time for Smart Beaconing">
</div>
<div>
<label for="sb_max_interv">Max interval [s]</label>
<input name="sb_max_interv" id="sb_max_interv" type="number" min="120" title="Maximal time for Smart Beaconing">
</div>
<div>
<label for="sb_min_speed">Min speed [km/h]</label>
<input name="sb_min_speed" id="sb_min_speed" type="number" min="0" title="Minimal speed for Smart Beaconing">
</div>
<div>
<label for="sb_max_speed">Max speed [km/h]</label>
<input name="sb_max_speed" id="sb_max_speed" type="number" min="1" title="Maximal speed for Smart Beaconing">
</div>
</div>
<div class="grid-container quarters">
<div>

@ -29,6 +29,16 @@ static const char *const PREF_APRS_FIXED_BEACON_PRESET = "aprs_fixed_beac";
static const char *const PREF_APRS_FIXED_BEACON_PRESET_INIT = "aprs_fix_b_init";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET = "aprs_fb_interv";
static const char *const PREF_APRS_FIXED_BEACON_INTERVAL_PRESET_INIT = "aprs_fb_in_init";
// SMART BEACONING
static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET = "sb_min_interv";
static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET_INIT = "sb_min_interv_i";
static const char *const PREF_APRS_SB_MAX_INTERVAL_PRESET = "sb_max_interv";
static const char *const PREF_APRS_SB_MAX_INTERVAL_PRESET_INIT = "sb_max_interv_i";
static const char *const PREF_APRS_SB_MIN_SPEED_PRESET = "sb_min_speed";
static const char *const PREF_APRS_SB_MIN_SPEED_PRESET_INIT = "sb_min_speed_i";
static const char *const PREF_APRS_SB_MAX_SPEED_PRESET = "sb_max_speed";
static const char *const PREF_APRS_SB_MAX_SPEED_PRESET_INIT = "sb_max_speed_i";
static const char *const PREF_APRS_GPS_EN = "gps_enabled";
static const char *const PREF_APRS_GPS_EN_INIT = "gps_state_init";
static const char *const PREF_APRS_SHOW_CMT = "show_cmt";

@ -36,12 +36,19 @@
#define SSD1306_ADDRESS 0x3C
// SPI config
#define SPI_sck 5
#define SPI_miso 19
#define SPI_mosi 27
#define SPI_ss 18
#ifdef ESP32_DEV_V1
#define SPI_sck 18
#define SPI_miso 19
#define SPI_mosi 23
#define SPI_ss 5
#else
#define SPI_sck 5
#define SPI_miso 19
#define SPI_mosi 27
#define SPI_ss 18
#endif
// IO config
#ifdef T_BEAM_V1_0
#define I2C_SDA 21
#define I2C_SCL 22
@ -77,19 +84,25 @@
#define I2C_SCL 15
#define BUTTON 2 //pin number for BUTTO
#define BUZZER 13 // enter your buzzer pin gpio
const byte TXLED = 4; //pin number for LED on TX Tracker
const byte TXLED = 2; //pin number for LED on TX Tracker
#elif HELTEC_V2
#define I2C_SDA 4
#define I2C_SCL 15
#define BUTTON 2 //pin number for BUTTO
#define BUTTON 0 //pin number for BUTTO
#define BUZZER 13 // enter your buzzer pin gpio
const byte TXLED = 4; //pin number for LED on TX Tracker
const byte TXLED = 25; //pin number for LED on TX Tracker
#elif ESP32_DEV_V1
#define I2C_SDA 4
#define I2C_SCL 15
#define BUTTON 2 //pin number for BUTTO
#define BUZZER 13 // enter your buzzer pin gpio
const byte TXLED = 4; //pin number for LED on TX Tracker
#define I2C_SDA 21
#define I2C_SCL 22
#define BUTTON 0 //pin number for BUTTO
#define BUZZER 13
const byte TXLED = 2; // enter your buzzer pin gpio
#endif
#ifdef TX_RX_LNA
const byte TXPIN = 17; //pin number for TX on 1W Modules
const byte RXPIN = 16; //pin number for RX on 1W Modules
#endif
// Variables for APRS packaging
@ -159,11 +172,18 @@ float BattVolts;
float InpVolts;
// variables for smart beaconing
float average_speed[5] = {0,0,0,0,0}, average_speed_final=0, max_speed=30, min_speed=0;
ulong sb_min_interval = 60000L;
ulong sb_max_interval = 360000L;
float sb_min_speed = 0;
float sb_max_speed = 30;
float average_speed[5] = {0,0,0,0,0}, average_speed_final=0;
float old_course = 0, new_course = 0;
int point_avg_speed = 0, point_avg_course = 0;
ulong min_time_to_nextTX=60000L; // minimum time period between TX = 60000ms = 60secs = 1min
ulong max_time_to_nextTX= MAX_TIME_TO_NEXT_TX;
ulong min_time_to_nextTX=SB_min_interval; // minimum time period between TX = 60000ms = 60secs = 1min
ulong max_time_to_nextTX= SB_max_interval;
ulong nextTX=60000L; // preset time period between TX = 60000ms = 60secs = 1min
ulong time_to_refresh = 0;
ulong next_fixed_beacon = 0;
@ -197,10 +217,19 @@ static const adc_unit_t unit = ADC_UNIT_1;
uint8_t loraReceivedLength = sizeof(lora_RXBUFF);
// Singleton instance of the radio driver
BG_RF95 rf95(18, 26); // TTGO T-Beam has NSS @ Pin 18 and Interrupt IO @ Pin26
#ifdef ESP32_DEV_V1
BG_RF95 rf95(5, 26); // For custom ESP32 and LoRa module
#else
BG_RF95 rf95(18, 26); // TTGO T-Beam has NSS @ Pin 18 and Interrupt IO @ Pin26
#endif
// initialize OLED display
#define OLED_RESET 16 // not used
#ifdef TX_RX_LNA
#define OLED_RESET 15 // not used
#else
#define OLED_RESET 16
#endif
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
// + FUNCTIONS-----------------------------------------------------------+//
@ -325,8 +354,13 @@ void sendpacket(){
* @param message
*/
void loraSend(byte lora_LTXPower, float lora_FREQ, const String &message) {
#ifdef TX_RX_LNA
digitalWrite(TXPIN, HIGH);
digitalWrite(RXPIN, LOW);
#endif
#ifdef ENABLE_LED_SIGNALING
digitalWrite(TXLED, LOW);
digitalWrite(TXLED, HIGH);
#endif
lastTX = millis();
@ -341,8 +375,13 @@ void loraSend(byte lora_LTXPower, float lora_FREQ, const String &message) {
rf95.setTxPower(lora_LTXPower);
rf95.sendAPRS(lora_TXBUFF, messageSize);
rf95.waitPacketSent();
#ifdef TX_RX_LNA
digitalWrite(TXPIN, LOW);
digitalWrite(RXPIN, HIGH);
#endif
#ifdef ENABLE_LED_SIGNALING
digitalWrite(TXLED, HIGH);
digitalWrite(TXLED, LOW);
#endif
}
@ -590,7 +629,34 @@ void setup(){
preferences.putInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET, fix_beacon_interval/1000);
}
fix_beacon_interval = preferences.getInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET) * 1000;
// + SMART BEACONING
if (!preferences.getBool(PREF_APRS_SB_MIN_INTERVAL_PRESET_INIT)){
preferences.putBool(PREF_APRS_SB_MIN_INTERVAL_PRESET_INIT, true);
preferences.putInt(PREF_APRS_SB_MIN_INTERVAL_PRESET, sb_min_interval/1000);
}
sb_min_interval = preferences.getInt(PREF_APRS_SB_MIN_INTERVAL_PRESET) * 1000;
if (!preferences.getBool(PREF_APRS_SB_MAX_INTERVAL_PRESET_INIT)){
preferences.putBool(PREF_APRS_SB_MAX_INTERVAL_PRESET_INIT, true);
preferences.putInt(PREF_APRS_SB_MAX_INTERVAL_PRESET, sb_max_interval/1000);
}
sb_max_interval = preferences.getInt(PREF_APRS_SB_MAX_INTERVAL_PRESET) * 1000;
if (!preferences.getBool(PREF_APRS_SB_MIN_SPEED_PRESET_INIT)){
preferences.putBool(PREF_APRS_SB_MIN_SPEED_PRESET_INIT, true);
preferences.putInt(PREF_APRS_SB_MIN_SPEED_PRESET, sb_min_speed);
}
sb_min_speed = preferences.getInt(PREF_APRS_SB_MIN_SPEED_PRESET);
if (!preferences.getBool(PREF_APRS_SB_MAX_SPEED_PRESET_INIT)){
preferences.putBool(PREF_APRS_SB_MAX_SPEED_PRESET_INIT, true);
preferences.putInt(PREF_APRS_SB_MAX_SPEED_PRESET, sb_max_speed);
}
sb_max_speed = preferences.getInt(PREF_APRS_SB_MAX_SPEED_PRESET);
//
if (!preferences.getBool(PREF_DEV_SHOW_RX_TIME_INIT)){
preferences.putBool(PREF_DEV_SHOW_RX_TIME_INIT, true);
preferences.putInt(PREF_DEV_SHOW_RX_TIME, showRXTime/1000);
@ -639,7 +705,12 @@ void setup(){
average_course[i]=0;
}
#ifdef TX_RX_LNA
pinMode(TXPIN, OUTPUT);
pinMode(RXPIN, OUTPUT);
#endif
pinMode(TXLED, OUTPUT);
#ifdef T_BEAM_V1_0
pinMode(BUTTON, INPUT);
#elif T_BEAM_V0_7
@ -647,7 +718,12 @@ void setup(){
#else
pinMode(BUTTON, INPUT_PULLUP);
#endif
digitalWrite(TXLED, LOW); // turn blue LED off
#ifdef TX_RX_LNA
digitalWrite(TXPIN, LOW); // turn blue LED off
digitalWrite(RXPIN, HIGH); // turn blue LED off
#endif
digitalWrite(TXLED, LOW); // turn blue LED off
Serial.begin(115200);
Wire.begin(I2C_SDA, I2C_SCL);
@ -706,12 +782,13 @@ void setup(){
#endif
if (!rf95.init()) {
writedisplaytext("LoRa-APRS","","Init:","RF95 FAILED!",":-(","");
//writedisplaytext("LoRa-APRS","","Init:","RF95 FAILED!",":-(","");
Serial.println("init failed");
for(;;); // Don't proceed, loop forever
}
if (max_time_to_nextTX < nextTX){
max_time_to_nextTX=nextTX;
if (sb_max_interval < nextTX){
sb_max_interval=nextTX;
}
writedisplaytext("LoRa-APRS","","Init:","RF95 OK!","","");
writedisplaytext(" "+Tcall,"","Init:","Waiting for GPS","","");
@ -741,7 +818,7 @@ void setup(){
SerialBT.setPin(BLUETOOTH_PIN);
#endif
#ifdef ENABLE_BLUETOOTH
SerialBT.begin(String("TTGO LORA APRS ") + Tcall);
SerialBT.begin(String("LORA APRS ") + Tcall);
writedisplaytext("LoRa-APRS","","Init:","BT OK!","","");
#endif
}
@ -757,7 +834,11 @@ void setup(){
writedisplaytext("","","","","","");
time_to_refresh = millis() + showRXTime;
displayInvalidGPS();
digitalWrite(TXLED, HIGH);
#ifdef TX_RX_LNA
digitalWrite(TXPIN, LOW);
digitalWrite(RXPIN, HIGH);
#endif
digitalWrite(TXLED, LOW);
}
// +---------------------------------------------------------------------+//
@ -876,7 +957,11 @@ void loop() {
}
writedisplaytext(" ((RX))", "", loraReceivedFrameString, "", "", "");
#ifdef KISS_PROTOCOL
sendToTNC(loraReceivedFrameString);
#ifdef RSSI_SNR_REPORT
sendToTNC(loraReceivedFrameString + ", RSSI:"+ rf95.lastRssi() + ", SNR:" + rf95.lastSNR() / 10); //show RSSI & SNR in packet
#else
sendToTNC(loraReceivedFrameString);
#endif
#endif
#ifdef ENABLE_WIFI
sendToWebList(loraReceivedFrameString, rf95.lastRssi(), rf95.lastSNR());
@ -899,9 +984,9 @@ void loop() {
point_avg_speed=0;
}
average_speed_final = (average_speed[0]+average_speed[1]+average_speed[2]+average_speed[3]+average_speed[4])/5;
nextTX = (max_time_to_nextTX-min_time_to_nextTX)/(max_speed-min_speed)*(max_speed-average_speed_final)+min_time_to_nextTX;
if (nextTX < min_time_to_nextTX) {nextTX=min_time_to_nextTX;}
if (nextTX > max_time_to_nextTX) {nextTX=max_time_to_nextTX;}
nextTX = (sb_max_interval-sb_min_interval)/(sb_max_speed-sb_min_speed)*(sb_max_speed-average_speed_final)+sb_min_interval;
if (nextTX < sb_min_interval) {nextTX=sb_min_interval;}
if (nextTX > sb_max_interval) {nextTX=sb_max_interval;}
average_course[point_avg_course] = gps.course.deg(); // calculate smart beaconing course
++point_avg_course;
if (point_avg_course>(ANGLE_AVGS-1)) {
@ -919,7 +1004,7 @@ void loop() {
if ((old_course < ANGLE) && (new_course > (360-ANGLE))) {
if (abs(new_course-old_course-360)>=ANGLE) {
nextTX = 0;
// lastTX = min_time_to_nextTX
// lastTX = sb_min_interval
}
} else {
if ((old_course > (360-ANGLE)) && (new_course < ANGLE)) {
@ -934,7 +1019,7 @@ void loop() {
}
old_course = new_course;
}
if ((millis()<max_time_to_nextTX)&&(lastTX == 0)) {
if ((millis()<sb_max_interval)&&(lastTX == 0)) {
nextTX = 0;
}
if ( (lastTX+nextTX) <= millis() ) {

@ -138,6 +138,10 @@ void handle_Cfg() {
jsonData += jsonLineFromPreferenceString(PREF_APRS_LATITUDE_PRESET);
jsonData += jsonLineFromPreferenceString(PREF_APRS_LONGITUDE_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MIN_INTERVAL_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MAX_INTERVAL_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MIN_SPEED_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_APRS_SB_MAX_SPEED_PRESET);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_BATTERY);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_FIXED_BEACON_PRESET);
jsonData += jsonLineFromPreferenceBool(PREF_APRS_SHOW_ALTITUDE);
@ -195,6 +199,18 @@ void handle_SaveAPRSCfg() {
if (server.hasArg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET)){
preferences.putInt(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET, server.arg(PREF_APRS_FIXED_BEACON_INTERVAL_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_SB_MIN_INTERVAL_PRESET)){
preferences.putInt(PREF_APRS_SB_MIN_INTERVAL_PRESET, server.arg(PREF_APRS_SB_MIN_INTERVAL_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_SB_MAX_INTERVAL_PRESET)){
preferences.putInt(PREF_APRS_SB_MAX_INTERVAL_PRESET, server.arg(PREF_APRS_SB_MAX_INTERVAL_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_SB_MIN_SPEED_PRESET)){
preferences.putInt(PREF_APRS_SB_MIN_SPEED_PRESET, server.arg(PREF_APRS_SB_MIN_SPEED_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_SB_MAX_SPEED_PRESET)){
preferences.putInt(PREF_APRS_SB_MAX_SPEED_PRESET, server.arg(PREF_APRS_SB_MAX_SPEED_PRESET).toInt());
}
if (server.hasArg(PREF_APRS_LONGITUDE_PRESET)){
preferences.putString(PREF_APRS_LONGITUDE_PRESET, server.arg(PREF_APRS_LONGITUDE_PRESET));
}

@ -11,7 +11,7 @@ try:
build_no = int(f.readline()) + 1
except:
print('Starting build number from 1..')
build_no = 1
build_no = 143
with open(FILENAME_BUILDNO, 'w+') as f:
f.write(str(build_no))
print('Build number: {}'.format(build_no))

Loading…
Cancel
Save