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

    1. Can you try scanning and connecting using only BLE_GAP_PHY_CODED, just to make sure that the problem isn't there. I think the problem is that when you get scan reports you don't know if they are CODED or 1MBPS, so the timeout occurs because you try connecting a 1MBPS advertiser to a PHY scanner, or the other way around. Also see what happens when you try to connect in BLE_GAP_EVT_ADV_REPORT. You can try calling the function nrf_ble_scan_connect_with_target in the BLE_GAP_EVT_ADV_REPORT as well, although I suspect it is already being called.

    2. Yes, I think so.

    3. I haven't looked too much into this, but I suspect you have to specify the correct scan_phy parameter, although I am not sure about this. We might find out together!

    Best regards,

    Simon

  • Hi

    After a long time I'm now coming back to this.

    I was wondering if I could get a more definite answer to #2 and #3?

    Regards
    Kim

Reply Children
No Data
Related