qmk_firmware icon indicating copy to clipboard operation
qmk_firmware copied to clipboard

annepro2: Add BLE status handling

Open mkopec opened this issue 9 months ago • 3 comments

Add BLE handling for Anne Pro 2:

  • Caps Lock LED
  • Cancelling profile key blinking upon successful connection, selecting another slot, selecting USB or unpairing.

Description

Add code to manage the bluetooth Caps Lock status LED, and to cancel the bluetooth profile key blinking upon succesful connection, unpairing or switching to USB mode.

I have not thoroughly reversed the BLE firmware protocol, but I observed that:

  • When enabling capslock on BLE host, the BLE firmware sends a message ending with 07 0x where x may be 0 if capslock is off, or 1 when capslock is on
  • When switching profiles, as soon as the connection is established, a message of the same size ending in 0c 00 is received on the BLE UART, which I guess is the confirmation of connection. I use that to cancel any blinking.

I was not able to trigger any other messages on that UART so I didn't implement full protocol handling (not enough data anyway)

The capslock status is reset upon switching slots, as per Bluetooth HID profile specification 1.1, appendix F

Tested on a C18 variant of the board with BLE firmware v1.0.0

Types of Changes

  • [ ] Core
  • [x] Bugfix
  • [ ] New feature
  • [x] Enhancement/optimization
  • [x] Keyboard (addition or update)
  • [ ] Keymap/layout (addition or update)
  • [ ] Documentation

Issues Fixed or Closed by This PR

  • https://github.com/qmk/qmk_firmware/issues/18435

Checklist

  • [x] My code follows the code style of this project: C, Python
  • [x] I have read the PR Checklist document and have made the appropriate changes.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
  • [x] I have tested the changes and verified that they work and don't break anything (as well as I can manage).

mkopec avatar Mar 08 '25 15:03 mkopec

This seems to break Bluetooth compatibility on my AnnePro2. My MacBook connects and instantly disconnects when using this patch applied to the top of develop, but works fine with develop at the same revision.

tzarc avatar Mar 28 '25 09:03 tzarc

That's weird, it's not sending any commands to the BLE controller, only parsing the ones that it sends to the AP. Sadly I don't have a macbook available for testing, but this change hasn't affected connectivity with my Linux PCs

mkopec avatar Mar 30 '25 10:03 mkopec

Thank you for your contribution! This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready. For maintainers: Please label with bug, awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

github-actions[bot] avatar May 15 '25 02:05 github-actions[bot]

Thank you for your contribution! This pull request has been automatically closed because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. // [stale-action-closed]

github-actions[bot] avatar Jun 14 '25 02:06 github-actions[bot]