From 3da9c7b081a92251396909499959f256e3fa27e6 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 5 Dec 2021 10:20:16 -0800 Subject: [PATCH 1/4] Update lastlat/lastlong int32 #956 --- src/plugins/PositionPlugin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/PositionPlugin.h b/src/plugins/PositionPlugin.h index 5ffe04803..402650afb 100644 --- a/src/plugins/PositionPlugin.h +++ b/src/plugins/PositionPlugin.h @@ -14,8 +14,8 @@ class PositionPlugin : public ProtobufPlugin, private concurrency::OST uint32_t lastGpsSend = 0; // Store the latest good lat / long - uint32_t lastGpsLatitude = 0; - uint32_t lastGpsLongitude = 0; + int32_t lastGpsLatitude = 0; + int32_t lastGpsLongitude = 0; /// We force a rebroadcast if the radio settings change uint32_t currentGeneration = 0; From eefef1dcebfa99f37285c062765f88191132694d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 5 Dec 2021 16:17:13 -0800 Subject: [PATCH 2/4] Add channel bitrate to myNodeInfo #959 --- src/configuration.h | 2 +- src/main.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/configuration.h b/src/configuration.h index a331c6441..4e73531db 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -200,7 +200,7 @@ along with this program. If not, see . // Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts // and waking from light sleep // #define PMU_IRQ 35 -// #define AXP192_SLAVE_ADDRESS 0x34 +#define AXP192_SLAVE_ADDRESS 0x34 #elif defined(TBEAM_V07) // This string must exactly match the case used in release file names or the android updater won't work diff --git a/src/main.cpp b/src/main.cpp index d28b8431a..4429391d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -590,6 +590,13 @@ void setup() 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. + myNodeInfo.bitrate = (float(Constants_DATA_PAYLOAD_LEN) / + (float(rIf->getPacketTime(Constants_DATA_PAYLOAD_LEN))) + ) * 1000; + DEBUG_MSG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate); + // This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values PowerFSM_setup(); // we will transition to ON in a couple of seconds, FIXME, only do this for cold boots, not waking from SDS powerFSMthread = new PowerFSMThread(); From 02e3d06bcb5009f8a2d7a6988df4781263dcd472 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 5 Dec 2021 18:31:36 -0600 Subject: [PATCH 3/4] Remove promote-release.sh from Release process (#958) --- .github/workflows/release.yml | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e4e259a6..40d4fcb49 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,12 +4,12 @@ on: # workflow_dispatch: # inputs: - # Only want to be run if a new tag starting with v is pushed. + # Only want to run if version.properties is bumped in master push: branches: - - "!*" - tags: - - "v1*" + - master + paths: + - 'version.properties' jobs: release-build: @@ -21,19 +21,15 @@ jobs: with: submodules: 'recursive' - # get github branch and tag names as ${{ steps.branch_name.outputs.SOURCE_TAG }} - - name: Branch name - id: branch_name - run: | - echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} - echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} - echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} - - name: Setup Python uses: actions/setup-python@v2 with: python-version: 3.x - + + # Will be available in steps.version.outputs.version + - name: Get release version string + run: echo "::set-output name=version::$(./bin/buildinfo.py long)" + id: version # Note: we don't use caches on release builds because we don't want to accidentally not have a virgin build machine - name: Upgrade python tools @@ -60,11 +56,6 @@ jobs: tar -xf build.tar -C data/static rm build.tar - # Will be available in steps.version.outputs.version - - name: Get version string - run: echo "::set-output name=version::$(./bin/buildinfo.py long)" - id: version - - name: Build everything run: bin/build-all.sh @@ -75,8 +66,7 @@ jobs: draft: true prerelease: true release_name: ${{ steps.version.outputs.version }} alpha - tag_name: ${{ steps.branch_name.outputs.SOURCE_TAG }} - # was ${{ github.ref }} + tag_name: v${{ steps.version.outputs.version }} body: | Autogenerated by github action, developer should edit as required before publishing... env: @@ -100,4 +90,4 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: release/archive/elfs-${{ steps.version.outputs.version }}.zip asset_name: debug-elfs-${{ steps.version.outputs.version }}.zip - asset_content_type: application/zip \ No newline at end of file + asset_content_type: application/zip From 5b34e3e1abd1030def911e097435cc49e04b42f1 Mon Sep 17 00:00:00 2001 From: Joshua Pirihi Date: Mon, 6 Dec 2021 15:37:35 +1300 Subject: [PATCH 4/4] When switching to battery, shutdown after on_battery_shutdown_after_secs --- src/PowerFSM.cpp | 17 +++++++++++++++++ src/PowerFSM.h | 1 + src/main.cpp | 9 +++++++++ src/mesh/generated/radioconfig.pb.h | 13 ++++++++----- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index e4cf8fae5..392992191 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -37,6 +37,14 @@ static void sdsEnter() doDeepSleep(getPref_sds_secs() * 1000LL); } +extern Power *power; + +static void shutdownEnter() +{ + DEBUG_MSG("Enter state: SHUTDOWN\n"); + power->shutdown(); +} + #include "error.h" static uint32_t secsSlept; @@ -217,6 +225,7 @@ static void bootEnter() { DEBUG_MSG("Enter state: BOOT\n"); } +State stateSHUTDOWN(shutdownEnter, NULL, NULL, "SHUTDOWN"); State stateSDS(sdsEnter, NULL, NULL, "SDS"); State stateLS(lsEnter, lsIdle, lsExit, "LS"); State stateNB(nbEnter, NULL, NULL, "NB"); @@ -260,6 +269,14 @@ void PowerFSM_setup() powerFSM.add_transition(&stateON, &stateSDS, EVENT_LOW_BATTERY, NULL, "LowBat"); powerFSM.add_transition(&stateSERIAL, &stateSDS, EVENT_LOW_BATTERY, NULL, "LowBat"); + // Handle being told to power off + powerFSM.add_transition(&stateBOOT, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateLS, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateNB, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateDARK, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateON, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateSERIAL, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + powerFSM.add_transition(&stateDARK, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing"); powerFSM.add_transition(&stateON, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing"); diff --git a/src/PowerFSM.h b/src/PowerFSM.h index 5541385a3..2515534b5 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -19,6 +19,7 @@ #define EVENT_POWER_CONNECTED 13 #define EVENT_POWER_DISCONNECTED 14 #define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone +#define EVENT_SHUTDOWN 16 //force a full shutdown now (not just sleep) extern Fsm powerFSM; extern State statePOWER, stateSERIAL; diff --git a/src/main.cpp b/src/main.cpp index 4429391d9..eafd19560 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -134,6 +134,8 @@ static int32_t ledBlinker() return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000); } +uint32_t timeLastPowered = 0; + /// Wrapper to convert our powerFSM stuff into a 'thread' class PowerFSMThread : public OSThread { @@ -151,6 +153,13 @@ class PowerFSMThread : public OSThread 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; } }; diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 4cbb693b3..ae13b867c 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -151,6 +151,7 @@ typedef struct _RadioConfig_UserPreferences { uint32_t position_flags; bool is_always_powered; uint32_t auto_screen_carousel_secs; + uint32_t on_battery_shutdown_after_secs; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -195,9 +196,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} +#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_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} +#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} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -264,6 +265,7 @@ extern "C" { #define RadioConfig_UserPreferences_position_flags_tag 150 #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_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -337,7 +339,8 @@ 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) \ X(a, STATIC, SINGULAR, BOOL, is_always_powered, 151) \ -X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) +X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \ +X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -349,8 +352,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 444 -#define RadioConfig_UserPreferences_size 441 +#define RadioConfig_size 451 +#define RadioConfig_UserPreferences_size 448 #ifdef __cplusplus } /* extern "C" */