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"?