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

Block peripheral connection after BLE_GAP_EVT_SCAN_REQ_REPORT

Hello, I use nrf51 based device as peripheral with SD110.
I use connectable advertising (BLE_GAP_ADV_TYPE_ADV_IND, BLE_GAP_ADV_FP_ANY) and turned on BLE_GAP_EVT_SCAN_REQ_REPORT s to be able to see addesses of scanning centrals.

The question is: How can peripheral block central with address X (received from scan report) from further connection request?

P.S. May be sd_ble_gap_connect_cancel() could be used but how and where?

  • You can't block it - if you are advertising connectably with no whitelist than anyone who sees you can connect to you if they want to, and they don't even need to scan you first either so you don't have any guarantee you will see an address in a scan report before the central tries to connect to you, so your filtering method doesn't really work. And you can't stop advertising to try and block them, they may well already have started connecting by the time you do that.

    All you can do is wait until they connect to you and then close the connection using sd_ble_gap_disconnect(). And sd_ble_gap_connect_cance() is not the function for it, that's the one for cancelling a connection you initiate.

  • Thank you, RK, Now it's clear for me with blocking. But how can I initiate connection in S110 softdevice?

  • You can't - the S110 is peripheral-only - the documentation however lists all the GAP functions there happen to be, but if they are not supported on the softdevice you're using, in this case S110, you'll get INVALID_STATE trying to use them.

    If you're advertising connectably, you can't stop things connecting to you, although you can feed them very little information beyond the public GATT table and then disconnect them. Bluetooth is friendly like that.

Related