示例#1
0
/**@brief Function to set the peer ID associated with a connection handle.
 *
 * @param[in]  conn_handle  The connection handle.
 * @param[in]  peer_id      The peer ID to associate with @c conn_handle.
 */
static void peer_id_set(uint16_t conn_handle, pm_peer_id_t peer_id)
{
    uint8_t conn_index = get_connection_by_conn_handle(conn_handle);
    if (conn_index != IM_NO_INVALID_CONN_HANDLES)
    {
        m_connections[conn_index].peer_id = peer_id;
    }
}
示例#2
0
pm_peer_id_t im_peer_id_get_by_conn_handle(uint16_t conn_handle)
{
    uint8_t conn_index = get_connection_by_conn_handle(conn_handle);

    if (MODULE_INITIALIZED && (conn_index != IM_NO_INVALID_CONN_HANDLES))
    {
        return m_im.connections[conn_index].peer_id;
    }

    return PM_PEER_ID_INVALID;
}
示例#3
0
ret_code_t im_ble_addr_get(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr)
{
    VERIFY_MODULE_INITIALIZED();
    VERIFY_PARAM_NOT_NULL(p_ble_addr);

    uint8_t conn_index = get_connection_by_conn_handle(conn_handle);
    if (conn_index != IM_NO_INVALID_CONN_HANDLES)
    {
        *p_ble_addr = m_im.connections[conn_index].peer_address;
        return NRF_SUCCESS;
    }

    return NRF_ERROR_NOT_FOUND;
}
示例#4
0
pm_peer_id_t im_peer_id_get_by_conn_handle(uint16_t conn_handle)
{
    uint8_t conn_index;

    NRF_PM_DEBUG_CHECK(m_module_initialized);

    conn_index = get_connection_by_conn_handle(conn_handle);

    if (conn_index != IM_NO_INVALID_CONN_HANDLES)
    {
        return m_connections[conn_index].peer_id;
    }

    return PM_PEER_ID_INVALID;
}
示例#5
0
ret_code_t im_ble_addr_get(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr)
{
    uint8_t conn_index;

    NRF_PM_DEBUG_CHECK(m_module_initialized);
    NRF_PM_DEBUG_CHECK(p_ble_addr != NULL);

    conn_index = get_connection_by_conn_handle(conn_handle);

    if (conn_index != IM_NO_INVALID_CONN_HANDLES)
    {
        *p_ble_addr = m_connections[conn_index].peer_address;
        return NRF_SUCCESS;
    }

    return NRF_ERROR_NOT_FOUND;
}
示例#6
0
/**@brief Function for registering a new connection instance.
 *
 * @param[in]  conn_handle  The handle of the new connection.
 * @param[in]  p_ble_addr   The address used to connect.
 *
 * @return Either the index of the new connection in the array or IM_NO_INVALID_CONN_HANDLES if no
 *         free position exists.
 */
uint8_t new_connection(uint16_t conn_handle, ble_gap_addr_t * p_ble_addr)
{
    uint8_t conn_index = IM_NO_INVALID_CONN_HANDLES;

    if ((p_ble_addr != NULL) && (conn_handle != BLE_CONN_HANDLE_INVALID))
    {
        ble_conn_state_user_flag_set(conn_handle, m_conn_state_user_flag_id, true);

        conn_index = get_connection_by_conn_handle(conn_handle);
        if (conn_index == IM_NO_INVALID_CONN_HANDLES)
        {
            conn_index = get_free_connection();
        }

        if (conn_index != IM_NO_INVALID_CONN_HANDLES)
        {
            m_connections[conn_index].conn_handle  = conn_handle;
            m_connections[conn_index].peer_id      = PM_PEER_ID_INVALID;
            m_connections[conn_index].peer_address = *p_ble_addr;
        }
    }
    return conn_index;
}