Update MediaKeys for API chagnes and fix EspNowBridge - #42
Conversation
📝 WalkthroughWalkthroughThe 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 Merge Risk: 🔵 Low · up to 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)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winRestore 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
📒 Files selected for processing (6)
Apps/EspNowBridge/main/Source/main.cppApps/EspNowBridge/manifest.propertiesApps/MediaKeys/main/Source/MediaKeys.cppApps/MediaKeys/main/Source/MediaKeys.hApps/MediaKeys/main/Source/main.cppApps/MediaKeys/manifest.properties
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.
Summary by CodeRabbit
New Features
Bug Fixes
Chores