-
-
Notifications
You must be signed in to change notification settings - Fork 39.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Keyboard] annepro2: fix bluetooth multi-pairing issue #17483
Conversation
This change fixes the bluetooth multi-pairing issue. ** Description ** The bluetooth broadcasting and connection functions in the annepro2_ble.c are incorrect, they do not handle the multi-pairing correctly. The exiting broadcasting command (12 bytes in total) is the combination of the 11 bytes length machine code (which is stated in the arrary "ble_mcu_start_broadcast[11]") and the 1 byte length value (which is stated in the variable "port" - also known as the Broadcast ID) : [ ble_mcu_start_broadcast (11 bytes) ] + [Broadcast ID 0-3 (1 byte)] 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00, 0x00-0x03 However, with above command, the annepro2 keyboard is always broadcasting the "ID 0" whatever we change the Broadcast ID to any value. The problem is that the eleventh byte of the command is actually for describing the Broadcast ID, that's why the exiting code is always broadcasting the "ID 0" which makes the keyboard unable to pair with other devices with ID 1-3. To resolve the problem, we can just simply modify the command to: [ ble_mcu_start_broadcast (10 bytes) ] + [Broadcast ID 0-3 (1 byte)] + [ 0x00 (1 byte)] 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00-0x03, 0x00 The bluetooth connection command has the same issue, so the fix has also covered that issue in this Push Request.
I've found this to be a major improvement. Switching between paired devices works as expected, but I have had to connect via USB before the keyboard will connect to any device over BT. Afterwards the keyboard can be unplugged and it continues to switch between devices Edit: I was mistaken. Connecting a USB cable not necessary. |
This works for me as well. Thanks coffeeyy! |
For some reason my AP2 won't pair even with normal master branch, let alone this PR. |
Try pressing the |
Nope, no difference, nor would I expect there to be considering the pairing is initiated through the serial link. |
I've tried out cherry-picking this commit on my fork and it fixes it - but that said I usually have through some hoops to make bluetooth on any firmware (ObinsKit included). Usually the
So far my experience with bluetooth with the QMK firmware and the fix on this PR has been as good as the official Obinskit firmware: works wonderfully after a lot of trial and error. |
Just got AP2 yesterday, already downloaded QMK, doing few tests and realized that BT was not working as was on ObinsKit firmware. Found this PR and I got my BT working again (BT1 on Linux, BT2 on Windows, BT3 on Android) I may easily swap between devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't prove that it works given my own AP2, but going off others' reports that it works.
This change fixes the bluetooth multi-pairing issue.
Description
The bluetooth broadcasting and connection functions in the annepro2_ble.c are incorrect, they do not handle the multi-pairing correctly.
The exiting broadcasting command (12 bytes in total) is the combination of the 11 bytes length machine code (which is stated in the array "ble_mcu_start_broadcast[11]") and the 1 byte length value (which is stated in the variable "port" - also known as the Broadcast ID) :
However, with above command, the annepro2 keyboard is always broadcasting the "ID 0" whatever we change the Broadcast ID to any value.
The problem is that the eleventh byte of the command is actually for describing the Broadcast ID, that's why the exiting code is always broadcasting the "ID 0" which makes the keyboard unable to pair with other devices with ID 1-3.
To resolve the problem, we can just simply modify the command to:
The bluetooth connection command has the same issue, so the fix has also covered that issue in this Push Request.
Types of Changes
Issues Fixed or Closed by This PR
Checklist