From 242bcc835391079562b012e7d6bb01d01d6356c3 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 30 Jan 2021 09:52:21 -0800 Subject: [PATCH 01/28] Update documentation location to the main mesthastic repo --- src/plugins/ExternalNotificationPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/ExternalNotificationPlugin.cpp b/src/plugins/ExternalNotificationPlugin.cpp index b4f3c801c..505eff7d1 100644 --- a/src/plugins/ExternalNotificationPlugin.cpp +++ b/src/plugins/ExternalNotificationPlugin.cpp @@ -11,7 +11,7 @@ /* Documentation: - https://github.com/mc-hamster/Meshtastic-device/blob/master/docs/software/plugins/ExternalNotificationPlugin.md + https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/plugins/ExternalNotificationPlugin.md This plugin supports: https://github.com/meshtastic/Meshtastic-device/issues/654 From 487b8c6e9ed4625b1a6849759d647ff0eb3d5d3a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 31 Jan 2021 09:12:01 -0800 Subject: [PATCH 02/28] #668 Initial work for Store & Forward Plugin --- docs/software/plugins/StoreRequestPlugin.md | 15 ++ src/plugins/StoreForwardPlugin.cpp | 148 ++++++++++++++++++++ src/plugins/StoreForwardPlugin.h | 54 +++++++ 3 files changed, 217 insertions(+) create mode 100644 src/plugins/StoreForwardPlugin.cpp create mode 100644 src/plugins/StoreForwardPlugin.h diff --git a/docs/software/plugins/StoreRequestPlugin.md b/docs/software/plugins/StoreRequestPlugin.md index 239a00de8..571ac4ed6 100644 --- a/docs/software/plugins/StoreRequestPlugin.md +++ b/docs/software/plugins/StoreRequestPlugin.md @@ -1,6 +1,21 @@ # About + This is a work in progress and is not yet available. +The Store Request Plugin is an implementation of a Store and Forward system to enable resilient messaging in the event that a client device is disconnected from the main network. + +Because of the increased network traffic for this overhead, it's not adviced to use this if you are duty cycle limited for your airtime usage nor is it adviced to use this for SF12. # Running notes +This will only work on nodes that are designated as a Router. + +Initial Requirements: + +* Must be installed on a router node. +* * This is an artificial limitation, but is in place to enforce best practices. +* * Router nodes are intended to be always online. If this plugin misses any messages, the reliability of the stored messages will be reduced +* Esp32 Processor based device with external PSRAM. (tbeam v1.0 and tbeamv1.1, maybe others) + +Initial Features +* \ No newline at end of file diff --git a/src/plugins/StoreForwardPlugin.cpp b/src/plugins/StoreForwardPlugin.cpp new file mode 100644 index 000000000..c40c35109 --- /dev/null +++ b/src/plugins/StoreForwardPlugin.cpp @@ -0,0 +1,148 @@ +#include "StoreForwardPlugin.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "configuration.h" +#include + +#include + +#define STORE_RECORDS 10 +#define BYTES_PER_RECORDS 512 + +struct sfRecord +{ + uint8_t bytes[BYTES_PER_RECORDS]; + uint32_t timestamp; // Time the packet was received +}; + +struct sfRecord records[STORE_RECORDS]; + +#define STOREFORWARDPLUGIN_ENABLED 1 + +StoreForwardPlugin *storeForwardPlugin; +StoreForwardPluginRadio *storeForwardPluginRadio; + +StoreForwardPlugin::StoreForwardPlugin() : concurrency::OSThread("SerialPlugin") {} + +// char serialStringChar[Constants_DATA_PAYLOAD_LEN]; + +int32_t StoreForwardPlugin::runOnce() +{ +#ifndef NO_ESP32 + + if (STOREFORWARDPLUGIN_ENABLED) { + + if (firstTime) { + + // Interface with the serial peripheral from in here. + DEBUG_MSG("Initializing Store & Forward Plugin\n"); + + // Router + if (radioConfig.preferences.is_router) { + if (ESP.getPsramSize()) { + if (ESP.getFreePsram() <= 1024 * 1024) { + // Do the startup here + + } else { + DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n"); + DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); + + return (INT32_MAX); + } + + } else { + DEBUG_MSG("Device doesn't have PSRAM.\n"); + DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); + + return (INT32_MAX); + } + + // Non-Router + } else { + + } + + storeForwardPluginRadio = new StoreForwardPluginRadio(); + + firstTime = 0; + + } else { + // TBD + } + + return (10); + } else { + DEBUG_MSG("Store & Forward Plugin - Disabled\n"); + + return (INT32_MAX); + } + +#endif +} + +MeshPacket *StoreForwardPluginRadio::allocReply() +{ + + auto reply = allocDataPacket(); // Allocate a packet for sending + + return reply; +} + +void StoreForwardPluginRadio::sendPayload(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + //p->want_ack = SERIALPLUGIN_ACK; + + // p->decoded.data.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply + // memcpy(p->decoded.data.payload.bytes, serialStringChar, p->decoded.data.payload.size); + + service.sendToMesh(p); +} + +bool StoreForwardPluginRadio::handleReceived(const MeshPacket &mp) +{ +#ifndef NO_ESP32 + + if (STOREFORWARDPLUGIN_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", + // nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + + if (mp.from == nodeDB.getNodeNum()) { + + /* + * If radioConfig.preferences.serialplugin_echo is true, then echo the packets that are sent out back to the TX + * of the serial interface. + */ + if (radioConfig.preferences.serialplugin_echo) { + + // For some reason, we get the packet back twice when we send out of the radio. + // TODO: need to find out why. + if (lastRxID != mp.id) { + lastRxID = mp.id; + // DEBUG_MSG("* * Message came this device\n"); + // Serial2.println("* * Message came this device"); + Serial2.printf("%s", p.payload.bytes); + } + } + + } else { + // DEBUG_MSG("* * Message came from the mesh\n"); + // Serial2.println("* * Message came from the mesh"); + Serial2.printf("%s", p.payload.bytes); + } + + } else { + DEBUG_MSG("Serial Plugin Disabled\n"); + } + +#endif + + return true; // Let others look at this message also if they want +} diff --git a/src/plugins/StoreForwardPlugin.h b/src/plugins/StoreForwardPlugin.h new file mode 100644 index 000000000..e9dac9b45 --- /dev/null +++ b/src/plugins/StoreForwardPlugin.h @@ -0,0 +1,54 @@ +#pragma once + +#include "SinglePortPlugin.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include +#include + +class StoreForwardPlugin : private concurrency::OSThread +{ + bool firstTime = 1; + + public: + StoreForwardPlugin(); + + protected: + virtual int32_t runOnce(); +}; + +extern StoreForwardPlugin *storeForwardPlugin; + +/* + * Radio interface for SerialPlugin + * + */ +class StoreForwardPluginRadio : public SinglePortPlugin +{ + uint32_t lastRxID; + + public: + /* + TODO: Switch this to PortNum_SERIAL_APP once the change is able to be merged back here + from the main code. + */ + + // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + StoreForwardPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {} + + /** + * Send our payload into the mesh + */ + void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + + protected: + virtual MeshPacket *allocReply(); + + /** Called to handle a particular incoming message + + @return true if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual bool handleReceived(const MeshPacket &mp); +}; + +extern StoreForwardPluginRadio *storeForwardPluginRadio; \ No newline at end of file From e8c6fccd633f801045a417054115025a4be1fb0d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 31 Jan 2021 09:12:36 -0800 Subject: [PATCH 03/28] #671 Range Test Plugin Initial work for Range Test Plugin --- src/plugins/Plugins.cpp | 11 +++- src/plugins/RangeTestPlugin.cpp | 103 ++++++++++++++++++++++++++++++++ src/plugins/RangeTestPlugin.h | 49 +++++++++++++++ 3 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 src/plugins/RangeTestPlugin.cpp create mode 100644 src/plugins/RangeTestPlugin.h diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index 90a1b554f..93487ac7a 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -1,9 +1,11 @@ #include "plugins/ExternalNotificationPlugin.h" #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" +#include "plugins/RangeTestPlugin.h" #include "plugins/RemoteHardwarePlugin.h" #include "plugins/ReplyPlugin.h" #include "plugins/SerialPlugin.h" +#include "plugins/StoreForwardPlugin.h" #include "plugins/TextMessagePlugin.h" /** @@ -24,7 +26,12 @@ void setupPlugins() #ifndef NO_ESP32 // Only run on an esp32 based device. - new SerialPlugin(); // Maintained by MC Hamster (Jm Casler) jm@casler.org - new ExternalNotificationPlugin(); // Maintained by MC Hamster (Jm Casler) jm@casler.org + /* + Maintained by MC Hamster (Jm Casler) jm@casler.org + */ + new SerialPlugin(); + new ExternalNotificationPlugin(); + new StoreForwardPlugin(); + new RangeTestPlugin(); #endif } \ No newline at end of file diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp new file mode 100644 index 000000000..1b8f80f31 --- /dev/null +++ b/src/plugins/RangeTestPlugin.cpp @@ -0,0 +1,103 @@ +#include "RangeTestPlugin.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "configuration.h" +#include + +#include + +#define RANGETESTPLUGIN_ENABLED 1 +#define RANGETESTPLUGIN_SENDER 0 + +RangeTestPlugin *rangeTestPlugin; +RangeTestPluginRadio *rangeTestPluginRadio; + +RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {} + +// char serialStringChar[Constants_DATA_PAYLOAD_LEN]; + +int32_t RangeTestPlugin::runOnce() +{ +#ifndef NO_ESP32 + + if (RANGETESTPLUGIN_ENABLED) { + + if (firstTime) { + + // Interface with the serial peripheral from in here. + DEBUG_MSG("Initializing Range Test Plugin\n"); + + rangeTestPluginRadio = new RangeTestPluginRadio(); + + firstTime = 0; + + } else { + // TBD + } + + return (10); + } else { + DEBUG_MSG("Range Test Plugin - Disabled\n"); + + return (INT32_MAX); + } + +#endif +} + +MeshPacket *RangeTestPluginRadio::allocReply() +{ + + auto reply = allocDataPacket(); // Allocate a packet for sending + + return reply; +} + +void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) +{ + MeshPacket *p = allocReply(); + p->to = dest; + p->decoded.want_response = wantReplies; + + service.sendToMesh(p); +} + +bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) +{ +#ifndef NO_ESP32 + + if (RANGETESTPLUGIN_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", + // nodeDB.getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + + if (mp.from != nodeDB.getNodeNum()) { + + // DEBUG_MSG("* * Message came from the mesh\n"); + // Serial2.println("* * Message came from the mesh"); + Serial2.printf("%s", p.payload.bytes); + p.payload.size; + gpsStatus->getLatitude(); + gpsStatus->getLongitude(); + gpsStatus->getHasLock(); + gpsStatus->getDOP(); + mp.rx_snr; + mp.hop_limit; + mp.decoded.position.latitude_i; + mp.decoded.position.longitude_i; + + + + } + + } else { + DEBUG_MSG("Range Test Plugin Disabled\n"); + } + +#endif + + return true; // Let others look at this message also if they want +} diff --git a/src/plugins/RangeTestPlugin.h b/src/plugins/RangeTestPlugin.h new file mode 100644 index 000000000..f66744dbd --- /dev/null +++ b/src/plugins/RangeTestPlugin.h @@ -0,0 +1,49 @@ +#pragma once + +#include "SinglePortPlugin.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include +#include + +class RangeTestPlugin : private concurrency::OSThread +{ + bool firstTime = 1; + + public: + RangeTestPlugin(); + + protected: + virtual int32_t runOnce(); +}; + +extern RangeTestPlugin *rangeTestPlugin; + +/* + * Radio interface for RangeTestPlugin + * + */ +class RangeTestPluginRadio : public SinglePortPlugin +{ + uint32_t lastRxID; + + public: + + RangeTestPluginRadio() : SinglePortPlugin("RangeTestPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + + /** + * Send our payload into the mesh + */ + void sendPayload(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + + protected: + virtual MeshPacket *allocReply(); + + /** Called to handle a particular incoming message + + @return true if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual bool handleReceived(const MeshPacket &mp); +}; + +extern RangeTestPluginRadio *rangeTestPluginRadio; \ No newline at end of file From c00173dbd2d09a73e63eba1042bead70aafa63f8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 31 Jan 2021 18:20:08 -0800 Subject: [PATCH 04/28] partial work --- src/plugins/RangeTestPlugin.cpp | 34 +++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index 1b8f80f31..ffe98458c 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -5,11 +5,16 @@ #include "Router.h" #include "configuration.h" #include - #include +//#include +//#include +//#include + +//#undef str + #define RANGETESTPLUGIN_ENABLED 1 -#define RANGETESTPLUGIN_SENDER 0 +#define RANGETESTPLUGIN_SENDER 20000 RangeTestPlugin *rangeTestPlugin; RangeTestPluginRadio *rangeTestPluginRadio; @@ -34,10 +39,21 @@ int32_t RangeTestPlugin::runOnce() firstTime = 0; } else { + + // If sender + if (RANGETESTPLUGIN_SENDER) { + + return (RANGETESTPLUGIN_SENDER); + + // Otherwise, we're a receiver. + } else { + + rangeTestPluginRadio->sendPayload(); + return (500); + } // TBD } - return (10); } else { DEBUG_MSG("Range Test Plugin - Disabled\n"); @@ -61,6 +77,15 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) p->to = dest; p->decoded.want_response = wantReplies; + p->want_ack = true; + + uint16_t packetSequence = 123456; + static char heartbeatString[20]; + snprintf(heartbeatString, sizeof(heartbeatString), "Seq: %d%%", packetSequence); + + p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply + memcpy(p->decoded.data.payload.bytes, heartbeatString, p->decoded.data.payload.size); + service.sendToMesh(p); } @@ -88,9 +113,6 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) mp.hop_limit; mp.decoded.position.latitude_i; mp.decoded.position.longitude_i; - - - } } else { From e9affb50d210f164df2eaef433d76f6c39afb8bd Mon Sep 17 00:00:00 2001 From: Jm Date: Tue, 2 Feb 2021 17:34:50 -0800 Subject: [PATCH 05/28] #674 add support for lora32 v1.3 --- platformio.ini | 7 +++++++ src/configuration.h | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/platformio.ini b/platformio.ini index 9e3b123db..fc94967b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,6 +10,7 @@ [platformio] ;default_envs = tbeam +;default_envs = tlora-v1.3 ;default_envs = tbeam0.7 ;default_envs = heltec ;default_envs = tlora-v1 @@ -149,6 +150,12 @@ board = ttgo-lora32-v1 build_flags = ${esp32_base.build_flags} -D TLORA_V1 +[env:tlora-v1.3] +extends = esp32_base +board = ttgo-lora32-v1 +build_flags = + ${esp32_base.build_flags} -D TLORA_V1_3 + ; note: the platformio definition for lora32-v2 seems stale, it is missing a pins_arduino.h file, therefore I don't think it works [env:tlora-v2] extends = esp32_base diff --git a/src/configuration.h b/src/configuration.h index 79d1009ca..267420878 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -309,6 +309,33 @@ along with this program. If not, see . #define LORA_DIO1 35 // Not really used #define LORA_DIO2 34 // Not really used +#elif defined(TLORA_V1_3) +// This string must exactly match the case used in release file names or the android updater won't work +#define HW_VENDOR "tlora-v1-3" + +#undef GPS_RX_PIN +#undef GPS_TX_PIN +#define GPS_RX_PIN 36 +#define GPS_TX_PIN 13 // per @eugene + +#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage + +#define I2C_SDA 4 // I2C pins for this board +#define I2C_SCL 15 + +#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller + +#define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost +#define LED_PIN 25 // If defined we will blink this LED +#define BUTTON_PIN 36 +#define BUTTON_NEED_PULLUP + +#define USE_RF95 +#define LORA_DIO0 26 // a No connect on the SX1262 module +#define LORA_RESET 14 +#define LORA_DIO1 35 // Not really used +#define LORA_DIO2 34 // Not really used + #elif defined(TLORA_V2_1_16) // This string must exactly match the case used in release file names or the android updater won't work #define HW_VENDOR "tlora-v2-1-1.6" From 5661e5dad6cddc867f361250fdd14ecbc2a335b9 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Feb 2021 22:43:24 -0800 Subject: [PATCH 06/28] Update radio-settings.md --- docs/radio-settings.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 7af9d79e0..76060b351 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -33,9 +33,9 @@ Channel zero starts at 903.08 MHz center frequency. Various data-rates are selectable when configuring a channel and are inversely proportional to the theoretical range of the devices: -| Channel setting | Data-rate | -|----------------------------|----------------------| -| Short range (but fast) | 21.875 kbps | -| Medium range (but fast) | 5.469 kbps | -| Long range (but slower) | 0.275 kbps | -| Very long range (but slow) | 0.183 kbps (default) | +| Channel setting | Alt Channel Name | Data-rate | SF | Symbols | Coding Rate | Bandwidth | +|----------------------------|------------------|----------------------|--------------|-------------------------| +| Short range (but fast) | Short Fast | 21.875 kbps | 7 | 128 | 4/5 | 125 | +| Medium range (but fast) | Medium | 5.469 kbps | 7 | 512 | 4/5 | 500 | +| Long range (but slower) | Long Alt | 0.275 kbps | 9 | 512 | 4/8 | 31 | +| Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 | 4096 | 4/8 | 125 | From 8a68ae0d044511f4236c631507d2954ba2f5168c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Feb 2021 22:47:16 -0800 Subject: [PATCH 07/28] Update radio-settings.md --- docs/radio-settings.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 76060b351..5c94fe9cf 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -39,3 +39,7 @@ Various data-rates are selectable when configuring a channel and are inversely p | Medium range (but fast) | Medium | 5.469 kbps | 7 | 512 | 4/5 | 500 | | Long range (but slower) | Long Alt | 0.275 kbps | 9 | 512 | 4/8 | 31 | | Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 | 4096 | 4/8 | 125 | + +Other radio settings can be configured by using the Python API. An easy calculator of other bit rates is: + +https://unsigned.io/understanding-lora-parameters/ \ No newline at end of file From 0c6c189028c72e789f744f65d6b32f99b4626cf5 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Feb 2021 23:01:05 -0800 Subject: [PATCH 08/28] Update to radio-settings.md --- docs/radio-settings.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 5c94fe9cf..ad90b9fd0 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -33,13 +33,14 @@ Channel zero starts at 903.08 MHz center frequency. Various data-rates are selectable when configuring a channel and are inversely proportional to the theoretical range of the devices: -| Channel setting | Alt Channel Name | Data-rate | SF | Symbols | Coding Rate | Bandwidth | -|----------------------------|------------------|----------------------|--------------|-------------------------| -| Short range (but fast) | Short Fast | 21.875 kbps | 7 | 128 | 4/5 | 125 | -| Medium range (but fast) | Medium | 5.469 kbps | 7 | 512 | 4/5 | 500 | -| Long range (but slower) | Long Alt | 0.275 kbps | 9 | 512 | 4/8 | 31 | -| Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 | 4096 | 4/8 | 125 | +| Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | +|:---------------------------|:-----------------|:---------------------|:-------------|:------------|:----------| +| Short range (but fast) | Short Fast | 21.875 kbps | 7 / 128 | 4/5 | 125 | +| Medium range (but fast) | Medium | 5.469 kbps | 7 / 512 | 4/5 | 500 | +| Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | +| Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | Other radio settings can be configured by using the Python API. An easy calculator of other bit rates is: -https://unsigned.io/understanding-lora-parameters/ \ No newline at end of file +[Lora Parameters](https://unsigned.io/understanding-lora-parameters/) + From 324627482aba9ac85551286be18e3fa7e34d3b1c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Feb 2021 23:57:25 -0800 Subject: [PATCH 09/28] Update radio-settings.md --- docs/radio-settings.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index ad90b9fd0..9968ee27e 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -31,7 +31,23 @@ Channel zero starts at 903.08 MHz center frequency. ## Data-rates -Various data-rates are selectable when configuring a channel and are inversely proportional to the theoretical range of the devices: +Various data-rates are selectable when configuring a channel and are inversely proportional to the theoretical range of the devices. + +Considerations: + +* Spreading Factor +* * Each step up in Spreading Factor dobules the airtime to transmit. +* * Each step up in Spreading Factor adds about 2.5db extra link budget. +* Bandwidth +* * Each doubling of the bandwidth is almost 3db less link budget. +* Coding Rate +* * Increasing coding rate increases reliability while decrasing data-rate. +* * 4/5 - 1.25x overhead +* * 4/6 - 1.5x overhead +* * 4/7 - 1.75x overhead +* * 4/8 - 2x overhead + +Predefined Channels: | Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | |:---------------------------|:-----------------|:---------------------|:-------------|:------------|:----------| @@ -40,7 +56,26 @@ Various data-rates are selectable when configuring a channel and are inversely p | Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | | Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | -Other radio settings can be configured by using the Python API. An easy calculator of other bit rates is: +Other settings can be set by using the Python API. + +> meshtastic --set spread_factor 10 --set coding_rate 8 --bandwidth 125 + +Some example settings: + +| Data-rate | SF / Symbols | Coding Rate | Bandwidth | Note | +|:---------------------|:-------------|:------------|:----------|:-----| +| 3.125 kbps | 8 / 256 | 4/5 | 125 | | +| 1.953 kbps | 8 / 256 | 4/8 | 125 | | +| 1.343 kbps | 11 / 2048 | 4/8 | 512 | | +| 1.099 kbps | 9 / 512 | 4/8 | 125 | | +| 0.814 kbps | 10 / 1024 | 4/6 | 125 | | +| 0.610 kbps | 10 / 1024 | 4/8 | 125 | | +| 0.488 kbps | 11 / 2048 | 4/6 | 125 | | +| 0.336 kbps | 11 / 2048 | 4/8 | 125 | | +| 0.092 kbps | 12 / 4096 | 4/8 | 62 | | +| 0.046 kbps | 12 / 4096 | 4/8 | 31 | Twice the range of "Long Slow" | + +An easy calculator of other bit rates is: [Lora Parameters](https://unsigned.io/understanding-lora-parameters/) From 6d66a53f8d3811b5523dc81d6162cf6e487b27f0 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 2 Feb 2021 23:59:34 -0800 Subject: [PATCH 10/28] Another update to radio-settings.md --- docs/radio-settings.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 9968ee27e..73aba91ff 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -31,6 +31,8 @@ Channel zero starts at 903.08 MHz center frequency. ## Data-rates +### About + Various data-rates are selectable when configuring a channel and are inversely proportional to the theoretical range of the devices. Considerations: @@ -47,6 +49,9 @@ Considerations: * * 4/7 - 1.75x overhead * * 4/8 - 2x overhead + +### Pre-Defined + Predefined Channels: | Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | @@ -56,6 +61,8 @@ Predefined Channels: | Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | | Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | +### Custom Settings + Other settings can be set by using the Python API. > meshtastic --set spread_factor 10 --set coding_rate 8 --bandwidth 125 @@ -75,7 +82,4 @@ Some example settings: | 0.092 kbps | 12 / 4096 | 4/8 | 62 | | | 0.046 kbps | 12 / 4096 | 4/8 | 31 | Twice the range of "Long Slow" | -An easy calculator of other bit rates is: - -[Lora Parameters](https://unsigned.io/understanding-lora-parameters/) From 9c60a7966fb9e254978690959555f69bf78ef37e Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 3 Feb 2021 00:01:52 -0800 Subject: [PATCH 11/28] Update radio-settings.md --- docs/radio-settings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 73aba91ff..4a3f615e0 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -52,7 +52,7 @@ Considerations: ### Pre-Defined -Predefined Channels: +We have four predefined channels. These are the most common settings and have been proven to work well: | Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | |:---------------------------|:-----------------|:---------------------|:-------------|:------------|:----------| @@ -63,7 +63,7 @@ Predefined Channels: ### Custom Settings -Other settings can be set by using the Python API. +You may want to select other channels for your usage. The other settings can be set by using the Python API. > meshtastic --set spread_factor 10 --set coding_rate 8 --bandwidth 125 From b901f8d9ae3dec67ae0623ad106b20df245bdd14 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 3 Feb 2021 00:15:41 -0800 Subject: [PATCH 12/28] Update to radio-settings.md --- docs/radio-settings.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 4a3f615e0..e6b148cc1 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -37,12 +37,12 @@ Various data-rates are selectable when configuring a channel and are inversely p Considerations: -* Spreading Factor +* Spreading Factor - How much we "spread" our data over time. * * Each step up in Spreading Factor dobules the airtime to transmit. * * Each step up in Spreading Factor adds about 2.5db extra link budget. -* Bandwidth +* Bandwidth - How big of a slice of the spectrum we use. * * Each doubling of the bandwidth is almost 3db less link budget. -* Coding Rate +* Coding Rate - How much redundency we encode to resist noise. * * Increasing coding rate increases reliability while decrasing data-rate. * * 4/5 - 1.25x overhead * * 4/6 - 1.5x overhead From 45c17659ccd5add061853ec7c38dbc7d4668c7a2 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 3 Feb 2021 01:04:23 -0800 Subject: [PATCH 13/28] radio-settings.md - add note about TCXO stability --- docs/radio-settings.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index e6b148cc1..027b9638f 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -42,6 +42,7 @@ Considerations: * * Each step up in Spreading Factor adds about 2.5db extra link budget. * Bandwidth - How big of a slice of the spectrum we use. * * Each doubling of the bandwidth is almost 3db less link budget. +* * Bandwidths less than 31 may be unstable unless you have a high quality Crystal Ossilator. * Coding Rate - How much redundency we encode to resist noise. * * Increasing coding rate increases reliability while decrasing data-rate. * * 4/5 - 1.25x overhead From 0fa654e53ad97cd68e38a7ce28e20971fa304a9e Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 3 Feb 2021 07:01:35 -0800 Subject: [PATCH 14/28] update radio-settings.md --- docs/radio-settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index 027b9638f..e45ea387c 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -66,7 +66,7 @@ We have four predefined channels. These are the most common settings and have be You may want to select other channels for your usage. The other settings can be set by using the Python API. -> meshtastic --set spread_factor 10 --set coding_rate 8 --bandwidth 125 +> meshtastic --setchan spread_factor 10 --setchan coding_rate 8 --setchan bandwidth 125 Some example settings: From 0c71de4e59e26a2e53fc6a503b6f669e6df07b4c Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 3 Feb 2021 08:09:59 -0800 Subject: [PATCH 15/28] Update for rangetest plugin --- platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index fc94967b5..bbdd58d48 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,14 +9,14 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -;default_envs = tbeam +default_envs = tbeam ;default_envs = tlora-v1.3 ;default_envs = tbeam0.7 ;default_envs = heltec ;default_envs = tlora-v1 ;default_envs = tlora-v2 ;default_envs = lora-relay-v1 # nrf board -default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here +;default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here [common] ; common is not currently used @@ -44,8 +44,8 @@ build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/n ;upload_port = /dev/ttyUSB0 ;monitor_port = /dev/ttyUSB0 -;upload_port = /dev/cu.SLAB_USBtoUART -;monitor_port = /dev/cu.SLAB_USBtoUART +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART ; the default is esptool ; upload_protocol = esp-prog From f46059ec4c407722caf0e73df593ad7f02b0981e Mon Sep 17 00:00:00 2001 From: Jm Date: Wed, 3 Feb 2021 08:10:13 -0800 Subject: [PATCH 16/28] update to range test plugin --- src/plugins/Plugins.cpp | 4 +-- src/plugins/RangeTestPlugin.cpp | 55 ++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index 93487ac7a..c845e652b 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -31,7 +31,7 @@ void setupPlugins() */ new SerialPlugin(); new ExternalNotificationPlugin(); - new StoreForwardPlugin(); - new RangeTestPlugin(); + //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 ffe98458c..a1fee184b 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -12,15 +12,17 @@ //#undef str - #define RANGETESTPLUGIN_ENABLED 1 -#define RANGETESTPLUGIN_SENDER 20000 +//#define RANGETESTPLUGIN_SENDER 60 * 1000 +#define RANGETESTPLUGIN_SENDER 0 RangeTestPlugin *rangeTestPlugin; RangeTestPluginRadio *rangeTestPluginRadio; RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {} +uint16_t packetSequence = 0; + // char serialStringChar[Constants_DATA_PAYLOAD_LEN]; int32_t RangeTestPlugin::runOnce() @@ -32,34 +34,40 @@ int32_t RangeTestPlugin::runOnce() if (firstTime) { // Interface with the serial peripheral from in here. - DEBUG_MSG("Initializing Range Test Plugin\n"); rangeTestPluginRadio = new RangeTestPluginRadio(); firstTime = 0; + if (RANGETESTPLUGIN_SENDER) { + DEBUG_MSG("Initializing Range Test Plugin -- Sender\n"); + return (RANGETESTPLUGIN_SENDER); + } else { + DEBUG_MSG("Initializing Range Test Plugin -- Receiver\n"); + return (500); + } + } else { - // If sender if (RANGETESTPLUGIN_SENDER) { - - return (RANGETESTPLUGIN_SENDER); - - // Otherwise, we're a receiver. - } else { + // If sender + DEBUG_MSG("Range Test Plugin - Sending heartbeat\n"); rangeTestPluginRadio->sendPayload(); - return (500); + return (RANGETESTPLUGIN_SENDER); + } else { + // Otherwise, we're a receiver. + + return (INT32_MAX); } // TBD } } else { DEBUG_MSG("Range Test Plugin - Disabled\n"); - - return (INT32_MAX); } + return (INT32_MAX); #endif } @@ -79,9 +87,10 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) p->want_ack = true; - uint16_t packetSequence = 123456; + packetSequence++; + static char heartbeatString[20]; - snprintf(heartbeatString, sizeof(heartbeatString), "Seq: %d%%", packetSequence); + snprintf(heartbeatString, sizeof(heartbeatString), "seq %d", packetSequence); p->decoded.data.payload.size = strlen(heartbeatString); // You must specify how many bytes are in the reply memcpy(p->decoded.data.payload.bytes, heartbeatString, p->decoded.data.payload.size); @@ -103,7 +112,10 @@ 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); + /* + + p.payload.size; gpsStatus->getLatitude(); gpsStatus->getLongitude(); @@ -113,6 +125,19 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) mp.hop_limit; mp.decoded.position.latitude_i; mp.decoded.position.longitude_i; + + */ + DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes); + DEBUG_MSG("p.payload.size %d\n", p.payload.size); + DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr); + DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit); + DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); + DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); + 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()); + } } else { From 056940a4ad39144602fab4f47706f1db2eb0e6bb Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 6 Feb 2021 09:13:49 -0800 Subject: [PATCH 17/28] Documentation --- docs/radio-settings.md | 11 +++++++++++ .../{StoreRequestPlugin.md => StoreForwardPlugin.md} | 0 2 files changed, 11 insertions(+) rename docs/software/plugins/{StoreRequestPlugin.md => StoreForwardPlugin.md} (100%) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index e45ea387c..d8790d0a2 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -84,3 +84,14 @@ Some example settings: | 0.046 kbps | 12 / 4096 | 4/8 | 31 | Twice the range of "Long Slow" | +## Cryptography + +The presahred key used by the devices can be updated. + +* 0 = No crypto +* 1 = Default channel key +* 2 - 10 = The default channel key, except with 1 through 9 added to the last byte + +To disable cryptography: + +> meshtastic --setchan psk 0 \ No newline at end of file diff --git a/docs/software/plugins/StoreRequestPlugin.md b/docs/software/plugins/StoreForwardPlugin.md similarity index 100% rename from docs/software/plugins/StoreRequestPlugin.md rename to docs/software/plugins/StoreForwardPlugin.md From 9035a06b4a3a22c24f34d122194a76b6f9525355 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 6 Feb 2021 10:02:23 -0800 Subject: [PATCH 18/28] Add link budget to radio-settings.md --- docs/radio-settings.md | 43 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index e45ea387c..122dcc01d 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -55,12 +55,14 @@ Considerations: We have four predefined channels. These are the most common settings and have been proven to work well: -| Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | -|:---------------------------|:-----------------|:---------------------|:-------------|:------------|:----------| -| Short range (but fast) | Short Fast | 21.875 kbps | 7 / 128 | 4/5 | 125 | -| Medium range (but fast) | Medium | 5.469 kbps | 7 / 512 | 4/5 | 500 | -| Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | -| Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | +| Channel setting | Alt Channel Name | Data-rate | SF / Symbols | Coding Rate | Bandwidth | Link Budget | +|:---------------------------|:-----------------|:---------------------|:-------------|:------------|:----------|:------------| +| Short range (but fast) | Short Fast | 21.875 kbps | 7 / 128 | 4/5 | 125 | 134dB | +| Medium range (but fast) | Medium | 5.469 kbps | 7 / 128 | 4/5 | 500 | 140dB | +| Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | 153dB | +| Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | 154dB | + +The link budget used by these calculations assumes a transmit power of 17dBm. Adjust your link budget assumptions based on your actual devices. ### Custom Settings @@ -68,19 +70,24 @@ You may want to select other channels for your usage. The other settings can be > meshtastic --setchan spread_factor 10 --setchan coding_rate 8 --setchan bandwidth 125 +After applying the settings, you will need to restart the device. After your device is restarted, it will generate a new crypto key and you will need to share the newly generated QR Code or URL to all your other devices. + Some example settings: -| Data-rate | SF / Symbols | Coding Rate | Bandwidth | Note | -|:---------------------|:-------------|:------------|:----------|:-----| -| 3.125 kbps | 8 / 256 | 4/5 | 125 | | -| 1.953 kbps | 8 / 256 | 4/8 | 125 | | -| 1.343 kbps | 11 / 2048 | 4/8 | 512 | | -| 1.099 kbps | 9 / 512 | 4/8 | 125 | | -| 0.814 kbps | 10 / 1024 | 4/6 | 125 | | -| 0.610 kbps | 10 / 1024 | 4/8 | 125 | | -| 0.488 kbps | 11 / 2048 | 4/6 | 125 | | -| 0.336 kbps | 11 / 2048 | 4/8 | 125 | | -| 0.092 kbps | 12 / 4096 | 4/8 | 62 | | -| 0.046 kbps | 12 / 4096 | 4/8 | 31 | Twice the range of "Long Slow" | +| Data-rate | SF / Symbols | Coding Rate | Bandwidth | Link Budget | Note | +|:---------------------|:-------------|:------------|:----------|:------------|:-----| +| 37.50 kbps | 6 / 64 | 4/5 | 500 | 129dB | Fastest possible speed | +| 3.125 kbps | 8 / 256 | 4/5 | 125 | 143dB | | +| 1.953 kbps | 8 / 256 | 4/8 | 125 | 143dB | | +| 1.343 kbps | 11 / 2048 | 4/8 | 500 | 145dB | | +| 1.099 kbps | 9 / 512 | 4/8 | 125 | 146dB | | +| 0.814 kbps | 10 / 1024 | 4/6 | 125 | 149dB | | +| 0.610 kbps | 10 / 1024 | 4/8 | 125 | 149dB | | +| 0.488 kbps | 11 / 2048 | 4/6 | 125 | 152dB | | +| 0.336 kbps | 11 / 2048 | 4/8 | 125 | 152dB | | +| 0.073 kbps | 12 / 4096 | 4/5 | 31 | 160dB | Twice the range of "Long Slow", low resliance to noise | +| 0.046 kbps | 12 / 4096 | 4/8 | 31 | 160dB | Twice the range of "Long Slow", high resliance to noise | +The link budget used by these calculations assumes a transmit power of 17dBm. Adjust your link budget assumptions based on your actual devices. +These channel settings may have not been tested. Use at your own discression. Share on https://meshtastic.discourse.group with your successes or failure. From 22af1b551a6840fec24c4195e072d3d4f363c6a3 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 6 Feb 2021 10:06:20 -0800 Subject: [PATCH 19/28] Add note about antenna gain. --- docs/radio-settings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index baa076542..c7ac2c9a3 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -62,7 +62,7 @@ We have four predefined channels. These are the most common settings and have be | Long range (but slower) | Long Alt | 0.275 kbps | 9 / 512 | 4/8 | 31 | 153dB | | Very long range (but slow) | Long Slow | 0.183 kbps (default) | 12 / 4096 | 4/8 | 125 | 154dB | -The link budget used by these calculations assumes a transmit power of 17dBm. Adjust your link budget assumptions based on your actual devices. +The link budget used by these calculations assumes a transmit power of 17dBm and an antenna with 0dB gain. Adjust your link budget assumptions based on your actual devices. ### Custom Settings @@ -88,7 +88,7 @@ Some example settings: | 0.073 kbps | 12 / 4096 | 4/5 | 31 | 160dB | Twice the range of "Long Slow", low resliance to noise | | 0.046 kbps | 12 / 4096 | 4/8 | 31 | 160dB | Twice the range of "Long Slow", high resliance to noise | -The link budget used by these calculations assumes a transmit power of 17dBm. Adjust your link budget assumptions based on your actual devices. +The link budget used by these calculations assumes a transmit power of 17dBm and an antenna with 0dB gain. Adjust your link budget assumptions based on your actual devices. These channel settings may have not been tested. Use at your own discression. Share on https://meshtastic.discourse.group with your successes or failure. From 9f9f02fc6f6b1054c72279855afe55c813255122 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 6 Feb 2021 21:38:54 -0800 Subject: [PATCH 20/28] Reverting platform.ini back to the way it was. --- platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index bbdd58d48..fc94967b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,14 +9,14 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = tbeam +;default_envs = tbeam ;default_envs = tlora-v1.3 ;default_envs = tbeam0.7 ;default_envs = heltec ;default_envs = tlora-v1 ;default_envs = tlora-v2 ;default_envs = lora-relay-v1 # nrf board -;default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here +default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here [common] ; common is not currently used @@ -44,8 +44,8 @@ build_flags = -Wno-missing-field-initializers -Isrc -Isrc/mesh -Isrc/gps -Ilib/n ;upload_port = /dev/ttyUSB0 ;monitor_port = /dev/ttyUSB0 -upload_port = /dev/cu.SLAB_USBtoUART -monitor_port = /dev/cu.SLAB_USBtoUART +;upload_port = /dev/cu.SLAB_USBtoUART +;monitor_port = /dev/cu.SLAB_USBtoUART ; the default is esptool ; upload_protocol = esp-prog From d678c4888471805b87016d5d4a7d5b79b8cabde3 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 6 Feb 2021 23:29:18 -0800 Subject: [PATCH 21/28] 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 a6388af96..fb503be49 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 6bf3a1c01..d37806307 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 c845e652b..ac8dd7336 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 a1fee184b..bae5e45fd 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 c40c35109..4ee4eac7c 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) { From 4ee01acb40487a97131842d890d324446497214e Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 7 Feb 2021 09:31:29 -0800 Subject: [PATCH 22/28] Change where the location information is taken from. --- src/plugins/RangeTestPlugin.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index bae5e45fd..f1131dfd0 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -53,13 +53,13 @@ int32_t RangeTestPlugin::runOnce() if (radioConfig.preferences.range_test_plugin_sender) { // If sender - DEBUG_MSG("Range Test Plugin - Sending heartbeat every %d ms\n", - (senderHeartbeat)); + 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("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); DEBUG_MSG("pref.fixed_position() %d\n", radioConfig.preferences.fixed_position); rangeTestPluginRadio->sendPayload(); @@ -125,23 +125,27 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) /* - p.payload.size; - gpsStatus->getLatitude(); - gpsStatus->getLongitude(); - gpsStatus->getHasLock(); - gpsStatus->getDOP(); - mp.rx_snr; - mp.hop_limit; - mp.decoded.position.latitude_i; - mp.decoded.position.longitude_i; */ + + NodeInfo *n = nodeDB.getNode(mp.from); + DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes); DEBUG_MSG("p.payload.size %d\n", p.payload.size); + DEBUG_MSG("mp.from %d\n", mp.from); DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr); DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit); - DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); - DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); + // DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); + // DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); + DEBUG_MSG("n->has_position %d\n", n->has_position); + DEBUG_MSG("n->position.latitude_i %d\n", n->position.latitude_i); + DEBUG_MSG("n->position.longitude_i %d\n", n->position.longitude_i); + + n->user.long_name; + n->user.short_name; + n->user.macaddr; + n->position.battery_level; + DEBUG_MSG("gpsStatus->getLatitude() %d\n", gpsStatus->getLatitude()); DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude()); DEBUG_MSG("gpsStatus->getHasLock() %d\n", gpsStatus->getHasLock()); From cb541d75a93a54fd73fd24f1aa8494384300dd43 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 7 Feb 2021 13:19:52 -0800 Subject: [PATCH 23/28] Update radio-settings.md with note of coverage. --- docs/radio-settings.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/radio-settings.md b/docs/radio-settings.md index c7ac2c9a3..3240d3ddd 100644 --- a/docs/radio-settings.md +++ b/docs/radio-settings.md @@ -85,8 +85,8 @@ Some example settings: | 0.610 kbps | 10 / 1024 | 4/8 | 125 | 149dB | | | 0.488 kbps | 11 / 2048 | 4/6 | 125 | 152dB | | | 0.336 kbps | 11 / 2048 | 4/8 | 125 | 152dB | | -| 0.073 kbps | 12 / 4096 | 4/5 | 31 | 160dB | Twice the range of "Long Slow", low resliance to noise | -| 0.046 kbps | 12 / 4096 | 4/8 | 31 | 160dB | Twice the range of "Long Slow", high resliance to noise | +| 0.073 kbps | 12 / 4096 | 4/5 | 31 | 160dB | Twice the range and/or coverage of "Long Slow", low resliance to noise | +| 0.046 kbps | 12 / 4096 | 4/8 | 31 | 160dB | Twice the range and/or coverage of "Long Slow", high resliance to noise | The link budget used by these calculations assumes a transmit power of 17dBm and an antenna with 0dB gain. Adjust your link budget assumptions based on your actual devices. From ca8a0ca8d222aef2dfe09d1e099500153c0e1df3 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 7 Feb 2021 19:20:29 -0800 Subject: [PATCH 24/28] update rangetest --- src/plugins/RangeTestPlugin.cpp | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index f1131dfd0..4ed11f447 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -7,6 +7,13 @@ #include #include +/* + As a sender, I can send packets every n-seonds. These packets include an incramented PacketID. + + As a receiver, I can receive packets from multiple senders. These packets can be saved to the spiffs. + +*/ + RangeTestPlugin *rangeTestPlugin; RangeTestPluginRadio *rangeTestPluginRadio; @@ -26,7 +33,7 @@ int32_t RangeTestPlugin::runOnce() */ radioConfig.preferences.range_test_plugin_enabled = 1; - radioConfig.preferences.range_test_plugin_sender = 60; + radioConfig.preferences.range_test_plugin_sender = 0; radioConfig.preferences.fixed_position = 1; uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; @@ -130,26 +137,30 @@ bool RangeTestPluginRadio::handleReceived(const MeshPacket &mp) NodeInfo *n = nodeDB.getNode(mp.from); + + DEBUG_MSG("-----------------------------------------\n"); DEBUG_MSG("p.payload.bytes \"%s\"\n", p.payload.bytes); DEBUG_MSG("p.payload.size %d\n", p.payload.size); + DEBUG_MSG("---- Received Packet:\n"); DEBUG_MSG("mp.from %d\n", mp.from); DEBUG_MSG("mp.rx_snr %f\n", mp.rx_snr); DEBUG_MSG("mp.hop_limit %d\n", mp.hop_limit); - // DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); - // DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); - DEBUG_MSG("n->has_position %d\n", n->has_position); - DEBUG_MSG("n->position.latitude_i %d\n", n->position.latitude_i); - DEBUG_MSG("n->position.longitude_i %d\n", n->position.longitude_i); - - n->user.long_name; - n->user.short_name; - n->user.macaddr; - n->position.battery_level; - + DEBUG_MSG("mp.decoded.position.latitude_i %d\n", mp.decoded.position.latitude_i); + DEBUG_MSG("mp.decoded.position.longitude_i %d\n", mp.decoded.position.longitude_i); + DEBUG_MSG("---- Node Information of Received Packet (mp.from):\n"); + DEBUG_MSG("n->user.long_name %s\n", n->user.long_name); + DEBUG_MSG("n->user.short_name %s\n", n->user.short_name); + DEBUG_MSG("n->user.macaddr %X\n", n->user.macaddr); + DEBUG_MSG("n->has_position %d\n", n->has_position); + DEBUG_MSG("n->position.latitude_i %d\n", n->position.latitude_i); + DEBUG_MSG("n->position.longitude_i %d\n", n->position.longitude_i); + DEBUG_MSG("n->position.battery_level %d\n", n->position.battery_level); + DEBUG_MSG("---- Current device location information:\n"); 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("-----------------------------------------\n"); } } else { From b29bcbbd4170416d937f0e299235b5c250063e4f Mon Sep 17 00:00:00 2001 From: Jm Date: Tue, 9 Feb 2021 21:59:00 -0800 Subject: [PATCH 25/28] #682 Exposing the actual radio center frequency to /static/report --- src/mesh/RadioInterface.cpp | 41 ++++++++++++++++++++++++++++---- src/mesh/RadioInterface.h | 23 ++++++++++++++++++ src/mesh/http/ContentHandler.cpp | 11 ++++++++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index b1aa807bc..01f3f7911 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -209,6 +209,38 @@ unsigned long hash(const char *str) return hash; } +/** + * Save our frequency for later reuse. + */ +void RadioInterface::saveFreq(float freq) +{ + savedFreq = freq; +} + +/** + * Save our channel for later reuse. + */ +void RadioInterface::saveChannelNum(uint32_t channel_num) +{ + savedChannelNum = channel_num; +} + +/** + * Save our frequency for later reuse. + */ +float RadioInterface::getFreq() +{ + return savedFreq; +} + +/** + * Save our channel for later reuse. + */ +uint32_t RadioInterface::getChannelNum() +{ + return savedChannelNum; +} + /** * Pull our channel settings etc... from protobufs to the dumb interface settings */ @@ -261,18 +293,19 @@ void RadioInterface::applyModemConfig() assert(myRegion); // Should have been found in init // If user has manually specified a channel num, then use that, otherwise generate one by hashing the name - int channel_num = - (channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName)) % myRegion->numChannels; + int channel_num = (channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName)) % myRegion->numChannels; freq = myRegion->freq + myRegion->spacing * channel_num; - DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, power=%d\n", channelName, channelSettings.modem_config, channel_num, - power); + DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, power=%d\n", channelName, channelSettings.modem_config, channel_num, power); DEBUG_MSG("Radio myRegion->freq: %f\n", myRegion->freq); DEBUG_MSG("Radio myRegion->spacing: %f\n", myRegion->spacing); DEBUG_MSG("Radio myRegion->numChannels: %d\n", myRegion->numChannels); DEBUG_MSG("Radio channel_num: %d\n", channel_num); DEBUG_MSG("Radio frequency: %f\n", freq); DEBUG_MSG("Short packet time: %u msec\n", shortPacketMsec); + + saveChannelNum(channel_num); + saveFreq(freq); } /** diff --git a/src/mesh/RadioInterface.h b/src/mesh/RadioInterface.h index 0d8c7b9b7..1f4fb8457 100644 --- a/src/mesh/RadioInterface.h +++ b/src/mesh/RadioInterface.h @@ -133,9 +133,22 @@ class RadioInterface uint32_t getPacketTime(MeshPacket *p); uint32_t getPacketTime(uint32_t totalPacketLen); + /** + * Get the channel we saved. + */ + uint32_t getChannelNum(); + + /** + * Get the frequency we saved. + */ + float getFreq(); + protected: int8_t power = 17; // Set by applyModemConfig() + float savedFreq; + uint32_t savedChannelNum; + /*** * given a packet set sendingPacket and decode the protobufs into radiobuf. Returns # of bytes to send (including the * PacketHeader & payload). @@ -157,6 +170,16 @@ class RadioInterface */ virtual void applyModemConfig(); + /** + * Save the frequency we selected for later reuse. + */ + virtual void saveFreq(float savedFreq); + + /** + * Save the chanel we selected for later reuse. + */ + virtual void saveChannelNum(uint32_t savedChannelNum); + private: /// Return 0 if sleep is okay int preflightSleepCb(void *unused = NULL) { return canSleep() ? 0 : 1; } diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 5f79702fc..8535dd349 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "RadioLibInterface.h" #ifndef NO_ESP32 #include "esp_task_wdt.h" @@ -928,10 +929,18 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->printf("\"has_battery\": %s,\n", BoolToString(powerStatus->getHasBattery())); res->printf("\"has_usb\": %s,\n", BoolToString(powerStatus->getHasUSB())); res->printf("\"is_charging\": %s\n", BoolToString(powerStatus->getIsCharging())); - res->println("}"); + res->println("},"); + + res->println("\"radio\": {"); + res->printf("\"frequecy\": %f,\n", RadioLibInterface::instance->getFreq()); + res->printf("\"lora_channel\": %d\n", RadioLibInterface::instance->getChannelNum()); + res->println("},"); + res->println("},"); + + res->println("\"status\": \"ok\""); res->println("}"); } From 8c27baae844ba7b5f6d41bf24a34cce666f6f31b Mon Sep 17 00:00:00 2001 From: Jm Date: Fri, 12 Feb 2021 18:48:18 -0800 Subject: [PATCH 26/28] Update platformio.ini --- platformio.ini | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/platformio.ini b/platformio.ini index fc94967b5..c90e9c7c5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,14 +9,13 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -;default_envs = tbeam -;default_envs = tlora-v1.3 +default_envs = tbeam ;default_envs = tbeam0.7 ;default_envs = heltec ;default_envs = tlora-v1 ;default_envs = tlora-v2 ;default_envs = lora-relay-v1 # nrf board -default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here +;default_envs = linux # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here [common] ; common is not currently used @@ -150,12 +149,6 @@ board = ttgo-lora32-v1 build_flags = ${esp32_base.build_flags} -D TLORA_V1 -[env:tlora-v1.3] -extends = esp32_base -board = ttgo-lora32-v1 -build_flags = - ${esp32_base.build_flags} -D TLORA_V1_3 - ; note: the platformio definition for lora32-v2 seems stale, it is missing a pins_arduino.h file, therefore I don't think it works [env:tlora-v2] extends = esp32_base @@ -349,4 +342,4 @@ lib_deps = extends = esp32_base board = genieblocks_lora build_flags = - ${esp32_base.build_flags} -D GENIEBLOCKS + ${esp32_base.build_flags} -D GENIEBLOCKS \ No newline at end of file From c9b1ee532dc030ddd045a7c0e7ed6533a6f7c4c5 Mon Sep 17 00:00:00 2001 From: Jm Date: Fri, 12 Feb 2021 18:49:24 -0800 Subject: [PATCH 27/28] Update deviceonly.pb.h --- src/mesh/generated/deviceonly.pb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index fb503be49..99d838d39 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -80,10 +80,10 @@ extern const pb_msgdesc_t DeviceState_msg; #define DeviceState_fields &DeviceState_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 6262 +#define DeviceState_size 6266 #ifdef __cplusplus } /* extern "C" */ #endif -#endif +#endif \ No newline at end of file From e225af28dc9f63ff555e85f51af87e8b52138b4a Mon Sep 17 00:00:00 2001 From: Jm Date: Fri, 12 Feb 2021 18:52:31 -0800 Subject: [PATCH 28/28] Disable plugins --- src/plugins/RangeTestPlugin.cpp | 6 +++--- src/plugins/StoreForwardPlugin.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/RangeTestPlugin.cpp b/src/plugins/RangeTestPlugin.cpp index 4ed11f447..8f03589c2 100644 --- a/src/plugins/RangeTestPlugin.cpp +++ b/src/plugins/RangeTestPlugin.cpp @@ -32,9 +32,9 @@ int32_t RangeTestPlugin::runOnce() without having to configure it from the PythonAPI or WebUI. */ - radioConfig.preferences.range_test_plugin_enabled = 1; - radioConfig.preferences.range_test_plugin_sender = 0; - radioConfig.preferences.fixed_position = 1; + // radioConfig.preferences.range_test_plugin_enabled = 1; + // radioConfig.preferences.range_test_plugin_sender = 0; + // radioConfig.preferences.fixed_position = 1; uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; diff --git a/src/plugins/StoreForwardPlugin.cpp b/src/plugins/StoreForwardPlugin.cpp index 4ee4eac7c..f71fb965b 100644 --- a/src/plugins/StoreForwardPlugin.cpp +++ b/src/plugins/StoreForwardPlugin.cpp @@ -19,7 +19,7 @@ struct sfRecord struct sfRecord records[STORE_RECORDS]; -#define STOREFORWARDPLUGIN_ENABLED 1 +#define STOREFORWARDPLUGIN_ENABLED 0 StoreForwardPlugin *storeForwardPlugin; StoreForwardPluginRadio *storeForwardPluginRadio;