From f17c773e7eba3a2ee1cad13ac76a0c9d0f6556eb Mon Sep 17 00:00:00 2001 From: gorzynsk Date: Sun, 11 Jul 2021 11:54:11 +0200 Subject: [PATCH] Adds Smart Beaconing settings --- .gitignore | 1 + data_embed/index.html | 29 +++++++++++++++++++++++- include/preference_storage.h | 10 +++++++++ platformio.ini | 12 ---------- src/TTGO_T-Beam_LoRa_APRS.ino | 42 ++++++++++++++++++++++++++++++++--- src/taskWebServer.cpp | 19 +++++++++++++++- 6 files changed, 96 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 52a4746..3219250 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ cmake-build-* /include/version.h /data_embed/*.out /src/TTGO_T-Beam_LoRa_APRS.ino.cpp +workspace.code-workspace diff --git a/data_embed/index.html b/data_embed/index.html index dc1c2a5..9bfba1c 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -45,6 +45,9 @@
+
+
Station Settings
+
@@ -79,13 +82,16 @@
+
+
Fixed Beaconing Settings
+
- +
@@ -97,6 +103,27 @@
+
+
Smart Beaconing Settings
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/include/preference_storage.h b/include/preference_storage.h index 442e43b..6499c4c 100644 --- a/include/preference_storage.h +++ b/include/preference_storage.h @@ -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"; diff --git a/platformio.ini b/platformio.ini index 00faf09..462fd9b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -52,18 +52,6 @@ build_flags = -D 'MAX_TIME_TO_NEXT_TX=360000L' -D 'FIX_BEACON_INTERVAL=1800000L' -[env:WB-ttgo-t-beam-v1.0] -platform = espressif32 @ 3.0.0 -board = ttgo-t-beam -build_flags = - ${env.build_flags} - -D T_BEAM_V1_0 - -D ENABLE_WIFI - -D ENABLE_BLUETOOTH - -D 'CALLSIGN="SQ2WB-4"' - -D 'DIGI_PATH="WIDE1-1"' - -D 'MAX_TIME_TO_NEXT_TX=120000L' - -D 'ENABLE_LED_SIGNALING' [env:ttgo-t-beam-v1.0] platform = espressif32 @ 3.0.0 diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 833ae39..45940b5 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -153,12 +153,19 @@ 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; +ulong SB_min_speed = 0; +ulong SB_max_speed = 30; + +float average_speed[5] = {0,0,0,0,0}, average_speed_final=0, max_speed=SB_max_speed, min_speed=SB_min_speed; 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; ulong fix_beacon_interval = FIX_BEACON_INTERVAL; @@ -585,6 +592,35 @@ void setup(){ } 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); diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp index 83ab67c..dc312bc 100644 --- a/src/taskWebServer.cpp +++ b/src/taskWebServer.cpp @@ -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); @@ -191,10 +195,23 @@ void handle_SaveAPRSCfg() { } if (server.hasArg(PREF_APRS_LATITUDE_PRESET)){ preferences.putString(PREF_APRS_LATITUDE_PRESET, server.arg(PREF_APRS_LATITUDE_PRESET)); - } + } 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)); }