Skip to content

feat(auto-off): add auto off manager for dynamic handling of auto-off functionality#214

Open
Ruben-Lohberg wants to merge 7 commits into
mainfrom
auto-off-2
Open

feat(auto-off): add auto off manager for dynamic handling of auto-off functionality#214
Ruben-Lohberg wants to merge 7 commits into
mainfrom
auto-off-2

Conversation

@Ruben-Lohberg
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkuettner97 @DennisMoschina Please review. This is my first time implementing a BLE service and I heavily relied on Codex

Comment thread src/bluetooth/gatt_services/power_saving_service.h
@github-actions
Copy link
Copy Markdown

Build output available:
openearable_v2_firmware.elf.zip
openearable_v2_fota.zip

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AutoOffManager singleton 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FW: add configurable auto-off feature for earable devices

3 participants