본문 바로가기
임베디드.일렉트로닉스/nRF52

nRF52 . BLE . Tx Power 설정.

by i.got.it 2023. 1. 29.

 

 

 

BLE Advertising 상태의 Tx Power 설정. 

-  함수 sd_ble_gap_tx_power_set ( , , ) 호출하면서 마지막 인자로 설정하려는 출력 파워 기록한다. 

- advertising init 과정에서 함수 ble_advertising_init 호출 이후 advertising  핸들 정상 확보된 이후에만  sd_ble_gap_tx_power_set( ) 호출가능하다. 

- 아래 호출 예는 ble_advertising_init 호출 직후 즉시 tx power 설정 하는 예제.  


static void advertising_init()
{

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);
    
    
    //BLE TX Power set for Advertising. after ble_advertising_init(&m_advertising,)
    sd_ble_gap_tx_power_set(
      BLE_GAP_TX_POWER_ROLE_ADV // uint8_t role
      , m_advertising.adv_handle //uint16_t handle
      , 0 // int8_t tx_power. nRF52840.-20~+8 4dB step.  -20,-16,-12,-8,-4,0,4,,8
    );

}

 

BLE Connection 상태의 Tx Power 설정. 

- 별도로 설정하지 않은 경우는  앞의 advertising 상태에서 설정한 동일 출력 파워 적용됨. 

- ble connection handle (sdk 예제코드에서 변수 m_conn_handle 로 되어있음.)정상 확보 상태에서만 sd_ble_gap_tx_power_set ( , , )  호출가능하다. 

 


    //BLE TX Power set for ble connection state. 
    sd_ble_gap_tx_power_set(
      BLE_GAP_TX_POWER_ROLE_CONN // uint8_t role
      , m_conn_handle //uint16_t handle
      , 0 // int8_t tx_power. nRF52840.-20~+8 4dB step.  -20,-16,-12,-8,-4,0,4,,8
    );

 

 

BLE Central 인 경우 Tx Power 설정. 

- sd_ble_gap_tx_power_set ( , , ) 1번 인자는 BLE_GAP_TX_POWER_ROLE_SCAN_INIT 로 한다. 이 경우 2번 인자 handle 은 함수 내부적으로 참조되지 않음. 

- 아무 시점에나 호출해도 됨.  


    //BLE TX Power set for Central
    
    sd_ble_gap_tx_power_set(
      BLE_GAP_TX_POWER_ROLE_SCAN_INIT // uint8_t role
      , 0 // uint16_t handle
      , 0 // int8_t tx_power. nRF52840.-20~+8 4dB step.  -20,-16,-12,-8,-4,0,4,,8
    );

 

 

 

 

 

 

BLE . RF 출력파워 설정 함수 

 



uint32_t sd_ble_gap_tx_power_set	(	uint8_t 	role,
uint16_t 	handle,
int8_t 	tx_power 
)

 

Set the radio's transmit power.Parameters

[in] role The role to set the transmit power for, see BLE_GAP_TX_POWER_ROLES for possible roles.
[in] handle The handle parameter is interpreted depending on role:
[in] tx_power Radio transmit power in dBm (see note for accepted values).

NoteSupported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm. In addition, on some chips following values are supported: +2dBm, +5dBm, +6dBm, +7dBm and +8dBm. Setting these values on a chip that does not support them will result in undefined behaviour.The initiator will have the same transmit power as the scanner.When a connection is created it will inherit the transmit power from the initiator or advertiser leading to the connection.Return values

NRF_SUCCESS Successfully changed the transmit power.
NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.

 

from : sd_ble_gap_tx_power_set - S140 SoftDevice version 7.3.0

 

 

 

 

연관 

 

 

nRF52 . BLE . RSSI

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) {

igotit.tistory.com

 

상위정리

 

STM32. nRF52. ESP32. EFM8. EFM32. PSoC 활용 정리.

STM32. nRF52. ESP32. EFM8. EFM32. PSoC 총정리 제조사 칩 주요특징 실리콘랩 8bit MCU EFM8 시리즈 32bit EFM32 시리즈 EFM8 싸다. STM STM32 . 최고 항상 만족. Cypress pSoC pSoC6 은 기대해볼만. NORDIC nRF52 블투 무선솔루

igotit.tistory.com

 

 

 


첫 등록 : 2019.01.23 

최종 수정 : 2023.01.29

단축 주소 : https://igotit.tistory.com/4205


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5