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

BLE_GAP_PHY_CODED connect immediate timeout

I'm extending an existing central application to support extended advertisement and CODED phy support.
However, I have trouble connecting to a device advertising with CODED phy.

Development is done on a nRF52840 dev-kit (nRF6828 rev. 0.12.0 2018.10). Final product uses a custom 52840 PCB.
Chip marking QIAACA.
Softdevice 6.1.0
nRF5 SDK v15.2.0

As a reference device I'm using another dev-kit running the ble_app_rscs example application with the following modification:
    init.config.ble_adv_primary_phy      = BLE_GAP_PHY_CODED;
    init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_CODED;
    //init.config.ble_adv_primary_phy      = BLE_GAP_PHY_1MBPS;
    //init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_2MBPS

My application scans with the following settings passed directly to sd_ble_gap_scan_start():

static ble_gap_scan_params_t scanParams = {
  .extended = 1,
  .report_incomplete_evts = 0,
  .active = 0,
  .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
  .scan_phys     = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED,
  .interval = 10*0x0004,
  .window   = 0x0004,
  .timeout = 0,
  .channel_mask = {0x00,0x00,0x00,0x00,0x00},
};

My application initiates connections with the following scan and connect settings passed directly to sd_ble_gap_connect(). Connection establishment is initiated by a higher system layer, hence async. to advertise events.

static ble_gap_scan_params_t connectScanParams = {
  .extended = 1,
  .report_incomplete_evts = 0,
  .active = 0,
  .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
  .scan_phys     = BLE_GAP_PHY_CODED,
  .interval = BLE_GAP_SCAN_INTERVAL_MIN,
  .window   = BLE_GAP_SCAN_WINDOW_MIN,
  .timeout = 0,
  .channel_mask = {0x00,0x00,0x00,0x00,0x00},
};

ble_gap_conn_params_t connectionParams;
connectionParams.min_conn_interval = MSEC_TO_UNITS(7.5, UNIT_1_25_MS);
connectionParams.max_conn_interval = MSEC_TO_UNITS(7.5, UNIT_1_25_MS);
connectionParams.slave_latency = 1;
#define MaxNumberOfMissedConnectEvents_d (20)
connectionParams.conn_sup_timeout = MSEC_TO_UNITS( 300, UNIT_10_MS );
connectScanParams.timeout = 1000; // 10 seconds

I do not initiate any phy negotiation, but I do handle BLE_GAP_EVT_PHY_UPDATE_REQUEST events accepting all common phys.

After adding BLE_GAP_PHY_CODED to the scanParams.scan_phys I receive BLE_GAP_PHY_CODED advertisements indicating connectable.

If initiating a connect using sd_ble_gap_connect() the function returns OK, but I immediately receive an BLE_GAP_EVT_TIMEOUT event with source BLE_GAP_TIMEOUT_SRC_CONN.

1. Do you have any idea why the connect timeout occur - even long before the specified timeout?
2. Looking at the ble_gap.h - ble_gap_adv_params_t documentation is is mentioned that: "primary_phy: "@note The primary_phy shall indicate @ref BLE_GAP_PHY_1MBPS if @ref ble_gap_adv_properties_t::type is not an extended advertising type."". Does this mean that sd_ble_gap_connect() may only be called while handling a BLE_GAP_EVT_ADV_REPORT event?
3. My goal is to do an implementation that is able to automatically connect to devices supporting BLE_GAP_PHY_CODED and/or BLE_GAP_PHY_1MBPS. Do I need to look at the last advertisement seen from a device to specify the correct connect scan_phy parameter, or is it possible to set ble_gap_scan_params_t to "connect using whatever phy is available"?

Parents
  • Hi Kim

    2. Please see this post for a thorough explanation of sd_ble_gap_connect().

    3. If your application is set to BLE_GAP_PHY_AUTO, the SD_BLE_GAP_PHY_UPDATE function will select PHY based on the peer's PHY preferences and the local link configuration. The PHY update procedure will for this case result in a PHY combination that respects the time constraints configured with sd_ble_cfg_set and the current link-layer data length. If the peer doesn't support the PHY Update Procedure, the resulting PHY_UPDATE will have a status set to BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.

    Note that BLE_GAP_PHY_AUTO will also be compatible with the BLE_GAP_PHY_2MBPS, so if you don't want to connect to devices preferring that, you might want to take a look at how to decide the PHY by way of I.E. a button press, in our BLE long-range demo.

    Best regards,

    Simon

Reply
  • Hi Kim

    2. Please see this post for a thorough explanation of sd_ble_gap_connect().

    3. If your application is set to BLE_GAP_PHY_AUTO, the SD_BLE_GAP_PHY_UPDATE function will select PHY based on the peer's PHY preferences and the local link configuration. The PHY update procedure will for this case result in a PHY combination that respects the time constraints configured with sd_ble_cfg_set and the current link-layer data length. If the peer doesn't support the PHY Update Procedure, the resulting PHY_UPDATE will have a status set to BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.

    Note that BLE_GAP_PHY_AUTO will also be compatible with the BLE_GAP_PHY_2MBPS, so if you don't want to connect to devices preferring that, you might want to take a look at how to decide the PHY by way of I.E. a button press, in our BLE long-range demo.

    Best regards,

    Simon

Children
No Data
Related