nRF52832 ------增强广播功率为4db

nRF52832 ------增强广播功率为4db

#define TX_POWER_LEVEL                      (4)                                     
	//(1)第一个参数设置对应角色的功耗
	//****1)BLE_GAP_TX_POWER_ROLE_ADV:广播发射功率
	//****2)BLE_GAP_TX_POWER_ROLE_SCAN_INIT:扫描或发起者功率
	//****3)BLE_GAP_TX_POWER_ROLE_CONN:连接时的功率
	//(2)第二个参数设置为广播的连接句柄:BLE_ADVERTISING_DEF(m_advertising); 定义实体
	//****广播初始化后m_advertising.adv_handle有效,因此sd_ble_gap_tx_power_set要在广播初始化后调用,否则会报m_advertising.adv_handle无效错误
	//(3)第三个参数设置功率的层级-40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm,填写对应的数字即可,例如:-40,4
    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);
/**@brief Set the radio's transmit power.
 *
 * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for
 *                 possible roles.
 * @param[in] handle   The handle parameter is interpreted depending on role:
 *                     - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
 *                     - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle,
 *                       will use the specified transmit power, and include it in the advertising packet headers if
 *                       @ref ble_gap_adv_properties_t::include_tx_power set.
 *                     - For all other roles handle is ignored.
 * @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
 *
  * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm.
  * @note The initiator will have the same transmit power as the scanner.
 * @note When a connection is created it will inherit the transmit power from the initiator or
 *       advertiser leading to the connection.
 *
 * @retval ::NRF_SUCCESS Successfully changed the transmit power.
 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
 * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
 */
SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power));

写博客不容易,需要大家多多支持。想了解更多,本人也可以提供有赏服务
nRF52832 ------增强广播功率为4db_第1张图片

你可能感兴趣的:(nRF52832)