I have a project where I want to connect one central device to multiple peripheral devices using BLE. Some of the connections should use 1M PHY, some should use coded PHY. Any of the peripheral devices may be present and the connections should form in any order - in other words, I want to scan and connect for both PHYs at the same time rather than one at a time (although, if needed, one at a time could be OK).
I am finding that I am able to successfully scan for devices advertising on both PHYs, but after connecting to one of the devices using coded PHY I can no longer see any coded PHY devices in the scan. I still get scan callbacks, but only for 1M PHY devices (I have multiple peripheral devices on both PHYs so I'm no longer seeing the non-connected ones). If the coded connection drops the coded scans start to work again. This is a problem because it limits me to only finding / connecting to one coded PHY device.
For reference here's some snippets showing the ad / scan / connect parameters.
Advertising:
uint32_t opt = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED;
struct bt_le_adv_param * adv_param = BT_LE_ADV_PARAM(opt, 160, 320, NULL);
int res = bt_le_ext_adv_update_param(ad_set, adv_param);
// Not shown: registering callbacks
struct bt_le_scan_param scan_params =
{
.type = BT_LE_SCAN_TYPE_PASSIVE,
.options = BT_LE_SCAN_OPT_CODED,
.interval = 0x40, // 40ms
.window = 0x20, // 20ms
.timeout = 0,
.interval_coded = 0,
.window_coded = 0,
};
int res = bt_le_scan_start(&scan_params, NULL);
struct bt_conn_le_create_param create_param =
{
.options = BT_CONN_LE_OPT_CODED,
.interval = 0x40,
.window = 0x20,
.interval_coded = 0,
.window_coded = 0,
.timeout = 0, // Use default (3 s)
};
struct bt_le_conn_param conn_param =
{
.interval_min = 6, // 7.5 ms, minimum allowed by spec
.interval_max = 6, // 7.5 ms. Note: 6 <= interval_min <= interval_max <= 3200
.latency = 0,
.timeout = 400, // 4 seconds
};
int res = bt_conn_le_create(peer, create_param, conn_param, conn);
// Not shown: saving the connection handle
.options = BT_LE_SCAN_OPT_CODED | BT_LE_SCAN_OPT_NO_1M,
.options = BT_CONN_LE_OPT_CODED | BT_CONN_LE_OPT_NO_1M,
struct bt_le_scan_param scan_params =
{
.type = BT_LE_SCAN_TYPE_PASSIVE,
.options = BT_LE_SCAN_OPT_CODED,
.interval = 0x40, // 40ms
.window = 0x30, // 30ms
.timeout = 0,
.interval_coded = 0,
.window_coded = 0,
};
<wrn> bt_hci_core: opcode 0x2041 status 0x12
Other relevant details:
NCS 2.4.1
5340 app core configuration (BT only):
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_MAX_CONN=4
CONFIG_BT_EXT_ADV=y
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_RX_STACK_SIZE=2048
CONFIG_BT_FILTER_ACCEPT_LIST=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_SMP=y
CONFIG_BT_DEVICE_NAME="ABC"
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_MAX_CONN=4
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_CTLR_PHY_CODED=y
CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=1