This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't read characteristics of BLE HID service example

I'm trying to implement the HID service on a custom nrf52832 board, unfortunately I'm running into problems.

Here's what happens: Advertising, connecting to the board, service discovery, GPIOs (buttons & LEDs), reading the battery level, etc. all work great. I use nRF Connect to test this. However when trying to read HID characteristics (except for the protocol mode), the operation never finishes (the spinner keeps spinning). The log does not show any errors or other entries, except for the battery service updates that keep coming in. When I hit disconnect the spinner stops and the device is discoverable again.

The same happens when I use the "enable all services" menu item like described in the example. The HID device also doesn't produce any input in Android, even when connecting through settings and enabling "use for input device").

At first I suspected problems in my code, but now I'm running the unmodified examples (with -DBOARD_CUSTOM though) and have the exact same issue. I tried both the HID mouse and keyboard example. I'm using version 12.2 of the nRF5 SDK, though I'm getting the same result with 12.0.

Any ideas what's going wrong? I'd also appreciate any hints on how to further debug this.

  • FormerMember
    0 FormerMember

    When I test here, the HID example, ble_app_hids_keyboard (SDK 12.2.0, S132, v3.0.0), works fine. I don't see the behavior that you describe. Could you try the same hex file as I am using, and check if that hex file results in the same problem on your side: ble_app_hids_keyboard.hex (the hex file uses external LFCLK crystal as LFCLK clock source)

    Update 06.02.2017:

    After a closer look at the keyboard example, I see that the scheduler is only being used for the simulated battery measurement updates..

    I now think I understand what you mean. I re-tested: I connected my phone to the advertising keyboard using nRF Connect. When I then enabled the "report" characteristics, there was a disconnect. Looking at the log in nRF Connect, the disconnect occured due to a "Blueooth priviledged" permission. From this blog post, chapter 4.6, it happened because HID is in-built in Android naively.

    Therefore, please try the following: Connect to the keyboard device from the Bluetooth setting in the Settings menu on the phone. At the top bar on the phone there will be instructions on how to proceed (connect properly).

    To test that the keyboard is working (using a nRF52-DK), put the phone cursor in a search window, press button 1, and see that 'hello' will be written.

  • Hey, thanks a lot for you effort. Unfortunately I still have the same problem (e.g. reading 0x2A4B report map). I flashed the file with nrfjprog --program ~/Downloads/ble_app_hids_keyboard.hex -f nrf52 --sectorerase and it advertises as K_KEYBOARD now. I also tried a full erase first and then reflashed the softdevice and hex file afterwards with the same result. There is a 32.768kHz crystal on my board.

  • While this points to a hardware problem, I really have a hard time imagining what it could be. Especially since only the HID service makes problems, the battery service, device information service, etc. all work flawless. I disabled the external LFCLK in my sdk_config.h, but it doesn't help. I'd be happy to show my schematic (via mail or so), but there's not much to it except for a Fanstel BT832 module, external crystal and some buttons/LEDs.

    Also some quick questions, is the scheduler needed to use the HID service? And is there a good place to report bugs/problems with the SDK?

  • FormerMember
    0 FormerMember in reply to FormerMember

    Okay, so at least the problem is not related to the firmware on the nRF52. If I understand correctly, it is service discovery that is failing (spinning). Which Android version and device are you using for the testing?

    Unfortunately, we don't have a "formal" way of reporting bugs in the SDK. The best way is to post it here on devzone, someone from Nordic will pick it up here, and when it is a confirmed bug, it can be put on this list.

    I see that the scheduler is being used in the ble_app_hids_keyboard example, so I guess there is a reason why it's there. You can try to remove it, and check how the example behave, if it changes anything.

  • Okay, so maybe you could have a look at components/libraries/util/app_error.h, the app_error_log function has all the NRF_LOG calls commented out, clearly by mistake. Looks like some debug work has made it into the release. It's in both the 12.2 and 12.0 SDK.

Related