From dbf0569e29bbe3ed088f5f9f16b4d7f4f4b17581 Mon Sep 17 00:00:00 2001 From: Jm Date: Thu, 14 Jan 2021 22:36:51 -0800 Subject: [PATCH 01/12] Update comments for serial pins recommended by @ryguy --- src/plugins/SerialPlugin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index cc355c06..fa32ceb6 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -27,6 +27,9 @@ 1) Enable the plugin by setting SERIALPLUGIN_ENABLED to 1. 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins. + On tbeam, recommend to use: + #define RXD2 35 + #define TXD2 15 3) Set SERIALPLUGIN_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 @@ -45,6 +48,7 @@ KNOWN PROBLEMS * Until the plugin 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. */ From cafe00e46391534e94bb23bf69fc957f93f6abab Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 19:40:47 -0800 Subject: [PATCH 02/12] Update of serialplugin --- src/plugins/SerialPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 82c8baf8..861cbf50 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -59,7 +59,7 @@ #define SERIALPLUGIN_BAUD 38400 #define SERIALPLUGIN_ENABLED 0 #define SERIALPLUGIN_ECHO 0 -#define SERIALPLUGIN_ACK 0 +#define SERIALPLUGIN_ACK 1 SerialPlugin *serialPlugin; SerialPluginRadio *serialPluginRadio; From cd84f2867cbf09201e1b3a1e443176c7e48361cc Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 20:00:37 -0800 Subject: [PATCH 03/12] Updated submodule proto --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 75078afe..7b46033b 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 75078afe43934f4ce15ef86ebc6950658a170145 +Subproject commit 7b46033b0acb953e6dc2a09e94cc31d613b6241f From 3dcdf372d7202f437f3a4b5c6085d08017f0beba Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 20:12:31 -0800 Subject: [PATCH 04/12] add remote update --- proto | 2 +- sdk-nrfxlib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proto b/proto index 7b46033b..ff4ff06d 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 7b46033b0acb953e6dc2a09e94cc31d613b6241f +Subproject commit ff4ff06d5ee7d5c63d2dd1b7f2c5f8e29a36be11 diff --git a/sdk-nrfxlib b/sdk-nrfxlib index 17e84535..e6e02cb8 160000 --- a/sdk-nrfxlib +++ b/sdk-nrfxlib @@ -1 +1 @@ -Subproject commit 17e8453553d4cfc21ab87c53c9627f0cf1216429 +Subproject commit e6e02cb83d238fae2f54f084858bd5e49a31afa1 From f435086a5a3ce554f4899aa3f4ca3f960055e7b9 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 20:50:58 -0800 Subject: [PATCH 05/12] Update generated protobufs --- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.c | 1 + src/mesh/generated/mesh.pb.h | 56 ++++++++++++++++++++++++++---- src/mesh/generated/portnums.pb.h | 8 +++-- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 39f39275..c3e55666 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -80,7 +80,7 @@ extern const pb_msgdesc_t DeviceState_msg; #define DeviceState_fields &DeviceState_msg /* Maximum encoded size of messages (where known) */ -#define DeviceState_size 6176 +#define DeviceState_size 6206 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c index 8f976cac..3bc2b080 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/mesh.pb.c @@ -57,3 +57,4 @@ PB_BIND(ToRadio, ToRadio, 2) + diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 0962effa..815fb2e2 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -35,6 +35,26 @@ typedef enum _RegionCode { RegionCode_TW = 8 } RegionCode; +typedef enum _ChargeCurrent { + ChargeCurrent_MAUnset = 0, + ChargeCurrent_MA100 = 1, + ChargeCurrent_MA190 = 2, + ChargeCurrent_MA280 = 3, + ChargeCurrent_MA360 = 4, + ChargeCurrent_MA450 = 5, + ChargeCurrent_MA550 = 6, + ChargeCurrent_MA630 = 7, + ChargeCurrent_MA700 = 8, + ChargeCurrent_MA780 = 9, + ChargeCurrent_MA880 = 10, + ChargeCurrent_MA960 = 11, + ChargeCurrent_MA1000 = 12, + ChargeCurrent_MA1080 = 13, + ChargeCurrent_MA1160 = 14, + ChargeCurrent_MA1240 = 15, + ChargeCurrent_MA1320 = 16 +} ChargeCurrent; + typedef enum _GpsOperation { GpsOperation_GpsOpUnset = 0, GpsOperation_GpsOpMobile = 2, @@ -145,6 +165,7 @@ typedef struct _RadioConfig_UserPreferences { char wifi_password[64]; bool wifi_ap_mode; RegionCode region; + ChargeCurrent charge_current; LocationSharing location_share; GpsOperation gps_operation; uint32_t gps_update_interval; @@ -156,6 +177,11 @@ 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; } RadioConfig_UserPreferences; typedef struct _RouteDiscovery { @@ -265,6 +291,10 @@ typedef struct _ToRadio { #define _RegionCode_MAX RegionCode_TW #define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TW+1)) +#define _ChargeCurrent_MIN ChargeCurrent_MAUnset +#define _ChargeCurrent_MAX ChargeCurrent_MA1320 +#define _ChargeCurrent_ARRAYSIZE ((ChargeCurrent)(ChargeCurrent_MA1320+1)) + #define _GpsOperation_MIN GpsOperation_GpsOpUnset #define _GpsOperation_MAX GpsOperation_GpsOpDisabled #define _GpsOperation_ARRAYSIZE ((GpsOperation)(GpsOperation_GpsOpDisabled+1)) @@ -299,7 +329,7 @@ extern "C" { #define MeshPacket_init_default {0, 0, 0, {SubPacket_init_default}, 0, 0, 0, 0, 0, 0} #define ChannelSettings_init_default {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0} #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default, false, ChannelSettings_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} #define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} @@ -313,7 +343,7 @@ extern "C" { #define MeshPacket_init_zero {0, 0, 0, {SubPacket_init_zero}, 0, 0, 0, 0, 0, 0} #define ChannelSettings_init_zero {0, _ChannelSettings_ModemConfig_MIN, {0, {0}}, "", 0, 0, 0, 0, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero, false, ChannelSettings_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} #define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} @@ -371,6 +401,7 @@ extern "C" { #define RadioConfig_UserPreferences_wifi_password_tag 13 #define RadioConfig_UserPreferences_wifi_ap_mode_tag 14 #define RadioConfig_UserPreferences_region_tag 15 +#define RadioConfig_UserPreferences_charge_current_tag 16 #define RadioConfig_UserPreferences_location_share_tag 32 #define RadioConfig_UserPreferences_gps_operation_tag 33 #define RadioConfig_UserPreferences_gps_update_interval_tag 34 @@ -381,6 +412,11 @@ 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 RouteDiscovery_route_tag 2 #define User_id_tag 1 #define User_long_name_tag 2 @@ -533,6 +569,7 @@ X(a, STATIC, SINGULAR, STRING, wifi_ssid, 12) \ X(a, STATIC, SINGULAR, STRING, wifi_password, 13) \ 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, UENUM, location_share, 32) \ X(a, STATIC, SINGULAR, UENUM, gps_operation, 33) \ X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 34) \ @@ -542,7 +579,12 @@ X(a, STATIC, SINGULAR, BOOL, is_low_power, 38) \ X(a, STATIC, SINGULAR, BOOL, fixed_position, 39) \ 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, 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) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -654,13 +696,13 @@ extern const pb_msgdesc_t ToRadio_msg; #define SubPacket_size 275 #define MeshPacket_size 320 #define ChannelSettings_size 95 -#define RadioConfig_size 319 -#define RadioConfig_UserPreferences_size 219 +#define RadioConfig_size 349 +#define RadioConfig_UserPreferences_size 249 #define NodeInfo_size 132 #define MyNodeInfo_size 106 #define LogRecord_size 81 -#define FromRadio_size 329 -#define ToRadio_size 323 +#define FromRadio_size 358 +#define ToRadio_size 353 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/portnums.pb.h index bef19c12..91c988fd 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/portnums.pb.h @@ -18,13 +18,15 @@ typedef enum _PortNum { PortNum_NODEINFO_APP = 4, PortNum_REPLY_APP = 32, PortNum_IP_TUNNEL_APP = 33, - PortNum_PRIVATE_APP = 256 + PortNum_SERIAL_APP = 64, + PortNum_PRIVATE_APP = 256, + PortNum_ATAK_FORWARDER = 257 } PortNum; /* Helper constants for enums */ #define _PortNum_MIN PortNum_UNKNOWN_APP -#define _PortNum_MAX PortNum_PRIVATE_APP -#define _PortNum_ARRAYSIZE ((PortNum)(PortNum_PRIVATE_APP+1)) +#define _PortNum_MAX PortNum_ATAK_FORWARDER +#define _PortNum_ARRAYSIZE ((PortNum)(PortNum_ATAK_FORWARDER+1)) #ifdef __cplusplus From b9d025dd582133b873ee86e65f527b325918b06d Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 20:53:45 -0800 Subject: [PATCH 06/12] Missed adding the proto file --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index ff4ff06d..855da870 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ff4ff06d5ee7d5c63d2dd1b7f2c5f8e29a36be11 +Subproject commit 855da8701edbb19818069ad8545d5b9f030bb33f From d7f26493a5d5ee66582adadfdace6da34f5372d6 Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 22:27:33 -0800 Subject: [PATCH 07/12] Update to SerialPlugin to take advantage of the configs --- src/plugins/Plugins.cpp | 11 +++- src/plugins/SerialPlugin.cpp | 108 ++++++++++++++++++----------------- 2 files changed, 64 insertions(+), 55 deletions(-) diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index eee8280c..096b9cf5 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -1,14 +1,15 @@ #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" +#include "plugins/RemoteHardwarePlugin.h" #include "plugins/ReplyPlugin.h" #include "plugins/SerialPlugin.h" -#include "plugins/RemoteHardwarePlugin.h" #include "plugins/TextMessagePlugin.h" /** * Create plugin instances here. If you are adding a new plugin, you must 'new' it here (or somewhere else) */ -void setupPlugins() { +void setupPlugins() +{ nodeInfoPlugin = new NodeInfoPlugin(); positionPlugin = new PositionPlugin(); textMessagePlugin = new TextMessagePlugin(); @@ -18,5 +19,11 @@ void setupPlugins() { new RemoteHardwarePlugin(); new ReplyPlugin(); + +#ifndef NO_ESP32 + // Only run on an esp32 based device. + new SerialPlugin(); // Maintained by MC Hamster (Jm Casler) jm@casler.org +#endif + } \ No newline at end of file diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 861cbf50..1d7f5c62 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -25,7 +25,7 @@ Basic Usage: - 1) Enable the plugin by setting SERIALPLUGIN_ENABLED to 1. + 1) Enable the plugin by setting serialplugin_enabled in the device configuration to 1. 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins. 3) Set SERIALPLUGIN_TIMEOUT to the amount of time to wait before we consider your packet as "done". @@ -57,8 +57,6 @@ #define SERIALPLUGIN_STRING_MAX Constants_DATA_PAYLOAD_LEN #define SERIALPLUGIN_TIMEOUT 250 #define SERIALPLUGIN_BAUD 38400 -#define SERIALPLUGIN_ENABLED 0 -#define SERIALPLUGIN_ECHO 0 #define SERIALPLUGIN_ACK 1 SerialPlugin *serialPlugin; @@ -70,43 +68,48 @@ char serialStringChar[Constants_DATA_PAYLOAD_LEN]; int32_t SerialPlugin::runOnce() { -#ifdef NO_ESP32 +#ifndef NO_ESP32 + if (radioConfig.preferences.serialplugin_enabled) { -#if SERIALPLUGIN_ENABLED == 1 + if (firstTime) { - if (firstTime) { + // Interface with the serial peripheral from in here. + DEBUG_MSG("Initilizing serial peripheral interface\n"); - // Interface with the serial peripheral from in here. - DEBUG_MSG("Initilizing 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); - Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); - Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. - Serial2.setRxBufferSize(SERIALPLUGIN_RX_BUFFER); + } else { + Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); + } + Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. + Serial2.setRxBufferSize(SERIALPLUGIN_RX_BUFFER); - serialPluginRadio = new SerialPluginRadio(); + serialPluginRadio = new SerialPluginRadio(); - firstTime = 0; + firstTime = 0; - } else { - String serialString; + } else { + String serialString; - while (Serial2.available()) { - serialString = Serial2.readString(); - serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN); + while (Serial2.available()) { + serialString = Serial2.readString(); + serialString.toCharArray(serialStringChar, Constants_DATA_PAYLOAD_LEN); - serialPluginRadio->sendPayload(); + serialPluginRadio->sendPayload(); - DEBUG_MSG("Received: %s\n", serialStringChar); + DEBUG_MSG("Received: %s\n", serialStringChar); + } } + + return (10); + } else { + DEBUG_MSG("Serial Plugin Disabled\n"); + + return (INT32_MAX); } - return (10); -#else - DEBUG_MSG("Serial Plugin Disabled\n"); - - return (INT32_MAX); -#endif - #endif } @@ -135,43 +138,42 @@ void SerialPluginRadio::sendPayload(NodeNum dest, bool wantReplies) bool SerialPluginRadio::handleReceived(const MeshPacket &mp) { -#ifdef NO_ESP32 +#ifndef NO_ESP32 -#if SERIALPLUGIN_ENABLED == 1 + if (radioConfig.preferences.serialplugin_enabled) { - auto &p = mp.decoded.data; - // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), - // mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); + auto &p = mp.decoded.data; + // DEBUG_MSG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s\n", nodeDB.getNodeNum(), + // mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); - if (mp.from == nodeDB.getNodeNum()) { + if (mp.from == nodeDB.getNodeNum()) { - /* - * If SERIALPLUGIN_ECHO is true, then echo the packets that are sent out back to the TX - * of the serial interface. - */ - if (SERIALPLUGIN_ECHO) { + /* + * If radioConfig.preferences.serialplugin_echo is true, then echo the packets that are sent out back to the TX + * of the serial interface. + */ + if (radioConfig.preferences.serialplugin_echo) { - // For some reason, we get the packet back twice when we send out of the radio. - // TODO: need to find out why. - if (lastRxID != mp.id) { - lastRxID = mp.id; - // DEBUG_MSG("* * Message came this device\n"); - // Serial2.println("* * Message came this device"); - Serial2.printf("%s", p.payload.bytes); + // For some reason, we get the packet back twice when we send out of the radio. + // TODO: need to find out why. + if (lastRxID != mp.id) { + lastRxID = mp.id; + // DEBUG_MSG("* * Message came this device\n"); + // Serial2.println("* * Message came this device"); + Serial2.printf("%s", p.payload.bytes); + } } + + } else { + // DEBUG_MSG("* * Message came from the mesh\n"); + // Serial2.println("* * Message came from the mesh"); + Serial2.printf("%s", p.payload.bytes); } } else { - // DEBUG_MSG("* * Message came from the mesh\n"); - // Serial2.println("* * Message came from the mesh"); - Serial2.printf("%s", p.payload.bytes); + DEBUG_MSG("Serial Plugin Disabled\n"); } -#else - DEBUG_MSG("Serial Plugin Disabled\n"); - -#endif - #endif return true; // Let others look at this message also if they want From 79532210e8a421c8dc74af2c05e464a82ac8f46d Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 22:31:56 -0800 Subject: [PATCH 08/12] SerialPlugin - Update comments with better instructions --- src/plugins/SerialPlugin.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index 1d7f5c62..e7053837 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -13,12 +13,7 @@ An overly simplistic interface to send messages over the mesh network by sending strings over a serial port. - Originally designed for lora32 v1.0 - Manufacture Info: http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1133&FId=t3:50003:3 - Pin Mapping: http://ae01.alicdn.com/kf/HTB1fLBcxkSWBuNjSszdq6zeSpXaJ.jpg - - This will probably and most likely work on other esp32 devices, given possible change the RX/TX - selection. + Default is to use RX GPIO 16 and TX GPIO 17. Need help with this plugin? Post your question on the Meshtastic Discourse: https://meshtastic.discourse.group @@ -26,7 +21,8 @@ Basic Usage: 1) Enable the plugin by setting serialplugin_enabled in the device configuration to 1. - 2) Set the pins (RXD2 / TXD2) for your preferred RX and TX GPIO pins. + 2) Set the pins (serialplugin_rxd / serialplugin_txd) for your preferred RX and TX GPIO pins. + If you're using a tbeam 1.0 or newer, recommend to use RX 35 / TX 15 3) Set SERIALPLUGIN_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 From 73ae151971b39d7fa1611e6b38188ce20e423dba Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 22:39:28 -0800 Subject: [PATCH 09/12] Added serialplugin_timeout to SerialPlugin --- src/plugins/SerialPlugin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index bded71c7..236b29f9 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -80,7 +80,15 @@ int32_t SerialPlugin::runOnce() } else { Serial2.begin(SERIALPLUGIN_BAUD, SERIAL_8N1, RXD2, TXD2); } - Serial2.setTimeout(SERIALPLUGIN_TIMEOUT); // Number of MS to wait to set the timeout for the string. + + if (radioConfig.preferences.serialplugin_timeout) { + Serial2.setTimeout( + radioConfig.preferences.serialplugin_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.setRxBufferSize(SERIALPLUGIN_RX_BUFFER); serialPluginRadio = new SerialPluginRadio(); From 20b8d2c4a58e674ed5baf77f5eadc114fc24de7d Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 22:41:33 -0800 Subject: [PATCH 10/12] Set the port to PortNum_SERIAL_APP --- src/plugins/SerialPlugin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/SerialPlugin.h b/src/plugins/SerialPlugin.h index c6d79f3e..4555c65b 100644 --- a/src/plugins/SerialPlugin.h +++ b/src/plugins/SerialPlugin.h @@ -33,8 +33,8 @@ class SerialPluginRadio : public SinglePortPlugin from the main code. */ - SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} - // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {} + // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} + SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {} /** * Send our payload into the mesh From c0711fde699e7c1dd3ee6309312f1625409d49ce Mon Sep 17 00:00:00 2001 From: Jm Date: Sat, 16 Jan 2021 23:10:08 -0800 Subject: [PATCH 11/12] #615 Allow rate for tbeam battery charger to be configurable --- src/Power.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 3d185cb2..26c40f92 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -1,4 +1,5 @@ #include "power.h" +#include "NodeDB.h" #include "PowerFSM.h" #include "main.h" #include "sleep.h" @@ -268,9 +269,42 @@ bool Power::axp192Init() DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE"); DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE"); - //axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1320MA); // actual limit (in HW) on the tbeam is 450mA - axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA); // There's no HW limit on the tbeam. Setting to 450mz to be a good neighbor on the usb bus. - + if (radioConfig.preferences.charge_current == ChargeCurrent_MAUnset) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA100) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_100MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA190) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_190MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA280) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_280MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA360) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_360MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA450) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA550) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_550MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA630) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_630MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA700) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_700MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA780) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_780MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA880) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_880MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA960) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_960MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA1000) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1000MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA1080) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1080MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA1160) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1160MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA1240) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1240MA); + } else if (radioConfig.preferences.charge_current == ChargeCurrent_MA1320) { + axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1320MA); + } + #if 0 // Not connected From 125eb2b7849233fafb8f931d18db03124fcdec62 Mon Sep 17 00:00:00 2001 From: Jm Date: Sun, 17 Jan 2021 00:11:26 -0800 Subject: [PATCH 12/12] Fix for build fail on NRF --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 1f962a8d..2033b2fa 100644 --- a/platformio.ini +++ b/platformio.ini @@ -185,7 +185,7 @@ build_type = debug ; I'm debugging with ICE a lot now build_flags = ${arduino_base.build_flags} -Wno-unused-variable -Isrc/nrf52 - -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3 + -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} - - - -