This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

central multilink example not building

Hi, All

I am trying the example here ...ncs\v1.9.1\zephyr\samples\bluetooth\central_multilink\ with nRF52833dk_nrf52833 board, however it doesn't build, and saying the  maximum conn number is outside of the valid range of [1. 20]. 

What is the range of CONFIG_BT_MAX_CONN? another example says 20, but why this one set it to 62?

Another question, when a central is connected to some peripherals,  is it still able to do scanning?

Thanks you!

Ping

  • Hi

    The radio will have to stop scanning while it is connecting to a device I'm afraid, as there is only one radio, it will have to stop scanning to be able to connect. If you want the device to always be scanning, you can't do connections, and only receive data from beacons. The error reasons can be found in the errno.h header file. -11 should point to EAGAIN, telling you to try again. What exact line is returning this error, as that usually gives a pointer as to what the reason is. I'm guessing you're being told to try creating the connection later (when the scanning has stopped), as the radio will be busy when you try scanning and creating a connection at the same time.

    Best regards,

    Simon

  • Hello, Simon

    I am revisit the example here, and would like to ask a question, in call back function connected show below, I wonder why conn_connecting is set to NULL even there is no failure on connection, I am thinking of calling disconnect function to disconnect it if I need to, but if it is set to NULL, then, it is not possible, right? Also, may I create multiple connection reference variables like conn_connecting ? as I need to create multiple connections same time and freely disconnect them any time.

     

    static void connected(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));
    
    	if (reason) {
    		printk("Failed to connect to %s (%u)\n", addr, reason);
    
    		bt_conn_unref(conn_connecting);
    		conn_connecting = NULL;
    
    		start_scan();
    		return;
    	}
    
    	conn_connecting = NULL;  //why set the conn_connectign to NULL here? how can I disconnect it?
    
    	conn_count++;
    	if (conn_count < CONFIG_BT_MAX_CONN) {
    		start_scan();
    	}
    
    	printk("Connected (%u): %s\n", conn_count, addr);

    Last question - don't think the following code in init_central() function in while (true) {} loop is ever be called, I wonder how does the program disconnect the connected multiple devices.

    		iterations--;
    		printk("Iterations remaining: %u\n", iterations);
    
    		printk("Disconnecting all...\n");
    		is_disconnecting = true;
    		bt_conn_foreach(BT_CONN_TYPE_LE, disconnect, NULL);

    Could you please explain a little bit? I am trying to connect second device without setting the first conn_connecting NULL, and it gave me an error code of -12, seems meaning ENOMEM - not enough core, does this mean it has run out of memory? It only had 1 connection.

    Thank you for your attention.

    Ping

  • Hi

    I see you also made a new case asking these same exact questions. In the future please create a new case if it's a separate topic or the older case was closed. Otherwise it's fine to ask in an existing post.

    1. As far as I can tell, this is used when you connect to a device with bt_conn_le_create(). So when you get the connected event, either because of a failed connection attempt or a successful one (the second one), the conn_connecting has to be cleared so you can connect to the next device with a new connection object.

    2. I don't think you need to, since this is cleared after a connection it is ready to be used by the next device that is connecting as well.

    3. It should reach the "Disconnecting all" line and below when the iterations limit (max connections) are reached this can be reached as well as far as I can tell.

    Best regards,

    Simon

  • Hi, Simon

    Thanks for your reply, I thought I need to create a new case to get some attention, good that you noticed - the new case has been closed anyway.

    1. if conn_connecting is set to NULL after connection is still established, I wonder how can I call disconnect() function below if I need to disconnect it,  the function needs to pass a connection object to work, it cannot be NULL, right?

    void disconnect(struct bt_conn *conn)

    2. Do you mean it will be overwritten by next connection? then back to question one, no connection object to refer to for disconnection. Do you mean I don't need to create multiple connection objects for multiple device connections? I need to disconnect them if I need.

    3. Yes, you are right, I noticed, but I have not seen any object to disconnect, still don't quite understand how I can have a software to do multiple connect and disconnect for any device I choose, any more examples please?

    Sorry to bother you with these questions, I am new to BLE and learning.

    Ping

  • Hi

    1. The disconnect doesn't use the conn_connecting call as far as I can see, but rather the connection handle or address of the device.

    2. Yes, the conn_connecting is just an event used during the connection procedure, and are cleared between connections.

    3. You need to store connection information, for example the addresses of the connected devices somewhere that you can call in order to disconnect from a specific device after connecting to multiple ones. 

    Best regards,

    Simon

Related