This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Avoid automatic connection

I am currently developing a device and would like the default behavior at boot to be:

1. Boot up

2. The device should start advertising for non-bonded devices.

3. When there is a certain physical interaction of the user with the device, the device should try to connect with any previously bonded device already on the white list.

4. When the host device disconnects, the device should return to state 2.

I have been trying to achieve that with the GAP advertising configuration without any real success. Is it even possible to achieve this behavior? How could it be implemented?

  • Hi Enrique, 

    2. The device should start advertising for non-bonded devices.

     You can either do directed advertisment( advertising to devices addresses in a whitelist) or undirected advertisment, advertise to all devices in range. In the latter case both bonded and unbonded device will be able to scan for the advertisment packet. It is not possible to advertise to unbonded peers exclusivly. 

    3. When there is a certain physical interaction of the user with the device, the device should try to connect with any previously bonded device already on the white list.

     Yes, you can use the physical interaction to configure the advertisement module in our SDK to start advertising using a whitelist which consists of the peers that it has bonded with. 

     You start advertising with the whitelist by calling ble_advertising_start with the advertising_mode parameter set to either: BLE_ADV_EVT_FAST_WHITELIST or BLE_ADV_EVT_SLOW_WHITELIST

    4. When the host device disconnects, the device should return to state 2.

     Call  ble_advertising_restart_without_whitelist() when you receive the BLE_GAP_EVT_DISCONNECTED event. 

    I recommend that you take a look at the ble_app_hids_keyboard example in our SDK. 

    Best regards

    Bjørn

Related