I'm using SDK 16.0 with SD340 6.1.1 on nRF52840
I'm working through alternating advertising on coded phy and non-coded phy. I have two scenarios where I don't want connections to be possible. In those scenarios, when I try to use:
BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED
BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED
I get back an error 10 from the soft device. Both exist in the ble_gap.h for the SD.
When I use:
BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED
It succeeds, but I am actually still able to connect using nRF Connect.
I have previously send questions to Garmin (thisisant), but they state that it supports everything that S140 v6.1.1 supports. I have not asked about this specifically, but I can.
Relevant code snippet:
void advertising_start(bool erase_bonds) {
// Last advertising mode. If true, then the switch is to normal
static uint8_t isCoded = 0;
/*
* 1. check if we have connections. This sets connectable
* 2. if connectable, check start count. 0-18: le coded. 19: 1m non-coded
* coded: 1ms duration. 100ms interval. le coded.
* standard: 250ms duration. 50ms interval. 1m
*/
// Get number of current connections. We want 1 connection only. If we have one
// Then switch to non-connectable advertising.
uint32_t count = ble_conn_state_peripheral_conn_count();
if (count) {
// We have a connection. No more.
advData.flags = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
// We know that we want to be coded at this point. B2V data
advModes.ble_adv_primary_phy = BLE_GAP_PHY_CODED;
advModes.ble_adv_secondary_phy = BLE_GAP_PHY_CODED;
advModes.ble_adv_extended_enabled = true;
// Do not expire advertising until a disconnect
advModes.ble_adv_fast_timeout = 0;
advModes.ble_adv_fast_interval = 160; /* 100ms */
// set manuf data
advData.p_manuf_specific_data = &manData;
} else {
// No connection. Alternate coded and non-coded
if (isCoded) {
isCoded = false;
// only allow connections on standard phy
//advData.flags = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
advData.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
// send standard adv packet
advModes.ble_adv_primary_phy = BLE_GAP_PHY_1MBPS;
advModes.ble_adv_secondary_phy = BLE_GAP_PHY_1MBPS;
advModes.ble_adv_extended_enabled = false;
// Set duration to 250ms, interval to 50ms
advModes.ble_adv_fast_timeout = 25; // units of 10ms (250ms)
advModes.ble_adv_fast_interval = 80; // units of .625ms (50ms)
// turn off manuf data for smaller packets
advData.p_manuf_specific_data = 0;
} else {
isCoded = true;
// Don't allow connections on coded phy
advData.flags = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
// Send coded packet
advModes.ble_adv_primary_phy = BLE_GAP_PHY_CODED;
advModes.ble_adv_secondary_phy = BLE_GAP_PHY_CODED;
advModes.ble_adv_extended_enabled = true;
// set duration to 1s, interval to 100ms
advModes.ble_adv_fast_timeout = 100; // units of 10ms (1s)
advModes.ble_adv_fast_interval = 160; // units of .625ms (100ms)
// set manuf data
advData.p_manuf_specific_data = &manData;
}
}
ble_advertising_modes_config_set(&m_advertising, &advModes);
ble_advertising_advdata_update(&m_advertising, &advData, &srData);
// Currently we don't use bonds, but leave this in for when we do. deleting bonds is part of reset.
if (erase_bonds == true) {
delete_bonds();
// Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
} else {
ret_code_t err_code;
err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
}
}