keep getting NRF_ERROR_INVALID_STATE when trying to send key via HID

Hey,

I have an app based on the UART central example. I successfully connect and bond to an android and am able to send data via uart over BLE.

I want to send data also via HID over BLE as demonstrated in the peripherial example of ble_app_hids_keyboard_pca10056_s140.

With the example I connect and bond my android and am able to see "hello" printed in a notebook app.

I merged that example to my app, but in my app after I connect and bond, I always fail while I try sending the key with ble_hids_inp_rep_send() that calls sd_ble_gatts_hvx() that always returns NRF_ERROR_INVALID_STATE error code.

I saw the documentation saying:

 * @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true:

 *                                   - Invalid Connection State
 *                                   - Notifications and/or indications not enabled in the CCCD

 *                                   - An ATT_MTU exchange is ongoing

and because I'm sure connection state is fine I assume it's the CCCD problem but I don't really understand why it happens and how to fix it.

does anyone know hoe I shall proceed?

Thanks,

Robbie

Parents
  • Ok, I understand that this didn't work because my central had only a gap server connection with the android and I needed a gap client connection with the android to send HID keys.

    My new question is do I have to advert from my central device (nordic board) and accept connection from android or can I use my server connection (that the nordic board initiated) to ask android to connect to me as gap client. I will prefer the android app will do the connection with me than have the user press in the bluetooth menu on my advertised device.

Reply
  • Ok, I understand that this didn't work because my central had only a gap server connection with the android and I needed a gap client connection with the android to send HID keys.

    My new question is do I have to advert from my central device (nordic board) and accept connection from android or can I use my server connection (that the nordic board initiated) to ask android to connect to me as gap client. I will prefer the android app will do the connection with me than have the user press in the bluetooth menu on my advertised device.

Children
No Data
Related