Skip to content

Fix BLE Keyboard HID service advertising - #2932

Open
federicopignatiello-png wants to merge 1 commit into
BruceDevices:devfrom
federicopignatiello-png:fix/ble-keyboard-hid-advertising
Open

federicopignatiello-png wants to merge 1 commit into
BruceDevices:devfrom
federicopignatiello-png:fix/ble-keyboard-hid-advertising

Conversation

@federicopignatiello-png

Copy link
Copy Markdown

Proposed Changes

BLE Keyboard (Keyboard_a) was not visible in Bluetooth discovery on Mac/iPhone when using an M5Stack Cardputer ADV.

In the normal HID advertising path, addServiceUUID() added HID service UUID 0x1812 to the advertising object. The subsequent setAdvertisementData() replaced that payload with a separate NimBLEAdvertisementData containing only flags, name, and appearance, dropping the HID UUID. Scan response is disabled in this path.

Add the HID UUID to the NimBLEAdvertisementData actually passed to setAdvertisementData(). This is a one-line move. The random-UUID path, security configuration, and other behavior remain unchanged.

Types of Changes

Bugfix.

Verification

On M5Stack Cardputer ADV, open BLE Keyboard, look for its configured name (e.g. Keyboard_a) on a Mac, pair it, and type harmless test text into an editor. A BLE advertisement inspection should show HID service UUID 0x1812 in the advertising payload.

Testing

  • Hardware tested: M5Stack Cardputer ADV.
  • Original firmware base: Bruce 1.16.1 (ba519c936c87b89c9c667c15b932d7faca5360d5). The device owner reports successful discovery, pairing, and BLE keyboard input on Mac after applying this fix in the diagnostic build.
  • Compared against current upstream main, a59213f3ec6cd302fa32c2042b2700c9c24d991a: BleKeyboard.cpp is identical to the 1.16.1 version and the same bug is present. This PR applies only the minimal fix on that main base.
  • pio run -e m5stack-cardputer succeeded with the exact source tree published in this PR. This is the official Cardputer/ADV environment. Reused the local toolchain/dependency cache, including NimBLE-Arduino 2.5.1 and FastLED 3.10.3 (satisfying the upstream constraint). Existing upstream deprecation/audio warnings remain; no build configuration changes are included.
  • git diff --check passes.
  • Hardware testing on the rebased main build has not been repeated. iPhone was part of the original visibility symptom; successful pairing/input is confirmed only on Mac.

Linked Issues

No linked issue.

User-Facing Change

Fix BLE Keyboard HID service advertising so the keyboard can be discovered by hosts such as macOS.

Further Comments

Only lib/Bad_Usb_Lib/BleKeyboard.cpp changes: one addition and one deletion. No diagnostic logging, binary artifacts, Wi-Fi, IR, SD, sniffer changes, or unrelated refactoring.

@Ninja-jr Ninja-jr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs to target dev. If the branch is off dev, just change the PR base. If it's off main, rebase locally onto dev and force-push.

Ninja-jr pushed a commit to Ninja-jr/Bruce_firmware that referenced this pull request Sep 29, 2026
@pr3y
pr3y changed the base branch from main to dev October 2, 2026 12:10

This branch has not been deployed

No deployments
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.

2 participants