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

S130 Permanent Advertising & Scanning during operation

Hi!

We're running a S130 Stack to act as both Peripheral & Central at the same time. Everything is working fine but i i'm not quite sure about best approach for handling permanent scanning & advertising at the same time.

The question is: After which BLE-Events do i have to restart scanning / advertising? (With scan / adv timeout = 0 and scan/adv timeout != 0).

E.g. Do i have to start scanning/adv after connection established? Do i have to start scanning/adv after data written? Do i have to start scanning/adv after disconnect event?

Would be cool to get some exact response here as i cannot find this in the docs.

... And: is there a possibility to ask the stack whether scanning or advertising is currently active?

greetings, Michael

Parents
  • FormerMember
    0 FormerMember

    The question is: After which BLE-Events do i have to restart scanning / advertising? (With scan / adv timeout = 0 and scan/adv timeout != 0).

    E.g. Do i have to start scanning/adv after connection established? Do i have to start scanning/adv after data written? Do i have to start scanning/adv after disconnect event?

    Advertiser: When a device is advertising connectable advertising, the device will stop advertising when a connection has been initiated by a peer device, meaning that it receives a connect request. The application will be notified the a connection has been initiated when receiving the BLE_GAP_EVT_CONNECTED event. The below figure explains what happens when a connectable advertiser receives a connection request.

    If you want the device to continue to advertise non-connectable advertising after the connection has been established, advertising has to be started manually.

    If the advertiser has a timeout, the application will receive the event BLE_GAP_EVT_TIMEOUT, see this message sequence chart.

    image description

    The device will not automatically (re-)start advertising after disconnecting. If the device should start advertising after a disconnect, advertising has to be started manually.

    Scanner: Similar to the advertiser, a scanner will stop scanning after having initiated a connection. If the scanner wants to continue scanning after a connection has been initiated, it has to be started manually. The ble_app_multilink_central example in the SDK does that.

    If scanning times out, the application will receive a BLE_GAP_EVT_TIMEOUT{BLE_GAP_TIMEOUT_SRC_SCAN} event, see this message sequence chart.

    Scanning and disconnection of a link are independent* operations, it is no problem to scan and have multiple links at the same time.

    *Scanning and disconnection of a link are independent as long as the number of links and roles are not maximized. S130/S132 v.2.0.x supports up to eight links concurrently along with either scanner or broadcaster.

    ... And: is there a possibility to ask the stack whether scanning or advertising is currently active?

    There is no function for asking the stack if it is scanning/advertising or not. However, since scanning and advertising have to be started manually and since they will only stop scanning/advertising on known cases, two variables, is_scanning and is_advertising, can for example easily keep track of the advertising/scanning state.

    Advertising and scanning can stop in the following cases:

    • Connected (BLE_GAP_EVT_CONNECTED)
    • Manually calling sd_ble_gap_adv_stop()/sd_ble_gap_scan_stop()
    • Timeout: BLE_GAP_EVT_TIMEOUT occurs

    If you plan to combine multiple roles for the device in your application, I would recommend you to take a look at the scheduling chapter in the S130 softdevice specification.

Reply
  • FormerMember
    0 FormerMember

    The question is: After which BLE-Events do i have to restart scanning / advertising? (With scan / adv timeout = 0 and scan/adv timeout != 0).

    E.g. Do i have to start scanning/adv after connection established? Do i have to start scanning/adv after data written? Do i have to start scanning/adv after disconnect event?

    Advertiser: When a device is advertising connectable advertising, the device will stop advertising when a connection has been initiated by a peer device, meaning that it receives a connect request. The application will be notified the a connection has been initiated when receiving the BLE_GAP_EVT_CONNECTED event. The below figure explains what happens when a connectable advertiser receives a connection request.

    If you want the device to continue to advertise non-connectable advertising after the connection has been established, advertising has to be started manually.

    If the advertiser has a timeout, the application will receive the event BLE_GAP_EVT_TIMEOUT, see this message sequence chart.

    image description

    The device will not automatically (re-)start advertising after disconnecting. If the device should start advertising after a disconnect, advertising has to be started manually.

    Scanner: Similar to the advertiser, a scanner will stop scanning after having initiated a connection. If the scanner wants to continue scanning after a connection has been initiated, it has to be started manually. The ble_app_multilink_central example in the SDK does that.

    If scanning times out, the application will receive a BLE_GAP_EVT_TIMEOUT{BLE_GAP_TIMEOUT_SRC_SCAN} event, see this message sequence chart.

    Scanning and disconnection of a link are independent* operations, it is no problem to scan and have multiple links at the same time.

    *Scanning and disconnection of a link are independent as long as the number of links and roles are not maximized. S130/S132 v.2.0.x supports up to eight links concurrently along with either scanner or broadcaster.

    ... And: is there a possibility to ask the stack whether scanning or advertising is currently active?

    There is no function for asking the stack if it is scanning/advertising or not. However, since scanning and advertising have to be started manually and since they will only stop scanning/advertising on known cases, two variables, is_scanning and is_advertising, can for example easily keep track of the advertising/scanning state.

    Advertising and scanning can stop in the following cases:

    • Connected (BLE_GAP_EVT_CONNECTED)
    • Manually calling sd_ble_gap_adv_stop()/sd_ble_gap_scan_stop()
    • Timeout: BLE_GAP_EVT_TIMEOUT occurs

    If you plan to combine multiple roles for the device in your application, I would recommend you to take a look at the scheduling chapter in the S130 softdevice specification.

Children
Related