From 7cda49aba539d6fffedf06499779684697210cd6 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 16:56:57 -0800 Subject: [PATCH 01/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 2930129e8..c703d579b 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 2930129e8eac348c094bbedeb929d86efafc2b62 +Subproject commit c703d579b20e184278546497246ce54b3bdd4118 From 7f3ad672b8a09763b0c2341aa48fe26fc35c2d61 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 16:59:24 -0800 Subject: [PATCH 02/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index c703d579b..d70449103 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit c703d579b20e184278546497246ce54b3bdd4118 +Subproject commit d704491030b659d20398ebd6bd74994297df069c From ee95594f741c540717bef43b30ae62756e6fe1ad Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 17:01:13 -0800 Subject: [PATCH 03/93] Rename EU865 to EU868 & Add TH and IN --- src/mesh/generated/radioconfig.pb.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 760d15e2b..b8850d05c 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -14,13 +14,15 @@ typedef enum _RegionCode { RegionCode_Unset = 0, RegionCode_US = 1, RegionCode_EU433 = 2, - RegionCode_EU865 = 3, + RegionCode_EU868 = 3, RegionCode_CN = 4, RegionCode_JP = 5, RegionCode_ANZ = 6, RegionCode_KR = 7, RegionCode_TW = 8, - RegionCode_RU = 9 + RegionCode_RU = 9, + RegionCode_IN = 10, + RegionCode_TH = 11 } RegionCode; typedef enum _ChargeCurrent { @@ -98,7 +100,8 @@ typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType { RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280 = 5, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808 = 7 + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808 = 7, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3 = 8 } RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType; /* Struct definitions */ @@ -197,8 +200,8 @@ typedef struct _RadioConfig { /* Helper constants for enums */ #define _RegionCode_MIN RegionCode_Unset -#define _RegionCode_MAX RegionCode_RU -#define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_RU+1)) +#define _RegionCode_MAX RegionCode_TH +#define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TH+1)) #define _ChargeCurrent_MIN ChargeCurrent_MAUnset #define _ChargeCurrent_MAX ChargeCurrent_MA1320 @@ -225,8 +228,8 @@ typedef struct _RadioConfig { #define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1)) #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808+1)) +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3 +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3+1)) #ifdef __cplusplus From 806a61251b3890a13d25467d4be35792ed1c7669 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 17:59:43 -0800 Subject: [PATCH 04/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index d70449103..956fa74e8 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit d704491030b659d20398ebd6bd74994297df069c +Subproject commit 956fa74e806574ba5a7facf899101035c3511bc9 From a1ad1e7973b6fa89d4b5aa7e4ff24d2d497e7dba Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 18:01:34 -0800 Subject: [PATCH 05/93] Updated modem configuration --- src/mesh/generated/channel.pb.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mesh/generated/channel.pb.h b/src/mesh/generated/channel.pb.h index d9d55f1f7..e4b54aeab 100644 --- a/src/mesh/generated/channel.pb.h +++ b/src/mesh/generated/channel.pb.h @@ -11,12 +11,13 @@ /* Enum definitions */ typedef enum _ChannelSettings_ModemConfig { - ChannelSettings_ModemConfig_Bw125Cr45Sf128 = 0, - ChannelSettings_ModemConfig_Bw500Cr45Sf128 = 1, - ChannelSettings_ModemConfig_Bw31_25Cr48Sf512 = 2, - ChannelSettings_ModemConfig_Bw125Cr48Sf4096 = 3, - ChannelSettings_ModemConfig_Bw250Cr46Sf2048 = 4, - ChannelSettings_ModemConfig_Bw250Cr47Sf1024 = 5 + ChannelSettings_ModemConfig_VLongSlow = 0, + ChannelSettings_ModemConfig_LongSlow = 1, + ChannelSettings_ModemConfig_LongFast = 2, + ChannelSettings_ModemConfig_MidSlow = 3, + ChannelSettings_ModemConfig_MidFast = 4, + ChannelSettings_ModemConfig_ShortSlow = 5, + ChannelSettings_ModemConfig_ShortFast = 6 } ChannelSettings_ModemConfig; typedef enum _Channel_Role { @@ -50,9 +51,9 @@ typedef struct _Channel { /* Helper constants for enums */ -#define _ChannelSettings_ModemConfig_MIN ChannelSettings_ModemConfig_Bw125Cr45Sf128 -#define _ChannelSettings_ModemConfig_MAX ChannelSettings_ModemConfig_Bw250Cr47Sf1024 -#define _ChannelSettings_ModemConfig_ARRAYSIZE ((ChannelSettings_ModemConfig)(ChannelSettings_ModemConfig_Bw250Cr47Sf1024+1)) +#define _ChannelSettings_ModemConfig_MIN ChannelSettings_ModemConfig_VLongSlow +#define _ChannelSettings_ModemConfig_MAX ChannelSettings_ModemConfig_ShortFast +#define _ChannelSettings_ModemConfig_ARRAYSIZE ((ChannelSettings_ModemConfig)(ChannelSettings_ModemConfig_ShortFast+1)) #define _Channel_Role_MIN Channel_Role_DISABLED #define _Channel_Role_MAX Channel_Role_SECONDARY From 2428ca09fcab7b681660ec7d6bca3827adce8d8b Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 18:06:05 -0800 Subject: [PATCH 06/93] Change the default pre shared key to break backward compatibility of default channel --- src/mesh/Channels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index d757fdb33..33bcbcdce 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -7,7 +7,7 @@ /// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128) static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, - 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf}; + 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01}; Channels channels; From 96b55372170a4ac5e02d8b9f5011a27784a331d3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 19:32:31 -0800 Subject: [PATCH 07/93] New bands, new band plans and new channel configurations --- src/mesh/Channels.cpp | 28 +++---- src/mesh/MeshRadio.h | 9 +- src/mesh/RadioInterface.cpp | 162 +++++++++++++++++++++++------------- 3 files changed, 123 insertions(+), 76 deletions(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 33bcbcdce..116462e3a 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -84,10 +84,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex) Channel &ch = getByIndex(chIndex); ChannelSettings &channelSettings = ch.settings; - // radioConfig.modem_config = RadioConfig_ModemConfig_Bw125Cr45Sf128; // medium range and fast - // channelSettings.modem_config = ChannelSettings_ModemConfig_Bw500Cr45Sf128; // short range and fast, but wide - // bandwidth so incompatible radios can talk together - channelSettings.modem_config = ChannelSettings_ModemConfig_Bw125Cr48Sf4096; // slow and long range + channelSettings.modem_config = ChannelSettings_ModemConfig_LongSlow; // Default to Long Range & Fast channelSettings.tx_power = 0; // default uint8_t defaultpskIndex = 1; @@ -216,24 +213,27 @@ const char *Channels::getName(size_t chIndex) channelName = "Unset"; else switch (channelSettings.modem_config) { - case ChannelSettings_ModemConfig_Bw125Cr45Sf128: + case ChannelSettings_ModemConfig_ShortSlow: channelName = "ShortSlow"; break; - case ChannelSettings_ModemConfig_Bw500Cr45Sf128: + case ChannelSettings_ModemConfig_ShortFast: channelName = "ShortFast"; break; - case ChannelSettings_ModemConfig_Bw31_25Cr48Sf512: - channelName = "LongFast"; - break; - case ChannelSettings_ModemConfig_Bw125Cr48Sf4096: - channelName = "LongSlow"; - break; - case ChannelSettings_ModemConfig_Bw250Cr46Sf2048: + case ChannelSettings_ModemConfig_MidSlow: channelName = "MediumSlow"; break; - case ChannelSettings_ModemConfig_Bw250Cr47Sf1024: + case ChannelSettings_ModemConfig_MidFast: channelName = "MediumFast"; break; + case ChannelSettings_ModemConfig_LongFast: + channelName = "LongFast"; + break; + case ChannelSettings_ModemConfig_LongSlow: + channelName = "LongSlow"; + break; + case ChannelSettings_ModemConfig_VLongSlow: + channelName = "VLongSlow"; + break; default: channelName = "Invalid"; break; diff --git a/src/mesh/MeshRadio.h b/src/mesh/MeshRadio.h index 02e775464..1b1437123 100644 --- a/src/mesh/MeshRadio.h +++ b/src/mesh/MeshRadio.h @@ -8,10 +8,13 @@ // Map from old region names to new region enums struct RegionInfo { RegionCode code; - uint8_t numChannels; - uint8_t powerLimit; // Or zero for not set - float freq; + float freqStart; + float freqEnd; + float dutyCycle; float spacing; + uint8_t powerLimit; // Or zero for not set + bool audioPermitted; + bool freqSwitching; const char *name; // EU433 etc }; diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 269f6a071..97275825d 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -1,4 +1,3 @@ -#include "configuration.h" #include "RadioInterface.h" #include "Channels.h" #include "MeshRadio.h" @@ -6,45 +5,86 @@ #include "NodeDB.h" #include "Router.h" #include "assert.h" +#include "configuration.h" #include "sleep.h" #include #include #include -#define RDEF(name, freq, spacing, num_ch, power_limit) \ +#define RDEF(name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, frequency_switching) \ { \ - RegionCode_##name, num_ch, power_limit, freq, spacing, #name \ + RegionCode_##name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, frequency_switching, #name \ } const RegionInfo regions[] = { - RDEF(US, 903.08f, 2.16f, 13, 0), RDEF(EU433, 433.175f, 0.2f, 8, 0), RDEF(EU865, 865.2f, 0.3f, 10, 0), - RDEF(CN, 470.0f, 2.0f, 20, 0), - RDEF(JP, 920.0f, 0.5f, 10, 13), // See https://github.com/meshtastic/Meshtastic-device/issues/346 power level 13 - RDEF(ANZ, 916.0f, 0.5f, 20, 0), // AU/NZ channel settings 915-928MHz - RDEF(KR, 921.9f, 0.2f, 8, 0), // KR channel settings (KR920-923) Start from TTN download channel - // freq. (921.9f is for download, others are for uplink) - RDEF(TW, 923.0f, 0.2f, 10, 0), // TW channel settings (AS2 bandplan 923-925MHz) - RDEF(RU, 868.9f, 0.2f, 2, 20), // See notes below - RDEF(Unset, 903.08f, 2.16f, 13, 0) // Assume US freqs if unset, Must be last + /* + https://link.springer.com/content/pdf/bbm%3A978-1-4842-4357-2%2F1.pdf + https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/ + */ + RDEF(US, 902.0f, 928.0f, 100, 0, 30, true, false), + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + */ + RDEF(EU433, 433.0f, 434.0f, 10, 0, 12, true, false), + + /* + https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/ + https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/ + https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true + */ + RDEF(EU868, 869.4f, 869.65f, 10, 0, 16, false, false), + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + */ + RDEF(CN, 470.0f, 510.0f, 100, 0, 19, true, false), + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + */ + RDEF(JP, 920.8f, 927.8f, 100, 0, 16, true, false), + + /* + ??? + */ + RDEF(ANZ, 915.0f, 928.0f, 100, 0, 0, true, false), + + /* + https://digital.gov.ru/uploaded/files/prilozhenie-12-k-reshenyu-gkrch-18-46-03-1.pdf + + Note: + - We do LBT, so 100% is allowed. + */ + RDEF(RU, 868.7f, 869.2f, 100, 0, 20, true, false), + + /* + ??? + */ + RDEF(KR, 920.0f, 923.0f, 100, 0, 0, true, false), + + /* + ??? + */ + RDEF(TW, 920.0f, 925.0f, 100, 0, 0, true, false), + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + */ + RDEF(IN, 865.0f, 867.0f, 100, 0, 30, true, false), + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + */ + RDEF(TH, 920.0f, 925.0f, 100, 0, 16, true, false), + + /* + This needs to be last. Same as US. + */ + RDEF(Unset, 902.0f, 928.0f, 100, 0, 30, true, false) + }; -/* Notes about the RU bandplan (from @denis-d in https://meshtastic.discourse.group/t/russian-band-plan-proposal/2786/2): - -According to Annex 12 to GKRCh (National Radio Frequency Commission) decision № 18-46-03-1 (September 11th 2018) -https://digital.gov.ru/uploaded/files/prilozhenie-12-k-reshenyu-gkrch-18-46-03-1.pdf 1 We have 3 options for 868 MHz: - -864,0 - 865,0 MHz ERP 25mW, Duty Cycle 0.1% (3.6 sec in hour) or LBT (Listen Before Talk), prohibited in airports. -866,0 - 868,0 MHz ERP 25mW, Duty Cycle 1% or LBT, PSD (Power Spectrum Density) 1000mW/MHz, prohibited in airports -868,7 - 869,2 MHz ERP 100mW, Duty Cycle 10% or LBT, no resctrictions -and according to RP2-1.0.2 LoRaWAN® Regional Parameters RP2-1.0.2 LoRaWAN® Regional Parameters - LoRa Alliance® -I propose to use following meshtastic bandplan: -1 channel - central frequency 868.9MHz 125kHz band -Protective band - 75kHz -2 channel - central frequency 869.1MHz 125kHz band - -RDEF(RU, 868.9f, 0.2f, 2, 20) -*/ - const RegionInfo *myRegion; void initRegion() @@ -55,7 +95,8 @@ void initRegion() myRegion = r; DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name); - myNodeInfo.num_bands = myRegion->numChannels; // Tell our android app how many channels we have + // myNodeInfo.num_bands = myRegion->numChannels; // Tell our android app how many channels we have + myNodeInfo.num_bands = 666; // JM Fixme! } /** @@ -274,38 +315,40 @@ void RadioInterface::applyModemConfig() auto channelSettings = channels.getPrimary(); if (channelSettings.spread_factor == 0) { switch (channelSettings.modem_config) { - case ChannelSettings_ModemConfig_Bw125Cr45Sf128: ///< Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium - ///< range - bw = 125; - cr = 5; + case ChannelSettings_ModemConfig_ShortFast: + bw = 250; + cr = 8; sf = 7; break; - case ChannelSettings_ModemConfig_Bw500Cr45Sf128: ///< Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short - ///< range - bw = 500; - cr = 5; - sf = 7; + case ChannelSettings_ModemConfig_ShortSlow: + bw = 250; + cr = 8; + sf = 8; break; - case ChannelSettings_ModemConfig_Bw31_25Cr48Sf512: ///< Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long - ///< range - bw = 31.25; + case ChannelSettings_ModemConfig_MidFast: + bw = 250; cr = 8; sf = 9; break; - case ChannelSettings_ModemConfig_Bw125Cr48Sf4096: + case ChannelSettings_ModemConfig_MidSlow: + bw = 250; + cr = 8; + sf = 10; + break; + case ChannelSettings_ModemConfig_LongSlow: + bw = 250; + cr = 8; + sf = 11; + break; + case ChannelSettings_ModemConfig_LongFast: bw = 125; cr = 8; sf = 12; break; - case ChannelSettings_ModemConfig_Bw250Cr46Sf2048: - bw = 250; - cr = 6; - sf = 11; - break; - case ChannelSettings_ModemConfig_Bw250Cr47Sf1024: - bw = 250; - cr = 7; - sf = 10; + case ChannelSettings_ModemConfig_VLongSlow: + bw = 31.25; + cr = 8; + sf = 12; break; default: assert(0); // Unknown enum @@ -327,20 +370,21 @@ void RadioInterface::applyModemConfig() assert(myRegion); // Should have been found in init + // Calculate the number of channels + uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart)/(myRegion->spacing + bw)); + // If user has manually specified a channel num, then use that, otherwise generate one by hashing the name const char *channelName = channels.getName(channels.getPrimaryIndex()); - int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % myRegion->numChannels; - float freq = myRegion->freq + radioConfig.preferences.frequency_offset + myRegion->spacing * channel_num; - + int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels; + float freq = myRegion->freqStart+(((myRegion->freqEnd - myRegion->freqStart/numChannels)/2)*1); saveChannelNum(channel_num); saveFreq(freq); 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 myRegion->freqStart / myRegion->freqEnd: %f / %f\n", myRegion->freqStart, myRegion->freqEnd); + DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels); DEBUG_MSG("Radio channel_num: %d\n", channel_num); - DEBUG_MSG("Radio frequency: %f\n", getFreq()); // the frequency could be overridden in RadioInterface::getFreq() for some modules + DEBUG_MSG("Radio frequency: %f\n", getFreq()); DEBUG_MSG("Short packet time: %u msec\n", shortPacketMsec); } From af1804ea6206a382f53a3664dbb2895bafe82792 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 19:42:03 -0800 Subject: [PATCH 08/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 956fa74e8..b22f484ba 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 956fa74e806574ba5a7facf899101035c3511bc9 +Subproject commit b22f484bab8ec50875a72001efe2e6c9b8f01952 From 1de086819c6d9dd035dca66661ac257460fb4144 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 19:45:26 -0800 Subject: [PATCH 09/93] Remove myNodeInfo.num_bands. It's not used by android. --- src/mesh/RadioInterface.cpp | 3 --- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 11 ++++------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 97275825d..ff13676dd 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -94,9 +94,6 @@ void initRegion() ; myRegion = r; DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name); - - // myNodeInfo.num_bands = myRegion->numChannels; // Tell our android app how many channels we have - myNodeInfo.num_bands = 666; // JM Fixme! } /** diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 22a7c95f3..82b2f6709 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -140,7 +140,7 @@ extern const pb_msgdesc_t ChannelFile_msg; /* Maximum encoded size of messages (where known) */ #define LegacyRadioConfig_size 4 #define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 11014 +#define DeviceState_size 11008 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index ffdad870f..82d00d8b1 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -152,7 +152,6 @@ typedef struct _LogRecord { typedef struct _MyNodeInfo { uint32_t my_node_num; bool has_gps; - uint32_t num_bands; char region[12]; char hw_model_deprecated[16]; char firmware_version[18]; @@ -339,7 +338,7 @@ extern "C" { #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #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, 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, 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 MyNodeInfo_init_default {0, 0, "", "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} @@ -351,7 +350,7 @@ extern "C" { #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #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, 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, 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 MyNodeInfo_init_zero {0, 0, "", "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} @@ -372,7 +371,6 @@ extern "C" { #define LogRecord_level_tag 4 #define MyNodeInfo_my_node_num_tag 1 #define MyNodeInfo_has_gps_tag 2 -#define MyNodeInfo_num_bands_tag 3 #define MyNodeInfo_region_tag 4 #define MyNodeInfo_hw_model_deprecated_tag 5 #define MyNodeInfo_firmware_version_tag 6 @@ -558,7 +556,6 @@ X(a, STATIC, SINGULAR, FLOAT, snr, 7) #define MyNodeInfo_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \ -X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \ X(a, STATIC, SINGULAR, STRING, region, 4) \ X(a, STATIC, SINGULAR, STRING, hw_model_deprecated, 5) \ X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \ @@ -652,9 +649,9 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_size 267 #define MeshPacket_size 318 #define NodeInfo_size 271 -#define MyNodeInfo_size 457 +#define MyNodeInfo_size 451 #define LogRecord_size 81 -#define FromRadio_size 466 +#define FromRadio_size 460 #define ToRadio_size 321 #define ToRadio_PeerInfo_size 8 From 71d5e6c4784128080d5d349e201ba5fb96456e93 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 19:55:19 -0800 Subject: [PATCH 10/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index b22f484ba..35f102f0a 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit b22f484bab8ec50875a72001efe2e6c9b8f01952 +Subproject commit 35f102f0a53c0d538922deadabdea0ea5adb5985 From b99d793e23154a59e7d84c45849e60e88ee5ab54 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 19:58:54 -0800 Subject: [PATCH 11/93] Remove legacyRadio and Legacy Preferences --- src/mesh/NodeDB.cpp | 12 --------- src/mesh/generated/deviceonly.pb.c | 6 ----- src/mesh/generated/deviceonly.pb.h | 43 +++--------------------------- 3 files changed, 3 insertions(+), 58 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index b112432e8..af8e12cdc 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -227,18 +227,6 @@ void NodeDB::init() info->user = owner; info->has_user = true; - // removed from 1.2 (though we do use old values if found) - // We set these _after_ loading from disk - because they come from the build and are more trusted than - // what is stored in flash - // if (xstr(HW_VERSION)[0]) - // strncpy(myNodeInfo.region, optstr(HW_VERSION), sizeof(myNodeInfo.region)); - // else DEBUG_MSG("This build does not specify a HW_VERSION\n"); // Eventually new builds will no longer include this build - // flag - - // DEBUG_MSG("legacy region %d\n", devicestate.legacyRadio.preferences.region); - if (radioConfig.preferences.region == RegionCode_Unset) - radioConfig.preferences.region = devicestate.legacyRadio.preferences.region; - // Check for the old style of region code strings, if found, convert to the new enum. // Those strings will look like "1.0-EU433" if (radioConfig.preferences.region == RegionCode_Unset && strncmp(myNodeInfo.region, "1.0-", 4) == 0) { diff --git a/src/mesh/generated/deviceonly.pb.c b/src/mesh/generated/deviceonly.pb.c index 764c54fdb..9bb586f5a 100644 --- a/src/mesh/generated/deviceonly.pb.c +++ b/src/mesh/generated/deviceonly.pb.c @@ -6,12 +6,6 @@ #error Regenerate this file with the current version of nanopb generator. #endif -PB_BIND(LegacyRadioConfig, LegacyRadioConfig, AUTO) - - -PB_BIND(LegacyRadioConfig_LegacyPreferences, LegacyRadioConfig_LegacyPreferences, AUTO) - - PB_BIND(DeviceState, DeviceState, 4) diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 82b2f6709..1f93989a0 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -18,18 +18,7 @@ typedef struct _ChannelFile { Channel channels[8]; } ChannelFile; -typedef struct _LegacyRadioConfig_LegacyPreferences { - RegionCode region; -} LegacyRadioConfig_LegacyPreferences; - -typedef struct _LegacyRadioConfig { - bool has_preferences; - LegacyRadioConfig_LegacyPreferences preferences; -} LegacyRadioConfig; - typedef struct _DeviceState { - bool has_legacyRadio; - LegacyRadioConfig legacyRadio; bool has_my_node; MyNodeInfo my_node; bool has_owner; @@ -56,20 +45,13 @@ extern "C" { #endif /* Initializer values for message structs */ -#define LegacyRadioConfig_init_default {false, LegacyRadioConfig_LegacyPreferences_init_default} -#define LegacyRadioConfig_LegacyPreferences_init_default {_RegionCode_MIN} -#define DeviceState_init_default {false, LegacyRadioConfig_init_default, false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""} #define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}} -#define LegacyRadioConfig_init_zero {false, LegacyRadioConfig_LegacyPreferences_init_zero} -#define LegacyRadioConfig_LegacyPreferences_init_zero {_RegionCode_MIN} -#define DeviceState_init_zero {false, LegacyRadioConfig_init_zero, false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""} #define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}} /* Field tags (for use in manual encoding/decoding) */ #define ChannelFile_channels_tag 1 -#define LegacyRadioConfig_LegacyPreferences_region_tag 15 -#define LegacyRadioConfig_preferences_tag 1 -#define DeviceState_legacyRadio_tag 1 #define DeviceState_my_node_tag 2 #define DeviceState_owner_tag 3 #define DeviceState_node_db_tag 4 @@ -85,19 +67,7 @@ extern "C" { #define DeviceState_canned_message_plugin_message_part5_tag 17 /* Struct field encoding specification for nanopb */ -#define LegacyRadioConfig_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, preferences, 1) -#define LegacyRadioConfig_CALLBACK NULL -#define LegacyRadioConfig_DEFAULT NULL -#define LegacyRadioConfig_preferences_MSGTYPE LegacyRadioConfig_LegacyPreferences - -#define LegacyRadioConfig_LegacyPreferences_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UENUM, region, 15) -#define LegacyRadioConfig_LegacyPreferences_CALLBACK NULL -#define LegacyRadioConfig_LegacyPreferences_DEFAULT NULL - #define DeviceState_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, legacyRadio, 1) \ X(a, STATIC, OPTIONAL, MESSAGE, my_node, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, owner, 3) \ X(a, STATIC, REPEATED, MESSAGE, node_db, 4) \ @@ -113,7 +83,6 @@ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part4, 16) \ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part5, 17) #define DeviceState_CALLBACK NULL #define DeviceState_DEFAULT NULL -#define DeviceState_legacyRadio_MSGTYPE LegacyRadioConfig #define DeviceState_my_node_MSGTYPE MyNodeInfo #define DeviceState_owner_MSGTYPE User #define DeviceState_node_db_MSGTYPE NodeInfo @@ -126,21 +95,15 @@ X(a, STATIC, REPEATED, MESSAGE, channels, 1) #define ChannelFile_DEFAULT NULL #define ChannelFile_channels_MSGTYPE Channel -extern const pb_msgdesc_t LegacyRadioConfig_msg; -extern const pb_msgdesc_t LegacyRadioConfig_LegacyPreferences_msg; extern const pb_msgdesc_t DeviceState_msg; extern const pb_msgdesc_t ChannelFile_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define LegacyRadioConfig_fields &LegacyRadioConfig_msg -#define LegacyRadioConfig_LegacyPreferences_fields &LegacyRadioConfig_LegacyPreferences_msg #define DeviceState_fields &DeviceState_msg #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define LegacyRadioConfig_size 4 -#define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 11008 +#define DeviceState_size 11002 #define ChannelFile_size 832 #ifdef __cplusplus From 04d16b82ba30bea603491b54bd3081ee2f779d58 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 20:00:46 -0800 Subject: [PATCH 12/93] Remove old style of region code fix --- src/mesh/NodeDB.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index af8e12cdc..64f6912ad 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -227,17 +227,6 @@ void NodeDB::init() info->user = owner; info->has_user = true; - // Check for the old style of region code strings, if found, convert to the new enum. - // Those strings will look like "1.0-EU433" - if (radioConfig.preferences.region == RegionCode_Unset && strncmp(myNodeInfo.region, "1.0-", 4) == 0) { - const char *regionStr = myNodeInfo.region + 4; // EU433 or whatever - for (const RegionInfo *r = regions; r->code != RegionCode_Unset; r++) - if (strcmp(r->name, regionStr) == 0) { - radioConfig.preferences.region = r->code; - break; - } - } - strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version)); // hw_model is no longer stored in myNodeInfo (as of 1.2.11) - we now store it as an enum in nodeinfo From 18e95e6bb4ebb864275102434eda11b20d4504f8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 20:08:29 -0800 Subject: [PATCH 13/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 35f102f0a..d192833e5 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 35f102f0a53c0d538922deadabdea0ea5adb5985 +Subproject commit d192833e5c43d7e388fa4605c41b0ef5ca459731 From eae872006813164040e26aae76486e6edbee056d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 20:35:44 -0800 Subject: [PATCH 14/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index d192833e5..6a66f8b1f 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit d192833e5c43d7e388fa4605c41b0ef5ca459731 +Subproject commit 6a66f8b1f81815e62279ff66dea908112583e6ab From 1ba7f009ddb87b4dc8afc4a784d4e6439ae8458c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 14 Feb 2022 20:37:44 -0800 Subject: [PATCH 15/93] Remove hw_model_deprecated --- src/mesh/NodeDB.cpp | 4 ---- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 11 ++++------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 64f6912ad..0587b9457 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -229,10 +229,6 @@ void NodeDB::init() strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version)); - // hw_model is no longer stored in myNodeInfo (as of 1.2.11) - we now store it as an enum in nodeinfo - myNodeInfo.hw_model_deprecated[0] = '\0'; - // strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model)); - #ifndef NO_ESP32 Preferences preferences; preferences.begin("meshtastic", false); diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 1f93989a0..a298579bb 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -103,7 +103,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 11002 +#define DeviceState_size 10985 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 82d00d8b1..8e98195ed 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -153,7 +153,6 @@ typedef struct _MyNodeInfo { uint32_t my_node_num; bool has_gps; char region[12]; - char hw_model_deprecated[16]; char firmware_version[18]; CriticalErrorCode error_code; uint32_t error_address; @@ -338,7 +337,7 @@ extern "C" { #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} -#define MyNodeInfo_init_default {0, 0, "", "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} +#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} @@ -350,7 +349,7 @@ extern "C" { #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} -#define MyNodeInfo_init_zero {0, 0, "", "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} +#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} @@ -372,7 +371,6 @@ extern "C" { #define MyNodeInfo_my_node_num_tag 1 #define MyNodeInfo_has_gps_tag 2 #define MyNodeInfo_region_tag 4 -#define MyNodeInfo_hw_model_deprecated_tag 5 #define MyNodeInfo_firmware_version_tag 6 #define MyNodeInfo_error_code_tag 7 #define MyNodeInfo_error_address_tag 8 @@ -557,7 +555,6 @@ X(a, STATIC, SINGULAR, FLOAT, snr, 7) X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \ X(a, STATIC, SINGULAR, STRING, region, 4) \ -X(a, STATIC, SINGULAR, STRING, hw_model_deprecated, 5) \ X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \ X(a, STATIC, SINGULAR, UENUM, error_code, 7) \ X(a, STATIC, SINGULAR, UINT32, error_address, 8) \ @@ -649,9 +646,9 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_size 267 #define MeshPacket_size 318 #define NodeInfo_size 271 -#define MyNodeInfo_size 451 +#define MyNodeInfo_size 434 #define LogRecord_size 81 -#define FromRadio_size 460 +#define FromRadio_size 443 #define ToRadio_size 321 #define ToRadio_PeerInfo_size 8 From 57bbd912b15552e851b42fb0fefbb3c9872bc107 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 15 Feb 2022 07:36:28 -0800 Subject: [PATCH 16/93] Fix typo in default channel (Thanks Andre!) --- src/mesh/Channels.cpp | 2 +- src/mesh/RadioInterface.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 116462e3a..2c6c6900d 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -84,7 +84,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex) Channel &ch = getByIndex(chIndex); ChannelSettings &channelSettings = ch.settings; - channelSettings.modem_config = ChannelSettings_ModemConfig_LongSlow; // Default to Long Range & Fast + channelSettings.modem_config = ChannelSettings_ModemConfig_LongFast; // Default to Long Range & Fast channelSettings.tx_power = 0; // default uint8_t defaultpskIndex = 1; diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index ff13676dd..e7b3ced75 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -32,6 +32,8 @@ const RegionInfo regions[] = { https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/ https://www.thethingsnetwork.org/docs/lorawan/regional-parameters/ https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true + + audio_permitted = false per regulation */ RDEF(EU868, 869.4f, 869.65f, 10, 0, 16, false, false), From 0c946609d5481bd3dcd63a9d259f15cf6e4d7a89 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Wed, 16 Feb 2022 11:39:29 +1100 Subject: [PATCH 17/93] Remove old CI script --- .github/actions/initbuild/action.yml | 39 ---------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/actions/initbuild/action.yml diff --git a/.github/actions/initbuild/action.yml b/.github/actions/initbuild/action.yml deleted file mode 100644 index b852d0a6c..000000000 --- a/.github/actions/initbuild/action.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: 'Common init' - -# WARNING due to https://github.com/actions/runner/issues/646 -# this code can't work - must copy and paste into workflows for now because 'uses' is not supported -runs: - using: "composite" - steps: - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Cache python libs - uses: actions/cache@v1 - id: cache-pip # needed in if test - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - - - name: Upgrade python tools - # We actually want to run this every time - # if: steps.cache-pip.outputs.cache-hit != 'true' - run: | - python -m pip install --upgrade pip - pip install -U platformio meshtastic adafruit-nrfutil - - # Don't cache for now because I want to be lazy with portuino updates githashes - # - name: Cache platformio - # uses: actions/cache@v1 - # id: cache-platformio # needed in if test - # with: - # path: ~/.platformio - # key: ${{ runner.os }}-platformio - - - name: Upgrade platformio - run: | - pio upgrade - - From 3a621ef26240d2ea1c536c320078e79e56735b76 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 15 Feb 2022 18:48:54 -0800 Subject: [PATCH 18/93] Fix bug in frequency formulas --- src/mesh/RadioInterface.cpp | 14 +++++++------- version.properties | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index e7b3ced75..6efba50f8 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -334,12 +334,12 @@ void RadioInterface::applyModemConfig() cr = 8; sf = 10; break; - case ChannelSettings_ModemConfig_LongSlow: + case ChannelSettings_ModemConfig_LongFast: bw = 250; cr = 8; sf = 11; break; - case ChannelSettings_ModemConfig_LongFast: + case ChannelSettings_ModemConfig_LongSlow: bw = 125; cr = 8; sf = 12; @@ -364,23 +364,23 @@ void RadioInterface::applyModemConfig() } power = channelSettings.tx_power; - shortPacketMsec = getPacketTime(sizeof(PacketHeader)); - assert(myRegion); // Should have been found in init // Calculate the number of channels - uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart)/(myRegion->spacing + bw)); + uint32_t numChannels = floor((myRegion->freqEnd - myRegion->freqStart) / (myRegion->spacing + (bw / 1000))); // If user has manually specified a channel num, then use that, otherwise generate one by hashing the name const char *channelName = channels.getName(channels.getPrimaryIndex()); int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels; - float freq = myRegion->freqStart+(((myRegion->freqEnd - myRegion->freqStart/numChannels)/2)*1); + float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num); + saveChannelNum(channel_num); saveFreq(freq); DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, power=%d\n", channelName, channelSettings.modem_config, channel_num, power); - DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f / %f\n", myRegion->freqStart, myRegion->freqEnd); + DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, + myRegion->freqEnd - myRegion->freqStart); DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels); DEBUG_MSG("Radio channel_num: %d\n", channel_num); DEBUG_MSG("Radio frequency: %f\n", getFreq()); diff --git a/version.properties b/version.properties index 0e3764e0e..2657b0278 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] -major = 1 -minor = 2 -build = 55 +major = 1 +minor = 3 +build = 0 From 9cdc6ae860c71055b43a632a5ea250cb6f39b702 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Wed, 16 Feb 2022 17:52:14 +1100 Subject: [PATCH 19/93] Add bug report issue template --- .github/ISSUE_TEMPLATE/Bug Report.yml | 76 +++++++++++++++++++ .../bug-report-or-feature-proposal.md | 38 ---------- 2 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/Bug Report.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug-report-or-feature-proposal.md diff --git a/.github/ISSUE_TEMPLATE/Bug Report.yml b/.github/ISSUE_TEMPLATE/Bug Report.yml new file mode 100644 index 000000000..b8c24ab2b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug Report.yml @@ -0,0 +1,76 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug", "triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + - type: dropdown + id: category + attributes: + label: Category + description: How would you catagorize this issue? + multiple: true + options: + - Hardware Compatibility + - BLE + - Serial + - WiFi + - Other + validations: + required: true + + - type: dropdown + id: hardware + attributes: + label: Hardware + description: What hardware are you encountering this issue on? + multiple: true + options: + - Not Applicable + - T-Beam + - T-Beam 0.7 + - T-Lora v1 + - T-Lora v1.3 + - T-Lora v2 1.6 + - T-Echo + - Rak4631 + - Rak11200 + - Heltec v1 + - Heltec v2 + - Heltec v2.1 + - Relay v1 + - Relay v2 + - DIY + - Other + validations: + required: true + + - type: input + id: version + attributes: + label: Firmware Version + description: This can be found on the device's screen or via one of the apps. + placeholder: x.x.x.yyyyyyy + validations: + required: true + + - type: textarea + id: body + attributes: + label: Description + description: Please provide details on what steps you performed for this to happen. + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: If you have any log output to help in diagnosing your bug, please provide it here. + render: Shell + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/bug-report-or-feature-proposal.md b/.github/ISSUE_TEMPLATE/bug-report-or-feature-proposal.md deleted file mode 100644 index 42f3b0d2c..000000000 --- a/.github/ISSUE_TEMPLATE/bug-report-or-feature-proposal.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report or feature proposal -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -Please - if you just have a question (i.e. not a bug report or a feature proposal), post in our [forum](https://meshtastic.discourse.group/) instead. - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Device info:** - - Device model: [e.g. TBEAM] - - Software Version [e.g. 0.7.8] - -**Smartphone information (if relevant):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - App Version [e.g. 0.7.2] - -**Additional context** -Add any other context about the problem here. From 54f062e94d26b222fca3e3b0478e42eda03ddba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 16 Feb 2022 14:22:40 +0100 Subject: [PATCH 20/93] Add littlefs dependancy to release flow as well (#1217) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6412bcddf..da7dfcf18 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: # if: steps.cache-pip.outputs.cache-hit != 'true' run: | python -m pip install --upgrade pip - pip install -U platformio meshtastic adafruit-nrfutil + pip install -U platformio meshtastic adafruit-nrfutil littlefs-python - name: Upgrade platformio run: | From e7e001c1597cc112b1627824bcf5bc1edb398db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 18 Feb 2022 18:42:24 +0100 Subject: [PATCH 21/93] Install littlefs-python during pio run (#1220) Install only if it is missing from the ENV. Caveat: this python module is essentially lib binding and needs Cython and a working compiler as well. this MAY or MAY NOT work. --- bin/platformio-custom.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index 1443f6d4f..d4117b4b8 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -8,6 +8,10 @@ from readprops import readProps Import("env") env.Replace( MKSPIFFSTOOL=env.get("PROJECT_DIR") + '/bin/mklittlefs.py' ) +try: + import littlefs +except ImportError: + env.Execute("$PYTHONEXE -m pip install --user littlefs-python") Import("projenv") From 8303500b7493605ec688663129e50991514b1aff Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Sat, 19 Feb 2022 15:30:30 +0200 Subject: [PATCH 22/93] Add RAK4361_5005_RAK14000 board variant and enable e-Paper module (#1199) * Create platformio.ini * Create variant.cpp * Create variant.h * Update EInkDisplay2.cpp * Update build-all.sh --- bin/build-all.sh | 4 +- src/graphics/EInkDisplay2.cpp | 16 +- .../platformio.ini | 9 + .../WisCore_RAK4631_E-Paper_Board/variant.cpp | 43 ++++ .../WisCore_RAK4631_E-Paper_Board/variant.h | 232 ++++++++++++++++++ 5 files changed, 300 insertions(+), 4 deletions(-) create mode 100644 variants/WisCore_RAK4631_E-Paper_Board/platformio.ini create mode 100644 variants/WisCore_RAK4631_E-Paper_Board/variant.cpp create mode 100644 variants/WisCore_RAK4631_E-Paper_Board/variant.h diff --git a/bin/build-all.sh b/bin/build-all.sh index 07b99df90..ee9fdac29 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -9,7 +9,7 @@ BOARDS_ESP32="rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec- #BOARDS_ESP32=tbeam # FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine -BOARDS_NRF52="rak4631_5005 rak4631_19003 t-echo" +BOARDS_NRF52="rak4631_5005 rak4631_5005_eink rak4631_19003 t-echo" #BOARDS_NRF52="" OUTDIR=release/latest @@ -108,4 +108,4 @@ echo Generating $ARCHIVEDIR/elfs-$VERSION.zip rm -f $ARCHIVEDIR/elfs-$VERSION.zip zip --junk-paths $ARCHIVEDIR/elfs-$VERSION.zip $OUTDIR/elfs/universal/firmware-*-$VERSION.* -echo BUILT ALL \ No newline at end of file +echo BUILT ALL diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index f93453dd4..2432e6f1c 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -9,14 +9,21 @@ #define COLORED GxEPD_BLACK #define UNCOLORED GxEPD_WHITE - +#if defined(TTGO_T_ECHO) #define TECHO_DISPLAY_MODEL GxEPD2_154_D67 +#elif defined(RAK4630) +#define TECHO_DISPLAY_MODEL GxEPD2_213_B74 +#endif GxEPD2_BW *adafruitDisplay; EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl) { + #if defined(TTGO_T_ECHO) setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); + #elif defined(RAK4630) + setGeometry(GEOMETRY_RAWMODE, 250, 122); + #endif // setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution // setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does } @@ -50,7 +57,12 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) } } - DEBUG_MSG("Updating eink... "); + #if defined(TTGO_T_ECHO) + DEBUG_MSG("Updating T-ECHO E-Paper... "); + #elif defined(RAK4630) + DEBUG_MSG("Updating RAK4361_5005 E-Paper... "); + #endif + // ePaper.Reset(); // wake the screen from sleep adafruitDisplay->display(false); // FIXME, use partial update mode // Put screen to sleep to save power (possibly not necessary because we already did poweroff inside of display) diff --git a/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini b/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini new file mode 100644 index 000000000..19874b93c --- /dev/null +++ b/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini @@ -0,0 +1,9 @@ +[env:rak4631_5005_eink] +extends = nrf52840_base +board = wiscore_rak4631 +build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_E-Paper_Board -D RAK_BASE_5005 +src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_E-Paper_Board> +lib_deps = + ${nrf52840_base.lib_deps} + https://github.com/meshtastic/GxEPD2.git +debug_tool = jlink diff --git a/variants/WisCore_RAK4631_E-Paper_Board/variant.cpp b/variants/WisCore_RAK4631_E-Paper_Board/variant.cpp new file mode 100644 index 000000000..5b9288319 --- /dev/null +++ b/variants/WisCore_RAK4631_E-Paper_Board/variant.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = + { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/variants/WisCore_RAK4631_E-Paper_Board/variant.h b/variants/WisCore_RAK4631_E-Paper_Board/variant.h new file mode 100644 index 000000000..4b5d21add --- /dev/null +++ b/variants/WisCore_RAK4631_E-Paper_Board/variant.h @@ -0,0 +1,232 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_RAK4630_ +#define _VARIANT_RAK4630_ + +#define RAK4630 + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (35) +#define PIN_LED2 (36) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ + +#ifdef RAK_BASE_5005 +#define PIN_BUTTON1 9 // Pin for button on E-ink button module or IO expansion +#define BUTTON_NEED_PULLUP +#endif +#define PIN_BUTTON2 12 +#define PIN_BUTTON3 24 +#define PIN_BUTTON4 25 + + +/* + * Analog pins + */ +#define PIN_A0 (5) +#define PIN_A1 (31) +#define PIN_A2 (28) +#define PIN_A3 (29) +#define PIN_A4 (30) +#define PIN_A5 (31) +#define PIN_A6 (0xff) +#define PIN_A7 (0xff) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6; +static const uint8_t A7 = PIN_A7; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (15) +#define PIN_SERIAL1_TX (16) + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (8) +#define PIN_SERIAL2_TX (6) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_MISO (45) +#define PIN_SPI_MOSI (44) +#define PIN_SPI_SCK (43) + +#define PIN_SPI1_MISO (29) // (0 + 29) +#define PIN_SPI1_MOSI (30) // (0 + 30) +#define PIN_SPI1_SCK (3) // (0 + 3) + +static const uint8_t SS = 42; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + + /* + * eink display pins + */ + +#define PIN_EINK_EN (0 + 2) // (0 + 2) Note: this is really just backlight power +#define PIN_EINK_CS (0 + 26) +#define PIN_EINK_BUSY (0 + 4) +#define PIN_EINK_DC (0 + 17) +#define PIN_EINK_RES (-1) +#define PIN_EINK_SCLK (0 + 3) +#define PIN_EINK_MOSI (0 + 30) // also called SDI + +// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON +// FIXME - I think this is actually just the board power enable - it enables power to the CPU also +//#define PIN_EINK_PWR_ON (-1) + +#define HAS_EINK + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (13) +#define PIN_WIRE_SCL (14) + +// QSPI Pins +#define PIN_QSPI_SCK 3 +#define PIN_QSPI_CS 26 +#define PIN_QSPI_IO0 30 +#define PIN_QSPI_IO1 29 +#define PIN_QSPI_IO2 28 +#define PIN_QSPI_IO3 2 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES IS25LP080D +#define EXTERNAL_FLASH_USE_QSPI + +/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports + RAK5005-O <-> nRF52840 + IO1 <-> P0.17 (Arduino GPIO number 17) + IO2 <-> P1.02 (Arduino GPIO number 34) + IO3 <-> P0.21 (Arduino GPIO number 21) + IO4 <-> P0.04 (Arduino GPIO number 4) + IO5 <-> P0.09 (Arduino GPIO number 9) + IO6 <-> P0.10 (Arduino GPIO number 10) + SW1 <-> P0.01 (Arduino GPIO number 1) + A0 <-> P0.04/AIN2 (Arduino Analog A2 + A1 <-> P0.31/AIN7 (Arduino Analog A7 + SPI_CS <-> P0.26 (Arduino GPIO number 26) + */ + +// RAK4630 LoRa module +#define USE_SX1262 +#define SX126X_CS (42) +#define SX126X_DIO1 (47) +#define SX126X_BUSY (46) +#define SX126X_RESET (38) +#define SX126X_TXEN (39) +#define SX126X_RXEN (37) +#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 + +// RAK1910 GPS module +// If using the wisblock GPS module and pluged into Port A on WisBlock base +// IO1 is hooked to PPS (pin 12 on header) = gpio 17 +// IO2 is hooked to GPS RESET = gpio 34, but it can not be used to this because IO2 is ALSO used to control 3V3_S power (1 is on). +// Therefore must be 1 to keep peripherals powered +// Power is on the controllable 3V3_S rail +// #define PIN_GPS_RESET (34) +#define PIN_GPS_EN (34) +#define PIN_GPS_PPS (17) // Pulse per second input from the GPS + +#ifdef RAK_BASE_5005 +#define GPS_RX_PIN PIN_SERIAL1_RX +#define GPS_TX_PIN PIN_SERIAL1_TX +#endif + +// Battery +// The battery sense is hooked to pin A0 (5) +#define BATTERY_PIN PIN_A0 +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +#define VBAT_DIVIDER (0.4F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP //REAL_VBAT_MV_PER_LSB +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From 29e70a80c6e3a9c95c7d15167132a44cf5f06aa5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 19 Feb 2022 07:32:15 -0600 Subject: [PATCH 23/93] Add rak eink variant (#1221) --- .github/workflows/main_matrix.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 59894f873..fcc33ca23 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -37,6 +37,7 @@ jobs: - board: meshtastic-diy-v1 - board: rak4631_5005 - board: rak4631_19003 + - board: rak4631_5005_eink - board: t-echo runs-on: ubuntu-latest @@ -162,6 +163,7 @@ jobs: include: - board: rak4631_5005 - board: rak4631_19003 + - board: rak4631_5005_eink - board: t-echo runs-on: ubuntu-latest From 1075b95f7917dfe2262b73145347dd47328cb56f Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 19 Feb 2022 22:55:36 -0800 Subject: [PATCH 24/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 6a66f8b1f..4ab31fc67 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 6a66f8b1f81815e62279ff66dea908112583e6ab +Subproject commit 4ab31fc67773f4925ab6a9abde9fefbff0fe1a7f From a7aa82e732f6b238590e19032dbd19bd0a010e28 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 19 Feb 2022 23:10:51 -0800 Subject: [PATCH 25/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 4ab31fc67..ce81bb93a 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 4ab31fc67773f4925ab6a9abde9fefbff0fe1a7f +Subproject commit ce81bb93aebeb3e1b0d4a1ed48997342a98ef678 From 701668804ab47b4f8206bdcfda59e0b595c7fa77 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 19 Feb 2022 23:17:48 -0800 Subject: [PATCH 26/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index ce81bb93a..257c4ccde 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ce81bb93aebeb3e1b0d4a1ed48997342a98ef678 +Subproject commit 257c4ccdee48a7c3f55c671187161913cb39a58f From e34190b4971ed8f2e04a5f444904bc4ef0ade280 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 19 Feb 2022 23:43:32 -0800 Subject: [PATCH 27/93] Plumbing for the GroupPlugin --- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.c | 3 +++ src/mesh/generated/mesh.pb.h | 31 ++++++++++++++++++++----- src/mesh/generated/portnums.pb.h | 1 + src/plugins/GroupPlugin.cpp | 37 ++++++++++++++++++++++++++++++ src/plugins/GroupPlugin.h | 29 +++++++++++++++++++++++ src/plugins/Plugins.cpp | 14 +++++------ 7 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 src/plugins/GroupPlugin.cpp create mode 100644 src/plugins/GroupPlugin.h diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index a298579bb..27c99c6e8 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -103,7 +103,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 10985 +#define DeviceState_size 10991 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c index 6846dc540..90eca5068 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/mesh.pb.c @@ -27,6 +27,9 @@ PB_BIND(MeshPacket, MeshPacket, 2) PB_BIND(NodeInfo, NodeInfo, AUTO) +PB_BIND(GroupInfo, GroupInfo, AUTO) + + PB_BIND(MyNodeInfo, MyNodeInfo, 2) diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 8e98195ed..e2d53fc50 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -140,8 +140,14 @@ typedef struct _Data { uint32_t request_id; uint32_t reply_id; bool is_tapback; + uint8_t group_id; } Data; +typedef struct _GroupInfo { + pb_size_t group_count; + char group[10][17]; +} GroupInfo; + typedef struct _LogRecord { char message[64]; uint32_t time; @@ -334,9 +340,10 @@ extern "C" { #define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_default {0, {RouteDiscovery_init_default}} -#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} +#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} +#define GroupInfo_init_default {0, {"", "", "", "", "", "", "", "", "", ""}} #define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} @@ -346,9 +353,10 @@ extern "C" { #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}} -#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} +#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} +#define GroupInfo_init_zero {0, {"", "", "", "", "", "", "", "", "", ""}} #define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} @@ -364,6 +372,8 @@ extern "C" { #define Data_request_id_tag 6 #define Data_reply_id_tag 7 #define Data_is_tapback_tag 8 +#define Data_group_id_tag 9 +#define GroupInfo_group_tag 1 #define LogRecord_message_tag 1 #define LogRecord_time_tag 2 #define LogRecord_source_tag 3 @@ -518,7 +528,8 @@ X(a, STATIC, SINGULAR, FIXED32, dest, 4) \ X(a, STATIC, SINGULAR, FIXED32, source, 5) \ X(a, STATIC, SINGULAR, FIXED32, request_id, 6) \ X(a, STATIC, SINGULAR, FIXED32, reply_id, 7) \ -X(a, STATIC, SINGULAR, BOOL, is_tapback, 8) +X(a, STATIC, SINGULAR, BOOL, is_tapback, 8) \ +X(a, STATIC, SINGULAR, UINT32, group_id, 9) #define Data_CALLBACK NULL #define Data_DEFAULT NULL @@ -551,6 +562,11 @@ X(a, STATIC, SINGULAR, FLOAT, snr, 7) #define NodeInfo_user_MSGTYPE User #define NodeInfo_position_MSGTYPE Position +#define GroupInfo_FIELDLIST(X, a) \ +X(a, STATIC, REPEATED, STRING, group, 1) +#define GroupInfo_CALLBACK NULL +#define GroupInfo_DEFAULT NULL + #define MyNodeInfo_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \ @@ -618,6 +634,7 @@ extern const pb_msgdesc_t Routing_msg; extern const pb_msgdesc_t Data_msg; extern const pb_msgdesc_t MeshPacket_msg; extern const pb_msgdesc_t NodeInfo_msg; +extern const pb_msgdesc_t GroupInfo_msg; extern const pb_msgdesc_t MyNodeInfo_msg; extern const pb_msgdesc_t LogRecord_msg; extern const pb_msgdesc_t FromRadio_msg; @@ -632,6 +649,7 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_fields &Data_msg #define MeshPacket_fields &MeshPacket_msg #define NodeInfo_fields &NodeInfo_msg +#define GroupInfo_fields &GroupInfo_msg #define MyNodeInfo_fields &MyNodeInfo_msg #define LogRecord_fields &LogRecord_msg #define FromRadio_fields &FromRadio_msg @@ -643,13 +661,14 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define User_size 97 #define RouteDiscovery_size 40 #define Routing_size 42 -#define Data_size 267 -#define MeshPacket_size 318 +#define Data_size 270 +#define MeshPacket_size 321 #define NodeInfo_size 271 +#define GroupInfo_size 180 #define MyNodeInfo_size 434 #define LogRecord_size 81 #define FromRadio_size 443 -#define ToRadio_size 321 +#define ToRadio_size 324 #define ToRadio_PeerInfo_size 8 #ifdef __cplusplus diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index 26eec9ed6..67b5df03d 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -20,6 +20,7 @@ typedef enum _PortNum { PortNum_ADMIN_APP = 6, PortNum_REPLY_APP = 32, PortNum_IP_TUNNEL_APP = 33, + PortNum_GROUP_APP = 34, PortNum_SERIAL_APP = 64, PortNum_STORE_FORWARD_APP = 65, PortNum_RANGE_TEST_APP = 66, diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp new file mode 100644 index 000000000..306d739a2 --- /dev/null +++ b/src/plugins/GroupPlugin.cpp @@ -0,0 +1,37 @@ +#include "GroupPlugin.h" +#include "MeshService.h" +#include "Router.h" +#include "configuration.h" + +GroupPlugin *groupPlugin; + +GroupPlugin::GroupPlugin() + : ProtobufPlugin("group", PortNum_GROUP_APP, GroupInfo_fields), concurrency::OSThread("GroupPlugin") +{ + //isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others + //setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup) +} + +bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr) +{ + auto p = *pptr; + + + + return false; // Let others look at this message also if they want +} + +MeshPacket *GroupPlugin::allocReply() +{ + return allocDataProtobuf(p); +} + +int32_t GroupPlugin::runOnce() +{ + NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); + + + + + return 5000; // to save power only wake for our callback occasionally +} diff --git a/src/plugins/GroupPlugin.h b/src/plugins/GroupPlugin.h new file mode 100644 index 000000000..6b73fede1 --- /dev/null +++ b/src/plugins/GroupPlugin.h @@ -0,0 +1,29 @@ +#pragma once +#include "GroupPlugin.h" +#include "ProtobufPlugin.h" +#include "concurrency/OSThread.h" + +/** + * Position plugin for sending/receiving positions into the mesh + */ +class GroupPlugin : private concurrency::OSThread, public ProtobufPlugin +{ + public: + GroupPlugin(); + + protected: + /** 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 handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *p) override; + + /** Messages can be received that have the want_response bit set. If set, this callback will be invoked + * so that subclasses can (optionally) send a response back to the original sender. */ + virtual MeshPacket *allocReply() override; + + /** Does our periodic broadcast */ + virtual int32_t runOnce() override; +}; + +extern GroupPlugin *groupPlugin; diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index 429a15bb6..3cf66a170 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -1,22 +1,22 @@ #include "configuration.h" #include "input/InputBroker.h" #include "input/RotaryEncoderInterruptImpl1.h" +#include "plugins/AdminPlugin.h" +#include "plugins/CannedMessagePlugin.h" #include "plugins/ExternalNotificationPlugin.h" +#include "plugins/GroupPlugin.h" #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" #include "plugins/RemoteHardwarePlugin.h" #include "plugins/ReplyPlugin.h" -#include "plugins/TextMessagePlugin.h" -#include "plugins/TextMessagePlugin.h" #include "plugins/RoutingPlugin.h" -#include "plugins/AdminPlugin.h" -#include "plugins/CannedMessagePlugin.h" +#include "plugins/TextMessagePlugin.h" #ifndef PORTDUINO #include "plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h" #endif #ifndef NO_ESP32 -#include "plugins/esp32/SerialPlugin.h" #include "plugins/esp32/RangeTestPlugin.h" +#include "plugins/esp32/SerialPlugin.h" #include "plugins/esp32/StoreForwardPlugin.h" #endif @@ -30,14 +30,14 @@ void setupPlugins() nodeInfoPlugin = new NodeInfoPlugin(); positionPlugin = new PositionPlugin(); textMessagePlugin = new TextMessagePlugin(); + groupPlugin = new GroupPlugin(); // Note: if the rest of meshtastic doesn't need to explicitly use your plugin, you do not need to assign the instance // to a global variable. new RemoteHardwarePlugin(); new ReplyPlugin(); - rotaryEncoderInterruptImpl1 = - new RotaryEncoderInterruptImpl1(); + rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); rotaryEncoderInterruptImpl1->init(); cannedMessagePlugin = new CannedMessagePlugin(); #ifndef PORTDUINO From 57d824cf5d708cc241b25a5439e86f8ce78ec246 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 19 Feb 2022 23:48:21 -0800 Subject: [PATCH 28/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 257c4ccde..91598a629 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 257c4ccdee48a7c3f55c671187161913cb39a58f +Subproject commit 91598a629e327c66ab4655a29d50759125c53097 From 389a8f140103e635d0415bc3036cdcabb13574eb Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 00:04:32 -0800 Subject: [PATCH 29/93] Add ourGroupInfo to NodeDB --- src/mesh/NodeDB.cpp | 1 + src/mesh/NodeDB.h | 1 + src/mesh/generated/deviceonly.pb.h | 11 ++++++++--- src/plugins/GroupPlugin.cpp | 14 ++++++++++---- src/plugins/GroupPlugin.h | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 0587b9457..9bdae9011 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -34,6 +34,7 @@ NodeDB nodeDB; // we have plenty of ram so statically alloc this tempbuf (for now) EXT_RAM_ATTR DeviceState devicestate; MyNodeInfo &myNodeInfo = devicestate.my_node; +GroupInfo &ourGroupInfo = devicestate.group_info; RadioConfig radioConfig; ChannelFile channelFile; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 86ab874e8..f5937b3fb 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -11,6 +11,7 @@ extern DeviceState devicestate; extern ChannelFile channelFile; extern MyNodeInfo &myNodeInfo; +extern GroupInfo &ourGroupInfo; extern RadioConfig radioConfig; extern User &owner; diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 27c99c6e8..14453a9ad 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -27,6 +27,8 @@ typedef struct _DeviceState { NodeInfo node_db[32]; pb_size_t receive_queue_count; MeshPacket receive_queue[1]; + bool has_group_info; + GroupInfo group_info; bool has_rx_text_message; MeshPacket rx_text_message; uint32_t version; @@ -45,9 +47,9 @@ extern "C" { #endif /* Initializer values for message structs */ -#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, GroupInfo_init_default, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""} #define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}} -#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, GroupInfo_init_zero, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""} #define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}} /* Field tags (for use in manual encoding/decoding) */ @@ -56,6 +58,7 @@ extern "C" { #define DeviceState_owner_tag 3 #define DeviceState_node_db_tag 4 #define DeviceState_receive_queue_tag 5 +#define DeviceState_group_info_tag 6 #define DeviceState_rx_text_message_tag 7 #define DeviceState_version_tag 8 #define DeviceState_no_save_tag 9 @@ -72,6 +75,7 @@ X(a, STATIC, OPTIONAL, MESSAGE, my_node, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, owner, 3) \ X(a, STATIC, REPEATED, MESSAGE, node_db, 4) \ X(a, STATIC, REPEATED, MESSAGE, receive_queue, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, group_info, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \ X(a, STATIC, SINGULAR, UINT32, version, 8) \ X(a, STATIC, SINGULAR, BOOL, no_save, 9) \ @@ -87,6 +91,7 @@ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part5, 17) #define DeviceState_owner_MSGTYPE User #define DeviceState_node_db_MSGTYPE NodeInfo #define DeviceState_receive_queue_MSGTYPE MeshPacket +#define DeviceState_group_info_MSGTYPE GroupInfo #define DeviceState_rx_text_message_MSGTYPE MeshPacket #define ChannelFile_FIELDLIST(X, a) \ @@ -103,7 +108,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 10991 +#define DeviceState_size 11174 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index 306d739a2..3e3f5df37 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -2,9 +2,13 @@ #include "MeshService.h" #include "Router.h" #include "configuration.h" +#include "NodeDB.h" + GroupPlugin *groupPlugin; + + GroupPlugin::GroupPlugin() : ProtobufPlugin("group", PortNum_GROUP_APP, GroupInfo_fields), concurrency::OSThread("GroupPlugin") { @@ -14,7 +18,7 @@ GroupPlugin::GroupPlugin() bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr) { - auto p = *pptr; + //auto p = *pptr; @@ -23,15 +27,17 @@ bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr) MeshPacket *GroupPlugin::allocReply() { - return allocDataProtobuf(p); + GroupInfo gi = GroupInfo_init_default; // Start with an empty structure + + return allocDataProtobuf(gi); } int32_t GroupPlugin::runOnce() { NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); - - + + //ourGroupInfo.group[0][1] = "a"; return 5000; // to save power only wake for our callback occasionally } diff --git a/src/plugins/GroupPlugin.h b/src/plugins/GroupPlugin.h index 6b73fede1..f456234b0 100644 --- a/src/plugins/GroupPlugin.h +++ b/src/plugins/GroupPlugin.h @@ -6,7 +6,7 @@ /** * Position plugin for sending/receiving positions into the mesh */ -class GroupPlugin : private concurrency::OSThread, public ProtobufPlugin +class GroupPlugin : public ProtobufPlugin, private concurrency::OSThread { public: GroupPlugin(); From d416f283413154b42d771e776f4cc0fa90c7fa7a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 01:32:50 -0800 Subject: [PATCH 30/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 91598a629..95e22cceb 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 91598a629e327c66ab4655a29d50759125c53097 +Subproject commit 95e22ccebd906e2becac1c7ac47af115138a6c85 From 3fdd4256349e948da89b0b7a3e5b359f9f983635 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 01:33:49 -0800 Subject: [PATCH 31/93] Add groups to payloadVariant --- src/mesh/PhoneAPI.cpp | 9 ++++++++- src/mesh/PhoneAPI.h | 1 + src/mesh/generated/mesh.pb.h | 6 +++++- src/plugins/GroupPlugin.cpp | 8 +++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 4f434fa1f..5d533793d 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -140,11 +140,18 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info fromRadioScratch.which_payloadVariant = FromRadio_my_info_tag; fromRadioScratch.my_info = myNodeInfo; - state = STATE_SEND_NODEINFO; + state = STATE_SEND_GROUPS; service.refreshMyNodeInfo(); // Update my NodeInfo because the client will be asking for it soon. break; + case STATE_SEND_GROUPS: + fromRadioScratch.which_payloadVariant = FromRadio_groups_tag; + fromRadioScratch.groups = ourGroupInfo; + state = STATE_SEND_NODEINFO; + + break; + case STATE_SEND_NODEINFO: { const NodeInfo *info = nodeInfoForPhone; nodeInfoForPhone = NULL; // We just consumed a nodeinfo, will need a new one next time diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 5a4ca381d..684f683f8 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -24,6 +24,7 @@ class PhoneAPI STATE_SEND_NOTHING, // (Eventual) Initial state, don't send anything until the client starts asking for config // (disconnected) STATE_SEND_MY_INFO, // send our my info record + STATE_SEND_GROUPS, // STATE_SEND_RADIO, // in 1.2 we now send this as a regular mesh packet // STATE_SEND_OWNER, no need to send Owner specially, it is just part of the nodedb STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index e2d53fc50..f04b3f426 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -275,6 +275,7 @@ typedef struct _FromRadio { uint32_t config_complete_id; bool rebooted; MeshPacket packet; + GroupInfo groups; }; } FromRadio; @@ -459,6 +460,7 @@ extern "C" { #define FromRadio_config_complete_id_tag 8 #define FromRadio_rebooted_tag 9 #define FromRadio_packet_tag 11 +#define FromRadio_groups_tag 12 #define ToRadio_packet_tag 2 #define ToRadio_peer_info_tag 3 #define ToRadio_want_config_id_tag 100 @@ -603,13 +605,15 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,node_info,node_info), 4) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,log_record,log_record), 7) \ X(a, STATIC, ONEOF, UINT32, (payloadVariant,config_complete_id,config_complete_id), 8) \ X(a, STATIC, ONEOF, BOOL, (payloadVariant,rebooted,rebooted), 9) \ -X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11) +X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11) \ +X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,groups,groups), 12) #define FromRadio_CALLBACK NULL #define FromRadio_DEFAULT NULL #define FromRadio_payloadVariant_my_info_MSGTYPE MyNodeInfo #define FromRadio_payloadVariant_node_info_MSGTYPE NodeInfo #define FromRadio_payloadVariant_log_record_MSGTYPE LogRecord #define FromRadio_payloadVariant_packet_MSGTYPE MeshPacket +#define FromRadio_payloadVariant_groups_MSGTYPE GroupInfo #define ToRadio_FIELDLIST(X, a) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 2) \ diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index 3e3f5df37..ce94dfaeb 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -37,7 +37,13 @@ int32_t GroupPlugin::runOnce() NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); - //ourGroupInfo.group[0][1] = "a"; + //ourGroupInfo.group[0] = "20"; + //ourGroupInfo.group_count; + sprintf(ourGroupInfo.group[0], "Group 0"); + sprintf(ourGroupInfo.group[1], "Group 1"); + sprintf(ourGroupInfo.group[2], "Group 2"); + sprintf(ourGroupInfo.group[3], "Group 3"); + sprintf(ourGroupInfo.group[4], "Group 4"); return 5000; // to save power only wake for our callback occasionally } From 3d4fc63ecc8aa7e521061c2e505c0071f568e791 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 02:44:13 -0800 Subject: [PATCH 32/93] Fix webserver crash with new filesystem --- src/mesh/http/ContentHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index b64ea2814..4eb6cb7e5 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -390,6 +390,9 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) res->println("Web server is running.

The content you are looking for can't be found. Please see: FAQ.

admin"); + + return; + } else { res->setHeader("Content-Encoding", "gzip"); } @@ -427,6 +430,7 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) return; } else { + DEBUG_MSG("ERROR: This should not have happened...\n"); res->println("ERROR: This should not have happened..."); } } From b15ef2749f38452804ff1aa1d1069fe0c9a81dcc Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 08:23:05 -0800 Subject: [PATCH 33/93] Add STATE_SEND_GROUPS to PhoneAPI::available --- src/mesh/PhoneAPI.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 5d533793d..72e02cfa2 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -1,4 +1,3 @@ -#include "configuration.h" #include "PhoneAPI.h" #include "Channels.h" #include "GPS.h" @@ -6,6 +5,7 @@ #include "NodeDB.h" #include "PowerFSM.h" #include "RadioInterface.h" +#include "configuration.h" #include #if FromRadio_size > MAX_TO_FROM_RADIO_SIZE @@ -228,6 +228,9 @@ bool PhoneAPI::available() case STATE_SEND_MY_INFO: return true; + case STATE_SEND_GROUPS: + return true; + case STATE_SEND_NODEINFO: if (!nodeInfoForPhone) nodeInfoForPhone = nodeDB.readNextInfo(); From 1e6e3805adb8023f7417ec84a3db2186e50a178f Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 20 Feb 2022 10:47:57 -0800 Subject: [PATCH 34/93] Add debug output of the group names. --- src/plugins/GroupPlugin.cpp | 42 +++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index ce94dfaeb..acab5979e 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -12,8 +12,19 @@ GroupPlugin *groupPlugin; GroupPlugin::GroupPlugin() : ProtobufPlugin("group", PortNum_GROUP_APP, GroupInfo_fields), concurrency::OSThread("GroupPlugin") { - //isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others - //setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup) + + strcpy(ourGroupInfo.group[0], "Avocado"); + strcpy(ourGroupInfo.group[1], "Backberries"); + strcpy(ourGroupInfo.group[2], "Cantaloupe"); + strcpy(ourGroupInfo.group[3], "Durian"); + strcpy(ourGroupInfo.group[4], "Elderberry"); + strcpy(ourGroupInfo.group[5], "Fig"); + strcpy(ourGroupInfo.group[6], "Guava"); + strcpy(ourGroupInfo.group[7], "Honeydew"); + strcpy(ourGroupInfo.group[8], "Jackfruit"); + strcpy(ourGroupInfo.group[9], "Kiwifruit"); + strcpy(ourGroupInfo.group[10], "TellJmYouSeeThis"); + } bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr) @@ -36,14 +47,23 @@ int32_t GroupPlugin::runOnce() { NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); - - //ourGroupInfo.group[0] = "20"; - //ourGroupInfo.group_count; - sprintf(ourGroupInfo.group[0], "Group 0"); - sprintf(ourGroupInfo.group[1], "Group 1"); - sprintf(ourGroupInfo.group[2], "Group 2"); - sprintf(ourGroupInfo.group[3], "Group 3"); - sprintf(ourGroupInfo.group[4], "Group 4"); - return 5000; // to save power only wake for our callback occasionally + DEBUG_MSG("Group 0=%s\n", ourGroupInfo.group[0]); + DEBUG_MSG("Group 1=%s\n", ourGroupInfo.group[1]); + DEBUG_MSG("Group 2=%s\n", ourGroupInfo.group[2]); + DEBUG_MSG("Group 3=%s\n", ourGroupInfo.group[3]); + DEBUG_MSG("Group 4=%s\n", ourGroupInfo.group[4]); + DEBUG_MSG("Group 5=%s\n", ourGroupInfo.group[5]); + DEBUG_MSG("Group 6=%s\n", ourGroupInfo.group[6]); + DEBUG_MSG("Group 7=%s\n", ourGroupInfo.group[7]); + DEBUG_MSG("Group 8=%s\n", ourGroupInfo.group[8]); + DEBUG_MSG("Group 9=%s\n", ourGroupInfo.group[9]); + DEBUG_MSG("Group 10=%s\n", ourGroupInfo.group[10]); + DEBUG_MSG("Group 11=%s\n", ourGroupInfo.group[11]); + + + + DEBUG_MSG("group plugin runOnce()\n"); + + return 50000; // to save power only wake for our callback occasionally } From a36889abbae489619043de36bee668ee966c9ba7 Mon Sep 17 00:00:00 2001 From: Balazs Kelemen <10376327+prampec@users.noreply.github.com> Date: Mon, 21 Feb 2022 06:29:15 +0100 Subject: [PATCH 35/93] Canned message - Extend messages length --- src/mesh/MeshPlugin.cpp | 58 ++++-- src/mesh/MeshPlugin.h | 28 +++ src/mesh/generated/admin.pb.h | 62 ++---- src/mesh/generated/cannedmessages.pb.c | 14 +- src/mesh/generated/cannedmessages.pb.h | 95 ++------- src/mesh/generated/deviceonly.pb.h | 23 +- src/mesh/generated/radioconfig.pb.h | 11 +- src/plugins/AdminPlugin.cpp | 23 +- src/plugins/CannedMessagePlugin.cpp | 278 +++++++++++++++++++++++-- src/plugins/CannedMessagePlugin.h | 29 ++- 10 files changed, 431 insertions(+), 190 deletions(-) diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 985a7060f..180e1ebfd 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -179,7 +179,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) if (!pluginFound) DEBUG_MSG("No plugins interested in portnum=%d, src=%s\n", - mp.decoded.portnum, + mp.decoded.portnum, (src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE"); } @@ -226,11 +226,13 @@ std::vector MeshPlugin::GetMeshPluginsWithUIFrames() { std::vector pluginsWithUIFrames; - for (auto i = plugins->begin(); i != plugins->end(); ++i) { - auto &pi = **i; - if (pi.wantUIFrame()) { - DEBUG_MSG("Plugin wants a UI Frame\n"); - pluginsWithUIFrames.push_back(&pi); + if (plugins) { + for (auto i = plugins->begin(); i != plugins->end(); ++i) { + auto &pi = **i; + if (pi.wantUIFrame()) { + DEBUG_MSG("Plugin wants a UI Frame\n"); + pluginsWithUIFrames.push_back(&pi); + } } } return pluginsWithUIFrames; @@ -239,14 +241,42 @@ std::vector MeshPlugin::GetMeshPluginsWithUIFrames() void MeshPlugin::observeUIEvents( Observer *observer) { - std::vector pluginsWithUIFrames; - for (auto i = plugins->begin(); i != plugins->end(); ++i) { - auto &pi = **i; - Observable *observable = - pi.getUIFrameObservable(); - if (observable != NULL) { - DEBUG_MSG("Plugin wants a UI Frame\n"); - observer->observe(observable); + if (plugins) { + for (auto i = plugins->begin(); i != plugins->end(); ++i) { + auto &pi = **i; + Observable *observable = + pi.getUIFrameObservable(); + if (observable != NULL) { + DEBUG_MSG("Plugin wants a UI Frame\n"); + observer->observe(observable); + } } } } + +AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response) +{ + AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED; + if (plugins) { + for (auto i = plugins->begin(); i != plugins->end(); ++i) { + auto &pi = **i; + AdminMessageHandleResult h = pi.handleAdminMessageForPlugin(mp, request, response); + if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) + { + // In case we have a response it always has priority. + DEBUG_MSG("Reply prepared by plugin '%s' of variant: %d\n", + pi.name, + response->which_variant); + handled = h; + } + else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) && + (h == AdminMessageHandleResult::HANDLED)) + { + // In case the message is handled it should be populated, but will not overwrite + // a result with response. + handled = h; + } + } + } + return handled; +} diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 456769dc0..8d59aa508 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -21,6 +21,19 @@ enum class ProcessMessage STOP = 1, }; +/** + * Used by plugins to return the result of the AdminMessage handling. + * If request is handled, then plugin should return HANDLED, + * If response is also prepared for the request, then HANDLED_WITH_RESPONSE + * should be returned. + */ +enum class AdminMessageHandleResult +{ + NOT_HANDLED = 0, + HANDLED = 1, + HANDLED_WITH_RESPONSE = 2, +}; + /* * This struct is used by Screen to figure out whether screen frame should be updated. */ @@ -57,6 +70,8 @@ class MeshPlugin static std::vector GetMeshPluginsWithUIFrames(); static void observeUIEvents(Observer *observer); + static AdminMessageHandleResult handleAdminMessageForAllPlugins( + const MeshPacket &mp, AdminMessage *request, AdminMessage *response); #ifndef NO_SCREEN virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { return; } #endif @@ -135,6 +150,19 @@ class MeshPlugin /// Send an error response for the specified packet. MeshPacket *allocErrorResponse(Routing_Error err, const MeshPacket *p); + /** + * @brief An admin message arrived to AdminPlugin. Plugin was asked whether it want to handle the request. + * + * @param mp The mesh packet arrived. + * @param request The AdminMessage request extracted from the packet. + * @param response The prepared response + * @return AdminMessageHandleResult + * HANDLED if message was handled + * HANDLED_WITH_RESPONSE if a response is also prepared and to be sent. + */ + virtual AdminMessageHandleResult handleAdminMessageForPlugin( + const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { return AdminMessageHandleResult::NOT_HANDLED; }; + private: /** * If any of the current chain of plugins has already sent a reply, it will be here. This is useful to allow diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 77518b60f..c313f9f55 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -4,7 +4,6 @@ #ifndef PB_ADMIN_PB_H_INCLUDED #define PB_ADMIN_PB_H_INCLUDED #include -#include "cannedmessages.pb.h" #include "channel.pb.h" #include "mesh.pb.h" #include "radioconfig.pb.h" @@ -31,20 +30,17 @@ typedef struct _AdminMessage { bool exit_simulator; int32_t reboot_seconds; bool get_canned_message_plugin_part1_request; - CannedMessagePluginMessagePart1 get_canned_message_plugin_part1_response; + char get_canned_message_plugin_part1_response[201]; bool get_canned_message_plugin_part2_request; - CannedMessagePluginMessagePart2 get_canned_message_plugin_part2_response; + char get_canned_message_plugin_part2_response[201]; bool get_canned_message_plugin_part3_request; - CannedMessagePluginMessagePart3 get_canned_message_plugin_part3_response; + char get_canned_message_plugin_part3_response[201]; bool get_canned_message_plugin_part4_request; - CannedMessagePluginMessagePart4 get_canned_message_plugin_part4_response; - bool get_canned_message_plugin_part5_request; - CannedMessagePluginMessagePart5 get_canned_message_plugin_part5_response; - CannedMessagePluginMessagePart1 set_canned_message_plugin_part1; - CannedMessagePluginMessagePart2 set_canned_message_plugin_part2; - CannedMessagePluginMessagePart3 set_canned_message_plugin_part3; - CannedMessagePluginMessagePart4 set_canned_message_plugin_part4; - CannedMessagePluginMessagePart5 set_canned_message_plugin_part5; + char get_canned_message_plugin_part4_response[201]; + char set_canned_message_plugin_part1[201]; + char set_canned_message_plugin_part2[201]; + char set_canned_message_plugin_part3[201]; + char set_canned_message_plugin_part4[201]; int32_t shutdown_seconds; }; } AdminMessage; @@ -80,13 +76,10 @@ extern "C" { #define AdminMessage_get_canned_message_plugin_part3_response_tag 41 #define AdminMessage_get_canned_message_plugin_part4_request_tag 42 #define AdminMessage_get_canned_message_plugin_part4_response_tag 43 -#define AdminMessage_get_canned_message_plugin_part5_request_tag 44 -#define AdminMessage_get_canned_message_plugin_part5_response_tag 45 -#define AdminMessage_set_canned_message_plugin_part1_tag 46 -#define AdminMessage_set_canned_message_plugin_part2_tag 47 -#define AdminMessage_set_canned_message_plugin_part3_tag 48 -#define AdminMessage_set_canned_message_plugin_part4_tag 49 -#define AdminMessage_set_canned_message_plugin_part5_tag 50 +#define AdminMessage_set_canned_message_plugin_part1_tag 44 +#define AdminMessage_set_canned_message_plugin_part2_tag 45 +#define AdminMessage_set_canned_message_plugin_part3_tag 46 +#define AdminMessage_set_canned_message_plugin_part4_tag 47 #define AdminMessage_shutdown_seconds_tag 51 /* Struct field encoding specification for nanopb */ @@ -105,20 +98,17 @@ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio) X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \ X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) \ X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part1_request,get_canned_message_plugin_part1_request), 36) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part1_response,get_canned_message_plugin_part1_response), 37) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part1_response,get_canned_message_plugin_part1_response), 37) \ X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part2_request,get_canned_message_plugin_part2_request), 38) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part2_response,get_canned_message_plugin_part2_response), 39) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part2_response,get_canned_message_plugin_part2_response), 39) \ X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part3_request,get_canned_message_plugin_part3_request), 40) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part3_response,get_canned_message_plugin_part3_response), 41) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part3_response,get_canned_message_plugin_part3_response), 41) \ X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part4_request,get_canned_message_plugin_part4_request), 42) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part4_response,get_canned_message_plugin_part4_response), 43) \ -X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part5_request,get_canned_message_plugin_part5_request), 44) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,get_canned_message_plugin_part5_response,get_canned_message_plugin_part5_response), 45) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part1,set_canned_message_plugin_part1), 46) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part2,set_canned_message_plugin_part2), 47) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part3,set_canned_message_plugin_part3), 48) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part4,set_canned_message_plugin_part4), 49) \ -X(a, STATIC, ONEOF, MESSAGE, (variant,set_canned_message_plugin_part5,set_canned_message_plugin_part5), 50) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part4_response,get_canned_message_plugin_part4_response), 43) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part1,set_canned_message_plugin_part1), 44) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part2,set_canned_message_plugin_part2), 45) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part3,set_canned_message_plugin_part3), 46) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part4,set_canned_message_plugin_part4), 47) \ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51) #define AdminMessage_CALLBACK NULL #define AdminMessage_DEFAULT NULL @@ -128,16 +118,6 @@ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), #define AdminMessage_variant_get_radio_response_MSGTYPE RadioConfig #define AdminMessage_variant_get_channel_response_MSGTYPE Channel #define AdminMessage_variant_get_owner_response_MSGTYPE User -#define AdminMessage_variant_get_canned_message_plugin_part1_response_MSGTYPE CannedMessagePluginMessagePart1 -#define AdminMessage_variant_get_canned_message_plugin_part2_response_MSGTYPE CannedMessagePluginMessagePart2 -#define AdminMessage_variant_get_canned_message_plugin_part3_response_MSGTYPE CannedMessagePluginMessagePart3 -#define AdminMessage_variant_get_canned_message_plugin_part4_response_MSGTYPE CannedMessagePluginMessagePart4 -#define AdminMessage_variant_get_canned_message_plugin_part5_response_MSGTYPE CannedMessagePluginMessagePart5 -#define AdminMessage_variant_set_canned_message_plugin_part1_MSGTYPE CannedMessagePluginMessagePart1 -#define AdminMessage_variant_set_canned_message_plugin_part2_MSGTYPE CannedMessagePluginMessagePart2 -#define AdminMessage_variant_set_canned_message_plugin_part3_MSGTYPE CannedMessagePluginMessagePart3 -#define AdminMessage_variant_set_canned_message_plugin_part4_MSGTYPE CannedMessagePluginMessagePart4 -#define AdminMessage_variant_set_canned_message_plugin_part5_MSGTYPE CannedMessagePluginMessagePart5 extern const pb_msgdesc_t AdminMessage_msg; @@ -145,7 +125,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 804 +#define AdminMessage_size 601 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/cannedmessages.pb.c b/src/mesh/generated/cannedmessages.pb.c index 16563446e..e36eff981 100644 --- a/src/mesh/generated/cannedmessages.pb.c +++ b/src/mesh/generated/cannedmessages.pb.c @@ -6,19 +6,7 @@ #error Regenerate this file with the current version of nanopb generator. #endif -PB_BIND(CannedMessagePluginMessagePart1, CannedMessagePluginMessagePart1, AUTO) - - -PB_BIND(CannedMessagePluginMessagePart2, CannedMessagePluginMessagePart2, AUTO) - - -PB_BIND(CannedMessagePluginMessagePart3, CannedMessagePluginMessagePart3, AUTO) - - -PB_BIND(CannedMessagePluginMessagePart4, CannedMessagePluginMessagePart4, AUTO) - - -PB_BIND(CannedMessagePluginMessagePart5, CannedMessagePluginMessagePart5, AUTO) +PB_BIND(CannedMessagePluginConfig, CannedMessagePluginConfig, 2) diff --git a/src/mesh/generated/cannedmessages.pb.h b/src/mesh/generated/cannedmessages.pb.h index 0f1b0786e..ec8a42123 100644 --- a/src/mesh/generated/cannedmessages.pb.h +++ b/src/mesh/generated/cannedmessages.pb.h @@ -10,25 +10,12 @@ #endif /* Struct definitions */ -typedef struct _CannedMessagePluginMessagePart1 { - char text[200]; -} CannedMessagePluginMessagePart1; - -typedef struct _CannedMessagePluginMessagePart2 { - char text[200]; -} CannedMessagePluginMessagePart2; - -typedef struct _CannedMessagePluginMessagePart3 { - char text[200]; -} CannedMessagePluginMessagePart3; - -typedef struct _CannedMessagePluginMessagePart4 { - char text[200]; -} CannedMessagePluginMessagePart4; - -typedef struct _CannedMessagePluginMessagePart5 { - char text[200]; -} CannedMessagePluginMessagePart5; +typedef struct _CannedMessagePluginConfig { + char messagesPart1[201]; + char messagesPart2[201]; + char messagesPart3[201]; + char messagesPart4[201]; +} CannedMessagePluginConfig; #ifdef __cplusplus @@ -36,69 +23,31 @@ extern "C" { #endif /* Initializer values for message structs */ -#define CannedMessagePluginMessagePart1_init_default {""} -#define CannedMessagePluginMessagePart2_init_default {""} -#define CannedMessagePluginMessagePart3_init_default {""} -#define CannedMessagePluginMessagePart4_init_default {""} -#define CannedMessagePluginMessagePart5_init_default {""} -#define CannedMessagePluginMessagePart1_init_zero {""} -#define CannedMessagePluginMessagePart2_init_zero {""} -#define CannedMessagePluginMessagePart3_init_zero {""} -#define CannedMessagePluginMessagePart4_init_zero {""} -#define CannedMessagePluginMessagePart5_init_zero {""} +#define CannedMessagePluginConfig_init_default {"", "", "", ""} +#define CannedMessagePluginConfig_init_zero {"", "", "", ""} /* Field tags (for use in manual encoding/decoding) */ -#define CannedMessagePluginMessagePart1_text_tag 1 -#define CannedMessagePluginMessagePart2_text_tag 1 -#define CannedMessagePluginMessagePart3_text_tag 1 -#define CannedMessagePluginMessagePart4_text_tag 1 -#define CannedMessagePluginMessagePart5_text_tag 1 +#define CannedMessagePluginConfig_messagesPart1_tag 11 +#define CannedMessagePluginConfig_messagesPart2_tag 12 +#define CannedMessagePluginConfig_messagesPart3_tag 13 +#define CannedMessagePluginConfig_messagesPart4_tag 14 /* Struct field encoding specification for nanopb */ -#define CannedMessagePluginMessagePart1_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, text, 1) -#define CannedMessagePluginMessagePart1_CALLBACK NULL -#define CannedMessagePluginMessagePart1_DEFAULT NULL +#define CannedMessagePluginConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, messagesPart1, 11) \ +X(a, STATIC, SINGULAR, STRING, messagesPart2, 12) \ +X(a, STATIC, SINGULAR, STRING, messagesPart3, 13) \ +X(a, STATIC, SINGULAR, STRING, messagesPart4, 14) +#define CannedMessagePluginConfig_CALLBACK NULL +#define CannedMessagePluginConfig_DEFAULT NULL -#define CannedMessagePluginMessagePart2_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, text, 1) -#define CannedMessagePluginMessagePart2_CALLBACK NULL -#define CannedMessagePluginMessagePart2_DEFAULT NULL - -#define CannedMessagePluginMessagePart3_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, text, 1) -#define CannedMessagePluginMessagePart3_CALLBACK NULL -#define CannedMessagePluginMessagePart3_DEFAULT NULL - -#define CannedMessagePluginMessagePart4_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, text, 1) -#define CannedMessagePluginMessagePart4_CALLBACK NULL -#define CannedMessagePluginMessagePart4_DEFAULT NULL - -#define CannedMessagePluginMessagePart5_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, text, 1) -#define CannedMessagePluginMessagePart5_CALLBACK NULL -#define CannedMessagePluginMessagePart5_DEFAULT NULL - -extern const pb_msgdesc_t CannedMessagePluginMessagePart1_msg; -extern const pb_msgdesc_t CannedMessagePluginMessagePart2_msg; -extern const pb_msgdesc_t CannedMessagePluginMessagePart3_msg; -extern const pb_msgdesc_t CannedMessagePluginMessagePart4_msg; -extern const pb_msgdesc_t CannedMessagePluginMessagePart5_msg; +extern const pb_msgdesc_t CannedMessagePluginConfig_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define CannedMessagePluginMessagePart1_fields &CannedMessagePluginMessagePart1_msg -#define CannedMessagePluginMessagePart2_fields &CannedMessagePluginMessagePart2_msg -#define CannedMessagePluginMessagePart3_fields &CannedMessagePluginMessagePart3_msg -#define CannedMessagePluginMessagePart4_fields &CannedMessagePluginMessagePart4_msg -#define CannedMessagePluginMessagePart5_fields &CannedMessagePluginMessagePart5_msg +#define CannedMessagePluginConfig_fields &CannedMessagePluginConfig_msg /* Maximum encoded size of messages (where known) */ -#define CannedMessagePluginMessagePart1_size 202 -#define CannedMessagePluginMessagePart2_size 202 -#define CannedMessagePluginMessagePart3_size 202 -#define CannedMessagePluginMessagePart4_size 202 -#define CannedMessagePluginMessagePart5_size 202 +#define CannedMessagePluginConfig_size 812 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 14453a9ad..d384e7e57 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -34,11 +34,6 @@ typedef struct _DeviceState { uint32_t version; bool no_save; bool did_gps_reset; - char canned_message_plugin_message_part1[200]; - char canned_message_plugin_message_part2[200]; - char canned_message_plugin_message_part3[200]; - char canned_message_plugin_message_part4[200]; - char canned_message_plugin_message_part5[200]; } DeviceState; @@ -47,9 +42,9 @@ extern "C" { #endif /* Initializer values for message structs */ -#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, GroupInfo_init_default, false, MeshPacket_init_default, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, GroupInfo_init_default, false, MeshPacket_init_default, 0, 0, 0} #define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}} -#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, GroupInfo_init_zero, false, MeshPacket_init_zero, 0, 0, 0, "", "", "", "", ""} +#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, GroupInfo_init_zero, false, MeshPacket_init_zero, 0, 0, 0} #define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}} /* Field tags (for use in manual encoding/decoding) */ @@ -63,11 +58,6 @@ extern "C" { #define DeviceState_version_tag 8 #define DeviceState_no_save_tag 9 #define DeviceState_did_gps_reset_tag 11 -#define DeviceState_canned_message_plugin_message_part1_tag 13 -#define DeviceState_canned_message_plugin_message_part2_tag 14 -#define DeviceState_canned_message_plugin_message_part3_tag 15 -#define DeviceState_canned_message_plugin_message_part4_tag 16 -#define DeviceState_canned_message_plugin_message_part5_tag 17 /* Struct field encoding specification for nanopb */ #define DeviceState_FIELDLIST(X, a) \ @@ -79,12 +69,7 @@ X(a, STATIC, OPTIONAL, MESSAGE, group_info, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \ X(a, STATIC, SINGULAR, UINT32, version, 8) \ X(a, STATIC, SINGULAR, BOOL, no_save, 9) \ -X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part1, 13) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part2, 14) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part3, 15) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part4, 16) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_message_part5, 17) +X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11) #define DeviceState_CALLBACK NULL #define DeviceState_DEFAULT NULL #define DeviceState_my_node_MSGTYPE MyNodeInfo @@ -108,7 +93,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 11174 +#define DeviceState_size 10162 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index b8850d05c..af24b5184 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -186,7 +186,6 @@ typedef struct _RadioConfig_UserPreferences { InputEventChar rotary1_event_press; bool canned_message_plugin_enabled; char canned_message_plugin_allow_input_source[16]; - char canned_message_plugin_messages[200]; bool canned_message_plugin_send_bell; bool mqtt_encryption_enabled; float adc_multiplier_override; @@ -238,9 +237,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0, 0} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", "", 0, 0, 0} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -322,7 +321,6 @@ extern "C" { #define RadioConfig_UserPreferences_rotary1_event_press_tag 166 #define RadioConfig_UserPreferences_canned_message_plugin_enabled_tag 170 #define RadioConfig_UserPreferences_canned_message_plugin_allow_input_source_tag 171 -#define RadioConfig_UserPreferences_canned_message_plugin_messages_tag 172 #define RadioConfig_UserPreferences_canned_message_plugin_send_bell_tag 173 #define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174 #define RadioConfig_UserPreferences_adc_multiplier_override_tag 175 @@ -415,7 +413,6 @@ X(a, STATIC, SINGULAR, UENUM, rotary1_event_ccw, 165) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_press, 166) \ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_enabled, 170) \ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_source, 171) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_messages, 172) \ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_send_bell, 173) \ X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \ X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) @@ -430,8 +427,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 801 -#define RadioConfig_UserPreferences_size 798 +#define RadioConfig_size 598 +#define RadioConfig_UserPreferences_size 595 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp index 3886cb232..2f1893a87 100644 --- a/src/plugins/AdminPlugin.cpp +++ b/src/plugins/AdminPlugin.cpp @@ -63,6 +63,9 @@ void AdminPlugin::handleGetRadio(const MeshPacket &req) bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) { + // if handled == false, then let others look at this message also if they want + bool handled = false; + assert(r); switch (r->which_variant) { case AdminMessage_set_owner_tag: @@ -119,11 +122,25 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) #endif default: - // Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages - DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant); + AdminMessage response = AdminMessage_init_default; + AdminMessageHandleResult handleResult = MeshPlugin::handleAdminMessageForAllPlugins(mp, r, &response); + + if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) + { + myReply = allocDataProtobuf(response); + } + else if (mp.decoded.want_response) + { + DEBUG_MSG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_variant); + } + else if (handleResult != AdminMessageHandleResult::HANDLED) + { + // Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages + DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant); + } break; } - return false; // Let others look at this message also if they want + return handled; } void AdminPlugin::handleSetOwner(const User &o) diff --git a/src/plugins/CannedMessagePlugin.cpp b/src/plugins/CannedMessagePlugin.cpp index b209187ad..a6b9a23f4 100644 --- a/src/plugins/CannedMessagePlugin.cpp +++ b/src/plugins/CannedMessagePlugin.cpp @@ -1,6 +1,8 @@ #include "configuration.h" #include "CannedMessagePlugin.h" #include "MeshService.h" +#include "FSCommon.h" +#include "mesh/generated/cannedmessages.pb.h" // TODO: reuse defined from Screen.cpp #define FONT_SMALL ArialMT_Plain_10 @@ -10,28 +12,40 @@ // Remove Canned message screen if no action is taken for some milliseconds #define INACTIVATE_AFTER_MS 20000 +static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto"; + +CannedMessagePluginConfig cannedMessagePluginConfig; + CannedMessagePlugin *cannedMessagePlugin; +// TODO: move it into NodeDB.h! +extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct); +extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct); + CannedMessagePlugin::CannedMessagePlugin() : SinglePortPlugin("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessagePlugin") { if (radioConfig.preferences.canned_message_plugin_enabled) { + this->loadProtoForPlugin(); if(this->splitConfiguredMessages() <= 0) { - radioConfig.preferences.canned_message_plugin_enabled = false; DEBUG_MSG("CannedMessagePlugin: No messages are configured. Plugin is disabled\n"); - return; + this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED; + } + else + { + DEBUG_MSG("CannedMessagePlugin is enabled\n"); + this->inputObserver.observe(inputBroker); } - this->inputObserver.observe(inputBroker); } } /** * @brief Items in array this->messages will be set to be pointing on the right * starting points of the string this->messageStore - * + * * @return int Returns the number of messages found. */ int CannedMessagePlugin::splitConfiguredMessages() @@ -39,11 +53,21 @@ int CannedMessagePlugin::splitConfiguredMessages() int messageIndex = 0; int i = 0; - strncpy( + // collect all the message parts + strcpy( this->messageStore, - radioConfig.preferences.canned_message_plugin_messages, - CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE); + cannedMessagePluginConfig.messagesPart1); + strcat( + this->messageStore, + cannedMessagePluginConfig.messagesPart2); + strcat( + this->messageStore, + cannedMessagePluginConfig.messagesPart3); + strcat( + this->messageStore, + cannedMessagePluginConfig.messagesPart4); + // The first message points to the beginning of the store. this->messages[messageIndex++] = this->messageStore; int upTo = @@ -51,13 +75,14 @@ int CannedMessagePlugin::splitConfiguredMessages() while (i < upTo) { - if (this->messageStore[i] == '|') + if (this->messageStore[i] == '|') { // Message ending found, replace it with string-end character. this->messageStore[i] = '\0'; DEBUG_MSG("CannedMessage %d is: '%s'\n", messageIndex-1, this->messages[messageIndex-1]); + // hit our max messages, bail if (messageIndex >= CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT) { this->messagesCount = messageIndex; @@ -72,6 +97,7 @@ int CannedMessagePlugin::splitConfiguredMessages() } if (strlen(this->messages[messageIndex-1]) > 0) { + // We have a last message. DEBUG_MSG("CannedMessage %d is: '%s'\n", messageIndex-1, this->messages[messageIndex-1]); this->messagesCount = messageIndex; @@ -92,6 +118,9 @@ int CannedMessagePlugin::handleInputEvent(const InputEvent *event) (strcmp(radioConfig.preferences.canned_message_plugin_allow_input_source, "_any") != 0)) { // Event source is not accepted. + // Event only accepted if source matches the configured one, or + // the configured one is "_any" (or if there is no configured + // source at all) return 0; } @@ -140,9 +169,6 @@ void CannedMessagePlugin::sendText(NodeNum dest, p->decoded.payload.size++; } - -// PacketId prevPacketId = p->id; // In case we need it later. - DEBUG_MSG("Sending message id=%d, msg=%.*s\n", p->id, p->decoded.payload.size, p->decoded.payload.bytes); @@ -152,6 +178,7 @@ void CannedMessagePlugin::sendText(NodeNum dest, int32_t CannedMessagePlugin::runOnce() { if ((!radioConfig.preferences.canned_message_plugin_enabled) + || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { return 30000; // TODO: should return MAX_VAL @@ -180,7 +207,7 @@ int32_t CannedMessagePlugin::runOnce() else if (this->currentMessageIndex == -1) { this->currentMessageIndex = 0; - DEBUG_MSG("First touch.\n"); + DEBUG_MSG("First touch (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); e.frameChanged = true; this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; } @@ -199,13 +226,13 @@ int32_t CannedMessagePlugin::runOnce() { this->currentMessageIndex = getPrevIndex(); this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; - DEBUG_MSG("MOVE UP\n"); + DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); } else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) { this->currentMessageIndex = this->getNextIndex(); this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE; - DEBUG_MSG("MOVE DOWN\n"); + DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); } if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) @@ -286,3 +313,226 @@ void CannedMessagePlugin::drawFrame( } } +void CannedMessagePlugin::loadProtoForPlugin() +{ + if (!loadProto(cannedMessagesConfigFile, CannedMessagePluginConfig_size, sizeof(cannedMessagesConfigFile), CannedMessagePluginConfig_fields, &cannedMessagePluginConfig)) { + installDefaultCannedMessagePluginConfig(); + } +} + +/** + * @brief Save the plugin config to file. + * + * @return true On success. + * @return false On error. + */ +bool CannedMessagePlugin::saveProtoForPlugin() +{ + bool okay = true; + +#ifdef FS + FS.mkdir("/prefs"); +#endif + + okay &= saveProto(cannedMessagesConfigFile, CannedMessagePluginConfig_size, sizeof(CannedMessagePluginConfig), CannedMessagePluginConfig_fields, &cannedMessagePluginConfig); + + return okay; +} + +/** + * @brief Fill configuration with default values. + */ +void CannedMessagePlugin::installDefaultCannedMessagePluginConfig() +{ + memset(cannedMessagePluginConfig.messagesPart1, 0, sizeof(cannedMessagePluginConfig.messagesPart1)); + memset(cannedMessagePluginConfig.messagesPart2, 0, sizeof(cannedMessagePluginConfig.messagesPart2)); + memset(cannedMessagePluginConfig.messagesPart3, 0, sizeof(cannedMessagePluginConfig.messagesPart3)); + memset(cannedMessagePluginConfig.messagesPart4, 0, sizeof(cannedMessagePluginConfig.messagesPart4)); +} + +/** + * @brief An admin message arrived to AdminPlugin. We are asked whether we want to handle that. + * + * @param mp The mesh packet arrived. + * @param request The AdminMessage request extracted from the packet. + * @param response The prepared response + * @return AdminMessageHandleResult HANDLED if message was handled + * HANDLED_WITH_RESULT if a result is also prepared. + */ +AdminMessageHandleResult CannedMessagePlugin::handleAdminMessageForPlugin( + const MeshPacket &mp, AdminMessage *request, AdminMessage *response) +{ + AdminMessageHandleResult result; + + switch (request->which_variant) { + case AdminMessage_get_canned_message_plugin_part1_request_tag: + DEBUG_MSG("Client is getting radio canned message part1\n"); + this->handleGetCannedMessagePluginPart1(mp, response); + result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; + break; + + case AdminMessage_get_canned_message_plugin_part2_request_tag: + DEBUG_MSG("Client is getting radio canned message part2\n"); + this->handleGetCannedMessagePluginPart2(mp, response); + result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; + break; + + case AdminMessage_get_canned_message_plugin_part3_request_tag: + DEBUG_MSG("Client is getting radio canned message part3\n"); + this->handleGetCannedMessagePluginPart3(mp, response); + result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; + break; + + case AdminMessage_get_canned_message_plugin_part4_request_tag: + DEBUG_MSG("Client is getting radio canned message part4\n"); + this->handleGetCannedMessagePluginPart4(mp, response); + result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; + break; + + case AdminMessage_set_canned_message_plugin_part1_tag: + DEBUG_MSG("Client is setting radio canned message part 1\n"); + this->handleSetCannedMessagePluginPart1( + request->set_canned_message_plugin_part1); + result = AdminMessageHandleResult::HANDLED; + break; + + case AdminMessage_set_canned_message_plugin_part2_tag: + DEBUG_MSG("Client is setting radio canned message part 2\n"); + this->handleSetCannedMessagePluginPart2( + request->set_canned_message_plugin_part2); + result = AdminMessageHandleResult::HANDLED; + break; + + case AdminMessage_set_canned_message_plugin_part3_tag: + DEBUG_MSG("Client is setting radio canned message part 3\n"); + this->handleSetCannedMessagePluginPart3( + request->set_canned_message_plugin_part3); + result = AdminMessageHandleResult::HANDLED; + break; + + case AdminMessage_set_canned_message_plugin_part4_tag: + DEBUG_MSG("Client is setting radio canned message part 4\n"); + this->handleSetCannedMessagePluginPart4( + request->set_canned_message_plugin_part4); + result = AdminMessageHandleResult::HANDLED; + break; + + default: + result = AdminMessageHandleResult::NOT_HANDLED; + } + + return result; +} + +void CannedMessagePlugin::handleGetCannedMessagePluginPart1( + const MeshPacket &req, AdminMessage *response) +{ + DEBUG_MSG("*** handleGetCannedMessagePluginPart1\n"); + assert(req.decoded.want_response); + + response->which_variant = AdminMessage_get_canned_message_plugin_part1_response_tag; + strcpy( + response->get_canned_message_plugin_part1_response, + cannedMessagePluginConfig.messagesPart1); +} + +void CannedMessagePlugin::handleGetCannedMessagePluginPart2( + const MeshPacket &req, AdminMessage *response) +{ + DEBUG_MSG("*** handleGetCannedMessagePluginPart2\n"); + assert(req.decoded.want_response); + + response->which_variant = AdminMessage_get_canned_message_plugin_part2_response_tag; + strcpy( + response->get_canned_message_plugin_part2_response, + cannedMessagePluginConfig.messagesPart2); +} + +void CannedMessagePlugin::handleGetCannedMessagePluginPart3( + const MeshPacket &req, AdminMessage *response) +{ + DEBUG_MSG("*** handleGetCannedMessagePluginPart3\n"); + assert(req.decoded.want_response); + + response->which_variant = AdminMessage_get_canned_message_plugin_part3_response_tag; + strcpy( + response->get_canned_message_plugin_part3_response, + cannedMessagePluginConfig.messagesPart3); +} + +void CannedMessagePlugin::handleGetCannedMessagePluginPart4( + const MeshPacket &req, AdminMessage *response) +{ + DEBUG_MSG("*** handleGetCannedMessagePluginPart4\n"); + assert(req.decoded.want_response); + + response->which_variant = AdminMessage_get_canned_message_plugin_part4_response_tag; + strcpy( + response->get_canned_message_plugin_part4_response, + cannedMessagePluginConfig.messagesPart4); +} + +void CannedMessagePlugin::handleSetCannedMessagePluginPart1(const char *from_msg) +{ + int changed = 0; + + if (*from_msg) + { + changed |= strcmp(cannedMessagePluginConfig.messagesPart1, from_msg); + strcpy(cannedMessagePluginConfig.messagesPart1, from_msg); + DEBUG_MSG("*** from_msg.text:%s\n", from_msg); + } + + if (changed) + { + this->saveProtoForPlugin(); + } +} + +void CannedMessagePlugin::handleSetCannedMessagePluginPart2(const char *from_msg) +{ + int changed = 0; + + if (*from_msg) + { + changed |= strcmp(cannedMessagePluginConfig.messagesPart2, from_msg); + strcpy(cannedMessagePluginConfig.messagesPart2, from_msg); + } + + if (changed) + { + this->saveProtoForPlugin(); + } +} + +void CannedMessagePlugin::handleSetCannedMessagePluginPart3(const char *from_msg) +{ + int changed = 0; + + if (*from_msg) + { + changed |= strcmp(cannedMessagePluginConfig.messagesPart3, from_msg); + strcpy(cannedMessagePluginConfig.messagesPart3, from_msg); + } + + if (changed) + { + this->saveProtoForPlugin(); + } +} + +void CannedMessagePlugin::handleSetCannedMessagePluginPart4(const char *from_msg) +{ + int changed = 0; + + if (*from_msg) + { + changed |= strcmp(cannedMessagePluginConfig.messagesPart4, from_msg); + strcpy(cannedMessagePluginConfig.messagesPart4, from_msg); + } + + if (changed) + { + this->saveProtoForPlugin(); + } +} diff --git a/src/plugins/CannedMessagePlugin.h b/src/plugins/CannedMessagePlugin.h index 1f7dcf42e..2cb6e0730 100644 --- a/src/plugins/CannedMessagePlugin.h +++ b/src/plugins/CannedMessagePlugin.h @@ -1,24 +1,24 @@ #pragma once -#include "SinglePortPlugin.h" +#include "ProtobufPlugin.h" #include "input/InputBroker.h" enum cannedMessagePluginRunState { + CANNED_MESSAGE_RUN_STATE_DISABLED, CANNED_MESSAGE_RUN_STATE_INACTIVE, CANNED_MESSAGE_RUN_STATE_ACTIVE, CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE, CANNED_MESSAGE_RUN_STATE_ACTION_SELECT, CANNED_MESSAGE_RUN_STATE_ACTION_UP, - CANNED_MESSAGE_RUN_STATE_ACTION_DOWN + CANNED_MESSAGE_RUN_STATE_ACTION_DOWN, }; #define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT 50 /** - * Due to config-packet size restrictions we cannot have user configuration bigger - * than Constants_DATA_PAYLOAD_LEN bytes. + * Sum of CannedMessagePluginConfig part sizes. */ -#define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 200 +#define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 800 class CannedMessagePlugin : public SinglePortPlugin, @@ -38,6 +38,16 @@ class CannedMessagePlugin : void eventDown(); void eventSelect(); + void handleGetCannedMessagePluginPart1(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessagePluginPart2(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessagePluginPart3(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessagePluginPart4(const MeshPacket &req, AdminMessage *response); + + void handleSetCannedMessagePluginPart1(const char *from_msg); + void handleSetCannedMessagePluginPart2(const char *from_msg); + void handleSetCannedMessagePluginPart3(const char *from_msg); + void handleSetCannedMessagePluginPart4(const char *from_msg); + protected: virtual int32_t runOnce() override; @@ -56,11 +66,18 @@ class CannedMessagePlugin : virtual Observable* getUIFrameObservable() override { return this; } virtual void drawFrame( OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override; + virtual AdminMessageHandleResult handleAdminMessageForPlugin( + const MeshPacket &mp, AdminMessage *request, AdminMessage *response) override; + + void loadProtoForPlugin(); + bool saveProtoForPlugin(); + + void installDefaultCannedMessagePluginConfig(); int currentMessageIndex = -1; cannedMessagePluginRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; - char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE]; + char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE+1]; char *messages[CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT]; int messagesCount = 0; unsigned long lastTouchMillis = 0; From 54ff8f2db323479d05118a1ab1349127fbe76c00 Mon Sep 17 00:00:00 2001 From: Balazs Kelemen <10376327+prampec@users.noreply.github.com> Date: Mon, 21 Feb 2022 23:53:56 +0100 Subject: [PATCH 36/93] Canned message - Fixes --- src/plugins/GroupPlugin.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index acab5979e..b67d05e7e 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -23,7 +23,6 @@ GroupPlugin::GroupPlugin() strcpy(ourGroupInfo.group[7], "Honeydew"); strcpy(ourGroupInfo.group[8], "Jackfruit"); strcpy(ourGroupInfo.group[9], "Kiwifruit"); - strcpy(ourGroupInfo.group[10], "TellJmYouSeeThis"); } @@ -58,8 +57,6 @@ int32_t GroupPlugin::runOnce() DEBUG_MSG("Group 7=%s\n", ourGroupInfo.group[7]); DEBUG_MSG("Group 8=%s\n", ourGroupInfo.group[8]); DEBUG_MSG("Group 9=%s\n", ourGroupInfo.group[9]); - DEBUG_MSG("Group 10=%s\n", ourGroupInfo.group[10]); - DEBUG_MSG("Group 11=%s\n", ourGroupInfo.group[11]); From 972c2bb329dc194efdcd52d9a74865ecc3aaf697 Mon Sep 17 00:00:00 2001 From: Balazs Kelemen <10376327+prampec@users.noreply.github.com> Date: Tue, 22 Feb 2022 07:08:44 +0100 Subject: [PATCH 37/93] Revert "Canned message - Fixes" This reverts commit 54ff8f2db323479d05118a1ab1349127fbe76c00. --- src/plugins/GroupPlugin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index b67d05e7e..acab5979e 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -23,6 +23,7 @@ GroupPlugin::GroupPlugin() strcpy(ourGroupInfo.group[7], "Honeydew"); strcpy(ourGroupInfo.group[8], "Jackfruit"); strcpy(ourGroupInfo.group[9], "Kiwifruit"); + strcpy(ourGroupInfo.group[10], "TellJmYouSeeThis"); } @@ -57,6 +58,8 @@ int32_t GroupPlugin::runOnce() DEBUG_MSG("Group 7=%s\n", ourGroupInfo.group[7]); DEBUG_MSG("Group 8=%s\n", ourGroupInfo.group[8]); DEBUG_MSG("Group 9=%s\n", ourGroupInfo.group[9]); + DEBUG_MSG("Group 10=%s\n", ourGroupInfo.group[10]); + DEBUG_MSG("Group 11=%s\n", ourGroupInfo.group[11]); From bb15ed903defcfd175ab5372f1b51db1f86c16d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Kelemen?= <10376327+prampec@users.noreply.github.com> Date: Tue, 22 Feb 2022 13:18:54 +0100 Subject: [PATCH 38/93] Cleanup docker readme. (#1233) Cleanup docker readme. --- README-docker.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ docker.txt | 17 ------------ 2 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 README-docker.md delete mode 100644 docker.txt diff --git a/README-docker.md b/README-docker.md new file mode 100644 index 000000000..8c7b8eab5 --- /dev/null +++ b/README-docker.md @@ -0,0 +1,72 @@ +## What is Docker used for + +Developers can simulate Device hardware by compiling and running +a linux native binary application. If you do not own a Linux +machine, or you just want to separate things, you might want +to run simulator inside a docker container + +## The Image +To build docker image, type + + `docker build -t meshtastic/device .` + +## Usage + +To run a container, type + + `docker run --rm -p 4403:4403 meshtastic/device` + +or, to get an interactive shell on the docker created container: + + `docker run -it -p 4403:4403 meshtastic/device bash` + +You might want to mount your local development folder: + + `docker run -it --mount type=bind,source=/PathToMyProjects/Meshtastic/Meshtastic-device-mybranch,target=/Meshtastic-device-mybranch -p 4403:4403 meshtastic/device bash` + +## Build the native application + +Linux native application should be built inside the container. +For this you must run container with interactive console +"-it", as seen above. + +First, some environment variables need to be set up with command: + + `. ~/.platformio/penv/bin/activate` + +You also want to make some adjustments in the bin/build-all.sh to conform the amd64 build: + +``` + sed -i 's/^BOARDS_ESP32.*/BOARDS_ESP32=""/' bin/build-all.sh + sed -i 's/^BOARDS_NRF52.*/BOARDS_NRF52=""/' bin/build-all.sh + sed -i 's/echo "Building SPIFFS.*/exit/' bin/build-all.sh +``` + +You can build amd64 image with command + +`bin/build-all.sh` + +## Executing the application interactively + +The built binary file should be found under name +`release/latest/bins/universal/meshtastic_linux_amd64`. +If this is not the case, you can also use direct program name: +`.pio/build/native/program` + +To use python cli against exposed port 4403, +type this in the host machine: + +`meshtastic --info --host localhost` + +## Stop the container + +Run this to get the ID: + +`docker ps` + +Stop the container with command: + +`docker kill ` + +> Tip: you can just use the first few characters of the ID in docker commands + diff --git a/docker.txt b/docker.txt deleted file mode 100644 index af2c9c0b0..000000000 --- a/docker.txt +++ /dev/null @@ -1,17 +0,0 @@ -To build: - docker build -t meshtastic/device . - -To run: - docker run --rm -p 4403:4403 meshtastic/device -or, to get a shell on the docker image: - docker run -it meshtastic/device bash - -To use python cli against it: - meshtastic --info --host localhost - -To stop: - # run this to get id - docker ps - # tip: you can just use the first few characters of the id in the next command - docker kill - From 31f4ec5d6c783a8ea36e30720bb9d52562fe1648 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 22 Feb 2022 17:10:01 -0800 Subject: [PATCH 39/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 95e22cceb..30e147a55 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 95e22ccebd906e2becac1c7ac47af115138a6c85 +Subproject commit 30e147a55ce27199cb638a1d82e0b88adc8f5385 From e52f94820e4ca1ecf10638177e10e43f59e28007 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 22 Feb 2022 17:16:45 -0800 Subject: [PATCH 40/93] remove test code --- src/plugins/GroupPlugin.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp index acab5979e..243ad1610 100644 --- a/src/plugins/GroupPlugin.cpp +++ b/src/plugins/GroupPlugin.cpp @@ -23,7 +23,6 @@ GroupPlugin::GroupPlugin() strcpy(ourGroupInfo.group[7], "Honeydew"); strcpy(ourGroupInfo.group[8], "Jackfruit"); strcpy(ourGroupInfo.group[9], "Kiwifruit"); - strcpy(ourGroupInfo.group[10], "TellJmYouSeeThis"); } From cd9def68507d148788ed5cf50174a96a3ce64809 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 22 Feb 2022 19:01:24 -0800 Subject: [PATCH 41/93] Add my test ssid --- src/mesh/http/WiFiAPClient.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index 1101ad1cd..208bd6c25 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -175,6 +175,9 @@ bool initWifi(bool forceSoftAP) { forcedSoftAP = forceSoftAP; + // strcpy(radioConfig.preferences.wifi_ssid, "meshtastic"); + // strcpy(radioConfig.preferences.wifi_password, "meshtastic!"); + if ((radioConfig.has_preferences && radioConfig.preferences.wifi_ssid[0]) || forceSoftAP) { const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiPsw = radioConfig.preferences.wifi_password; From b6d7eadea3287424b375d7f8bca8a033cbf9c5d8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 24 Feb 2022 20:05:27 -0800 Subject: [PATCH 42/93] Remove chat groups --- src/mesh/PhoneAPI.cpp | 12 +------ src/plugins/GroupPlugin.cpp | 68 ------------------------------------- src/plugins/GroupPlugin.h | 29 ---------------- src/plugins/Plugins.cpp | 4 +-- 4 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 src/plugins/GroupPlugin.cpp delete mode 100644 src/plugins/GroupPlugin.h diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 72e02cfa2..ca794036f 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -140,16 +140,9 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info fromRadioScratch.which_payloadVariant = FromRadio_my_info_tag; fromRadioScratch.my_info = myNodeInfo; - state = STATE_SEND_GROUPS; - - service.refreshMyNodeInfo(); // Update my NodeInfo because the client will be asking for it soon. - break; - - case STATE_SEND_GROUPS: - fromRadioScratch.which_payloadVariant = FromRadio_groups_tag; - fromRadioScratch.groups = ourGroupInfo; state = STATE_SEND_NODEINFO; + service.refreshMyNodeInfo(); // Update my NodeInfo because the client will be asking for it soon. break; case STATE_SEND_NODEINFO: { @@ -228,9 +221,6 @@ bool PhoneAPI::available() case STATE_SEND_MY_INFO: return true; - case STATE_SEND_GROUPS: - return true; - case STATE_SEND_NODEINFO: if (!nodeInfoForPhone) nodeInfoForPhone = nodeDB.readNextInfo(); diff --git a/src/plugins/GroupPlugin.cpp b/src/plugins/GroupPlugin.cpp deleted file mode 100644 index 243ad1610..000000000 --- a/src/plugins/GroupPlugin.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "GroupPlugin.h" -#include "MeshService.h" -#include "Router.h" -#include "configuration.h" -#include "NodeDB.h" - - -GroupPlugin *groupPlugin; - - - -GroupPlugin::GroupPlugin() - : ProtobufPlugin("group", PortNum_GROUP_APP, GroupInfo_fields), concurrency::OSThread("GroupPlugin") -{ - - strcpy(ourGroupInfo.group[0], "Avocado"); - strcpy(ourGroupInfo.group[1], "Backberries"); - strcpy(ourGroupInfo.group[2], "Cantaloupe"); - strcpy(ourGroupInfo.group[3], "Durian"); - strcpy(ourGroupInfo.group[4], "Elderberry"); - strcpy(ourGroupInfo.group[5], "Fig"); - strcpy(ourGroupInfo.group[6], "Guava"); - strcpy(ourGroupInfo.group[7], "Honeydew"); - strcpy(ourGroupInfo.group[8], "Jackfruit"); - strcpy(ourGroupInfo.group[9], "Kiwifruit"); - -} - -bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr) -{ - //auto p = *pptr; - - - - return false; // Let others look at this message also if they want -} - -MeshPacket *GroupPlugin::allocReply() -{ - GroupInfo gi = GroupInfo_init_default; // Start with an empty structure - - return allocDataProtobuf(gi); -} - -int32_t GroupPlugin::runOnce() -{ - NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); - - - DEBUG_MSG("Group 0=%s\n", ourGroupInfo.group[0]); - DEBUG_MSG("Group 1=%s\n", ourGroupInfo.group[1]); - DEBUG_MSG("Group 2=%s\n", ourGroupInfo.group[2]); - DEBUG_MSG("Group 3=%s\n", ourGroupInfo.group[3]); - DEBUG_MSG("Group 4=%s\n", ourGroupInfo.group[4]); - DEBUG_MSG("Group 5=%s\n", ourGroupInfo.group[5]); - DEBUG_MSG("Group 6=%s\n", ourGroupInfo.group[6]); - DEBUG_MSG("Group 7=%s\n", ourGroupInfo.group[7]); - DEBUG_MSG("Group 8=%s\n", ourGroupInfo.group[8]); - DEBUG_MSG("Group 9=%s\n", ourGroupInfo.group[9]); - DEBUG_MSG("Group 10=%s\n", ourGroupInfo.group[10]); - DEBUG_MSG("Group 11=%s\n", ourGroupInfo.group[11]); - - - - DEBUG_MSG("group plugin runOnce()\n"); - - return 50000; // to save power only wake for our callback occasionally -} diff --git a/src/plugins/GroupPlugin.h b/src/plugins/GroupPlugin.h deleted file mode 100644 index f456234b0..000000000 --- a/src/plugins/GroupPlugin.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "GroupPlugin.h" -#include "ProtobufPlugin.h" -#include "concurrency/OSThread.h" - -/** - * Position plugin for sending/receiving positions into the mesh - */ -class GroupPlugin : public ProtobufPlugin, private concurrency::OSThread -{ - public: - GroupPlugin(); - - protected: - /** 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 handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *p) override; - - /** Messages can be received that have the want_response bit set. If set, this callback will be invoked - * so that subclasses can (optionally) send a response back to the original sender. */ - virtual MeshPacket *allocReply() override; - - /** Does our periodic broadcast */ - virtual int32_t runOnce() override; -}; - -extern GroupPlugin *groupPlugin; diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index 3cf66a170..c979ce9da 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -4,7 +4,6 @@ #include "plugins/AdminPlugin.h" #include "plugins/CannedMessagePlugin.h" #include "plugins/ExternalNotificationPlugin.h" -#include "plugins/GroupPlugin.h" #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" #include "plugins/RemoteHardwarePlugin.h" @@ -30,8 +29,7 @@ void setupPlugins() nodeInfoPlugin = new NodeInfoPlugin(); positionPlugin = new PositionPlugin(); textMessagePlugin = new TextMessagePlugin(); - groupPlugin = new GroupPlugin(); - + // Note: if the rest of meshtastic doesn't need to explicitly use your plugin, you do not need to assign the instance // to a global variable. From c5a8cc6d3f94067544538dc3402f59e6d8f96da9 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Fri, 25 Feb 2022 15:03:52 +0200 Subject: [PATCH 43/93] Add 1.54, 2.9 and 4.2 inch e-Paper support for RAK4361 boards - with partial updates for faster screen transitions (#1240) * Update platformio.ini --- platformio.ini | 7 +- src/graphics/EInkDisplay2.cpp | 69 +++++++++++++++++-- .../platformio.ini | 2 +- variants/t-echo/platformio.ini | 4 +- 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/platformio.ini b/platformio.ini index f7974b2e6..d45101430 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,8 +23,9 @@ default_envs = tbeam ;default_envs = t-echo ;default_envs = nrf52840dk-geeksville ;default_envs = native # 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 = rak4631 -;default_envs = rak4630 +;default_envs = rak4631_5005 +;default_envs = rak4631_5005_eink +;default_envs = rak4631_19003 ;default_envs = meshtastic-diy-v1 ;default_envs = meshtastic-diy-v1.1 @@ -265,4 +266,4 @@ monitor_port = /dev/ttyUSB0 monitor_speed = 115200 # For experimenting with RAM sizes -# board_build.ldscript = linker/nrf52840_s140_sim832.ld \ No newline at end of file +# board_build.ldscript = linker/nrf52840_s140_sim832.ld diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 2432e6f1c..4c030b60c 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -12,7 +12,19 @@ #if defined(TTGO_T_ECHO) #define TECHO_DISPLAY_MODEL GxEPD2_154_D67 #elif defined(RAK4630) + +//GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128 #define TECHO_DISPLAY_MODEL GxEPD2_213_B74 + +//4.2 inch 300x400 - GxEPD2_420_M01 +//#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 + +//2.9 inch 296x128 - GxEPD2_290_T5D +//#define TECHO_DISPLAY_MODEL GxEPD2_290_T5D + +//1.54 inch 200x200 - GxEPD2_154_M09 +//#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 + #endif GxEPD2_BW *adafruitDisplay; @@ -22,7 +34,19 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl) #if defined(TTGO_T_ECHO) setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); #elif defined(RAK4630) + + //GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128 setGeometry(GEOMETRY_RAWMODE, 250, 122); + + //GxEPD2_420_M01 + //setGeometry(GEOMETRY_RAWMODE, 300, 400); + + //GxEPD2_290_T5D + //setGeometry(GEOMETRY_RAWMODE, 296, 128); + + //GxEPD2_154_M09 + //setGeometry(GEOMETRY_RAWMODE, 200, 200); + #endif // setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution // setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does @@ -47,8 +71,8 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) // FIXME - only draw bits have changed (use backbuf similar to the other displays) // tft.drawBitmap(0, 0, buffer, 128, 64, TFT_YELLOW, TFT_BLACK); - for (uint8_t y = 0; y < displayHeight; y++) { - for (uint8_t x = 0; x < displayWidth; x++) { + for (uint64_t y = 0; y < displayHeight; y++) { + for (uint64_t x = 0; x < displayWidth; x++) { // get src pixel in the page based ordering the OLED lib uses FIXME, super inefficent auto b = buffer[x + (y / 8) * displayWidth]; @@ -63,8 +87,22 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit) DEBUG_MSG("Updating RAK4361_5005 E-Paper... "); #endif + #if defined(TTGO_T_ECHO) // ePaper.Reset(); // wake the screen from sleep adafruitDisplay->display(false); // FIXME, use partial update mode + #elif defined(RAK4630) + + //RAK14000 2.13 inch b/w 250x122 does not support partial updates + adafruitDisplay->display(false); // FIXME, use partial update mode + + //Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false); + // 1.54 inch 200x200 - GxEPD2_154_M09 + // 2.9 inch 296x128 - GxEPD2_290_T5D + // 4.2 inch 300x400 - GxEPD2_420_M01 + //adafruitDisplay->nextPage(); + + #endif + // Put screen to sleep to save power (possibly not necessary because we already did poweroff inside of display) adafruitDisplay->hibernate(); DEBUG_MSG("done\n"); @@ -109,14 +147,33 @@ bool EInkDisplay::connect() pinMode(PIN_EINK_EN, OUTPUT); #endif - auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, - PIN_EINK_DC, - PIN_EINK_RES, - PIN_EINK_BUSY, SPI1); + +#if defined(TTGO_T_ECHO) +{ + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, SPI1); adafruitDisplay = new GxEPD2_BW(*lowLevel); adafruitDisplay->init(); adafruitDisplay->setRotation(3); +} +#elif defined(RAK4630) +{ + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + + adafruitDisplay = new GxEPD2_BW(*lowLevel); + + adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + + //RAK14000 2.13 inch b/w 250x122 does not support partial updates + adafruitDisplay->setRotation(3); + //For 1.54, 2.9 and 4.2 + //adafruitDisplay->setRotation(1); + + adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); +} +#endif + + //adafruitDisplay->setFullWindow(); //adafruitDisplay->fillScreen(UNCOLORED); //adafruitDisplay->drawCircle(100, 100, 20, COLORED); diff --git a/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini b/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini index 19874b93c..19855006b 100644 --- a/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini +++ b/variants/WisCore_RAK4631_E-Paper_Board/platformio.ini @@ -5,5 +5,5 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_E-Paper_Bo src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_E-Paper_Board> lib_deps = ${nrf52840_base.lib_deps} - https://github.com/meshtastic/GxEPD2.git + https://github.com/ZinggJM/GxEPD2.git debug_tool = jlink diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 495eaf91a..9714b0268 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -12,6 +12,6 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo src_filter = ${nrf52_base.src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} - https://github.com/geeksville/GxEPD2.git + https://github.com/meshtastic/GxEPD2 adafruit/Adafruit BusIO -;upload_protocol = fs \ No newline at end of file +;upload_protocol = fs From c3cee236bd66a5a2abee923287d9002236546305 Mon Sep 17 00:00:00 2001 From: Andre Kirchhoff Date: Fri, 25 Feb 2022 11:22:59 -0300 Subject: [PATCH 44/93] add m-flasher to README (#1241) --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7da82ea3..65aed143b 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,12 @@ Update Instructions +[Using Meshtastic Flasher](https://meshtastic.org/docs/getting-started/meshtastic-flasher) + +Manual Method + [For ESP32 devices click here](https://meshtastic.org/docs/getting-started/flashing-esp32) [For nRF52 devices click here](https://meshtastic.org/docs/getting-started/flashing-nrf52) -For developer information and specific building instructions, please see the [developer doccumentation](https://meshtastic.org/docs/developers) +For developer information and specific building instructions, please see the [developer documentation](https://meshtastic.org/docs/developers) From fc54f2f63dc448cdc1de5424493265f8494600a0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 25 Feb 2022 22:13:28 +0000 Subject: [PATCH 45/93] Temporary 1.2 legacy PR checks (#1243) * Temporary 1.2 legacy PR checks --- .github/workflows/main_matrix_1_2_temp.yml | 324 +++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100644 .github/workflows/main_matrix_1_2_temp.yml diff --git a/.github/workflows/main_matrix_1_2_temp.yml b/.github/workflows/main_matrix_1_2_temp.yml new file mode 100644 index 000000000..3b4f9dfc3 --- /dev/null +++ b/.github/workflows/main_matrix_1_2_temp.yml @@ -0,0 +1,324 @@ +name: Continuous Integration PR Checks (1.2 Legacy) +on: + # Note: This is different from "pull_request". Need to specify ref when doing checkouts. + pull_request_target: + branches: [ 1.2-legacy ] + paths-ignore: + - '**.md' + - '**.yml' + + workflow_dispatch: + +jobs: + + check: + strategy: + fail-fast: false + matrix: + include: + - board: rak11200 + - board: tlora-v2 + - board: tlora-v1 + - board: tlora_v1_3 + - board: tlora-v2-1-1.6 + - board: tbeam + - board: heltec-v1 + - board: heltec-v2.0 + - board: heltec-v2.1 + - board: tbeam0.7 + - board: meshtastic-diy-v1 + - board: rak4631_5005 + - board: rak4631_19003 + - board: t-echo + + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Install cppcheck + run: | + sudo apt-get install -y cppcheck + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Upgrade python tools and install platformio + run: | + python -m pip install --upgrade pip + pip install -U platformio + + - name: Upgrade platformio + run: | + pio upgrade + + - name: Check ${{ matrix.board }} + run: bin/check-all.sh ${{ matrix.board }} + + build-esp32: + strategy: + fail-fast: false + matrix: + include: + - board: rak11200 + - board: tlora-v2 + - board: tlora-v1 + - board: tlora_v1_3 + - board: tlora-v2-1-1.6 + - board: tbeam + - board: heltec-v1 + - board: heltec-v2.0 + - board: heltec-v2.1 + - board: tbeam0.7 + - board: meshtastic-diy-v1 + + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Upgrade python tools + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + - name: Upgrade platformio + run: | + pio upgrade + + - name: Pull web ui + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: "meshtastic/meshtastic-web" + file: "build.tar" + target: "build.tar" + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Unpack web ui + run: | + tar -xf build.tar -C data/static + rm build.tar + + - name: Build ESP32 + run: bin/build-esp32.sh ${{ matrix.board }} + + - name: Get release version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version + + - name: Store binaries as an artifact + uses: actions/upload-artifact@v2 + with: + name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip + path: | + release/*.bin + release/*.elf + retention-days: 90 + + build-nrf52: + strategy: + fail-fast: false + matrix: + include: + - board: rak4631_5005 + - board: rak4631_19003 + - board: t-echo + + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Upgrade python tools + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + - name: Upgrade platformio + run: | + pio upgrade + + - name: Build NRF52 + run: bin/build-nrf52.sh ${{ matrix.board }} + + - name: Get release version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version + + - name: Store binaries as an artifact + uses: actions/upload-artifact@v2 + with: + name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip + path: | + release/*.uf2 + release/*.elf + retention-days: 90 + + build-native: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Cache python libs + uses: actions/cache@v1 + id: cache-pip # needed in if test + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip + + - name: Upgrade python tools + run: | + python -m pip install --upgrade pip + pip install -U platformio meshtastic adafruit-nrfutil + + - name: Upgrade platformio + run: | + pio upgrade + + # We now run integration test before other build steps (to quickly see runtime failures) + - name: Build for native + run: platformio run -e native + - name: Integration test + run: | + .pio/build/native/program & + sleep 20 # 5 seconds was not enough + echo "Simulator started, launching python test..." + python3 -c 'from meshtastic.test import testSimulator; testSimulator()' + + - name: Build Native + run: bin/build-native.sh + + - name: Get release version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version + + - name: Store binaries as an artifact + uses: actions/upload-artifact@v2 + with: + name: firmware-native-${{ steps.version.outputs.version }}.zip + path: | + release/meshtasticd_linux_amd64 + release/device-*.sh + release/device-*.bat + retention-days: 90 + + gather-artifacts: + runs-on: ubuntu-latest + needs: [build-esp32, build-nrf52, build-native] + steps: + + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - uses: actions/download-artifact@v2 + with: + path: ./ + + - name: Get release version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version + + - name: Move files up + run: mv -b -t ./ ./*tbeam-*/spiffs*.bin ./*tbeam-*/system-info.bin ./**/firmware*.bin ./**/*.uf2 ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat + + - name: Repackage in single firmware zip + uses: actions/upload-artifact@v2 + with: + name: firmware-${{ steps.version.outputs.version }} + path: | + ./*.bin + ./*.uf2 + ./meshtasticd_linux_amd64 + ./device-*.sh + ./device-*.bat + retention-days: 90 + + - uses: actions/download-artifact@v2 + with: + name: firmware-${{ steps.version.outputs.version }} + path: ./output + + # For diagnostics + - name: Show artifacts + run: ls -lR + + - name: Zip firmware + run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output + + - name: Repackage in single elfs zip + uses: actions/upload-artifact@v2 + with: + name: debug-elfs-${{ steps.version.outputs.version }}.zip + path: ./*.elf + retention-days: 90 + + - name: Create request artifacts + if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }} + uses: gavv/pull-request-artifacts@v1.0.0 + with: + commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + artifacts-branch: artifacts + artifacts: ./firmware-${{ steps.version.outputs.version }}.zip From c97541d4fcf44b4656a26fd7f3c111163ccff865 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 25 Feb 2022 17:25:43 -0600 Subject: [PATCH 46/93] Turns out this workflow is needed on the target branch --- .github/workflows/main_matrix_1_2_temp.yml | 324 --------------------- 1 file changed, 324 deletions(-) delete mode 100644 .github/workflows/main_matrix_1_2_temp.yml diff --git a/.github/workflows/main_matrix_1_2_temp.yml b/.github/workflows/main_matrix_1_2_temp.yml deleted file mode 100644 index 3b4f9dfc3..000000000 --- a/.github/workflows/main_matrix_1_2_temp.yml +++ /dev/null @@ -1,324 +0,0 @@ -name: Continuous Integration PR Checks (1.2 Legacy) -on: - # Note: This is different from "pull_request". Need to specify ref when doing checkouts. - pull_request_target: - branches: [ 1.2-legacy ] - paths-ignore: - - '**.md' - - '**.yml' - - workflow_dispatch: - -jobs: - - check: - strategy: - fail-fast: false - matrix: - include: - - board: rak11200 - - board: tlora-v2 - - board: tlora-v1 - - board: tlora_v1_3 - - board: tlora-v2-1-1.6 - - board: tbeam - - board: heltec-v1 - - board: heltec-v2.0 - - board: heltec-v2.1 - - board: tbeam0.7 - - board: meshtastic-diy-v1 - - board: rak4631_5005 - - board: rak4631_19003 - - board: t-echo - - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Install cppcheck - run: | - sudo apt-get install -y cppcheck - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Cache python libs - uses: actions/cache@v1 - id: cache-pip # needed in if test - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - - - name: Upgrade python tools and install platformio - run: | - python -m pip install --upgrade pip - pip install -U platformio - - - name: Upgrade platformio - run: | - pio upgrade - - - name: Check ${{ matrix.board }} - run: bin/check-all.sh ${{ matrix.board }} - - build-esp32: - strategy: - fail-fast: false - matrix: - include: - - board: rak11200 - - board: tlora-v2 - - board: tlora-v1 - - board: tlora_v1_3 - - board: tlora-v2-1-1.6 - - board: tbeam - - board: heltec-v1 - - board: heltec-v2.0 - - board: heltec-v2.1 - - board: tbeam0.7 - - board: meshtastic-diy-v1 - - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Cache python libs - uses: actions/cache@v1 - id: cache-pip # needed in if test - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - - - name: Upgrade python tools - run: | - python -m pip install --upgrade pip - pip install -U platformio meshtastic adafruit-nrfutil - - - name: Upgrade platformio - run: | - pio upgrade - - - name: Pull web ui - uses: dsaltares/fetch-gh-release-asset@master - with: - repo: "meshtastic/meshtastic-web" - file: "build.tar" - target: "build.tar" - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Unpack web ui - run: | - tar -xf build.tar -C data/static - rm build.tar - - - name: Build ESP32 - run: bin/build-esp32.sh ${{ matrix.board }} - - - name: Get release version string - run: echo "::set-output name=version::$(./bin/buildinfo.py long)" - id: version - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v2 - with: - name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip - path: | - release/*.bin - release/*.elf - retention-days: 90 - - build-nrf52: - strategy: - fail-fast: false - matrix: - include: - - board: rak4631_5005 - - board: rak4631_19003 - - board: t-echo - - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Cache python libs - uses: actions/cache@v1 - id: cache-pip # needed in if test - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - - - name: Upgrade python tools - run: | - python -m pip install --upgrade pip - pip install -U platformio meshtastic adafruit-nrfutil - - - name: Upgrade platformio - run: | - pio upgrade - - - name: Build NRF52 - run: bin/build-nrf52.sh ${{ matrix.board }} - - - name: Get release version string - run: echo "::set-output name=version::$(./bin/buildinfo.py long)" - id: version - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v2 - with: - name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip - path: | - release/*.uf2 - release/*.elf - retention-days: 90 - - build-native: - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: 'recursive' - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Cache python libs - uses: actions/cache@v1 - id: cache-pip # needed in if test - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - - - name: Upgrade python tools - run: | - python -m pip install --upgrade pip - pip install -U platformio meshtastic adafruit-nrfutil - - - name: Upgrade platformio - run: | - pio upgrade - - # We now run integration test before other build steps (to quickly see runtime failures) - - name: Build for native - run: platformio run -e native - - name: Integration test - run: | - .pio/build/native/program & - sleep 20 # 5 seconds was not enough - echo "Simulator started, launching python test..." - python3 -c 'from meshtastic.test import testSimulator; testSimulator()' - - - name: Build Native - run: bin/build-native.sh - - - name: Get release version string - run: echo "::set-output name=version::$(./bin/buildinfo.py long)" - id: version - - - name: Store binaries as an artifact - uses: actions/upload-artifact@v2 - with: - name: firmware-native-${{ steps.version.outputs.version }}.zip - path: | - release/meshtasticd_linux_amd64 - release/device-*.sh - release/device-*.bat - retention-days: 90 - - gather-artifacts: - runs-on: ubuntu-latest - needs: [build-esp32, build-nrf52, build-native] - steps: - - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - - uses: actions/download-artifact@v2 - with: - path: ./ - - - name: Get release version string - run: echo "::set-output name=version::$(./bin/buildinfo.py long)" - id: version - - - name: Move files up - run: mv -b -t ./ ./*tbeam-*/spiffs*.bin ./*tbeam-*/system-info.bin ./**/firmware*.bin ./**/*.uf2 ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat - - - name: Repackage in single firmware zip - uses: actions/upload-artifact@v2 - with: - name: firmware-${{ steps.version.outputs.version }} - path: | - ./*.bin - ./*.uf2 - ./meshtasticd_linux_amd64 - ./device-*.sh - ./device-*.bat - retention-days: 90 - - - uses: actions/download-artifact@v2 - with: - name: firmware-${{ steps.version.outputs.version }} - path: ./output - - # For diagnostics - - name: Show artifacts - run: ls -lR - - - name: Zip firmware - run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output - - - name: Repackage in single elfs zip - uses: actions/upload-artifact@v2 - with: - name: debug-elfs-${{ steps.version.outputs.version }}.zip - path: ./*.elf - retention-days: 90 - - - name: Create request artifacts - if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }} - uses: gavv/pull-request-artifacts@v1.0.0 - with: - commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }} - repo-token: ${{ secrets.GITHUB_TOKEN }} - artifacts-branch: artifacts - artifacts: ./firmware-${{ steps.version.outputs.version }}.zip From f2a31cc67886c2e1feb2fec9671f20fde40a6c4a Mon Sep 17 00:00:00 2001 From: puzzled-pancake <78745145+puzzled-pancake@users.noreply.github.com> Date: Sun, 27 Feb 2022 17:01:25 +1300 Subject: [PATCH 47/93] Update RadioInterface.cpp Add NZ 866 --- src/mesh/RadioInterface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 6efba50f8..34162b693 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -78,6 +78,12 @@ const RegionInfo regions[] = { /* https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf */ + RDEF(NZ866, 864.0f, 868.0f, 100, 0, 0, true, false), + + /* + https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752 + https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf + */ RDEF(TH, 920.0f, 925.0f, 100, 0, 16, true, false), /* @@ -447,4 +453,4 @@ size_t RadioInterface::beginSending(MeshPacket *p) sendingPacket = p; return p->encrypted.size + sizeof(PacketHeader); -} \ No newline at end of file +} From 59ce0c7d093904136b36eb3c40c0279ee2ac26f7 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:18:32 -0800 Subject: [PATCH 48/93] Rename EnvironmentalMeasurementPlugin.cpp to Telemetry --- .../{EnvironmentalMeasurementPlugin.cpp => Telemetry} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/EnvironmentalMeasurement/{EnvironmentalMeasurementPlugin.cpp => Telemetry} (100%) diff --git a/src/plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.cpp b/src/plugins/EnvironmentalMeasurement/Telemetry similarity index 100% rename from src/plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.cpp rename to src/plugins/EnvironmentalMeasurement/Telemetry From ceccbd3ef237a0b077a2491e8733306e93c22b03 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:18:50 -0800 Subject: [PATCH 49/93] Rename Telemetry to Telemetry.cpp --- src/plugins/EnvironmentalMeasurement/{Telemetry => Telemetry.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/EnvironmentalMeasurement/{Telemetry => Telemetry.cpp} (100%) diff --git a/src/plugins/EnvironmentalMeasurement/Telemetry b/src/plugins/EnvironmentalMeasurement/Telemetry.cpp similarity index 100% rename from src/plugins/EnvironmentalMeasurement/Telemetry rename to src/plugins/EnvironmentalMeasurement/Telemetry.cpp From 529707489ac14f84a6cf8db27a400396b904805a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:19:14 -0800 Subject: [PATCH 50/93] Rename EnvironmentalMeasurementPlugin.h to Telemetry.h --- .../{EnvironmentalMeasurementPlugin.h => Telemetry.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/plugins/EnvironmentalMeasurement/{EnvironmentalMeasurementPlugin.h => Telemetry.h} (100%) diff --git a/src/plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h b/src/plugins/EnvironmentalMeasurement/Telemetry.h similarity index 100% rename from src/plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h rename to src/plugins/EnvironmentalMeasurement/Telemetry.h From a25beff241e1a8df4f16e7a0862499df1581f51b Mon Sep 17 00:00:00 2001 From: puzzled-pancake <78745145+puzzled-pancake@users.noreply.github.com> Date: Sun, 27 Feb 2022 17:29:25 +1300 Subject: [PATCH 51/93] Update RadioInterface.cpp --- src/mesh/RadioInterface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 34162b693..efe0794d6 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -75,14 +75,15 @@ const RegionInfo regions[] = { */ RDEF(IN, 865.0f, 867.0f, 100, 0, 30, true, false), - /* - https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf + /* + https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752 + https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf */ RDEF(NZ866, 864.0f, 868.0f, 100, 0, 0, true, false), - /* - https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752 - https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf + + /* + https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf */ RDEF(TH, 920.0f, 925.0f, 100, 0, 16, true, false), From f9bcddafefa5c812de2fb4d9881afccf9cf373be Mon Sep 17 00:00:00 2001 From: puzzled-pancake <78745145+puzzled-pancake@users.noreply.github.com> Date: Sun, 27 Feb 2022 17:30:11 +1300 Subject: [PATCH 52/93] Update RadioInterface.cpp --- src/mesh/RadioInterface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index efe0794d6..98b4cdb14 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -81,7 +81,6 @@ const RegionInfo regions[] = { */ RDEF(NZ866, 864.0f, 868.0f, 100, 0, 0, true, false), - /* https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf */ From a0f80c1a2aeea88a4ec38a5da3c5fc7fad7effef Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:31:05 -0800 Subject: [PATCH 53/93] Delete environmental_measurement.pb.c --- src/mesh/generated/environmental_measurement.pb.c | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/mesh/generated/environmental_measurement.pb.c diff --git a/src/mesh/generated/environmental_measurement.pb.c b/src/mesh/generated/environmental_measurement.pb.c deleted file mode 100644 index b55d14a0a..000000000 --- a/src/mesh/generated/environmental_measurement.pb.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.4 */ - -#include "environmental_measurement.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -PB_BIND(EnvironmentalMeasurement, EnvironmentalMeasurement, AUTO) - - - From 5bff62e428cc17ad6661e2964795a817f0bbed26 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:31:16 -0800 Subject: [PATCH 54/93] Delete environmental_measurement.pb.h --- .../generated/environmental_measurement.pb.h | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/mesh/generated/environmental_measurement.pb.h diff --git a/src/mesh/generated/environmental_measurement.pb.h b/src/mesh/generated/environmental_measurement.pb.h deleted file mode 100644 index aaaedf644..000000000 --- a/src/mesh/generated/environmental_measurement.pb.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.4 */ - -#ifndef PB_ENVIRONMENTAL_MEASUREMENT_PB_H_INCLUDED -#define PB_ENVIRONMENTAL_MEASUREMENT_PB_H_INCLUDED -#include - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Struct definitions */ -typedef struct _EnvironmentalMeasurement { - float temperature; - float relative_humidity; - float barometric_pressure; - float gas_resistance; - float voltage; - float current; -} EnvironmentalMeasurement; - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Initializer values for message structs */ -#define EnvironmentalMeasurement_init_default {0, 0, 0, 0, 0, 0} -#define EnvironmentalMeasurement_init_zero {0, 0, 0, 0, 0, 0} - -/* Field tags (for use in manual encoding/decoding) */ -#define EnvironmentalMeasurement_temperature_tag 1 -#define EnvironmentalMeasurement_relative_humidity_tag 2 -#define EnvironmentalMeasurement_barometric_pressure_tag 3 -#define EnvironmentalMeasurement_gas_resistance_tag 4 -#define EnvironmentalMeasurement_voltage_tag 5 -#define EnvironmentalMeasurement_current_tag 6 - -/* Struct field encoding specification for nanopb */ -#define EnvironmentalMeasurement_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, FLOAT, temperature, 1) \ -X(a, STATIC, SINGULAR, FLOAT, relative_humidity, 2) \ -X(a, STATIC, SINGULAR, FLOAT, barometric_pressure, 3) \ -X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ -X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ -X(a, STATIC, SINGULAR, FLOAT, current, 6) -#define EnvironmentalMeasurement_CALLBACK NULL -#define EnvironmentalMeasurement_DEFAULT NULL - -extern const pb_msgdesc_t EnvironmentalMeasurement_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define EnvironmentalMeasurement_fields &EnvironmentalMeasurement_msg - -/* Maximum encoded size of messages (where known) */ -#define EnvironmentalMeasurement_size 30 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif From ac43a1b1820eb789603fdd8af3a8f5e7ddffc919 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 20:52:22 -0800 Subject: [PATCH 55/93] Rename environmental measurement to telemetry --- .vscode/extensions.json | 19 +- src/mesh/NodeDB.cpp | 1 - src/mesh/NodeDB.h | 1 - src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/deviceonly.pb.h | 12 +- src/mesh/generated/mesh.pb.c | 3 - src/mesh/generated/mesh.pb.h | 37 +-- src/mesh/generated/portnums.pb.h | 4 +- src/mesh/generated/radioconfig.pb.h | 89 +++--- src/mesh/generated/telemetry.pb.c | 12 + src/mesh/generated/telemetry.pb.h | 62 ++++ .../Sensor/BME280Sensor.h | 15 - .../Sensor/BME680Sensor.h | 15 - .../Sensor/DHTSensor.cpp | 36 --- .../Sensor/DHTSensor.h | 15 - .../Sensor/DallasSensor.h | 17 - .../Sensor/EnvironmentalMeasurementSensor.h | 12 - .../Sensor/MCP9808Sensor.h | 15 - .../EnvironmentalMeasurement/Telemetry.cpp | 299 ------------------ src/plugins/Plugins.cpp | 4 +- .../Sensor/BME280Sensor.cpp | 10 +- src/plugins/Telemetry/Sensor/BME280Sensor.h | 15 + .../Sensor/BME680Sensor.cpp | 12 +- src/plugins/Telemetry/Sensor/BME680Sensor.h | 15 + src/plugins/Telemetry/Sensor/DHTSensor.cpp | 36 +++ src/plugins/Telemetry/Sensor/DHTSensor.h | 15 + .../Sensor/DallasSensor.cpp | 14 +- src/plugins/Telemetry/Sensor/DallasSensor.h | 17 + .../Sensor/MCP9808Sensor.cpp | 10 +- src/plugins/Telemetry/Sensor/MCP9808Sensor.h | 15 + .../Telemetry/Sensor/TelemetrySensor.h | 12 + src/plugins/Telemetry/Telemetry.cpp | 299 ++++++++++++++++++ .../Telemetry.h | 16 +- variants/portduino/platformio.ini | 4 +- 34 files changed, 603 insertions(+), 557 deletions(-) create mode 100644 src/mesh/generated/telemetry.pb.c create mode 100644 src/mesh/generated/telemetry.pb.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/EnvironmentalMeasurementSensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h delete mode 100644 src/plugins/EnvironmentalMeasurement/Telemetry.cpp rename src/plugins/{EnvironmentalMeasurement => Telemetry}/Sensor/BME280Sensor.cpp (67%) create mode 100644 src/plugins/Telemetry/Sensor/BME280Sensor.h rename src/plugins/{EnvironmentalMeasurement => Telemetry}/Sensor/BME680Sensor.cpp (72%) create mode 100644 src/plugins/Telemetry/Sensor/BME680Sensor.h create mode 100644 src/plugins/Telemetry/Sensor/DHTSensor.cpp create mode 100644 src/plugins/Telemetry/Sensor/DHTSensor.h rename src/plugins/{EnvironmentalMeasurement => Telemetry}/Sensor/DallasSensor.cpp (53%) create mode 100644 src/plugins/Telemetry/Sensor/DallasSensor.h rename src/plugins/{EnvironmentalMeasurement => Telemetry}/Sensor/MCP9808Sensor.cpp (65%) create mode 100644 src/plugins/Telemetry/Sensor/MCP9808Sensor.h create mode 100644 src/plugins/Telemetry/Sensor/TelemetrySensor.h create mode 100644 src/plugins/Telemetry/Telemetry.cpp rename src/plugins/{EnvironmentalMeasurement => Telemetry}/Telemetry.h (52%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 27bdd05a2..9a91518aa 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,11 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide", - "xaver.clang-format" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide", + "xaver.clang-format" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 9bdae9011..0587b9457 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -34,7 +34,6 @@ NodeDB nodeDB; // we have plenty of ram so statically alloc this tempbuf (for now) EXT_RAM_ATTR DeviceState devicestate; MyNodeInfo &myNodeInfo = devicestate.my_node; -GroupInfo &ourGroupInfo = devicestate.group_info; RadioConfig radioConfig; ChannelFile channelFile; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index f5937b3fb..86ab874e8 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -11,7 +11,6 @@ extern DeviceState devicestate; extern ChannelFile channelFile; extern MyNodeInfo &myNodeInfo; -extern GroupInfo &ourGroupInfo; extern RadioConfig radioConfig; extern User &owner; diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index c313f9f55..1a065f7f2 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 601 +#define AdminMessage_size 608 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index d384e7e57..c6d468adc 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -6,7 +6,6 @@ #include #include "channel.pb.h" #include "mesh.pb.h" -#include "radioconfig.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -27,8 +26,6 @@ typedef struct _DeviceState { NodeInfo node_db[32]; pb_size_t receive_queue_count; MeshPacket receive_queue[1]; - bool has_group_info; - GroupInfo group_info; bool has_rx_text_message; MeshPacket rx_text_message; uint32_t version; @@ -42,9 +39,9 @@ extern "C" { #endif /* Initializer values for message structs */ -#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, GroupInfo_init_default, false, MeshPacket_init_default, 0, 0, 0} +#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0} #define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}} -#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, GroupInfo_init_zero, false, MeshPacket_init_zero, 0, 0, 0} +#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0} #define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}} /* Field tags (for use in manual encoding/decoding) */ @@ -53,7 +50,6 @@ extern "C" { #define DeviceState_owner_tag 3 #define DeviceState_node_db_tag 4 #define DeviceState_receive_queue_tag 5 -#define DeviceState_group_info_tag 6 #define DeviceState_rx_text_message_tag 7 #define DeviceState_version_tag 8 #define DeviceState_no_save_tag 9 @@ -65,7 +61,6 @@ X(a, STATIC, OPTIONAL, MESSAGE, my_node, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, owner, 3) \ X(a, STATIC, REPEATED, MESSAGE, node_db, 4) \ X(a, STATIC, REPEATED, MESSAGE, receive_queue, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, group_info, 6) \ X(a, STATIC, OPTIONAL, MESSAGE, rx_text_message, 7) \ X(a, STATIC, SINGULAR, UINT32, version, 8) \ X(a, STATIC, SINGULAR, BOOL, no_save, 9) \ @@ -76,7 +71,6 @@ X(a, STATIC, SINGULAR, BOOL, did_gps_reset, 11) #define DeviceState_owner_MSGTYPE User #define DeviceState_node_db_MSGTYPE NodeInfo #define DeviceState_receive_queue_MSGTYPE MeshPacket -#define DeviceState_group_info_MSGTYPE GroupInfo #define DeviceState_rx_text_message_MSGTYPE MeshPacket #define ChannelFile_FIELDLIST(X, a) \ @@ -93,7 +87,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 10162 +#define DeviceState_size 9973 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c index 90eca5068..6846dc540 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/mesh.pb.c @@ -27,9 +27,6 @@ PB_BIND(MeshPacket, MeshPacket, 2) PB_BIND(NodeInfo, NodeInfo, AUTO) -PB_BIND(GroupInfo, GroupInfo, AUTO) - - PB_BIND(MyNodeInfo, MyNodeInfo, 2) diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index f04b3f426..8e98195ed 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -140,14 +140,8 @@ typedef struct _Data { uint32_t request_id; uint32_t reply_id; bool is_tapback; - uint8_t group_id; } Data; -typedef struct _GroupInfo { - pb_size_t group_count; - char group[10][17]; -} GroupInfo; - typedef struct _LogRecord { char message[64]; uint32_t time; @@ -275,7 +269,6 @@ typedef struct _FromRadio { uint32_t config_complete_id; bool rebooted; MeshPacket packet; - GroupInfo groups; }; } FromRadio; @@ -341,10 +334,9 @@ extern "C" { #define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_default {0, {RouteDiscovery_init_default}} -#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, 0} +#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} -#define GroupInfo_init_default {0, {"", "", "", "", "", "", "", "", "", ""}} #define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} @@ -354,10 +346,9 @@ extern "C" { #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}} -#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0, 0} +#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} -#define GroupInfo_init_zero {0, {"", "", "", "", "", "", "", "", "", ""}} #define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} @@ -373,8 +364,6 @@ extern "C" { #define Data_request_id_tag 6 #define Data_reply_id_tag 7 #define Data_is_tapback_tag 8 -#define Data_group_id_tag 9 -#define GroupInfo_group_tag 1 #define LogRecord_message_tag 1 #define LogRecord_time_tag 2 #define LogRecord_source_tag 3 @@ -460,7 +449,6 @@ extern "C" { #define FromRadio_config_complete_id_tag 8 #define FromRadio_rebooted_tag 9 #define FromRadio_packet_tag 11 -#define FromRadio_groups_tag 12 #define ToRadio_packet_tag 2 #define ToRadio_peer_info_tag 3 #define ToRadio_want_config_id_tag 100 @@ -530,8 +518,7 @@ X(a, STATIC, SINGULAR, FIXED32, dest, 4) \ X(a, STATIC, SINGULAR, FIXED32, source, 5) \ X(a, STATIC, SINGULAR, FIXED32, request_id, 6) \ X(a, STATIC, SINGULAR, FIXED32, reply_id, 7) \ -X(a, STATIC, SINGULAR, BOOL, is_tapback, 8) \ -X(a, STATIC, SINGULAR, UINT32, group_id, 9) +X(a, STATIC, SINGULAR, BOOL, is_tapback, 8) #define Data_CALLBACK NULL #define Data_DEFAULT NULL @@ -564,11 +551,6 @@ X(a, STATIC, SINGULAR, FLOAT, snr, 7) #define NodeInfo_user_MSGTYPE User #define NodeInfo_position_MSGTYPE Position -#define GroupInfo_FIELDLIST(X, a) \ -X(a, STATIC, REPEATED, STRING, group, 1) -#define GroupInfo_CALLBACK NULL -#define GroupInfo_DEFAULT NULL - #define MyNodeInfo_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \ X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \ @@ -605,15 +587,13 @@ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,node_info,node_info), 4) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,log_record,log_record), 7) \ X(a, STATIC, ONEOF, UINT32, (payloadVariant,config_complete_id,config_complete_id), 8) \ X(a, STATIC, ONEOF, BOOL, (payloadVariant,rebooted,rebooted), 9) \ -X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11) \ -X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,groups,groups), 12) +X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 11) #define FromRadio_CALLBACK NULL #define FromRadio_DEFAULT NULL #define FromRadio_payloadVariant_my_info_MSGTYPE MyNodeInfo #define FromRadio_payloadVariant_node_info_MSGTYPE NodeInfo #define FromRadio_payloadVariant_log_record_MSGTYPE LogRecord #define FromRadio_payloadVariant_packet_MSGTYPE MeshPacket -#define FromRadio_payloadVariant_groups_MSGTYPE GroupInfo #define ToRadio_FIELDLIST(X, a) \ X(a, STATIC, ONEOF, MESSAGE, (payloadVariant,packet,packet), 2) \ @@ -638,7 +618,6 @@ extern const pb_msgdesc_t Routing_msg; extern const pb_msgdesc_t Data_msg; extern const pb_msgdesc_t MeshPacket_msg; extern const pb_msgdesc_t NodeInfo_msg; -extern const pb_msgdesc_t GroupInfo_msg; extern const pb_msgdesc_t MyNodeInfo_msg; extern const pb_msgdesc_t LogRecord_msg; extern const pb_msgdesc_t FromRadio_msg; @@ -653,7 +632,6 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_fields &Data_msg #define MeshPacket_fields &MeshPacket_msg #define NodeInfo_fields &NodeInfo_msg -#define GroupInfo_fields &GroupInfo_msg #define MyNodeInfo_fields &MyNodeInfo_msg #define LogRecord_fields &LogRecord_msg #define FromRadio_fields &FromRadio_msg @@ -665,14 +643,13 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define User_size 97 #define RouteDiscovery_size 40 #define Routing_size 42 -#define Data_size 270 -#define MeshPacket_size 321 +#define Data_size 267 +#define MeshPacket_size 318 #define NodeInfo_size 271 -#define GroupInfo_size 180 #define MyNodeInfo_size 434 #define LogRecord_size 81 #define FromRadio_size 443 -#define ToRadio_size 324 +#define ToRadio_size 321 #define ToRadio_PeerInfo_size 8 #ifdef __cplusplus diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index 67b5df03d..9b70f80ce 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -20,11 +20,11 @@ typedef enum _PortNum { PortNum_ADMIN_APP = 6, PortNum_REPLY_APP = 32, PortNum_IP_TUNNEL_APP = 33, - PortNum_GROUP_APP = 34, + PortNum_ROUTER_APP = 34, PortNum_SERIAL_APP = 64, PortNum_STORE_FORWARD_APP = 65, PortNum_RANGE_TEST_APP = 66, - PortNum_ENVIRONMENTAL_MEASUREMENT_APP = 67, + PortNum_TELEMETRY_APP = 67, PortNum_ZPS_APP = 68, PortNum_PRIVATE_APP = 256, PortNum_ATAK_FORWARDER = 257, diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index af24b5184..869480331 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -92,17 +92,17 @@ typedef enum _InputEventChar { InputEventChar_KEY_CANCEL = 24 } InputEventChar; -typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType { - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 = 0, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280 = 5, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808 = 7, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3 = 8 -} RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType; +typedef enum _RadioConfig_UserPreferences_TelemetrySensorType { + RadioConfig_UserPreferences_TelemetrySensorType_DHT11 = 0, + RadioConfig_UserPreferences_TelemetrySensorType_DS18B20 = 1, + RadioConfig_UserPreferences_TelemetrySensorType_DHT12 = 2, + RadioConfig_UserPreferences_TelemetrySensorType_DHT21 = 3, + RadioConfig_UserPreferences_TelemetrySensorType_DHT22 = 4, + RadioConfig_UserPreferences_TelemetrySensorType_BME280 = 5, + RadioConfig_UserPreferences_TelemetrySensorType_BME680 = 6, + RadioConfig_UserPreferences_TelemetrySensorType_MCP9808 = 7, + RadioConfig_UserPreferences_TelemetrySensorType_SHTC3 = 8 +} RadioConfig_UserPreferences_TelemetrySensorType; /* Struct definitions */ typedef struct _RadioConfig_UserPreferences { @@ -158,14 +158,14 @@ typedef struct _RadioConfig_UserPreferences { uint32_t store_forward_plugin_records; uint32_t store_forward_plugin_history_return_max; uint32_t store_forward_plugin_history_return_window; - bool environmental_measurement_plugin_measurement_enabled; - bool environmental_measurement_plugin_screen_enabled; - uint32_t environmental_measurement_plugin_read_error_count_threshold; - uint32_t environmental_measurement_plugin_update_interval; - uint32_t environmental_measurement_plugin_recovery_interval; - bool environmental_measurement_plugin_display_farenheit; - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType environmental_measurement_plugin_sensor_type; - uint32_t environmental_measurement_plugin_sensor_pin; + bool telemetry_module_measurement_enabled; + bool telemetry_module_screen_enabled; + uint32_t telemetry_module_read_error_count_threshold; + uint32_t telemetry_module_update_interval; + uint32_t telemetry_module_recovery_interval; + bool telemetry_module_display_farenheit; + RadioConfig_UserPreferences_TelemetrySensorType telemetry_module_sensor_type; + uint32_t telemetry_module_sensor_pin; bool store_forward_plugin_enabled; bool store_forward_plugin_heartbeat; uint32_t position_flags; @@ -189,6 +189,7 @@ typedef struct _RadioConfig_UserPreferences { bool canned_message_plugin_send_bell; bool mqtt_encryption_enabled; float adc_multiplier_override; + uint32_t serialplugin_baud; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -226,9 +227,9 @@ typedef struct _RadioConfig { #define _InputEventChar_MAX InputEventChar_KEY_BACK #define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1)) -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_SHTC3+1)) +#define _RadioConfig_UserPreferences_TelemetrySensorType_MIN RadioConfig_UserPreferences_TelemetrySensorType_DHT11 +#define _RadioConfig_UserPreferences_TelemetrySensorType_MAX RadioConfig_UserPreferences_TelemetrySensorType_SHTC3 +#define _RadioConfig_UserPreferences_TelemetrySensorType_ARRAYSIZE ((RadioConfig_UserPreferences_TelemetrySensorType)(RadioConfig_UserPreferences_TelemetrySensorType_SHTC3+1)) #ifdef __cplusplus @@ -237,9 +238,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -293,14 +294,14 @@ extern "C" { #define RadioConfig_UserPreferences_store_forward_plugin_records_tag 137 #define RadioConfig_UserPreferences_store_forward_plugin_history_return_max_tag 138 #define RadioConfig_UserPreferences_store_forward_plugin_history_return_window_tag 139 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_measurement_enabled_tag 140 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_screen_enabled_tag 141 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_read_error_count_threshold_tag 142 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_update_interval_tag 143 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_recovery_interval_tag 144 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_display_farenheit_tag 145 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_sensor_type_tag 146 -#define RadioConfig_UserPreferences_environmental_measurement_plugin_sensor_pin_tag 147 +#define RadioConfig_UserPreferences_telemetry_module_measurement_enabled_tag 140 +#define RadioConfig_UserPreferences_telemetry_module_screen_enabled_tag 141 +#define RadioConfig_UserPreferences_telemetry_module_read_error_count_threshold_tag 142 +#define RadioConfig_UserPreferences_telemetry_module_update_interval_tag 143 +#define RadioConfig_UserPreferences_telemetry_module_recovery_interval_tag 144 +#define RadioConfig_UserPreferences_telemetry_module_display_farenheit_tag 145 +#define RadioConfig_UserPreferences_telemetry_module_sensor_type_tag 146 +#define RadioConfig_UserPreferences_telemetry_module_sensor_pin_tag 147 #define RadioConfig_UserPreferences_store_forward_plugin_enabled_tag 148 #define RadioConfig_UserPreferences_store_forward_plugin_heartbeat_tag 149 #define RadioConfig_UserPreferences_position_flags_tag 150 @@ -324,6 +325,7 @@ extern "C" { #define RadioConfig_UserPreferences_canned_message_plugin_send_bell_tag 173 #define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174 #define RadioConfig_UserPreferences_adc_multiplier_override_tag 175 +#define RadioConfig_UserPreferences_serialplugin_baud_tag 176 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -385,14 +387,14 @@ X(a, STATIC, SINGULAR, BOOL, range_test_plugin_save, 134) \ X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_records, 137) \ X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_history_return_max, 138) \ X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_history_return_window, 139) \ -X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_measurement_enabled, 140) \ -X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_screen_enabled, 141) \ -X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_read_error_count_threshold, 142) \ -X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_update_interval, 143) \ -X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_recovery_interval, 144) \ -X(a, STATIC, SINGULAR, BOOL, environmental_measurement_plugin_display_farenheit, 145) \ -X(a, STATIC, SINGULAR, UENUM, environmental_measurement_plugin_sensor_type, 146) \ -X(a, STATIC, SINGULAR, UINT32, environmental_measurement_plugin_sensor_pin, 147) \ +X(a, STATIC, SINGULAR, BOOL, telemetry_module_measurement_enabled, 140) \ +X(a, STATIC, SINGULAR, BOOL, telemetry_module_screen_enabled, 141) \ +X(a, STATIC, SINGULAR, UINT32, telemetry_module_read_error_count_threshold, 142) \ +X(a, STATIC, SINGULAR, UINT32, telemetry_module_update_interval, 143) \ +X(a, STATIC, SINGULAR, UINT32, telemetry_module_recovery_interval, 144) \ +X(a, STATIC, SINGULAR, BOOL, telemetry_module_display_farenheit, 145) \ +X(a, STATIC, SINGULAR, UENUM, telemetry_module_sensor_type, 146) \ +X(a, STATIC, SINGULAR, UINT32, telemetry_module_sensor_pin, 147) \ X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_enabled, 148) \ X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_heartbeat, 149) \ X(a, STATIC, SINGULAR, UINT32, position_flags, 150) \ @@ -415,7 +417,8 @@ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_enabled, 170) \ X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_source, 171) \ X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_send_bell, 173) \ X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \ -X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) +X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) \ +X(a, STATIC, SINGULAR, UINT32, serialplugin_baud, 176) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -427,8 +430,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 598 -#define RadioConfig_UserPreferences_size 595 +#define RadioConfig_size 605 +#define RadioConfig_UserPreferences_size 602 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/telemetry.pb.c b/src/mesh/generated/telemetry.pb.c new file mode 100644 index 000000000..25f04010a --- /dev/null +++ b/src/mesh/generated/telemetry.pb.c @@ -0,0 +1,12 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.4 */ + +#include "telemetry.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(Telemetry, Telemetry, AUTO) + + + diff --git a/src/mesh/generated/telemetry.pb.h b/src/mesh/generated/telemetry.pb.h new file mode 100644 index 000000000..6dbfec365 --- /dev/null +++ b/src/mesh/generated/telemetry.pb.h @@ -0,0 +1,62 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.4 */ + +#ifndef PB_TELEMETRY_PB_H_INCLUDED +#define PB_TELEMETRY_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _Telemetry { + float temperature; + float relative_humidity; + float barometric_pressure; + float gas_resistance; + float voltage; + float current; +} Telemetry; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define Telemetry_init_default {0, 0, 0, 0, 0, 0} +#define Telemetry_init_zero {0, 0, 0, 0, 0, 0} + +/* Field tags (for use in manual encoding/decoding) */ +#define Telemetry_temperature_tag 1 +#define Telemetry_relative_humidity_tag 2 +#define Telemetry_barometric_pressure_tag 3 +#define Telemetry_gas_resistance_tag 4 +#define Telemetry_voltage_tag 5 +#define Telemetry_current_tag 6 + +/* Struct field encoding specification for nanopb */ +#define Telemetry_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, FLOAT, temperature, 1) \ +X(a, STATIC, SINGULAR, FLOAT, relative_humidity, 2) \ +X(a, STATIC, SINGULAR, FLOAT, barometric_pressure, 3) \ +X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \ +X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \ +X(a, STATIC, SINGULAR, FLOAT, current, 6) +#define Telemetry_CALLBACK NULL +#define Telemetry_DEFAULT NULL + +extern const pb_msgdesc_t Telemetry_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define Telemetry_fields &Telemetry_msg + +/* Maximum encoded size of messages (where known) */ +#define Telemetry_size 30 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h deleted file mode 100644 index 8c667cd13..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "EnvironmentalMeasurementSensor.h" -#include - -#define BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class BME280Sensor : virtual public EnvironmentalMeasurementSensor { -private: - Adafruit_BME280 bme280; - -public: - BME280Sensor(); - virtual int32_t runOnce() override; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override; -}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h deleted file mode 100644 index 1cc0ee3da..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "EnvironmentalMeasurementSensor.h" -#include - -#define BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class BME680Sensor : virtual public EnvironmentalMeasurementSensor { -private: - Adafruit_BME680 bme680; - -public: - BME680Sensor(); - virtual int32_t runOnce() override; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override; -}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp b/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp deleted file mode 100644 index 85f498f29..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "configuration.h" -#include "MeshService.h" -#include "EnvironmentalMeasurementSensor.h" -#include "DHTSensor.h" -#include - -DHTSensor::DHTSensor() : EnvironmentalMeasurementSensor {} { -} - -int32_t DHTSensor::runOnce() { - if (RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 || - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12) { - dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11); - } - else { - dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22); - } - - dht->begin(); - dht->read(); - DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11/DHT12 on pin: %d\n", - radioConfig.preferences.environmental_measurement_plugin_sensor_pin); - - return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); -} - -bool DHTSensor::getMeasurement(EnvironmentalMeasurement *measurement) { - if (!dht->read(true)) { - DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n"); - return false; - } - measurement->relative_humidity = dht->readHumidity(); - measurement->temperature = dht->readTemperature(); - return true; -} \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h deleted file mode 100644 index d839fc99e..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/DHTSensor.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "EnvironmentalMeasurementSensor.h" -#include - -#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class DHTSensor : virtual public EnvironmentalMeasurementSensor { -private: - DHT *dht = NULL; - -public: - DHTSensor(); - virtual int32_t runOnce() override; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override; -}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h deleted file mode 100644 index ce602052f..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.h +++ /dev/null @@ -1,17 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "EnvironmentalMeasurementSensor.h" -#include -#include - -#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class DallasSensor : virtual public EnvironmentalMeasurementSensor { -private: - OneWire *oneWire = NULL; - DS18B20 *ds18b20 = NULL; - -public: - DallasSensor(); - virtual int32_t runOnce() override; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override; -}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/EnvironmentalMeasurementSensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/EnvironmentalMeasurementSensor.h deleted file mode 100644 index 37ba09670..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/EnvironmentalMeasurementSensor.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "../mesh/generated/environmental_measurement.pb.h" -#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class EnvironmentalMeasurementSensor { -protected: - EnvironmentalMeasurementSensor() { } - -public: - virtual int32_t runOnce() = 0; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) = 0; -}; diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h b/src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h deleted file mode 100644 index eb868e652..000000000 --- a/src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "../mesh/generated/environmental_measurement.pb.h" -#include "EnvironmentalMeasurementSensor.h" -#include - -#define MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 - -class MCP9808Sensor : virtual public EnvironmentalMeasurementSensor { -private: - Adafruit_MCP9808 mcp9808; - -public: - MCP9808Sensor(); - virtual int32_t runOnce() override; - virtual bool getMeasurement(EnvironmentalMeasurement *measurement) override; -}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Telemetry.cpp b/src/plugins/EnvironmentalMeasurement/Telemetry.cpp deleted file mode 100644 index 51b1501e6..000000000 --- a/src/plugins/EnvironmentalMeasurement/Telemetry.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "EnvironmentalMeasurementPlugin.h" -#include "../mesh/generated/environmental_measurement.pb.h" -#include "MeshService.h" -#include "NodeDB.h" -#include "RTC.h" -#include "Router.h" -#include "configuration.h" -#include "main.h" -#include -#include - -// Sensors -#include "Sensor/BME280Sensor.h" -#include "Sensor/BME680Sensor.h" -#include "Sensor/DHTSensor.h" -#include "Sensor/DallasSensor.h" -#include "Sensor/MCP9808Sensor.h" - -BME280Sensor bme280Sensor; -BME680Sensor bme680Sensor; -DHTSensor dhtSensor; -DallasSensor dallasSensor; -MCP9808Sensor mcp9808Sensor; - -#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 -#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true - -#ifdef HAS_EINK -// The screen is bigger so use bigger fonts -#define FONT_SMALL ArialMT_Plain_16 -#define FONT_MEDIUM ArialMT_Plain_24 -#define FONT_LARGE ArialMT_Plain_24 -#else -#define FONT_SMALL ArialMT_Plain_10 -#define FONT_MEDIUM ArialMT_Plain_16 -#define FONT_LARGE ArialMT_Plain_24 -#endif - -#define fontHeight(font) ((font)[1] + 1) // height is position 1 - -#define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL) -#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM) - - -int32_t EnvironmentalMeasurementPlugin::runOnce() -{ -#ifndef PORTDUINO - /* - Uncomment the preferences below if you want to use the plugin - without having to configure it from the PythonAPI or WebUI. - */ - /* - radioConfig.preferences.environmental_measurement_plugin_measurement_enabled = 1; - radioConfig.preferences.environmental_measurement_plugin_screen_enabled = 1; - radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold = 5; - radioConfig.preferences.environmental_measurement_plugin_update_interval = 600; - radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 60; - radioConfig.preferences.environmental_measurement_plugin_display_farenheit = false; - radioConfig.preferences.environmental_measurement_plugin_sensor_pin = 13; - - radioConfig.preferences.environmental_measurement_plugin_sensor_type = - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType:: - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280; - */ - - if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || - radioConfig.preferences.environmental_measurement_plugin_screen_enabled)) { - // If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it - return (INT32_MAX); - } - - if (firstTime) { - // This is the first time the OSThread library has called this function, so do some setup - firstTime = 0; - - if (radioConfig.preferences.environmental_measurement_plugin_measurement_enabled) { - DEBUG_MSG("EnvironmentalMeasurement: Initializing\n"); - // it's possible to have this plugin enabled, only for displaying values on the screen. - // therefore, we should only enable the sensor loop if measurement is also enabled - switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { - - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: - return dhtSensor.runOnce(); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: - return dallasSensor.runOnce(); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: - return bme280Sensor.runOnce(); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680: - return bme680Sensor.runOnce(); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808: - return mcp9808Sensor.runOnce(); - default: - DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); - return (INT32_MAX); - break; - } - } - return (INT32_MAX); - } else { - // if we somehow got to a second run of this plugin with measurement disabled, then just wait forever - if (!radioConfig.preferences.environmental_measurement_plugin_measurement_enabled) - return (INT32_MAX); - // this is not the first time OSThread library has called this function - // so just do what we intend to do on the interval - if (sensor_read_error_count > radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold) { - if (radioConfig.preferences.environmental_measurement_plugin_recovery_interval > 0) { - DEBUG_MSG("EnvironmentalMeasurement: TEMPORARILY DISABLED; The " - "environmental_measurement_plugin_read_error_count_threshold has been exceed: %d. Will retry reads in " - "%d seconds\n", - radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold, - radioConfig.preferences.environmental_measurement_plugin_recovery_interval); - sensor_read_error_count = 0; - return (radioConfig.preferences.environmental_measurement_plugin_recovery_interval * 1000); - } - DEBUG_MSG("EnvironmentalMeasurement: DISABLED; The environmental_measurement_plugin_read_error_count_threshold has " - "been exceed: %d. Reads will not be retried until after device reset\n", - radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold); - return (INT32_MAX); - - } else if (sensor_read_error_count > 0) { - DEBUG_MSG("EnvironmentalMeasurement: There have been %d sensor read failures. Will retry %d more times\n", - sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, - radioConfig.preferences.environmental_measurement_plugin_read_error_count_threshold - - sensor_read_error_count); - } - if (!sendOurEnvironmentalMeasurement()) { - // if we failed to read the sensor, then try again - // as soon as we can according to the maximum polling frequency - - switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: - return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: - return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680: - return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808: - return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); - default: - return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); - } - } - } - // The return of runOnce is an int32 representing the desired number of - // miliseconds until the function should be called again by the - // OSThread library. Multiply the preference value by 1000 to convert seconds to miliseconds - return (radioConfig.preferences.environmental_measurement_plugin_update_interval * 1000); -#endif -} - -bool EnvironmentalMeasurementPlugin::wantUIFrame() -{ - return radioConfig.preferences.environmental_measurement_plugin_screen_enabled; -} - -String GetSenderName(const MeshPacket &mp) -{ - String sender; - - auto node = nodeDB.getNode(getFrom(&mp)); - if (node) { - sender = node->user.short_name; - } else { - sender = "UNK"; - } - return sender; -} - -uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp) -{ - uint32_t now = getTime(); - - uint32_t last_seen = mp->rx_time; - int delta = (int)(now - last_seen); - if (delta < 0) // our clock must be slightly off still - not set from GPS yet - delta = 0; - - return delta; -} - -float EnvironmentalMeasurementPlugin::CelsiusToFarenheit(float c) -{ - return (c * 9) / 5 + 32; -} - -void EnvironmentalMeasurementPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -{ - display->setTextAlignment(TEXT_ALIGN_LEFT); - display->setFont(FONT_MEDIUM); - display->drawString(x, y, "Environment"); - if (lastMeasurementPacket == nullptr) { - display->setFont(FONT_SMALL); - display->drawString(x, y += fontHeight(FONT_MEDIUM), "No measurement"); - return; - } - - EnvironmentalMeasurement lastMeasurement; - - uint32_t agoSecs = GetTimeSinceMeshPacket(lastMeasurementPacket); - String lastSender = GetSenderName(*lastMeasurementPacket); - - auto &p = lastMeasurementPacket->decoded; - if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, EnvironmentalMeasurement_fields, &lastMeasurement)) { - display->setFont(FONT_SMALL); - display->drawString(x, y += fontHeight(FONT_MEDIUM), "Measurement Error"); - DEBUG_MSG("EnvironmentalMeasurement: unable to decode last packet"); - return; - } - - display->setFont(FONT_SMALL); - String last_temp = String(lastMeasurement.temperature, 0) + "°C"; - if (radioConfig.preferences.environmental_measurement_plugin_display_farenheit) { - last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F"; - } - display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + lastSender + "(" + String(agoSecs) + "s)"); - display->drawString(x, y += fontHeight(FONT_SMALL) - 2,"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.relative_humidity, 0) + "%"); - if (lastMeasurement.barometric_pressure != 0) - display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA"); -} - -bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p) -{ - if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || - radioConfig.preferences.environmental_measurement_plugin_screen_enabled)) { - // If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume - return false; - } - - String sender = GetSenderName(mp); - - DEBUG_MSG("EnvironmentalMeasurement: Received data from %s\n", sender); - DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p->relative_humidity); - DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p->temperature); - DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", p->barometric_pressure); - DEBUG_MSG("EnvironmentalMeasurement->gas_resistance: %f\n", p->gas_resistance); - - lastMeasurementPacket = packetPool.allocCopy(mp); - - return false; // Let others look at this message also if they want -} - -bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum dest, bool wantReplies) -{ - EnvironmentalMeasurement m; - m.barometric_pressure = 0; - m.gas_resistance = 0; - DEBUG_MSG("-----------------------------------------\n"); - - DEBUG_MSG("EnvironmentalMeasurement: Read data\n"); - - switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) { - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20: - if (!dallasSensor.getMeasurement(&m)) - sensor_read_error_count++; - break; - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: - if (!dhtSensor.getMeasurement(&m)) - sensor_read_error_count++; - break; - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: - bme280Sensor.getMeasurement(&m); - break; - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680: - bme680Sensor.getMeasurement(&m); - break; - case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MCP9808: - mcp9808Sensor.getMeasurement(&m); - break; - default: - DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); - return false; - } - - DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", m.relative_humidity); - DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", m.temperature); - DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", m.barometric_pressure); - DEBUG_MSG("EnvironmentalMeasurement->gas_resistance: %f\n", m.gas_resistance); - - sensor_read_error_count = 0; - - MeshPacket *p = allocDataProtobuf(m); - p->to = dest; - p->decoded.want_response = wantReplies; - - lastMeasurementPacket = packetPool.allocCopy(*p); - DEBUG_MSG("EnvironmentalMeasurement: Sending packet to mesh"); - service.sendToMesh(p); - return true; -} diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index c979ce9da..f2dc7a7df 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -11,7 +11,7 @@ #include "plugins/RoutingPlugin.h" #include "plugins/TextMessagePlugin.h" #ifndef PORTDUINO -#include "plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h" +#include "plugins/Telemetry/Telemetry.h" #endif #ifndef NO_ESP32 #include "plugins/esp32/RangeTestPlugin.h" @@ -39,7 +39,7 @@ void setupPlugins() rotaryEncoderInterruptImpl1->init(); cannedMessagePlugin = new CannedMessagePlugin(); #ifndef PORTDUINO - new EnvironmentalMeasurementPlugin(); + new TelemetryPlugin(); #endif #ifndef NO_ESP32 // Only run on an esp32 based device. diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.cpp b/src/plugins/Telemetry/Sensor/BME280Sensor.cpp similarity index 67% rename from src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.cpp rename to src/plugins/Telemetry/Sensor/BME280Sensor.cpp index 3ee9cf240..49c3564d2 100644 --- a/src/plugins/EnvironmentalMeasurement/Sensor/BME280Sensor.cpp +++ b/src/plugins/Telemetry/Sensor/BME280Sensor.cpp @@ -1,10 +1,10 @@ -#include "../mesh/generated/environmental_measurement.pb.h" +#include "../mesh/generated/telemetry.pb.h" #include "configuration.h" -#include "EnvironmentalMeasurementSensor.h" +#include "TelemetrySensor.h" #include "BME280Sensor.h" #include -BME280Sensor::BME280Sensor() : EnvironmentalMeasurementSensor {} { +BME280Sensor::BME280Sensor() : TelemetrySensor {} { } int32_t BME280Sensor::runOnce() { @@ -15,12 +15,12 @@ int32_t BME280Sensor::runOnce() { DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"); // TODO more verbose diagnostics } else { - DEBUG_MSG("EnvironmentalMeasurement: Opened BME280 on default i2c bus"); + DEBUG_MSG("Telemetry: Opened BME280 on default i2c bus"); } return BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } -bool BME280Sensor::getMeasurement(EnvironmentalMeasurement *measurement) { +bool BME280Sensor::getMeasurement(Telemetry *measurement) { measurement->temperature = bme280.readTemperature(); measurement->relative_humidity = bme280.readHumidity(); measurement->barometric_pressure = bme280.readPressure() / 100.0F; diff --git a/src/plugins/Telemetry/Sensor/BME280Sensor.h b/src/plugins/Telemetry/Sensor/BME280Sensor.h new file mode 100644 index 000000000..420c859c2 --- /dev/null +++ b/src/plugins/Telemetry/Sensor/BME280Sensor.h @@ -0,0 +1,15 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +#define BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class BME280Sensor : virtual public TelemetrySensor { +private: + Adafruit_BME280 bme280; + +public: + BME280Sensor(); + virtual int32_t runOnce() override; + virtual bool getMeasurement(Telemetry *measurement) override; +}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.cpp b/src/plugins/Telemetry/Sensor/BME680Sensor.cpp similarity index 72% rename from src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.cpp rename to src/plugins/Telemetry/Sensor/BME680Sensor.cpp index d761e3e7d..f4e09e8b0 100644 --- a/src/plugins/EnvironmentalMeasurement/Sensor/BME680Sensor.cpp +++ b/src/plugins/Telemetry/Sensor/BME680Sensor.cpp @@ -1,10 +1,10 @@ -#include "../mesh/generated/environmental_measurement.pb.h" +#include "../mesh/generated/telemetry.pb.h" #include "configuration.h" -#include "EnvironmentalMeasurementSensor.h" +#include "TelemetrySensor.h" #include "BME680Sensor.h" #include -BME680Sensor::BME680Sensor() : EnvironmentalMeasurementSensor {} { +BME680Sensor::BME680Sensor() : TelemetrySensor {} { } int32_t BME680Sensor::runOnce() { @@ -13,9 +13,9 @@ int32_t BME680Sensor::runOnce() { bme680Status = bme680.begin(0x76); if (!bme680Status) { DEBUG_MSG("Could not find a valid BME680 sensor, check wiring, address, sensor ID!"); - // TODO more verbose diagnosticsEnvironmentalMeasurementSensor + // TODO more verbose TelemetrySensor } else { - DEBUG_MSG("EnvironmentalMeasurement: Opened BME680 on default i2c bus"); + DEBUG_MSG("Telemetry: Opened BME680 on default i2c bus"); // Set up oversampling and filter initialization bme680.setTemperatureOversampling(BME680_OS_8X); bme680.setHumidityOversampling(BME680_OS_2X); @@ -26,7 +26,7 @@ int32_t BME680Sensor::runOnce() { return (BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } -bool BME680Sensor::getMeasurement(EnvironmentalMeasurement *measurement) { +bool BME680Sensor::getMeasurement(Telemetry *measurement) { measurement->temperature = bme680.readTemperature(); measurement->relative_humidity = bme680.readHumidity(); measurement->barometric_pressure = bme680.readPressure() / 100.0F; diff --git a/src/plugins/Telemetry/Sensor/BME680Sensor.h b/src/plugins/Telemetry/Sensor/BME680Sensor.h new file mode 100644 index 000000000..d502cd69c --- /dev/null +++ b/src/plugins/Telemetry/Sensor/BME680Sensor.h @@ -0,0 +1,15 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +#define BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class BME680Sensor : virtual public TelemetrySensor { +private: + Adafruit_BME680 bme680; + +public: + BME680Sensor(); + virtual int32_t runOnce() override; + virtual bool getMeasurement(Telemetry *measurement) override; +}; \ No newline at end of file diff --git a/src/plugins/Telemetry/Sensor/DHTSensor.cpp b/src/plugins/Telemetry/Sensor/DHTSensor.cpp new file mode 100644 index 000000000..bd9448245 --- /dev/null +++ b/src/plugins/Telemetry/Sensor/DHTSensor.cpp @@ -0,0 +1,36 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "configuration.h" +#include "MeshService.h" +#include "TelemetrySensor.h" +#include "DHTSensor.h" +#include + +DHTSensor::DHTSensor() : TelemetrySensor {} { +} + +int32_t DHTSensor::runOnce() { + if (RadioConfig_UserPreferences_TelemetrySensorType_DHT11 || + RadioConfig_UserPreferences_TelemetrySensorType_DHT12) { + dht = new DHT(radioConfig.preferences.telemetry_module_sensor_pin, DHT11); + } + else { + dht = new DHT(radioConfig.preferences.telemetry_module_sensor_pin, DHT22); + } + + dht->begin(); + dht->read(); + DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", + radioConfig.preferences.telemetry_module_sensor_pin); + + return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); +} + +bool DHTSensor::getMeasurement(Telemetry *measurement) { + if (!dht->read(true)) { + DEBUG_MSG("Telemetry: FAILED TO READ DATA\n"); + return false; + } + measurement->relative_humidity = dht->readHumidity(); + measurement->temperature = dht->readTemperature(); + return true; +} \ No newline at end of file diff --git a/src/plugins/Telemetry/Sensor/DHTSensor.h b/src/plugins/Telemetry/Sensor/DHTSensor.h new file mode 100644 index 000000000..4e062d1d1 --- /dev/null +++ b/src/plugins/Telemetry/Sensor/DHTSensor.h @@ -0,0 +1,15 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class DHTSensor : virtual public TelemetrySensor { +private: + DHT *dht = NULL; + +public: + DHTSensor(); + virtual int32_t runOnce() override; + virtual bool getMeasurement(Telemetry *measurement) override; +}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.cpp b/src/plugins/Telemetry/Sensor/DallasSensor.cpp similarity index 53% rename from src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.cpp rename to src/plugins/Telemetry/Sensor/DallasSensor.cpp index e82844ca1..16db31ad5 100644 --- a/src/plugins/EnvironmentalMeasurement/Sensor/DallasSensor.cpp +++ b/src/plugins/Telemetry/Sensor/DallasSensor.cpp @@ -1,26 +1,26 @@ -#include "../mesh/generated/environmental_measurement.pb.h" +#include "../mesh/generated/telemetry.pb.h" #include "configuration.h" #include "MeshService.h" -#include "EnvironmentalMeasurementSensor.h" +#include "TelemetrySensor.h" #include "DallasSensor.h" #include #include -DallasSensor::DallasSensor() : EnvironmentalMeasurementSensor {} { +DallasSensor::DallasSensor() : TelemetrySensor {} { } int32_t DallasSensor::runOnce() { - oneWire = new OneWire(radioConfig.preferences.environmental_measurement_plugin_sensor_pin); + oneWire = new OneWire(radioConfig.preferences.telemetry_module_sensor_pin); ds18b20 = new DS18B20(oneWire); ds18b20->begin(); ds18b20->setResolution(12); ds18b20->requestTemperatures(); - DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n", - radioConfig.preferences.environmental_measurement_plugin_sensor_pin); + DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", + radioConfig.preferences.telemetry_module_sensor_pin); return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } -bool DallasSensor::getMeasurement(EnvironmentalMeasurement *measurement) { +bool DallasSensor::getMeasurement(Telemetry *measurement) { if (ds18b20->isConversionComplete()) { measurement->temperature = ds18b20->getTempC(); measurement->relative_humidity = 0; diff --git a/src/plugins/Telemetry/Sensor/DallasSensor.h b/src/plugins/Telemetry/Sensor/DallasSensor.h new file mode 100644 index 000000000..c07825b09 --- /dev/null +++ b/src/plugins/Telemetry/Sensor/DallasSensor.h @@ -0,0 +1,17 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "TelemetrySensor.h" +#include +#include + +#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class DallasSensor : virtual public TelemetrySensor { +private: + OneWire *oneWire = NULL; + DS18B20 *ds18b20 = NULL; + +public: + DallasSensor(); + virtual int32_t runOnce() override; + virtual bool getMeasurement(Telemetry *measurement) override; +}; \ No newline at end of file diff --git a/src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.cpp b/src/plugins/Telemetry/Sensor/MCP9808Sensor.cpp similarity index 65% rename from src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.cpp rename to src/plugins/Telemetry/Sensor/MCP9808Sensor.cpp index 3634677e5..701f27f96 100644 --- a/src/plugins/EnvironmentalMeasurement/Sensor/MCP9808Sensor.cpp +++ b/src/plugins/Telemetry/Sensor/MCP9808Sensor.cpp @@ -1,10 +1,10 @@ -#include "../mesh/generated/environmental_measurement.pb.h" +#include "../mesh/generated/telemetry.pb.h" #include "configuration.h" -#include "EnvironmentalMeasurementSensor.h" +#include "TelemetrySensor.h" #include "MCP9808Sensor.h" #include -MCP9808Sensor::MCP9808Sensor() : EnvironmentalMeasurementSensor {} { +MCP9808Sensor::MCP9808Sensor() : TelemetrySensor {} { } int32_t MCP9808Sensor::runOnce() { @@ -14,14 +14,14 @@ int32_t MCP9808Sensor::runOnce() { if (!mcp9808Status) { DEBUG_MSG("Could not find a valid MCP9808 sensor, check wiring, address, sensor ID!"); } else { - DEBUG_MSG("EnvironmentalMeasurement: Opened MCP9808 on default i2c bus"); + DEBUG_MSG("TelemetrySensor: Opened MCP9808 on default i2c bus"); // Reduce resolution from 0.0625 degrees (precision) to 0.125 degrees (high). mcp9808.setResolution(2); } return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } -bool MCP9808Sensor::getMeasurement(EnvironmentalMeasurement *measurement) { +bool MCP9808Sensor::getMeasurement(Telemetry *measurement) { measurement->temperature = mcp9808.readTempC(); return true; diff --git a/src/plugins/Telemetry/Sensor/MCP9808Sensor.h b/src/plugins/Telemetry/Sensor/MCP9808Sensor.h new file mode 100644 index 000000000..f7190e95b --- /dev/null +++ b/src/plugins/Telemetry/Sensor/MCP9808Sensor.h @@ -0,0 +1,15 @@ +#include "../mesh/generated/telemetry.pb.h" +#include "TelemetrySensor.h" +#include + +#define MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class MCP9808Sensor : virtual public TelemetrySensor { +private: + Adafruit_MCP9808 mcp9808; + +public: + MCP9808Sensor(); + virtual int32_t runOnce() override; + virtual bool getMeasurement(Telemetry *measurement) override; +}; \ No newline at end of file diff --git a/src/plugins/Telemetry/Sensor/TelemetrySensor.h b/src/plugins/Telemetry/Sensor/TelemetrySensor.h new file mode 100644 index 000000000..327ef8aaa --- /dev/null +++ b/src/plugins/Telemetry/Sensor/TelemetrySensor.h @@ -0,0 +1,12 @@ +#pragma once +#include "../mesh/generated/telemetry.pb.h" +#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 + +class TelemetrySensor { +protected: + TelemetrySensor() { } + +public: + virtual int32_t runOnce() = 0; + virtual bool getMeasurement(Telemetry *measurement) = 0; +}; diff --git a/src/plugins/Telemetry/Telemetry.cpp b/src/plugins/Telemetry/Telemetry.cpp new file mode 100644 index 000000000..0aa0e8bb7 --- /dev/null +++ b/src/plugins/Telemetry/Telemetry.cpp @@ -0,0 +1,299 @@ +#include "Telemetry.h" +#include "../mesh/generated/telemetry.pb.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "configuration.h" +#include "main.h" +#include +#include + +// Sensors +#include "Sensor/BME280Sensor.h" +#include "Sensor/BME680Sensor.h" +#include "Sensor/DHTSensor.h" +#include "Sensor/DallasSensor.h" +#include "Sensor/MCP9808Sensor.h" + +BME280Sensor bme280Sensor; +BME680Sensor bme680Sensor; +DHTSensor dhtSensor; +DallasSensor dallasSensor; +MCP9808Sensor mcp9808Sensor; + +#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 +#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true + +#ifdef HAS_EINK +// The screen is bigger so use bigger fonts +#define FONT_SMALL ArialMT_Plain_16 +#define FONT_MEDIUM ArialMT_Plain_24 +#define FONT_LARGE ArialMT_Plain_24 +#else +#define FONT_SMALL ArialMT_Plain_10 +#define FONT_MEDIUM ArialMT_Plain_16 +#define FONT_LARGE ArialMT_Plain_24 +#endif + +#define fontHeight(font) ((font)[1] + 1) // height is position 1 + +#define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL) +#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM) + + +int32_t TelemetryPlugin::runOnce() +{ +#ifndef PORTDUINO + /* + Uncomment the preferences below if you want to use the plugin + without having to configure it from the PythonAPI or WebUI. + */ + /* + radioConfig.preferences.telemetry_module_measurement_enabled = 1; + radioConfig.preferences.telemetry_module_screen_enabled = 1; + radioConfig.preferences.telemetry_module_read_error_count_threshold = 5; + radioConfig.preferences.telemetry_module_update_interval = 600; + radioConfig.preferences.telemetry_module_recovery_interval = 60; + radioConfig.preferences.telemetry_module_display_farenheit = false; + radioConfig.preferences.telemetry_module_sensor_pin = 13; + + radioConfig.preferences.telemetry_module_sensor_type = + RadioConfig_UserPreferences_TelemetrySensorType:: + RadioConfig_UserPreferences_TelemetrySensorType_BME280; + */ + + if (!(radioConfig.preferences.telemetry_module_measurement_enabled || + radioConfig.preferences.telemetry_module_screen_enabled)) { + // If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it + return (INT32_MAX); + } + + if (firstTime) { + // This is the first time the OSThread library has called this function, so do some setup + firstTime = 0; + + if (radioConfig.preferences.telemetry_module_measurement_enabled) { + DEBUG_MSG("Telemetry: Initializing\n"); + // it's possible to have this plugin enabled, only for displaying values on the screen. + // therefore, we should only enable the sensor loop if measurement is also enabled + switch (radioConfig.preferences.telemetry_module_sensor_type) { + + case RadioConfig_UserPreferences_TelemetrySensorType_DHT11: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT12: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT21: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT22: + return dhtSensor.runOnce(); + case RadioConfig_UserPreferences_TelemetrySensorType_DS18B20: + return dallasSensor.runOnce(); + case RadioConfig_UserPreferences_TelemetrySensorType_BME280: + return bme280Sensor.runOnce(); + case RadioConfig_UserPreferences_TelemetrySensorType_BME680: + return bme680Sensor.runOnce(); + case RadioConfig_UserPreferences_TelemetrySensorType_MCP9808: + return mcp9808Sensor.runOnce(); + default: + DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling plugin"); + return (INT32_MAX); + break; + } + } + return (INT32_MAX); + } else { + // if we somehow got to a second run of this plugin with measurement disabled, then just wait forever + if (!radioConfig.preferences.telemetry_module_measurement_enabled) + return (INT32_MAX); + // this is not the first time OSThread library has called this function + // so just do what we intend to do on the interval + if (sensor_read_error_count > radioConfig.preferences.telemetry_module_read_error_count_threshold) { + if (radioConfig.preferences.telemetry_module_recovery_interval > 0) { + DEBUG_MSG("Telemetry: TEMPORARILY DISABLED; The " + "telemetry_module_read_error_count_threshold has been exceed: %d. Will retry reads in " + "%d seconds\n", + radioConfig.preferences.telemetry_module_read_error_count_threshold, + radioConfig.preferences.telemetry_module_recovery_interval); + sensor_read_error_count = 0; + return (radioConfig.preferences.telemetry_module_recovery_interval * 1000); + } + DEBUG_MSG("Telemetry: DISABLED; The telemetry_module_read_error_count_threshold has " + "been exceed: %d. Reads will not be retried until after device reset\n", + radioConfig.preferences.telemetry_module_read_error_count_threshold); + return (INT32_MAX); + + } else if (sensor_read_error_count > 0) { + DEBUG_MSG("Telemetry: There have been %d sensor read failures. Will retry %d more times\n", + sensor_read_error_count, sensor_read_error_count, sensor_read_error_count, + radioConfig.preferences.telemetry_module_read_error_count_threshold - + sensor_read_error_count); + } + if (!sendOurTelemetry()) { + // if we failed to read the sensor, then try again + // as soon as we can according to the maximum polling frequency + + switch (radioConfig.preferences.telemetry_module_sensor_type) { + case RadioConfig_UserPreferences_TelemetrySensorType_DHT11: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT12: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT21: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT22: + return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_TelemetrySensorType_DS18B20: + return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_TelemetrySensorType_BME280: + case RadioConfig_UserPreferences_TelemetrySensorType_BME680: + return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_TelemetrySensorType_MCP9808: + return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + default: + return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + } + } + } + // The return of runOnce is an int32 representing the desired number of + // miliseconds until the function should be called again by the + // OSThread library. Multiply the preference value by 1000 to convert seconds to miliseconds + return (radioConfig.preferences.telemetry_module_update_interval * 1000); +#endif +} + +bool TelemetryPlugin::wantUIFrame() +{ + return radioConfig.preferences.telemetry_module_screen_enabled; +} + +String GetSenderName(const MeshPacket &mp) +{ + String sender; + + auto node = nodeDB.getNode(getFrom(&mp)); + if (node) { + sender = node->user.short_name; + } else { + sender = "UNK"; + } + return sender; +} + +uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp) +{ + uint32_t now = getTime(); + + uint32_t last_seen = mp->rx_time; + int delta = (int)(now - last_seen); + if (delta < 0) // our clock must be slightly off still - not set from GPS yet + delta = 0; + + return delta; +} + +float TelemetryPlugin::CelsiusToFarenheit(float c) +{ + return (c * 9) / 5 + 32; +} + +void TelemetryPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +{ + display->setTextAlignment(TEXT_ALIGN_LEFT); + display->setFont(FONT_MEDIUM); + display->drawString(x, y, "Environment"); + if (lastMeasurementPacket == nullptr) { + display->setFont(FONT_SMALL); + display->drawString(x, y += fontHeight(FONT_MEDIUM), "No measurement"); + return; + } + + Telemetry lastMeasurement; + + uint32_t agoSecs = GetTimeSinceMeshPacket(lastMeasurementPacket); + String lastSender = GetSenderName(*lastMeasurementPacket); + + auto &p = lastMeasurementPacket->decoded; + if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, Telemetry_fields, &lastMeasurement)) { + display->setFont(FONT_SMALL); + display->drawString(x, y += fontHeight(FONT_MEDIUM), "Measurement Error"); + DEBUG_MSG("Telemetry: unable to decode last packet"); + return; + } + + display->setFont(FONT_SMALL); + String last_temp = String(lastMeasurement.temperature, 0) + "°C"; + if (radioConfig.preferences.telemetry_module_display_farenheit) { + last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F"; + } + display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + lastSender + "(" + String(agoSecs) + "s)"); + display->drawString(x, y += fontHeight(FONT_SMALL) - 2,"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.relative_humidity, 0) + "%"); + if (lastMeasurement.barometric_pressure != 0) + display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA"); +} + +bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) +{ + if (!(radioConfig.preferences.telemetry_module_measurement_enabled || + radioConfig.preferences.telemetry_module_screen_enabled)) { + // If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume + return false; + } + + String sender = GetSenderName(mp); + + DEBUG_MSG("Telemetry: Received data from %s\n", sender); + DEBUG_MSG("Telemetry->relative_humidity: %f\n", p->relative_humidity); + DEBUG_MSG("Telemetry->temperature: %f\n", p->temperature); + DEBUG_MSG("Telemetry->barometric_pressure: %f\n", p->barometric_pressure); + DEBUG_MSG("Telemetry->gas_resistance: %f\n", p->gas_resistance); + + lastMeasurementPacket = packetPool.allocCopy(mp); + + return false; // Let others look at this message also if they want +} + +bool TelemetryPlugin::sendOurTelemetry(NodeNum dest, bool wantReplies) +{ + Telemetry m; + m.barometric_pressure = 0; + m.gas_resistance = 0; + DEBUG_MSG("-----------------------------------------\n"); + + DEBUG_MSG("Telemetry: Read data\n"); + + switch (radioConfig.preferences.telemetry_module_sensor_type) { + case RadioConfig_UserPreferences_TelemetrySensorType_DS18B20: + if (!dallasSensor.getMeasurement(&m)) + sensor_read_error_count++; + break; + case RadioConfig_UserPreferences_TelemetrySensorType_DHT11: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT12: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT21: + case RadioConfig_UserPreferences_TelemetrySensorType_DHT22: + if (!dhtSensor.getMeasurement(&m)) + sensor_read_error_count++; + break; + case RadioConfig_UserPreferences_TelemetrySensorType_BME280: + bme280Sensor.getMeasurement(&m); + break; + case RadioConfig_UserPreferences_TelemetrySensorType_BME680: + bme680Sensor.getMeasurement(&m); + break; + case RadioConfig_UserPreferences_TelemetrySensorType_MCP9808: + mcp9808Sensor.getMeasurement(&m); + break; + default: + DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling plugin"); + return false; + } + + DEBUG_MSG("Telemetry->relative_humidity: %f\n", m.relative_humidity); + DEBUG_MSG("Telemetry->temperature: %f\n", m.temperature); + DEBUG_MSG("Telemetry->barometric_pressure: %f\n", m.barometric_pressure); + DEBUG_MSG("Telemetry->gas_resistance: %f\n", m.gas_resistance); + + sensor_read_error_count = 0; + + MeshPacket *p = allocDataProtobuf(m); + p->to = dest; + p->decoded.want_response = wantReplies; + + lastMeasurementPacket = packetPool.allocCopy(*p); + DEBUG_MSG("Telemetry: Sending packet to mesh"); + service.sendToMesh(p); + return true; +} diff --git a/src/plugins/EnvironmentalMeasurement/Telemetry.h b/src/plugins/Telemetry/Telemetry.h similarity index 52% rename from src/plugins/EnvironmentalMeasurement/Telemetry.h rename to src/plugins/Telemetry/Telemetry.h index 6066daf33..177ad0ce1 100644 --- a/src/plugins/EnvironmentalMeasurement/Telemetry.h +++ b/src/plugins/Telemetry/Telemetry.h @@ -1,15 +1,15 @@ #pragma once -#include "../mesh/generated/environmental_measurement.pb.h" +#include "../mesh/generated/telemetry.pb.h" #include "ProtobufPlugin.h" #include #include -class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public ProtobufPlugin +class TelemetryPlugin : private concurrency::OSThread, public ProtobufPlugin { public: - EnvironmentalMeasurementPlugin() - : concurrency::OSThread("EnvironmentalMeasurementPlugin"), - ProtobufPlugin("EnvironmentalMeasurement", PortNum_ENVIRONMENTAL_MEASUREMENT_APP, &EnvironmentalMeasurement_msg) + TelemetryPlugin() + : concurrency::OSThread("TelemetryPlugin"), + ProtobufPlugin("Telemetry", PortNum_TELEMETRY_APP, &Telemetry_msg) { lastMeasurementPacket = nullptr; } @@ -20,12 +20,12 @@ class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public Pro /** 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 handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p) override; + virtual bool handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) override; virtual int32_t runOnce() override; /** - * Send our EnvironmentalMeasurement into the mesh + * Send our Telemetry into the mesh */ - bool sendOurEnvironmentalMeasurement(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + bool sendOurTelemetry(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); private: float CelsiusToFarenheit(float c); diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index c4d561558..3bb12d48e 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -8,7 +8,7 @@ src_filter = - - - - - + - +<../variants/portduino> build_flags = ${arduino_base.build_flags} -O0 -I variants/portduino framework = arduino @@ -27,7 +27,7 @@ src_filter = - - - - - + - +<../variants/portduino> build_flags = ${arduino_base.build_flags} -O0 -lgpiod -I variants/portduino framework = arduino From 9b44d2e999c8e13b1f0c6aab5dd541324a9aea2f Mon Sep 17 00:00:00 2001 From: puzzled-pancake <78745145+puzzled-pancake@users.noreply.github.com> Date: Sun, 27 Feb 2022 18:12:27 +1300 Subject: [PATCH 56/93] Update RadioInterface.cpp --- src/mesh/RadioInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 98b4cdb14..d280377b4 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -79,7 +79,7 @@ const RegionInfo regions[] = { https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752 https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf */ - RDEF(NZ866, 864.0f, 868.0f, 100, 0, 0, true, false), + RDEF(NZ865, 864.0f, 868.0f, 100, 0, 0, true, false), /* https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf From c511fa2fe6906fb2b67754634e58427f6f3a7db3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 21:28:05 -0800 Subject: [PATCH 57/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 30e147a55..a367c4186 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 30e147a55ce27199cb638a1d82e0b88adc8f5385 +Subproject commit a367c418609100793ddb0f1fbdfbece9f10bb809 From 9050fe7f901016d80cf10642e3ca2d6a90a4430b Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 21:32:52 -0800 Subject: [PATCH 58/93] regen protos for NZ regioncode --- src/mesh/generated/radioconfig.pb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 869480331..1d4f59da4 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -22,7 +22,8 @@ typedef enum _RegionCode { RegionCode_TW = 8, RegionCode_RU = 9, RegionCode_IN = 10, - RegionCode_TH = 11 + RegionCode_NZ865 = 11, + RegionCode_TH = 12 } RegionCode; typedef enum _ChargeCurrent { From 218a208ab733415a9b9ae643cf88cbd6d8efbe94 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 26 Feb 2022 23:56:26 -0800 Subject: [PATCH 59/93] mv plugins/ to modules/ --- platformio.ini | 2 +- src/graphics/Screen.cpp | 2 +- src/main.cpp | 2 +- src/mesh/MeshPlugin.cpp | 2 +- src/mesh/MeshService.cpp | 4 +-- src/mesh/NodeDB.cpp | 2 +- src/mesh/Router.cpp | 2 +- src/{plugins => modules}/AdminPlugin.cpp | 0 src/{plugins => modules}/AdminPlugin.h | 0 .../CannedMessagePlugin.cpp | 0 .../CannedMessagePlugin.h | 0 .../ExternalNotificationPlugin.cpp | 2 +- .../ExternalNotificationPlugin.h | 0 src/{plugins => modules}/NodeInfoPlugin.cpp | 0 src/{plugins => modules}/NodeInfoPlugin.h | 0 src/{plugins => modules}/PluginDev.h | 0 src/{plugins => modules}/Plugins.cpp | 26 +++++++++---------- src/{plugins => modules}/Plugins.h | 0 src/{plugins => modules}/PositionPlugin.cpp | 0 src/{plugins => modules}/PositionPlugin.h | 0 .../RemoteHardwarePlugin.cpp | 0 .../RemoteHardwarePlugin.h | 0 src/{plugins => modules}/ReplyPlugin.cpp | 0 src/{plugins => modules}/ReplyPlugin.h | 0 src/{plugins => modules}/RoutingPlugin.cpp | 0 src/{plugins => modules}/RoutingPlugin.h | 0 .../Telemetry/Sensor/BME280Sensor.cpp | 0 .../Telemetry/Sensor/BME280Sensor.h | 0 .../Telemetry/Sensor/BME680Sensor.cpp | 0 .../Telemetry/Sensor/BME680Sensor.h | 0 .../Telemetry/Sensor/DHTSensor.cpp | 0 .../Telemetry/Sensor/DHTSensor.h | 0 .../Telemetry/Sensor/DallasSensor.cpp | 0 .../Telemetry/Sensor/DallasSensor.h | 0 .../Telemetry/Sensor/MCP9808Sensor.cpp | 0 .../Telemetry/Sensor/MCP9808Sensor.h | 0 .../Telemetry/Sensor/TelemetrySensor.h | 0 .../Telemetry/Telemetry.cpp | 0 .../Telemetry/Telemetry.h | 0 .../TextMessagePlugin.cpp | 0 src/{plugins => modules}/TextMessagePlugin.h | 0 .../esp32/RangeTestPlugin.cpp | 0 .../esp32/RangeTestPlugin.h | 0 .../esp32/SerialPlugin.cpp | 0 src/{plugins => modules}/esp32/SerialPlugin.h | 0 .../esp32/StoreForwardPlugin.cpp | 2 +- .../esp32/StoreForwardPlugin.h | 0 variants/portduino/platformio.ini | 8 +++--- 48 files changed, 27 insertions(+), 27 deletions(-) rename src/{plugins => modules}/AdminPlugin.cpp (100%) rename src/{plugins => modules}/AdminPlugin.h (100%) rename src/{plugins => modules}/CannedMessagePlugin.cpp (100%) rename src/{plugins => modules}/CannedMessagePlugin.h (100%) rename src/{plugins => modules}/ExternalNotificationPlugin.cpp (99%) rename src/{plugins => modules}/ExternalNotificationPlugin.h (100%) rename src/{plugins => modules}/NodeInfoPlugin.cpp (100%) rename src/{plugins => modules}/NodeInfoPlugin.h (100%) rename src/{plugins => modules}/PluginDev.h (100%) rename src/{plugins => modules}/Plugins.cpp (74%) rename src/{plugins => modules}/Plugins.h (100%) rename src/{plugins => modules}/PositionPlugin.cpp (100%) rename src/{plugins => modules}/PositionPlugin.h (100%) rename src/{plugins => modules}/RemoteHardwarePlugin.cpp (100%) rename src/{plugins => modules}/RemoteHardwarePlugin.h (100%) rename src/{plugins => modules}/ReplyPlugin.cpp (100%) rename src/{plugins => modules}/ReplyPlugin.h (100%) rename src/{plugins => modules}/RoutingPlugin.cpp (100%) rename src/{plugins => modules}/RoutingPlugin.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/BME280Sensor.cpp (100%) rename src/{plugins => modules}/Telemetry/Sensor/BME280Sensor.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/BME680Sensor.cpp (100%) rename src/{plugins => modules}/Telemetry/Sensor/BME680Sensor.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/DHTSensor.cpp (100%) rename src/{plugins => modules}/Telemetry/Sensor/DHTSensor.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/DallasSensor.cpp (100%) rename src/{plugins => modules}/Telemetry/Sensor/DallasSensor.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/MCP9808Sensor.cpp (100%) rename src/{plugins => modules}/Telemetry/Sensor/MCP9808Sensor.h (100%) rename src/{plugins => modules}/Telemetry/Sensor/TelemetrySensor.h (100%) rename src/{plugins => modules}/Telemetry/Telemetry.cpp (100%) rename src/{plugins => modules}/Telemetry/Telemetry.h (100%) rename src/{plugins => modules}/TextMessagePlugin.cpp (100%) rename src/{plugins => modules}/TextMessagePlugin.h (100%) rename src/{plugins => modules}/esp32/RangeTestPlugin.cpp (100%) rename src/{plugins => modules}/esp32/RangeTestPlugin.h (100%) rename src/{plugins => modules}/esp32/SerialPlugin.cpp (100%) rename src/{plugins => modules}/esp32/SerialPlugin.h (100%) rename src/{plugins => modules}/esp32/StoreForwardPlugin.cpp (99%) rename src/{plugins => modules}/esp32/StoreForwardPlugin.h (100%) diff --git a/platformio.ini b/platformio.ini index d45101430..f19c6a526 100644 --- a/platformio.ini +++ b/platformio.ini @@ -196,7 +196,7 @@ build_flags = -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.7 ;-DCFG_DEBUG=3 src_filter = - ${arduino_base.src_filter} - - - - - - + ${arduino_base.src_filter} - - - - - - lib_ignore = BluetoothOTA ; monitor_port = /dev/ttyACM1 diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index e679227f7..370bc9a54 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -32,7 +32,7 @@ along with this program. If not, see . #include "main.h" #include "mesh-pb-constants.h" #include "mesh/Channels.h" -#include "plugins/TextMessagePlugin.h" +#include "modules/TextMessagePlugin.h" #include "sleep.h" #include "target_specific.h" #include "utils.h" diff --git a/src/main.cpp b/src/main.cpp index 544040ac0..813309de2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ #include "concurrency/Periodic.h" #include "graphics/Screen.h" #include "main.h" -#include "plugins/Plugins.h" +#include "modules/Plugins.h" #include "sleep.h" #include "target_specific.h" #include diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 180e1ebfd..b2261a471 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -3,7 +3,7 @@ #include "Channels.h" #include "MeshService.h" #include "NodeDB.h" -#include "plugins/RoutingPlugin.h" +#include "modules/RoutingPlugin.h" #include std::vector *MeshPlugin::plugins; diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index bbc75e38b..151c4e2de 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -12,8 +12,8 @@ #include "RTC.h" #include "main.h" #include "mesh-pb-constants.h" -#include "plugins/NodeInfoPlugin.h" -#include "plugins/PositionPlugin.h" +#include "modules/NodeInfoPlugin.h" +#include "modules/PositionPlugin.h" #include "power.h" /* diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 0587b9457..fd7203f7d 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -19,7 +19,7 @@ #ifndef NO_ESP32 #include "mesh/http/WiFiAPClient.h" -#include "plugins/esp32/StoreForwardPlugin.h" +#include "modules/esp32/StoreForwardPlugin.h" #include #include #endif diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 64e0a4795..0917ec65f 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -6,7 +6,7 @@ #include "RTC.h" #include "main.h" #include "mesh-pb-constants.h" -#include "plugins/RoutingPlugin.h" +#include "modules/RoutingPlugin.h" #if defined(HAS_WIFI) || defined(PORTDUINO) #include "mqtt/MQTT.h" diff --git a/src/plugins/AdminPlugin.cpp b/src/modules/AdminPlugin.cpp similarity index 100% rename from src/plugins/AdminPlugin.cpp rename to src/modules/AdminPlugin.cpp diff --git a/src/plugins/AdminPlugin.h b/src/modules/AdminPlugin.h similarity index 100% rename from src/plugins/AdminPlugin.h rename to src/modules/AdminPlugin.h diff --git a/src/plugins/CannedMessagePlugin.cpp b/src/modules/CannedMessagePlugin.cpp similarity index 100% rename from src/plugins/CannedMessagePlugin.cpp rename to src/modules/CannedMessagePlugin.cpp diff --git a/src/plugins/CannedMessagePlugin.h b/src/modules/CannedMessagePlugin.h similarity index 100% rename from src/plugins/CannedMessagePlugin.h rename to src/modules/CannedMessagePlugin.h diff --git a/src/plugins/ExternalNotificationPlugin.cpp b/src/modules/ExternalNotificationPlugin.cpp similarity index 99% rename from src/plugins/ExternalNotificationPlugin.cpp rename to src/modules/ExternalNotificationPlugin.cpp index 122c77be8..bea9a7e06 100644 --- a/src/plugins/ExternalNotificationPlugin.cpp +++ b/src/modules/ExternalNotificationPlugin.cpp @@ -11,7 +11,7 @@ /* Documentation: - https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/plugins/ExternalNotificationPlugin.md + https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/modules/ExternalNotificationPlugin.md This plugin supports: https://github.com/meshtastic/Meshtastic-device/issues/654 diff --git a/src/plugins/ExternalNotificationPlugin.h b/src/modules/ExternalNotificationPlugin.h similarity index 100% rename from src/plugins/ExternalNotificationPlugin.h rename to src/modules/ExternalNotificationPlugin.h diff --git a/src/plugins/NodeInfoPlugin.cpp b/src/modules/NodeInfoPlugin.cpp similarity index 100% rename from src/plugins/NodeInfoPlugin.cpp rename to src/modules/NodeInfoPlugin.cpp diff --git a/src/plugins/NodeInfoPlugin.h b/src/modules/NodeInfoPlugin.h similarity index 100% rename from src/plugins/NodeInfoPlugin.h rename to src/modules/NodeInfoPlugin.h diff --git a/src/plugins/PluginDev.h b/src/modules/PluginDev.h similarity index 100% rename from src/plugins/PluginDev.h rename to src/modules/PluginDev.h diff --git a/src/plugins/Plugins.cpp b/src/modules/Plugins.cpp similarity index 74% rename from src/plugins/Plugins.cpp rename to src/modules/Plugins.cpp index f2dc7a7df..8b543265d 100644 --- a/src/plugins/Plugins.cpp +++ b/src/modules/Plugins.cpp @@ -1,22 +1,22 @@ #include "configuration.h" #include "input/InputBroker.h" #include "input/RotaryEncoderInterruptImpl1.h" -#include "plugins/AdminPlugin.h" -#include "plugins/CannedMessagePlugin.h" -#include "plugins/ExternalNotificationPlugin.h" -#include "plugins/NodeInfoPlugin.h" -#include "plugins/PositionPlugin.h" -#include "plugins/RemoteHardwarePlugin.h" -#include "plugins/ReplyPlugin.h" -#include "plugins/RoutingPlugin.h" -#include "plugins/TextMessagePlugin.h" +#include "modules/AdminPlugin.h" +#include "modules/CannedMessagePlugin.h" +#include "modules/ExternalNotificationPlugin.h" +#include "modules/NodeInfoPlugin.h" +#include "modules/PositionPlugin.h" +#include "modules/RemoteHardwarePlugin.h" +#include "modules/ReplyPlugin.h" +#include "modules/RoutingPlugin.h" +#include "modules/TextMessagePlugin.h" #ifndef PORTDUINO -#include "plugins/Telemetry/Telemetry.h" +#include "modules/Telemetry/Telemetry.h" #endif #ifndef NO_ESP32 -#include "plugins/esp32/RangeTestPlugin.h" -#include "plugins/esp32/SerialPlugin.h" -#include "plugins/esp32/StoreForwardPlugin.h" +#include "modules/esp32/RangeTestPlugin.h" +#include "modules/esp32/SerialPlugin.h" +#include "modules/esp32/StoreForwardPlugin.h" #endif /** diff --git a/src/plugins/Plugins.h b/src/modules/Plugins.h similarity index 100% rename from src/plugins/Plugins.h rename to src/modules/Plugins.h diff --git a/src/plugins/PositionPlugin.cpp b/src/modules/PositionPlugin.cpp similarity index 100% rename from src/plugins/PositionPlugin.cpp rename to src/modules/PositionPlugin.cpp diff --git a/src/plugins/PositionPlugin.h b/src/modules/PositionPlugin.h similarity index 100% rename from src/plugins/PositionPlugin.h rename to src/modules/PositionPlugin.h diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/modules/RemoteHardwarePlugin.cpp similarity index 100% rename from src/plugins/RemoteHardwarePlugin.cpp rename to src/modules/RemoteHardwarePlugin.cpp diff --git a/src/plugins/RemoteHardwarePlugin.h b/src/modules/RemoteHardwarePlugin.h similarity index 100% rename from src/plugins/RemoteHardwarePlugin.h rename to src/modules/RemoteHardwarePlugin.h diff --git a/src/plugins/ReplyPlugin.cpp b/src/modules/ReplyPlugin.cpp similarity index 100% rename from src/plugins/ReplyPlugin.cpp rename to src/modules/ReplyPlugin.cpp diff --git a/src/plugins/ReplyPlugin.h b/src/modules/ReplyPlugin.h similarity index 100% rename from src/plugins/ReplyPlugin.h rename to src/modules/ReplyPlugin.h diff --git a/src/plugins/RoutingPlugin.cpp b/src/modules/RoutingPlugin.cpp similarity index 100% rename from src/plugins/RoutingPlugin.cpp rename to src/modules/RoutingPlugin.cpp diff --git a/src/plugins/RoutingPlugin.h b/src/modules/RoutingPlugin.h similarity index 100% rename from src/plugins/RoutingPlugin.h rename to src/modules/RoutingPlugin.h diff --git a/src/plugins/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp similarity index 100% rename from src/plugins/Telemetry/Sensor/BME280Sensor.cpp rename to src/modules/Telemetry/Sensor/BME280Sensor.cpp diff --git a/src/plugins/Telemetry/Sensor/BME280Sensor.h b/src/modules/Telemetry/Sensor/BME280Sensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/BME280Sensor.h rename to src/modules/Telemetry/Sensor/BME280Sensor.h diff --git a/src/plugins/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp similarity index 100% rename from src/plugins/Telemetry/Sensor/BME680Sensor.cpp rename to src/modules/Telemetry/Sensor/BME680Sensor.cpp diff --git a/src/plugins/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/BME680Sensor.h rename to src/modules/Telemetry/Sensor/BME680Sensor.h diff --git a/src/plugins/Telemetry/Sensor/DHTSensor.cpp b/src/modules/Telemetry/Sensor/DHTSensor.cpp similarity index 100% rename from src/plugins/Telemetry/Sensor/DHTSensor.cpp rename to src/modules/Telemetry/Sensor/DHTSensor.cpp diff --git a/src/plugins/Telemetry/Sensor/DHTSensor.h b/src/modules/Telemetry/Sensor/DHTSensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/DHTSensor.h rename to src/modules/Telemetry/Sensor/DHTSensor.h diff --git a/src/plugins/Telemetry/Sensor/DallasSensor.cpp b/src/modules/Telemetry/Sensor/DallasSensor.cpp similarity index 100% rename from src/plugins/Telemetry/Sensor/DallasSensor.cpp rename to src/modules/Telemetry/Sensor/DallasSensor.cpp diff --git a/src/plugins/Telemetry/Sensor/DallasSensor.h b/src/modules/Telemetry/Sensor/DallasSensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/DallasSensor.h rename to src/modules/Telemetry/Sensor/DallasSensor.h diff --git a/src/plugins/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp similarity index 100% rename from src/plugins/Telemetry/Sensor/MCP9808Sensor.cpp rename to src/modules/Telemetry/Sensor/MCP9808Sensor.cpp diff --git a/src/plugins/Telemetry/Sensor/MCP9808Sensor.h b/src/modules/Telemetry/Sensor/MCP9808Sensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/MCP9808Sensor.h rename to src/modules/Telemetry/Sensor/MCP9808Sensor.h diff --git a/src/plugins/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h similarity index 100% rename from src/plugins/Telemetry/Sensor/TelemetrySensor.h rename to src/modules/Telemetry/Sensor/TelemetrySensor.h diff --git a/src/plugins/Telemetry/Telemetry.cpp b/src/modules/Telemetry/Telemetry.cpp similarity index 100% rename from src/plugins/Telemetry/Telemetry.cpp rename to src/modules/Telemetry/Telemetry.cpp diff --git a/src/plugins/Telemetry/Telemetry.h b/src/modules/Telemetry/Telemetry.h similarity index 100% rename from src/plugins/Telemetry/Telemetry.h rename to src/modules/Telemetry/Telemetry.h diff --git a/src/plugins/TextMessagePlugin.cpp b/src/modules/TextMessagePlugin.cpp similarity index 100% rename from src/plugins/TextMessagePlugin.cpp rename to src/modules/TextMessagePlugin.cpp diff --git a/src/plugins/TextMessagePlugin.h b/src/modules/TextMessagePlugin.h similarity index 100% rename from src/plugins/TextMessagePlugin.h rename to src/modules/TextMessagePlugin.h diff --git a/src/plugins/esp32/RangeTestPlugin.cpp b/src/modules/esp32/RangeTestPlugin.cpp similarity index 100% rename from src/plugins/esp32/RangeTestPlugin.cpp rename to src/modules/esp32/RangeTestPlugin.cpp diff --git a/src/plugins/esp32/RangeTestPlugin.h b/src/modules/esp32/RangeTestPlugin.h similarity index 100% rename from src/plugins/esp32/RangeTestPlugin.h rename to src/modules/esp32/RangeTestPlugin.h diff --git a/src/plugins/esp32/SerialPlugin.cpp b/src/modules/esp32/SerialPlugin.cpp similarity index 100% rename from src/plugins/esp32/SerialPlugin.cpp rename to src/modules/esp32/SerialPlugin.cpp diff --git a/src/plugins/esp32/SerialPlugin.h b/src/modules/esp32/SerialPlugin.h similarity index 100% rename from src/plugins/esp32/SerialPlugin.h rename to src/modules/esp32/SerialPlugin.h diff --git a/src/plugins/esp32/StoreForwardPlugin.cpp b/src/modules/esp32/StoreForwardPlugin.cpp similarity index 99% rename from src/plugins/esp32/StoreForwardPlugin.cpp rename to src/modules/esp32/StoreForwardPlugin.cpp index f556359f2..7a05b9ab1 100644 --- a/src/plugins/esp32/StoreForwardPlugin.cpp +++ b/src/modules/esp32/StoreForwardPlugin.cpp @@ -7,7 +7,7 @@ #include "configuration.h" #include "mesh-pb-constants.h" #include "mesh/generated/storeforward.pb.h" -#include "plugins/PluginDev.h" +#include "modules/PluginDev.h" #include #include #include diff --git a/src/plugins/esp32/StoreForwardPlugin.h b/src/modules/esp32/StoreForwardPlugin.h similarity index 100% rename from src/plugins/esp32/StoreForwardPlugin.h rename to src/modules/esp32/StoreForwardPlugin.h diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 3bb12d48e..dd37c3bc9 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -7,8 +7,8 @@ src_filter = - - - - - - - + - + - +<../variants/portduino> build_flags = ${arduino_base.build_flags} -O0 -I variants/portduino framework = arduino @@ -26,8 +26,8 @@ src_filter = - - - - - - - + - + - +<../variants/portduino> build_flags = ${arduino_base.build_flags} -O0 -lgpiod -I variants/portduino framework = arduino From 86e767eec261b85c3c6e227077b563a3cc9a0de1 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 00:18:35 -0800 Subject: [PATCH 60/93] Update filenames from plugins to modules --- src/graphics/Screen.cpp | 2 +- src/main.cpp | 2 +- src/mesh/MeshPlugin.cpp | 2 +- src/mesh/MeshService.cpp | 4 ++-- src/mesh/Router.cpp | 2 +- .../{AdminPlugin.cpp => AdminModule.cpp} | 2 +- src/modules/{AdminPlugin.h => AdminModule.h} | 0 ...ssagePlugin.cpp => CannedMessageModule.cpp} | 2 +- ...edMessagePlugin.h => CannedMessageModule.h} | 0 ...ugin.cpp => ExternalNotificationModule.cpp} | 4 ++-- ...onPlugin.h => ExternalNotificationModule.h} | 0 src/modules/{PluginDev.h => ModuleDev.h} | 0 src/modules/{Plugins.cpp => Modules.cpp} | 18 +++++++++--------- src/modules/{Plugins.h => Modules.h} | 0 .../{NodeInfoPlugin.cpp => NodeInfoModule.cpp} | 2 +- .../{NodeInfoPlugin.h => NodeInfoModule.h} | 0 .../{PositionPlugin.cpp => PositionModule.cpp} | 2 +- .../{PositionPlugin.h => PositionModule.h} | 0 ...warePlugin.cpp => RemoteHardwareModule.cpp} | 2 +- ...HardwarePlugin.h => RemoteHardwareModule.h} | 0 .../{ReplyPlugin.cpp => ReplyModule.cpp} | 2 +- src/modules/{ReplyPlugin.h => ReplyModule.h} | 0 .../{RoutingPlugin.cpp => RoutingModule.cpp} | 2 +- .../{RoutingPlugin.h => RoutingModule.h} | 0 ...MessagePlugin.cpp => TextMessageModule.cpp} | 2 +- ...TextMessagePlugin.h => TextMessageModule.h} | 0 src/modules/esp32/StoreForwardPlugin.cpp | 2 +- 27 files changed, 26 insertions(+), 26 deletions(-) rename src/modules/{AdminPlugin.cpp => AdminModule.cpp} (99%) rename src/modules/{AdminPlugin.h => AdminModule.h} (100%) rename src/modules/{CannedMessagePlugin.cpp => CannedMessageModule.cpp} (99%) rename src/modules/{CannedMessagePlugin.h => CannedMessageModule.h} (100%) rename src/modules/{ExternalNotificationPlugin.cpp => ExternalNotificationModule.cpp} (98%) rename src/modules/{ExternalNotificationPlugin.h => ExternalNotificationModule.h} (100%) rename src/modules/{PluginDev.h => ModuleDev.h} (100%) rename src/modules/{Plugins.cpp => Modules.cpp} (82%) rename src/modules/{Plugins.h => Modules.h} (100%) rename src/modules/{NodeInfoPlugin.cpp => NodeInfoModule.cpp} (98%) rename src/modules/{NodeInfoPlugin.h => NodeInfoModule.h} (100%) rename src/modules/{PositionPlugin.cpp => PositionModule.cpp} (99%) rename src/modules/{PositionPlugin.h => PositionModule.h} (100%) rename src/modules/{RemoteHardwarePlugin.cpp => RemoteHardwareModule.cpp} (99%) rename src/modules/{RemoteHardwarePlugin.h => RemoteHardwareModule.h} (100%) rename src/modules/{ReplyPlugin.cpp => ReplyModule.cpp} (96%) rename src/modules/{ReplyPlugin.h => ReplyModule.h} (100%) rename src/modules/{RoutingPlugin.cpp => RoutingModule.cpp} (98%) rename src/modules/{RoutingPlugin.h => RoutingModule.h} (100%) rename src/modules/{TextMessagePlugin.cpp => TextMessageModule.cpp} (95%) rename src/modules/{TextMessagePlugin.h => TextMessageModule.h} (100%) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 370bc9a54..ede88e41c 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -32,7 +32,7 @@ along with this program. If not, see . #include "main.h" #include "mesh-pb-constants.h" #include "mesh/Channels.h" -#include "modules/TextMessagePlugin.h" +#include "modules/TextMessageModule.h" #include "sleep.h" #include "target_specific.h" #include "utils.h" diff --git a/src/main.cpp b/src/main.cpp index 813309de2..68c21c502 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ #include "concurrency/Periodic.h" #include "graphics/Screen.h" #include "main.h" -#include "modules/Plugins.h" +#include "modules/Modules.h" #include "sleep.h" #include "target_specific.h" #include diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index b2261a471..323f56363 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -3,7 +3,7 @@ #include "Channels.h" #include "MeshService.h" #include "NodeDB.h" -#include "modules/RoutingPlugin.h" +#include "modules/RoutingModule.h" #include std::vector *MeshPlugin::plugins; diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 151c4e2de..d9de5f52d 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -12,8 +12,8 @@ #include "RTC.h" #include "main.h" #include "mesh-pb-constants.h" -#include "modules/NodeInfoPlugin.h" -#include "modules/PositionPlugin.h" +#include "modules/NodeInfoModule.h" +#include "modules/PositionModule.h" #include "power.h" /* diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 0917ec65f..6fac3739f 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -6,7 +6,7 @@ #include "RTC.h" #include "main.h" #include "mesh-pb-constants.h" -#include "modules/RoutingPlugin.h" +#include "modules/RoutingModule.h" #if defined(HAS_WIFI) || defined(PORTDUINO) #include "mqtt/MQTT.h" diff --git a/src/modules/AdminPlugin.cpp b/src/modules/AdminModule.cpp similarity index 99% rename from src/modules/AdminPlugin.cpp rename to src/modules/AdminModule.cpp index 2f1893a87..5123a93c8 100644 --- a/src/modules/AdminPlugin.cpp +++ b/src/modules/AdminModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "AdminPlugin.h" +#include "AdminModule.h" #include "Channels.h" #include "MeshService.h" #include "NodeDB.h" diff --git a/src/modules/AdminPlugin.h b/src/modules/AdminModule.h similarity index 100% rename from src/modules/AdminPlugin.h rename to src/modules/AdminModule.h diff --git a/src/modules/CannedMessagePlugin.cpp b/src/modules/CannedMessageModule.cpp similarity index 99% rename from src/modules/CannedMessagePlugin.cpp rename to src/modules/CannedMessageModule.cpp index a6b9a23f4..0d2a15715 100644 --- a/src/modules/CannedMessagePlugin.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "CannedMessagePlugin.h" +#include "CannedMessageModule.h" #include "MeshService.h" #include "FSCommon.h" #include "mesh/generated/cannedmessages.pb.h" diff --git a/src/modules/CannedMessagePlugin.h b/src/modules/CannedMessageModule.h similarity index 100% rename from src/modules/CannedMessagePlugin.h rename to src/modules/CannedMessageModule.h diff --git a/src/modules/ExternalNotificationPlugin.cpp b/src/modules/ExternalNotificationModule.cpp similarity index 98% rename from src/modules/ExternalNotificationPlugin.cpp rename to src/modules/ExternalNotificationModule.cpp index bea9a7e06..59827e6f8 100644 --- a/src/modules/ExternalNotificationPlugin.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "ExternalNotificationPlugin.h" +#include "ExternalNotificationModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" @@ -11,7 +11,7 @@ /* Documentation: - https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/modules/ExternalNotificationPlugin.md + https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/modules/ExternalNotificationModule.md This plugin supports: https://github.com/meshtastic/Meshtastic-device/issues/654 diff --git a/src/modules/ExternalNotificationPlugin.h b/src/modules/ExternalNotificationModule.h similarity index 100% rename from src/modules/ExternalNotificationPlugin.h rename to src/modules/ExternalNotificationModule.h diff --git a/src/modules/PluginDev.h b/src/modules/ModuleDev.h similarity index 100% rename from src/modules/PluginDev.h rename to src/modules/ModuleDev.h diff --git a/src/modules/Plugins.cpp b/src/modules/Modules.cpp similarity index 82% rename from src/modules/Plugins.cpp rename to src/modules/Modules.cpp index 8b543265d..915ac0d4f 100644 --- a/src/modules/Plugins.cpp +++ b/src/modules/Modules.cpp @@ -1,15 +1,15 @@ #include "configuration.h" #include "input/InputBroker.h" #include "input/RotaryEncoderInterruptImpl1.h" -#include "modules/AdminPlugin.h" -#include "modules/CannedMessagePlugin.h" -#include "modules/ExternalNotificationPlugin.h" -#include "modules/NodeInfoPlugin.h" -#include "modules/PositionPlugin.h" -#include "modules/RemoteHardwarePlugin.h" -#include "modules/ReplyPlugin.h" -#include "modules/RoutingPlugin.h" -#include "modules/TextMessagePlugin.h" +#include "modules/AdminModule.h" +#include "modules/CannedMessageModule.h" +#include "modules/ExternalNotificationModule.h" +#include "modules/NodeInfoModule.h" +#include "modules/PositionModule.h" +#include "modules/RemoteHardwareModule.h" +#include "modules/ReplyModule.h" +#include "modules/RoutingModule.h" +#include "modules/TextMessageModule.h" #ifndef PORTDUINO #include "modules/Telemetry/Telemetry.h" #endif diff --git a/src/modules/Plugins.h b/src/modules/Modules.h similarity index 100% rename from src/modules/Plugins.h rename to src/modules/Modules.h diff --git a/src/modules/NodeInfoPlugin.cpp b/src/modules/NodeInfoModule.cpp similarity index 98% rename from src/modules/NodeInfoPlugin.cpp rename to src/modules/NodeInfoModule.cpp index 51303ac57..83056d268 100644 --- a/src/modules/NodeInfoPlugin.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "NodeInfoPlugin.h" +#include "NodeInfoModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" diff --git a/src/modules/NodeInfoPlugin.h b/src/modules/NodeInfoModule.h similarity index 100% rename from src/modules/NodeInfoPlugin.h rename to src/modules/NodeInfoModule.h diff --git a/src/modules/PositionPlugin.cpp b/src/modules/PositionModule.cpp similarity index 99% rename from src/modules/PositionPlugin.cpp rename to src/modules/PositionModule.cpp index 3f1355cbe..0f52d1865 100644 --- a/src/modules/PositionPlugin.cpp +++ b/src/modules/PositionModule.cpp @@ -1,4 +1,4 @@ -#include "PositionPlugin.h" +#include "PositionModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" diff --git a/src/modules/PositionPlugin.h b/src/modules/PositionModule.h similarity index 100% rename from src/modules/PositionPlugin.h rename to src/modules/PositionModule.h diff --git a/src/modules/RemoteHardwarePlugin.cpp b/src/modules/RemoteHardwareModule.cpp similarity index 99% rename from src/modules/RemoteHardwarePlugin.cpp rename to src/modules/RemoteHardwareModule.cpp index 9da7ae218..1068e9cca 100644 --- a/src/modules/RemoteHardwarePlugin.cpp +++ b/src/modules/RemoteHardwareModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "RemoteHardwarePlugin.h" +#include "RemoteHardwareModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" diff --git a/src/modules/RemoteHardwarePlugin.h b/src/modules/RemoteHardwareModule.h similarity index 100% rename from src/modules/RemoteHardwarePlugin.h rename to src/modules/RemoteHardwareModule.h diff --git a/src/modules/ReplyPlugin.cpp b/src/modules/ReplyModule.cpp similarity index 96% rename from src/modules/ReplyPlugin.cpp rename to src/modules/ReplyModule.cpp index b0aa08673..d6f5dd10d 100644 --- a/src/modules/ReplyPlugin.cpp +++ b/src/modules/ReplyModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "ReplyPlugin.h" +#include "ReplyModule.h" #include "MeshService.h" #include "main.h" diff --git a/src/modules/ReplyPlugin.h b/src/modules/ReplyModule.h similarity index 100% rename from src/modules/ReplyPlugin.h rename to src/modules/ReplyModule.h diff --git a/src/modules/RoutingPlugin.cpp b/src/modules/RoutingModule.cpp similarity index 98% rename from src/modules/RoutingPlugin.cpp rename to src/modules/RoutingModule.cpp index 82b0403fe..e762a8a03 100644 --- a/src/modules/RoutingPlugin.cpp +++ b/src/modules/RoutingModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "RoutingPlugin.h" +#include "RoutingModule.h" #include "MeshService.h" #include "NodeDB.h" #include "Router.h" diff --git a/src/modules/RoutingPlugin.h b/src/modules/RoutingModule.h similarity index 100% rename from src/modules/RoutingPlugin.h rename to src/modules/RoutingModule.h diff --git a/src/modules/TextMessagePlugin.cpp b/src/modules/TextMessageModule.cpp similarity index 95% rename from src/modules/TextMessagePlugin.cpp rename to src/modules/TextMessageModule.cpp index c2b1f08b2..bd6aea770 100644 --- a/src/modules/TextMessagePlugin.cpp +++ b/src/modules/TextMessageModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "TextMessagePlugin.h" +#include "TextMessageModule.h" #include "NodeDB.h" #include "PowerFSM.h" diff --git a/src/modules/TextMessagePlugin.h b/src/modules/TextMessageModule.h similarity index 100% rename from src/modules/TextMessagePlugin.h rename to src/modules/TextMessageModule.h diff --git a/src/modules/esp32/StoreForwardPlugin.cpp b/src/modules/esp32/StoreForwardPlugin.cpp index 7a05b9ab1..f789d5948 100644 --- a/src/modules/esp32/StoreForwardPlugin.cpp +++ b/src/modules/esp32/StoreForwardPlugin.cpp @@ -7,7 +7,7 @@ #include "configuration.h" #include "mesh-pb-constants.h" #include "mesh/generated/storeforward.pb.h" -#include "modules/PluginDev.h" +#include "modules/ModuleDev.h" #include #include #include From 3a04a0ee7af30c0b796a0ebb44d24ecd1eba705c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 00:29:05 -0800 Subject: [PATCH 61/93] "plugin(s)" renamed to "module(s)" in comments and debug --- geeksville-private/TODO.md | 18 ++++++------- src/graphics/Screen.cpp | 16 ++++++------ src/main.cpp | 2 +- src/mesh/MeshPlugin.cpp | 22 ++++++++-------- src/mesh/MeshPlugin.h | 30 +++++++++++----------- src/mesh/ProtobufPlugin.h | 6 ++--- src/mesh/Router.cpp | 2 +- src/mesh/Router.h | 2 +- src/mesh/SinglePortPlugin.h | 2 +- src/modules/CannedMessageModule.cpp | 4 +-- src/modules/ExternalNotificationModule.cpp | 4 +-- src/modules/ModuleDev.h | 2 +- src/modules/Modules.cpp | 6 ++--- src/modules/Modules.h | 2 +- src/modules/NodeInfoModule.h | 2 +- src/modules/PositionModule.h | 2 +- src/modules/RemoteHardwareModule.h | 2 +- src/modules/ReplyModule.h | 4 +-- src/modules/RoutingModule.cpp | 2 +- src/modules/RoutingModule.h | 2 +- src/modules/Telemetry/Telemetry.cpp | 14 +++++----- src/modules/esp32/RangeTestPlugin.cpp | 2 +- src/modules/esp32/SerialPlugin.cpp | 6 ++--- src/modules/esp32/StoreForwardPlugin.cpp | 2 +- 24 files changed, 78 insertions(+), 78 deletions(-) diff --git a/geeksville-private/TODO.md b/geeksville-private/TODO.md index 7059ddbe2..5d9dfa7a1 100644 --- a/geeksville-private/TODO.md +++ b/geeksville-private/TODO.md @@ -63,7 +63,7 @@ You probably don't care about this section - skip to the next one. ## Multichannel support -* DONE cleanup the external notification and serial plugins +* DONE cleanup the external notification and serial modules * non ack version of stress test fails sometimes! * tx fault test has a bug #734 - * turn off fault 8: https://github.com/meshtastic/Meshtastic-device/issues/734 * DONE move device types into an enum in nodeinfo @@ -79,13 +79,13 @@ You probably don't care about this section - skip to the next one. * DONE set mynodeinfo.max_channels * DONE set mynodeinfo.num_bands (formerly num_channels) * DONE fix sniffing of non Routing packets -* DONE enable remote setttings access by moving settings operations into a regular plugin (move settings ops out of PhoneAPI) +* DONE enable remote setttings access by moving settings operations into a regular module (move settings ops out of PhoneAPI) * DONE move portnum up? * DONE remove region specific builds from the firmware * DONE test single channel without python * DONE Use "default" for name if name is empty * DONE fix python data packet receiving (nothing showing in log?) -* DONE implement 'get channels' Admin plugin operation +* DONE implement 'get channels' Admin module operation * DONE use get-channels from python * DONE use get channels & get settings from android * DONE use set-channel from python @@ -98,7 +98,7 @@ You probably don't care about this section - skip to the next one. * DONE fix setch-fast in python tool * age out pendingrequests in the python API * DONE stress test channel download from python, sometimes it seems like we don't get all replies, bug was due to simultaneous android connection -* DONE combine acks and responses in a single message if possible (do routing plugin LAST and drop ACK if someone else has already replied) +* DONE combine acks and responses in a single message if possible (do routing module LAST and drop ACK if someone else has already replied) * DONE don't send packets we received from the phone BACK TOWARDS THE PHONE (possibly use fromnode 0 for packets the phone sends?) * DONE fix 1.1.50 android debug panel display * DONE test android channel setting @@ -118,7 +118,7 @@ You probably don't care about this section - skip to the next one. * use single byte 'well known' channel names for admin, gpio, etc... * use presence of gpio channel to enable gpio ops, same for serial etc... * DONE restrict gpio & serial & settings operations to the admin channel (unless local to the current node) -* DONE add channel restrictions for plugins (and restrict routing plugin to the "control" channel) +* DONE add channel restrictions for modules (and restrict routing module to the "control" channel) * stress test multi channel * DONE investigate @mc-hamster report of heap corruption * DONE use set-user from android @@ -134,7 +134,7 @@ You probably don't care about this section - skip to the next one. * allow chaning packets in single transmission - to increase airtime efficiency and amortize packet overhead * DONE move most parts of meshpacket into the Data packet, so that we can chain multiple Data for sending when they all have a common destination and key. * when selecting a MeshPacket for transmit, scan the TX queue for any Data packets we can merge together as a WirePayload. In the low level send/rx code expand that into multiple MeshPackets as needed (thus 'hiding' from MeshPacket that over the wire we send multiple datapackets -* DONE confirm we are still calling the plugins for messages inbound from the phone (or generated locally) +* DONE confirm we are still calling the modules for messages inbound from the phone (or generated locally) * DONE confirm we are still multi hop routing flood broadcasts * DONE confirm we are still doing resends on unicast reliable packets * add history to routed packets: https://meshtastic.discourse.group/t/packet-source-tracking/2764/2 @@ -142,7 +142,7 @@ You probably don't care about this section - skip to the next one. * DONE move acks into routing * DONE make all subpackets different versions of data * DONE move routing control into a data packet -* have phoneapi done via plugin (will allow multiple simultaneous API clients - stop disabling BLE while using phone API) +* have phoneapi done via module (will allow multiple simultaneous API clients - stop disabling BLE while using phone API) * use reference counting and dynamic sizing for meshpackets. - use https://docs.microsoft.com/en-us/cpp/cpp/how-to-create-and-use-shared-ptr-instances?view=msvc-160 (already used in arduino) * let multiple PhoneAPI endpoints work at once * allow multiple simultaneous bluetooth connections (create the bluetooth phoneapi instance dynamically based on client id) @@ -182,12 +182,12 @@ For app cleanup: * DONE require a recent python api to talk to these new device loads * DONE require a recent android app to talk to these new device loads * DONE fix handleIncomingPosition -* DONE move want_replies handling into plugins +* DONE move want_replies handling into modules * DONE on android for received positions handle either old or new positions / user messages * DONE on android side send old or new positions as needed / user messages * DONE test python side handle new position/user messages * DONE make a gpio example. --gpiowrb 4 1, --gpiord 0x444, --gpiowatch 0x3ff -* DONE fix position sending to use new plugin +* DONE fix position sending to use new module * DONE Add SinglePortNumPlugin - as the new most useful baseclass * DONE move positions into regular data packets (use new app framework) * DONE move user info into regular data packets (use new app framework) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index ede88e41c..5ac3cca4f 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -67,8 +67,8 @@ uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, // Threshold values for the GPS lock accuracy bar display uint32_t dopThresholds[5] = {2000, 1000, 500, 200, 100}; -// At some point, we're going to ask all of the plugins if they would like to display a screen frame -// we'll need to hold onto pointers for the plugins that can draw a frame. +// At some point, we're going to ask all of the modules if they would like to display a screen frame +// we'll need to hold onto pointers for the modules that can draw a frame. std::vector pluginFrames; // Stores the last 4 of our hardware ID, to make finding the device for pairing easier @@ -189,7 +189,7 @@ static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int // frame, then we want this to be `0` plugin_frame = state->transitionFrameTarget; } else { - // otherwise, just display the plugin frame that's aligned with the current frame + // otherwise, just display the module frame that's aligned with the current frame plugin_frame = state->currentFrame; // DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", plugin_frame); } @@ -259,7 +259,7 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta display->drawString(0 + x, FONT_HEIGHT_MEDIUM + y, "For help, please post on\nmeshtastic.discourse.group"); } -// Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward plugin are enabled +// Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled static bool shouldDrawMessage(const MeshPacket *packet) { return packet->from != 0 && !radioConfig.preferences.range_test_plugin_enabled && @@ -827,7 +827,7 @@ void Screen::setup() if (textMessagePlugin) textMessageObserver.observe(textMessagePlugin); - // Plugins can notify screen about refresh + // Modules can notify screen about refresh MeshPlugin::observeUIEvents(&uiFrameEventObserver); } @@ -977,7 +977,7 @@ void Screen::setFrames() showingNormalScreen = true; pluginFrames = MeshPlugin::GetMeshPluginsWithUIFrames(); - DEBUG_MSG("Showing %d plugin frames\n", pluginFrames.size()); + DEBUG_MSG("Showing %d module frames\n", pluginFrames.size()); int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + pluginFrames.size(); DEBUG_MSG("Total frame count: %d\n", totalFrameCount); @@ -998,13 +998,13 @@ void Screen::setFrames() normalFrames[numframes++] = drawPluginFrame; } - DEBUG_MSG("Added plugins. numframes: %d\n", numframes); + DEBUG_MSG("Added modules. numframes: %d\n", numframes); // If we have a critical fault, show it first if (myNodeInfo.error_code) normalFrames[numframes++] = drawCriticalFaultFrame; - // If we have a text message - show it next, unless it's a phone message and we aren't using any special plugins + // If we have a text message - show it next, unless it's a phone message and we aren't using any special modules if (devicestate.has_rx_text_message && shouldDrawMessage(&devicestate.rx_text_message)) { normalFrames[numframes++] = drawTextMessageFrame; } diff --git a/src/main.cpp b/src/main.cpp index 68c21c502..24e60fc7d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -537,7 +537,7 @@ void setup() service.init(); - // Now that the mesh service is created, create any plugins + // Now that the mesh service is created, create any modules setupPlugins(); // Do this after service.init (because that clears error_code) diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 323f56363..9944954f7 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -11,7 +11,7 @@ std::vector *MeshPlugin::plugins; const MeshPacket *MeshPlugin::currentRequest; /** - * If any of the current chain of plugins has already sent a reply, it will be here. This is useful to allow + * If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow * the RoutingPlugin to avoid sending redundant acks */ MeshPacket *MeshPlugin::currentReply; @@ -29,7 +29,7 @@ void MeshPlugin::setup() {} MeshPlugin::~MeshPlugin() { - assert(0); // FIXME - remove from list of plugins once someone needs this feature + assert(0); // FIXME - remove from list of modules once someone needs this feature } MeshPacket *MeshPlugin::allocAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex) @@ -68,10 +68,10 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket * void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) { - // DEBUG_MSG("In call plugins\n"); + // DEBUG_MSG("In call modules\n"); bool pluginFound = false; - // We now allow **encrypted** packets to pass through the plugins + // We now allow **encrypted** packets to pass through the modules bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag; currentReply = NULL; // No reply yet @@ -85,7 +85,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) pi.currentRequest = ∓ - /// We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious) + /// We only call modules that are interested in the packet (and the message is destined to us or we are promiscious) bool wantsPacket = (isDecoded || pi.encryptedOk) && (pi.isPromiscuous || toUs) && pi.wantPacket(&mp); if ((src == RX_SRC_LOCAL) && !(pi.loopbackOk)) { @@ -104,7 +104,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) Channel *ch = isDecoded ? &channels.getByIndex(mp.channel) : NULL; /// Is the channel this packet arrived on acceptable? (security check) - /// Note: we can't know channel names for encrypted packets, so those are NEVER sent to boundChannel plugins + /// Note: we can't know channel names for encrypted packets, so those are NEVER sent to boundChannel modules /// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to /// to be able to fetch the initial admin packets without yet knowing any channels. @@ -128,7 +128,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) ProcessMessage handled = pi.handleReceived(mp); // Possibly send replies (but only if the message was directed to us specifically, i.e. not for promiscious - // sniffing) also: we only let the one plugin send a reply, once that happens, remaining plugins are not + // sniffing) also: we only let the one module send a reply, once that happens, remaining modules are not // considered // NOTE: we send a reply *even if the (non broadcast) request was from us* which is unfortunate but necessary @@ -178,7 +178,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) } if (!pluginFound) - DEBUG_MSG("No plugins interested in portnum=%d, src=%s\n", + DEBUG_MSG("No modules interested in portnum=%d, src=%s\n", mp.decoded.portnum, (src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE"); } @@ -201,8 +201,8 @@ void MeshPlugin::sendResponse(const MeshPacket &req) setReplyTo(r, req); currentReply = r; } else { - // Ignore - this is now expected behavior for routing plugin (because it ignores some replies) - // DEBUG_MSG("WARNING: Client requested response but this plugin did not provide\n"); + // Ignore - this is now expected behavior for routing module (because it ignores some replies) + // DEBUG_MSG("WARNING: Client requested response but this module did not provide\n"); } } @@ -264,7 +264,7 @@ AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshP if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) { // In case we have a response it always has priority. - DEBUG_MSG("Reply prepared by plugin '%s' of variant: %d\n", + DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n", pi.name, response->which_variant); handled = h; diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 8d59aa508..7c323e9d8 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -22,8 +22,8 @@ enum class ProcessMessage }; /** - * Used by plugins to return the result of the AdminMessage handling. - * If request is handled, then plugin should return HANDLED, + * Used by modules to return the result of the AdminMessage handling. + * If request is handled, then module should return HANDLED, * If response is also prepared for the request, then HANDLED_WITH_RESPONSE * should be returned. */ @@ -42,15 +42,15 @@ typedef struct _UIFrameEvent { bool needRedraw; } UIFrameEvent; -/** A baseclass for any mesh "plugin". +/** A baseclass for any mesh "module". * - * A plugin allows you to add new features to meshtastic device code, without needing to know messaging details. + * A module allows you to add new features to meshtastic device code, without needing to know messaging details. * - * A key concept for this is that your plugin should use a particular "portnum" for each message type you want to receive + * A key concept for this is that your module should use a particular "portnum" for each message type you want to receive * and handle. * - * Interally we use plugins to implement the core meshtastic text messaging and gps position sharing features. You - * can use these classes as examples for how to write your own custom plugin. See here: (FIXME) + * Interally we use modules to implement the core meshtastic text messaging and gps position sharing features. You + * can use these classes as examples for how to write your own custom module. See here: (FIXME) */ class MeshPlugin { @@ -78,17 +78,17 @@ class MeshPlugin protected: const char *name; - /** Most plugins only care about packets that are destined for their node (i.e. broadcasts or has their node as the specific + /** Most modules only care about packets that are destined for their node (i.e. broadcasts or has their node as the specific recipient) But some plugs might want to 'sniff' packets that are merely being routed (passing through the current node). Those - plugins can set this to true and their handleReceived() will be called for every packet. + modules can set this to true and their handleReceived() will be called for every packet. */ bool isPromiscuous = false; - /** Also receive a copy of LOCALLY GENERATED messages - most plugins should leave + /** Also receive a copy of LOCALLY GENERATED messages - most modules should leave * this setting disabled - see issue #877 */ bool loopbackOk = false; - /** Most plugins only understand decrypted packets. For plugins that also want to see encrypted packets, they should set this + /** Most modules only understand decrypted packets. For modules that also want to see encrypted packets, they should set this * flag */ bool encryptedOk = false; @@ -101,11 +101,11 @@ class MeshPlugin const char *boundChannel = NULL; /** - * If this plugin is currently handling a request currentRequest will be preset + * If this module is currently handling a request currentRequest will be preset * to the packet with the request. This is mostly useful for reply handlers. * * Note: this can be static because we are guaranteed to be processing only one - * plugin at a time. + * plumodulegin at a time. */ static const MeshPacket *currentRequest; @@ -115,7 +115,7 @@ class MeshPlugin MeshPacket *myReply = NULL; /** - * Initialize your plugin. This setup function is called once after all hardware and mesh protocol layers have + * Initialize your module. This setup function is called once after all hardware and mesh protocol layers have * been initialized */ virtual void setup(); @@ -165,7 +165,7 @@ class MeshPlugin private: /** - * If any of the current chain of plugins has already sent a reply, it will be here. This is useful to allow + * If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow * the RoutingPlugin to avoid sending redundant acks */ static MeshPacket *currentReply; diff --git a/src/mesh/ProtobufPlugin.h b/src/mesh/ProtobufPlugin.h index 940d60d76..72d80e0f3 100644 --- a/src/mesh/ProtobufPlugin.h +++ b/src/mesh/ProtobufPlugin.h @@ -2,10 +2,10 @@ #include "SinglePortPlugin.h" /** - * A base class for mesh plugins that assume that they are sending/receiving one particular protobuf based + * A base class for mesh modules that assume that they are sending/receiving one particular protobuf based * payload. Using one particular app ID. * - * If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your plugin + * If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your module * and avoid a bunch of boilerplate code. */ template class ProtobufPlugin : protected SinglePortPlugin @@ -67,7 +67,7 @@ template class ProtobufPlugin : protected SinglePortPlugin if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) decoded = &scratch; else - DEBUG_MSG("Error decoding protobuf plugin!\n"); + DEBUG_MSG("Error decoding protobuf module!\n"); } return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE; diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 6fac3739f..3fce80d83 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -376,7 +376,7 @@ void Router::handleReceived(MeshPacket *p, RxSource src) printPacket("packet decoding failed (no PSK?)", p); } - // call plugins here + // call modules here MeshPlugin::callPlugins(*p, src); } diff --git a/src/mesh/Router.h b/src/mesh/Router.h index 463596c85..65ee5f4fc 100644 --- a/src/mesh/Router.h +++ b/src/mesh/Router.h @@ -85,7 +85,7 @@ class Router : protected concurrency::OSThread /** * Should this incoming filter be dropped? * - * FIXME, move this into the new RoutingPlugin and do the filtering there using the regular plugin logic + * FIXME, move this into the new RoutingPlugin and do the filtering there using the regular module logic * * Called immedately on receiption, before any further processing. * @return true to abandon the packet diff --git a/src/mesh/SinglePortPlugin.h b/src/mesh/SinglePortPlugin.h index 60ca5e653..564c03cdb 100644 --- a/src/mesh/SinglePortPlugin.h +++ b/src/mesh/SinglePortPlugin.h @@ -3,7 +3,7 @@ #include "Router.h" /** - * Most plugins are only interested in sending/receving one particular portnum. This baseclass simplifies that common + * Most modules are only interested in sending/receving one particular portnum. This baseclass simplifies that common * case. */ class SinglePortPlugin : public MeshPlugin diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 0d2a15715..e537f2211 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -197,7 +197,7 @@ int32_t CannedMessagePlugin::runOnce() (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) && (millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS) { - // Reset plugin + // Reset module DEBUG_MSG("Reset due the lack of activity.\n"); e.frameChanged = true; this->currentMessageIndex = -1; @@ -321,7 +321,7 @@ void CannedMessagePlugin::loadProtoForPlugin() } /** - * @brief Save the plugin config to file. + * @brief Save the module config to file. * * @return true On success. * @return false On error. diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 59827e6f8..cda7bfa52 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -13,7 +13,7 @@ Documentation: https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/modules/ExternalNotificationModule.md - This plugin supports: + This module supports: https://github.com/meshtastic/Meshtastic-device/issues/654 @@ -55,7 +55,7 @@ uint32_t externalTurnedOn = 0; int32_t ExternalNotificationPlugin::runOnce() { /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ diff --git a/src/modules/ModuleDev.h b/src/modules/ModuleDev.h index f0fccb8c5..df2e449a5 100644 --- a/src/modules/ModuleDev.h +++ b/src/modules/ModuleDev.h @@ -2,7 +2,7 @@ /* * To developers: - * Use this to enable / disable features in your plugin that you don't want to risk checking into GitHub. + * Use this to enable / disable features in your module that you don't want to risk checking into GitHub. * */ diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 915ac0d4f..1dfad5657 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -20,7 +20,7 @@ #endif /** - * Create plugin instances here. If you are adding a new plugin, you must 'new' it here (or somewhere else) + * Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else) */ void setupPlugins() { @@ -30,7 +30,7 @@ void setupPlugins() positionPlugin = new PositionPlugin(); textMessagePlugin = new TextMessagePlugin(); - // Note: if the rest of meshtastic doesn't need to explicitly use your plugin, you do not need to assign the instance + // Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance // to a global variable. new RemoteHardwarePlugin(); @@ -57,6 +57,6 @@ void setupPlugins() // new StoreForwardPlugin(); #endif - // NOTE! This plugin must be added LAST because it likes to check for replies from other plugins and avoid sending extra acks + // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks routingPlugin = new RoutingPlugin(); } \ No newline at end of file diff --git a/src/modules/Modules.h b/src/modules/Modules.h index 7d2a20cf2..79e6627d2 100644 --- a/src/modules/Modules.h +++ b/src/modules/Modules.h @@ -1,6 +1,6 @@ #pragma once /** - * Create plugin instances here. If you are adding a new plugin, you must 'new' it here (or somewhere else) + * Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else) */ void setupPlugins(); \ No newline at end of file diff --git a/src/modules/NodeInfoModule.h b/src/modules/NodeInfoModule.h index 3ad959518..39ae1f6b0 100644 --- a/src/modules/NodeInfoModule.h +++ b/src/modules/NodeInfoModule.h @@ -2,7 +2,7 @@ #include "ProtobufPlugin.h" /** - * NodeInfo plugin for sending/receiving NodeInfos into the mesh + * NodeInfo module for sending/receiving NodeInfos into the mesh */ class NodeInfoPlugin : public ProtobufPlugin, private concurrency::OSThread { diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 05042ac29..91d76b72f 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -3,7 +3,7 @@ #include "concurrency/OSThread.h" /** - * Position plugin for sending/receiving positions into the mesh + * Position module for sending/receiving positions into the mesh */ class PositionPlugin : public ProtobufPlugin, private concurrency::OSThread { diff --git a/src/modules/RemoteHardwareModule.h b/src/modules/RemoteHardwareModule.h index ab55c1a07..9fa4bb0df 100644 --- a/src/modules/RemoteHardwareModule.h +++ b/src/modules/RemoteHardwareModule.h @@ -4,7 +4,7 @@ #include "concurrency/OSThread.h" /** - * A plugin that provides easy low-level remote access to device hardware. + * A module that provides easy low-level remote access to device hardware. */ class RemoteHardwarePlugin : public ProtobufPlugin, private concurrency::OSThread { diff --git a/src/modules/ReplyModule.h b/src/modules/ReplyModule.h index 16f0d1cdf..4686e8145 100644 --- a/src/modules/ReplyModule.h +++ b/src/modules/ReplyModule.h @@ -3,7 +3,7 @@ /** - * A simple example plugin that just replies with "Message received" to any message it receives. + * A simple example module that just replies with "Message received" to any message it receives. */ class ReplyPlugin : public SinglePortPlugin { @@ -15,7 +15,7 @@ class ReplyPlugin : public SinglePortPlugin protected: - /** For reply plugin we do all of our processing in the (normally optional) + /** For reply module we do all of our processing in the (normally optional) * want_replies handling */ virtual MeshPacket *allocReply() override; diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index e762a8a03..e87f8ca85 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -12,7 +12,7 @@ bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r) printPacket("Routing sniffing", &mp); router->sniffReceived(&mp, r); - // FIXME - move this to a non promsicious PhoneAPI plugin? + // FIXME - move this to a non promsicious PhoneAPI module? // Note: we are careful not to send back packets that started with the phone back to the phone if ((mp.to == NODENUM_BROADCAST || mp.to == nodeDB.getNodeNum()) && (mp.from != 0)) { printPacket("Delivering rx packet", &mp); diff --git a/src/modules/RoutingModule.h b/src/modules/RoutingModule.h index cb0eab13e..ae2088475 100644 --- a/src/modules/RoutingModule.h +++ b/src/modules/RoutingModule.h @@ -3,7 +3,7 @@ #include "Channels.h" /** - * Routing plugin for router control messages + * Routing module for router control messages */ class RoutingPlugin : public ProtobufPlugin { diff --git a/src/modules/Telemetry/Telemetry.cpp b/src/modules/Telemetry/Telemetry.cpp index 0aa0e8bb7..7758667c5 100644 --- a/src/modules/Telemetry/Telemetry.cpp +++ b/src/modules/Telemetry/Telemetry.cpp @@ -46,7 +46,7 @@ int32_t TelemetryPlugin::runOnce() { #ifndef PORTDUINO /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ /* @@ -65,7 +65,7 @@ int32_t TelemetryPlugin::runOnce() if (!(radioConfig.preferences.telemetry_module_measurement_enabled || radioConfig.preferences.telemetry_module_screen_enabled)) { - // If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it + // If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it return (INT32_MAX); } @@ -75,7 +75,7 @@ int32_t TelemetryPlugin::runOnce() if (radioConfig.preferences.telemetry_module_measurement_enabled) { DEBUG_MSG("Telemetry: Initializing\n"); - // it's possible to have this plugin enabled, only for displaying values on the screen. + // it's possible to have this module enabled, only for displaying values on the screen. // therefore, we should only enable the sensor loop if measurement is also enabled switch (radioConfig.preferences.telemetry_module_sensor_type) { @@ -93,14 +93,14 @@ int32_t TelemetryPlugin::runOnce() case RadioConfig_UserPreferences_TelemetrySensorType_MCP9808: return mcp9808Sensor.runOnce(); default: - DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling plugin"); + DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling module"); return (INT32_MAX); break; } } return (INT32_MAX); } else { - // if we somehow got to a second run of this plugin with measurement disabled, then just wait forever + // if we somehow got to a second run of this module with measurement disabled, then just wait forever if (!radioConfig.preferences.telemetry_module_measurement_enabled) return (INT32_MAX); // this is not the first time OSThread library has called this function @@ -229,7 +229,7 @@ bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) { if (!(radioConfig.preferences.telemetry_module_measurement_enabled || radioConfig.preferences.telemetry_module_screen_enabled)) { - // If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume + // If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume return false; } @@ -277,7 +277,7 @@ bool TelemetryPlugin::sendOurTelemetry(NodeNum dest, bool wantReplies) mcp9808Sensor.getMeasurement(&m); break; default: - DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling plugin"); + DEBUG_MSG("Telemetry: Invalid sensor type selected; Disabling module"); return false; } diff --git a/src/modules/esp32/RangeTestPlugin.cpp b/src/modules/esp32/RangeTestPlugin.cpp index 5e7238fa5..efe6d7ae7 100644 --- a/src/modules/esp32/RangeTestPlugin.cpp +++ b/src/modules/esp32/RangeTestPlugin.cpp @@ -32,7 +32,7 @@ int32_t RangeTestPlugin::runOnce() #ifndef NO_ESP32 /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ diff --git a/src/modules/esp32/SerialPlugin.cpp b/src/modules/esp32/SerialPlugin.cpp index f6f3326fc..cc60c96ee 100644 --- a/src/modules/esp32/SerialPlugin.cpp +++ b/src/modules/esp32/SerialPlugin.cpp @@ -15,12 +15,12 @@ Default is to use RX GPIO 16 and TX GPIO 17. - Need help with this plugin? Post your question on the Meshtastic Discourse: + Need help with this module? Post your question on the Meshtastic Discourse: https://meshtastic.discourse.group Basic Usage: - 1) Enable the plugin by setting serialplugin_enabled to 1. + 1) Enable the module by setting serialplugin_enabled to 1. 2) Set the pins (serialplugin_rxd / serialplugin_rxd) for your preferred RX and TX GPIO pins. On tbeam, recommend to use: RXD 35 @@ -39,7 +39,7 @@ - This won't happen any time soon. KNOWN PROBLEMS - * Until the plugin is initilized by the startup sequence, the TX pin is in a floating + * Until the module is initilized by the startup sequence, the TX pin is in a floating state. Device connected to that pin may see this as "noise". * Will not work on NRF and the Linux device targets. diff --git a/src/modules/esp32/StoreForwardPlugin.cpp b/src/modules/esp32/StoreForwardPlugin.cpp index f789d5948..69928dc0a 100644 --- a/src/modules/esp32/StoreForwardPlugin.cpp +++ b/src/modules/esp32/StoreForwardPlugin.cpp @@ -296,7 +296,7 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) { if (!radioConfig.preferences.store_forward_plugin_enabled) { - // If this plugin is not enabled in any capacity, don't handle the packet, and allow other plugins to consume + // If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume return ProcessMessage::CONTINUE; } From bc27dbde986011a8d2218aef164b1c7e9dd86a12 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 00:38:07 -0800 Subject: [PATCH 62/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index a367c4186..810de551e 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit a367c418609100793ddb0f1fbdfbece9f10bb809 +Subproject commit 810de551ea3a3b78a87bd71a1c8397d5544a2f0d From eeacb280d18ceb9afeca2713e89ec9caf7bf4595 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 00:48:54 -0800 Subject: [PATCH 63/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 810de551e..e94d4f54b 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 810de551ea3a3b78a87bd71a1c8397d5544a2f0d +Subproject commit e94d4f54ba23a867e79c355b85dffd7ce4afd08c From ed5dea9f8515283db4c5f448e8baeeadfc992649 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 00:52:25 -0800 Subject: [PATCH 64/93] Update _plugin_ in radioconfig to _module_ --- src/graphics/Screen.cpp | 4 +- src/mesh/generated/radioconfig.pb.h | 144 ++++++++++----------- src/modules/CannedMessageModule.cpp | 14 +- src/modules/ExternalNotificationModule.cpp | 58 ++++----- src/modules/esp32/RangeTestPlugin.cpp | 22 ++-- src/modules/esp32/SerialPlugin.cpp | 40 +++--- src/modules/esp32/StoreForwardPlugin.cpp | 26 ++-- 7 files changed, 154 insertions(+), 154 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 5ac3cca4f..3d047186b 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -262,8 +262,8 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta // Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled static bool shouldDrawMessage(const MeshPacket *packet) { - return packet->from != 0 && !radioConfig.preferences.range_test_plugin_enabled && - !radioConfig.preferences.store_forward_plugin_enabled; + return packet->from != 0 && !radioConfig.preferences.range_test_module_enabled && + !radioConfig.preferences.store_forward_module_enabled; } /// Draw the last text message we received diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 1d4f59da4..5c30273ac 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -141,24 +141,24 @@ typedef struct _RadioConfig_UserPreferences { bool debug_log_enabled; pb_size_t ignore_incoming_count; uint32_t ignore_incoming[3]; - bool serialplugin_enabled; - bool serialplugin_echo; - uint32_t serialplugin_rxd; - uint32_t serialplugin_txd; - uint32_t serialplugin_timeout; - uint32_t serialplugin_mode; - bool ext_notification_plugin_enabled; - uint32_t ext_notification_plugin_output_ms; - uint32_t ext_notification_plugin_output; - 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; - uint32_t store_forward_plugin_records; - uint32_t store_forward_plugin_history_return_max; - uint32_t store_forward_plugin_history_return_window; + bool serialmodule_enabled; + bool serialmodule_echo; + uint32_t serialmodule_rxd; + uint32_t serialmodule_txd; + uint32_t serialmodule_timeout; + uint32_t serialmodule_mode; + bool ext_notification_module_enabled; + uint32_t ext_notification_module_output_ms; + uint32_t ext_notification_module_output; + bool ext_notification_module_active; + bool ext_notification_module_alert_message; + bool ext_notification_module_alert_bell; + bool range_test_module_enabled; + uint32_t range_test_module_sender; + bool range_test_module_save; + uint32_t store_forward_module_records; + uint32_t store_forward_module_history_return_max; + uint32_t store_forward_module_history_return_window; bool telemetry_module_measurement_enabled; bool telemetry_module_screen_enabled; uint32_t telemetry_module_read_error_count_threshold; @@ -167,8 +167,8 @@ typedef struct _RadioConfig_UserPreferences { bool telemetry_module_display_farenheit; RadioConfig_UserPreferences_TelemetrySensorType telemetry_module_sensor_type; uint32_t telemetry_module_sensor_pin; - bool store_forward_plugin_enabled; - bool store_forward_plugin_heartbeat; + bool store_forward_module_enabled; + bool store_forward_module_heartbeat; uint32_t position_flags; bool is_always_powered; uint32_t auto_screen_carousel_secs; @@ -185,12 +185,12 @@ typedef struct _RadioConfig_UserPreferences { InputEventChar rotary1_event_cw; InputEventChar rotary1_event_ccw; InputEventChar rotary1_event_press; - bool canned_message_plugin_enabled; - char canned_message_plugin_allow_input_source[16]; - bool canned_message_plugin_send_bell; + bool canned_message_module_enabled; + char canned_message_module_allow_input_source[16]; + bool canned_message_module_send_bell; bool mqtt_encryption_enabled; float adc_multiplier_override; - uint32_t serialplugin_baud; + uint32_t serialmodule_baud; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -277,24 +277,24 @@ extern "C" { #define RadioConfig_UserPreferences_factory_reset_tag 100 #define RadioConfig_UserPreferences_debug_log_enabled_tag 101 #define RadioConfig_UserPreferences_ignore_incoming_tag 103 -#define RadioConfig_UserPreferences_serialplugin_enabled_tag 120 -#define RadioConfig_UserPreferences_serialplugin_echo_tag 121 -#define RadioConfig_UserPreferences_serialplugin_rxd_tag 122 -#define RadioConfig_UserPreferences_serialplugin_txd_tag 123 -#define RadioConfig_UserPreferences_serialplugin_timeout_tag 124 -#define RadioConfig_UserPreferences_serialplugin_mode_tag 125 -#define RadioConfig_UserPreferences_ext_notification_plugin_enabled_tag 126 -#define RadioConfig_UserPreferences_ext_notification_plugin_output_ms_tag 127 -#define RadioConfig_UserPreferences_ext_notification_plugin_output_tag 128 -#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_records_tag 137 -#define RadioConfig_UserPreferences_store_forward_plugin_history_return_max_tag 138 -#define RadioConfig_UserPreferences_store_forward_plugin_history_return_window_tag 139 +#define RadioConfig_UserPreferences_serialmodule_enabled_tag 120 +#define RadioConfig_UserPreferences_serialmodule_echo_tag 121 +#define RadioConfig_UserPreferences_serialmodule_rxd_tag 122 +#define RadioConfig_UserPreferences_serialmodule_txd_tag 123 +#define RadioConfig_UserPreferences_serialmodule_timeout_tag 124 +#define RadioConfig_UserPreferences_serialmodule_mode_tag 125 +#define RadioConfig_UserPreferences_ext_notification_module_enabled_tag 126 +#define RadioConfig_UserPreferences_ext_notification_module_output_ms_tag 127 +#define RadioConfig_UserPreferences_ext_notification_module_output_tag 128 +#define RadioConfig_UserPreferences_ext_notification_module_active_tag 129 +#define RadioConfig_UserPreferences_ext_notification_module_alert_message_tag 130 +#define RadioConfig_UserPreferences_ext_notification_module_alert_bell_tag 131 +#define RadioConfig_UserPreferences_range_test_module_enabled_tag 132 +#define RadioConfig_UserPreferences_range_test_module_sender_tag 133 +#define RadioConfig_UserPreferences_range_test_module_save_tag 134 +#define RadioConfig_UserPreferences_store_forward_module_records_tag 137 +#define RadioConfig_UserPreferences_store_forward_module_history_return_max_tag 138 +#define RadioConfig_UserPreferences_store_forward_module_history_return_window_tag 139 #define RadioConfig_UserPreferences_telemetry_module_measurement_enabled_tag 140 #define RadioConfig_UserPreferences_telemetry_module_screen_enabled_tag 141 #define RadioConfig_UserPreferences_telemetry_module_read_error_count_threshold_tag 142 @@ -303,8 +303,8 @@ extern "C" { #define RadioConfig_UserPreferences_telemetry_module_display_farenheit_tag 145 #define RadioConfig_UserPreferences_telemetry_module_sensor_type_tag 146 #define RadioConfig_UserPreferences_telemetry_module_sensor_pin_tag 147 -#define RadioConfig_UserPreferences_store_forward_plugin_enabled_tag 148 -#define RadioConfig_UserPreferences_store_forward_plugin_heartbeat_tag 149 +#define RadioConfig_UserPreferences_store_forward_module_enabled_tag 148 +#define RadioConfig_UserPreferences_store_forward_module_heartbeat_tag 149 #define RadioConfig_UserPreferences_position_flags_tag 150 #define RadioConfig_UserPreferences_is_always_powered_tag 151 #define RadioConfig_UserPreferences_auto_screen_carousel_secs_tag 152 @@ -321,12 +321,12 @@ extern "C" { #define RadioConfig_UserPreferences_rotary1_event_cw_tag 164 #define RadioConfig_UserPreferences_rotary1_event_ccw_tag 165 #define RadioConfig_UserPreferences_rotary1_event_press_tag 166 -#define RadioConfig_UserPreferences_canned_message_plugin_enabled_tag 170 -#define RadioConfig_UserPreferences_canned_message_plugin_allow_input_source_tag 171 -#define RadioConfig_UserPreferences_canned_message_plugin_send_bell_tag 173 +#define RadioConfig_UserPreferences_canned_message_module_enabled_tag 170 +#define RadioConfig_UserPreferences_canned_message_module_allow_input_source_tag 171 +#define RadioConfig_UserPreferences_canned_message_module_send_bell_tag 173 #define RadioConfig_UserPreferences_mqtt_encryption_enabled_tag 174 #define RadioConfig_UserPreferences_adc_multiplier_override_tag 175 -#define RadioConfig_UserPreferences_serialplugin_baud_tag 176 +#define RadioConfig_UserPreferences_serialmodule_baud_tag 176 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -370,24 +370,24 @@ X(a, STATIC, SINGULAR, UINT32, gps_max_dop, 46) \ X(a, STATIC, SINGULAR, BOOL, factory_reset, 100) \ X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 101) \ X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \ -X(a, STATIC, SINGULAR, BOOL, serialplugin_enabled, 120) \ -X(a, STATIC, SINGULAR, BOOL, serialplugin_echo, 121) \ -X(a, STATIC, SINGULAR, UINT32, serialplugin_rxd, 122) \ -X(a, STATIC, SINGULAR, UINT32, serialplugin_txd, 123) \ -X(a, STATIC, SINGULAR, UINT32, serialplugin_timeout, 124) \ -X(a, STATIC, SINGULAR, UINT32, serialplugin_mode, 125) \ -X(a, STATIC, SINGULAR, BOOL, ext_notification_plugin_enabled, 126) \ -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, 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, UINT32, store_forward_plugin_records, 137) \ -X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_history_return_max, 138) \ -X(a, STATIC, SINGULAR, UINT32, store_forward_plugin_history_return_window, 139) \ +X(a, STATIC, SINGULAR, BOOL, serialmodule_enabled, 120) \ +X(a, STATIC, SINGULAR, BOOL, serialmodule_echo, 121) \ +X(a, STATIC, SINGULAR, UINT32, serialmodule_rxd, 122) \ +X(a, STATIC, SINGULAR, UINT32, serialmodule_txd, 123) \ +X(a, STATIC, SINGULAR, UINT32, serialmodule_timeout, 124) \ +X(a, STATIC, SINGULAR, UINT32, serialmodule_mode, 125) \ +X(a, STATIC, SINGULAR, BOOL, ext_notification_module_enabled, 126) \ +X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output_ms, 127) \ +X(a, STATIC, SINGULAR, UINT32, ext_notification_module_output, 128) \ +X(a, STATIC, SINGULAR, BOOL, ext_notification_module_active, 129) \ +X(a, STATIC, SINGULAR, BOOL, ext_notification_module_alert_message, 130) \ +X(a, STATIC, SINGULAR, BOOL, ext_notification_module_alert_bell, 131) \ +X(a, STATIC, SINGULAR, BOOL, range_test_module_enabled, 132) \ +X(a, STATIC, SINGULAR, UINT32, range_test_module_sender, 133) \ +X(a, STATIC, SINGULAR, BOOL, range_test_module_save, 134) \ +X(a, STATIC, SINGULAR, UINT32, store_forward_module_records, 137) \ +X(a, STATIC, SINGULAR, UINT32, store_forward_module_history_return_max, 138) \ +X(a, STATIC, SINGULAR, UINT32, store_forward_module_history_return_window, 139) \ X(a, STATIC, SINGULAR, BOOL, telemetry_module_measurement_enabled, 140) \ X(a, STATIC, SINGULAR, BOOL, telemetry_module_screen_enabled, 141) \ X(a, STATIC, SINGULAR, UINT32, telemetry_module_read_error_count_threshold, 142) \ @@ -396,8 +396,8 @@ X(a, STATIC, SINGULAR, UINT32, telemetry_module_recovery_interval, 144) \ X(a, STATIC, SINGULAR, BOOL, telemetry_module_display_farenheit, 145) \ X(a, STATIC, SINGULAR, UENUM, telemetry_module_sensor_type, 146) \ X(a, STATIC, SINGULAR, UINT32, telemetry_module_sensor_pin, 147) \ -X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_enabled, 148) \ -X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_heartbeat, 149) \ +X(a, STATIC, SINGULAR, BOOL, store_forward_module_enabled, 148) \ +X(a, STATIC, SINGULAR, BOOL, store_forward_module_heartbeat, 149) \ X(a, STATIC, SINGULAR, UINT32, position_flags, 150) \ X(a, STATIC, SINGULAR, BOOL, is_always_powered, 151) \ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \ @@ -414,12 +414,12 @@ X(a, STATIC, SINGULAR, UINT32, rotary1_pin_press, 163) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_cw, 164) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_ccw, 165) \ X(a, STATIC, SINGULAR, UENUM, rotary1_event_press, 166) \ -X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_enabled, 170) \ -X(a, STATIC, SINGULAR, STRING, canned_message_plugin_allow_input_source, 171) \ -X(a, STATIC, SINGULAR, BOOL, canned_message_plugin_send_bell, 173) \ +X(a, STATIC, SINGULAR, BOOL, canned_message_module_enabled, 170) \ +X(a, STATIC, SINGULAR, STRING, canned_message_module_allow_input_source, 171) \ +X(a, STATIC, SINGULAR, BOOL, canned_message_module_send_bell, 173) \ X(a, STATIC, SINGULAR, BOOL, mqtt_encryption_enabled, 174) \ X(a, STATIC, SINGULAR, FLOAT, adc_multiplier_override, 175) \ -X(a, STATIC, SINGULAR, UINT32, serialplugin_baud, 176) +X(a, STATIC, SINGULAR, UINT32, serialmodule_baud, 176) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index e537f2211..0289e06c3 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -26,7 +26,7 @@ CannedMessagePlugin::CannedMessagePlugin() : SinglePortPlugin("canned", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessagePlugin") { - if (radioConfig.preferences.canned_message_plugin_enabled) + if (radioConfig.preferences.canned_message_module_enabled) { this->loadProtoForPlugin(); if(this->splitConfiguredMessages() <= 0) @@ -113,9 +113,9 @@ int CannedMessagePlugin::splitConfiguredMessages() int CannedMessagePlugin::handleInputEvent(const InputEvent *event) { if ( - (strlen(radioConfig.preferences.canned_message_plugin_allow_input_source) > 0) && - (strcmp(radioConfig.preferences.canned_message_plugin_allow_input_source, event->source) != 0) && - (strcmp(radioConfig.preferences.canned_message_plugin_allow_input_source, "_any") != 0)) + (strlen(radioConfig.preferences.canned_message_module_allow_input_source) > 0) && + (strcmp(radioConfig.preferences.canned_message_module_allow_input_source, event->source) != 0) && + (strcmp(radioConfig.preferences.canned_message_module_allow_input_source, "_any") != 0)) { // Event source is not accepted. // Event only accepted if source matches the configured one, or @@ -162,7 +162,7 @@ void CannedMessagePlugin::sendText(NodeNum dest, p->want_ack = true; p->decoded.payload.size = strlen(message); memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size); - if (radioConfig.preferences.canned_message_plugin_send_bell) + if (radioConfig.preferences.canned_message_module_send_bell) { p->decoded.payload.bytes[p->decoded.payload.size-1] = 7; // Bell character p->decoded.payload.bytes[p->decoded.payload.size] = '\0'; // Bell character @@ -177,7 +177,7 @@ void CannedMessagePlugin::sendText(NodeNum dest, int32_t CannedMessagePlugin::runOnce() { - if ((!radioConfig.preferences.canned_message_plugin_enabled) + if ((!radioConfig.preferences.canned_message_module_enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { @@ -259,7 +259,7 @@ const char* CannedMessagePlugin::getNextMessage() } bool CannedMessagePlugin::shouldDraw() { - if (!radioConfig.preferences.canned_message_plugin_enabled) + if (!radioConfig.preferences.canned_message_module_enabled) { return false; } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index cda7bfa52..e64d86d01 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -19,26 +19,26 @@ Quick reference: - radioConfig.preferences.ext_notification_plugin_enabled + radioConfig.preferences.ext_notification_module_enabled 0 = Disabled (Default) 1 = Enabled - radioConfig.preferences.ext_notification_plugin_active + radioConfig.preferences.ext_notification_module_active 0 = Active Low (Default) 1 = Active High - radioConfig.preferences.ext_notification_plugin_alert_message + radioConfig.preferences.ext_notification_module_alert_message 0 = Disabled (Default) 1 = Alert when a text message comes - radioConfig.preferences.ext_notification_plugin_alert_bell + radioConfig.preferences.ext_notification_module_alert_bell 0 = Disabled (Default) 1 = Alert when the bell character is received - radioConfig.preferences.ext_notification_plugin_output + radioConfig.preferences.ext_notification_module_output GPIO of the output. (Default = 13) - radioConfig.preferences.ext_notification_plugin_output_ms + radioConfig.preferences.ext_notification_module_output_ms Amount of time in ms for the alert. Default is 1000. */ @@ -59,19 +59,19 @@ int32_t ExternalNotificationPlugin::runOnce() without having to configure it from the PythonAPI or WebUI. */ - // radioConfig.preferences.ext_notification_plugin_enabled = 1; - // radioConfig.preferences.ext_notification_plugin_alert_message = 1; + // radioConfig.preferences.ext_notification_module_enabled = 1; + // radioConfig.preferences.ext_notification_module_alert_message = 1; - // radioConfig.preferences.ext_notification_plugin_active = 1; - // radioConfig.preferences.ext_notification_plugin_alert_bell = 1; - // radioConfig.preferences.ext_notification_plugin_output_ms = 1000; - // radioConfig.preferences.ext_notification_plugin_output = 13; + // radioConfig.preferences.ext_notification_module_active = 1; + // radioConfig.preferences.ext_notification_module_alert_bell = 1; + // radioConfig.preferences.ext_notification_module_output_ms = 1000; + // radioConfig.preferences.ext_notification_module_output = 13; if (externalCurrentState) { // If the output is turned on, turn it back off after the given period of time. - if (externalTurnedOn + (radioConfig.preferences.ext_notification_plugin_output_ms - ? radioConfig.preferences.ext_notification_plugin_output_ms + if (externalTurnedOn + (radioConfig.preferences.ext_notification_module_output_ms + ? radioConfig.preferences.ext_notification_module_output_ms : EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) < millis()) { DEBUG_MSG("Turning off external notification\n"); @@ -88,9 +88,9 @@ void ExternalNotificationPlugin::setExternalOn() externalCurrentState = 1; externalTurnedOn = millis(); - digitalWrite((radioConfig.preferences.ext_notification_plugin_output ? radioConfig.preferences.ext_notification_plugin_output + digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output : EXT_NOTIFICATION_PLUGIN_OUTPUT), - (radioConfig.preferences.ext_notification_plugin_active ? true : false)); + (radioConfig.preferences.ext_notification_module_active ? true : false)); #endif } @@ -99,9 +99,9 @@ void ExternalNotificationPlugin::setExternalOff() #ifdef EXT_NOTIFY_OUT externalCurrentState = 0; - digitalWrite((radioConfig.preferences.ext_notification_plugin_output ? radioConfig.preferences.ext_notification_plugin_output + digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output : EXT_NOTIFICATION_PLUGIN_OUTPUT), - (radioConfig.preferences.ext_notification_plugin_active ? false : true)); + (radioConfig.preferences.ext_notification_module_active ? false : true)); #endif } @@ -122,20 +122,20 @@ ExternalNotificationPlugin::ExternalNotificationPlugin() without having to configure it from the PythonAPI or WebUI. */ - // radioConfig.preferences.ext_notification_plugin_enabled = 1; - // radioConfig.preferences.ext_notification_plugin_alert_message = 1; + // radioConfig.preferences.ext_notification_module_enabled = 1; + // radioConfig.preferences.ext_notification_module_alert_message = 1; - // radioConfig.preferences.ext_notification_plugin_active = 1; - // radioConfig.preferences.ext_notification_plugin_alert_bell = 1; - // radioConfig.preferences.ext_notification_plugin_output_ms = 1000; - // radioConfig.preferences.ext_notification_plugin_output = 13; + // radioConfig.preferences.ext_notification_module_active = 1; + // radioConfig.preferences.ext_notification_module_alert_bell = 1; + // radioConfig.preferences.ext_notification_module_output_ms = 1000; + // radioConfig.preferences.ext_notification_module_output = 13; - if (radioConfig.preferences.ext_notification_plugin_enabled) { + if (radioConfig.preferences.ext_notification_module_enabled) { DEBUG_MSG("Initializing External Notification Plugin\n"); // Set the direction of a pin - pinMode((radioConfig.preferences.ext_notification_plugin_output ? radioConfig.preferences.ext_notification_plugin_output + pinMode((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output : EXT_NOTIFICATION_PLUGIN_OUTPUT), OUTPUT); @@ -154,13 +154,13 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp) #ifndef NO_ESP32 #ifdef EXT_NOTIFY_OUT - if (radioConfig.preferences.ext_notification_plugin_enabled) { + if (radioConfig.preferences.ext_notification_module_enabled) { if (getFrom(&mp) != nodeDB.getNodeNum()) { // TODO: This may be a problem if messages are sent in unicide, but I'm not sure if it will. // Need to know if and how this could be a problem. - if (radioConfig.preferences.ext_notification_plugin_alert_bell) { + if (radioConfig.preferences.ext_notification_module_alert_bell) { auto &p = mp.decoded; DEBUG_MSG("externalNotificationPlugin - Notification Bell\n"); for (int i = 0; i < p.payload.size; i++) { @@ -170,7 +170,7 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp) } } - if (radioConfig.preferences.ext_notification_plugin_alert_message) { + if (radioConfig.preferences.ext_notification_module_alert_message) { DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n"); setExternalOn(); } diff --git a/src/modules/esp32/RangeTestPlugin.cpp b/src/modules/esp32/RangeTestPlugin.cpp index efe6d7ae7..59ab48767 100644 --- a/src/modules/esp32/RangeTestPlugin.cpp +++ b/src/modules/esp32/RangeTestPlugin.cpp @@ -36,33 +36,33 @@ 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 = 45; - // radioConfig.preferences.range_test_plugin_save = 1; + // radioConfig.preferences.range_test_module_enabled = 1; + // radioConfig.preferences.range_test_module_sender = 45; + // radioConfig.preferences.range_test_module_save = 1; // Fixed position is useful when testing indoors. // radioConfig.preferences.fixed_position = 1; - uint32_t senderHeartbeat = radioConfig.preferences.range_test_plugin_sender * 1000; + uint32_t senderHeartbeat = radioConfig.preferences.range_test_module_sender * 1000; - if (radioConfig.preferences.range_test_plugin_enabled) { + if (radioConfig.preferences.range_test_module_enabled) { if (firstTime) { rangeTestPluginRadio = new RangeTestPluginRadio(); firstTime = 0; - if (radioConfig.preferences.range_test_plugin_sender) { - DEBUG_MSG("Initializing Range Test Plugin -- Sender\n"); + if (radioConfig.preferences.range_test_module_sender) { + DEBUG_MSG("Initializing Range Test Module -- Sender\n"); return (5000); // Sending first message 5 seconds after initilization. } else { - DEBUG_MSG("Initializing Range Test Plugin -- Receiver\n"); + DEBUG_MSG("Initializing Range Test Module -- Receiver\n"); return (500); } } else { - if (radioConfig.preferences.range_test_plugin_sender) { + if (radioConfig.preferences.range_test_module_sender) { // If sender DEBUG_MSG("Range Test Plugin - Sending heartbeat every %d ms\n", (senderHeartbeat)); @@ -131,7 +131,7 @@ ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (radioConfig.preferences.range_test_plugin_enabled) { + if (radioConfig.preferences.range_test_module_enabled) { /* auto &p = mp.decoded; @@ -141,7 +141,7 @@ ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp) if (getFrom(&mp) != nodeDB.getNodeNum()) { - if (radioConfig.preferences.range_test_plugin_save) { + if (radioConfig.preferences.range_test_module_save) { appendFile(mp); } diff --git a/src/modules/esp32/SerialPlugin.cpp b/src/modules/esp32/SerialPlugin.cpp index cc60c96ee..2687eff27 100644 --- a/src/modules/esp32/SerialPlugin.cpp +++ b/src/modules/esp32/SerialPlugin.cpp @@ -21,17 +21,17 @@ Basic Usage: 1) Enable the module by setting serialplugin_enabled to 1. - 2) Set the pins (serialplugin_rxd / serialplugin_rxd) for your preferred RX and TX GPIO pins. + 2) Set the pins (serialmodule_rxd / serialmodule_rxd) for your preferred RX and TX GPIO pins. On tbeam, recommend to use: RXD 35 TXD 15 - 3) Set serialplugin_timeout to the amount of time to wait before we consider + 3) Set serialmodule_timeout to the amount of time to wait before we consider your packet as "done". 4) (Optional) In SerialPlugin.h set the port to PortNum_TEXT_MESSAGE_APP if you want to send messages to/from the general text message channel. 5) Connect to your device over the serial interface at 38400 8N1. 6) Send a packet up to 240 bytes in length. This will get relayed over the mesh network. - 7) (Optional) Set serialplugin_echo to 1 and any message you send out will be echoed back + 7) (Optional) Set serialmodule_echo to 1 and any message you send out will be echoed back to your device. TODO (in this order): @@ -72,34 +72,34 @@ int32_t SerialPlugin::runOnce() #ifndef NO_ESP32 /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ - // radioConfig.preferences.serialplugin_enabled = 1; - // radioConfig.preferences.serialplugin_rxd = 35; - // radioConfig.preferences.serialplugin_txd = 15; - // radioConfig.preferences.serialplugin_timeout = 1000; - // radioConfig.preferences.serialplugin_echo = 1; + // radioConfig.preferences.serialmodule_enabled = 1; + // radioConfig.preferences.serialmodule_rxd = 35; + // radioConfig.preferences.serialmodule_txd = 15; + // radioConfig.preferences.serialmodule_timeout = 1000; + // radioConfig.preferences.serialmodule_echo = 1; - if (radioConfig.preferences.serialplugin_enabled) { + if (radioConfig.preferences.serialmodule_enabled) { if (firstTime) { // Interface with the serial peripheral from in here. DEBUG_MSG("Initializing serial peripheral interface\n"); - if (radioConfig.preferences.serialplugin_rxd && radioConfig.preferences.serialplugin_txd) { - Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, radioConfig.preferences.serialplugin_rxd, - radioConfig.preferences.serialplugin_txd); + if (radioConfig.preferences.serialmodule_rxd && radioConfig.preferences.serialmodule_txd) { + Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd, + radioConfig.preferences.serialmodule_txd); } else { Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); } - if (radioConfig.preferences.serialplugin_timeout) { + if (radioConfig.preferences.serialmodule_timeout) { Serial2.setTimeout( - radioConfig.preferences.serialplugin_timeout); // Number of MS to wait to set the timeout for the string. + radioConfig.preferences.serialmodule_timeout); // Number of MS to wait to set the timeout for the string. } else { Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. @@ -161,7 +161,7 @@ ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (radioConfig.preferences.serialplugin_enabled) { + if (radioConfig.preferences.serialmodule_enabled) { auto &p = mp.decoded; // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", @@ -170,10 +170,10 @@ ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp) if (getFrom(&mp) == nodeDB.getNodeNum()) { /* - * If radioConfig.preferences.serialplugin_echo is true, then echo the packets that are sent out back to the TX + * If radioConfig.preferences.serialmodule_echo is true, then echo the packets that are sent out back to the TX * of the serial interface. */ - if (radioConfig.preferences.serialplugin_echo) { + if (radioConfig.preferences.serialmodule_echo) { // For some reason, we get the packet back twice when we send out of the radio. // TODO: need to find out why. @@ -187,12 +187,12 @@ ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp) } else { - if (radioConfig.preferences.serialplugin_mode == 0 || radioConfig.preferences.serialplugin_mode == 1) { + if (radioConfig.preferences.serialmodule_mode == 0 || radioConfig.preferences.serialmodule_mode == 1) { // DEBUG_MSG("* * Message came from the mesh\n"); // Serial2.println("* * Message came from the mesh"); Serial2.printf("%s", p.payload.bytes); - } else if (radioConfig.preferences.serialplugin_mode == 10) { + } else if (radioConfig.preferences.serialmodule_mode == 10) { /* @jobionekabnoi Add code here to handle what gets sent out to the serial interface. diff --git a/src/modules/esp32/StoreForwardPlugin.cpp b/src/modules/esp32/StoreForwardPlugin.cpp index 69928dc0a..b061c3bfe 100644 --- a/src/modules/esp32/StoreForwardPlugin.cpp +++ b/src/modules/esp32/StoreForwardPlugin.cpp @@ -19,7 +19,7 @@ int32_t StoreForwardPlugin::runOnce() #ifndef NO_ESP32 - if (radioConfig.preferences.store_forward_plugin_enabled) { + if (radioConfig.preferences.store_forward_module_enabled) { if (radioConfig.preferences.is_router) { @@ -243,7 +243,7 @@ void StoreForwardPlugin::sendMessage(NodeNum dest, char *str) ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 - if (radioConfig.preferences.store_forward_plugin_enabled) { + if (radioConfig.preferences.store_forward_module_enabled) { DEBUG_MSG("--- S&F Received something\n"); @@ -295,7 +295,7 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) { - if (!radioConfig.preferences.store_forward_plugin_enabled) { + if (!radioConfig.preferences.store_forward_module_enabled) { // If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume return ProcessMessage::CONTINUE; } @@ -391,12 +391,12 @@ StoreForwardPlugin::StoreForwardPlugin() without having to configure it from the PythonAPI or WebUI. */ - radioConfig.preferences.store_forward_plugin_enabled = 1; + radioConfig.preferences.store_forward_module_enabled = 1; radioConfig.preferences.is_router = 1; radioConfig.preferences.is_always_powered = 1; } - if (radioConfig.preferences.store_forward_plugin_enabled) { + if (radioConfig.preferences.store_forward_module_enabled) { // Router if (radioConfig.preferences.is_router) { @@ -407,20 +407,20 @@ StoreForwardPlugin::StoreForwardPlugin() // Do the startup here // Maximum number of records to return. - if (radioConfig.preferences.store_forward_plugin_history_return_max) - this->historyReturnMax = radioConfig.preferences.store_forward_plugin_history_return_max; + if (radioConfig.preferences.store_forward_module_history_return_max) + this->historyReturnMax = radioConfig.preferences.store_forward_module_history_return_max; // Maximum time window for records to return (in minutes) - if (radioConfig.preferences.store_forward_plugin_history_return_window) - this->historyReturnWindow = radioConfig.preferences.store_forward_plugin_history_return_window; + if (radioConfig.preferences.store_forward_module_history_return_window) + this->historyReturnWindow = radioConfig.preferences.store_forward_module_history_return_window; // Maximum number of records to store in memory - if (radioConfig.preferences.store_forward_plugin_records) - this->records = radioConfig.preferences.store_forward_plugin_records; + if (radioConfig.preferences.store_forward_module_records) + this->records = radioConfig.preferences.store_forward_module_records; // Maximum number of records to store in memory - if (radioConfig.preferences.store_forward_plugin_heartbeat) - this->heartbeat = radioConfig.preferences.store_forward_plugin_heartbeat; + if (radioConfig.preferences.store_forward_module_heartbeat) + this->heartbeat = radioConfig.preferences.store_forward_module_heartbeat; // Popupate PSRAM with our data structures. this->populatePSRAM(); From ebc9fef222c901ffcb3ce688d635c4c99e354d34 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 01:00:35 -0800 Subject: [PATCH 65/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index e94d4f54b..cd7d99a07 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit e94d4f54ba23a867e79c355b85dffd7ce4afd08c +Subproject commit cd7d99a0767664601f351b511d32b13814f4d67e From ba7644e3766cff4b78b389cd829a16bd6b4c4eac Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 01:09:36 -0800 Subject: [PATCH 66/93] Update canned messages from plugin to module --- src/input/RotaryEncoderInterruptImpl1.cpp | 2 +- src/mesh/generated/admin.pb.h | 72 +++++++++---------- src/mesh/generated/cannedmessages.pb.c | 2 +- src/mesh/generated/cannedmessages.pb.h | 28 ++++---- src/modules/CannedMessageModule.cpp | 86 +++++++++++------------ 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/input/RotaryEncoderInterruptImpl1.cpp b/src/input/RotaryEncoderInterruptImpl1.cpp index e0e904a0d..74d318084 100644 --- a/src/input/RotaryEncoderInterruptImpl1.cpp +++ b/src/input/RotaryEncoderInterruptImpl1.cpp @@ -27,7 +27,7 @@ void RotaryEncoderInterruptImpl1::init() char eventPressed = static_cast(radioConfig.preferences.rotary1_event_press); - //radioConfig.preferences.ext_notification_plugin_output + //radioConfig.preferences.ext_notification_module_output RotaryEncoderInterruptBase::init( pinA, pinB, pinPress, eventCw, eventCcw, eventPressed, diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 1a065f7f2..fc9a20d56 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -29,18 +29,18 @@ typedef struct _AdminMessage { bool confirm_set_radio; bool exit_simulator; int32_t reboot_seconds; - bool get_canned_message_plugin_part1_request; - char get_canned_message_plugin_part1_response[201]; - bool get_canned_message_plugin_part2_request; - char get_canned_message_plugin_part2_response[201]; - bool get_canned_message_plugin_part3_request; - char get_canned_message_plugin_part3_response[201]; - bool get_canned_message_plugin_part4_request; - char get_canned_message_plugin_part4_response[201]; - char set_canned_message_plugin_part1[201]; - char set_canned_message_plugin_part2[201]; - char set_canned_message_plugin_part3[201]; - char set_canned_message_plugin_part4[201]; + bool get_canned_message_module_part1_request; + char get_canned_message_module_part1_response[201]; + bool get_canned_message_module_part2_request; + char get_canned_message_module_part2_response[201]; + bool get_canned_message_module_part3_request; + char get_canned_message_module_part3_response[201]; + bool get_canned_message_module_part4_request; + char get_canned_message_module_part4_response[201]; + char set_canned_message_module_part1[201]; + char set_canned_message_module_part2[201]; + char set_canned_message_module_part3[201]; + char set_canned_message_module_part4[201]; int32_t shutdown_seconds; }; } AdminMessage; @@ -68,18 +68,18 @@ extern "C" { #define AdminMessage_confirm_set_radio_tag 33 #define AdminMessage_exit_simulator_tag 34 #define AdminMessage_reboot_seconds_tag 35 -#define AdminMessage_get_canned_message_plugin_part1_request_tag 36 -#define AdminMessage_get_canned_message_plugin_part1_response_tag 37 -#define AdminMessage_get_canned_message_plugin_part2_request_tag 38 -#define AdminMessage_get_canned_message_plugin_part2_response_tag 39 -#define AdminMessage_get_canned_message_plugin_part3_request_tag 40 -#define AdminMessage_get_canned_message_plugin_part3_response_tag 41 -#define AdminMessage_get_canned_message_plugin_part4_request_tag 42 -#define AdminMessage_get_canned_message_plugin_part4_response_tag 43 -#define AdminMessage_set_canned_message_plugin_part1_tag 44 -#define AdminMessage_set_canned_message_plugin_part2_tag 45 -#define AdminMessage_set_canned_message_plugin_part3_tag 46 -#define AdminMessage_set_canned_message_plugin_part4_tag 47 +#define AdminMessage_get_canned_message_module_part1_request_tag 36 +#define AdminMessage_get_canned_message_module_part1_response_tag 37 +#define AdminMessage_get_canned_message_module_part2_request_tag 38 +#define AdminMessage_get_canned_message_module_part2_response_tag 39 +#define AdminMessage_get_canned_message_module_part3_request_tag 40 +#define AdminMessage_get_canned_message_module_part3_response_tag 41 +#define AdminMessage_get_canned_message_module_part4_request_tag 42 +#define AdminMessage_get_canned_message_module_part4_response_tag 43 +#define AdminMessage_set_canned_message_module_part1_tag 44 +#define AdminMessage_set_canned_message_module_part2_tag 45 +#define AdminMessage_set_canned_message_module_part3_tag 46 +#define AdminMessage_set_canned_message_module_part4_tag 47 #define AdminMessage_shutdown_seconds_tag 51 /* Struct field encoding specification for nanopb */ @@ -97,18 +97,18 @@ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_chan X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \ X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \ X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) \ -X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part1_request,get_canned_message_plugin_part1_request), 36) \ -X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part1_response,get_canned_message_plugin_part1_response), 37) \ -X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part2_request,get_canned_message_plugin_part2_request), 38) \ -X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part2_response,get_canned_message_plugin_part2_response), 39) \ -X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part3_request,get_canned_message_plugin_part3_request), 40) \ -X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part3_response,get_canned_message_plugin_part3_response), 41) \ -X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_plugin_part4_request,get_canned_message_plugin_part4_request), 42) \ -X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_plugin_part4_response,get_canned_message_plugin_part4_response), 43) \ -X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part1,set_canned_message_plugin_part1), 44) \ -X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part2,set_canned_message_plugin_part2), 45) \ -X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part3,set_canned_message_plugin_part3), 46) \ -X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_plugin_part4,set_canned_message_plugin_part4), 47) \ +X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part1_request,get_canned_message_module_part1_request), 36) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part1_response,get_canned_message_module_part1_response), 37) \ +X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part2_request,get_canned_message_module_part2_request), 38) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part2_response,get_canned_message_module_part2_response), 39) \ +X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part3_request,get_canned_message_module_part3_request), 40) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part3_response,get_canned_message_module_part3_response), 41) \ +X(a, STATIC, ONEOF, BOOL, (variant,get_canned_message_module_part4_request,get_canned_message_module_part4_request), 42) \ +X(a, STATIC, ONEOF, STRING, (variant,get_canned_message_module_part4_response,get_canned_message_module_part4_response), 43) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part1,set_canned_message_module_part1), 44) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part2,set_canned_message_module_part2), 45) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part3,set_canned_message_module_part3), 46) \ +X(a, STATIC, ONEOF, STRING, (variant,set_canned_message_module_part4,set_canned_message_module_part4), 47) \ X(a, STATIC, ONEOF, INT32, (variant,shutdown_seconds,shutdown_seconds), 51) #define AdminMessage_CALLBACK NULL #define AdminMessage_DEFAULT NULL diff --git a/src/mesh/generated/cannedmessages.pb.c b/src/mesh/generated/cannedmessages.pb.c index e36eff981..e50dc685c 100644 --- a/src/mesh/generated/cannedmessages.pb.c +++ b/src/mesh/generated/cannedmessages.pb.c @@ -6,7 +6,7 @@ #error Regenerate this file with the current version of nanopb generator. #endif -PB_BIND(CannedMessagePluginConfig, CannedMessagePluginConfig, 2) +PB_BIND(CannedMessageModuleConfig, CannedMessageModuleConfig, 2) diff --git a/src/mesh/generated/cannedmessages.pb.h b/src/mesh/generated/cannedmessages.pb.h index ec8a42123..c6d6c86ff 100644 --- a/src/mesh/generated/cannedmessages.pb.h +++ b/src/mesh/generated/cannedmessages.pb.h @@ -10,12 +10,12 @@ #endif /* Struct definitions */ -typedef struct _CannedMessagePluginConfig { +typedef struct _CannedMessageModuleConfig { char messagesPart1[201]; char messagesPart2[201]; char messagesPart3[201]; char messagesPart4[201]; -} CannedMessagePluginConfig; +} CannedMessageModuleConfig; #ifdef __cplusplus @@ -23,31 +23,31 @@ extern "C" { #endif /* Initializer values for message structs */ -#define CannedMessagePluginConfig_init_default {"", "", "", ""} -#define CannedMessagePluginConfig_init_zero {"", "", "", ""} +#define CannedMessageModuleConfig_init_default {"", "", "", ""} +#define CannedMessageModuleConfig_init_zero {"", "", "", ""} /* Field tags (for use in manual encoding/decoding) */ -#define CannedMessagePluginConfig_messagesPart1_tag 11 -#define CannedMessagePluginConfig_messagesPart2_tag 12 -#define CannedMessagePluginConfig_messagesPart3_tag 13 -#define CannedMessagePluginConfig_messagesPart4_tag 14 +#define CannedMessageModuleConfig_messagesPart1_tag 11 +#define CannedMessageModuleConfig_messagesPart2_tag 12 +#define CannedMessageModuleConfig_messagesPart3_tag 13 +#define CannedMessageModuleConfig_messagesPart4_tag 14 /* Struct field encoding specification for nanopb */ -#define CannedMessagePluginConfig_FIELDLIST(X, a) \ +#define CannedMessageModuleConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, messagesPart1, 11) \ X(a, STATIC, SINGULAR, STRING, messagesPart2, 12) \ X(a, STATIC, SINGULAR, STRING, messagesPart3, 13) \ X(a, STATIC, SINGULAR, STRING, messagesPart4, 14) -#define CannedMessagePluginConfig_CALLBACK NULL -#define CannedMessagePluginConfig_DEFAULT NULL +#define CannedMessageModuleConfig_CALLBACK NULL +#define CannedMessageModuleConfig_DEFAULT NULL -extern const pb_msgdesc_t CannedMessagePluginConfig_msg; +extern const pb_msgdesc_t CannedMessageModuleConfig_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define CannedMessagePluginConfig_fields &CannedMessagePluginConfig_msg +#define CannedMessageModuleConfig_fields &CannedMessageModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define CannedMessagePluginConfig_size 812 +#define CannedMessageModuleConfig_size 812 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 0289e06c3..c1467c5b1 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -14,7 +14,7 @@ static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto"; -CannedMessagePluginConfig cannedMessagePluginConfig; +CannedMessageModuleConfig cannedMessageModuleConfig; CannedMessagePlugin *cannedMessagePlugin; @@ -56,16 +56,16 @@ int CannedMessagePlugin::splitConfiguredMessages() // collect all the message parts strcpy( this->messageStore, - cannedMessagePluginConfig.messagesPart1); + cannedMessageModuleConfig.messagesPart1); strcat( this->messageStore, - cannedMessagePluginConfig.messagesPart2); + cannedMessageModuleConfig.messagesPart2); strcat( this->messageStore, - cannedMessagePluginConfig.messagesPart3); + cannedMessageModuleConfig.messagesPart3); strcat( this->messageStore, - cannedMessagePluginConfig.messagesPart4); + cannedMessageModuleConfig.messagesPart4); // The first message points to the beginning of the store. this->messages[messageIndex++] = @@ -315,7 +315,7 @@ void CannedMessagePlugin::drawFrame( void CannedMessagePlugin::loadProtoForPlugin() { - if (!loadProto(cannedMessagesConfigFile, CannedMessagePluginConfig_size, sizeof(cannedMessagesConfigFile), CannedMessagePluginConfig_fields, &cannedMessagePluginConfig)) { + if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) { installDefaultCannedMessagePluginConfig(); } } @@ -334,7 +334,7 @@ bool CannedMessagePlugin::saveProtoForPlugin() FS.mkdir("/prefs"); #endif - okay &= saveProto(cannedMessagesConfigFile, CannedMessagePluginConfig_size, sizeof(CannedMessagePluginConfig), CannedMessagePluginConfig_fields, &cannedMessagePluginConfig); + okay &= saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(CannedMessageModuleConfig), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig); return okay; } @@ -344,10 +344,10 @@ bool CannedMessagePlugin::saveProtoForPlugin() */ void CannedMessagePlugin::installDefaultCannedMessagePluginConfig() { - memset(cannedMessagePluginConfig.messagesPart1, 0, sizeof(cannedMessagePluginConfig.messagesPart1)); - memset(cannedMessagePluginConfig.messagesPart2, 0, sizeof(cannedMessagePluginConfig.messagesPart2)); - memset(cannedMessagePluginConfig.messagesPart3, 0, sizeof(cannedMessagePluginConfig.messagesPart3)); - memset(cannedMessagePluginConfig.messagesPart4, 0, sizeof(cannedMessagePluginConfig.messagesPart4)); + memset(cannedMessageModuleConfig.messagesPart1, 0, sizeof(cannedMessageModuleConfig.messagesPart1)); + memset(cannedMessageModuleConfig.messagesPart2, 0, sizeof(cannedMessageModuleConfig.messagesPart2)); + memset(cannedMessageModuleConfig.messagesPart3, 0, sizeof(cannedMessageModuleConfig.messagesPart3)); + memset(cannedMessageModuleConfig.messagesPart4, 0, sizeof(cannedMessageModuleConfig.messagesPart4)); } /** @@ -365,55 +365,55 @@ AdminMessageHandleResult CannedMessagePlugin::handleAdminMessageForPlugin( AdminMessageHandleResult result; switch (request->which_variant) { - case AdminMessage_get_canned_message_plugin_part1_request_tag: + case AdminMessage_get_canned_message_module_part1_request_tag: DEBUG_MSG("Client is getting radio canned message part1\n"); this->handleGetCannedMessagePluginPart1(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; - case AdminMessage_get_canned_message_plugin_part2_request_tag: + case AdminMessage_get_canned_message_module_part2_request_tag: DEBUG_MSG("Client is getting radio canned message part2\n"); this->handleGetCannedMessagePluginPart2(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; - case AdminMessage_get_canned_message_plugin_part3_request_tag: + case AdminMessage_get_canned_message_module_part3_request_tag: DEBUG_MSG("Client is getting radio canned message part3\n"); this->handleGetCannedMessagePluginPart3(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; - case AdminMessage_get_canned_message_plugin_part4_request_tag: + case AdminMessage_get_canned_message_module_part4_request_tag: DEBUG_MSG("Client is getting radio canned message part4\n"); this->handleGetCannedMessagePluginPart4(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; - case AdminMessage_set_canned_message_plugin_part1_tag: + case AdminMessage_set_canned_message_module_part1_tag: DEBUG_MSG("Client is setting radio canned message part 1\n"); this->handleSetCannedMessagePluginPart1( - request->set_canned_message_plugin_part1); + request->set_canned_message_module_part1); result = AdminMessageHandleResult::HANDLED; break; - case AdminMessage_set_canned_message_plugin_part2_tag: + case AdminMessage_set_canned_message_module_part2_tag: DEBUG_MSG("Client is setting radio canned message part 2\n"); this->handleSetCannedMessagePluginPart2( - request->set_canned_message_plugin_part2); + request->set_canned_message_module_part2); result = AdminMessageHandleResult::HANDLED; break; - case AdminMessage_set_canned_message_plugin_part3_tag: + case AdminMessage_set_canned_message_module_part3_tag: DEBUG_MSG("Client is setting radio canned message part 3\n"); this->handleSetCannedMessagePluginPart3( - request->set_canned_message_plugin_part3); + request->set_canned_message_module_part3); result = AdminMessageHandleResult::HANDLED; break; - case AdminMessage_set_canned_message_plugin_part4_tag: + case AdminMessage_set_canned_message_module_part4_tag: DEBUG_MSG("Client is setting radio canned message part 4\n"); this->handleSetCannedMessagePluginPart4( - request->set_canned_message_plugin_part4); + request->set_canned_message_module_part4); result = AdminMessageHandleResult::HANDLED; break; @@ -430,10 +430,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart1( DEBUG_MSG("*** handleGetCannedMessagePluginPart1\n"); assert(req.decoded.want_response); - response->which_variant = AdminMessage_get_canned_message_plugin_part1_response_tag; + response->which_variant = AdminMessage_get_canned_message_module_part1_response_tag; strcpy( - response->get_canned_message_plugin_part1_response, - cannedMessagePluginConfig.messagesPart1); + response->get_canned_message_module_part1_response, + cannedMessageModuleConfig.messagesPart1); } void CannedMessagePlugin::handleGetCannedMessagePluginPart2( @@ -442,10 +442,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart2( DEBUG_MSG("*** handleGetCannedMessagePluginPart2\n"); assert(req.decoded.want_response); - response->which_variant = AdminMessage_get_canned_message_plugin_part2_response_tag; + response->which_variant = AdminMessage_get_canned_message_module_part2_response_tag; strcpy( - response->get_canned_message_plugin_part2_response, - cannedMessagePluginConfig.messagesPart2); + response->get_canned_message_module_part2_response, + cannedMessageModuleConfig.messagesPart2); } void CannedMessagePlugin::handleGetCannedMessagePluginPart3( @@ -454,10 +454,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart3( DEBUG_MSG("*** handleGetCannedMessagePluginPart3\n"); assert(req.decoded.want_response); - response->which_variant = AdminMessage_get_canned_message_plugin_part3_response_tag; + response->which_variant = AdminMessage_get_canned_message_module_part3_response_tag; strcpy( - response->get_canned_message_plugin_part3_response, - cannedMessagePluginConfig.messagesPart3); + response->get_canned_message_module_part3_response, + cannedMessageModuleConfig.messagesPart3); } void CannedMessagePlugin::handleGetCannedMessagePluginPart4( @@ -466,10 +466,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart4( DEBUG_MSG("*** handleGetCannedMessagePluginPart4\n"); assert(req.decoded.want_response); - response->which_variant = AdminMessage_get_canned_message_plugin_part4_response_tag; + response->which_variant = AdminMessage_get_canned_message_module_part4_response_tag; strcpy( - response->get_canned_message_plugin_part4_response, - cannedMessagePluginConfig.messagesPart4); + response->get_canned_message_module_part4_response, + cannedMessageModuleConfig.messagesPart4); } void CannedMessagePlugin::handleSetCannedMessagePluginPart1(const char *from_msg) @@ -478,8 +478,8 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart1(const char *from_msg if (*from_msg) { - changed |= strcmp(cannedMessagePluginConfig.messagesPart1, from_msg); - strcpy(cannedMessagePluginConfig.messagesPart1, from_msg); + changed |= strcmp(cannedMessageModuleConfig.messagesPart1, from_msg); + strcpy(cannedMessageModuleConfig.messagesPart1, from_msg); DEBUG_MSG("*** from_msg.text:%s\n", from_msg); } @@ -495,8 +495,8 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart2(const char *from_msg if (*from_msg) { - changed |= strcmp(cannedMessagePluginConfig.messagesPart2, from_msg); - strcpy(cannedMessagePluginConfig.messagesPart2, from_msg); + changed |= strcmp(cannedMessageModuleConfig.messagesPart2, from_msg); + strcpy(cannedMessageModuleConfig.messagesPart2, from_msg); } if (changed) @@ -511,8 +511,8 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart3(const char *from_msg if (*from_msg) { - changed |= strcmp(cannedMessagePluginConfig.messagesPart3, from_msg); - strcpy(cannedMessagePluginConfig.messagesPart3, from_msg); + changed |= strcmp(cannedMessageModuleConfig.messagesPart3, from_msg); + strcpy(cannedMessageModuleConfig.messagesPart3, from_msg); } if (changed) @@ -527,8 +527,8 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart4(const char *from_msg if (*from_msg) { - changed |= strcmp(cannedMessagePluginConfig.messagesPart4, from_msg); - strcpy(cannedMessagePluginConfig.messagesPart4, from_msg); + changed |= strcmp(cannedMessageModuleConfig.messagesPart4, from_msg); + strcpy(cannedMessageModuleConfig.messagesPart4, from_msg); } if (changed) From 24556f2803856d60921d131c2a374e21c4dc7ff6 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 01:20:23 -0800 Subject: [PATCH 67/93] CannedMessages from plugin to module --- src/modules/CannedMessageModule.cpp | 90 ++++++++++++++--------------- src/modules/CannedMessageModule.h | 36 ++++++------ src/modules/Modules.cpp | 2 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index c1467c5b1..9ad96d830 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -16,27 +16,27 @@ static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto"; CannedMessageModuleConfig cannedMessageModuleConfig; -CannedMessagePlugin *cannedMessagePlugin; +CannedMessageModule *cannedMessageModule; // TODO: move it into NodeDB.h! extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct); extern bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct); -CannedMessagePlugin::CannedMessagePlugin() +CannedMessageModule::CannedMessageModule() : SinglePortPlugin("canned", PortNum_TEXT_MESSAGE_APP), - concurrency::OSThread("CannedMessagePlugin") + concurrency::OSThread("CannedMessageModule") { if (radioConfig.preferences.canned_message_module_enabled) { this->loadProtoForPlugin(); if(this->splitConfiguredMessages() <= 0) { - DEBUG_MSG("CannedMessagePlugin: No messages are configured. Plugin is disabled\n"); + DEBUG_MSG("CannedMessageModule: No messages are configured. Plugin is disabled\n"); this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED; } else { - DEBUG_MSG("CannedMessagePlugin is enabled\n"); + DEBUG_MSG("CannedMessageModule is enabled\n"); this->inputObserver.observe(inputBroker); } } @@ -48,7 +48,7 @@ CannedMessagePlugin::CannedMessagePlugin() * * @return int Returns the number of messages found. */ -int CannedMessagePlugin::splitConfiguredMessages() +int CannedMessageModule::splitConfiguredMessages() { int messageIndex = 0; int i = 0; @@ -110,7 +110,7 @@ int CannedMessagePlugin::splitConfiguredMessages() return this->messagesCount; } -int CannedMessagePlugin::handleInputEvent(const InputEvent *event) +int CannedMessageModule::handleInputEvent(const InputEvent *event) { if ( (strlen(radioConfig.preferences.canned_message_module_allow_input_source) > 0) && @@ -153,7 +153,7 @@ int CannedMessagePlugin::handleInputEvent(const InputEvent *event) return 0; } -void CannedMessagePlugin::sendText(NodeNum dest, +void CannedMessageModule::sendText(NodeNum dest, const char* message, bool wantReplies) { @@ -175,7 +175,7 @@ void CannedMessagePlugin::sendText(NodeNum dest, service.sendToMesh(p); } -int32_t CannedMessagePlugin::runOnce() +int32_t CannedMessageModule::runOnce() { if ((!radioConfig.preferences.canned_message_module_enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) @@ -245,19 +245,19 @@ int32_t CannedMessagePlugin::runOnce() return 30000; // TODO: should return MAX_VAL } -const char* CannedMessagePlugin::getCurrentMessage() +const char* CannedMessageModule::getCurrentMessage() { return this->messages[this->currentMessageIndex]; } -const char* CannedMessagePlugin::getPrevMessage() +const char* CannedMessageModule::getPrevMessage() { return this->messages[this->getPrevIndex()]; } -const char* CannedMessagePlugin::getNextMessage() +const char* CannedMessageModule::getNextMessage() { return this->messages[this->getNextIndex()]; } -bool CannedMessagePlugin::shouldDraw() +bool CannedMessageModule::shouldDraw() { if (!radioConfig.preferences.canned_message_module_enabled) { @@ -266,7 +266,7 @@ bool CannedMessagePlugin::shouldDraw() return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE); } -int CannedMessagePlugin::getNextIndex() +int CannedMessageModule::getNextIndex() { if (this->currentMessageIndex >= (this->messagesCount -1)) { @@ -278,7 +278,7 @@ int CannedMessagePlugin::getNextIndex() } } -int CannedMessagePlugin::getPrevIndex() +int CannedMessageModule::getPrevIndex() { if (this->currentMessageIndex <= 0) { @@ -290,12 +290,12 @@ int CannedMessagePlugin::getPrevIndex() } } -void CannedMessagePlugin::drawFrame( +void CannedMessageModule::drawFrame( OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { displayedNodeNum = 0; // Not currently showing a node pane - if (cannedMessagePlugin->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) + if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_MEDIUM); @@ -305,18 +305,18 @@ void CannedMessagePlugin::drawFrame( { display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_SMALL); - display->drawString(0 + x, 0 + y, cannedMessagePlugin->getPrevMessage()); + display->drawString(0 + x, 0 + y, cannedMessageModule->getPrevMessage()); display->setFont(FONT_MEDIUM); - display->drawString(0 + x, 0 + y + 8, cannedMessagePlugin->getCurrentMessage()); + display->drawString(0 + x, 0 + y + 8, cannedMessageModule->getCurrentMessage()); display->setFont(FONT_SMALL); - display->drawString(0 + x, 0 + y + 24, cannedMessagePlugin->getNextMessage()); + display->drawString(0 + x, 0 + y + 24, cannedMessageModule->getNextMessage()); } } -void CannedMessagePlugin::loadProtoForPlugin() +void CannedMessageModule::loadProtoForPlugin() { if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) { - installDefaultCannedMessagePluginConfig(); + installDefaultCannedMessageModuleConfig(); } } @@ -326,7 +326,7 @@ void CannedMessagePlugin::loadProtoForPlugin() * @return true On success. * @return false On error. */ -bool CannedMessagePlugin::saveProtoForPlugin() +bool CannedMessageModule::saveProtoForPlugin() { bool okay = true; @@ -342,7 +342,7 @@ bool CannedMessagePlugin::saveProtoForPlugin() /** * @brief Fill configuration with default values. */ -void CannedMessagePlugin::installDefaultCannedMessagePluginConfig() +void CannedMessageModule::installDefaultCannedMessageModuleConfig() { memset(cannedMessageModuleConfig.messagesPart1, 0, sizeof(cannedMessageModuleConfig.messagesPart1)); memset(cannedMessageModuleConfig.messagesPart2, 0, sizeof(cannedMessageModuleConfig.messagesPart2)); @@ -359,7 +359,7 @@ void CannedMessagePlugin::installDefaultCannedMessagePluginConfig() * @return AdminMessageHandleResult HANDLED if message was handled * HANDLED_WITH_RESULT if a result is also prepared. */ -AdminMessageHandleResult CannedMessagePlugin::handleAdminMessageForPlugin( +AdminMessageHandleResult CannedMessageModule::handleAdminMessageForPlugin( const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { AdminMessageHandleResult result; @@ -367,52 +367,52 @@ AdminMessageHandleResult CannedMessagePlugin::handleAdminMessageForPlugin( switch (request->which_variant) { case AdminMessage_get_canned_message_module_part1_request_tag: DEBUG_MSG("Client is getting radio canned message part1\n"); - this->handleGetCannedMessagePluginPart1(mp, response); + this->handleGetCannedMessageModulePart1(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; case AdminMessage_get_canned_message_module_part2_request_tag: DEBUG_MSG("Client is getting radio canned message part2\n"); - this->handleGetCannedMessagePluginPart2(mp, response); + this->handleGetCannedMessageModulePart2(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; case AdminMessage_get_canned_message_module_part3_request_tag: DEBUG_MSG("Client is getting radio canned message part3\n"); - this->handleGetCannedMessagePluginPart3(mp, response); + this->handleGetCannedMessageModulePart3(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; case AdminMessage_get_canned_message_module_part4_request_tag: DEBUG_MSG("Client is getting radio canned message part4\n"); - this->handleGetCannedMessagePluginPart4(mp, response); + this->handleGetCannedMessageModulePart4(mp, response); result = AdminMessageHandleResult::HANDLED_WITH_RESPONSE; break; case AdminMessage_set_canned_message_module_part1_tag: DEBUG_MSG("Client is setting radio canned message part 1\n"); - this->handleSetCannedMessagePluginPart1( + this->handleSetCannedMessageModulePart1( request->set_canned_message_module_part1); result = AdminMessageHandleResult::HANDLED; break; case AdminMessage_set_canned_message_module_part2_tag: DEBUG_MSG("Client is setting radio canned message part 2\n"); - this->handleSetCannedMessagePluginPart2( + this->handleSetCannedMessageModulePart2( request->set_canned_message_module_part2); result = AdminMessageHandleResult::HANDLED; break; case AdminMessage_set_canned_message_module_part3_tag: DEBUG_MSG("Client is setting radio canned message part 3\n"); - this->handleSetCannedMessagePluginPart3( + this->handleSetCannedMessageModulePart3( request->set_canned_message_module_part3); result = AdminMessageHandleResult::HANDLED; break; case AdminMessage_set_canned_message_module_part4_tag: DEBUG_MSG("Client is setting radio canned message part 4\n"); - this->handleSetCannedMessagePluginPart4( + this->handleSetCannedMessageModulePart4( request->set_canned_message_module_part4); result = AdminMessageHandleResult::HANDLED; break; @@ -424,10 +424,10 @@ AdminMessageHandleResult CannedMessagePlugin::handleAdminMessageForPlugin( return result; } -void CannedMessagePlugin::handleGetCannedMessagePluginPart1( +void CannedMessageModule::handleGetCannedMessageModulePart1( const MeshPacket &req, AdminMessage *response) { - DEBUG_MSG("*** handleGetCannedMessagePluginPart1\n"); + DEBUG_MSG("*** handleGetCannedMessageModulePart1\n"); assert(req.decoded.want_response); response->which_variant = AdminMessage_get_canned_message_module_part1_response_tag; @@ -436,10 +436,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart1( cannedMessageModuleConfig.messagesPart1); } -void CannedMessagePlugin::handleGetCannedMessagePluginPart2( +void CannedMessageModule::handleGetCannedMessageModulePart2( const MeshPacket &req, AdminMessage *response) { - DEBUG_MSG("*** handleGetCannedMessagePluginPart2\n"); + DEBUG_MSG("*** handleGetCannedMessageModulePart2\n"); assert(req.decoded.want_response); response->which_variant = AdminMessage_get_canned_message_module_part2_response_tag; @@ -448,10 +448,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart2( cannedMessageModuleConfig.messagesPart2); } -void CannedMessagePlugin::handleGetCannedMessagePluginPart3( +void CannedMessageModule::handleGetCannedMessageModulePart3( const MeshPacket &req, AdminMessage *response) { - DEBUG_MSG("*** handleGetCannedMessagePluginPart3\n"); + DEBUG_MSG("*** handleGetCannedMessageModulePart3\n"); assert(req.decoded.want_response); response->which_variant = AdminMessage_get_canned_message_module_part3_response_tag; @@ -460,10 +460,10 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart3( cannedMessageModuleConfig.messagesPart3); } -void CannedMessagePlugin::handleGetCannedMessagePluginPart4( +void CannedMessageModule::handleGetCannedMessageModulePart4( const MeshPacket &req, AdminMessage *response) { - DEBUG_MSG("*** handleGetCannedMessagePluginPart4\n"); + DEBUG_MSG("*** handleGetCannedMessageModulePart4\n"); assert(req.decoded.want_response); response->which_variant = AdminMessage_get_canned_message_module_part4_response_tag; @@ -472,7 +472,7 @@ void CannedMessagePlugin::handleGetCannedMessagePluginPart4( cannedMessageModuleConfig.messagesPart4); } -void CannedMessagePlugin::handleSetCannedMessagePluginPart1(const char *from_msg) +void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg) { int changed = 0; @@ -489,7 +489,7 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart1(const char *from_msg } } -void CannedMessagePlugin::handleSetCannedMessagePluginPart2(const char *from_msg) +void CannedMessageModule::handleSetCannedMessageModulePart2(const char *from_msg) { int changed = 0; @@ -505,7 +505,7 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart2(const char *from_msg } } -void CannedMessagePlugin::handleSetCannedMessagePluginPart3(const char *from_msg) +void CannedMessageModule::handleSetCannedMessageModulePart3(const char *from_msg) { int changed = 0; @@ -521,7 +521,7 @@ void CannedMessagePlugin::handleSetCannedMessagePluginPart3(const char *from_msg } } -void CannedMessagePlugin::handleSetCannedMessagePluginPart4(const char *from_msg) +void CannedMessageModule::handleSetCannedMessageModulePart4(const char *from_msg) { int changed = 0; diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 2cb6e0730..9b3211d14 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -2,7 +2,7 @@ #include "ProtobufPlugin.h" #include "input/InputBroker.h" -enum cannedMessagePluginRunState +enum cannedMessageModuleRunState { CANNED_MESSAGE_RUN_STATE_DISABLED, CANNED_MESSAGE_RUN_STATE_INACTIVE, @@ -16,20 +16,20 @@ enum cannedMessagePluginRunState #define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT 50 /** - * Sum of CannedMessagePluginConfig part sizes. + * Sum of CannedMessageModuleConfig part sizes. */ #define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 800 -class CannedMessagePlugin : +class CannedMessageModule : public SinglePortPlugin, public Observable, private concurrency::OSThread { - CallbackObserver inputObserver = - CallbackObserver( - this, &CannedMessagePlugin::handleInputEvent); + CallbackObserver inputObserver = + CallbackObserver( + this, &CannedMessageModule::handleInputEvent); public: - CannedMessagePlugin(); + CannedMessageModule(); const char* getCurrentMessage(); const char* getPrevMessage(); const char* getNextMessage(); @@ -38,15 +38,15 @@ class CannedMessagePlugin : void eventDown(); void eventSelect(); - void handleGetCannedMessagePluginPart1(const MeshPacket &req, AdminMessage *response); - void handleGetCannedMessagePluginPart2(const MeshPacket &req, AdminMessage *response); - void handleGetCannedMessagePluginPart3(const MeshPacket &req, AdminMessage *response); - void handleGetCannedMessagePluginPart4(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessageModulePart1(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessageModulePart2(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessageModulePart3(const MeshPacket &req, AdminMessage *response); + void handleGetCannedMessageModulePart4(const MeshPacket &req, AdminMessage *response); - void handleSetCannedMessagePluginPart1(const char *from_msg); - void handleSetCannedMessagePluginPart2(const char *from_msg); - void handleSetCannedMessagePluginPart3(const char *from_msg); - void handleSetCannedMessagePluginPart4(const char *from_msg); + void handleSetCannedMessageModulePart1(const char *from_msg); + void handleSetCannedMessageModulePart2(const char *from_msg); + void handleSetCannedMessageModulePart3(const char *from_msg); + void handleSetCannedMessageModulePart4(const char *from_msg); protected: @@ -72,10 +72,10 @@ class CannedMessagePlugin : void loadProtoForPlugin(); bool saveProtoForPlugin(); - void installDefaultCannedMessagePluginConfig(); + void installDefaultCannedMessageModuleConfig(); int currentMessageIndex = -1; - cannedMessagePluginRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE+1]; char *messages[CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT]; @@ -83,4 +83,4 @@ class CannedMessagePlugin : unsigned long lastTouchMillis = 0; }; -extern CannedMessagePlugin *cannedMessagePlugin; +extern CannedMessageModule *cannedMessageModule; diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 1dfad5657..48e94d0cf 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -37,7 +37,7 @@ void setupPlugins() new ReplyPlugin(); rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); rotaryEncoderInterruptImpl1->init(); - cannedMessagePlugin = new CannedMessagePlugin(); + cannedMessageModule = new CannedMessageModule(); #ifndef PORTDUINO new TelemetryPlugin(); #endif From a83cfffd3a598aeac13d574f28928969aadc088b Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 01:27:17 -0800 Subject: [PATCH 68/93] Rename plugins in /esp32 --- src/mesh/NodeDB.cpp | 2 +- src/modules/Modules.cpp | 6 +++--- .../esp32/{RangeTestPlugin.cpp => RangeTestModule.cpp} | 2 +- src/modules/esp32/{RangeTestPlugin.h => RangeTestModule.h} | 0 src/modules/esp32/{SerialPlugin.cpp => SerialModule.cpp} | 4 ++-- src/modules/esp32/{SerialPlugin.h => SerialModule.h} | 0 .../{StoreForwardPlugin.cpp => StoreForwardModule.cpp} | 2 +- .../esp32/{StoreForwardPlugin.h => StoreForwardModule.h} | 0 8 files changed, 8 insertions(+), 8 deletions(-) rename src/modules/esp32/{RangeTestPlugin.cpp => RangeTestModule.cpp} (99%) rename src/modules/esp32/{RangeTestPlugin.h => RangeTestModule.h} (100%) rename src/modules/esp32/{SerialPlugin.cpp => SerialModule.cpp} (98%) rename src/modules/esp32/{SerialPlugin.h => SerialModule.h} (100%) rename src/modules/esp32/{StoreForwardPlugin.cpp => StoreForwardModule.cpp} (99%) rename src/modules/esp32/{StoreForwardPlugin.h => StoreForwardModule.h} (100%) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index fd7203f7d..13e3812af 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -19,7 +19,7 @@ #ifndef NO_ESP32 #include "mesh/http/WiFiAPClient.h" -#include "modules/esp32/StoreForwardPlugin.h" +#include "modules/esp32/StoreForwardModule.h" #include #include #endif diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 48e94d0cf..52528e35d 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -14,9 +14,9 @@ #include "modules/Telemetry/Telemetry.h" #endif #ifndef NO_ESP32 -#include "modules/esp32/RangeTestPlugin.h" -#include "modules/esp32/SerialPlugin.h" -#include "modules/esp32/StoreForwardPlugin.h" +#include "modules/esp32/RangeTestModule.h" +#include "modules/esp32/SerialModule.h" +#include "modules/esp32/StoreForwardModule.h" #endif /** diff --git a/src/modules/esp32/RangeTestPlugin.cpp b/src/modules/esp32/RangeTestModule.cpp similarity index 99% rename from src/modules/esp32/RangeTestPlugin.cpp rename to src/modules/esp32/RangeTestModule.cpp index 59ab48767..cf2a38e35 100644 --- a/src/modules/esp32/RangeTestPlugin.cpp +++ b/src/modules/esp32/RangeTestModule.cpp @@ -1,4 +1,4 @@ -#include "RangeTestPlugin.h" +#include "RangeTestModule.h" #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" diff --git a/src/modules/esp32/RangeTestPlugin.h b/src/modules/esp32/RangeTestModule.h similarity index 100% rename from src/modules/esp32/RangeTestPlugin.h rename to src/modules/esp32/RangeTestModule.h diff --git a/src/modules/esp32/SerialPlugin.cpp b/src/modules/esp32/SerialModule.cpp similarity index 98% rename from src/modules/esp32/SerialPlugin.cpp rename to src/modules/esp32/SerialModule.cpp index 2687eff27..849d1cd7b 100644 --- a/src/modules/esp32/SerialPlugin.cpp +++ b/src/modules/esp32/SerialModule.cpp @@ -1,5 +1,5 @@ #include "configuration.h" -#include "SerialPlugin.h" +#include "SerialModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" @@ -27,7 +27,7 @@ TXD 15 3) Set serialmodule_timeout to the amount of time to wait before we consider your packet as "done". - 4) (Optional) In SerialPlugin.h set the port to PortNum_TEXT_MESSAGE_APP if you want to + 4) (Optional) In SerialModule.h set the port to PortNum_TEXT_MESSAGE_APP if you want to send messages to/from the general text message channel. 5) Connect to your device over the serial interface at 38400 8N1. 6) Send a packet up to 240 bytes in length. This will get relayed over the mesh network. diff --git a/src/modules/esp32/SerialPlugin.h b/src/modules/esp32/SerialModule.h similarity index 100% rename from src/modules/esp32/SerialPlugin.h rename to src/modules/esp32/SerialModule.h diff --git a/src/modules/esp32/StoreForwardPlugin.cpp b/src/modules/esp32/StoreForwardModule.cpp similarity index 99% rename from src/modules/esp32/StoreForwardPlugin.cpp rename to src/modules/esp32/StoreForwardModule.cpp index b061c3bfe..3aedcdf3a 100644 --- a/src/modules/esp32/StoreForwardPlugin.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -1,4 +1,4 @@ -#include "StoreForwardPlugin.h" +#include "StoreForwardModule.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" diff --git a/src/modules/esp32/StoreForwardPlugin.h b/src/modules/esp32/StoreForwardModule.h similarity index 100% rename from src/modules/esp32/StoreForwardPlugin.h rename to src/modules/esp32/StoreForwardModule.h From 3c5e49d8f491da726d5227bdc933e972878f908d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 01:49:24 -0800 Subject: [PATCH 69/93] More renaming plugin to module --- geeksville-private/TODO.md | 4 +-- src/graphics/Screen.cpp | 20 ++++++------ src/main.cpp | 2 +- src/mesh/MeshPlugin.cpp | 34 +++++++++---------- src/mesh/MeshPlugin.h | 6 ++-- src/modules/CannedMessageModule.cpp | 2 +- src/modules/CannedMessageModule.h | 8 ++--- src/modules/ExternalNotificationModule.cpp | 38 +++++++++++----------- src/modules/ExternalNotificationModule.h | 6 ++-- src/modules/Modules.cpp | 7 ++-- src/modules/Modules.h | 2 +- src/modules/esp32/RangeTestModule.cpp | 20 ++++++------ src/modules/esp32/RangeTestModule.h | 14 ++++---- src/modules/esp32/SerialModule.cpp | 20 ++++++------ 14 files changed, 91 insertions(+), 92 deletions(-) diff --git a/geeksville-private/TODO.md b/geeksville-private/TODO.md index 5d9dfa7a1..3c43508e4 100644 --- a/geeksville-private/TODO.md +++ b/geeksville-private/TODO.md @@ -71,7 +71,7 @@ You probably don't care about this section - skip to the next one. * nrf52 should preserve local time across reset * cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later * nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger) -* DONE call RouterPlugin for *all* packets - not just Router packets +* DONE call RouterModule for *all* packets - not just Router packets * DONE generate channel hash from the name of the channel+the psk (not just one or the other) * DONE send a hint that can be used to select which channel to try and hash against with each message * DONE remove deprecated @@ -188,7 +188,7 @@ For app cleanup: * DONE test python side handle new position/user messages * DONE make a gpio example. --gpiowrb 4 1, --gpiord 0x444, --gpiowatch 0x3ff * DONE fix position sending to use new module -* DONE Add SinglePortNumPlugin - as the new most useful baseclass +* DONE Add SinglePortNumModule - as the new most useful baseclass * DONE move positions into regular data packets (use new app framework) * DONE move user info into regular data packets (use new app framework) * DONE test that positions, text messages and user info still work diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 3d047186b..237e08c9f 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -178,7 +178,7 @@ static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - uint8_t plugin_frame; + uint8_t module_frame; // there's a little but in the UI transition code // where it invokes the function at the correct offset // in the array of "drawScreen" functions; however, @@ -187,14 +187,14 @@ static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int if (state->frameState == IN_TRANSITION && state->transitionFrameRelationship == INCOMING) { // if we're transitioning from the end of the frame list back around to the first // frame, then we want this to be `0` - plugin_frame = state->transitionFrameTarget; + module_frame = state->transitionFrameTarget; } else { // otherwise, just display the module frame that's aligned with the current frame - plugin_frame = state->currentFrame; - // DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", plugin_frame); + module_frame = state->currentFrame; + // DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", module_frame); } - // DEBUG_MSG("Drawing Plugin Frame %d\n\n", plugin_frame); - MeshPlugin &pi = *pluginFrames.at(plugin_frame); + // DEBUG_MSG("Drawing Module Frame %d\n\n", module_frame); + MeshPlugin &pi = *pluginFrames.at(module_frame); pi.drawFrame(display, state, x, y); } @@ -988,12 +988,12 @@ void Screen::setFrames() size_t numframes = 0; - // put all of the plugin frames first. + // put all of the module frames first. // this is a little bit of a dirty hack; since we're going to call - // the same drawPluginFrame handler here for all of these plugin frames + // the same drawModuleFrame handler here for all of these module frames // and then we'll just assume that the state->currentFrame value - // is the same offset into the pluginFrames vector - // so that we can invoke the plugin's callback + // is the same offset into the moduleFrames vector + // so that we can invoke the module's callback for (auto i = pluginFrames.begin(); i != pluginFrames.end(); ++i) { normalFrames[numframes++] = drawPluginFrame; } diff --git a/src/main.cpp b/src/main.cpp index 24e60fc7d..f025d3dd2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -538,7 +538,7 @@ void setup() service.init(); // Now that the mesh service is created, create any modules - setupPlugins(); + setupModules(); // Do this after service.init (because that clears error_code) #ifdef AXP192_SLAVE_ADDRESS diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 9944954f7..48c081807 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -6,7 +6,7 @@ #include "modules/RoutingModule.h" #include -std::vector *MeshPlugin::plugins; +std::vector *MeshPlugin::modules; const MeshPacket *MeshPlugin::currentRequest; @@ -19,10 +19,10 @@ MeshPacket *MeshPlugin::currentReply; MeshPlugin::MeshPlugin(const char *_name) : name(_name) { // Can't trust static initalizer order, so we check each time - if (!plugins) - plugins = new std::vector(); + if (!modules) + modules = new std::vector(); - plugins->push_back(this); + modules->push_back(this); } void MeshPlugin::setup() {} @@ -80,7 +80,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) auto ourNodeNum = nodeDB.getNodeNum(); bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum; - for (auto i = plugins->begin(); i != plugins->end(); ++i) { + for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; pi.currentRequest = ∓ @@ -96,7 +96,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time if (wantsPacket) { - DEBUG_MSG("Plugin '%s' wantsPacket=%d\n", pi.name, wantsPacket); + DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket); pluginFound = true; @@ -137,9 +137,9 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) // any other node. if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) { pi.sendResponse(mp); - DEBUG_MSG("Plugin '%s' sent a response\n", pi.name); + DEBUG_MSG("Module '%s' sent a response\n", pi.name); } else { - DEBUG_MSG("Plugin '%s' considered\n", pi.name); + DEBUG_MSG("Module '%s' considered\n", pi.name); } // If the requester didn't ask for a response we might need to discard unused replies to prevent memory leaks @@ -150,7 +150,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) } if (handled == ProcessMessage::STOP) { - DEBUG_MSG("Plugin '%s' handled and skipped other processing\n", pi.name); + DEBUG_MSG("Module '%s' handled and skipped other processing\n", pi.name); break; } } @@ -226,11 +226,11 @@ std::vector MeshPlugin::GetMeshPluginsWithUIFrames() { std::vector pluginsWithUIFrames; - if (plugins) { - for (auto i = plugins->begin(); i != plugins->end(); ++i) { + if (modules) { + for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; if (pi.wantUIFrame()) { - DEBUG_MSG("Plugin wants a UI Frame\n"); + DEBUG_MSG("Module wants a UI Frame\n"); pluginsWithUIFrames.push_back(&pi); } } @@ -241,13 +241,13 @@ std::vector MeshPlugin::GetMeshPluginsWithUIFrames() void MeshPlugin::observeUIEvents( Observer *observer) { - if (plugins) { - for (auto i = plugins->begin(); i != plugins->end(); ++i) { + if (modules) { + for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; Observable *observable = pi.getUIFrameObservable(); if (observable != NULL) { - DEBUG_MSG("Plugin wants a UI Frame\n"); + DEBUG_MSG("Module wants a UI Frame\n"); observer->observe(observable); } } @@ -257,8 +257,8 @@ void MeshPlugin::observeUIEvents( AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED; - if (plugins) { - for (auto i = plugins->begin(); i != plugins->end(); ++i) { + if (modules) { + for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; AdminMessageHandleResult h = pi.handleAdminMessageForPlugin(mp, request, response); if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 7c323e9d8..047482308 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -54,7 +54,7 @@ typedef struct _UIFrameEvent { */ class MeshPlugin { - static std::vector *plugins; + static std::vector *modules; public: /** Constructor @@ -151,7 +151,7 @@ class MeshPlugin MeshPacket *allocErrorResponse(Routing_Error err, const MeshPacket *p); /** - * @brief An admin message arrived to AdminPlugin. Plugin was asked whether it want to handle the request. + * @brief An admin message arrived to AdminModule. Module was asked whether it want to handle the request. * * @param mp The mesh packet arrived. * @param request The AdminMessage request extracted from the packet. @@ -166,7 +166,7 @@ class MeshPlugin private: /** * If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow - * the RoutingPlugin to avoid sending redundant acks + * the RoutingModule to avoid sending redundant acks */ static MeshPacket *currentReply; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 9ad96d830..dbb12bd40 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -83,7 +83,7 @@ int CannedMessageModule::splitConfiguredMessages() messageIndex-1, this->messages[messageIndex-1]); // hit our max messages, bail - if (messageIndex >= CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT) + if (messageIndex >= CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT) { this->messagesCount = messageIndex; return this->messagesCount; diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 9b3211d14..c38c4aceb 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -14,11 +14,11 @@ enum cannedMessageModuleRunState }; -#define CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT 50 +#define CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT 50 /** * Sum of CannedMessageModuleConfig part sizes. */ -#define CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE 800 +#define CANNED_MESSAGE_MODULE_MESSAGES_SIZE 800 class CannedMessageModule : public SinglePortPlugin, @@ -77,8 +77,8 @@ class CannedMessageModule : int currentMessageIndex = -1; cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; - char messageStore[CANNED_MESSAGE_PLUGIN_MESSAGES_SIZE+1]; - char *messages[CANNED_MESSAGE_PLUGIN_MESSAGE_MAX_COUNT]; + char messageStore[CANNED_MESSAGE_MODULE_MESSAGES_SIZE+1]; + char *messages[CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT]; int messagesCount = 0; unsigned long lastTouchMillis = 0; }; diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index e64d86d01..d9f9f7d09 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -44,15 +44,15 @@ */ // Default configurations -#define EXT_NOTIFICATION_PLUGIN_OUTPUT EXT_NOTIFY_OUT -#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000 +#define EXT_NOTIFICATION_MODULE_OUTPUT EXT_NOTIFY_OUT +#define EXT_NOTIFICATION_MODULE_OUTPUT_MS 1000 #define ASCII_BELL 0x07 bool externalCurrentState = 0; uint32_t externalTurnedOn = 0; -int32_t ExternalNotificationPlugin::runOnce() +int32_t ExternalNotificationModule::runOnce() { /* Uncomment the preferences below if you want to use the module @@ -72,7 +72,7 @@ int32_t ExternalNotificationPlugin::runOnce() // If the output is turned on, turn it back off after the given period of time. if (externalTurnedOn + (radioConfig.preferences.ext_notification_module_output_ms ? radioConfig.preferences.ext_notification_module_output_ms - : EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) < + : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { DEBUG_MSG("Turning off external notification\n"); setExternalOff(); @@ -82,34 +82,34 @@ int32_t ExternalNotificationPlugin::runOnce() return (25); } -void ExternalNotificationPlugin::setExternalOn() +void ExternalNotificationModule::setExternalOn() { #ifdef EXT_NOTIFY_OUT externalCurrentState = 1; externalTurnedOn = millis(); digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output - : EXT_NOTIFICATION_PLUGIN_OUTPUT), + : EXT_NOTIFICATION_MODULE_OUTPUT), (radioConfig.preferences.ext_notification_module_active ? true : false)); #endif } -void ExternalNotificationPlugin::setExternalOff() +void ExternalNotificationModule::setExternalOff() { #ifdef EXT_NOTIFY_OUT externalCurrentState = 0; digitalWrite((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output - : EXT_NOTIFICATION_PLUGIN_OUTPUT), + : EXT_NOTIFICATION_MODULE_OUTPUT), (radioConfig.preferences.ext_notification_module_active ? false : true)); #endif } // -------- -ExternalNotificationPlugin::ExternalNotificationPlugin() - : SinglePortPlugin("ExternalNotificationPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread( - "ExternalNotificationPlugin") +ExternalNotificationModule::ExternalNotificationModule() + : SinglePortPlugin("ExternalNotificationModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread( + "ExternalNotificationModule") { // restrict to the admin channel for rx boundChannel = Channels::gpioChannel; @@ -118,7 +118,7 @@ ExternalNotificationPlugin::ExternalNotificationPlugin() #ifdef EXT_NOTIFY_OUT /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ @@ -132,24 +132,24 @@ ExternalNotificationPlugin::ExternalNotificationPlugin() if (radioConfig.preferences.ext_notification_module_enabled) { - DEBUG_MSG("Initializing External Notification Plugin\n"); + DEBUG_MSG("Initializing External Notification Module\n"); // Set the direction of a pin pinMode((radioConfig.preferences.ext_notification_module_output ? radioConfig.preferences.ext_notification_module_output - : EXT_NOTIFICATION_PLUGIN_OUTPUT), + : EXT_NOTIFICATION_MODULE_OUTPUT), OUTPUT); // Turn off the pin setExternalOff(); } else { - DEBUG_MSG("External Notification Plugin Disabled\n"); + DEBUG_MSG("External Notification Module Disabled\n"); enabled = false; } #endif #endif } -ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp) +ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 #ifdef EXT_NOTIFY_OUT @@ -162,7 +162,7 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp) // Need to know if and how this could be a problem. if (radioConfig.preferences.ext_notification_module_alert_bell) { auto &p = mp.decoded; - DEBUG_MSG("externalNotificationPlugin - Notification Bell\n"); + DEBUG_MSG("externalNotificationModule - Notification Bell\n"); for (int i = 0; i < p.payload.size; i++) { if (p.payload.bytes[i] == ASCII_BELL) { setExternalOn(); @@ -171,13 +171,13 @@ ProcessMessage ExternalNotificationPlugin::handleReceived(const MeshPacket &mp) } if (radioConfig.preferences.ext_notification_module_alert_message) { - DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n"); + DEBUG_MSG("externalNotificationModule - Notification Module\n"); setExternalOn(); } } } else { - DEBUG_MSG("External Notification Plugin Disabled\n"); + DEBUG_MSG("External Notification Module Disabled\n"); } #endif diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index dc8a1cb12..40593aa83 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -7,13 +7,13 @@ #include /* - * Radio interface for ExternalNotificationPlugin + * Radio interface for ExternalNotificationModule * */ -class ExternalNotificationPlugin : public SinglePortPlugin, private concurrency::OSThread +class ExternalNotificationModule : public SinglePortPlugin, private concurrency::OSThread { public: - ExternalNotificationPlugin(); + ExternalNotificationModule(); void setExternalOn(); void setExternalOff(); diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 52528e35d..e01b374b3 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -22,7 +22,7 @@ /** * Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else) */ -void setupPlugins() +void setupModules() { inputBroker = new InputBroker(); adminPlugin = new AdminPlugin(); @@ -48,12 +48,11 @@ void setupPlugins() Maintained by MC Hamster (Jm Casler) jm@casler.org */ new SerialPlugin(); - new ExternalNotificationPlugin(); + new ExternalNotificationModule(); - // rangeTestPlugin = new RangeTestPlugin(); storeForwardPlugin = new StoreForwardPlugin(); - new RangeTestPlugin(); + new RangeTestModule(); // new StoreForwardPlugin(); #endif diff --git a/src/modules/Modules.h b/src/modules/Modules.h index 79e6627d2..e34fc1eca 100644 --- a/src/modules/Modules.h +++ b/src/modules/Modules.h @@ -3,4 +3,4 @@ /** * Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else) */ -void setupPlugins(); \ No newline at end of file +void setupModules(); \ No newline at end of file diff --git a/src/modules/esp32/RangeTestModule.cpp b/src/modules/esp32/RangeTestModule.cpp index cf2a38e35..414b0c443 100644 --- a/src/modules/esp32/RangeTestModule.cpp +++ b/src/modules/esp32/RangeTestModule.cpp @@ -16,10 +16,10 @@ As a receiver, I can receive packets from multiple senders. These packets can be saved to the Filesystem. */ -RangeTestPlugin *rangeTestPlugin; -RangeTestPluginRadio *rangeTestPluginRadio; +RangeTestModule *rangeTestModule; +RangeTestModuleRadio *rangeTestModuleRadio; -RangeTestPlugin::RangeTestPlugin() : concurrency::OSThread("RangeTestPlugin") {} +RangeTestModule::RangeTestModule() : concurrency::OSThread("RangeTestModule") {} uint32_t packetSequence = 0; @@ -27,7 +27,7 @@ uint32_t packetSequence = 0; #define SEC_PER_HOUR 3600 #define SEC_PER_MIN 60 -int32_t RangeTestPlugin::runOnce() +int32_t RangeTestModule::runOnce() { #ifndef NO_ESP32 @@ -48,7 +48,7 @@ int32_t RangeTestPlugin::runOnce() if (radioConfig.preferences.range_test_module_enabled) { if (firstTime) { - rangeTestPluginRadio = new RangeTestPluginRadio(); + rangeTestModuleRadio = new RangeTestModuleRadio(); firstTime = 0; @@ -75,7 +75,7 @@ int32_t RangeTestPlugin::runOnce() // Only send packets if the channel is less than 25% utilized. if (airTime->channelUtilizationPercent() < 25) { - rangeTestPluginRadio->sendPayload(); + rangeTestModuleRadio->sendPayload(); } else { DEBUG_MSG("rangeTest - Channel utilization is >25 percent. Skipping this opportunity to send.\n"); } @@ -97,7 +97,7 @@ int32_t RangeTestPlugin::runOnce() return (INT32_MAX); } -MeshPacket *RangeTestPluginRadio::allocReply() +MeshPacket *RangeTestModuleRadio::allocReply() { auto reply = allocDataPacket(); // Allocate a packet for sending @@ -105,7 +105,7 @@ MeshPacket *RangeTestPluginRadio::allocReply() return reply; } -void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) +void RangeTestModuleRadio::sendPayload(NodeNum dest, bool wantReplies) { MeshPacket *p = allocReply(); p->to = dest; @@ -127,7 +127,7 @@ void RangeTestPluginRadio::sendPayload(NodeNum dest, bool wantReplies) powerFSM.trigger(EVENT_CONTACT_FROM_PHONE); } -ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp) +ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 @@ -183,7 +183,7 @@ ProcessMessage RangeTestPluginRadio::handleReceived(const MeshPacket &mp) return ProcessMessage::CONTINUE; // Let others look at this message also if they want } -bool RangeTestPluginRadio::appendFile(const MeshPacket &mp) +bool RangeTestModuleRadio::appendFile(const MeshPacket &mp) { auto &p = mp.decoded; diff --git a/src/modules/esp32/RangeTestModule.h b/src/modules/esp32/RangeTestModule.h index 5e7d7da16..23ef0aaf6 100644 --- a/src/modules/esp32/RangeTestModule.h +++ b/src/modules/esp32/RangeTestModule.h @@ -6,29 +6,29 @@ #include #include -class RangeTestPlugin : private concurrency::OSThread +class RangeTestModule : private concurrency::OSThread { bool firstTime = 1; public: - RangeTestPlugin(); + RangeTestModule(); protected: virtual int32_t runOnce() override; }; -extern RangeTestPlugin *rangeTestPlugin; +extern RangeTestModule *rangeTestModule; /* - * Radio interface for RangeTestPlugin + * Radio interface for RangeTestModule * */ -class RangeTestPluginRadio : public SinglePortPlugin +class RangeTestModuleRadio : public SinglePortPlugin { uint32_t lastRxID = 0; public: - RangeTestPluginRadio() : SinglePortPlugin("RangeTestPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + RangeTestModuleRadio() : SinglePortPlugin("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP) {} /** * Send our payload into the mesh @@ -55,4 +55,4 @@ class RangeTestPluginRadio : public SinglePortPlugin virtual ProcessMessage handleReceived(const MeshPacket &mp) override; }; -extern RangeTestPluginRadio *rangeTestPluginRadio; +extern RangeTestModuleRadio *rangeTestModuleRadio; diff --git a/src/modules/esp32/SerialModule.cpp b/src/modules/esp32/SerialModule.cpp index 849d1cd7b..c8b9914b1 100644 --- a/src/modules/esp32/SerialModule.cpp +++ b/src/modules/esp32/SerialModule.cpp @@ -48,11 +48,11 @@ #define RXD2 16 #define TXD2 17 -#define SERIALPLUGIN_RX_BUFFER 128 -#define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN -#define SERIALPLUGIN_TIMEOUT 250 -#define SERIALPLUGIN_BAUD 38400 -#define SERIALPLUGIN_ACK 1 +#define SERIALMODULE_RX_BUFFER 128 +#define SERIALMODULE_STRING_MAX Constants_DATA_PAYLOAD_LEN +#define SERIALMODULE_TIMEOUT 250 +#define SERIALMODULE_BAUD 38400 +#define SERIALMODULE_ACK 1 SerialPlugin *serialPlugin; SerialPluginRadio *serialPluginRadio; @@ -90,11 +90,11 @@ int32_t SerialPlugin::runOnce() DEBUG_MSG("Initializing serial peripheral interface\n"); if (radioConfig.preferences.serialmodule_rxd && radioConfig.preferences.serialmodule_txd) { - Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd, + Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, radioConfig.preferences.serialmodule_rxd, radioConfig.preferences.serialmodule_txd); } else { - Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); + Serial2.begin(SERIALMODULE_BAUD, SERIAL_8N1, RXD2, TXD2); } if (radioConfig.preferences.serialmodule_timeout) { @@ -102,10 +102,10 @@ int32_t SerialPlugin::runOnce() radioConfig.preferences.serialmodule_timeout); // Number of MS to wait to set the timeout for the string. } else { - Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. + Serial2.setTimeout(SERIALMODULE_TIMEOUT); // Number of MS to wait to set the timeout for the string. } - Serial2.setRxBufferSize(SERIALPLUGIN_RX_BUFFER); + Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER); serialPluginRadio = new SerialPluginRadio(); @@ -149,7 +149,7 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) p->to = dest; p->decoded.want_response = wantReplies; - p->want_ack = SERIALPLUGIN_ACK; + p->want_ack = SERIALMODULE_ACK; p->decoded.payload.size = strlen(serialStringChar); // You must specify how many bytes are in the reply memcpy(p->decoded.payload.bytes, serialStringChar, p->decoded.payload.size); From e53abbfb2bdaf21d65082b00649cce46009f5037 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 02:21:02 -0800 Subject: [PATCH 70/93] more rename plugin to module --- src/graphics/Screen.cpp | 16 +++--- src/mesh/MeshPlugin.cpp | 16 +++--- src/mesh/MeshPlugin.h | 2 +- src/mesh/MeshService.cpp | 14 ++--- src/mesh/MeshService.h | 2 +- src/mesh/Router.cpp | 2 +- src/mesh/Router.h | 4 +- src/modules/AdminModule.cpp | 16 +++--- src/modules/AdminModule.h | 8 +-- src/modules/CannedMessageModule.cpp | 20 +++---- src/modules/CannedMessageModule.h | 6 +-- src/modules/ModuleDev.h | 2 +- src/modules/Modules.cpp | 21 ++++---- src/modules/NodeInfoModule.cpp | 14 ++--- src/modules/NodeInfoModule.h | 6 +-- src/modules/PositionModule.cpp | 14 ++--- src/modules/PositionModule.h | 6 +-- src/modules/RemoteHardwareModule.cpp | 6 +-- src/modules/RemoteHardwareModule.h | 6 +-- src/modules/ReplyModule.cpp | 2 +- src/modules/ReplyModule.h | 4 +- src/modules/RoutingModule.cpp | 10 ++-- src/modules/RoutingModule.h | 6 +-- src/modules/Telemetry/Telemetry.cpp | 12 ++--- src/modules/Telemetry/Telemetry.h | 6 +-- src/modules/TextMessageModule.cpp | 4 +- src/modules/TextMessageModule.h | 6 +-- src/modules/esp32/RangeTestModule.cpp | 6 +-- src/modules/esp32/SerialModule.cpp | 28 +++++----- src/modules/esp32/SerialModule.h | 14 ++--- src/modules/esp32/StoreForwardModule.cpp | 66 ++++++++++++------------ src/modules/esp32/StoreForwardModule.h | 6 +-- variants/diy/v1/variant.h | 2 +- variants/diy/v1_1/variant.h | 2 +- variants/heltec_v2.1/variant.h | 2 +- variants/tbeam/variant.h | 2 +- variants/tbeam_v07/variant.h | 2 +- variants/tlora_v1/variant.h | 2 +- 38 files changed, 181 insertions(+), 182 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 237e08c9f..4e7fb0638 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -69,7 +69,7 @@ uint32_t dopThresholds[5] = {2000, 1000, 500, 200, 100}; // At some point, we're going to ask all of the modules if they would like to display a screen frame // we'll need to hold onto pointers for the modules that can draw a frame. -std::vector pluginFrames; +std::vector moduleFrames; // Stores the last 4 of our hardware ID, to make finding the device for pairing easier static char ourId[5]; @@ -194,7 +194,7 @@ static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int // DEBUG_MSG("Screen is not in transition. Frame: %d\n\n", module_frame); } // DEBUG_MSG("Drawing Module Frame %d\n\n", module_frame); - MeshPlugin &pi = *pluginFrames.at(module_frame); + MeshPlugin &pi = *moduleFrames.at(module_frame); pi.drawFrame(display, state, x, y); } @@ -824,8 +824,8 @@ void Screen::setup() powerStatusObserver.observe(&powerStatus->onNewStatus); gpsStatusObserver.observe(&gpsStatus->onNewStatus); nodeStatusObserver.observe(&nodeStatus->onNewStatus); - if (textMessagePlugin) - textMessageObserver.observe(textMessagePlugin); + if (textMessageModule) + textMessageObserver.observe(textMessageModule); // Modules can notify screen about refresh MeshPlugin::observeUIEvents(&uiFrameEventObserver); @@ -976,9 +976,9 @@ void Screen::setFrames() DEBUG_MSG("showing standard frames\n"); showingNormalScreen = true; - pluginFrames = MeshPlugin::GetMeshPluginsWithUIFrames(); - DEBUG_MSG("Showing %d module frames\n", pluginFrames.size()); - int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + pluginFrames.size(); + moduleFrames = MeshPlugin::GetMeshPluginsWithUIFrames(); + DEBUG_MSG("Showing %d module frames\n", moduleFrames.size()); + int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + moduleFrames.size(); DEBUG_MSG("Total frame count: %d\n", totalFrameCount); // We don't show the node info our our node (if we have it yet - we should) @@ -994,7 +994,7 @@ void Screen::setFrames() // and then we'll just assume that the state->currentFrame value // is the same offset into the moduleFrames vector // so that we can invoke the module's callback - for (auto i = pluginFrames.begin(); i != pluginFrames.end(); ++i) { + for (auto i = moduleFrames.begin(); i != moduleFrames.end(); ++i) { normalFrames[numframes++] = drawPluginFrame; } diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 48c081807..77d647562 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -69,7 +69,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket * void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) { // DEBUG_MSG("In call modules\n"); - bool pluginFound = false; + bool moduleFound = false; // We now allow **encrypted** packets to pass through the modules bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag; @@ -98,7 +98,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) if (wantsPacket) { DEBUG_MSG("Module '%s' wantsPacket=%d\n", pi.name, wantsPacket); - pluginFound = true; + moduleFound = true; /// received channel (or NULL if not decoded) Channel *ch = isDecoded ? &channels.getByIndex(mp.channel) : NULL; @@ -173,11 +173,11 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) // SECURITY NOTE! I considered sending back a different error code if we didn't find the psk (i.e. !isDecoded) // but opted NOT TO. Because it is not a good idea to let remote nodes 'probe' to find out which PSKs were "good" vs // bad. - routingPlugin->sendAckNak(Routing_Error_NO_RESPONSE, getFrom(&mp), mp.id, mp.channel); + routingModule->sendAckNak(Routing_Error_NO_RESPONSE, getFrom(&mp), mp.id, mp.channel); } } - if (!pluginFound) + if (!moduleFound) DEBUG_MSG("No modules interested in portnum=%d, src=%s\n", mp.decoded.portnum, (src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE"); @@ -225,17 +225,17 @@ void setReplyTo(MeshPacket *p, const MeshPacket &to) std::vector MeshPlugin::GetMeshPluginsWithUIFrames() { - std::vector pluginsWithUIFrames; + std::vector modulesWithUIFrames; if (modules) { for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; if (pi.wantUIFrame()) { DEBUG_MSG("Module wants a UI Frame\n"); - pluginsWithUIFrames.push_back(&pi); + modulesWithUIFrames.push_back(&pi); } } } - return pluginsWithUIFrames; + return modulesWithUIFrames; } void MeshPlugin::observeUIEvents( @@ -260,7 +260,7 @@ AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshP if (modules) { for (auto i = modules->begin(); i != modules->end(); ++i) { auto &pi = **i; - AdminMessageHandleResult h = pi.handleAdminMessageForPlugin(mp, request, response); + AdminMessageHandleResult h = pi.handleAdminMessageForModule(mp, request, response); if (h == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) { // In case we have a response it always has priority. diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 047482308..97f9e6474 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -160,7 +160,7 @@ class MeshPlugin * HANDLED if message was handled * HANDLED_WITH_RESPONSE if a response is also prepared and to be sent. */ - virtual AdminMessageHandleResult handleAdminMessageForPlugin( + virtual AdminMessageHandleResult handleAdminMessageForModule( const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { return AdminMessageHandleResult::NOT_HANDLED; }; private: diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index d9de5f52d..863c6333a 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -115,10 +115,10 @@ void MeshService::reloadOwner() // DEBUG_MSG("reloadOwner()\n"); // update our local data directly nodeDB.updateUser(nodeDB.getNodeNum(), owner); - assert(nodeInfoPlugin); + assert(nodeInfoModule); // update everyone else - if (nodeInfoPlugin) - nodeInfoPlugin->sendOurNodeInfo(); + if (nodeInfoModule) + nodeInfoModule->sendOurNodeInfo(); nodeDB.saveToDisk(); } @@ -175,14 +175,14 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) assert(node); if (node->has_position) { - if (positionPlugin) { + if (positionModule) { DEBUG_MSG("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies); - positionPlugin->sendOurPosition(dest, wantReplies); + positionModule->sendOurPosition(dest, wantReplies); } } else { - if (nodeInfoPlugin) { + if (nodeInfoModule) { DEBUG_MSG("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies); - nodeInfoPlugin->sendOurNodeInfo(dest, wantReplies); + nodeInfoModule->sendOurNodeInfo(dest, wantReplies); } } } diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index eecfbdf64..3abae8efe 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -91,7 +91,7 @@ class MeshService /// Handle a packet that just arrived from the radio. This method does _ReliableRouternot_ free the provided packet. If it /// needs to keep the packet around it makes a copy int handleFromRadio(const MeshPacket *p); - friend class RoutingPlugin; + friend class RoutingModule; }; extern MeshService service; diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 3fce80d83..7f0dbd51f 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -132,7 +132,7 @@ MeshPacket *Router::allocForSending() */ void Router::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex) { - routingPlugin->sendAckNak(err, to, idFrom, chIndex); + routingModule->sendAckNak(err, to, idFrom, chIndex); } void Router::abortSendAndNak(Routing_Error err, MeshPacket *p) diff --git a/src/mesh/Router.h b/src/mesh/Router.h index 65ee5f4fc..3f079d92c 100644 --- a/src/mesh/Router.h +++ b/src/mesh/Router.h @@ -71,7 +71,7 @@ class Router : protected concurrency::OSThread void enqueueReceivedMessage(MeshPacket *p); protected: - friend class RoutingPlugin; + friend class RoutingModule; /** * Send a packet on a suitable interface. This routine will @@ -85,7 +85,7 @@ class Router : protected concurrency::OSThread /** * Should this incoming filter be dropped? * - * FIXME, move this into the new RoutingPlugin and do the filtering there using the regular module logic + * FIXME, move this into the new RoutingModule and do the filtering there using the regular module logic * * Called immedately on receiption, before any further processing. * @return true to abandon the packet diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 5123a93c8..41acfeeed 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -10,7 +10,7 @@ #include "unistd.h" #endif -AdminPlugin *adminPlugin; +AdminModule *adminModule; /// A special reserved string to indicate strings we can not share with external nodes. We will use this 'reserved' word instead. /// Also, to make setting work correctly, if someone tries to set a string to this reserved value we assume they don't really want a change. @@ -30,7 +30,7 @@ static void writeSecret(char *buf, const char *currentVal) { } } -void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) +void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) { if (req.decoded.want_response) { // We create the reply here @@ -41,7 +41,7 @@ void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) } } -void AdminPlugin::handleGetRadio(const MeshPacket &req) +void AdminModule::handleGetRadio(const MeshPacket &req) { if (req.decoded.want_response) { // We create the reply here @@ -61,7 +61,7 @@ void AdminPlugin::handleGetRadio(const MeshPacket &req) } } -bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) +bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) { // if handled == false, then let others look at this message also if they want bool handled = false; @@ -143,7 +143,7 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) return handled; } -void AdminPlugin::handleSetOwner(const User &o) +void AdminModule::handleSetOwner(const User &o) { int changed = 0; @@ -173,7 +173,7 @@ void AdminPlugin::handleSetOwner(const User &o) service.reloadOwner(); } -void AdminPlugin::handleSetChannel(const Channel &cc) +void AdminModule::handleSetChannel(const Channel &cc) { channels.setChannel(cc); @@ -187,7 +187,7 @@ void AdminPlugin::handleSetChannel(const Channel &cc) } } -void AdminPlugin::handleSetRadio(RadioConfig &r) +void AdminModule::handleSetRadio(RadioConfig &r) { writeSecret(r.preferences.wifi_password, radioConfig.preferences.wifi_password); radioConfig = r; @@ -195,7 +195,7 @@ void AdminPlugin::handleSetRadio(RadioConfig &r) service.reloadConfig(); } -AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields) +AdminModule::AdminModule() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields) { // restrict to the admin channel for rx boundChannel = Channels::adminChannel; diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index 4c4b956cc..98af9a677 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -2,15 +2,15 @@ #include "ProtobufPlugin.h" /** - * Routing plugin for router control messages + * Routing module for router control messages */ -class AdminPlugin : public ProtobufPlugin +class AdminModule : public ProtobufPlugin { public: /** Constructor * name is for debugging output */ - AdminPlugin(); + AdminModule(); protected: /** Called to handle a particular incoming message @@ -28,4 +28,4 @@ class AdminPlugin : public ProtobufPlugin void handleGetRadio(const MeshPacket &req); }; -extern AdminPlugin *adminPlugin; +extern AdminModule *adminModule; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index dbb12bd40..204330e8f 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -28,10 +28,10 @@ CannedMessageModule::CannedMessageModule() { if (radioConfig.preferences.canned_message_module_enabled) { - this->loadProtoForPlugin(); + this->loadProtoForModule(); if(this->splitConfiguredMessages() <= 0) { - DEBUG_MSG("CannedMessageModule: No messages are configured. Plugin is disabled\n"); + DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n"); this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED; } else @@ -313,7 +313,7 @@ void CannedMessageModule::drawFrame( } } -void CannedMessageModule::loadProtoForPlugin() +void CannedMessageModule::loadProtoForModule() { if (!loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(cannedMessagesConfigFile), CannedMessageModuleConfig_fields, &cannedMessageModuleConfig)) { installDefaultCannedMessageModuleConfig(); @@ -326,7 +326,7 @@ void CannedMessageModule::loadProtoForPlugin() * @return true On success. * @return false On error. */ -bool CannedMessageModule::saveProtoForPlugin() +bool CannedMessageModule::saveProtoForModule() { bool okay = true; @@ -351,7 +351,7 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig() } /** - * @brief An admin message arrived to AdminPlugin. We are asked whether we want to handle that. + * @brief An admin message arrived to AdminModule. We are asked whether we want to handle that. * * @param mp The mesh packet arrived. * @param request The AdminMessage request extracted from the packet. @@ -359,7 +359,7 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig() * @return AdminMessageHandleResult HANDLED if message was handled * HANDLED_WITH_RESULT if a result is also prepared. */ -AdminMessageHandleResult CannedMessageModule::handleAdminMessageForPlugin( +AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule( const MeshPacket &mp, AdminMessage *request, AdminMessage *response) { AdminMessageHandleResult result; @@ -485,7 +485,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart1(const char *from_msg if (changed) { - this->saveProtoForPlugin(); + this->saveProtoForModule(); } } @@ -501,7 +501,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart2(const char *from_msg if (changed) { - this->saveProtoForPlugin(); + this->saveProtoForModule(); } } @@ -517,7 +517,7 @@ void CannedMessageModule::handleSetCannedMessageModulePart3(const char *from_msg if (changed) { - this->saveProtoForPlugin(); + this->saveProtoForModule(); } } @@ -533,6 +533,6 @@ void CannedMessageModule::handleSetCannedMessageModulePart4(const char *from_msg if (changed) { - this->saveProtoForPlugin(); + this->saveProtoForModule(); } } diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index c38c4aceb..3a33b6acf 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -66,11 +66,11 @@ class CannedMessageModule : virtual Observable* getUIFrameObservable() override { return this; } virtual void drawFrame( OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override; - virtual AdminMessageHandleResult handleAdminMessageForPlugin( + virtual AdminMessageHandleResult handleAdminMessageForModule( const MeshPacket &mp, AdminMessage *request, AdminMessage *response) override; - void loadProtoForPlugin(); - bool saveProtoForPlugin(); + void loadProtoForModule(); + bool saveProtoForModule(); void installDefaultCannedMessageModuleConfig(); diff --git a/src/modules/ModuleDev.h b/src/modules/ModuleDev.h index df2e449a5..da8de3e9c 100644 --- a/src/modules/ModuleDev.h +++ b/src/modules/ModuleDev.h @@ -6,5 +6,5 @@ * */ -// Enable development more for StoreForwardPlugin +// Enable development more for StoreForwardModule bool StoreForward_Dev = false; \ No newline at end of file diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index e01b374b3..fda285ed6 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -25,21 +25,21 @@ void setupModules() { inputBroker = new InputBroker(); - adminPlugin = new AdminPlugin(); - nodeInfoPlugin = new NodeInfoPlugin(); - positionPlugin = new PositionPlugin(); - textMessagePlugin = new TextMessagePlugin(); + adminModule = new AdminModule(); + nodeInfoModule = new NodeInfoModule(); + positionModule = new PositionModule(); + textMessageModule = new TextMessageModule(); // Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance // to a global variable. - new RemoteHardwarePlugin(); - new ReplyPlugin(); + new RemoteHardwareModule(); + new ReplyModule(); rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1(); rotaryEncoderInterruptImpl1->init(); cannedMessageModule = new CannedMessageModule(); #ifndef PORTDUINO - new TelemetryPlugin(); + new TelemetryModule(); #endif #ifndef NO_ESP32 // Only run on an esp32 based device. @@ -47,15 +47,14 @@ void setupModules() /* Maintained by MC Hamster (Jm Casler) jm@casler.org */ - new SerialPlugin(); + new SerialModule(); new ExternalNotificationModule(); - storeForwardPlugin = new StoreForwardPlugin(); + storeForwardModule = new StoreForwardModule(); new RangeTestModule(); - // new StoreForwardPlugin(); #endif // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra acks - routingPlugin = new RoutingPlugin(); + routingModule = new RoutingModule(); } \ No newline at end of file diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 83056d268..9994d314f 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -6,9 +6,9 @@ #include "Router.h" #include "main.h" -NodeInfoPlugin *nodeInfoPlugin; +NodeInfoModule *nodeInfoModule; -bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, User *pptr) +bool NodeInfoModule::handleReceivedProtobuf(const MeshPacket &mp, User *pptr) { auto p = *pptr; @@ -27,7 +27,7 @@ bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, User *pptr) return false; // Let others look at this message also if they want } -void NodeInfoPlugin::sendOurNodeInfo(NodeNum dest, bool wantReplies) +void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies) { // cancel any not yet sent (now stale) position packets if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal) @@ -42,7 +42,7 @@ void NodeInfoPlugin::sendOurNodeInfo(NodeNum dest, bool wantReplies) service.sendToMesh(p); } -MeshPacket *NodeInfoPlugin::allocReply() +MeshPacket *NodeInfoModule::allocReply() { User &u = owner; @@ -50,15 +50,15 @@ MeshPacket *NodeInfoPlugin::allocReply() return allocDataProtobuf(u); } -NodeInfoPlugin::NodeInfoPlugin() - : ProtobufPlugin("nodeinfo", PortNum_NODEINFO_APP, User_fields), concurrency::OSThread("NodeInfoPlugin") +NodeInfoModule::NodeInfoModule() + : ProtobufPlugin("nodeinfo", PortNum_NODEINFO_APP, User_fields), concurrency::OSThread("NodeInfoModule") { isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others setIntervalFromNow(30 * 1000); // Send our initial owner announcement 30 seconds after we start (to give network time to setup) } -int32_t NodeInfoPlugin::runOnce() +int32_t NodeInfoModule::runOnce() { static uint32_t currentGeneration; diff --git a/src/modules/NodeInfoModule.h b/src/modules/NodeInfoModule.h index 39ae1f6b0..9030a83a9 100644 --- a/src/modules/NodeInfoModule.h +++ b/src/modules/NodeInfoModule.h @@ -4,7 +4,7 @@ /** * NodeInfo module for sending/receiving NodeInfos into the mesh */ -class NodeInfoPlugin : public ProtobufPlugin, private concurrency::OSThread +class NodeInfoModule : public ProtobufPlugin, private concurrency::OSThread { /// The id of the last packet we sent, to allow us to cancel it if we make something fresher PacketId prevPacketId = 0; @@ -14,7 +14,7 @@ class NodeInfoPlugin : public ProtobufPlugin, private concurrency::OSThrea /** Constructor * name is for debugging output */ - NodeInfoPlugin(); + NodeInfoModule(); /** * Send our NodeInfo into the mesh @@ -36,4 +36,4 @@ class NodeInfoPlugin : public ProtobufPlugin, private concurrency::OSThrea virtual int32_t runOnce() override; }; -extern NodeInfoPlugin *nodeInfoPlugin; +extern NodeInfoModule *nodeInfoModule; diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 0f52d1865..1deabae0f 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -7,16 +7,16 @@ #include "configuration.h" #include "gps/GeoCoord.h" -PositionPlugin *positionPlugin; +PositionModule *positionModule; -PositionPlugin::PositionPlugin() - : ProtobufPlugin("position", PortNum_POSITION_APP, Position_fields), concurrency::OSThread("PositionPlugin") +PositionModule::PositionModule() + : ProtobufPlugin("position", PortNum_POSITION_APP, Position_fields), concurrency::OSThread("PositionModule") { isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup) } -bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr) +bool PositionModule::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr) { auto p = *pptr; @@ -53,7 +53,7 @@ bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr return false; // Let others look at this message also if they want } -MeshPacket *PositionPlugin::allocReply() +MeshPacket *PositionModule::allocReply() { NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position assert(node->has_position); @@ -109,7 +109,7 @@ MeshPacket *PositionPlugin::allocReply() return allocDataProtobuf(p); } -void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies) +void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies) { // cancel any not yet sent (now stale) position packets if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal) @@ -124,7 +124,7 @@ void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies) service.sendToMesh(p); } -int32_t PositionPlugin::runOnce() +int32_t PositionModule::runOnce() { NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 91d76b72f..8fbc5865c 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -5,7 +5,7 @@ /** * Position module for sending/receiving positions into the mesh */ -class PositionPlugin : public ProtobufPlugin, private concurrency::OSThread +class PositionModule : public ProtobufPlugin, private concurrency::OSThread { /// The id of the last packet we sent, to allow us to cancel it if we make something fresher PacketId prevPacketId = 0; @@ -24,7 +24,7 @@ class PositionPlugin : public ProtobufPlugin, private concurrency::OST /** Constructor * name is for debugging output */ - PositionPlugin(); + PositionModule(); /** * Send our position into the mesh @@ -47,4 +47,4 @@ class PositionPlugin : public ProtobufPlugin, private concurrency::OST virtual int32_t runOnce() override; }; -extern PositionPlugin *positionPlugin; +extern PositionModule *positionModule; diff --git a/src/modules/RemoteHardwareModule.cpp b/src/modules/RemoteHardwareModule.cpp index 1068e9cca..7ceaffeab 100644 --- a/src/modules/RemoteHardwareModule.cpp +++ b/src/modules/RemoteHardwareModule.cpp @@ -46,13 +46,13 @@ static uint64_t digitalReads(uint64_t mask) return res; } -RemoteHardwarePlugin::RemoteHardwarePlugin() +RemoteHardwareModule::RemoteHardwareModule() : ProtobufPlugin("remotehardware", PortNum_REMOTE_HARDWARE_APP, HardwareMessage_fields), concurrency::OSThread( "remotehardware") { } -bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr) +bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr) { auto p = *pptr; DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ); @@ -111,7 +111,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, Hardwar return false; } -int32_t RemoteHardwarePlugin::runOnce() +int32_t RemoteHardwareModule::runOnce() { if (watchGpios) { uint32_t now = millis(); diff --git a/src/modules/RemoteHardwareModule.h b/src/modules/RemoteHardwareModule.h index 9fa4bb0df..19811705a 100644 --- a/src/modules/RemoteHardwareModule.h +++ b/src/modules/RemoteHardwareModule.h @@ -6,7 +6,7 @@ /** * A module that provides easy low-level remote access to device hardware. */ -class RemoteHardwarePlugin : public ProtobufPlugin, private concurrency::OSThread +class RemoteHardwareModule : public ProtobufPlugin, private concurrency::OSThread { /// The current set of GPIOs we've been asked to watch for changes uint64_t watchGpios = 0; @@ -20,7 +20,7 @@ class RemoteHardwarePlugin : public ProtobufPlugin, private con /** Constructor * name is for debugging output */ - RemoteHardwarePlugin(); + RemoteHardwareModule(); protected: /** Called to handle a particular incoming message @@ -40,4 +40,4 @@ class RemoteHardwarePlugin : public ProtobufPlugin, private con virtual int32_t runOnce() override; }; -extern RemoteHardwarePlugin remoteHardwarePlugin; +extern RemoteHardwareModule remoteHardwareModule; diff --git a/src/modules/ReplyModule.cpp b/src/modules/ReplyModule.cpp index d6f5dd10d..af7232895 100644 --- a/src/modules/ReplyModule.cpp +++ b/src/modules/ReplyModule.cpp @@ -5,7 +5,7 @@ #include -MeshPacket *ReplyPlugin::allocReply() +MeshPacket *ReplyModule::allocReply() { assert(currentRequest); // should always be !NULL auto req = *currentRequest; diff --git a/src/modules/ReplyModule.h b/src/modules/ReplyModule.h index 4686e8145..af17224a6 100644 --- a/src/modules/ReplyModule.h +++ b/src/modules/ReplyModule.h @@ -5,13 +5,13 @@ /** * A simple example module that just replies with "Message received" to any message it receives. */ -class ReplyPlugin : public SinglePortPlugin +class ReplyModule : public SinglePortPlugin { public: /** Constructor * name is for debugging output */ - ReplyPlugin() : SinglePortPlugin("reply", PortNum_REPLY_APP) {} + ReplyModule() : SinglePortPlugin("reply", PortNum_REPLY_APP) {} protected: diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index e87f8ca85..070231032 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -5,9 +5,9 @@ #include "Router.h" #include "main.h" -RoutingPlugin *routingPlugin; +RoutingModule *routingModule; -bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r) +bool RoutingModule::handleReceivedProtobuf(const MeshPacket &mp, Routing *r) { printPacket("Routing sniffing", &mp); router->sniffReceived(&mp, r); @@ -22,7 +22,7 @@ bool RoutingPlugin::handleReceivedProtobuf(const MeshPacket &mp, Routing *r) return false; // Let others look at this message also if they want } -MeshPacket *RoutingPlugin::allocReply() +MeshPacket *RoutingModule::allocReply() { assert(currentRequest); @@ -34,14 +34,14 @@ MeshPacket *RoutingPlugin::allocReply() return NULL; } -void RoutingPlugin::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex) +void RoutingModule::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex) { auto p = allocAckNak(err, to, idFrom, chIndex); router->sendLocal(p); // we sometimes send directly to the local node } -RoutingPlugin::RoutingPlugin() : ProtobufPlugin("routing", PortNum_ROUTING_APP, Routing_fields) +RoutingModule::RoutingModule() : ProtobufPlugin("routing", PortNum_ROUTING_APP, Routing_fields) { isPromiscuous = true; } diff --git a/src/modules/RoutingModule.h b/src/modules/RoutingModule.h index ae2088475..66a326c7b 100644 --- a/src/modules/RoutingModule.h +++ b/src/modules/RoutingModule.h @@ -5,13 +5,13 @@ /** * Routing module for router control messages */ -class RoutingPlugin : public ProtobufPlugin +class RoutingModule : public ProtobufPlugin { public: /** Constructor * name is for debugging output */ - RoutingPlugin(); + RoutingModule(); void sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex); @@ -32,4 +32,4 @@ class RoutingPlugin : public ProtobufPlugin virtual bool wantPacket(const MeshPacket *p) override { return true; } }; -extern RoutingPlugin *routingPlugin; +extern RoutingModule *routingModule; diff --git a/src/modules/Telemetry/Telemetry.cpp b/src/modules/Telemetry/Telemetry.cpp index 7758667c5..e01981924 100644 --- a/src/modules/Telemetry/Telemetry.cpp +++ b/src/modules/Telemetry/Telemetry.cpp @@ -42,7 +42,7 @@ MCP9808Sensor mcp9808Sensor; #define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM) -int32_t TelemetryPlugin::runOnce() +int32_t TelemetryModule::runOnce() { #ifndef PORTDUINO /* @@ -155,7 +155,7 @@ int32_t TelemetryPlugin::runOnce() #endif } -bool TelemetryPlugin::wantUIFrame() +bool TelemetryModule::wantUIFrame() { return radioConfig.preferences.telemetry_module_screen_enabled; } @@ -185,12 +185,12 @@ uint32_t GetTimeSinceMeshPacket(const MeshPacket *mp) return delta; } -float TelemetryPlugin::CelsiusToFarenheit(float c) +float TelemetryModule::CelsiusToFarenheit(float c) { return (c * 9) / 5 + 32; } -void TelemetryPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +void TelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_MEDIUM); @@ -225,7 +225,7 @@ void TelemetryPlugin::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA"); } -bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) +bool TelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) { if (!(radioConfig.preferences.telemetry_module_measurement_enabled || radioConfig.preferences.telemetry_module_screen_enabled)) { @@ -246,7 +246,7 @@ bool TelemetryPlugin::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *p) return false; // Let others look at this message also if they want } -bool TelemetryPlugin::sendOurTelemetry(NodeNum dest, bool wantReplies) +bool TelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies) { Telemetry m; m.barometric_pressure = 0; diff --git a/src/modules/Telemetry/Telemetry.h b/src/modules/Telemetry/Telemetry.h index 177ad0ce1..40da90986 100644 --- a/src/modules/Telemetry/Telemetry.h +++ b/src/modules/Telemetry/Telemetry.h @@ -4,11 +4,11 @@ #include #include -class TelemetryPlugin : private concurrency::OSThread, public ProtobufPlugin +class TelemetryModule : private concurrency::OSThread, public ProtobufPlugin { public: - TelemetryPlugin() - : concurrency::OSThread("TelemetryPlugin"), + TelemetryModule() + : concurrency::OSThread("TelemetryModule"), ProtobufPlugin("Telemetry", PortNum_TELEMETRY_APP, &Telemetry_msg) { lastMeasurementPacket = nullptr; diff --git a/src/modules/TextMessageModule.cpp b/src/modules/TextMessageModule.cpp index bd6aea770..abccc0ae8 100644 --- a/src/modules/TextMessageModule.cpp +++ b/src/modules/TextMessageModule.cpp @@ -3,9 +3,9 @@ #include "NodeDB.h" #include "PowerFSM.h" -TextMessagePlugin *textMessagePlugin; +TextMessageModule *textMessageModule; -ProcessMessage TextMessagePlugin::handleReceived(const MeshPacket &mp) +ProcessMessage TextMessageModule::handleReceived(const MeshPacket &mp) { auto &p = mp.decoded; DEBUG_MSG("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes); diff --git a/src/modules/TextMessageModule.h b/src/modules/TextMessageModule.h index d730c3ae4..184bb9e11 100644 --- a/src/modules/TextMessageModule.h +++ b/src/modules/TextMessageModule.h @@ -5,13 +5,13 @@ /** * Text message handling for meshtastic - draws on the OLED display the most recent received message */ -class TextMessagePlugin : public SinglePortPlugin, public Observable +class TextMessageModule : public SinglePortPlugin, public Observable { public: /** Constructor * name is for debugging output */ - TextMessagePlugin() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {} + TextMessageModule() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {} protected: @@ -22,4 +22,4 @@ class TextMessagePlugin : public SinglePortPlugin, public ObservablegetLatitude() %d\n", gpsStatus->getLatitude()); DEBUG_MSG("gpsStatus->getLongitude() %d\n", gpsStatus->getLongitude()); @@ -90,7 +90,7 @@ int32_t RangeTestModule::runOnce() } } else { - DEBUG_MSG("Range Test Plugin - Disabled\n"); + DEBUG_MSG("Range Test Module - Disabled\n"); } #endif @@ -175,7 +175,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const MeshPacket &mp) } } else { - DEBUG_MSG("Range Test Plugin Disabled\n"); + DEBUG_MSG("Range Test Module Disabled\n"); } #endif diff --git a/src/modules/esp32/SerialModule.cpp b/src/modules/esp32/SerialModule.cpp index c8b9914b1..a29e03bbf 100644 --- a/src/modules/esp32/SerialModule.cpp +++ b/src/modules/esp32/SerialModule.cpp @@ -9,7 +9,7 @@ #include /* - SerialPlugin + SerialModule A simple interface to send messages over the mesh network by sending strings over a serial port. @@ -20,7 +20,7 @@ Basic Usage: - 1) Enable the module by setting serialplugin_enabled to 1. + 1) Enable the module by setting serialmodule_enabled to 1. 2) Set the pins (serialmodule_rxd / serialmodule_rxd) for your preferred RX and TX GPIO pins. On tbeam, recommend to use: RXD 35 @@ -54,20 +54,20 @@ #define SERIALMODULE_BAUD 38400 #define SERIALMODULE_ACK 1 -SerialPlugin *serialPlugin; -SerialPluginRadio *serialPluginRadio; +SerialModule *serialModule; +SerialModuleRadio *serialModuleRadio; -SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {} +SerialModule::SerialModule() : concurrency::OSThread("SerialModule") {} char serialStringChar[Constants_DATA_PAYLOAD_LEN]; -SerialPluginRadio::SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) +SerialModuleRadio::SerialModuleRadio() : SinglePortPlugin("SerialModuleRadio", PortNum_SERIAL_APP) { // restrict to the admin channel for rx boundChannel = Channels::serialChannel; } -int32_t SerialPlugin::runOnce() +int32_t SerialModule::runOnce() { #ifndef NO_ESP32 @@ -107,7 +107,7 @@ int32_t SerialPlugin::runOnce() Serial2.setRxBufferSize(SERIALMODULE_RX_BUFFER); - serialPluginRadio = new SerialPluginRadio(); + serialModuleRadio = new SerialModuleRadio(); firstTime = 0; @@ -118,7 +118,7 @@ int32_t SerialPlugin::runOnce() serialString = Serial2.readString(); serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN); - serialPluginRadio->sendPayload(); + serialModuleRadio->sendPayload(); DEBUG_MSG("Received: %s\n", serialStringChar); } @@ -126,7 +126,7 @@ int32_t SerialPlugin::runOnce() return (10); } else { - DEBUG_MSG("Serial Plugin Disabled\n"); + DEBUG_MSG("Serial Module Disabled\n"); return (INT32_MAX); } @@ -135,7 +135,7 @@ int32_t SerialPlugin::runOnce() #endif } -MeshPacket *SerialPluginRadio::allocReply() +MeshPacket *SerialModuleRadio::allocReply() { auto reply = allocDataPacket(); // Allocate a packet for sending @@ -143,7 +143,7 @@ MeshPacket *SerialPluginRadio::allocReply() return reply; } -void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) +void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies) { MeshPacket *p = allocReply(); p->to = dest; @@ -157,7 +157,7 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) service.sendToMesh(p); } -ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp) +ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 @@ -202,7 +202,7 @@ ProcessMessage SerialPluginRadio::handleReceived(const MeshPacket &mp) } } else { - DEBUG_MSG("Serial Plugin Disabled\n"); + DEBUG_MSG("Serial Module Disabled\n"); } #endif diff --git a/src/modules/esp32/SerialModule.h b/src/modules/esp32/SerialModule.h index 7781e4419..860f53082 100644 --- a/src/modules/esp32/SerialModule.h +++ b/src/modules/esp32/SerialModule.h @@ -6,24 +6,24 @@ #include #include -class SerialPlugin : private concurrency::OSThread +class SerialModule : private concurrency::OSThread { bool firstTime = 1; public: - SerialPlugin(); + SerialModule(); protected: virtual int32_t runOnce() override; }; -extern SerialPlugin *serialPlugin; +extern SerialModule *serialModule; /* - * Radio interface for SerialPlugin + * Radio interface for SerialModule * */ -class SerialPluginRadio : public SinglePortPlugin +class SerialModuleRadio : public SinglePortPlugin { uint32_t lastRxID = 0; @@ -33,7 +33,7 @@ class SerialPluginRadio : public SinglePortPlugin from the main code. */ - SerialPluginRadio(); + SerialModuleRadio(); /** * Send our payload into the mesh @@ -50,4 +50,4 @@ class SerialPluginRadio : public SinglePortPlugin virtual ProcessMessage handleReceived(const MeshPacket &mp) override; }; -extern SerialPluginRadio *serialPluginRadio; +extern SerialModuleRadio *serialModuleRadio; diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index 3aedcdf3a..a8c775236 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -12,9 +12,9 @@ #include #include -StoreForwardPlugin *storeForwardPlugin; +StoreForwardModule *storeForwardModule; -int32_t StoreForwardPlugin::runOnce() +int32_t StoreForwardModule::runOnce() { #ifndef NO_ESP32 @@ -31,11 +31,11 @@ int32_t StoreForwardPlugin::runOnce() if (airTime->channelUtilizationPercent() < 25) { // DEBUG_MSG("--- --- --- In busy loop 1 %d\n", this->packetHistoryTXQueue_index); - storeForwardPlugin->sendPayload(this->busyTo, this->packetHistoryTXQueue_index); + storeForwardModule->sendPayload(this->busyTo, this->packetHistoryTXQueue_index); if (this->packetHistoryTXQueue_index == packetHistoryTXQueue_size) { strcpy(this->routerMessage, "** S&F - Done"); - storeForwardPlugin->sendMessage(this->busyTo, this->routerMessage); + storeForwardModule->sendMessage(this->busyTo, this->routerMessage); // DEBUG_MSG("--- --- --- In busy loop - Done \n"); this->packetHistoryTXQueue_index = 0; @@ -52,13 +52,13 @@ int32_t StoreForwardPlugin::runOnce() return (this->packetTimeMax); } else { - DEBUG_MSG("Store & Forward Plugin - Disabled (is_router = false)\n"); + DEBUG_MSG("Store & Forward Module - Disabled (is_router = false)\n"); return (INT32_MAX); } } else { - DEBUG_MSG("Store & Forward Plugin - Disabled\n"); + DEBUG_MSG("Store & Forward Module - Disabled\n"); return (INT32_MAX); } @@ -70,7 +70,7 @@ int32_t StoreForwardPlugin::runOnce() /* Create our data structure in the PSRAM. */ -void StoreForwardPlugin::populatePSRAM() +void StoreForwardModule::populatePSRAM() { /* For PSRAM usage, see: @@ -104,7 +104,7 @@ void StoreForwardPlugin::populatePSRAM() DEBUG_MSG(" numberOfPackets for packetHistory - %u\n", numberOfPackets); } -void StoreForwardPlugin::historyReport() +void StoreForwardModule::historyReport() { DEBUG_MSG("Iterating through the message history...\n"); DEBUG_MSG("Message history contains %u records\n", this->packetHistoryCurrent); @@ -113,27 +113,27 @@ void StoreForwardPlugin::historyReport() /* * */ -void StoreForwardPlugin::historySend(uint32_t msAgo, uint32_t to) +void StoreForwardModule::historySend(uint32_t msAgo, uint32_t to) { // uint32_t packetsSent = 0; - uint32_t queueSize = storeForwardPlugin->historyQueueCreate(msAgo, to); + uint32_t queueSize = storeForwardModule->historyQueueCreate(msAgo, to); if (queueSize) { snprintf(this->routerMessage, 80, "** S&F - Sending %u message(s)", queueSize); - storeForwardPlugin->sendMessage(to, this->routerMessage); + storeForwardModule->sendMessage(to, this->routerMessage); this->busy = true; // runOnce() will pickup the next steps once busy = true. this->busyTo = to; } else { strcpy(this->routerMessage, "** S&F - No history to send"); - storeForwardPlugin->sendMessage(to, this->routerMessage); + storeForwardModule->sendMessage(to, this->routerMessage); } } -uint32_t StoreForwardPlugin::historyQueueCreate(uint32_t msAgo, uint32_t to) +uint32_t StoreForwardModule::historyQueueCreate(uint32_t msAgo, uint32_t to) { // uint32_t packetHistoryTXQueueIndex = 0; @@ -177,7 +177,7 @@ uint32_t StoreForwardPlugin::historyQueueCreate(uint32_t msAgo, uint32_t to) return this->packetHistoryTXQueue_size; } -void StoreForwardPlugin::historyAdd(const MeshPacket &mp) +void StoreForwardModule::historyAdd(const MeshPacket &mp) { const auto &p = mp.decoded; @@ -191,13 +191,13 @@ void StoreForwardPlugin::historyAdd(const MeshPacket &mp) this->packetHistoryCurrent++; } -MeshPacket *StoreForwardPlugin::allocReply() +MeshPacket *StoreForwardModule::allocReply() { auto reply = allocDataPacket(); // Allocate a packet for sending return reply; } -void StoreForwardPlugin::sendPayload(NodeNum dest, uint32_t packetHistory_index) +void StoreForwardModule::sendPayload(NodeNum dest, uint32_t packetHistory_index) { DEBUG_MSG("Sending S&F Payload\n"); MeshPacket *p = allocReply(); @@ -218,7 +218,7 @@ void StoreForwardPlugin::sendPayload(NodeNum dest, uint32_t packetHistory_index) service.sendToMesh(p); } -void StoreForwardPlugin::sendMessage(NodeNum dest, char *str) +void StoreForwardModule::sendMessage(NodeNum dest, char *str) { MeshPacket *p = allocReply(); @@ -240,7 +240,7 @@ void StoreForwardPlugin::sendMessage(NodeNum dest, char *str) // HardwareMessage_init_default } -ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) +ProcessMessage StoreForwardModule::handleReceived(const MeshPacket &mp) { #ifndef NO_ESP32 if (radioConfig.preferences.store_forward_module_enabled) { @@ -261,9 +261,9 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) // Send the last 60 minutes of messages. if (this->busy) { strcpy(this->routerMessage, "** S&F - Busy. Try again shortly."); - storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage); + storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage); } else { - storeForwardPlugin->historySend(1000 * 60, getFrom(&mp)); + storeForwardModule->historySend(1000 * 60, getFrom(&mp)); } } else if ((p.payload.bytes[0] == 'S') && (p.payload.bytes[1] == 'F') && (p.payload.bytes[2] == 'm') && (p.payload.bytes[3] == 0x00)) { @@ -271,10 +271,10 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) "01234567890123456789012345678901234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456789012345678901234567890123456", sizeof(this->routerMessage)); - storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage); + storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage); } else { - storeForwardPlugin->historyAdd(mp); + storeForwardModule->historyAdd(mp); } } else if (mp.decoded.portnum == PortNum_STORE_FORWARD_APP) { @@ -285,7 +285,7 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) } } else { - DEBUG_MSG("Store & Forward Plugin - Disabled\n"); + DEBUG_MSG("Store & Forward Module - Disabled\n"); } #endif @@ -293,7 +293,7 @@ ProcessMessage StoreForwardPlugin::handleReceived(const MeshPacket &mp) return ProcessMessage::CONTINUE; // Let others look at this message also if they want } -ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) +ProcessMessage StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p) { if (!radioConfig.preferences.store_forward_module_enabled) { // If this module is not enabled in any capacity, don't handle the packet, and allow other modules to consume @@ -323,9 +323,9 @@ ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, // Send the last 60 minutes of messages. if (this->busy) { strcpy(this->routerMessage, "** S&F - Busy. Try again shortly."); - storeForwardPlugin->sendMessage(getFrom(&mp), this->routerMessage); + storeForwardModule->sendMessage(getFrom(&mp), this->routerMessage); } else { - storeForwardPlugin->historySend(1000 * 60, getFrom(&mp)); + storeForwardModule->historySend(1000 * 60, getFrom(&mp)); } break; @@ -377,8 +377,8 @@ ProcessMessage StoreForwardPlugin::handleReceivedProtobuf(const MeshPacket &mp, return ProcessMessage::STOP; // There's no need for others to look at this message. } -StoreForwardPlugin::StoreForwardPlugin() - : SinglePortPlugin("StoreForwardPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("StoreForwardPlugin") +StoreForwardModule::StoreForwardModule() + : SinglePortPlugin("StoreForwardModule", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("StoreForwardModule") { #ifndef NO_ESP32 @@ -387,7 +387,7 @@ StoreForwardPlugin::StoreForwardPlugin() if (StoreForward_Dev) { /* - Uncomment the preferences below if you want to use the plugin + Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ @@ -400,7 +400,7 @@ StoreForwardPlugin::StoreForwardPlugin() // Router if (radioConfig.preferences.is_router) { - DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Router\n"); + DEBUG_MSG("Initializing Store & Forward Module - Enabled as Router\n"); if (ESP.getPsramSize()) { if (ESP.getFreePsram() >= 1024 * 1024) { @@ -427,17 +427,17 @@ StoreForwardPlugin::StoreForwardPlugin() } else { DEBUG_MSG("Device has less than 1M of PSRAM free. Aborting startup.\n"); - DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); + DEBUG_MSG("Store & Forward Module - Aborting Startup.\n"); } } else { DEBUG_MSG("Device doesn't have PSRAM.\n"); - DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); + DEBUG_MSG("Store & Forward Module - Aborting Startup.\n"); } // Client } else { - DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n"); + DEBUG_MSG("Initializing Store & Forward Module - Enabled as Client\n"); } } #endif diff --git a/src/modules/esp32/StoreForwardModule.h b/src/modules/esp32/StoreForwardModule.h index 2514b89bf..4d610c667 100644 --- a/src/modules/esp32/StoreForwardModule.h +++ b/src/modules/esp32/StoreForwardModule.h @@ -18,7 +18,7 @@ struct PacketHistoryStruct { pb_size_t payload_size; }; -class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThread +class StoreForwardModule : public SinglePortPlugin, private concurrency::OSThread { // bool firstTime = 1; bool busy = 0; @@ -37,7 +37,7 @@ class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThrea uint32_t packetTimeMax = 2000; public: - StoreForwardPlugin(); + StoreForwardModule(); /** Update our local reference of when we last saw that node. @@ -82,4 +82,4 @@ class StoreForwardPlugin : public SinglePortPlugin, private concurrency::OSThrea }; -extern StoreForwardPlugin *storeForwardPlugin; +extern StoreForwardModule *storeForwardModule; diff --git a/variants/diy/v1/variant.h b/variants/diy/v1/variant.h index d1724340e..2d2b195cf 100644 --- a/variants/diy/v1/variant.h +++ b/variants/diy/v1/variant.h @@ -9,7 +9,7 @@ //#define GPS_TX_PIN 12 // not connected #define BUTTON_PIN 39 // The middle button GPIO on the T-Beam -#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975). +#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). #define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) #define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module diff --git a/variants/diy/v1_1/variant.h b/variants/diy/v1_1/variant.h index d5d6f238c..3100c7029 100644 --- a/variants/diy/v1_1/variant.h +++ b/variants/diy/v1_1/variant.h @@ -8,7 +8,7 @@ #define BUTTON_PIN 2 // The middle button GPIO on the T-Beam #define BUTTON_NEED_PULLUP -#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975). +#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). #define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module #define LORA_RESET 27 // RST for SX1276, and for SX1262/SX1268 diff --git a/variants/heltec_v2.1/variant.h b/variants/heltec_v2.1/variant.h index daa1ab880..2c0f4e165 100644 --- a/variants/heltec_v2.1/variant.h +++ b/variants/heltec_v2.1/variant.h @@ -27,4 +27,4 @@ #define ADC_MULTIPLIER 3.8 #define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin. +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. diff --git a/variants/tbeam/variant.h b/variants/tbeam/variant.h index fef19e785..11bc21f4a 100644 --- a/variants/tbeam/variant.h +++ b/variants/tbeam/variant.h @@ -5,7 +5,7 @@ #define BUTTON_PIN 38 // The middle button GPIO on the T-Beam //#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed. Does anyone use this? It is not documented anywhere. -#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin. +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. #define LED_INVERTED 1 #define LED_PIN 4 // Newer tbeams (1.1) have an extra led on GPIO4 diff --git a/variants/tbeam_v07/variant.h b/variants/tbeam_v07/variant.h index ff007428c..359641aa4 100644 --- a/variants/tbeam_v07/variant.h +++ b/variants/tbeam_v07/variant.h @@ -5,7 +5,7 @@ #define BUTTON_PIN 39 #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin. +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. #define USE_RF95 #define LORA_DIO0 26 // a No connect on the SX1262 module diff --git a/variants/tlora_v1/variant.h b/variants/tlora_v1/variant.h index 06352fbbd..c138447df 100644 --- a/variants/tlora_v1/variant.h +++ b/variants/tlora_v1/variant.h @@ -12,7 +12,7 @@ #define LED_PIN 2 // If defined we will blink this LED #define BUTTON_PIN 0 // If defined, this will be used for user button presses #define BUTTON_NEED_PULLUP -#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin. +#define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Module. #define USE_RF95 #define LORA_DIO0 26 // a No connect on the SX1262 module From ebba628736b182962c5cf533b55bcfdf6ec8f5ad Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 02:26:22 -0800 Subject: [PATCH 71/93] Rename Plugin to Module in ui related areas. --- src/graphics/Screen.cpp | 6 +++--- src/mesh/MeshPlugin.cpp | 2 +- src/mesh/MeshPlugin.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 4e7fb0638..a5a2fb303 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -176,7 +176,7 @@ static void drawSleepScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int } #endif -static void drawPluginFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { uint8_t module_frame; // there's a little but in the UI transition code @@ -976,7 +976,7 @@ void Screen::setFrames() DEBUG_MSG("showing standard frames\n"); showingNormalScreen = true; - moduleFrames = MeshPlugin::GetMeshPluginsWithUIFrames(); + moduleFrames = MeshPlugin::GetMeshModulesWithUIFrames(); DEBUG_MSG("Showing %d module frames\n", moduleFrames.size()); int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + moduleFrames.size(); DEBUG_MSG("Total frame count: %d\n", totalFrameCount); @@ -995,7 +995,7 @@ void Screen::setFrames() // is the same offset into the moduleFrames vector // so that we can invoke the module's callback for (auto i = moduleFrames.begin(); i != moduleFrames.end(); ++i) { - normalFrames[numframes++] = drawPluginFrame; + normalFrames[numframes++] = drawModuleFrame; } DEBUG_MSG("Added modules. numframes: %d\n", numframes); diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 77d647562..d3e0f584e 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -222,7 +222,7 @@ void setReplyTo(MeshPacket *p, const MeshPacket &to) p->decoded.request_id = to.id; } -std::vector MeshPlugin::GetMeshPluginsWithUIFrames() +std::vector MeshPlugin::GetMeshModulesWithUIFrames() { std::vector modulesWithUIFrames; diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 97f9e6474..7abd56e14 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -68,7 +68,7 @@ class MeshPlugin */ static void callPlugins(const MeshPacket &mp, RxSource src = RX_SRC_RADIO); - static std::vector GetMeshPluginsWithUIFrames(); + static std::vector GetMeshModulesWithUIFrames(); static void observeUIEvents(Observer *observer); static AdminMessageHandleResult handleAdminMessageForAllPlugins( const MeshPacket &mp, AdminMessage *request, AdminMessage *response); From 7c868c78cc84cce2f8af784485165136ddad5428 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 09:52:31 -0800 Subject: [PATCH 72/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index cd7d99a07..148840a89 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit cd7d99a0767664601f351b511d32b13814f4d67e +Subproject commit 148840a89817df062fcf1959e93cfeaae5d96fa6 From 92ffbca339cd767ea3d128226e841285db4f4ab0 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 09:57:09 -0800 Subject: [PATCH 73/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 148840a89..2d2ed26fd 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 148840a89817df062fcf1959e93cfeaae5d96fa6 +Subproject commit 2d2ed26fd91e6586be699c88bd9900a42d2c9941 From 10fefe7c7b1432922e78791432ee9e1c3dc347fd Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 10:01:40 -0800 Subject: [PATCH 74/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 2d2ed26fd..d18545583 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 2d2ed26fd91e6586be699c88bd9900a42d2c9941 +Subproject commit d1854558375a712cddc914bfebe69fd5e279be83 From 92d5dedc630eec39dfb6fd5871d00a610929eb1e Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 12:46:23 -0800 Subject: [PATCH 75/93] Remove incomplete ReliableRouter implementation --- src/main.cpp | 6 - src/mesh/DSRRouter.cpp | 250 ----------------------------------------- src/mesh/DSRRouter.h | 80 ------------- 3 files changed, 336 deletions(-) delete mode 100644 src/mesh/DSRRouter.cpp delete mode 100644 src/mesh/DSRRouter.h diff --git a/src/main.cpp b/src/main.cpp index f025d3dd2..5893d95a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,6 @@ #include "error.h" #include "power.h" // #include "rom/rtc.h" -#include "DSRRouter.h" // #include "debug.h" #include "FSCommon.h" #include "RTC.h" @@ -62,8 +61,6 @@ uint8_t screen_found; bool axp192_found; -Router *router = NULL; // Users of router don't care what sort of subclass implements that API - // ----------------------------------------------------------------------------- // Application // ----------------------------------------------------------------------------- @@ -443,8 +440,6 @@ void setup() fsInit(); - router = new DSRRouter(); - #ifdef I2C_SDA Wire.begin(I2C_SDA, I2C_SCL); #elif !defined(NO_WIRE) @@ -662,7 +657,6 @@ void setup() if (!rIf) RECORD_CRITICALERROR(CriticalErrorCode_NoRadio); else{ - router->addInterface(rIf); // Calculate and save the bit rate to myNodeInfo // TODO: This needs to be added what ever method changes the channel from the phone. diff --git a/src/mesh/DSRRouter.cpp b/src/mesh/DSRRouter.cpp deleted file mode 100644 index c2a170ec7..000000000 --- a/src/mesh/DSRRouter.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include "configuration.h" -#include "DSRRouter.h" - -/* when we receive any packet - -- sniff and update tables (especially useful to find adjacent nodes). Update user, network and position info. -- if we need to route() that packet, resend it to the next_hop based on our nodedb. -- if it is broadcast or destined for our node, deliver locally -- handle routereply/routeerror/routediscovery messages as described below -- then free it - -routeDiscovery - -- if we've already passed through us (or is from us), then it ignore it -- use the nodes already mentioned in the request to update our routing table -- if they were looking for us, send back a routereply -- if max_hops is zero and they weren't looking for us, drop (FIXME, send back error - I think not though?) -- if we receive a discovery packet, we use it to populate next_hop (if needed) towards the requester (after decrementing max_hops) -- if we receive a discovery packet, and we have a next_hop in our nodedb for that destination we send a (reliable) we send a route -reply towards the requester - -when sending any reliable packet - -- if timeout doing retries, send a routeError (nak) message back towards the original requester. all nodes eavesdrop on that -packet and update their route caches. - -when we receive a routereply packet - -- update next_hop on the node, if the new reply needs fewer hops than the existing one (we prefer shorter paths). fixme, someday -use a better heuristic - -when we receive a routeError packet - -- delete the route for that failed recipient, restartRouteDiscovery() -- if we receive routeerror in response to a discovery, -- fixme, eventually keep caches of possible other routes. -*/ - -ErrorCode DSRRouter::send(MeshPacket *p) -{ - // We only consider multihop routing packets (i.e. those with dest set) - if (p->decoded.dest) { - // add an entry for this pending message - auto pending = startRetransmission(p); - // FIXME - when acks come in for this packet, we should _not_ delete the record unless the ack was from - // the final dest. We need to keep that record around until FIXME - // Also we should not retransmit multihop entries in that table at all - - // If we have an entry in our routing tables, just send it, otherwise start a route discovery - NodeNum nextHop = getNextHop(p->decoded.dest); - if (nextHop) { - sendNextHop(nextHop, p); // start a reliable single hop send - } else { - pending->wantRoute = true; - - // start discovery, but only if we don't already a discovery in progress for that node number - startDiscovery(p->decoded.dest); - } - - return ERRNO_OK; - } else - return ReliableRouter::send(p); -} - -void DSRRouter::sniffReceived(const MeshPacket *p, const Routing *c) -{ - // Learn 0 hop routes by just hearing any adjacent nodes - // But treat broadcasts carefully, because when flood broadcasts go out they keep the same original "from". So we want to - // ignore rebroadcasts. - // this will also add records for any ACKs we receive for our messages - if (p->to != NODENUM_BROADCAST || p->hop_limit != HOP_RELIABLE) { - addRoute(getFrom(p), getFrom(p), 0); // We are adjacent with zero hops - } - - if (c) - switch (c->which_variant) { - case Routing_route_request_tag: - // Handle route discovery packets (will be a broadcast message) - // FIXME - always start request with the senders nodenum - if (weAreInRoute(c->route_request)) { - DEBUG_MSG("Ignoring a route request that contains us\n"); - } else { - updateRoutes(c->route_request, - true); // Update our routing tables based on the route that came in so far on this request - - if (p->decoded.dest == getNodeNum()) { - // They were looking for us, send back a route reply (the sender address will be first in the list) - sendRouteReply(c->route_request); - } else { - // They were looking for someone else, forward it along (as a zero hop broadcast) - NodeNum nextHop = getNextHop(p->decoded.dest); - if (nextHop) { - // in our route cache, reply to the requester (the sender address will be first in the list) - sendRouteReply(c->route_request, nextHop); - } else { - // Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) - resendRouteRequest(p); - } - } - } - break; - case Routing_route_reply_tag: - updateRoutes(c->route_reply, false); - - // FIXME, if any of our current pending packets were waiting for this route, send them (and leave them as regular - // pending packets until ack arrives) - // FIXME, if we don't get a route reply at all (or a route error), timeout and generate a routeerror TIMEOUT on our - // own... - break; - case Routing_error_reason_tag: - removeRoute(p->decoded.dest); - - // FIXME: if any pending packets were waiting on this route, delete them - break; - default: - break; - } - - // We simply ignore ACKs - because ReliableRouter will delete the pending packet for us - - // Handle regular packets - if (p->to == getNodeNum()) { // Destined for us (at least for this hop) - - // We need to route this packet to some other node - if (p->decoded.dest && p->decoded.dest != p->to) { - // if we have a route out, resend the packet to the next hop, otherwise return RouteError no-route available - - NodeNum nextHop = getNextHop(p->decoded.dest); - if (nextHop) { - sendNextHop(nextHop, p); // start a reliable single hop send - } else { - // We don't have a route out - assert(p->decoded.source); // I think this is guaranteed by now - - // FIXME - what if the current packet _is_ a route error packet? - sendRouteError(p, Routing_Error_NO_ROUTE); - } - - // FIXME, stop local processing of this packet - } - - if (c) { - // handle naks - convert them to route error packets - // All naks are generated locally, because we failed resending the packet too many times - PacketId nakId = c->error_reason ? p->decoded.request_id : 0; - if (nakId) { - auto pending = findPendingPacket(p->to, nakId); - if (pending && - pending->packet->decoded.source) { // if source not set, this was not a multihop packet, just ignore - removeRoute(pending->packet->decoded.dest); // We no longer have a route to the specified node - - sendRouteError(p, Routing_Error_GOT_NAK); - } - } - } - } - - ReliableRouter::sniffReceived(p, c); -} - -/** - * Does our node appear in the specified route - */ -bool DSRRouter::weAreInRoute(const RouteDiscovery &route) -{ - return true; // FIXME -} - -/** - * Given a DSR route, use that route to update our DB of possible routes - * - * Note: routes are always listed in the same order - from sender to receipient (i.e. route_replies also use this some order) - * - * @param isRequest is true if we are looking at a route request, else we are looking at a reply - **/ -void DSRRouter::updateRoutes(const RouteDiscovery &route, bool isRequest) -{ - DEBUG_MSG("FIXME not implemented updateRoutes\n"); -} - -/** - * send back a route reply (the sender address will be first in the list) - */ -void DSRRouter::sendRouteReply(const RouteDiscovery &route, NodeNum toAppend) -{ - DEBUG_MSG("FIXME not implemented sendRoute\n"); -} - -/** - * Given a nodenum return the next node we should forward to if we want to reach that node. - * - * @return 0 if no route found - */ -NodeNum DSRRouter::getNextHop(NodeNum dest) -{ - DEBUG_MSG("FIXME not implemented getNextHop\n"); - return 0; -} - -/** Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) - * - * We will bump down hop_limit in this call. - */ -void DSRRouter::resendRouteRequest(const MeshPacket *p) -{ - DEBUG_MSG("FIXME not implemented resendRoute\n"); -} - -/** - * Record that forwarder can reach dest for us, but they will need numHops to get there. - * If our routing tables already have something that can reach that node in fewer hops we will keep the existing route - * instead. - */ -void DSRRouter::addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops) -{ - DEBUG_MSG("FIXME not implemented addRoute\n"); -} - -/** - * Record that we no longer have a route to the dest - */ -void DSRRouter::removeRoute(NodeNum dest) -{ - DEBUG_MSG("FIXME not implemented removeRoute\n"); -} - -/** - * Forward the specified packet to the specified node - */ -void DSRRouter::sendNextHop(NodeNum n, const MeshPacket *p) -{ - DEBUG_MSG("FIXME not implemented sendNextHop\n"); -} - -/** - * Send a route error packet towards whoever originally sent this message - */ -void DSRRouter::sendRouteError(const MeshPacket *p, Routing_Error err) -{ - DEBUG_MSG("FIXME not implemented sendRouteError\n"); -} - -/** make a copy of p, start discovery, but only if we don't - * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission - * when the discovery is complete. - */ -void DSRRouter::startDiscovery(NodeNum dest) -{ - DEBUG_MSG("FIXME not implemented startDiscovery\n"); -} \ No newline at end of file diff --git a/src/mesh/DSRRouter.h b/src/mesh/DSRRouter.h deleted file mode 100644 index 0caa9310a..000000000 --- a/src/mesh/DSRRouter.h +++ /dev/null @@ -1,80 +0,0 @@ -#include "ReliableRouter.h" - -class DSRRouter : public ReliableRouter -{ - - protected: - /** - * Every (non duplicate) packet this node receives will be passed through this method. This allows subclasses to - * update routing tables etc... based on what we overhear (even for messages not destined to our node) - */ - virtual void sniffReceived(const MeshPacket *p, const Routing *c) override; - - /** - * Send a packet on a suitable interface. This routine will - * later free() the packet to pool. This routine is not allowed to stall. - * If the txmit queue is full it might return an error - */ - virtual ErrorCode send(MeshPacket *p) override; - - private: - /** - * Does our node appear in the specified route - */ - bool weAreInRoute(const RouteDiscovery &route); - - /** - * Given a DSR route, use that route to update our DB of possible routes - * - * Note: routes are always listed in the same order - from sender to receipient (i.e. route_replies also use this some order) - * - * @param isRequest is true if we are looking at a route request, else we are looking at a reply - **/ - void updateRoutes(const RouteDiscovery &route, bool isRequest); - - /** - * send back a route reply (the sender address will be first in the list) - */ - void sendRouteReply(const RouteDiscovery &route, NodeNum toAppend = 0); - - /** - * Given a nodenum return the next node we should forward to if we want to reach that node. - * - * @return 0 if no route found - */ - NodeNum getNextHop(NodeNum dest); - - /** Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) - * - * We will bump down hop_limit in this call. - */ - void resendRouteRequest(const MeshPacket *p); - - /** - * Record that forwarder can reach dest for us, but they will need numHops to get there. - * If our routing tables already have something that can reach that node in fewer hops we will keep the existing route - * instead. - */ - void addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops); - - /** - * Record that we no longer have a route to the dest - */ - void removeRoute(NodeNum dest); - - /** - * Forward the specified packet to the specified node - */ - void sendNextHop(NodeNum n, const MeshPacket *p); - - /** - * Send a route error packet towards whoever originally sent this message - */ - void sendRouteError(const MeshPacket *p, Routing_Error err); - - /** make a copy of p, start discovery, but only if we don't - * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission - * when the discovery is complete. - */ - void startDiscovery(NodeNum dest); -}; From a2eb148c509221d094a4841f09beb22b606e03c1 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 12:50:50 -0800 Subject: [PATCH 76/93] Revert "Merge pull request #1257 from mc-hamster/router" This reverts commit 33ed9476f8370c184b0a615219fbd290510e0544, reversing changes made to 10fefe7c7b1432922e78791432ee9e1c3dc347fd. --- src/main.cpp | 6 + src/mesh/DSRRouter.cpp | 250 +++++++++++++++++++++++++++++++++++++++++ src/mesh/DSRRouter.h | 80 +++++++++++++ 3 files changed, 336 insertions(+) create mode 100644 src/mesh/DSRRouter.cpp create mode 100644 src/mesh/DSRRouter.h diff --git a/src/main.cpp b/src/main.cpp index 5893d95a2..f025d3dd2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include "error.h" #include "power.h" // #include "rom/rtc.h" +#include "DSRRouter.h" // #include "debug.h" #include "FSCommon.h" #include "RTC.h" @@ -61,6 +62,8 @@ uint8_t screen_found; bool axp192_found; +Router *router = NULL; // Users of router don't care what sort of subclass implements that API + // ----------------------------------------------------------------------------- // Application // ----------------------------------------------------------------------------- @@ -440,6 +443,8 @@ void setup() fsInit(); + router = new DSRRouter(); + #ifdef I2C_SDA Wire.begin(I2C_SDA, I2C_SCL); #elif !defined(NO_WIRE) @@ -657,6 +662,7 @@ void setup() if (!rIf) RECORD_CRITICALERROR(CriticalErrorCode_NoRadio); else{ + router->addInterface(rIf); // Calculate and save the bit rate to myNodeInfo // TODO: This needs to be added what ever method changes the channel from the phone. diff --git a/src/mesh/DSRRouter.cpp b/src/mesh/DSRRouter.cpp new file mode 100644 index 000000000..c2a170ec7 --- /dev/null +++ b/src/mesh/DSRRouter.cpp @@ -0,0 +1,250 @@ +#include "configuration.h" +#include "DSRRouter.h" + +/* when we receive any packet + +- sniff and update tables (especially useful to find adjacent nodes). Update user, network and position info. +- if we need to route() that packet, resend it to the next_hop based on our nodedb. +- if it is broadcast or destined for our node, deliver locally +- handle routereply/routeerror/routediscovery messages as described below +- then free it + +routeDiscovery + +- if we've already passed through us (or is from us), then it ignore it +- use the nodes already mentioned in the request to update our routing table +- if they were looking for us, send back a routereply +- if max_hops is zero and they weren't looking for us, drop (FIXME, send back error - I think not though?) +- if we receive a discovery packet, we use it to populate next_hop (if needed) towards the requester (after decrementing max_hops) +- if we receive a discovery packet, and we have a next_hop in our nodedb for that destination we send a (reliable) we send a route +reply towards the requester + +when sending any reliable packet + +- if timeout doing retries, send a routeError (nak) message back towards the original requester. all nodes eavesdrop on that +packet and update their route caches. + +when we receive a routereply packet + +- update next_hop on the node, if the new reply needs fewer hops than the existing one (we prefer shorter paths). fixme, someday +use a better heuristic + +when we receive a routeError packet + +- delete the route for that failed recipient, restartRouteDiscovery() +- if we receive routeerror in response to a discovery, +- fixme, eventually keep caches of possible other routes. +*/ + +ErrorCode DSRRouter::send(MeshPacket *p) +{ + // We only consider multihop routing packets (i.e. those with dest set) + if (p->decoded.dest) { + // add an entry for this pending message + auto pending = startRetransmission(p); + // FIXME - when acks come in for this packet, we should _not_ delete the record unless the ack was from + // the final dest. We need to keep that record around until FIXME + // Also we should not retransmit multihop entries in that table at all + + // If we have an entry in our routing tables, just send it, otherwise start a route discovery + NodeNum nextHop = getNextHop(p->decoded.dest); + if (nextHop) { + sendNextHop(nextHop, p); // start a reliable single hop send + } else { + pending->wantRoute = true; + + // start discovery, but only if we don't already a discovery in progress for that node number + startDiscovery(p->decoded.dest); + } + + return ERRNO_OK; + } else + return ReliableRouter::send(p); +} + +void DSRRouter::sniffReceived(const MeshPacket *p, const Routing *c) +{ + // Learn 0 hop routes by just hearing any adjacent nodes + // But treat broadcasts carefully, because when flood broadcasts go out they keep the same original "from". So we want to + // ignore rebroadcasts. + // this will also add records for any ACKs we receive for our messages + if (p->to != NODENUM_BROADCAST || p->hop_limit != HOP_RELIABLE) { + addRoute(getFrom(p), getFrom(p), 0); // We are adjacent with zero hops + } + + if (c) + switch (c->which_variant) { + case Routing_route_request_tag: + // Handle route discovery packets (will be a broadcast message) + // FIXME - always start request with the senders nodenum + if (weAreInRoute(c->route_request)) { + DEBUG_MSG("Ignoring a route request that contains us\n"); + } else { + updateRoutes(c->route_request, + true); // Update our routing tables based on the route that came in so far on this request + + if (p->decoded.dest == getNodeNum()) { + // They were looking for us, send back a route reply (the sender address will be first in the list) + sendRouteReply(c->route_request); + } else { + // They were looking for someone else, forward it along (as a zero hop broadcast) + NodeNum nextHop = getNextHop(p->decoded.dest); + if (nextHop) { + // in our route cache, reply to the requester (the sender address will be first in the list) + sendRouteReply(c->route_request, nextHop); + } else { + // Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) + resendRouteRequest(p); + } + } + } + break; + case Routing_route_reply_tag: + updateRoutes(c->route_reply, false); + + // FIXME, if any of our current pending packets were waiting for this route, send them (and leave them as regular + // pending packets until ack arrives) + // FIXME, if we don't get a route reply at all (or a route error), timeout and generate a routeerror TIMEOUT on our + // own... + break; + case Routing_error_reason_tag: + removeRoute(p->decoded.dest); + + // FIXME: if any pending packets were waiting on this route, delete them + break; + default: + break; + } + + // We simply ignore ACKs - because ReliableRouter will delete the pending packet for us + + // Handle regular packets + if (p->to == getNodeNum()) { // Destined for us (at least for this hop) + + // We need to route this packet to some other node + if (p->decoded.dest && p->decoded.dest != p->to) { + // if we have a route out, resend the packet to the next hop, otherwise return RouteError no-route available + + NodeNum nextHop = getNextHop(p->decoded.dest); + if (nextHop) { + sendNextHop(nextHop, p); // start a reliable single hop send + } else { + // We don't have a route out + assert(p->decoded.source); // I think this is guaranteed by now + + // FIXME - what if the current packet _is_ a route error packet? + sendRouteError(p, Routing_Error_NO_ROUTE); + } + + // FIXME, stop local processing of this packet + } + + if (c) { + // handle naks - convert them to route error packets + // All naks are generated locally, because we failed resending the packet too many times + PacketId nakId = c->error_reason ? p->decoded.request_id : 0; + if (nakId) { + auto pending = findPendingPacket(p->to, nakId); + if (pending && + pending->packet->decoded.source) { // if source not set, this was not a multihop packet, just ignore + removeRoute(pending->packet->decoded.dest); // We no longer have a route to the specified node + + sendRouteError(p, Routing_Error_GOT_NAK); + } + } + } + } + + ReliableRouter::sniffReceived(p, c); +} + +/** + * Does our node appear in the specified route + */ +bool DSRRouter::weAreInRoute(const RouteDiscovery &route) +{ + return true; // FIXME +} + +/** + * Given a DSR route, use that route to update our DB of possible routes + * + * Note: routes are always listed in the same order - from sender to receipient (i.e. route_replies also use this some order) + * + * @param isRequest is true if we are looking at a route request, else we are looking at a reply + **/ +void DSRRouter::updateRoutes(const RouteDiscovery &route, bool isRequest) +{ + DEBUG_MSG("FIXME not implemented updateRoutes\n"); +} + +/** + * send back a route reply (the sender address will be first in the list) + */ +void DSRRouter::sendRouteReply(const RouteDiscovery &route, NodeNum toAppend) +{ + DEBUG_MSG("FIXME not implemented sendRoute\n"); +} + +/** + * Given a nodenum return the next node we should forward to if we want to reach that node. + * + * @return 0 if no route found + */ +NodeNum DSRRouter::getNextHop(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented getNextHop\n"); + return 0; +} + +/** Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) + * + * We will bump down hop_limit in this call. + */ +void DSRRouter::resendRouteRequest(const MeshPacket *p) +{ + DEBUG_MSG("FIXME not implemented resendRoute\n"); +} + +/** + * Record that forwarder can reach dest for us, but they will need numHops to get there. + * If our routing tables already have something that can reach that node in fewer hops we will keep the existing route + * instead. + */ +void DSRRouter::addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops) +{ + DEBUG_MSG("FIXME not implemented addRoute\n"); +} + +/** + * Record that we no longer have a route to the dest + */ +void DSRRouter::removeRoute(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented removeRoute\n"); +} + +/** + * Forward the specified packet to the specified node + */ +void DSRRouter::sendNextHop(NodeNum n, const MeshPacket *p) +{ + DEBUG_MSG("FIXME not implemented sendNextHop\n"); +} + +/** + * Send a route error packet towards whoever originally sent this message + */ +void DSRRouter::sendRouteError(const MeshPacket *p, Routing_Error err) +{ + DEBUG_MSG("FIXME not implemented sendRouteError\n"); +} + +/** make a copy of p, start discovery, but only if we don't + * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission + * when the discovery is complete. + */ +void DSRRouter::startDiscovery(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented startDiscovery\n"); +} \ No newline at end of file diff --git a/src/mesh/DSRRouter.h b/src/mesh/DSRRouter.h new file mode 100644 index 000000000..0caa9310a --- /dev/null +++ b/src/mesh/DSRRouter.h @@ -0,0 +1,80 @@ +#include "ReliableRouter.h" + +class DSRRouter : public ReliableRouter +{ + + protected: + /** + * Every (non duplicate) packet this node receives will be passed through this method. This allows subclasses to + * update routing tables etc... based on what we overhear (even for messages not destined to our node) + */ + virtual void sniffReceived(const MeshPacket *p, const Routing *c) override; + + /** + * Send a packet on a suitable interface. This routine will + * later free() the packet to pool. This routine is not allowed to stall. + * If the txmit queue is full it might return an error + */ + virtual ErrorCode send(MeshPacket *p) override; + + private: + /** + * Does our node appear in the specified route + */ + bool weAreInRoute(const RouteDiscovery &route); + + /** + * Given a DSR route, use that route to update our DB of possible routes + * + * Note: routes are always listed in the same order - from sender to receipient (i.e. route_replies also use this some order) + * + * @param isRequest is true if we are looking at a route request, else we are looking at a reply + **/ + void updateRoutes(const RouteDiscovery &route, bool isRequest); + + /** + * send back a route reply (the sender address will be first in the list) + */ + void sendRouteReply(const RouteDiscovery &route, NodeNum toAppend = 0); + + /** + * Given a nodenum return the next node we should forward to if we want to reach that node. + * + * @return 0 if no route found + */ + NodeNum getNextHop(NodeNum dest); + + /** Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) + * + * We will bump down hop_limit in this call. + */ + void resendRouteRequest(const MeshPacket *p); + + /** + * Record that forwarder can reach dest for us, but they will need numHops to get there. + * If our routing tables already have something that can reach that node in fewer hops we will keep the existing route + * instead. + */ + void addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops); + + /** + * Record that we no longer have a route to the dest + */ + void removeRoute(NodeNum dest); + + /** + * Forward the specified packet to the specified node + */ + void sendNextHop(NodeNum n, const MeshPacket *p); + + /** + * Send a route error packet towards whoever originally sent this message + */ + void sendRouteError(const MeshPacket *p, Routing_Error err); + + /** make a copy of p, start discovery, but only if we don't + * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission + * when the discovery is complete. + */ + void startDiscovery(NodeNum dest); +}; From e5e13d78c366c66be9dfdbc23ecb8415ef14203a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 27 Feb 2022 12:56:18 -0800 Subject: [PATCH 77/93] Add role to generated proto --- src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/radioconfig.pb.c | 1 + src/mesh/generated/radioconfig.pb.h | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index fc9a20d56..6230efbe2 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 608 +#define AdminMessage_size 611 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.c b/src/mesh/generated/radioconfig.pb.c index 040c62fb2..a6e64691d 100644 --- a/src/mesh/generated/radioconfig.pb.c +++ b/src/mesh/generated/radioconfig.pb.c @@ -21,3 +21,4 @@ PB_BIND(RadioConfig_UserPreferences, RadioConfig_UserPreferences, 2) + diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 5c30273ac..182be895e 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -26,6 +26,12 @@ typedef enum _RegionCode { RegionCode_TH = 12 } RegionCode; +typedef enum _Role { + Role_Default = 0, + Role_Router = 1, + Role_Repeater = 2 +} Role; + typedef enum _ChargeCurrent { ChargeCurrent_MAUnset = 0, ChargeCurrent_MA100 = 1, @@ -123,6 +129,7 @@ typedef struct _RadioConfig_UserPreferences { RegionCode region; ChargeCurrent charge_current; bool position_broadcast_smart; + Role role; LocationSharing location_share; GpsOperation gps_operation; uint32_t gps_update_interval; @@ -204,6 +211,10 @@ typedef struct _RadioConfig { #define _RegionCode_MAX RegionCode_TH #define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TH+1)) +#define _Role_MIN Role_Default +#define _Role_MAX Role_Repeater +#define _Role_ARRAYSIZE ((Role)(Role_Repeater+1)) + #define _ChargeCurrent_MIN ChargeCurrent_MAUnset #define _ChargeCurrent_MAX ChargeCurrent_MA1320 #define _ChargeCurrent_ARRAYSIZE ((ChargeCurrent)(ChargeCurrent_MA1320+1)) @@ -239,9 +250,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 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, 0, _Role_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 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, 0, _Role_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_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, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -260,6 +271,7 @@ extern "C" { #define RadioConfig_UserPreferences_region_tag 15 #define RadioConfig_UserPreferences_charge_current_tag 16 #define RadioConfig_UserPreferences_position_broadcast_smart_tag 17 +#define RadioConfig_UserPreferences_role_tag 18 #define RadioConfig_UserPreferences_location_share_tag 32 #define RadioConfig_UserPreferences_gps_operation_tag 33 #define RadioConfig_UserPreferences_gps_update_interval_tag 34 @@ -353,6 +365,7 @@ X(a, STATIC, SINGULAR, BOOL, wifi_ap_mode, 14) \ X(a, STATIC, SINGULAR, UENUM, region, 15) \ X(a, STATIC, SINGULAR, UENUM, charge_current, 16) \ X(a, STATIC, SINGULAR, BOOL, position_broadcast_smart, 17) \ +X(a, STATIC, SINGULAR, UENUM, role, 18) \ X(a, STATIC, SINGULAR, UENUM, location_share, 32) \ X(a, STATIC, SINGULAR, UENUM, gps_operation, 33) \ X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 34) \ @@ -431,8 +444,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 605 -#define RadioConfig_UserPreferences_size 602 +#define RadioConfig_size 608 +#define RadioConfig_UserPreferences_size 605 #ifdef __cplusplus } /* extern "C" */ From 91b0fcb2576104a02aafaafa7d0ac4a024da0011 Mon Sep 17 00:00:00 2001 From: puzzled-pancake <78745145+puzzled-pancake@users.noreply.github.com> Date: Mon, 28 Feb 2022 10:39:48 +1300 Subject: [PATCH 78/93] Added comments on ANZ added 1w limit Added comments https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf https://www.iot.org.au/wp/wp-content/uploads/2016/12/IoTSpectrumFactSheet.pdf As noted 1w limit on both --- src/mesh/RadioInterface.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index d280377b4..c5046d6bb 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -48,9 +48,10 @@ const RegionInfo regions[] = { RDEF(JP, 920.8f, 927.8f, 100, 0, 16, true, false), /* - ??? + https://www.iot.org.au/wp/wp-content/uploads/2016/12/IoTSpectrumFactSheet.pdf + https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf */ - RDEF(ANZ, 915.0f, 928.0f, 100, 0, 0, true, false), + RDEF(ANZ, 915.0f, 928.0f, 100, 0, 30, true, false), /* https://digital.gov.ru/uploaded/files/prilozhenie-12-k-reshenyu-gkrch-18-46-03-1.pdf From ca4c1c9d7ce7f662a26ac1b3e1e2e14dd54b324a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 28 Feb 2022 21:19:38 +0000 Subject: [PATCH 79/93] Moved button thread to its own file (#1260) * Moved button thread to its own file * Move some debug code blocks into their own files * Shutdown refactoring * Removed GENIEBLOCKS --- src/ButtonThread.h | 220 +++++++++++++++++++++++++++++ src/debug/axpDebug.h | 19 +++ src/debug/i2cScan.h | 44 ++++++ src/main.cpp | 326 +------------------------------------------ src/main.h | 1 + src/shutdown.h | 41 ++++++ 6 files changed, 329 insertions(+), 322 deletions(-) create mode 100644 src/ButtonThread.h create mode 100644 src/debug/axpDebug.h create mode 100644 src/debug/i2cScan.h create mode 100644 src/shutdown.h diff --git a/src/ButtonThread.h b/src/ButtonThread.h new file mode 100644 index 000000000..1b86f0924 --- /dev/null +++ b/src/ButtonThread.h @@ -0,0 +1,220 @@ +#include "configuration.h" +#include "concurrency/OSThread.h" +#include "PowerFSM.h" +#include "RadioLibInterface.h" +#include "graphics/Screen.h" +#include "power.h" +#include "buzz.h" +#include + +#ifndef NO_ESP32 +#include "nimble/BluetoothUtil.h" +#endif + +namespace concurrency +{ +/** + * Watch a GPIO and if we get an IRQ, wake the main thread. + * Use to add wake on button press + */ +void wakeOnIrq(int irq, int mode) +{ + attachInterrupt( + irq, + [] { + BaseType_t higherWake = 0; + mainDelay.interruptFromISR(&higherWake); + }, + FALLING); +} + +class ButtonThread : public concurrency::OSThread +{ +// Prepare for button presses +#ifdef BUTTON_PIN + OneButton userButton; +#endif +#ifdef BUTTON_PIN_ALT + OneButton userButtonAlt; +#endif +#ifdef BUTTON_PIN_TOUCH + OneButton userButtonTouch; +#endif + static bool shutdown_on_long_stop; + + public: + static uint32_t longPressTime; + + // callback returns the period for the next callback invocation (or 0 if we should no longer be called) + ButtonThread() : OSThread("Button") + { +#ifdef BUTTON_PIN + userButton = OneButton(BUTTON_PIN, true, true); +#ifdef INPUT_PULLUP_SENSE + // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did + pinMode(BUTTON_PIN, INPUT_PULLUP_SENSE); +#endif + userButton.attachClick(userButtonPressed); + userButton.attachDuringLongPress(userButtonPressedLong); + userButton.attachDoubleClick(userButtonDoublePressed); + userButton.attachMultiClick(userButtonMultiPressed); + userButton.attachLongPressStart(userButtonPressedLongStart); + userButton.attachLongPressStop(userButtonPressedLongStop); + wakeOnIrq(BUTTON_PIN, FALLING); +#endif +#ifdef BUTTON_PIN_ALT + userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true); +#ifdef INPUT_PULLUP_SENSE + // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did + pinMode(BUTTON_PIN_ALT, INPUT_PULLUP_SENSE); +#endif + userButtonAlt.attachClick(userButtonPressed); + userButtonAlt.attachDuringLongPress(userButtonPressedLong); + userButtonAlt.attachDoubleClick(userButtonDoublePressed); + userButtonAlt.attachLongPressStart(userButtonPressedLongStart); + userButtonAlt.attachLongPressStop(userButtonPressedLongStop); + wakeOnIrq(BUTTON_PIN_ALT, FALLING); +#endif + +#ifdef BUTTON_PIN_TOUCH + userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); +#ifdef INPUT_PULLUP_SENSE + // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did + pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE); +#endif + userButtonTouch.attachClick(touchPressed); + userButtonTouch.attachDuringLongPress(touchPressedLong); + userButtonTouch.attachDoubleClick(touchDoublePressed); + userButtonTouch.attachLongPressStart(touchPressedLongStart); + userButtonTouch.attachLongPressStop(touchPressedLongStop); + wakeOnIrq(BUTTON_PIN_TOUCH, FALLING); +#endif + + } + + protected: + /// If the button is pressed we suppress CPU sleep until release + int32_t runOnce() override + { + canSleep = true; // Assume we should not keep the board awake + +#ifdef BUTTON_PIN + userButton.tick(); + canSleep &= userButton.isIdle(); +#endif +#ifdef BUTTON_PIN_ALT + userButtonAlt.tick(); + canSleep &= userButtonAlt.isIdle(); +#endif +#ifdef BUTTON_PIN_TOUCH + userButtonTouch.tick(); + canSleep &= userButtonTouch.isIdle(); +#endif + // if (!canSleep) DEBUG_MSG("Supressing sleep!\n"); + // else DEBUG_MSG("sleep ok\n"); + + return 5; + } + + private: + static void touchPressed() + { + screen->forceDisplay(); + DEBUG_MSG("touch press!\n"); + } + static void touchDoublePressed() + { + DEBUG_MSG("touch double press!\n"); + } + static void touchPressedLong() + { + DEBUG_MSG("touch press long!\n"); + } + static void touchDoublePressedLong() + { + DEBUG_MSG("touch double pressed!\n"); + } + static void touchPressedLongStart() + { + DEBUG_MSG("touch long press start!\n"); + } + static void touchPressedLongStop() + { + DEBUG_MSG("touch long press stop!\n"); + } + + + static void userButtonPressed() + { + // DEBUG_MSG("press!\n"); + powerFSM.trigger(EVENT_PRESS); + } + static void userButtonPressedLong() + { + // DEBUG_MSG("Long press!\n"); +#ifndef NRF52_SERIES + screen->adjustBrightness(); +#endif + // If user button is held down for 5 seconds, shutdown the device. + if (millis() - longPressTime > 5 * 1000) { +#ifdef TBEAM_V10 + if (axp192_found == true) { + setLed(false); + power->shutdown(); + } +#elif NRF52_SERIES + // Do actual shutdown when button released, otherwise the button release + // may wake the board immediatedly. + if (!shutdown_on_long_stop) { + screen->startShutdownScreen(); + DEBUG_MSG("Shutdown from long press"); + playBeep(); + ledOff(PIN_LED1); + ledOff(PIN_LED2); + shutdown_on_long_stop = true; + } +#endif + } else { + // DEBUG_MSG("Long press %u\n", (millis() - longPressTime)); + } + } + + static void userButtonDoublePressed() + { +#ifndef NO_ESP32 + disablePin(); +#elif defined(HAS_EINK) + digitalWrite(PIN_EINK_EN,digitalRead(PIN_EINK_EN) == LOW); +#endif + } + + static void userButtonMultiPressed() + { +#ifndef NO_ESP32 + clearNVS(); +#endif +#ifdef NRF52_SERIES + clearBonds(); +#endif + } + + + static void userButtonPressedLongStart() + { + DEBUG_MSG("Long press start!\n"); + longPressTime = millis(); + } + + static void userButtonPressedLongStop() + { + DEBUG_MSG("Long press stop!\n"); + longPressTime = 0; + if (shutdown_on_long_stop) { + playShutdownMelody(); + delay(3000); + power->shutdown(); + } + } +}; + +} \ No newline at end of file diff --git a/src/debug/axpDebug.h b/src/debug/axpDebug.h new file mode 100644 index 000000000..28e3ee26e --- /dev/null +++ b/src/debug/axpDebug.h @@ -0,0 +1,19 @@ +#if 0 +// Turn off for now +uint32_t axpDebugRead() +{ + axp.debugCharging(); + DEBUG_MSG("vbus current %f\n", axp.getVbusCurrent()); + DEBUG_MSG("charge current %f\n", axp.getBattChargeCurrent()); + DEBUG_MSG("bat voltage %f\n", axp.getBattVoltage()); + DEBUG_MSG("batt pct %d\n", axp.getBattPercentage()); + DEBUG_MSG("is battery connected %d\n", axp.isBatteryConnect()); + DEBUG_MSG("is USB connected %d\n", axp.isVBUSPlug()); + DEBUG_MSG("is charging %d\n", axp.isChargeing()); + + return 30 * 1000; +} + +Periodic axpDebugOutput(axpDebugRead); +axpDebugOutput.setup(); +#endif \ No newline at end of file diff --git a/src/debug/i2cScan.h b/src/debug/i2cScan.h new file mode 100644 index 000000000..4752bf0bf --- /dev/null +++ b/src/debug/i2cScan.h @@ -0,0 +1,44 @@ +#include "../configuration.h" +#include "../main.h" +#include + +#ifndef NO_WIRE +void scanI2Cdevice(void) +{ + byte err, addr; + int nDevices = 0; + for (addr = 1; addr < 127; addr++) { + Wire.beginTransmission(addr); + err = Wire.endTransmission(); + if (err == 0) { + DEBUG_MSG("I2C device found at address 0x%x\n", addr); + + nDevices++; + + if (addr == SSD1306_ADDRESS) { + screen_found = addr; + DEBUG_MSG("ssd1306 display found\n"); + } + if (addr == ST7567_ADDRESS) { + screen_found = addr; + DEBUG_MSG("st7567 display found\n"); + } +#ifdef AXP192_SLAVE_ADDRESS + if (addr == AXP192_SLAVE_ADDRESS) { + axp192_found = true; + DEBUG_MSG("axp192 PMU found\n"); + } +#endif + } else if (err == 4) { + DEBUG_MSG("Unknow error at address 0x%x\n", addr); + } + } + + if (nDevices == 0) + DEBUG_MSG("No I2C devices found\n"); + else + DEBUG_MSG("done\n"); +} +#else +void scanI2Cdevice(void) {} +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f025d3dd2..400ddff63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,8 +20,10 @@ #include "main.h" #include "modules/Modules.h" #include "sleep.h" +#include "shutdown.h" #include "target_specific.h" -#include +#include "debug/i2cScan.h" +#include "debug/axpDebug.h" #include // #include @@ -41,6 +43,7 @@ #include "SX1262Interface.h" #include "SX1268Interface.h" #include "LLCC68Interface.h" +#include "ButtonThread.h" using namespace concurrency; @@ -64,50 +67,6 @@ bool axp192_found; Router *router = NULL; // Users of router don't care what sort of subclass implements that API -// ----------------------------------------------------------------------------- -// Application -// ----------------------------------------------------------------------------- -#ifndef NO_WIRE -void scanI2Cdevice(void) -{ - byte err, addr; - int nDevices = 0; - for (addr = 1; addr < 127; addr++) { - Wire.beginTransmission(addr); - err = Wire.endTransmission(); - if (err == 0) { - DEBUG_MSG("I2C device found at address 0x%x\n", addr); - - nDevices++; - - if (addr == SSD1306_ADDRESS) { - screen_found = addr; - DEBUG_MSG("ssd1306 display found\n"); - } - if (addr == ST7567_ADDRESS) { - screen_found = addr; - DEBUG_MSG("st7567 display found\n"); - } -#ifdef AXP192_SLAVE_ADDRESS - if (addr == AXP192_SLAVE_ADDRESS) { - axp192_found = true; - DEBUG_MSG("axp192 PMU found\n"); - } -#endif - } else if (err == 4) { - DEBUG_MSG("Unknow error at address 0x%x\n", addr); - } - } - - if (nDevices == 0) - DEBUG_MSG("No I2C devices found\n"); - else - DEBUG_MSG("done\n"); -} -#else -void scanI2Cdevice(void) {} -#endif - const char *getDeviceName() { uint8_t dmac[6]; @@ -161,210 +120,6 @@ class PowerFSMThread : public OSThread } }; -/** - * Watch a GPIO and if we get an IRQ, wake the main thread. - * Use to add wake on button press - */ -void wakeOnIrq(int irq, int mode) -{ - attachInterrupt( - irq, - [] { - BaseType_t higherWake = 0; - mainDelay.interruptFromISR(&higherWake); - }, - FALLING); -} - -class ButtonThread : public OSThread -{ -// Prepare for button presses -#ifdef BUTTON_PIN - OneButton userButton; -#endif -#ifdef BUTTON_PIN_ALT - OneButton userButtonAlt; -#endif -#ifdef BUTTON_PIN_TOUCH - OneButton userButtonTouch; -#endif - static bool shutdown_on_long_stop; - - public: - static uint32_t longPressTime; - - // callback returns the period for the next callback invocation (or 0 if we should no longer be called) - ButtonThread() : OSThread("Button") - { -#ifdef BUTTON_PIN - userButton = OneButton(BUTTON_PIN, true, true); -#ifdef INPUT_PULLUP_SENSE - // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did - pinMode(BUTTON_PIN, INPUT_PULLUP_SENSE); -#endif - userButton.attachClick(userButtonPressed); - userButton.attachDuringLongPress(userButtonPressedLong); - userButton.attachDoubleClick(userButtonDoublePressed); - userButton.attachMultiClick(userButtonMultiPressed); - userButton.attachLongPressStart(userButtonPressedLongStart); - userButton.attachLongPressStop(userButtonPressedLongStop); - wakeOnIrq(BUTTON_PIN, FALLING); -#endif -#ifdef BUTTON_PIN_ALT - userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true); -#ifdef INPUT_PULLUP_SENSE - // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did - pinMode(BUTTON_PIN_ALT, INPUT_PULLUP_SENSE); -#endif - userButtonAlt.attachClick(userButtonPressed); - userButtonAlt.attachDuringLongPress(userButtonPressedLong); - userButtonAlt.attachDoubleClick(userButtonDoublePressed); - userButtonAlt.attachLongPressStart(userButtonPressedLongStart); - userButtonAlt.attachLongPressStop(userButtonPressedLongStop); - wakeOnIrq(BUTTON_PIN_ALT, FALLING); -#endif - -#ifdef BUTTON_PIN_TOUCH - userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); -#ifdef INPUT_PULLUP_SENSE - // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did - pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE); -#endif - userButtonTouch.attachClick(touchPressed); - userButtonTouch.attachDuringLongPress(touchPressedLong); - userButtonTouch.attachDoubleClick(touchDoublePressed); - userButtonTouch.attachLongPressStart(touchPressedLongStart); - userButtonTouch.attachLongPressStop(touchPressedLongStop); - wakeOnIrq(BUTTON_PIN_TOUCH, FALLING); -#endif - - } - - protected: - /// If the button is pressed we suppress CPU sleep until release - int32_t runOnce() override - { - canSleep = true; // Assume we should not keep the board awake - -#ifdef BUTTON_PIN - userButton.tick(); - canSleep &= userButton.isIdle(); -#endif -#ifdef BUTTON_PIN_ALT - userButtonAlt.tick(); - canSleep &= userButtonAlt.isIdle(); -#endif -#ifdef BUTTON_PIN_TOUCH - userButtonTouch.tick(); - canSleep &= userButtonTouch.isIdle(); -#endif - // if (!canSleep) DEBUG_MSG("Supressing sleep!\n"); - // else DEBUG_MSG("sleep ok\n"); - - return 5; - } - - private: - static void touchPressed() - { - screen->forceDisplay(); - DEBUG_MSG("touch press!\n"); - } - static void touchDoublePressed() - { - DEBUG_MSG("touch double press!\n"); - } - static void touchPressedLong() - { - DEBUG_MSG("touch press long!\n"); - } - static void touchDoublePressedLong() - { - DEBUG_MSG("touch double pressed!\n"); - } - static void touchPressedLongStart() - { - DEBUG_MSG("touch long press start!\n"); - } - static void touchPressedLongStop() - { - DEBUG_MSG("touch long press stop!\n"); - } - - - static void userButtonPressed() - { - // DEBUG_MSG("press!\n"); - powerFSM.trigger(EVENT_PRESS); - } - static void userButtonPressedLong() - { - // DEBUG_MSG("Long press!\n"); -#ifndef NRF52_SERIES - screen->adjustBrightness(); -#endif - // If user button is held down for 5 seconds, shutdown the device. - if (millis() - longPressTime > 5 * 1000) { -#ifdef TBEAM_V10 - if (axp192_found == true) { - setLed(false); - power->shutdown(); - } -#elif NRF52_SERIES - // Do actual shutdown when button released, otherwise the button release - // may wake the board immediatedly. - if (!shutdown_on_long_stop) { - screen->startShutdownScreen(); - DEBUG_MSG("Shutdown from long press"); - playBeep(); - ledOff(PIN_LED1); - ledOff(PIN_LED2); - shutdown_on_long_stop = true; - } -#endif - } else { - // DEBUG_MSG("Long press %u\n", (millis() - longPressTime)); - } - } - - static void userButtonDoublePressed() - { -#ifndef NO_ESP32 - disablePin(); -#elif defined(HAS_EINK) - digitalWrite(PIN_EINK_EN,digitalRead(PIN_EINK_EN) == LOW); -#endif - } - - static void userButtonMultiPressed() - { -#ifndef NO_ESP32 - clearNVS(); -#endif -#ifdef NRF52_SERIES - clearBonds(); -#endif - } - - - static void userButtonPressedLongStart() - { - DEBUG_MSG("Long press start!\n"); - longPressTime = millis(); - } - - static void userButtonPressedLongStop() - { - DEBUG_MSG("Long press stop!\n"); - longPressTime = 0; - if (shutdown_on_long_stop) { - playShutdownMelody(); - delay(3000); - power->shutdown(); - } - } -}; - bool ButtonThread::shutdown_on_long_stop = false; static Periodic *ledPeriodic; @@ -510,22 +265,6 @@ void setup() readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time) -#ifdef GENIEBLOCKS - Im intentionally breaking your build so you see this note.Feel free to revert if not correct.I think you can - remove this GPS_RESET_N code by instead defining PIN_GPS_RESET and - use the shared code in GPS.cpp instead.- geeksville - - // gps setup - pinMode(GPS_RESET_N, OUTPUT); - pinMode(GPS_EXTINT, OUTPUT); - digitalWrite(GPS_RESET_N, HIGH); - digitalWrite(GPS_EXTINT, LOW); - // battery setup - // If we want to read battery level, we need to set BATTERY_EN_PIN pin to low. - // ToDo: For low power consumption after read battery level, set that pin to high. - pinMode(BATTERY_EN_PIN, OUTPUT); - digitalWrite(BATTERY_EN_PIN, LOW); -#endif gps = createGps(); if (gps) @@ -680,66 +419,9 @@ void setup() setCPUFast(false); // 80MHz is fine for our slow peripherals } -#if 0 -// Turn off for now - -uint32_t axpDebugRead() -{ - axp.debugCharging(); - DEBUG_MSG("vbus current %f\n", axp.getVbusCurrent()); - DEBUG_MSG("charge current %f\n", axp.getBattChargeCurrent()); - DEBUG_MSG("bat voltage %f\n", axp.getBattVoltage()); - DEBUG_MSG("batt pct %d\n", axp.getBattPercentage()); - DEBUG_MSG("is battery connected %d\n", axp.isBatteryConnect()); - DEBUG_MSG("is USB connected %d\n", axp.isVBUSPlug()); - DEBUG_MSG("is charging %d\n", axp.isChargeing()); - - return 30 * 1000; -} - -Periodic axpDebugOutput(axpDebugRead); -axpDebugOutput.setup(); -#endif - uint32_t rebootAtMsec; // If not zero we will reboot at this time (used to reboot shortly after the update completes) uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to shutdown from python or mobile client) -void powerCommandsCheck() -{ - if (rebootAtMsec && millis() > rebootAtMsec) { -#ifndef NO_ESP32 - DEBUG_MSG("Rebooting for update\n"); - ESP.restart(); -#else - DEBUG_MSG("FIXME implement reboot for this platform"); -#endif - } - -#if NRF52_SERIES - if (shutdownAtMsec) { - screen->startShutdownScreen(); - playBeep(); - ledOff(PIN_LED1); - ledOff(PIN_LED2); - } -#endif - - if (shutdownAtMsec && millis() > shutdownAtMsec) { - DEBUG_MSG("Shutting down from admin command\n"); -#ifdef TBEAM_V10 - if (axp192_found == true) { - setLed(false); - power->shutdown(); - } -#elif NRF52_SERIES - playShutdownMelody(); - power->shutdown(); -#else - DEBUG_MSG("FIXME implement shutdown for this platform"); -#endif - } -} - // If a thread does something that might need for it to be rescheduled ASAP it can set this flag // This will supress the current delay and instead try to run ASAP. bool runASAP; diff --git a/src/main.h b/src/main.h index 2d93caebb..c03652368 100644 --- a/src/main.h +++ b/src/main.h @@ -5,6 +5,7 @@ #include "PowerStatus.h" #include "graphics/Screen.h" +extern uint8_t screen_found; extern bool axp192_found; extern bool isCharging; extern bool isUSBPowered; diff --git a/src/shutdown.h b/src/shutdown.h new file mode 100644 index 000000000..10c93bde2 --- /dev/null +++ b/src/shutdown.h @@ -0,0 +1,41 @@ +#include "configuration.h" +#include "graphics/Screen.h" +#include "power.h" +#include "buzz.h" +#include "main.h" + +void powerCommandsCheck() +{ + if (rebootAtMsec && millis() > rebootAtMsec) { +#ifndef NO_ESP32 + DEBUG_MSG("Rebooting for update\n"); + ESP.restart(); +#else + DEBUG_MSG("FIXME implement reboot for this platform"); +#endif + } + +#if NRF52_SERIES + if (shutdownAtMsec) { + screen->startShutdownScreen(); + playBeep(); + ledOff(PIN_LED1); + ledOff(PIN_LED2); + } +#endif + + if (shutdownAtMsec && millis() > shutdownAtMsec) { + DEBUG_MSG("Shutting down from admin command\n"); +#ifdef TBEAM_V10 + if (axp192_found == true) { + setLed(false); + power->shutdown(); + } +#elif NRF52_SERIES + playShutdownMelody(); + power->shutdown(); +#else + DEBUG_MSG("FIXME implement shutdown for this platform"); +#endif + } +} From ac8ba706f07cf671888c0a006e9396bb8fe9e5b9 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 28 Feb 2022 17:07:31 -0800 Subject: [PATCH 80/93] Add rssi meta data to the rf95 interface --- src/mesh/RF95Interface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index 5a1cce32a..adaeead46 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -140,6 +140,8 @@ bool RF95Interface::reconfigure() void RF95Interface::addReceiveMetadata(MeshPacket *mp) { mp->rx_snr = lora->getSNR(); + mp->rx_rssi = lround(lora->getRSSI()); + } void RF95Interface::setStandby() From 32ef354c2291010b483cf12aacb22d644d2e4ab0 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 28 Feb 2022 17:47:09 -0800 Subject: [PATCH 81/93] Add rssi to printPacket --- src/mesh/RadioInterface.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index d280377b4..509b51d51 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -218,6 +218,9 @@ void printPacket(const char *prefix, const MeshPacket *p) if (p->rx_snr != 0.0) { DEBUG_MSG(" rxSNR=%g", p->rx_snr); } + if (p->rx_rssi != 0) { + DEBUG_MSG(" rxSNR=%g", p->rx_rssi); + } if (p->priority != 0) DEBUG_MSG(" priority=%d", p->priority); From 4209fc8b2c2c1ca5bf7b40d6b3bb229ab63b5543 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 28 Feb 2022 19:35:59 -0800 Subject: [PATCH 82/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index d18545583..6de2cab5c 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit d1854558375a712cddc914bfebe69fd5e279be83 +Subproject commit 6de2cab5c503bd2550b110a15ab36e0a139be181 From 2fa8f45d74f0630ade5b05010e89a6e0740b3293 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 28 Feb 2022 22:03:39 -0800 Subject: [PATCH 83/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 6de2cab5c..7c49bdad9 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 6de2cab5c503bd2550b110a15ab36e0a139be181 +Subproject commit 7c49bdad99f53332d17796188fc89fd5c29e0ce3 From 4d8c0c11dc472b282f5bd323e54d5061e52fc958 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Mon, 28 Feb 2022 22:44:51 -0800 Subject: [PATCH 84/93] Added router to mynodeinfo --- src/mesh/FloodingRouter.h | 6 ++++++ src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 33 ++++++++++++++++++++++-------- src/mesh/generated/portnums.pb.h | 1 - 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/mesh/FloodingRouter.h b/src/mesh/FloodingRouter.h index 387b4576b..2fae67666 100644 --- a/src/mesh/FloodingRouter.h +++ b/src/mesh/FloodingRouter.h @@ -52,6 +52,12 @@ class FloodingRouter : public Router, protected PacketHistory */ virtual bool shouldFilterReceived(MeshPacket *p) override; + /** + * Are we in range of a router? + * @return true if we're in range of a router + */ + virtual bool rangeOfRouter(const MeshPacket *p); + /** * Look for broadcasts we need to rebroadcast */ diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index c6d468adc..75dd95bef 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -87,7 +87,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 9973 +#define DeviceState_size 10109 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 8e98195ed..1bc2d32ac 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -169,6 +169,12 @@ typedef struct _MyNodeInfo { bool has_wifi; float channel_utilization; float air_util_tx; + pb_size_t router_count; + uint32_t router[4]; + pb_size_t router_snr_count; + float router_snr[4]; + pb_size_t router_sec_count; + uint16_t router_sec[4]; } MyNodeInfo; typedef struct _Position { @@ -176,6 +182,7 @@ typedef struct _Position { int32_t longitude_i; int32_t altitude; int32_t battery_level; + bool router_heartbeat; uint32_t time; Position_LocSource location_source; Position_AltSource altitude_source; @@ -330,26 +337,26 @@ extern "C" { #endif /* Initializer values for message structs */ -#define Position_init_default {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define Position_init_default {0, 0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_default {0, {RouteDiscovery_init_default}} #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} -#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} +#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} #define ToRadio_PeerInfo_init_default {0, 0} -#define Position_init_zero {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define Position_init_zero {0, 0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN, 0, 0, 0} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} -#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0} +#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} @@ -385,10 +392,14 @@ extern "C" { #define MyNodeInfo_has_wifi_tag 18 #define MyNodeInfo_channel_utilization_tag 19 #define MyNodeInfo_air_util_tx_tag 20 +#define MyNodeInfo_router_tag 21 +#define MyNodeInfo_router_snr_tag 22 +#define MyNodeInfo_router_sec_tag 23 #define Position_latitude_i_tag 1 #define Position_longitude_i_tag 2 #define Position_altitude_tag 3 #define Position_battery_level_tag 4 +#define Position_router_heartbeat_tag 5 #define Position_time_tag 9 #define Position_location_source_tag 10 #define Position_altitude_source_tag 11 @@ -460,6 +471,7 @@ X(a, STATIC, SINGULAR, SFIXED32, latitude_i, 1) \ X(a, STATIC, SINGULAR, SFIXED32, longitude_i, 2) \ X(a, STATIC, SINGULAR, INT32, altitude, 3) \ X(a, STATIC, SINGULAR, INT32, battery_level, 4) \ +X(a, STATIC, SINGULAR, BOOL, router_heartbeat, 5) \ X(a, STATIC, SINGULAR, FIXED32, time, 9) \ X(a, STATIC, SINGULAR, UENUM, location_source, 10) \ X(a, STATIC, SINGULAR, UENUM, altitude_source, 11) \ @@ -568,7 +580,10 @@ X(a, STATIC, REPEATED, UINT32, air_period_tx, 16) \ X(a, STATIC, REPEATED, UINT32, air_period_rx, 17) \ X(a, STATIC, SINGULAR, BOOL, has_wifi, 18) \ X(a, STATIC, SINGULAR, FLOAT, channel_utilization, 19) \ -X(a, STATIC, SINGULAR, FLOAT, air_util_tx, 20) +X(a, STATIC, SINGULAR, FLOAT, air_util_tx, 20) \ +X(a, STATIC, REPEATED, UINT32, router, 21) \ +X(a, STATIC, REPEATED, FLOAT, router_snr, 22) \ +X(a, STATIC, REPEATED, UINT32, router_sec, 23) #define MyNodeInfo_CALLBACK NULL #define MyNodeInfo_DEFAULT NULL @@ -639,16 +654,16 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define ToRadio_PeerInfo_fields &ToRadio_PeerInfo_msg /* Maximum encoded size of messages (where known) */ -#define Position_size 153 +#define Position_size 155 #define User_size 97 #define RouteDiscovery_size 40 #define Routing_size 42 #define Data_size 267 #define MeshPacket_size 318 -#define NodeInfo_size 271 -#define MyNodeInfo_size 434 +#define NodeInfo_size 273 +#define MyNodeInfo_size 506 #define LogRecord_size 81 -#define FromRadio_size 443 +#define FromRadio_size 515 #define ToRadio_size 321 #define ToRadio_PeerInfo_size 8 diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index 9b70f80ce..0ba48d592 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -20,7 +20,6 @@ typedef enum _PortNum { PortNum_ADMIN_APP = 6, PortNum_REPLY_APP = 32, PortNum_IP_TUNNEL_APP = 33, - PortNum_ROUTER_APP = 34, PortNum_SERIAL_APP = 64, PortNum_STORE_FORWARD_APP = 65, PortNum_RANGE_TEST_APP = 66, From 556fc6210de2499e03413cf1b2da86c500358f6e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 1 Mar 2022 18:40:21 +0000 Subject: [PATCH 85/93] Moved power fsm thread out of main (#1265) --- src/PowerFSMThread.h | 38 ++++++++++++++++++++++++++++++++++++++ src/main.cpp | 31 ++----------------------------- src/main.h | 2 ++ 3 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 src/PowerFSMThread.h diff --git a/src/PowerFSMThread.h b/src/PowerFSMThread.h new file mode 100644 index 000000000..00f31e9c3 --- /dev/null +++ b/src/PowerFSMThread.h @@ -0,0 +1,38 @@ +#include "configuration.h" +#include "concurrency/OSThread.h" +#include "main.h" +#include "PowerFSM.h" +#include "power.h" +#include "NodeDB.h" + +namespace concurrency +{ +/// Wrapper to convert our powerFSM stuff into a 'thread' +class PowerFSMThread : public OSThread +{ + public: + // callback returns the period for the next callback invocation (or 0 if we should no longer be called) + PowerFSMThread() : OSThread("PowerFSM") {} + + protected: + int32_t runOnce() override + { + powerFSM.run_machine(); + + /// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake + /// cpu for serial rx - FIXME) + auto state = powerFSM.getState(); + canSleep = (state != &statePOWER) && (state != &stateSERIAL); + + if (powerStatus->getHasUSB()) { + timeLastPowered = millis(); + } else if (radioConfig.preferences.on_battery_shutdown_after_secs > 0 && + millis() > timeLastPowered + (1000 * radioConfig.preferences.on_battery_shutdown_after_secs)) { //shutdown after 30 minutes unpowered + powerFSM.trigger(EVENT_SHUTDOWN); + } + + return 10; + } +}; + +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 400ddff63..fcbe8d912 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,8 +43,9 @@ #include "SX1262Interface.h" #include "SX1268Interface.h" #include "LLCC68Interface.h" -#include "ButtonThread.h" +#include "ButtonThread.h" +#include "PowerFSMThread.h" using namespace concurrency; @@ -92,34 +93,6 @@ static int32_t ledBlinker() uint32_t timeLastPowered = 0; -/// Wrapper to convert our powerFSM stuff into a 'thread' -class PowerFSMThread : public OSThread -{ - public: - // callback returns the period for the next callback invocation (or 0 if we should no longer be called) - PowerFSMThread() : OSThread("PowerFSM") {} - - protected: - int32_t runOnce() override - { - powerFSM.run_machine(); - - /// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake - /// cpu for serial rx - FIXME) - auto state = powerFSM.getState(); - canSleep = (state != &statePOWER) && (state != &stateSERIAL); - - if (powerStatus->getHasUSB()) { - timeLastPowered = millis(); - } else if (radioConfig.preferences.on_battery_shutdown_after_secs > 0 && - millis() > timeLastPowered + (1000 * radioConfig.preferences.on_battery_shutdown_after_secs)) { //shutdown after 30 minutes unpowered - powerFSM.trigger(EVENT_SHUTDOWN); - } - - return 10; - } -}; - bool ButtonThread::shutdown_on_long_stop = false; static Periodic *ledPeriodic; diff --git a/src/main.h b/src/main.h index c03652368..b87b1886d 100644 --- a/src/main.h +++ b/src/main.h @@ -21,6 +21,8 @@ extern graphics::Screen *screen; // Return a human readable string of the form "Meshtastic_ab13" const char *getDeviceName(); +extern uint32_t timeLastPowered; + extern uint32_t rebootAtMsec; extern uint32_t shutdownAtMsec; From 09edd7f89bcdcb5f1922a184a5f13ce6acae3e6f Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 18:49:46 -0800 Subject: [PATCH 86/93] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 7c49bdad9..f6ba3722b 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 7c49bdad99f53332d17796188fc89fd5c29e0ce3 +Subproject commit f6ba3722be8a51c3c0c1446bb08e730a0be568e0 From 2c7b3acbb9f7534d7dc7cc07fbc8524fb1a5f7d7 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 18:55:11 -0800 Subject: [PATCH 87/93] Fix tophone build error --- src/airtime.cpp | 8 +++---- src/mesh/FloodingRouter.cpp | 38 ++++++++++++++++++++++++++---- src/mesh/FloodingRouter.h | 4 +++- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.c | 2 +- src/mesh/generated/mesh.pb.h | 12 +++++----- 6 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 5c0378cfa..598820782 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -31,7 +31,7 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) uint8_t AirTime::currentPeriodIndex() { - return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % PERIODS_TO_LOG); + return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % myNodeInfo.air_period_rx_count); } uint8_t AirTime::getPeriodUtilMinute() { @@ -48,7 +48,7 @@ void AirTime::airtimeRotatePeriod() if (this->airtimes.lastPeriodIndex != this->currentPeriodIndex()) { DEBUG_MSG("Rotating airtimes to a new period = %u\n", this->currentPeriodIndex()); - for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { + for (int i = myNodeInfo.air_period_rx_count - 2; i >= 0; --i) { this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[i]; this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i]; this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i]; @@ -83,7 +83,7 @@ uint32_t *AirTime::airtimeReport(reportTypes reportType) uint8_t AirTime::getPeriodsToLog() { - return PERIODS_TO_LOG; + return myNodeInfo.air_period_rx_count; } uint32_t AirTime::getSecondsPerPeriod() @@ -140,7 +140,7 @@ int32_t AirTime::runOnce() } // Init airtime windows to all 0 - for (int i = 0; i < PERIODS_TO_LOG; i++) { + for (int i = 0; i < myNodeInfo.air_period_rx_count; i++) { this->airtimes.periodTX[i] = 0; this->airtimes.periodRX[i] = 0; this->airtimes.periodRX_ALL[i] = 0; diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 14ce6dd02..0a14552ab 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -1,5 +1,5 @@ -#include "configuration.h" #include "FloodingRouter.h" +#include "configuration.h" #include "mesh-pb-constants.h" FloodingRouter::FloodingRouter() {} @@ -27,11 +27,41 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p) return Router::shouldFilterReceived(p); } +bool FloodingRouter::inRangeOfRouter() +{ + + uint32_t maximum_router_sec = 300; + + // FIXME : Scale minimum_snr to accomodate different modem configurations. + float minimum_snr = 2; + + for (int i = 0; i < myNodeInfo.router_count; i++) { + // A router has been seen and the heartbeat was heard within the last 300 seconds + if ( + ((myNodeInfo.router_sec[i] > 0) && (myNodeInfo.router_sec[i] < maximum_router_sec)) && + (myNodeInfo.router_snr[i] > minimum_snr) + ) { + return true; + } + } + + return false; +} + void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c) { - // If a broadcast, possibly _also_ send copies out into the mesh. - // (FIXME, do something smarter than naive flooding here) - if (p->to == NODENUM_BROADCAST && p->hop_limit > 0 && getFrom(p) != getNodeNum()) { + bool rebroadcastPacket = true; + + if (radioConfig.preferences.role == Role_Repeater || radioConfig.preferences.role == Role_Router) { + rebroadcastPacket = true; + + } else if ((radioConfig.preferences.role == Role_Default) && inRangeOfRouter()) { + DEBUG_MSG("Role_Default - rx_snr > 13\n"); + + rebroadcastPacket = false; + } + + if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum() && rebroadcastPacket)) { if (p->id != 0) { MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it diff --git a/src/mesh/FloodingRouter.h b/src/mesh/FloodingRouter.h index 2fae67666..9b54008d0 100644 --- a/src/mesh/FloodingRouter.h +++ b/src/mesh/FloodingRouter.h @@ -54,9 +54,11 @@ class FloodingRouter : public Router, protected PacketHistory /** * Are we in range of a router? + * + * "range" here may not be the right term. * @return true if we're in range of a router */ - virtual bool rangeOfRouter(const MeshPacket *p); + virtual bool inRangeOfRouter(); /** * Look for broadcasts we need to rebroadcast diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 75dd95bef..c7183ba9a 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -87,7 +87,7 @@ extern const pb_msgdesc_t ChannelFile_msg; #define ChannelFile_fields &ChannelFile_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 10109 +#define DeviceState_size 9885 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c index 6846dc540..636535936 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/mesh.pb.c @@ -27,7 +27,7 @@ PB_BIND(MeshPacket, MeshPacket, 2) PB_BIND(NodeInfo, NodeInfo, AUTO) -PB_BIND(MyNodeInfo, MyNodeInfo, 2) +PB_BIND(MyNodeInfo, MyNodeInfo, AUTO) PB_BIND(LogRecord, LogRecord, AUTO) diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 1bc2d32ac..bda47e04c 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -163,9 +163,9 @@ typedef struct _MyNodeInfo { uint32_t min_app_version; uint32_t max_channels; pb_size_t air_period_tx_count; - uint32_t air_period_tx[24]; + uint32_t air_period_tx[8]; pb_size_t air_period_rx_count; - uint32_t air_period_rx[24]; + uint32_t air_period_rx[8]; bool has_wifi; float channel_utilization; float air_util_tx; @@ -344,7 +344,7 @@ extern "C" { #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} -#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} +#define MyNodeInfo_init_default {0, 0, "", "", _CriticalErrorCode_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, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} @@ -356,7 +356,7 @@ extern "C" { #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} -#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 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, 0}, 0, 0, 0, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} +#define MyNodeInfo_init_zero {0, 0, "", "", _CriticalErrorCode_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, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}, 0, {0, 0, 0, 0}} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} @@ -661,9 +661,9 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_size 267 #define MeshPacket_size 318 #define NodeInfo_size 273 -#define MyNodeInfo_size 506 +#define MyNodeInfo_size 282 #define LogRecord_size 81 -#define FromRadio_size 515 +#define FromRadio_size 327 #define ToRadio_size 321 #define ToRadio_PeerInfo_size 8 From ee533b2d5ce426b8c72648bc914e1002343d22e8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 19:02:08 -0800 Subject: [PATCH 88/93] Bumping to 1.3.1 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 2657b0278..04de8d925 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 0 +build = 1 From c1613de4267d80c7cdaa2eb901d6c5648ef25a2a Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 3 Mar 2022 04:27:49 +0000 Subject: [PATCH 89/93] merge the 1.2 hang bugfix to 1.3 --- src/mesh/PhoneAPI.h | 2 +- src/mesh/Router.cpp | 2 +- suppressions.txt | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 684f683f8..ca926b096 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -59,7 +59,7 @@ class PhoneAPI // Call this when the client drops the connection, resets the state to STATE_SEND_NOTHING // Unregisters our observer. A closed connection **can** be reopened by calling init again. - void close(); + virtual void close(); /** * Handle a ToRadio protobuf diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 7f0dbd51f..f3210f1ec 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -276,7 +276,7 @@ bool perhapsDecode(MeshPacket *p) if (p->which_payloadVariant == MeshPacket_decoded_tag) return true; // If packet was already decoded just return - assert(p->which_payloadVariant == MeshPacket_encrypted_tag); + //assert(p->which_payloadVariant == MeshPacket_encrypted_tag); // Try to find a channel that works with this hash for (ChannelIndex chIndex = 0; chIndex < channels.getNumChannels(); chIndex++) { diff --git a/suppressions.txt b/suppressions.txt index cdf858753..42dd40c33 100644 --- a/suppressions.txt +++ b/suppressions.txt @@ -36,3 +36,7 @@ cstyleCast // ignore stuff that is not ours *:.pio/* *:*/libdeps/* + +// these two caused issues +missingOverride +virtualCallInConstructor From 0f862edc4762fc1d521ec90e849a4e107fec0e4c Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Thu, 3 Mar 2022 04:29:34 +0000 Subject: [PATCH 90/93] remove the --user --- bin/platformio-custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index d4117b4b8..4672dbc96 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -11,7 +11,7 @@ env.Replace( MKSPIFFSTOOL=env.get("PROJECT_DIR") + '/bin/mklittlefs.py' ) try: import littlefs except ImportError: - env.Execute("$PYTHONEXE -m pip install --user littlefs-python") + env.Execute("$PYTHONEXE -m pip install littlefs-python") Import("projenv") From 75bf2cc9c63674a94e37ad087d86125c2f1ffc82 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 20:38:14 -0800 Subject: [PATCH 91/93] Update PERIODS_TO_LOG --- src/airtime.cpp | 6 +++--- src/airtime.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 598820782..fed4ef8aa 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -31,7 +31,7 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) uint8_t AirTime::currentPeriodIndex() { - return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % myNodeInfo.air_period_rx_count); + return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % PERIODS_TO_LOG); } uint8_t AirTime::getPeriodUtilMinute() { @@ -48,7 +48,7 @@ void AirTime::airtimeRotatePeriod() if (this->airtimes.lastPeriodIndex != this->currentPeriodIndex()) { DEBUG_MSG("Rotating airtimes to a new period = %u\n", this->currentPeriodIndex()); - for (int i = myNodeInfo.air_period_rx_count - 2; i >= 0; --i) { + for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[i]; this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i]; this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i]; @@ -83,7 +83,7 @@ uint32_t *AirTime::airtimeReport(reportTypes reportType) uint8_t AirTime::getPeriodsToLog() { - return myNodeInfo.air_period_rx_count; + return PERIODS_TO_LOG; } uint32_t AirTime::getSecondsPerPeriod() diff --git a/src/airtime.h b/src/airtime.h index 6491e3648..f6b9bdcb5 100644 --- a/src/airtime.h +++ b/src/airtime.h @@ -26,7 +26,7 @@ #define CHANNEL_UTILIZATION_PERIODS 6 #define SECONDS_PER_PERIOD 3600 -#define PERIODS_TO_LOG 24 +#define PERIODS_TO_LOG 8 #define MINUTES_IN_HOUR 60 #define SECONDS_IN_MINUTE 60 #define MS_IN_HOUR (MINUTES_IN_HOUR * SECONDS_IN_MINUTE * 1000) From 958f20da1accd674d6541e7ca4c75a32c8571227 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 20:42:05 -0800 Subject: [PATCH 92/93] Update to 1.3.2 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 04de8d925..c2192c347 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 1 +build = 2 From 2fe124eb17aed5aac58eb4a7d6384d375af6a80c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 2 Mar 2022 20:50:09 -0800 Subject: [PATCH 93/93] Bump to 1.3.3 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index c2192c347..75bab9547 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 3 -build = 2 +build = 3