Hi,
I am working on the v1.7.0 and I am trying to connect two peripheral with the same services to a central. The first works without any problems:
Scanning successfully started
[00:00:00.006,988] <inf> sdc_hci_driver: SoftDevice Controller build revision:
3f 47 70 8e 81 95 4e 86 9d d3 a2 95 88 f6 30 0a |?Gp...N. ......0.
7f 53 49 fd |.SI.
[00:00:00.010,314] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.010,345] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:00.010,345] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 63.28743 Build 1318420878
[00:00:00.011,566] <inf> bt_hci_core: Identity: FD:A4:A5:64:D6:48 (random)
[00:00:00.011,596] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x125b, manufacturer 0x0059
[00:00:00.011,596] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x125b
// first connection
Connected: D8:E8:A2:5E:BD:75 (random)
Scanning successfully started
// second one does not succeed
Create conn failed (err -111)
When I unplug / disconnect the first connected, the other one is able to join. Here is my code:
#pragma once
#include <autoconf.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/gatt.h>
#include <bluetooth/gap.h>
#include <bluetooth/gatt_dm.h>
#include "services/pressed.h"
static void start_scan(void);
static struct bt_conn *default_conn;
static void connected(struct bt_conn *conn, uint8_t err)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
default_conn = NULL;
printk("Connected: %s\n", addr);
start_scan();
}
static void disconnected(struct bt_conn *conn, uint8_t reason)
{
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
printk("Disconnected: %s (reason 0x%02x)\n", addr, reason);
bt_conn_unref(conn);
default_conn = NULL;
start_scan();
}
static struct bt_conn_cb master_conn_callbacks = {
.connected = connected,
.disconnected = disconnected,
};
static void scan_filter_match(struct bt_scan_device_info *device_info,
struct bt_scan_filter_match *filter_match,
bool connectable)
{
int err;
char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
err = bt_scan_stop();
if (err) {
printk("Stop LE scan failed (err %d)\n", err);
}
struct bt_conn_le_create_param create_params = {
.options = BT_CONN_LE_OPT_CODED | BT_CONN_LE_OPT_NO_1M,
.interval = BT_GAP_SCAN_FAST_INTERVAL, .window = BT_GAP_SCAN_FAST_INTERVAL,
.interval_coded = 0,
.window_coded = 0,
.timeout = 0,
};
struct bt_le_conn_param conn_params = {
.interval_min = BT_GAP_INIT_CONN_INT_MIN,
.interval_max = BT_GAP_INIT_CONN_INT_MAX,
.latency = 0,
.timeout = 400, // 4 seconds
};
err = bt_conn_le_create(device_info->recv_info->addr, &create_params,
&conn_params,
&default_conn);
if (err) {
printk("Create conn failed (err %d)\n", err);
err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
if (err) {
printk("Scanning failed to start (err %d)\n", err);
return;
}
return;
}
}
BT_SCAN_CB_INIT(scan_cb, scan_filter_match, NULL, NULL, NULL);
static void init_start_scan(void) {
int err;
bt_le_scan_param scan_param = {
.type = BT_LE_SCAN_TYPE_ACTIVE,
.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
.interval = BT_GAP_SCAN_FAST_INTERVAL,
.window = BT_GAP_SCAN_FAST_WINDOW,
.timeout = 0,
.interval_coded = 0,
.window_coded = 0,
};
struct bt_scan_init_param scan_init = {
.scan_param = &scan_param,
.connect_if_match = 0,
.conn_param = NULL
};
bt_conn_cb_register(&master_conn_callbacks);
bt_scan_init(&scan_init);
bt_scan_cb_register(&scan_cb);
err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, &pressed_service_id.uuid);
if (err) {
printk("Scanning filters cannot be set (err %d)\n", err);
return;
}
err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
if (err) {
printk("Filters cannot be turned on (err %d)\n", err);
return;
}
start_scan();
}
static void start_scan(void)
{
int err;
err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
if (err) {
printk("Scanning failed to start (err %d)\n", err);
return;
}
printk("Scanning successfully started\n");
}
Does anyone has a clue, why this is happening? What means the error-code -111?