NORDIC ble RSSI

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    ret_code_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        /* 连接事件 */
        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO("Connected");
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = sd_ble_gap_rssi_start(m_conn_handle, 2, 2); //启动rssi
            APP_ERROR_CHECK(err_code);
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
            APP_ERROR_CHECK(err_code);
            ble_conn_handler();
            break;

        /* RSSI改变事件 */
        case BLE_GAP_EVT_RSSI_CHANGED:
            ble_rssi = p_ble_evt->evt.gap_evt.params.rssi_changed.rssi; //获取rssi
            break;
        
        default:
            // No implementation needed.
            break;
    }
}

猜你喜欢

转载自www.cnblogs.com/yeshenmeng/p/11713620.html
今日推荐