feat(auto-off): add auto off manager for dynamic handling of auto-off functionality#214
Open
Ruben-Lohberg wants to merge 7 commits into
Open
feat(auto-off): add auto off manager for dynamic handling of auto-off functionality#214Ruben-Lohberg wants to merge 7 commits into
Ruben-Lohberg wants to merge 7 commits into
Conversation
Ruben-Lohberg
commented
May 18, 2026
Collaborator
Author
There was a problem hiding this comment.
@mkuettner97 @DennisMoschina Please review. This is my first time implementing a BLE service and I heavily relied on Codex
Ruben-Lohberg
commented
May 18, 2026
|
Build output available: |
There was a problem hiding this comment.
Pull request overview
This PR introduces an AutoOffManager to coordinate automatic power-off based on a configurable “power saving mode”, integrates it with sensor and LE Audio activity, and exposes the current/supported modes via a new Bluetooth GATT service.
Changes:
- Add
AutoOffManagersingleton with participant registration + allow/prohibit gating and persistent mode selection. - Integrate auto-off participation into SensorManager and LE Audio streaming state.
- Add a new BLE GATT “power saving” service and corresponding Kconfig/prj.conf settings for defaults, component thresholds, and timeouts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/SensorManager/SensorManager.cpp |
Registers SensorManager as an auto-off participant and toggles allow/prohibit based on active sensors. |
src/bluetooth/gatt_services/power_saving_service.h |
Defines UUIDs for the new Power Saving BLE GATT service/characteristics. |
src/bluetooth/gatt_services/power_saving_service.c |
Implements read/write of current mode and read of supported modes via AutoOffManager. |
src/bluetooth/gatt_services/CMakeLists.txt |
Adds the new power saving service source to the build. |
src/bluetooth/bt_stream/le_audio.c |
Registers LE Audio as an auto-off participant and toggles based on streaming events via zbus. |
src/Battery/Kconfig |
Adds Kconfig options for default mode, per-component thresholds, and mode-specific timeouts. |
src/Battery/CMakeLists.txt |
Adds AutoOffManager.cpp to the build. |
src/Battery/AutoOffManager.h |
Declares the AutoOffManager API and C wrappers for C modules. |
src/Battery/AutoOffManager.cpp |
Implements participant registry, scheduling/canceling delayed power-off, and settings persistence. |
src/audio/streamctrl.c |
Initializes the auto-off manager during application startup. |
prj.conf |
Sets concrete default values for the newly introduced Kconfig options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return false; | ||
| } | ||
|
|
||
| return participant.level >= current_mode; |
| K_MUTEX_DEFINE(auto_off_mutex); | ||
| K_WORK_DELAYABLE_DEFINE(auto_off_work, auto_off_work_handler); | ||
|
|
||
| // RAII implementation for k_mutext instead of std::lock_guard<std::mutex> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.