nRF51822 as hid keyboard: how to pair/bond to multiple devices (smartphones)

Hello,
I'm modifying the ble_peripheral/ble_app_hids_keyboard example on a custom board. When I pair my board with the first phone, it works fine.

APP:INFO:Timer tick
APP:INFO:Uart IN: AT+PSWD=001234
APP:INFO:Uart OUT: C_OK
APP:INFO:Uart IN: AT+BOND
APP:INFO:Uart OUT: C_OK
APP:INFO:Stop advertising
APP:INFO:Timer tick
APP:INFO:Timer tick
APP:INFO:Restart advertising without whitelist
APP:INFO:BLE_ADV_EVT_FAST
APP:INFO:Timer tick
APP:INFO:Timer tick
APP:INFO:Connected to 4B.03.1E.BE.35.4B
APP:INFO:Timer tick
APP:INFO:GAP sec passkey display.
APP:INFO:Passkey: 001234
APP:INFO:Timer tick
APP:INFO:Timer tick
APP:INFO:Connection secured. Role: 1. conn_handle: 0, Procedure: 1
APP:INFO:New Bond, add the peer to the whitelist if possible
APP:INFO:       m_whitelist_peer_cnt 1, MAX_PEERS_WLIST 8
APP:INFO:Uart OUT: PAIRED:0000
APP:INFO:Timer tick
APP:INFO:Timer tick
APP:INFO:Disconnected
APP:INFO:BLE_ADV_EVT_FAST_WHITELIST
APP:INFO:Stop advertising
APP:INFO:Timer tick

But I can pair it with a second phone only if I turn off the bluetooth on the first one otherwise it will connect to the first phone that I paired earlier. How I could prevent that?

APP:INFO:Uart IN: AT+PSWD=001234
APP:INFO:Uart OUT: C_OK
APP:INFO:Uart IN: AT+BOND
APP:INFO:Uart OUT: C_OK
APP:INFO:Stop advertising
APP:INFO:Timer tick
APP:INFO:Timer tick
APP:INFO:Restart advertising without whitelist
APP:INFO:BLE_ADV_EVT_FAST_WHITELIST
APP:INFO:BLE_ADV_EVT_FAST
APP:INFO:Timer tick
APP:INFO:Connected to a previously bonded device.
APP:INFO:Connected to 4B.03.1E.BE.35.4B
APP:INFO:Connection secured. Role: 1. conn_handle: 0, Procedure: 0
APP:INFO:Disconnected
APP:INFO:BLE_ADV_EVT_FAST_WHITELIST
APP:INFO:Stop advertising
APP:INFO:Timer tick

Parents
  • HI,

    BLE_ADV_EVT_FAST starts fast advertising mode. After the connection is established, current peer is added to the whitelist and fast advertising mode using the whitelist is started with BLE_ADV_EVT_FAST_WHITELIST. The purpose of the whitelist is to enable devices to only receive advertising requests from devices listed in the whitelist.

    There are potentially two reasons for your problem - number of allowed connection and whitelist.

    Depending on the application, keyboard might be expected to have one active connection. In that case, one active connection would prevent other connection advertisements. An application would need to accept at least 2 connections in your case.

    When you try to establish a connection with the second device, advertising with a whitelist is active and this prevents the connection to the second phone. You could either try to scan without whitelist and add second device to the whitelist when it is connected, or you could consider turning off the whitelist completely. 

    Best regards,

    Dejan

Reply
  • HI,

    BLE_ADV_EVT_FAST starts fast advertising mode. After the connection is established, current peer is added to the whitelist and fast advertising mode using the whitelist is started with BLE_ADV_EVT_FAST_WHITELIST. The purpose of the whitelist is to enable devices to only receive advertising requests from devices listed in the whitelist.

    There are potentially two reasons for your problem - number of allowed connection and whitelist.

    Depending on the application, keyboard might be expected to have one active connection. In that case, one active connection would prevent other connection advertisements. An application would need to accept at least 2 connections in your case.

    When you try to establish a connection with the second device, advertising with a whitelist is active and this prevents the connection to the second phone. You could either try to scan without whitelist and add second device to the whitelist when it is connected, or you could consider turning off the whitelist completely. 

    Best regards,

    Dejan

Children
No Data
Related