From 11130496c4ecdb803ddd62651f1229ed9496f49b Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 15 Mar 2022 15:49:25 -0700 Subject: [PATCH] remove is_router in favor of role == Role_Router --- src/PowerFSM.cpp | 4 ++-- src/gps/GPS.cpp | 4 ++-- src/mesh/NodeDB.h | 2 +- src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/radioconfig.pb.h | 11 ++++------- src/modules/esp32/StoreForwardModule.cpp | 5 ++--- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 095f844b5..802f8665d 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -16,7 +16,7 @@ static bool isPowered() return true; } - bool isRouter = radioConfig.preferences.is_router; + bool isRouter = (radioConfig.preferences.role == Role_Router ? 1 : 0); // If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON // We assume routers might be powered all the time, but from a low current (solar) source @@ -238,7 +238,7 @@ Fsm powerFSM(&stateBOOT); void PowerFSM_setup() { - bool isRouter = radioConfig.preferences.is_router; + bool isRouter = (radioConfig.preferences.role == Role_Router ? 1 : 0); bool hasPower = isPowered(); DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower); diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index c1e480347..6b0c1e3a4 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -167,7 +167,7 @@ uint32_t GPS::getWakeTime() const return t; // already maxint if (t == 0) - t = radioConfig.preferences.is_router ? 5 * 60 : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much + t = (radioConfig.preferences.role == Role_Router) ? 5 * 60 : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much // less if we can find sats) or less if a router t *= 1000; // msecs @@ -190,7 +190,7 @@ uint32_t GPS::getSleepTime() const return t; // already maxint if (t == 0) // default - unset in preferences - t = radioConfig.preferences.is_router ? 24 * 60 * 60 : 2 * 60; // 2 mins or once per day for routers + t = (radioConfig.preferences.role == Role_Router) ? 24 * 60 * 60 : 2 * 60; // 2 mins or once per day for routers t *= 1000; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 86ab874e8..2724bf797 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -157,7 +157,7 @@ extern NodeDB nodeDB; // Our delay functions check for this for times that should never expire #define NODE_DELAY_FOREVER 0xffffffff -#define IF_ROUTER(routerVal, normalVal) (radioConfig.preferences.is_router ? (routerVal) : (normalVal)) +#define IF_ROUTER(routerVal, normalVal) ((radioConfig.preferences.role == Role_Router) ? (routerVal) : (normalVal)) #define PREF_GET(name, defaultVal) \ inline uint32_t getPref_##name() { return radioConfig.preferences.name ? radioConfig.preferences.name : (defaultVal); } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 6230efbe2..fc9a20d56 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 611 +#define AdminMessage_size 608 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index ac4c40443..4674ca0d2 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -133,7 +133,6 @@ typedef struct _RadioConfig_UserPreferences { GpsOperation gps_operation; uint32_t gps_update_interval; uint32_t gps_attempt_time; - bool is_router; bool is_low_power; bool fixed_position; bool serial_disabled; @@ -249,9 +248,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, _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_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, _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, _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_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, _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 @@ -275,7 +274,6 @@ extern "C" { #define RadioConfig_UserPreferences_gps_operation_tag 33 #define RadioConfig_UserPreferences_gps_update_interval_tag 34 #define RadioConfig_UserPreferences_gps_attempt_time_tag 36 -#define RadioConfig_UserPreferences_is_router_tag 37 #define RadioConfig_UserPreferences_is_low_power_tag 38 #define RadioConfig_UserPreferences_fixed_position_tag 39 #define RadioConfig_UserPreferences_serial_disabled_tag 40 @@ -369,7 +367,6 @@ 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) \ X(a, STATIC, SINGULAR, UINT32, gps_attempt_time, 36) \ -X(a, STATIC, SINGULAR, BOOL, is_router, 37) \ X(a, STATIC, SINGULAR, BOOL, is_low_power, 38) \ X(a, STATIC, SINGULAR, BOOL, fixed_position, 39) \ X(a, STATIC, SINGULAR, BOOL, serial_disabled, 40) \ @@ -443,8 +440,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 608 -#define RadioConfig_UserPreferences_size 605 +#define RadioConfig_size 605 +#define RadioConfig_UserPreferences_size 602 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index 41e7077b7..a3fc2a3f0 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -21,7 +21,7 @@ int32_t StoreForwardModule::runOnce() if (radioConfig.preferences.store_forward_module_enabled) { - if (radioConfig.preferences.is_router) { + if (radioConfig.preferences.role == Role_Router) { // Send out the message queue. if (this->busy) { @@ -392,14 +392,13 @@ StoreForwardModule::StoreForwardModule() */ radioConfig.preferences.store_forward_module_enabled = 1; - radioConfig.preferences.is_router = 1; radioConfig.preferences.is_always_powered = 1; } if (radioConfig.preferences.store_forward_module_enabled) { // Router - if (radioConfig.preferences.is_router) { + if (radioConfig.preferences.role == Role_Router) { DEBUG_MSG("Initializing Store & Forward Module - Enabled as Router\n"); if (ESP.getPsramSize()) { if (ESP.getFreePsram() >= 1024 * 1024) {