Skip to content

Update MediaKeys for API chagnes and fix EspNowBridge - #42

Merged
KenVanHoeylandt merged 3 commits into
mainfrom
develop
Aug 26, 2026
Merged

Update MediaKeys for API chagnes and fix EspNowBridge#42
KenVanHoeylandt merged 3 commits into
mainfrom
develop

Conversation

@KenVanHoeylandt

@KenVanHoeylandt KenVanHoeylandt commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Improved Bluetooth event handling in Media Keys for more reliable device interaction.
    • Bluetooth state is restored appropriately when the feature is disabled or the app exits.
  • Bug Fixes

    • Fixed shutdown sequencing to prevent invalid event-group access during app teardown.
  • Chores

    • Updated EspNowBridge to version 0.8.0.
    • Updated Media Keys to version 0.11.0.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The ESP-NOW Bridge now tears down its WiFi event-group subscription before destroying the task event group. Media Keys now acquires Bluetooth resources during initialization, subscribes to Bluetooth events, polls events in the app loop, and dispatches them through handleBtEvent. Bluetooth device references persist for the app lifetime. Toggle-off restores the prior radio state without full teardown. Both applications have updated version metadata.

Merge Risk: 🔵 Low · up to 5353e

The change can leave a previously disabled Bluetooth radio enabled when HID startup fails, so later toggling may not restore the user’s original radio state. This is localized and mergeable with explicit owner follow-up to restore the radio on both failure paths.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the two main changes: MediaKeys API updates and the EspNowBridge fix. The typo in “chagnes” does not prevent understanding.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Apps/MediaKeys/main/Source/MediaKeys.cpp (1)

210-224: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore the radio after HID startup failure.

If either failure path runs after this app enabled an initially-off radio, the code clears the switch but leaves the radio ON. A later successful enable clears radioWasOff, so toggle-off no longer restores the original radio state.

Proposed fix
 void startHid(Context* ctx) {
     // Called once the BT radio is confirmed ON (either already was, or just came up).
     // May be called from handleBtEvent() on the app's own task - LVGL must already be locked by caller.
     ctx->radioEnabling = false;

     ctx->hidDevice = bluetooth_hid_device_get_device();
     if (!ctx->hidDevice) {
         LOG_E(TAG, "BLE HID device unavailable after radio on");
         ctx->isEnabled = false;
         if (ctx->switchWidget) lv_obj_remove_state(ctx->switchWidget, LV_STATE_CHECKED);
+        restoreRadioIfNeeded(ctx);
         return;
     }

     error_t err = bluetooth_hid_device_start(ctx->hidDevice, BT_HID_DEVICE_MODE_KEYBOARD);
     if (err != ERROR_NONE) {
         LOG_E(TAG, "Failed to start HID device: %d", (int)err);
         ctx->hidDevice = nullptr;
         ctx->isEnabled = false;
         if (ctx->switchWidget) lv_obj_remove_state(ctx->switchWidget, LV_STATE_CHECKED);
+        restoreRadioIfNeeded(ctx);
         return;
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bd434e25-db40-42da-a03d-1c025ce9321a

📥 Commits

Reviewing files that changed from the base of the PR and between b0baa00 and 5353e0e.

📒 Files selected for processing (6)
  • Apps/EspNowBridge/main/Source/main.cpp
  • Apps/EspNowBridge/manifest.properties
  • Apps/MediaKeys/main/Source/MediaKeys.cpp
  • Apps/MediaKeys/main/Source/MediaKeys.h
  • Apps/MediaKeys/main/Source/main.cpp
  • Apps/MediaKeys/manifest.properties

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

@KenVanHoeylandt
KenVanHoeylandt merged commit 55328ce into main Aug 26, 2026
21 checks passed
@KenVanHoeylandt
KenVanHoeylandt deleted the develop branch August 26, 2026 06:29
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.

1 participant