bt_hci_core: opcode 0x200d status 0x0d On second peripheral turned on

Hello everyone! I am having some trouble in connecting two peripherals to a single central station.

As peripherals I'm using 2 nRF5340DK flashed with the UART-Peripheral Sample. I just have changed the Device Name for each of them.

As central, I'm using a nRF7002DK. I started from the ble_coex WiFi sample and I am actually able to pair without any problem my central to one of the peripheral. I changed the scan filter type from UUID to Device Name so even at the moment I can forget about the Service layer(I'll need to implement my own later).

My goal is to also have connected the second peripheral, and I was looking at the multi-NUS sample that I found online. I tried to adapt the code to my scenario in which I still don't want to deal with the right service.


The first peripheral connects fine, but as soon as I turn on the second one, It fails to connect to it, with the log giving to me the following error:

<wrn> bt_hci_core: opcode 0x200d status 0x0d

I have in my conf files the following settings regarding the available connections

CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2

And the curious thing is that if I use 

struct bt_throughput *throughput = bt_conn_ctx_alloc(&conns_ctx_lib, conn);
memset(throughput, 0, bt_conn_ctx_block_size_get(&conns_ctx_lib));

err = bt_throughput_init(throughput, &throughput_cb); 

err = bt_gatt_dm_start(default_conn,
                BT_UUID_THROUGHPUT,
                &discovery_cb,
                &throughput);

if (err) {
    LOG_INF("Discover failed (err %d)", err);
}

size_t num_conns = bt_conn_ctx_count(&conns_ctx_lib);
bt_conn_ctx_release(&conns_ctx_lib, (void *)throughput);
LOG_INF("Number of connections: %d", num_conns);

in my connection callback, I read that when I turn on the first peripheral, the Number of connection is already 2. I'm wondering if that is related

Parents
  • Hi,

    You could try to add CONFIG_BT_MAX_CONN=2 to both application and network core. In addition, you could try to set CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=2 to the network core image.

    Best regards,
    Dejan

  • I already set CONFIG_BT_MAX_CONN=2 in both cores. Also, if I set CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=2 it doesn't build correctly.

    Also tried CONFIG_BT_MAX_CONN=2 and CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=2 but the error is showing anyways

    May I share you my config files and the code that I have setup to run the bt stack?

  • Hi,

    dario.sortino said:
    Also tried CONFIG_BT_MAX_CONN=2 and CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=2 but the error is showing anyways

    Is the result different? Can you connect to the second peripheral in this case?
    Do you get different result if you increase CONFIG_BT_MAX_CONN on the central side? 

    dario.sortino said:
    May I share you my config files and the code that I have setup to run the bt stack?

    If increasing maximum number of connections does not resolve the issue, you could send full log showing the error/warning and your config files.

    Best regards,
    Dejan

Reply
  • Hi,

    dario.sortino said:
    Also tried CONFIG_BT_MAX_CONN=2 and CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=2 but the error is showing anyways

    Is the result different? Can you connect to the second peripheral in this case?
    Do you get different result if you increase CONFIG_BT_MAX_CONN on the central side? 

    dario.sortino said:
    May I share you my config files and the code that I have setup to run the bt stack?

    If increasing maximum number of connections does not resolve the issue, you could send full log showing the error/warning and your config files.

    Best regards,
    Dejan

