From d678c4888471805b87016d5d4a7d5b79b8cabde3 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 6 Feb 2021 23:29:18 -0800 Subject: [PATCH] work on rangetestplugin and storeforwardplugin done for the night. --- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 29 ++++++++++++++----- src/plugins/Plugins.cpp | 2 +- src/plugins/RangeTestPlugin.cpp | 46 ++++++++++++++++++------------ src/plugins/StoreForwardPlugin.cpp | 14 +++++++-- 5 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index a6388af9..fb503be4 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -80,7 +80,7 @@ extern const pb_msgdesc_t DeviceState_msg; #define DeviceState_fields &DeviceState_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 6239 +#define DeviceState_size 6262 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 6bf3a1c0..d3780630 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -193,6 +193,11 @@ typedef struct _RadioConfig_UserPreferences { bool ext_notification_plugin_active; bool ext_notification_plugin_alert_message; bool ext_notification_plugin_alert_bell; + bool range_test_plugin_enabled; + uint32_t range_test_plugin_sender; + bool range_test_plugin_save; + bool store_forward_plugin_enabled; + uint32_t store_forward_plugin_records; } RadioConfig_UserPreferences; typedef struct _RouteDiscovery { @@ -340,7 +345,7 @@ extern "C" { #define MeshPacket_init_default {0, 0, 0, {SubPacket_init_default}, 0, 0, 0, 0, 0, 0} #define ChannelSettings_init_default {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0} #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} #define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} @@ -354,7 +359,7 @@ extern "C" { #define MeshPacket_init_zero {0, 0, 0, {SubPacket_init_zero}, 0, 0, 0, 0, 0, 0} #define ChannelSettings_init_zero {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} #define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} @@ -435,6 +440,11 @@ extern "C" { #define RadioConfig_UserPreferences_ext_notification_plugin_active_tag 129 #define RadioConfig_UserPreferences_ext_notification_plugin_alert_message_tag 130 #define RadioConfig_UserPreferences_ext_notification_plugin_alert_bell_tag 131 +#define RadioConfig_UserPreferences_range_test_plugin_enabled_tag 132 +#define RadioConfig_UserPreferences_range_test_plugin_sender_tag 133 +#define RadioConfig_UserPreferences_range_test_plugin_save_tag 134 +#define RadioConfig_UserPreferences_store_forward_plugin_enabled_tag 136 +#define RadioConfig_UserPreferences_store_forward_plugin_records_tag 137 #define RouteDiscovery_route_tag 2 #define User_id_tag 1 #define User_long_name_tag 2 @@ -609,7 +619,12 @@ X(a, STATIC, SINGULAR, UINT32, ext_notification_plugin_output_ms, 127) \ X(a, STATIC, SINGULAR, UINT32, ext_notification_plugin_output, 128) \ X(a, STATIC, SINGULAR, BOOL, ext_notification_plugin_active, 129) \ X(a, STATIC, SINGULAR, BOOL, ext_notification_plugin_alert_message, 130) \ -X(a, STATIC, SINGULAR, BOOL, ext_notification_plugin_alert_bell, 131) +X(a, STATIC, SINGULAR, BOOL, ext_notification_plugin_alert_bell, 131) \ +X(a, STATIC, SINGULAR, BOOL, range_test_plugin_enabled, 132) \ +X(a, STATIC, SINGULAR, UINT32, range_test_plugin_sender, 133) \ +X(a, STATIC, SINGULAR, BOOL, range_test_plugin_save, 134) \ +X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_enabled, 136) \ +X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_records, 137) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -721,13 +736,13 @@ extern const pb_msgdesc_t ToRadio_msg; #define SubPacket_size 275 #define MeshPacket_size 320 #define ChannelSettings_size 95 -#define RadioConfig_size 382 -#define RadioConfig_UserPreferences_size 282 +#define RadioConfig_size 405 +#define RadioConfig_UserPreferences_size 305 #define NodeInfo_size 132 #define MyNodeInfo_size 106 #define LogRecord_size 81 -#define FromRadio_size 391 -#define ToRadio_size 386 +#define FromRadio_size 414 +#define ToRadio_size 409 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index c845e652..ac8dd733 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -31,7 +31,7 @@ void setupPlugins() */ new SerialPlugin(); new ExternalNotificationPlugin(); - //new StoreForwardPlugin(); + //storeForwardPlugin = new StoreForwardPlugin(); rangeTestPlugin = new RangeTestPlugin(); #endif } \ No newline at end of file diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index a1fee184..bae5e45f 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -6,15 +6,6 @@ #include "configuration.h" #include #include -//#include -//#include -//#include - -//#undef str - -#define RANGETESTPLUGIN_ENABLED 1 -//#define RANGETESTPLUGIN_SENDER 60 * 1000 -#define RANGETESTPLUGIN_SENDER 0 RangeTestPlugin *rangeTestPlugin; RangeTestPluginRadio *rangeTestPluginRadio; @@ -29,7 +20,18 @@ int32_t RangeTestPlugin::runOnce() { #ifndef NO_ESP32 - if (RANGETESTPLUGIN_ENABLED) { + /* + Uncomment the preferences below if you want to use the plugin + without having to configure it from the PythonAPI or WebUI. + */ + + radioConfig.preferences.range_test_plugin_enabled = 1; + radioConfig.preferences.range_test_plugin_sender = 60; + radioConfig.preferences.fixed_position = 1; + + uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; + + if (radioConfig.preferences.range_test_plugin_enabled) { if (firstTime) { @@ -39,9 +41,9 @@ int32_t RangeTestPlugin::runOnce() firstTime = 0; - if (RANGETESTPLUGIN_SENDER) { + if (radioConfig.preferences.range_test_plugin_sender) { DEBUG_MSG("Initializing Range Test Plugin -- Sender\n"); - return (RANGETESTPLUGIN_SENDER); + return (senderHeartbeat); } else { DEBUG_MSG("Initializing Range Test Plugin -- Receiver\n"); return (500); @@ -49,16 +51,23 @@ int32_t RangeTestPlugin::runOnce() } else { - if (RANGETESTPLUGIN_SENDER) { + if (radioConfig.preferences.range_test_plugin_sender) { // If sender - DEBUG_MSG("Range Test Plugin - Sending heartbeat\n"); + DEBUG_MSG("Range Test Plugin - Sending heartbeat every %d ms\n", + (senderHeartbeat)); + + DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude()); + DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude()); + DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); + DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP()); + DEBUG_MSG("pref.fixed_position() %d\n", radioConfig.preferences.fixed_position); rangeTestPluginRadio->sendPayload(); - return (RANGETESTPLUGIN_SENDER); + return ((senderHeartbeat)); } else { // Otherwise, we're a receiver. - return (INT32_MAX); + return (500); } // TBD } @@ -102,7 +111,7 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (RANGETESTPLUGIN_ENABLED) { + if (radioConfig.preferences.range_test_plugin_enabled) { auto &p = mp.decoded.data; // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", @@ -112,7 +121,7 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) // DEBUG_MSG("* * Message came from the mesh\n"); // Serial2.println("* * Message came from the mesh"); - //Serial2.printf("%s", p.payload.bytes); + // Serial2.printf("%s", p.payload.bytes); /* @@ -137,7 +146,6 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude()); DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); DEBUG_MSG("gpsStatus->getDOP() %d\n", gpsStatus->getDOP()); - } } else { diff --git a/src/plugins/StoreForwardPlugin.cpp b/src/plugins/StoreForwardPlugin.cpp index c40c3510..4ee4eac7 100644 --- a/src/plugins/StoreForwardPlugin.cpp +++ b/src/plugins/StoreForwardPlugin.cpp @@ -8,7 +8,7 @@ #include -#define STORE_RECORDS 10 +#define STORE_RECORDS 5000 #define BYTES_PER_RECORDS 512 struct sfRecord @@ -23,7 +23,7 @@ struct sfRecord records[STORE_RECORDS]; StoreForwardPlugin *storeForwardPlugin; StoreForwardPluginRadio *storeForwardPluginRadio; - + StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("SerialPlugin") {} // char serialStringChar[Constants_DATA_PAYLOAD_LEN]; @@ -32,7 +32,15 @@ int32_t StoreForwardPlugin::runOnce() { #ifndef NO_ESP32 - if (STOREFORWARDPLUGIN_ENABLED) { + /* + Uncomment the preferences below if you want to use the plugin + without having to configure it from the PythonAPI or WebUI. + */ + + //radioConfig.preferences.store_forward_plugin_enabled = 1; + //radioConfig.preferences.store_forward_plugin_records = 80; + + if (radioConfig.preferences.store_forward_plugin_enabled) { if (firstTime) {