nRF52发射功率配置
#define TX_POWER_LEVEL (-8)
static void advertising_init(void)
{
uint32_t err_code;
ble_advertising_init_t init;
int8_t tx_power_level = TX_POWER_LEVEL;
memset(&init, 0, sizeof(init));
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
init.advdata.include_appearance = false;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
init.advdata.p_tx_power_level = &tx_power_level;
init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
init.srdata.uuids_complete.p_uuids = m_adv_uuids;
init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
init.evt_handler = on_adv_evt;
err_code = ble_advertising_init(&m_advertising, &init);
APP_ERROR_CHECK(err_code);
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}
static void tx_power_set(void)
{
ret_code_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, TX_POWER_LEVEL);
APP_ERROR_CHECK(err_code);
}
获取接收信号强度RSSI
int8_t rssi=0;
uint8_t p_ch_index;
sd_ble_gap_rssi_start(m_conn_handle,BLE_GAP_RSSI_THRESHOLD_INVALID,0);
sd_ble_gap_rssi_get(m_conn_handle, &rssi,&p_ch_index);
NRF_LOG_INFO("rssi: %d",rssi);
NRF_LOG_INFO("Channel: %d",p_ch_index);