/* Function finding a free position in m_im.connections. 
@detail All connection handles in the m_im.connections array are checked against the connection state module. The index of the first one that is not a connection handle for a current connection is returned. This position in the array can safely be used for a new connection. */
uint8_t get_free_connection()
/* Function finding a free position in m_im.connections. 
@detail All connection handles in the m_im.connections array are checked against the connection state module. The index of the first one that is not a connection handle for a current connection is returned. This position in the array can safely be used for a new connection. */
uint8_t get_free_connection()
{
    for (uint32_t i = 0; i < IM_MAX_CONN_HANDLES; i++)
    {
        if (!ble_conn_state_user_flag_get(m_im.connections[i].conn_handle, m_im.conn_state_user_flag_id))
        {
            return i;
        }
    }
    return IM_NO_INVALID_CONN_HANDLES;
}