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

Scan / Connection Request

Team,

I received the following customer inquiry and hope you can help:

The BLE – WiFi bridge project I’m working on will need to control up to 64 nodes, not concurrently though. So I built the system to have a message queue from the server and if a message is pending for a node, when it sees an advertisement from the node, I stop the scanning service, and call sd_ble_gap_connect. When this is called, and I’m waiting for the connection, of course, I don’t receive any advertisements until I start the scanner service again.

Do I need to cancel the connection request before I can start scanning again? I want to allow time for the connection to take place, but I don’t want to miss too many advertisements from the other nodes.

I’ve thought about using the white list feature, and when an advert comes in for a device I want to connect to, then setting the white list, but I assume I would need to stop and start the scanning service to update the white list, is this accurate? Would this be a better approach? I only have a few hundred milliseconds to send out the connection request, so am trying to avoid any latency.

Team...any feedback/guidance you can share is appreciated.  Thanks.

Gene

Parents
  • Hi Gene,

    So you simply call sd_ble_gap_scan_start() to start receiving advertisement reports. Once you want to connect to a specific peer based on the received advertisment report you call sd_ble_gap_connect(). For both api calls you define a set of parameters, one is the timeout:

    uint16_t              timeout;                    /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */

    On BLE_GAP_EVT_TIMEOUT or BLE_GAP_EVT_CONNECTED, you need to call sd_ble_gap_scan_start() again.

    If you know the advertisement interval, then you can time the call to the sd_ble_gap_connect(), such that if the advertisment interval is 100ms, then possible wait 95ms before calling sd_ble_gap_connect() with a 20ms timeout. It's not possible with accurate timing, since the BLE spec mandate a 10ms random delay on the advertisment intervals.

    Best regards,
    Kenneth

Reply
  • Hi Gene,

    So you simply call sd_ble_gap_scan_start() to start receiving advertisement reports. Once you want to connect to a specific peer based on the received advertisment report you call sd_ble_gap_connect(). For both api calls you define a set of parameters, one is the timeout:

    uint16_t              timeout;                    /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */

    On BLE_GAP_EVT_TIMEOUT or BLE_GAP_EVT_CONNECTED, you need to call sd_ble_gap_scan_start() again.

    If you know the advertisement interval, then you can time the call to the sd_ble_gap_connect(), such that if the advertisment interval is 100ms, then possible wait 95ms before calling sd_ble_gap_connect() with a 20ms timeout. It's not possible with accurate timing, since the BLE spec mandate a 10ms random delay on the advertisment intervals.

    Best regards,
    Kenneth

Children
No Data
Related