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

hid ble keyboard pairing to a specific device

hi,

we're using a Adafruit nrf52832 board for a building a ble keyboard . w're able to pair to two central devices and appear to them as a keyboard , but for example : we can pair to a smartphone and a desktop pc at the same time as a hid keyboard , but we're noticing that the hid outputs goes to one of them which is the smartphone !

we also have another service beside the hid keyboard , and we want to only output the hid to the other device, not the smartphone where the app that interact with the that service is installed !

is there any parameter to set for that ?  

or any work around to manage that pairing ?

best regards,

Abdelali

Parents
  • Hi,

    The questions are not clear to me.

    we're using a Adafruit nrf52832 board for a building a ble keyboard . w're able to pair to two central devices and appear to them as a keyboard , but for example : we can pair to a smartphone and a desktop pc at the same time as a hid keyboard , but we're noticing that the hid outputs goes to one of them which is the smartphone !

    There is no practical limit to how many devices you cand bond with (provided you have enough flash). Is the problem here that you would also want to be connected to multiple devices simultaneously? If so, that is possible, but it does seem a bit strange for a keyboard. Or is the problem that the nRF is not connected to the device you want, and you want a method to select which device the nRF should accept connection from? Please elaborate.

    we also have another service beside the hid keyboard , and we want to only output the hid to the other device, not the smartphone where the app that interact with the that service is installed !

    Again, is the case here that you want multiple concurrent connections and a different set of services on the different connections? Or do you just want a single connection and adapt the services depending on what you are connected to? Assuming the latter, there are a few possibilities and problems:

    • How will you know what type of device you are connected to?
    • The SoftDevice API only allows adding more services, not removing any.
      • This means that you cannot remove/hide a service (HID) once it has been added.
      • However, you can add services only after deciding that the connected peer will use it. If you do, then you also need to use service changed to trigger a new service discovery, so that the peer's GATT client will know about the new services. So this is possible, not very clean.

    As well as explaining in more detail what you want to do, I am also interested in knowing why, since this seems a bit unorthodox.

  • hi Einar,

    thanks for your reply !

    ok , what we want to be able to do: is first to build a keyboard over ble, based on the nrf52832 , and add other services to. these services will be used by a phone application . and we want the nrf52832 to be paired to two devices , the first is the phone where the application is installed , and the other one is the device that we want to output the keyboard HID to !

    we've tried that, but seems the keyboard HID outputs goes only to the phone, not even to the other device we want to!

    our concerns here are :

    - is it possible , like we can manage which device the HID keyboard service be outputs to ? cause it shows in both (phone , and the other device (eg. desktop) ) as HID keyboard , but the phone gets the HID outputs , not the desktop ( the other device) !

    best regards,

    Abdelali

  • Hi,

    abdelali said:
    ok , what we want to be able to do: is first to build a keyboard over ble, based on the nrf52832 , and add other services to. these services will be used by a phone application . and we want the nrf52832 to be paired to two devices , the first is the phone where the application is installed , and the other one is the device that we want to output the keyboard HID to !

    I see. So, you want to be simultaneously connected to two devices (not only paired with them simultaneously). That part is no problem. 

    abdelali said:
    we've tried that, but seems the keyboard HID outputs goes only to the phone, not even to the other device we want to!

    What did you try?

    abdelali said:
    - is it possible , like we can manage which device the HID keyboard service be outputs to ? cause it shows in both (phone , and the other device (eg. desktop) ) as HID keyboard , but the phone gets the HID outputs , not the desktop ( the other device) !

    Yes, sort of. If that is OK, the simplest is to make all services available to all connected peers. But you have a connection handle for each connection, so you can select on which connection you should send the HID data. The SDK does not include a multi-peripheral HID example, but you can refer to the Experimental: BLE Multiperipheral Application to see how it can be done.

    For this approach, you will also need a method to indicate connection is what. So you could for instance send HID data by default, but use your custom app on the phone to write to a characteristic that indicates that it should not receive HID events (or similar).

    Exactly how you do it is up to you, but this is an outline of one possible way to implement it.

Reply
  • Hi,

    abdelali said:
    ok , what we want to be able to do: is first to build a keyboard over ble, based on the nrf52832 , and add other services to. these services will be used by a phone application . and we want the nrf52832 to be paired to two devices , the first is the phone where the application is installed , and the other one is the device that we want to output the keyboard HID to !

    I see. So, you want to be simultaneously connected to two devices (not only paired with them simultaneously). That part is no problem. 

    abdelali said:
    we've tried that, but seems the keyboard HID outputs goes only to the phone, not even to the other device we want to!

    What did you try?

    abdelali said:
    - is it possible , like we can manage which device the HID keyboard service be outputs to ? cause it shows in both (phone , and the other device (eg. desktop) ) as HID keyboard , but the phone gets the HID outputs , not the desktop ( the other device) !

    Yes, sort of. If that is OK, the simplest is to make all services available to all connected peers. But you have a connection handle for each connection, so you can select on which connection you should send the HID data. The SDK does not include a multi-peripheral HID example, but you can refer to the Experimental: BLE Multiperipheral Application to see how it can be done.

    For this approach, you will also need a method to indicate connection is what. So you could for instance send HID data by default, but use your custom app on the phone to write to a characteristic that indicates that it should not receive HID events (or similar).

    Exactly how you do it is up to you, but this is an outline of one possible way to implement it.

Children
No Data
Related