HID over ble on central device

Hey,

I saw the example in the SDK for hid keyboard over ble but it is only as a peripheral device.

In my project I have the nordic board as a central device connecting to an android and communicating via uart over ble.

I also want the nordic board to be able to send the android HID keys and to be able to write using this flow "HELLO WORLD" on the android.

The problem is I must have the android discover my board's gatt to be able to send the HID key. Is there any way to do this?

I tried advertising the board first and connecting the android as the central, then disconnecting and start advertising the android and connect the board as the central.

this doesn't raise any errors but does not result in seeing anything written on the android.

Can anyone give me a better clue on what I am missing?

Thanks,

Robbie

Parents
  • Update:
    I realize now that the scenario I gave is not totally full:
    "I tried advertising the board first and connecting the android as the central, then disconnecting and start advertising the android and connect the board as the central. this doesn't raise any errors but does not result in seeing anything written on the android."
    This is true until I reset the android, then I get an error indicating I don't have the CCCD of the connection handle's HID.

Reply
  • Update:
    I realize now that the scenario I gave is not totally full:
    "I tried advertising the board first and connecting the android as the central, then disconnecting and start advertising the android and connect the board as the central. this doesn't raise any errors but does not result in seeing anything written on the android."
    This is true until I reset the android, then I get an error indicating I don't have the CCCD of the connection handle's HID.

Children
  • Hi,

    Typically the HID device is the peripheral, I don't know how well different phones will handle the opposite. It could be that it somehow identifies your device differently when the role changes(peripheral->central), or that the role change makes it so that the CCCD are not loaded.

    Why just not keep the nRF5 device as the peripheral?

  • This project requires the nRF to be the central, I can't change the role. It needs to maintain multiple connections that each one uses the hid.
    I agree that the role change makes it that the CCCD are not loaded. Is there any API I can call on the nRF to make the phone discover thr nRF's services (this will give me the hid CCCD)?

  • RobbLev said:
    It needs to maintain multiple connections that each one uses the hid.

    Could you explain the use-case some more? The nRF52 connects to multiple phones? And sends keypress to all the phones at the same time?

    Why does it have to be the central?

    PS: SoftDevice S140 supports in total 20 concurrent links with freely selectable role (Central/Peripheral).  That means that you can have e.g 10 Central and 10 Peripheral links at the same time.

    RobbLev said:
    Is there any API I can call on the nRF to make the phone discover thr nRF's services (this will give me the hid CCCD)?

    Not sure if it will solve the CCCD issue, but service changed indication is used to inform the other device to do a new service discovery. You can try calling pm_local_database_has_changed() when the device connects, and see if that helps.

Related