deleted
Hi Nick,
Can you please tell us more on your test setup and also show us the console output where you see the warning you mentioned? It sounds like a configuration issue with the software but I can try to assist you more after you provide more information that I requested.
deleted
Isn't this the same issue as mentioned here ?
Yes, the infinite loop seems wrong like you already suspected and it is better to have a timeout and move on. I suggest the below for the cleanup code
if (k_sem_take(&sem_connected, K_SECONDS(4)) != 0) {
printk("W: Connection to device %d timed out. Skipping...\n", i);
if (connections[i]) {
bt_conn_disconnect(connections[i], BT_HCI_ERR_REMOTE_USER_TERM_CONN);
bt_conn_unref(connections[i]);
connections[i] = NULL;
}
continue; // Move on to the next device
}
Also please do not open multiple threads on the same issue and please close on of these two threads.
deleted
Yes, Please share you whole project zipped. I need to see what your code is doing in other callbacks like connected(). I also need to see how you are giving the semaphore sem_connected.
Yes, Please share you whole project zipped. I need to see what your code is doing in other callbacks like connected(). I also need to see how you are giving the semaphore sem_connected.
deleted
There is a bug in your code, in the connected_cb() you are not giving the semaphore when the connection fails.
So when there is a connection failure your main loop is stuck. You also still have k_sem_take waiting for K_FOREVER.
I suggest you one of the two changes
1) In your connected_cb()
static void connected_cb(struct bt_conn *conn, uint8_t err)
{
if (err) {
LOG_ERR("Connection failed (err 0x%02x)", err);
bt_conn_unref(conn);
k_sem_give(&sem_connected); // ADD THIS NEW LINE ADDED SUSHEEL
return;
}
/* On success the same give(), which you are doing already. */
k_sem_give(&sem_connected);
…
}
2) Make sure your k_sem_take are not waiting for ever and PLEASE DO NOT IGNORE RETURN VALUES of function calls like k_sem_take