From c8bea4f0916e79bf3057f5036ebfdcabfad7a1fc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 7 Dec 2021 20:42:06 -0600 Subject: [PATCH 01/22] Split RAK-4631 targets by base board --- bin/build-all.sh | 2 +- platformio.ini | 13 +++++++++++-- variants/WisCore_RAK4631_Board/variant.h | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 9e0fcee71..922fd4b7d 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -9,7 +9,7 @@ BOARDS_ESP32="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v2.0 helt #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 t-echo" +BOARDS_NRF52="rak4631_5005 rak4631_19003 t-echo" #BOARDS_NRF52="" OUTDIR=release/latest diff --git a/platformio.ini b/platformio.ini index 7a908ffd9..4c223d659 100644 --- a/platformio.ini +++ b/platformio.ini @@ -325,12 +325,21 @@ monitor_speed = 115200 # board_build.ldscript = linker/nrf52840_s140_sim832.ld ; The very slick RAK wireless RAK 4631 / 4630 board -[env:rak4631] +[env:rak4631_5005] extends = nrf52840_base board = wiscore_rak4631 # add our variants files to the include and src paths # define build flags for the TFT_eSPI library -build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board +build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_5005 +src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board> +debug_tool = jlink + +[env:rak4631_19003] +extends = nrf52840_base +board = wiscore_rak4631 +# add our variants files to the include and src paths +# define build flags for the TFT_eSPI library +build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_19003 src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board> debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) diff --git a/variants/WisCore_RAK4631_Board/variant.h b/variants/WisCore_RAK4631_Board/variant.h index bea410c3c..ece891723 100644 --- a/variants/WisCore_RAK4631_Board/variant.h +++ b/variants/WisCore_RAK4631_Board/variant.h @@ -58,7 +58,9 @@ extern "C" { /* * Buttons */ -#define PIN_BUTTON1 11 +#ifdef RAK_BASE_5005 +#define PIN_BUTTON1 5 // This will default to normal button pin +#endif #define PIN_BUTTON2 12 #define PIN_BUTTON3 24 #define PIN_BUTTON4 25 @@ -169,8 +171,11 @@ static const uint8_t SCK = PIN_SPI_SCK; // #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) From 3d4e4bfa5010bdf07e4daa345a2d613e178ab978 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 9 Dec 2021 11:47:42 -0800 Subject: [PATCH 02/22] Update generated protos & has_wifi #979 https://github.com/meshtastic/Meshtastic-device/issues/979 --- src/mesh/NodeDB.cpp | 4 + src/mesh/generated/admin.pb.h | 9 ++- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 13 +-- src/mesh/generated/storeforward.pb.c | 3 + src/mesh/generated/storeforward.pb.h | 114 +++++++++++++++++---------- 6 files changed, 95 insertions(+), 50 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 6f1d26f6a..c6f872b8e 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -245,6 +245,10 @@ void NodeDB::init() preferences.end(); DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count); + /* The ESP32 has a wifi radio. This will need to be modified at some point so + * the test isn't so simplistic. + */ + myNodeInfo.has_wifi = true; #endif resetRadioConfig(); // If bogus settings got saved, then fix them diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 550a00b9a..670978a0a 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -5,8 +5,8 @@ #define PB_ADMIN_PB_H_INCLUDED #include #include "channel.pb.h" -#include "mesh.pb.h" #include "radioconfig.pb.h" +#include "mesh.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -23,6 +23,8 @@ typedef struct _AdminMessage { RadioConfig get_radio_response; uint32_t get_channel_request; Channel get_channel_response; + bool get_owner_request; + User get_owner_response; bool confirm_set_channel; bool confirm_set_radio; bool exit_simulator; @@ -47,6 +49,8 @@ extern "C" { #define AdminMessage_get_radio_response_tag 5 #define AdminMessage_get_channel_request_tag 6 #define AdminMessage_get_channel_response_tag 7 +#define AdminMessage_get_owner_request_tag 8 +#define AdminMessage_get_owner_response_tag 9 #define AdminMessage_confirm_set_channel_tag 32 #define AdminMessage_confirm_set_radio_tag 33 #define AdminMessage_exit_simulator_tag 34 @@ -61,6 +65,8 @@ X(a, STATIC, ONEOF, BOOL, (variant,get_radio_request,get_radio_request) X(a, STATIC, ONEOF, MESSAGE, (variant,get_radio_response,get_radio_response), 5) \ X(a, STATIC, ONEOF, UINT32, (variant,get_channel_request,get_channel_request), 6) \ X(a, STATIC, ONEOF, MESSAGE, (variant,get_channel_response,get_channel_response), 7) \ +X(a, STATIC, ONEOF, BOOL, (variant,get_owner_request,get_owner_request), 8) \ +X(a, STATIC, ONEOF, MESSAGE, (variant,get_owner_response,get_owner_response), 9) \ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \ X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) \ @@ -72,6 +78,7 @@ X(a, STATIC, ONEOF, INT32, (variant,reboot_seconds,reboot_seconds), 35) #define AdminMessage_variant_set_channel_MSGTYPE Channel #define AdminMessage_variant_get_radio_response_MSGTYPE RadioConfig #define AdminMessage_variant_get_channel_response_MSGTYPE Channel +#define AdminMessage_variant_get_owner_response_MSGTYPE User extern const pb_msgdesc_t AdminMessage_msg; diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 46fdcac74..c87d9d819 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -125,7 +125,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 9936 +#define DeviceState_size 9939 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 8defe6258..21be09fd8 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -157,6 +157,7 @@ typedef struct _MyNodeInfo { uint32_t air_period_tx[24]; pb_size_t air_period_rx_count; uint32_t air_period_rx[24]; + bool has_wifi; } MyNodeInfo; typedef struct _Position { @@ -320,7 +321,7 @@ extern "C" { #define Data_init_default {_PortNum_MIN, {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} #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}} +#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} #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}} @@ -332,7 +333,7 @@ extern "C" { #define Data_init_zero {_PortNum_MIN, {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} #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}} +#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} #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}} @@ -365,6 +366,7 @@ extern "C" { #define MyNodeInfo_max_channels_tag 15 #define MyNodeInfo_air_period_tx_tag 16 #define MyNodeInfo_air_period_rx_tag 17 +#define MyNodeInfo_has_wifi_tag 18 #define Position_latitude_i_tag 1 #define Position_longitude_i_tag 2 #define Position_altitude_tag 3 @@ -543,7 +545,8 @@ X(a, STATIC, SINGULAR, UINT32, message_timeout_msec, 13) \ X(a, STATIC, SINGULAR, UINT32, min_app_version, 14) \ X(a, STATIC, SINGULAR, UINT32, max_channels, 15) \ X(a, STATIC, REPEATED, UINT32, air_period_tx, 16) \ -X(a, STATIC, REPEATED, UINT32, air_period_rx, 17) +X(a, STATIC, REPEATED, UINT32, air_period_rx, 17) \ +X(a, STATIC, SINGULAR, BOOL, has_wifi, 18) #define MyNodeInfo_CALLBACK NULL #define MyNodeInfo_DEFAULT NULL @@ -621,9 +624,9 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_size 260 #define MeshPacket_size 309 #define NodeInfo_size 270 -#define MyNodeInfo_size 442 +#define MyNodeInfo_size 445 #define LogRecord_size 81 -#define FromRadio_size 451 +#define FromRadio_size 454 #define ToRadio_size 312 #define ToRadio_PeerInfo_size 8 diff --git a/src/mesh/generated/storeforward.pb.c b/src/mesh/generated/storeforward.pb.c index 5cca6d04a..51f7c3b92 100644 --- a/src/mesh/generated/storeforward.pb.c +++ b/src/mesh/generated/storeforward.pb.c @@ -15,5 +15,8 @@ PB_BIND(StoreAndForward_Statistics, StoreAndForward_Statistics, AUTO) PB_BIND(StoreAndForward_History, StoreAndForward_History, AUTO) +PB_BIND(StoreAndForward_Heartbeat, StoreAndForward_Heartbeat, AUTO) + + diff --git a/src/mesh/generated/storeforward.pb.h b/src/mesh/generated/storeforward.pb.h index 76ca41873..9c346cd96 100644 --- a/src/mesh/generated/storeforward.pb.h +++ b/src/mesh/generated/storeforward.pb.h @@ -17,29 +17,37 @@ typedef enum _StoreAndForward_RequestResponse { StoreAndForward_RequestResponse_ROUTER_PING = 3, StoreAndForward_RequestResponse_ROUTER_PONG = 4, StoreAndForward_RequestResponse_ROUTER_BUSY = 5, + StoreAndForward_RequestResponse_ROUTER_HISTORY = 6, StoreAndForward_RequestResponse_CLIENT_ERROR = 101, StoreAndForward_RequestResponse_CLIENT_HISTORY = 102, StoreAndForward_RequestResponse_CLIENT_STATS = 103, StoreAndForward_RequestResponse_CLIENT_PING = 104, - StoreAndForward_RequestResponse_CLIENT_PONG = 105 + StoreAndForward_RequestResponse_CLIENT_PONG = 105, + StoreAndForward_RequestResponse_CLIENT_ABORT = 106 } StoreAndForward_RequestResponse; /* Struct definitions */ +typedef struct _StoreAndForward_Heartbeat { + uint32_t period; + uint32_t secondary; +} StoreAndForward_Heartbeat; + typedef struct _StoreAndForward_History { - uint32_t HistoryMessages; - uint32_t Window; + uint32_t history_messages; + uint32_t window; + uint32_t last_request; } StoreAndForward_History; typedef struct _StoreAndForward_Statistics { - uint32_t MessagesTotal; - uint32_t MessagesSaved; - uint32_t MessagesMax; - uint32_t UpTime; - uint32_t Requests; - uint32_t RequestsHistory; - bool Heartbeat; - uint32_t ReturnMax; - uint32_t ReturnWindow; + uint32_t messages_total; + uint32_t messages_saved; + uint32_t messages_max; + uint32_t up_time; + uint32_t requests; + uint32_t requests_history; + bool heartbeat; + uint32_t return_max; + uint32_t return_window; } StoreAndForward_Statistics; typedef struct _StoreAndForward { @@ -48,13 +56,15 @@ typedef struct _StoreAndForward { StoreAndForward_Statistics stats; bool has_history; StoreAndForward_History history; + bool has_heartbeat; + StoreAndForward_Heartbeat heartbeat; } StoreAndForward; /* Helper constants for enums */ #define _StoreAndForward_RequestResponse_MIN StoreAndForward_RequestResponse_UNSET -#define _StoreAndForward_RequestResponse_MAX StoreAndForward_RequestResponse_CLIENT_PONG -#define _StoreAndForward_RequestResponse_ARRAYSIZE ((StoreAndForward_RequestResponse)(StoreAndForward_RequestResponse_CLIENT_PONG+1)) +#define _StoreAndForward_RequestResponse_MAX StoreAndForward_RequestResponse_CLIENT_ABORT +#define _StoreAndForward_RequestResponse_ARRAYSIZE ((StoreAndForward_RequestResponse)(StoreAndForward_RequestResponse_CLIENT_ABORT+1)) #ifdef __cplusplus @@ -62,71 +72,89 @@ extern "C" { #endif /* Initializer values for message structs */ -#define StoreAndForward_init_default {_StoreAndForward_RequestResponse_MIN, false, StoreAndForward_Statistics_init_default, false, StoreAndForward_History_init_default} +#define StoreAndForward_init_default {_StoreAndForward_RequestResponse_MIN, false, StoreAndForward_Statistics_init_default, false, StoreAndForward_History_init_default, false, StoreAndForward_Heartbeat_init_default} #define StoreAndForward_Statistics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define StoreAndForward_History_init_default {0, 0} -#define StoreAndForward_init_zero {_StoreAndForward_RequestResponse_MIN, false, StoreAndForward_Statistics_init_zero, false, StoreAndForward_History_init_zero} +#define StoreAndForward_History_init_default {0, 0, 0} +#define StoreAndForward_Heartbeat_init_default {0, 0} +#define StoreAndForward_init_zero {_StoreAndForward_RequestResponse_MIN, false, StoreAndForward_Statistics_init_zero, false, StoreAndForward_History_init_zero, false, StoreAndForward_Heartbeat_init_zero} #define StoreAndForward_Statistics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define StoreAndForward_History_init_zero {0, 0} +#define StoreAndForward_History_init_zero {0, 0, 0} +#define StoreAndForward_Heartbeat_init_zero {0, 0} /* Field tags (for use in manual encoding/decoding) */ -#define StoreAndForward_History_HistoryMessages_tag 1 -#define StoreAndForward_History_Window_tag 2 -#define StoreAndForward_Statistics_MessagesTotal_tag 1 -#define StoreAndForward_Statistics_MessagesSaved_tag 2 -#define StoreAndForward_Statistics_MessagesMax_tag 3 -#define StoreAndForward_Statistics_UpTime_tag 4 -#define StoreAndForward_Statistics_Requests_tag 5 -#define StoreAndForward_Statistics_RequestsHistory_tag 6 -#define StoreAndForward_Statistics_Heartbeat_tag 7 -#define StoreAndForward_Statistics_ReturnMax_tag 8 -#define StoreAndForward_Statistics_ReturnWindow_tag 9 +#define StoreAndForward_Heartbeat_period_tag 1 +#define StoreAndForward_Heartbeat_secondary_tag 2 +#define StoreAndForward_History_history_messages_tag 1 +#define StoreAndForward_History_window_tag 2 +#define StoreAndForward_History_last_request_tag 3 +#define StoreAndForward_Statistics_messages_total_tag 1 +#define StoreAndForward_Statistics_messages_saved_tag 2 +#define StoreAndForward_Statistics_messages_max_tag 3 +#define StoreAndForward_Statistics_up_time_tag 4 +#define StoreAndForward_Statistics_requests_tag 5 +#define StoreAndForward_Statistics_requests_history_tag 6 +#define StoreAndForward_Statistics_heartbeat_tag 7 +#define StoreAndForward_Statistics_return_max_tag 8 +#define StoreAndForward_Statistics_return_window_tag 9 #define StoreAndForward_rr_tag 1 #define StoreAndForward_stats_tag 2 #define StoreAndForward_history_tag 3 +#define StoreAndForward_heartbeat_tag 4 /* Struct field encoding specification for nanopb */ #define StoreAndForward_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, rr, 1) \ X(a, STATIC, OPTIONAL, MESSAGE, stats, 2) \ -X(a, STATIC, OPTIONAL, MESSAGE, history, 3) +X(a, STATIC, OPTIONAL, MESSAGE, history, 3) \ +X(a, STATIC, OPTIONAL, MESSAGE, heartbeat, 4) #define StoreAndForward_CALLBACK NULL #define StoreAndForward_DEFAULT NULL #define StoreAndForward_stats_MSGTYPE StoreAndForward_Statistics #define StoreAndForward_history_MSGTYPE StoreAndForward_History +#define StoreAndForward_heartbeat_MSGTYPE StoreAndForward_Heartbeat #define StoreAndForward_Statistics_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, MessagesTotal, 1) \ -X(a, STATIC, SINGULAR, UINT32, MessagesSaved, 2) \ -X(a, STATIC, SINGULAR, UINT32, MessagesMax, 3) \ -X(a, STATIC, SINGULAR, UINT32, UpTime, 4) \ -X(a, STATIC, SINGULAR, UINT32, Requests, 5) \ -X(a, STATIC, SINGULAR, UINT32, RequestsHistory, 6) \ -X(a, STATIC, SINGULAR, BOOL, Heartbeat, 7) \ -X(a, STATIC, SINGULAR, UINT32, ReturnMax, 8) \ -X(a, STATIC, SINGULAR, UINT32, ReturnWindow, 9) +X(a, STATIC, SINGULAR, UINT32, messages_total, 1) \ +X(a, STATIC, SINGULAR, UINT32, messages_saved, 2) \ +X(a, STATIC, SINGULAR, UINT32, messages_max, 3) \ +X(a, STATIC, SINGULAR, UINT32, up_time, 4) \ +X(a, STATIC, SINGULAR, UINT32, requests, 5) \ +X(a, STATIC, SINGULAR, UINT32, requests_history, 6) \ +X(a, STATIC, SINGULAR, BOOL, heartbeat, 7) \ +X(a, STATIC, SINGULAR, UINT32, return_max, 8) \ +X(a, STATIC, SINGULAR, UINT32, return_window, 9) #define StoreAndForward_Statistics_CALLBACK NULL #define StoreAndForward_Statistics_DEFAULT NULL #define StoreAndForward_History_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, HistoryMessages, 1) \ -X(a, STATIC, SINGULAR, UINT32, Window, 2) +X(a, STATIC, SINGULAR, UINT32, history_messages, 1) \ +X(a, STATIC, SINGULAR, UINT32, window, 2) \ +X(a, STATIC, SINGULAR, UINT32, last_request, 3) #define StoreAndForward_History_CALLBACK NULL #define StoreAndForward_History_DEFAULT NULL +#define StoreAndForward_Heartbeat_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, period, 1) \ +X(a, STATIC, SINGULAR, UINT32, secondary, 2) +#define StoreAndForward_Heartbeat_CALLBACK NULL +#define StoreAndForward_Heartbeat_DEFAULT NULL + extern const pb_msgdesc_t StoreAndForward_msg; extern const pb_msgdesc_t StoreAndForward_Statistics_msg; extern const pb_msgdesc_t StoreAndForward_History_msg; +extern const pb_msgdesc_t StoreAndForward_Heartbeat_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define StoreAndForward_fields &StoreAndForward_msg #define StoreAndForward_Statistics_fields &StoreAndForward_Statistics_msg #define StoreAndForward_History_fields &StoreAndForward_History_msg +#define StoreAndForward_Heartbeat_fields &StoreAndForward_Heartbeat_msg /* Maximum encoded size of messages (where known) */ -#define StoreAndForward_size 68 +#define StoreAndForward_size 88 #define StoreAndForward_Statistics_size 50 -#define StoreAndForward_History_size 12 +#define StoreAndForward_History_size 18 +#define StoreAndForward_Heartbeat_size 12 #ifdef __cplusplus } /* extern "C" */ From 66085d74475a171e8e153d432fc53a0a3b70f832 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 9 Dec 2021 19:56:49 -0600 Subject: [PATCH 03/22] RAK-5005 button pin mapping tweak --- variants/WisCore_RAK4631_Board/variant.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/variants/WisCore_RAK4631_Board/variant.h b/variants/WisCore_RAK4631_Board/variant.h index ece891723..3058068c8 100644 --- a/variants/WisCore_RAK4631_Board/variant.h +++ b/variants/WisCore_RAK4631_Board/variant.h @@ -58,13 +58,16 @@ extern "C" { /* * Buttons */ + #ifdef RAK_BASE_5005 -#define PIN_BUTTON1 5 // This will default to normal button pin +#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 */ @@ -149,7 +152,7 @@ static const uint8_t SCK = PIN_SPI_SCK; 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) + SPI_CS <-> P0.26 (Arduino GPIO number 26) */ // RAK4630 LoRa module From 686057a0b161f69e679e3e9c57754800ae8d75b9 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 11 Dec 2021 18:33:52 -0800 Subject: [PATCH 04/22] Make screen animations smoother (aka Scale the CPU) #983 --- src/graphics/Screen.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 83880d9a5..25698e634 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -36,6 +36,7 @@ along with this program. If not, see . #include "target_specific.h" #include "utils.h" #include "gps/GeoCoord.h" +#include "sleep.h" #ifndef NO_ESP32 #include "mesh/http/WiFiAPClient.h" @@ -875,6 +876,9 @@ int32_t Screen::runOnce() // oldFrameState = ui.getUiState()->frameState; DEBUG_MSG("Setting idle framerate\n"); targetFramerate = IDLE_FRAMERATE; + + setCPUFast(false); // Turn down the CPU now that the framerate has been reduced + ui.setTargetFPS(targetFramerate); forceDisplay(); } @@ -1074,6 +1078,9 @@ void Screen::setFastFramerate() // We are about to start a transition so speed up fps targetFramerate = SCREEN_TRANSITION_FRAMERATE; + + setCPUFast(true); // Turn up the CPU to improve screen animations + ui.setTargetFPS(targetFramerate); setInterval(0); // redraw ASAP runASAP = true; From 4fb5107298bbe8c81f823990fd9e0cc16cd1d8af Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 11 Dec 2021 18:35:28 -0800 Subject: [PATCH 05/22] Make screen animations smoother (aka Scale the CPU) #983 --- src/graphics/Screen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 25698e634..e2542489a 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -877,7 +877,9 @@ int32_t Screen::runOnce() DEBUG_MSG("Setting idle framerate\n"); targetFramerate = IDLE_FRAMERATE; - setCPUFast(false); // Turn down the CPU now that the framerate has been reduced +#ifndef NO_ESP32 + setCPUFast(false); // Turn up the CPU to improve screen animations +#endif ui.setTargetFPS(targetFramerate); forceDisplay(); @@ -1079,7 +1081,9 @@ void Screen::setFastFramerate() // We are about to start a transition so speed up fps targetFramerate = SCREEN_TRANSITION_FRAMERATE; +#ifndef NO_ESP32 setCPUFast(true); // Turn up the CPU to improve screen animations +#endif ui.setTargetFPS(targetFramerate); setInterval(0); // redraw ASAP From 1ed3195194c06fba01404931a47203953f32ace4 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 11 Dec 2021 19:36:58 -0800 Subject: [PATCH 06/22] Identify the mode on the screen with the radio conf #986 --- src/graphics/Screen.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index e2542489a..3cac06463 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1310,7 +1310,24 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat display->drawString(x, y, String("USB")); } - auto mode = "Mode " + String(channels.getPrimary().modem_config); + auto mode = ""; + + if (channels.getPrimary().modem_config == 0) { + mode = "ShSlow"; + } else if (channels.getPrimary().modem_config == 1) { + mode = "ShFast"; + } else if (channels.getPrimary().modem_config == 2) { + mode = "LngFast"; + } else if (channels.getPrimary().modem_config == 3) { + mode = "LngSlow"; + } else if (channels.getPrimary().modem_config == 4) { + mode = "MedSlow"; + } else if (channels.getPrimary().modem_config == 5) { + mode = "MedFast"; + } else { + mode = "Custom"; + } + display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode); // Line 2 From a1f97aea77982d7520f8f6afe19553ca294f9a77 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 11 Dec 2021 19:39:31 -0800 Subject: [PATCH 07/22] Update Screen.cpp --- src/graphics/Screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 3cac06463..2b028a842 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1313,9 +1313,9 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat auto mode = ""; if (channels.getPrimary().modem_config == 0) { - mode = "ShSlow"; + mode = "ShrtSlow"; } else if (channels.getPrimary().modem_config == 1) { - mode = "ShFast"; + mode = "ShrtFast"; } else if (channels.getPrimary().modem_config == 2) { mode = "LngFast"; } else if (channels.getPrimary().modem_config == 3) { From 446fb857cc15b50b8ebb56960ae7e446d69b4465 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 11 Dec 2021 19:50:20 -0800 Subject: [PATCH 08/22] Bug in getNumOnlineNodes #988 --- src/mesh/NodeDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c6f872b8e..4ba4c14d1 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -433,7 +433,7 @@ uint32_t sinceLastSeen(const NodeInfo *n) return delta; } -#define NUM_ONLINE_SECS (60 * 2) // 2 hrs to consider someone offline +#define NUM_ONLINE_SECS (60 & 60 * 2) // 2 hrs to consider someone offline size_t NodeDB::getNumOnlineNodes() { From f119555c12c57d725f940bb310d7da9d1cccf9b1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 11 Dec 2021 21:26:03 -0600 Subject: [PATCH 09/22] Convert to NimBLE Arduino (#985) --- .vscode/settings.json | 3 ++- platformio.ini | 6 +++++- src/nimble/BluetoothUtil.cpp | 1 - src/nimble/BluetoothUtil.h | 1 - src/nimble/NimbleBluetoothAPI.cpp | 1 - src/nimble/NimbleDefs.h | 1 - 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 455d58ffb..4a61ccd24 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,7 +50,8 @@ "cassert": "cpp", "iterator": "cpp", "shared_mutex": "cpp", - "iostream": "cpp" + "iostream": "cpp", + "esp_nimble_hci.h": "c" }, "cSpell.words": [ "Blox", diff --git a/platformio.ini b/platformio.ini index 4c223d659..8d9b02978 100644 --- a/platformio.ini +++ b/platformio.ini @@ -113,9 +113,13 @@ lib_deps = adafruit/Adafruit Unified Sensor@^1.1.4 paulstoffregen/OneWire@^2.3.5 robtillaart/DS18B20@^0.1.11 + h2zero/NimBLE-Arduino@^1.3.1 # Hmm - this doesn't work yet # board_build.ldscript = linker/esp32.extram.bss.ld -lib_ignore = segger_rtt +lib_ignore = + segger_rtt + ESP32 BLE Arduino + platform_packages = framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276 diff --git a/src/nimble/BluetoothUtil.cpp b/src/nimble/BluetoothUtil.cpp index 2c69b0bcc..eae2a6db7 100644 --- a/src/nimble/BluetoothUtil.cpp +++ b/src/nimble/BluetoothUtil.cpp @@ -11,7 +11,6 @@ #include "services/gap/ble_svc_gap.h" #include "services/gatt/ble_svc_gatt.h" #include "sleep.h" -#include #include #ifndef NO_ESP32 diff --git a/src/nimble/BluetoothUtil.h b/src/nimble/BluetoothUtil.h index fe6d0e678..4e423769e 100644 --- a/src/nimble/BluetoothUtil.h +++ b/src/nimble/BluetoothUtil.h @@ -1,6 +1,5 @@ #pragma once -#include #include /// We only allow one BLE connection at a time diff --git a/src/nimble/NimbleBluetoothAPI.cpp b/src/nimble/NimbleBluetoothAPI.cpp index da2f80ea1..6b44e44d0 100644 --- a/src/nimble/NimbleBluetoothAPI.cpp +++ b/src/nimble/NimbleBluetoothAPI.cpp @@ -3,7 +3,6 @@ #include "configuration.h" #include "nimble/BluetoothUtil.h" #include "nimble/NimbleDefs.h" -#include // This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in // proccess at once diff --git a/src/nimble/NimbleDefs.h b/src/nimble/NimbleDefs.h index 6b1db22e5..7a2b0b46a 100644 --- a/src/nimble/NimbleDefs.h +++ b/src/nimble/NimbleDefs.h @@ -11,7 +11,6 @@ #include "host/ble_uuid.h" #include "nimble/nimble_port.h" #include "nimble/nimble_port_freertos.h" -#include #ifdef __cplusplus extern "C" { From 1f4a3085ef6080c2fd016be59e5f851c467c9a2d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 12 Dec 2021 07:54:29 -0600 Subject: [PATCH 10/22] Peg to specific version of NimBLE Arduino --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 8d9b02978..8d4f3a883 100644 --- a/platformio.ini +++ b/platformio.ini @@ -113,7 +113,7 @@ lib_deps = adafruit/Adafruit Unified Sensor@^1.1.4 paulstoffregen/OneWire@^2.3.5 robtillaart/DS18B20@^0.1.11 - h2zero/NimBLE-Arduino@^1.3.1 + h2zero/NimBLE-Arduino@1.3.1 # Hmm - this doesn't work yet # board_build.ldscript = linker/esp32.extram.bss.ld lib_ignore = From ee70b5996f5268f25b971942486b635c71ba3d6a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 14 Dec 2021 22:38:54 -0500 Subject: [PATCH 11/22] Updated formula for position plugin --- src/plugins/PositionPlugin.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/PositionPlugin.cpp b/src/plugins/PositionPlugin.cpp index e0503930c..e10f05d1e 100644 --- a/src/plugins/PositionPlugin.cpp +++ b/src/plugins/PositionPlugin.cpp @@ -148,14 +148,22 @@ int32_t PositionPlugin::runOnce() NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) { + // The minimum distance to travel before we are able to send a new position packet. + const uint32_t distanceTravelMinimum = 30; + + // The minimum time that would pass before we are able to send a new position packet. + const uint32_t timeTravelMinimum = 30; + + // Determine the distance in meters between two points on the globe float distance = GeoCoord::latLongToMeter(lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7, node->position.latitude_i * 1e-7, node->position.longitude_i * 1e-7); - // 2500 is a magic number. 50 is the minumum distance we want to travel before sending another position packet. - uint32_t distanceTravel = ((2500 / myNodeInfo.bitrate) >= 50) ? (2500 / myNodeInfo.bitrate) : 50; + // Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear. + const float distanceTravelMath = 1203 / (sqrt( pow(myNodeInfo.bitrate, 1.5) / 1.1 ) ) ; + uint32_t distanceTravel = (distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum; - // 1500 is a magic number. 30 is the minumum interval between position packets - uint32_t timeTravel = ((1500 / myNodeInfo.bitrate) >= 30) ? (1500 / myNodeInfo.bitrate) : 30; + // Yes, this has a bunch of magic numbers. Sorry. + uint32_t timeTravel = ((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum; // If the distance traveled since the last update is greater than 100 meters // and it's been at least 60 seconds since the last update From 62602b54f4bd55fc58d5c345f3536c5d7fb100bf Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 14 Dec 2021 23:50:49 -0500 Subject: [PATCH 12/22] Improve time to generate the SSL certificate --- src/graphics/Screen.cpp | 12 ++++++++++-- src/mesh/http/WebServer.cpp | 22 ++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 2b028a842..71cdad008 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -156,7 +156,11 @@ static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16 display->drawString(64 + x, y, "Creating SSL certificate"); display->setFont(FONT_SMALL); - display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait..."); + if ((millis() / 1000) % 2) { + display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ."); + } else { + display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . "); + } } #ifdef HAS_EINK @@ -216,7 +220,11 @@ static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, i display->drawString(64 + x, y, "Updating"); display->setFont(FONT_SMALL); - display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait..."); + if ((millis() / 1000) % 2) { + display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ."); + } else { + display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . "); + } // display->setFont(FONT_LARGE); // display->drawString(64 + x, 26 + y, btPIN); diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index f9e2e99dc..9d370846b 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "sleep.h" #include #include @@ -79,12 +80,14 @@ static void taskCreateCert(void *parameter) prefs.begin("MeshtasticHTTPS", false); // Delete the saved certs (used in debugging) - if (0) { + +#if 0 DEBUG_MSG("Deleting any saved SSL keys ...\n"); // prefs.clear(); prefs.remove("PK"); prefs.remove("cert"); - } +#endif + DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n"); @@ -103,16 +106,12 @@ static void taskCreateCert(void *parameter) cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen); DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength()); - // DEBUG_MSG("Retrieved Private Key: " + String(cert->getPKLength()) + " Bytes"); - // for (int i = 0; i < cert->getPKLength(); i++) - // Serial.print(cert->getPKData()[i], HEX); - // Serial.println(); - DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength()); - // for (int i = 0; i < cert->getCertLength(); i++) - // Serial.print(cert->getCertData()[i], HEX); - // Serial.println(); + } else { + + setCPUFast(true); + DEBUG_MSG("Creating the certificate. This may take a while. Please wait...\n"); yield(); cert = new SSLCert(); @@ -144,6 +143,9 @@ static void taskCreateCert(void *parameter) prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength()); prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength()); } + + setCPUFast(false); + } isCertReady = true; From 5ff6b919c6bfc00a95e337a9da0f71a67a4db483 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 15 Dec 2021 07:50:36 -0600 Subject: [PATCH 13/22] Remove BATTERY_PIN from tlora v1 target (#996) --- src/configuration.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index 0d32e36fd..2bddcbb65 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -330,8 +330,6 @@ along with this program. If not, see . #define GPS_RX_PIN 36 #define GPS_TX_PIN 37 -#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage - #define I2C_SDA 4 // I2C pins for this board #define I2C_SCL 15 From 5354c49c50fcf8b87a34bbfd307ab23fb2cc41fe Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 16 Dec 2021 13:53:59 -0500 Subject: [PATCH 14/22] Bump version to 1.2.49 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 5eae0b8b4..13eff275e 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 2 -build = 48 +build = 49 From a27260a605e324d05d0ebe24beca6229f3549536 Mon Sep 17 00:00:00 2001 From: Vladislav Osmanov <7123463+osmanovv@users.noreply.github.com> Date: Fri, 17 Dec 2021 12:13:27 +0300 Subject: [PATCH 15/22] Overridden default pin to use for Ext Notify Plugin (#975) In Meshtastic DIY `GPIO13` is used for `SX126X_TXEN`, so we choose `GPIO12` as default for Ext Notification Plugin. --- src/configuration.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/configuration.h b/src/configuration.h index 2bddcbb65..597f60094 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -243,6 +243,7 @@ along with this program. If not, see . //#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 LORA_DIO0 26 // a No connect on the SX1262/SX1268 module #define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268 From b71051a227ff35dac62c53b7cfd4bcf45d186ac2 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Fri, 17 Dec 2021 14:02:29 -0500 Subject: [PATCH 16/22] Attempt to address the ssl screen crashing on AndreK's device. --- src/graphics/Screen.cpp | 8 ++++- src/mesh/http/WebServer.cpp | 70 ++++++++++++------------------------- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 71cdad008..ecf9953be 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -40,6 +40,7 @@ along with this program. If not, see . #ifndef NO_ESP32 #include "mesh/http/WiFiAPClient.h" +#include "esp_task_wdt.h" #endif using namespace meshtastic; /** @todo remove */ @@ -155,6 +156,11 @@ static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16 display->setFont(FONT_SMALL); display->drawString(64 + x, y, "Creating SSL certificate"); +#ifndef NO_ESP32 + yield(); + esp_task_wdt_reset(); +#endif + display->setFont(FONT_SMALL); if ((millis() / 1000) % 2) { display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ."); @@ -934,7 +940,7 @@ void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiStat * it is expected that this will be used during the boot phase */ void Screen::setSSLFrames() { - DEBUG_MSG("showing SSL frames\n"); + // DEBUG_MSG("showing SSL frames\n"); static FrameCallback sslFrames[] = {drawSSLScreen}; ui.setFrames(sslFrames, 1); ui.update(); diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 9d370846b..dea62765c 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -79,13 +79,13 @@ static void taskCreateCert(void *parameter) { prefs.begin("MeshtasticHTTPS", false); - // Delete the saved certs (used in debugging) #if 0 - DEBUG_MSG("Deleting any saved SSL keys ...\n"); - // prefs.clear(); - prefs.remove("PK"); - prefs.remove("cert"); + // Delete the saved certs (used in debugging) + DEBUG_MSG("Deleting any saved SSL keys ...\n"); + // prefs.clear(); + prefs.remove("PK"); + prefs.remove("cert"); #endif @@ -156,6 +156,7 @@ static void taskCreateCert(void *parameter) void createSSLCert() { + bool runLoop = false; if (isWifiAvailable() && !isCertReady) { // Create a new process just to handle creating the cert. @@ -163,21 +164,28 @@ void createSSLCert() // jm@casler.org (Oct 2020) xTaskCreate(taskCreateCert, /* Task function. */ "createCert", /* String with name of task. */ - 16384, /* Stack size in bytes. */ + //16384, /* Stack size in bytes. */ + 8192, /* Stack size in bytes. */ NULL, /* Parameter passed as input of the task */ 16, /* Priority of the task. */ NULL); /* Task handle. */ DEBUG_MSG("Waiting for SSL Cert to be generated.\n"); - int seconds = 0; while (!isCertReady) { - DEBUG_MSG("."); - delay(1000); - yield(); - esp_task_wdt_reset(); - seconds++; - if ((seconds == 3) && screen) { - screen->setSSLFrames(); + if ((millis() / 500) % 2) { + if (runLoop) { + DEBUG_MSG("."); + + yield(); + esp_task_wdt_reset(); + + if ((millis() / 1000 >= 3) && screen) { + screen->setSSLFrames(); + } + } + runLoop = false; + } else { + runLoop = true; } } DEBUG_MSG("SSL Cert Ready!\n"); @@ -201,40 +209,6 @@ void initWebServer() { DEBUG_MSG("Initializing Web Server ...\n"); -#if 0 -// this seems to be a copypaste dup of taskCreateCert - prefs.begin("MeshtasticHTTPS", false); - - size_t pkLen = prefs.getBytesLength("PK"); - size_t certLen = prefs.getBytesLength("cert"); - - DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n"); - - if (pkLen && certLen) { - - uint8_t *pkBuffer = new uint8_t[pkLen]; - prefs.getBytes("PK", pkBuffer, pkLen); - - uint8_t *certBuffer = new uint8_t[certLen]; - prefs.getBytes("cert", certBuffer, certLen); - - cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen); - - DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength()); - // DEBUG_MSG("Retrieved Private Key: " + String(cert->getPKLength()) + " Bytes"); - // for (int i = 0; i < cert->getPKLength(); i++) - // Serial.print(cert->getPKData()[i], HEX); - // Serial.println(); - - DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength()); - // for (int i = 0; i < cert->getCertLength(); i++) - // Serial.print(cert->getCertData()[i], HEX); - // Serial.println(); - } else { - DEBUG_MSG("Web Server started without SSL keys! How did this happen?\n"); - } -#endif - // We can now use the new certificate to setup our server as usual. secureServer = new HTTPSServer(cert); insecureServer = new HTTPServer(); From d1370071da5d6b449caa22f4aa7c5a30f6a53e96 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Fri, 17 Dec 2021 15:53:23 -0500 Subject: [PATCH 17/22] Test that the screen object has been created --- src/mesh/http/WebServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index dea62765c..301b18ccb 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -179,8 +179,9 @@ void createSSLCert() yield(); esp_task_wdt_reset(); - if ((millis() / 1000 >= 3) && screen) { - screen->setSSLFrames(); + if ((millis() / 1000 >= 3) && screen) { + if (screen) + screen->setSSLFrames(); } } runLoop = false; From f3fc88ac5d49976af4ace8d4a3d7d0471429903d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 18 Dec 2021 11:02:54 -0500 Subject: [PATCH 18/22] Test if screen address was found --- src/graphics/Screen.cpp | 11 +++++++---- src/graphics/Screen.h | 2 ++ src/mesh/http/WebServer.cpp | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index ecf9953be..dc3f73d39 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -703,6 +703,7 @@ void _screen_header() Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev) { + address_found = address; cmdQueue.setReader(this); } @@ -940,10 +941,12 @@ void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiStat * it is expected that this will be used during the boot phase */ void Screen::setSSLFrames() { - // DEBUG_MSG("showing SSL frames\n"); - static FrameCallback sslFrames[] = {drawSSLScreen}; - ui.setFrames(sslFrames, 1); - ui.update(); + if (address_found) { + // DEBUG_MSG("showing SSL frames\n"); + static FrameCallback sslFrames[] = {drawSSLScreen}; + ui.setFrames(sslFrames, 1); + ui.update(); + } } // restore our regular frame list diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index e4b9044c7..9334fe43c 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -97,6 +97,8 @@ class Screen : public concurrency::OSThread Screen(const Screen &) = delete; Screen &operator=(const Screen &) = delete; + uint8_t address_found; + /// Initializes the UI, turns on the display, starts showing boot screen. // // Not thread safe - must be called before any other methods are called. diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 301b18ccb..d073c16a0 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -6,6 +6,8 @@ #include #include #include "sleep.h" +#include "graphics/Screen.h" + #include #include @@ -179,9 +181,8 @@ void createSSLCert() yield(); esp_task_wdt_reset(); - if ((millis() / 1000 >= 3) && screen) { - if (screen) - screen->setSSLFrames(); + if (millis() / 1000 >= 3) { + screen->setSSLFrames(); } } runLoop = false; From 0e5a783c5aba82063e62b2064ecb283a30ec3755 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 18 Dec 2021 15:20:17 -0500 Subject: [PATCH 19/22] Show fixed position indicator on screen #866 Show fixed position indicator on screen #866 --- src/graphics/Screen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index dc3f73d39..702708c82 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -428,7 +428,10 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const auto gpsFormat = radioConfig.preferences.gps_format; String displayLine = ""; - if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) { + if (radioConfig.preferences.fixed_position) { + displayLine = "Fixed GPS"; + display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); + } else if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) { displayLine = "No GPS Module"; display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); } else if (!gps->getHasLock() && !radioConfig.preferences.fixed_position) { From 4fcd82d6f575f9108d963573296318e3e9b85071 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 18 Dec 2021 15:51:44 -0500 Subject: [PATCH 20/22] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 10e6857b1..26389cfa0 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 10e6857b1bd4a03ec16ec5cbaadf4f28293ab9a5 +Subproject commit 26389cfa05f4980f318cc5c4ddbe3770a7865251 From d7a1b9fd62c93c5994adcdedb2ee37728afa6745 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 18 Dec 2021 16:21:12 -0500 Subject: [PATCH 21/22] Allow hop_limit to be configured https://github.com/meshtastic/Meshtastic-device/issues/1007 --- src/mesh/ReliableRouter.cpp | 9 +++++++-- src/mesh/Router.cpp | 6 +++++- src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/radioconfig.pb.h | 13 ++++++++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index dd2fd9b2a..96aca5026 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -16,8 +16,13 @@ ErrorCode ReliableRouter::send(MeshPacket *p) // If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our // message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop counts // and we want this message to get through the whole mesh, so use the default. - if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) - p->hop_limit = HOP_RELIABLE; + if (p->to == NODENUM_BROADCAST && p->hop_limit == 0) { + if (radioConfig.preferences.hop_limit && radioConfig.preferences.hop_limit <= HOP_MAX) { + p->hop_limit = (radioConfig.preferences.hop_limit >= HOP_MAX) ? HOP_MAX : radioConfig.preferences.hop_limit; + } else { + p->hop_limit = HOP_RELIABLE; + } + } auto copy = packetPool.allocCopy(*p); startRetransmission(copy); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 053f36295..5c62b87ab 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -115,7 +115,11 @@ MeshPacket *Router::allocForSending() p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start. p->from = nodeDB.getNodeNum(); p->to = NODENUM_BROADCAST; - p->hop_limit = HOP_RELIABLE; + if (radioConfig.preferences.hop_limit && radioConfig.preferences.hop_limit <= HOP_MAX) { + p->hop_limit = (radioConfig.preferences.hop_limit >= HOP_MAX) ? HOP_MAX : radioConfig.preferences.hop_limit; + } else { + p->hop_limit = HOP_RELIABLE; + } p->id = generatePacketId(); p->rx_time = getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 670978a0a..08c647aea 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 454 +#define AdminMessage_size 461 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index ae13b867c..8fb70d39b 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -152,6 +152,7 @@ typedef struct _RadioConfig_UserPreferences { bool is_always_powered; uint32_t auto_screen_carousel_secs; uint32_t on_battery_shutdown_after_secs; + uint32_t hop_limit; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -196,9 +197,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} +#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} #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} +#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} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -266,6 +267,7 @@ extern "C" { #define RadioConfig_UserPreferences_is_always_powered_tag 151 #define RadioConfig_UserPreferences_auto_screen_carousel_secs_tag 152 #define RadioConfig_UserPreferences_on_battery_shutdown_after_secs_tag 153 +#define RadioConfig_UserPreferences_hop_limit_tag 154 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -340,7 +342,8 @@ X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_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) \ -X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) +X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \ +X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -352,8 +355,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 451 -#define RadioConfig_UserPreferences_size 448 +#define RadioConfig_size 458 +#define RadioConfig_UserPreferences_size 455 #ifdef __cplusplus } /* extern "C" */ From 3adb79bd187bc148773e458fec02845e45aa7015 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 19 Dec 2021 13:54:51 -0500 Subject: [PATCH 22/22] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 26389cfa0..c52c8ef99 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 26389cfa05f4980f318cc5c4ddbe3770a7865251 +Subproject commit c52c8ef99ead88a5edb73891b33247c54d37cb28