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

[S120] Send scan request to particular peripherals

Using,

  • IAR EWARM 7.20

  • PCA10001 V 2.0.0 (Changed the MCU to QFAAH00 Revision 3)

  • SDK 10.0

  • SoftDevice S120 2.1

  • Example: Multi-link Example (examples\ble_central\ble_app_multilink_peripheral)

/************************************************************/

Hi, I'm quite new to S120 central examples. I mostly worked with S110 examples.

As far as I know, central does passive / active scanning.

I want to implement a central that sends scan request to particular peripherals.

For instance, let's say that there are 3 peripherals (X, Y, and Z) close to the central device.

Also, each peripherals use different services. For instance, X uses NUS, Y uses HID, and Z uses HRS.

All peripherals are advertising so the central gets BLE_GAP_EVT_ADV_REPORT from all three of them.

Since the peripherals use different services, I can distinguish them.

(Of course there are other ways to distinguish each.)

Then, I want the central to send scan request to only X.

I don't want the central to send scan request niether to Y nor Z.

Is this possible? What part should I modify?

It's like I want to make X that the scanner has scanned X and

I don't want Y and Z to know that they were scanned.

-Regards, Mango

Parents
  • FormerMember
    0 FormerMember

    In order to not send a scan request to any peripheral, you have to use the selective scanning option in m_scan_param. When setting selective scanning, the scanner needs a whitelist of device addresses towards which it should transmit scan requests.

    I guess the ideal option for you would be to use selective scanning based on UUIDs, but unfortunately, that is not an option.

    One way to "get around" adding multiple devices to the whitelist is to set the address in all the peripheral devices to the same address. And then, add that address to the whitelist. You can set the address of the peripheral devices using sd_ble_gap_address_set(..).

    Update 02.03.16: This tutorial in the section "Setting up and start advertising with our Softdevice --> Example code" shows how to add a device address to a whitelist for advertising. However, the way to add a device to a whitlist for scanning is exactly the same.

    I have attached a scanning example that shows how to add a device to a whitelist, and then perform active selective scanning: ble_app_hrs_c_filter_active_scanning.zip The example is a modifed version of ble_app_hrs_c, and was made with SDK 11.0.0-2.alpha. The example should be placed in the following folder: ..\nRF5_SDK_11.0.0-2.alpha_bc3f6a0\examples\ble_central

    0)

    Active scanning: Scanning device sends scan requests to advertisers of type "connectable unidirected" or "scannable unidirected (non-connectable device)" based on a potentially set filter policy .

    Selective scanning: Selective scanning is filtered scanning based on a whitelist.

    Active selective scanning: Active scanning scanning based on a filter policy (whitelist).

    1) Yes, if you plan to implement bonding in your application when connecting to a pheripheral and multiple peripheral devices have the same address, the bond information cannot be stored based on both the device address and the IRK. That is the default setting in the device manager.

    2) You can add devices to the scan whitelist manually. For scanning there is no need for an IRK. When bonding, the device stores the encryption information using the devices manager. When pairing, the encryption information is not stored upon a disconnection. Bonding with devices doesn't automatically enables a whitelist.

Reply
  • FormerMember
    0 FormerMember

    In order to not send a scan request to any peripheral, you have to use the selective scanning option in m_scan_param. When setting selective scanning, the scanner needs a whitelist of device addresses towards which it should transmit scan requests.

    I guess the ideal option for you would be to use selective scanning based on UUIDs, but unfortunately, that is not an option.

    One way to "get around" adding multiple devices to the whitelist is to set the address in all the peripheral devices to the same address. And then, add that address to the whitelist. You can set the address of the peripheral devices using sd_ble_gap_address_set(..).

    Update 02.03.16: This tutorial in the section "Setting up and start advertising with our Softdevice --> Example code" shows how to add a device address to a whitelist for advertising. However, the way to add a device to a whitlist for scanning is exactly the same.

    I have attached a scanning example that shows how to add a device to a whitelist, and then perform active selective scanning: ble_app_hrs_c_filter_active_scanning.zip The example is a modifed version of ble_app_hrs_c, and was made with SDK 11.0.0-2.alpha. The example should be placed in the following folder: ..\nRF5_SDK_11.0.0-2.alpha_bc3f6a0\examples\ble_central

    0)

    Active scanning: Scanning device sends scan requests to advertisers of type "connectable unidirected" or "scannable unidirected (non-connectable device)" based on a potentially set filter policy .

    Selective scanning: Selective scanning is filtered scanning based on a whitelist.

    Active selective scanning: Active scanning scanning based on a filter policy (whitelist).

    1) Yes, if you plan to implement bonding in your application when connecting to a pheripheral and multiple peripheral devices have the same address, the bond information cannot be stored based on both the device address and the IRK. That is the default setting in the device manager.

    2) You can add devices to the scan whitelist manually. For scanning there is no need for an IRK. When bonding, the device stores the encryption information using the devices manager. When pairing, the encryption information is not stored upon a disconnection. Bonding with devices doesn't automatically enables a whitelist.

Children
  • This time, suppose peripherals X,Y, and Z's addresses are set to FF:EE:DD:CC:BB:AA and they use only NUS.

    1. Is selective scanning meaning passive scanning? Also, I should set my central device to do selective scanning, do I?

    2. I'm not getting the meaning of not using encryption. Since the peripherals only use NUS,

    after pairing, both central and connected peripherals are not using encryption, are they?

    Is this something about pairing and bonding?

    1. When adding device at the whitelist, I thought the IRK of the peripheral was required.

    I thought only bonded peripherals were added.

    When pairing, does the central calls device manager related handlers to add it to the whitelist?

    I might have known some completely incorrect. So feel free to point out the wrong ideas I have, please.

  • FormerMember
    0 FormerMember in reply to FormerMember

    I have updated my answer to answer your questions. I was a little wrong is shouldn't be any problem to use encryption. The device manager stores by default the IRK for each device.

Related