BLE connection 상태의 RSSI
ble_evt_handler 내부에서 BLE_GAP_EVT_RSSI_CHANGED 추가해둔 상태에서, 함수 sd_ble_gap_rssi_start(,,) 호출하면 rssi 값 확보가능
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
switch (p_ble_evt->header.evt_id)
{
.. 중략.
case BLE_GAP_EVT_RSSI_CHANGED:
//int8_t Received Signal Strength Indication in dBm.
NRF_LOG_INFO("Changed RSSI : %d", p_ble_evt->evt.gap_evt.params.rssi_changed.rssi);
break;
}// switch
}
함수 sd_ble_gap_rssi_start()
sd_ble_gap_rssi_start(
uint16_t conn_handle
, uint8_t threshold_dbm
, uint8_t skip_count
)
/////// args
/*
uint16_t conn_handle
Connection handle.
uint8_t threshold_dbm
Minimum change in dBm before triggering the @ref BLE_GAP_EVT_RSSI_CHANGED event.
Events are disabled if threshold_dbm equals @ref BLE_GAP_RSSI_THRESHOLD_INVALID.
uint8_t skip_count
Number of RSSI samples with a change of threshold_dbm or more before sending
a new @ref BLE_GAP_EVT_RSSI_CHANGED event.
*/
함수 sd_ble_gap_rssi_start() 호출예.
ble_evt_handler 내부 case BLE_GAP_EVT_CONNECTED: 에서 sd_ble_gap_rssi_start() 호출예.
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
NRF_LOG_INFO("Connected");
//err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
//APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
APP_ERROR_CHECK(err_code);
sd_ble_gap_rssi_start(m_conn_handle,5,10); // RSSI
break;
... 중략.
실행 결과.
- SES Debug Terminal 에서 확인.
BLE Central 에서 peripheral 의 advertising 상태의 rssi
BLE central 측의 ble_evt_handler 내부에서 BLE_GAP_EVT_ADV_REPORT: 에서 확보가능.
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
switch (p_ble_evt->header.evt_id)
{
.. 중략.
// only for available central device are scanning and detects an advertising packet.
case BLE_GAP_EVT_ADV_REPORT:
NRF_LOG_INFO("advertising RSSI: %d", p_ble_evt->evt.gap_evt.params.adv_report.rssi);
break;
}// switch
}
연관
상위정리
첫 등록 : 2020.03.06
최종 수정 : 2023.01.30
단축 주소 : https://igotit.tistory.com/4206
'임베디드.일렉트로닉스 > nRF52' 카테고리의 다른 글
nRF52 . application timer . RTC1 . LFCLK (0) | 2023.02.06 |
---|---|
nRF5340 . 블루투스 5.3 . LE Audio (0) | 2023.01.31 |
nRF52 . BLE . Tx Power 설정. (0) | 2023.01.29 |
nRF52 . BLE . 연속 advertising . fatal error (0) | 2023.01.29 |
nRF52 . SES . 빌드 오류 해결 . __vfprintf.h: No such file or directory (0) | 2023.01.20 |
댓글