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

Two centrals both scanning

I have two nRF52832 side by side scanning for advertisement with filter by name. Because I will have a number of peripherals advertising, so I want to have multiple centrals to serve them. I notice both centrals will connect to the same device, and one connection eventually timeouts and one connection succeeds. The one that fails take a little longer like 500 to 600 msec to connect, while the good one take 20 to 30 msec to connect. How can I make a earlier detection it is not a real connection so that it can scan for the next peripheral?

Bad one:

[01:51:46.648,925] <debug> ble_scan: Scanning
[01:51:46.690,917] <debug> ble_scan: Connecting
[01:51:46.690,917] <debug> ble_scan: Connection status: 0
[01:51:47.326,171] <debug> nrf_ble_gatt: on_connected_evt
[01:51:47.326,171] <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

Good one:

[01:51:30.124,023] <debug> ble_scan: Scanning
[01:51:46.173,828] <debug> ble_scan: Connecting
[01:51:46.173,828] <debug> ble_scan: Connection status: 0
[01:51:46.197,265] <debug> nrf_ble_gatt: on_connected_evt
[01:51:46.197,265] <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.

Thanks.

Parents
  • If a connection request is sent from the central, then the central will try 6 connection intervals before giving up (;connection failed to establish), so you can for instance set the initial (minimum) connection interval to something shorter than 80-100ms? When trying to connect to a peripheral, it may also be good to set a reasonable timeout value (e.g. 1-2seconds), in case the peripheral is no longer in range or turned OFF. Both these parameters are set when calling sd_ble_gap_connect().

    Best regards,
    Kenneth

  • Hi Kenneth,

    It looks like the sd_ble_gap_connect() takes the parameters from sdk_config.h.
    #define NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL 7.5
    #define NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL 30
    #define NRF_BLE_SCAN_SLAVE_LATENCY 0
    #define NRF_BLE_SCAN_SUPERVISION_TIMEOUT 2000
    They are already very small values, if I reduce them to smaller value, the firmware will halt.

    You mentioned the 6 connection intervals, is it a parameter I can change? 

    My issue is the stack reports it is connected, but it may not really be. Is there a reliable way to detect the connection is really made after the SCAN REQUEST?

    Thanks.

  • My issue is the stack reports it is connected, but it may not really be

    My suggestion would avoid you getting into that situation at all.

Reply Children
Related