W: conn failed to establish. RF noise?

deleted

Parents Reply Children
  • 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

Related