Children
  • Unluckily it would not change the result.

    I kept trying stuff and ended up using directly the multi-NUS service in my device that previously was running the throughput serivice.

    All the code related to the BT is here

    /* -------------------------------- Include Directives -------------------------------- */
    /* HAL */
    
    #include "api_ble.h"
    
    LOG_MODULE_REGISTER(api_ble, 4);
    
    /* --------------------------------- Global Variables --------------------------------- */
    
    
    struct bt_conn *default_conn;
    struct bt_le_conn_param *conn_param = BT_LE_CONN_PARAM( CONFIG_INTERVAL_MIN, 
                                                            CONFIG_INTERVAL_MAX, 
                                                            CONFIG_CONNECTION_LATENCY, 
                                                            CONFIG_SUPERVISION_TIMEOUT);
    
    BT_CONN_CTX_DEF(conns, CONFIG_BT_MAX_CONN, sizeof(struct bt_nus_client));
    
    BT_SCAN_CB_INIT(scan_cb,
                    ifeel_on_scan_filter_match,
                    ifeel_on_scan_filter_no_match,
                    ifeel_on_scan_connecting_error, 
    				ifeel_on_scan_connecting);
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
    	.connected = ifeel_on_bt_connected,
    	.disconnected = ifeel_on_bt_disconnected
    };
    
    extern struct bt_gatt_dm_cb discovery_cb = {
    	.completed         = ifeel_on_discovery_complete,
    	.service_not_found = ifeel_on_discovery_service_not_found,
    	.error_found       = ifeel_on_discovery_error,
    };
    
    extern struct bt_conn_auth_cb conn_auth_callbacks = {
    	.cancel = auth_cancel,
    	.pairing_confirm = pairing_confirm
    };
    
    extern struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
    	.pairing_complete = pairing_complete,
    	.pairing_failed = pairing_failed
    };
    
    /* -------------------------------- Function Definitions -------------------------------*/
    
    
    ifeel_t ifeel_ble_init(void){
    
    	int err;
    
    	err = bt_conn_auth_cb_register(&conn_auth_callbacks);
    	if (err) {
    		LOG_ERR("Failed to register authorization callbacks.");
    		return 0;
    	}
    
    	err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
    	if (err) {
    		printk("Failed to register authorization info callbacks.\n");
    		return 0;
    	}
    
    	err = bt_enable(NULL);
    	if (err) {
    		LOG_INF("Bluetooth init failed (err %d)", err);
    		return err;
    	}
    	if (IS_ENABLED(CONFIG_SETTINGS)) {
    		settings_load();
    	}
    
        iFEEL(ifeel_ble_scan_init());
        iFEEL(ifeel_ble_scan_start());
    
    }
    
    ifeel_t ifeel_ble_scan_start(void){
    
        int err;
    	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
    	if (err) {
    		LOG_INF("Starting scanning failed (err %d)", err);
    		return err;
    	}
        LOG_INF("BLE Scanning started");
        return 0;
     }
    
    
    
    ifeel_t ifeel_ble_scan_init(void){
        int err;
    	struct bt_le_scan_param scan_param = {
    		.type = BT_LE_SCAN_TYPE_ACTIVE,
    		.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
    		.interval = 0x0010,
    		.window = 0x0010,
    	};
    
    	struct bt_scan_init_param scan_init = {
    		.connect_if_match = 1,
    		//.scan_param = &scan_param,
    		//.conn_param = conn_param
    	};
    
    	bt_scan_init(&scan_init);
    	bt_scan_cb_register(&scan_cb);
    
    	// err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, "iFeel-Peripheral");
    	// if (err) {
    	// 	LOG_INF("Scanning filters cannot be set");
    	// 	return err;
    	// }
    
        // err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, "iFeel-Peripheral1");
    	// if (err) {
    	// 	LOG_INF("Scanning filters cannot be set");
    	// 	return err;
    	// }
    
    	// err = bt_scan_filter_enable(BT_SCAN_NAME_FILTER, false);
    	// if (err) {
    	// 	LOG_INF("Filters cannot be turned on");
        //     return err;
    	// }
    
    	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_NUS_SERVICE);
    	if (err) {
    		LOG_ERR("Scanning filters cannot be set (err %d)", err);
    		return err;
    	}
    
    	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
    	if (err) {
    		LOG_ERR("Filters cannot be turned on (err %d)", err);
    		return err;
    	}
        
        LOG_INF("BLE Scanning initialized");
    
        return 0;
    }
    
    void auth_cancel(struct bt_conn *conn)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_INF("Pairing cancelled: %s", addr);
    }
    
    
    void pairing_confirm(struct bt_conn *conn)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	bt_conn_auth_pairing_confirm(conn);
    
    	LOG_INF("Pairing confirmed: %s", addr);
    }
    
    
    void pairing_complete(struct bt_conn *conn, bool bonded)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_INF("Pairing completed: %s, bonded: %d", addr,bonded);
    }
    
    void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_WRN("Pairing failed conn: %s, reason %d", addr,	reason);
    }
    
    
    void ifeel_on_scan_filter_match(struct bt_scan_device_info *device_info, bool connectable){
    
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
    
    	LOG_INF("Filters matched. Address: %s connectable: %d",
    		addr, connectable);
    }
    
    void ifeel_on_scan_filter_no_match(struct bt_scan_device_info *device_info, bool connectable)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
    
    	//LOG_INF("Filter not match. Address: %s connectable: %d", addr, connectable);
    }
    
    void ifeel_on_scan_connecting_error(struct bt_scan_device_info *device_info){
    
    	LOG_INF("Connecting failed");
    	
    	ifeel_ble_scan_start();
    }
    
    void ifeel_on_scan_connecting(struct bt_scan_device_info *device_info,
    			    struct bt_conn *conn)
    {
    	default_conn = bt_conn_ref(conn);
    }
    
    void ifeel_on_discovery_complete(struct bt_gatt_dm *dm, void *context){
        
        int err;
    	struct bt_nus_client *nus = context;
    
    	struct bt_throughput *throughput = context;
        LOG_INF("Service discovery complete");
        bt_gatt_dm_data_print(dm);
    
    	// bt_nus_handles_assign(dm, nus);
    	// bt_nus_subscribe_receive(nus);
    
    	// bt_gatt_dm_data_release(dm);
    	ifeel_ble_scan_start();
    
    
    }
    
    void ifeel_on_discovery_service_not_found(struct bt_conn *conn, void *context){
        LOG_INF("Service not found");
    }
    
    void ifeel_on_discovery_error(struct bt_conn *conn, int err, void *context){
        LOG_INF("Discovery error: %d", err);
    }
    
    void ifeel_on_bt_connected(struct bt_conn *conn, uint8_t hci_err){
    
    	char addr[BT_ADDR_LE_STR_LEN];
        struct bt_conn_info info = {0};
    	
    	int err;
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	if (hci_err) {
    
    		LOG_INF("Connection failed (err 0x%02x)", hci_err);
    		if (default_conn == conn) {
    			bt_conn_unref(default_conn);
    			default_conn = NULL;
    
    			ifeel_ble_scan_start();
    		}
    		return;
    	}
        
    	default_conn = bt_conn_ref(conn);
    
    	LOG_INF("----- Connected to %s -----", addr);
    
        // err = ifeel_ble_conn_set(BT_LE_CONN_PARAM(CONFIG_INTERVAL_MIN,
        //                         CONFIG_INTERVAL_MAX,
        //                         CONFIG_CONNECTION_LATENCY, CONFIG_SUPERVISION_TIMEOUT),
        //                         BT_CONN_LE_PHY_PARAM_2M,
        //                         BT_LE_DATA_LEN_PARAM_MAX);
        // if (err) {
        //     LOG_INF("Connection parameters set failed (err %d)", err);
        // }
    
    	struct bt_nus_client *nus_client = bt_conn_ctx_alloc(&conns_ctx_lib, conn);
    	if (!nus_client) {
    		LOG_WRN("There is no free memory to "
    			"allocate the connection context");
    	}
    	
    	struct bt_nus_client_init_param nus_client_param = {
    		.cb = {
    			.received = NULL,
    			.sent = NULL,
    		}
    	};
    
    	memset(nus_client, 0, bt_conn_ctx_block_size_get(&conns_ctx_lib));
    
    	err = bt_nus_client_init(nus_client, &nus_client_param);
    
        err = bt_gatt_dm_start(default_conn,
                        BT_UUID_NUS_SERVICE,
                        &discovery_cb,
                        &nus_client);
    
    	if (err) {
    		LOG_ERR("could not start the discovery procedure, error "
    			"code: %d", err);
    	}
    	
    	bt_conn_ctx_release(&conns_ctx_lib, (void *)nus_client);
    
    	err = bt_scan_stop();
    	if ((!err) && (err != -EALREADY)) {
    		LOG_ERR("Stop LE scan failed (err %d)", err);
    	}	
    
    }
    
    void ifeel_on_bt_disconnected(struct bt_conn *conn, uint8_t reason){
    	
    	int err;
    
        LOG_INF("Disconnected (reason %u)", reason);
        
    	err = bt_conn_ctx_free(&conns_ctx_lib, conn);
    
    	if (err) {
    		LOG_WRN("The memory was not allocated for the context of this "
    			"connection.");
    	}
        
    	bt_conn_unref(default_conn);
    	default_conn = NULL;
    
    	ifeel_ble_scan_start();
    }
    
    ifeel_t ifeel_ble_conn_set(const struct bt_le_conn_param *conn_param,
    			const struct bt_conn_le_phy_param *phy,
    			const struct bt_conn_le_data_len_param *data_len){
    
        int err;
    	struct bt_conn_info info = {0};
    
    	err = bt_conn_get_info(default_conn, &info);
    	if (err) {
    		LOG_INF("Failed to get connection info %d", err);
    		return err;
    	}
    
    	err = bt_conn_le_phy_update(default_conn, phy);
    	if (err) {
    		LOG_INF("PHY update failed: %d", err);
    		return err;
    	}
    
    	if (err) {
    		LOG_INF("PHY update timeout");
    		return err;
    	}
    
    	if (info.le.data_len->tx_max_len != data_len->tx_max_len) {
    
    		err = bt_conn_le_data_len_update(default_conn, data_len);
    		if (err) {
    			LOG_INF("LE data length update failed: %d",
    				    err);
    			return err;
    		}
    
    		LOG_INF("LE Data length updated");
    		if (err) {
    			LOG_INF("LE Data Length update timeout: %d", err);
    			return err;
    		}
    	}
    
    	if (info.le.interval != conn_param->interval_max) {
    		err = bt_conn_le_param_update(default_conn, conn_param);
    		if (err) {
    			LOG_INF("Connection parameters update failed: %d", err);
    			return err;
    		}
    
    		LOG_INF("Connection parameters updated");
    		if (err) {
    			LOG_INF("Connection parameters update timeout: %d", err);
    			return err;
    		}
    	}
    
    	return 0;
    }
    
    /* End of file FILENAME */
    

    And my conf files are

    prj-wifi.conf5707.prj.conf

    And for the network core

    6864.hci_ipc.conf

    In my main, I call `ifeel_ble_init` to start the whole bt stack.

  • I had to comment out line 228-231 otherwise a MPU Fault shows

  • /* -------------------------------- Include Directives -------------------------------- */
    /* HAL */
    
    #include "api_ble.h"
    
    LOG_MODULE_REGISTER(api_ble, 4);
    
    /* --------------------------------- Global Variables --------------------------------- */
    
    
    struct bt_conn *default_conn;
    struct bt_le_conn_param *conn_param = BT_LE_CONN_PARAM( CONFIG_INTERVAL_MIN, 
                                                            CONFIG_INTERVAL_MAX, 
                                                            CONFIG_CONNECTION_LATENCY, 
                                                            CONFIG_SUPERVISION_TIMEOUT);
    
    BT_CONN_CTX_DEF(conns, CONFIG_BT_MAX_CONN, sizeof(struct bt_nus_client));
    
    BT_SCAN_CB_INIT(scan_cb,
                    ifeel_on_scan_filter_match,
                    ifeel_on_scan_filter_no_match,
                    ifeel_on_scan_connecting_error, 
    				ifeel_on_scan_connecting);
    
    BT_CONN_CB_DEFINE(conn_callbacks) = {
    	.connected = ifeel_on_bt_connected,
    	.disconnected = ifeel_on_bt_disconnected
    };
    
    extern struct bt_gatt_dm_cb discovery_cb = {
    	.completed         = ifeel_on_discovery_complete,
    	.service_not_found = ifeel_on_discovery_service_not_found,
    	.error_found       = ifeel_on_discovery_error,
    };
    
    extern struct bt_conn_auth_cb conn_auth_callbacks = {
    	.cancel = auth_cancel,
    	.pairing_confirm = pairing_confirm
    };
    
    extern struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
    	.pairing_complete = pairing_complete,
    	.pairing_failed = pairing_failed
    };
    
    /* -------------------------------- Function Definitions -------------------------------*/
    
    
    ifeel_t ifeel_ble_init(void){
    
    	int err;
    
    	err = bt_conn_auth_cb_register(&conn_auth_callbacks);
    	if (err) {
    		LOG_ERR("Failed to register authorization callbacks.");
    		return 0;
    	}
    
    	err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
    	if (err) {
    		printk("Failed to register authorization info callbacks.\n");
    		return 0;
    	}
    
    	err = bt_enable(NULL);
    	if (err) {
    		LOG_INF("Bluetooth init failed (err %d)", err);
    		return err;
    	}
    	if (IS_ENABLED(CONFIG_SETTINGS)) {
    		settings_load();
    	}
    
        iFEEL(ifeel_ble_scan_init());
        iFEEL(ifeel_ble_scan_start());
    
    }
    
    ifeel_t ifeel_ble_scan_start(void){
    
        int err;
    	err = bt_scan_start(BT_SCAN_TYPE_SCAN_ACTIVE);
    	if (err) {
    		LOG_INF("Starting scanning failed (err %d)", err);
    		return err;
    	}
        LOG_INF("BLE Scanning started");
        return 0;
     }
    
    
    
    ifeel_t ifeel_ble_scan_init(void){
        int err;
    	struct bt_le_scan_param scan_param = {
    		.type = BT_LE_SCAN_TYPE_ACTIVE,
    		.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
    		.interval = 0x0010,
    		.window = 0x0010,
    	};
    
    	struct bt_scan_init_param scan_init = {
    		.connect_if_match = 1,
    		//.scan_param = &scan_param,
    		//.conn_param = conn_param
    	};
    
    	bt_scan_init(&scan_init);
    	bt_scan_cb_register(&scan_cb);
    
    	// err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, "iFeel-Peripheral");
    	// if (err) {
    	// 	LOG_INF("Scanning filters cannot be set");
    	// 	return err;
    	// }
    
        // err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, "iFeel-Peripheral1");
    	// if (err) {
    	// 	LOG_INF("Scanning filters cannot be set");
    	// 	return err;
    	// }
    
    	// err = bt_scan_filter_enable(BT_SCAN_NAME_FILTER, false);
    	// if (err) {
    	// 	LOG_INF("Filters cannot be turned on");
        //     return err;
    	// }
    
    	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_NUS_SERVICE);
    	if (err) {
    		LOG_ERR("Scanning filters cannot be set (err %d)", err);
    		return err;
    	}
    
    	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
    	if (err) {
    		LOG_ERR("Filters cannot be turned on (err %d)", err);
    		return err;
    	}
        
        LOG_INF("BLE Scanning initialized");
    
        return 0;
    }
    
    void ifeel_gatt_discover(struct bt_conn *conn){
    
    	int err;
    	struct bt_nus_client *nus_client = bt_conn_ctx_get(&conns_ctx_lib, conn);
    
    	if (!nus_client) {
    		return;
    	}
    
    	err = bt_gatt_dm_start(conn,
    			       BT_UUID_NUS_SERVICE,
    			       &discovery_cb,
    			       nus_client);
    	if (err) {
    		LOG_ERR("could not start the discovery procedure, error "
    			"code: %d", err);
    	}
    
    	bt_conn_ctx_release(&conns_ctx_lib, (void *) nus_client);
    
    }
    
    void auth_cancel(struct bt_conn *conn)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_INF("Pairing cancelled: %s", addr);
    }
    
    
    void pairing_confirm(struct bt_conn *conn)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	bt_conn_auth_pairing_confirm(conn);
    
    	LOG_INF("Pairing confirmed: %s", addr);
    }
    
    
    void pairing_complete(struct bt_conn *conn, bool bonded)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_INF("Pairing completed: %s, bonded: %d", addr,bonded);
    }
    
    void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	LOG_WRN("Pairing failed conn: %s, reason %d", addr,	reason);
    }
    
    
    void ifeel_on_scan_filter_match(struct bt_scan_device_info *device_info, bool connectable){
    
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
    
    	LOG_INF("Filters matched. Address: %s connectable: %d",
    		addr, connectable);
    }
    
    void ifeel_on_scan_filter_no_match(struct bt_scan_device_info *device_info, bool connectable)
    {
    	char addr[BT_ADDR_LE_STR_LEN];
    
    	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
    
    	//LOG_INF("Filter not match. Address: %s connectable: %d", addr, connectable);
    }
    
    void ifeel_on_scan_connecting_error(struct bt_scan_device_info *device_info){
    
    	LOG_INF("Connecting failed");
    	
    }
    
    void ifeel_on_scan_connecting(struct bt_scan_device_info *device_info,
    			    struct bt_conn *conn)
    {
    	default_conn = bt_conn_ref(conn);
    }
    
    void ifeel_on_discovery_complete(struct bt_gatt_dm *dm, void *context){
        
        int err;
    	struct bt_nus_client *nus = context;
    
        LOG_INF("Service discovery complete");
        bt_gatt_dm_data_print(dm);
    
    	LOG_INF("dm data printed");
    
    	bt_nus_handles_assign(dm, nus);
    	LOG_INF("nus handles assigned");
    
    	bt_nus_subscribe_receive(nus);
    	LOG_INF("nus subscribed");
    
    	bt_gatt_dm_data_release(dm);
    	LOG_INF("dm data released");
    	
    	ifeel_ble_scan_start();
    
    }
    
    void ifeel_on_discovery_service_not_found(struct bt_conn *conn, void *context){
        LOG_INF("Service not found");
    }
    
    void ifeel_on_discovery_error(struct bt_conn *conn, int err, void *context){
        LOG_INF("Discovery error: %d", err);
    }
    
    void ifeel_on_bt_connected(struct bt_conn *conn, uint8_t hci_err){
    
    	char addr[BT_ADDR_LE_STR_LEN];
        struct bt_conn_info info = {0};
    	
    	int err;
    
    	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
    
    	if (hci_err) {
    
    		LOG_INF("Connection failed (err 0x%02x)", hci_err);
    		if (default_conn == conn) {
    			bt_conn_unref(default_conn);
    			default_conn = NULL;
    
    			ifeel_ble_scan_start();
    		}
    		return;
    	}
        
    	default_conn = bt_conn_ref(conn);
    
    	LOG_INF("----- Connected to %s -----", addr);
    
        // err = ifeel_ble_conn_set(BT_LE_CONN_PARAM(CONFIG_INTERVAL_MIN,
        //                         CONFIG_INTERVAL_MAX,
        //                         CONFIG_CONNECTION_LATENCY, CONFIG_SUPERVISION_TIMEOUT),
        //                         BT_CONN_LE_PHY_PARAM_2M,
        //                         BT_LE_DATA_LEN_PARAM_MAX);
        // if (err) {
        //     LOG_INF("Connection parameters set failed (err %d)", err);
        // }
    
    	struct bt_nus_client *nus_client = bt_conn_ctx_alloc(&conns_ctx_lib, conn);
    	if (!nus_client) {
    		LOG_WRN("There is no free memory to allocate the connection context");
    	}
    	
    	struct bt_nus_client_init_param nus_client_param = {
    		.cb = {
    			.received = NULL,
    			.sent = NULL,
    		}
    	};
    
    	memset(nus_client, 0, bt_conn_ctx_block_size_get(&conns_ctx_lib));
    
    	err = bt_nus_client_init(nus_client, &nus_client_param);
    
    	bt_conn_ctx_release(&conns_ctx_lib, (void *)nus_client);
    
    	ifeel_gatt_discover(conn);
    	
    	err = bt_scan_stop();
    	if ((!err) && (err != -EALREADY)) {
    		LOG_ERR("Stop LE scan failed (err %d)", err);
    	}else{
    		LOG_INF("BLE scan stopped");
    	}
    
    
    }
    
    void ifeel_on_bt_disconnected(struct bt_conn *conn, uint8_t reason){
    	
    	int err;
    
        LOG_INF("Disconnected (reason %u)", reason);
        
    	err = bt_conn_ctx_free(&conns_ctx_lib, conn);
    
    	if (err) {
    		LOG_WRN("The memory was not allocated for the context of this "
    			"connection.");
    	}
        
    	bt_conn_unref(default_conn);
    	default_conn = NULL;
    
    }
    
    ifeel_t ifeel_ble_conn_set(const struct bt_le_conn_param *conn_param,
    			const struct bt_conn_le_phy_param *phy,
    			const struct bt_conn_le_data_len_param *data_len){
    
        int err;
    	struct bt_conn_info info = {0};
    
    	err = bt_conn_get_info(default_conn, &info);
    	if (err) {
    		LOG_INF("Failed to get connection info %d", err);
    		return err;
    	}
    
    	err = bt_conn_le_phy_update(default_conn, phy);
    	if (err) {
    		LOG_INF("PHY update failed: %d", err);
    		return err;
    	}
    
    	if (err) {
    		LOG_INF("PHY update timeout");
    		return err;
    	}
    
    	if (info.le.data_len->tx_max_len != data_len->tx_max_len) {
    
    		err = bt_conn_le_data_len_update(default_conn, data_len);
    		if (err) {
    			LOG_INF("LE data length update failed: %d",
    				    err);
    			return err;
    		}
    
    		LOG_INF("LE Data length updated");
    		if (err) {
    			LOG_INF("LE Data Length update timeout: %d", err);
    			return err;
    		}
    	}
    
    	if (info.le.interval != conn_param->interval_max) {
    		err = bt_conn_le_param_update(default_conn, conn_param);
    		if (err) {
    			LOG_INF("Connection parameters update failed: %d", err);
    			return err;
    		}
    
    		LOG_INF("Connection parameters updated");
    		if (err) {
    			LOG_INF("Connection parameters update timeout: %d", err);
    			return err;
    		}
    	}
    
    	return 0;
    }
    
    /* End of file FILENAME */
    

    Please refer to this block of code.

    With this, the sample returns the following log:

    Ther is only one peripheral turned on and it works fine if I flash the multi-NUS sample (from which I based my code). Apparently the problem is solved with an "erase and flash" of the board.

    Currently, I see

    when turning on the second peripheral.

  • I solved by removing completely the content of hci_ipc.conf

Related