qmk_firmware icon indicating copy to clipboard operation
qmk_firmware copied to clipboard

[Bug] Bluetooth not working on Apple devices

Open jakallergis opened this issue 3 years ago • 1 comments

Describe the Bug

I don't know if this is specific to apple devices or bluetooth in general, I didn't test on Windows/Linux or android devices.

I am using the flow as described in the documentation and everything works just fine. However, when I try to connect via bluetooth it doesn't work unless I forget the keyboard from the device's bluetooth connections list, then press FN2+[1-4] and then press connect on the apple device when I see it show up in the list. I can even continue and connect the rest of the bluetooth devices and switch between them just fine, but if I switch the keyboard off and on again, then it immediately connects (or at least that's what it looks like on the apple device) but you cannot type anything. You have to forget the device, restart the keyboard, and connect from scratch.

I thought that it might be something with the BLE firmware that doesn't change (I think) when you flash this firmware. Like, maybe the version of the installed BLE firmware has some incompatibilities with the version developers where using when creating the QMK port. So I tried this flow multiple times by first flashing a different firmware upgrade from the ObinsKit app.

So what I did was this:

  • enter DFU mode
  • open the keyboard in ObinsKit
  • select a firmware version and hit upgrade
  • enter DFU mode again after the keyboard boots up
  • flash the custom QMK Firmware in the keyboard using the annepro2_tools
  • flash the shine firmware in the keyboard using the annepro2_tools
  • check that it works with USB (this always works perfectly fine 💪)
  • check that it connects via bluetooth and works properly
  • it didn't work properly

👆 and I did this with every single firmware version available for flashing in the ObinsKit app

Thank you in advance

System Information

  • Keyboard:
    • Revision (if applicable): C18
  • Operating system: OSX Monterey 12.0.1
  • AVR GCC version: avr-gcc (Homebrew AVR GCC 8.4.0_2) 8.4.0
  • ARM GCC version: arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
  • QMK Firmware version: No names found, cannot describe anything
  • Any keyboard related software installed?
    • [ ] AutoHotKey
    • [ ] Karabiner
    • [x] Other: ObinsKit

Additional Context

Please note that this is not a fault of the keyboard, or at least it doesn't make sense for it to be, because this works perfectly fine with ObinsKit.

Tried to dig into the project a little bit and try to locate the problem in the code, but I couldn't find anything specific. However, seeing the code around the BLE module, it seems like the FN2+[1-4] keys start a broadcast but then it's not clear how and when it goes into pairing mode. For example, in the stock firmware, if you press FN2+1 for a few seconds it will go into pairing mode for that BLE slot. How would that be done with this project? Although, even if that feature is indeed missing I don't think that's the main issue here. It looks more like a problem with persisting the state of the BLE module

jakallergis avatar Dec 05 '21 12:12 jakallergis

I understand this bug exists for a while now, but really don't know where to go about fixing it. The main problem comes from that the BT firmware is closed source and the chip itself doesn't have a whole lot of technical documentation either. So reversing the firmware is going to be non trivial as well. Generally we don't understand how the BT chip actually works so we implemented the protocol by guessing / cross verifying with what the official firmware does.

Codetector1374 avatar Dec 05 '21 17:12 Codetector1374