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

about BLE_HIDS_EVT_NOTIF_ENABLED

Hi Nordic team,

I have a simple HID BLE device which send volume+/- multimedia keys to a Android device, it works well if it is first time to pair with the Android device, but if I switch off Bluetooth in Android's setting menu and switch on again, the volume+/- keys no longer working.

I checked and debugged and found it is caused by the BLE device not getting the BLE_HIDS_EVT_NOTIF_ENABLED from the Android phone, so the HVX return code is 0x8 and failed. I also search the forum and found there's no way to enable the notify on peripheral side, I also found there're solutions is to call "sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0)", but I'm not sure where to put this function, I have tried that function in "BLE_GAP_EVT_CONNECTED", "BLE_GATTS_EVT_SYS_ATTR_MISSING" events but none of them works.

Any suggestion where am I doing wrong and how to fix this to enable the notify? Thanks very much..

added main.c here: main.c

  • Hi,

    it looks like the Android only connect the HID keyboard when re-connect, because the phone shows the device is connected. But the BLE device in ignored, but as i said, if it is the first time pairing, then i can see the BLE_GAP_EVT_CONNECTED event, but not in re-connect. However, i did see "DM_EVT_CONNECTION" event, just missing the "BLE_GAP_EVT_CONNECTED".

    Why is that and where should i start to debug why the BLE is not connected? Any suggestion?

    Thanks,

  • Hi Anders,

    I rewire the whole project based on ble_app_hid_keyboard and upload the main.c in the first post and do the test again, when BLE keyboard first pair with Android, works fine, when switch off the Bluetooth in Android, BLE disconnected and save the Service context successfully. the problem comes when i switch Bluetooth on again, BLE keyboard re-connected with Android and calls the calling sd_ble_gatts_sys_attr_set function, and got a error code of 0xb(NRF_ERROR_INVALID_DATA), and the second call of sd_ble_gatts_sys_attr_set also same error(0xb).

    One thing to mention, i did see "BLE_GAP_EVT_CONNECTED" this time after re-write the whole project, but still failed on function of sd_ble_gatts_sys_attr_set, is this the reason why my BLE not working after re-connect? This time i got 0x3401 instead of 0x8 error code.

    then i tested with iPhone, it also call sd_ble_gatts_sys_attr_get when disconnect and calls sd_ble_gatts_sys_attr_set when re-connect, the only difference is sd_ble_gatts_sys_attr_set is succeed and BLE keyboard is working after re-connect.

    Any suggestion why cause such result?

    Thanks,

  • Can you try a unchanged HID example from the SDK, and see how that works? Remember to clear the device from the android phone, and also do a full flash erase on the nRF device before testing

  • Hi,

    If clear the device in Android's Bluetooth device list, then there's no problem because Android will issue a "pairing" request, which will enable the notify, this will work, but it is not possible to ask end user do the pairing each time when he using the BLE.

    I tested the unchanged sample of ble_app_hid_keyboard, it works, you can check my main.c, i only change sending "hello" to sending a "volume +" key, but just not working and couldn't find why.

    can you tell me how to erase the whole flash?

    Thanks,

  • Hi. To be clear: Is the following working with the unchanged example?

    1. Connect ( and pair) with the phone. (first connection)
    2. Turn bluetooth off->on on the phone
    3. Successfully reconnect and receive hid commands?

    You can erase the flash by either using nRFgo studio or nRFjprog (command line tools). See part 3 of this guide.

Related