/** ********************************************************************************************************* * Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved. ********************************************************************************************************* * @file gap_le_rf.h * @brief Head file for GAP RF * @details * @author * @date 2020-06-18 * @version v0.8 * ********************************************************************************************************* */ /*============================================================================* * Define to prevent recursive inclusion *============================================================================*/ #ifndef GAP_LE_RF_H #define GAP_LE_RF_H #ifdef __cplusplus extern "C" { #endif /*============================================================================* * Header Files *============================================================================*/ #include "upperstack_config.h" #include "gap_le.h" /** @addtogroup GAP GAP Module * @{ */ /** @addtogroup GAP_LE GAP LE Module * @{ */ /** @addtogroup GAP_LE_RF GAP LE RF Module * @{ */ /*============================================================================* * Macros *============================================================================*/ /** @defgroup GAP_LE_RF_Exported_Macros GAP LE Rf Exported Macros * @{ */ /** @defgroup GAP_LE_RF_MSG_Types GAP LE RF Msg Types * @{ */ #define GAP_MSG_LE_RF_INFO 0xD1 /** End of GAP_LE_RF_MSG_Types * @} */ /** @defgroup GAP_LE_RF_MSG_Opcodes GAP LE RF Msg Opcodes * @{ */ #define GAP_LE_RF_READ_RF_PATH_COMPENSATION 0x0000 //!Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; cause = le_rf_read_rf_path_compensation(); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_0_RF_PATH_SUPPORT case GAP_LE_RF_READ_RF_PATH_COMPENSATION: APP_PRINT_INFO3("GAP_LE_RF_READ_RF_PATH_COMPENSATION:cause 0x%x, rf tx path comp value %d, rf rx path comp value %d", p_le_rf_cb->data.p_le_rf_read_rf_path_compensation_rsp->cause, p_le_rf_cb->data.p_le_rf_read_rf_path_compensation_rsp->rf_tx_path_comp_value, p_le_rf_cb->data.p_le_rf_read_rf_path_compensation_rsp->rf_rx_path_comp_value); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_read_rf_path_compensation(void); /** * @brief Indicate the RF path gain or loss between the RF transceiver and the antenna contributed * by intermediate components. * * @param[in] rf_tx_path_comp_value RF Tx Path Compensation Range: -128.0 dB (0xFB00) to 128.0 dB (0x0500) Units: 0.1 dB * @param[in] rf_rx_path_comp_value RF Rx Path Compensation Range: -128.0 dB (0xFB00) to 128.0 dB (0x0500) Units: 0.1 dB * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; cause = le_rf_write_rf_path_compensation(rf_tx_path_comp_value, rf_rx_path_comp_value); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_0_RF_PATH_SUPPORT case GAP_LE_RF_WRITE_RF_PATH_COMPENSATION: APP_PRINT_INFO1("GAP_LE_RF_WRITE_RF_PATH_COMPENSATION:cause 0x%x", p_le_rf_cb->data.le_rf_cause.cause); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_write_rf_path_compensation(int16_t rf_tx_path_comp_value, int16_t rf_rx_path_comp_value); #endif #if F_BT_LE_5_2_POWER_CONTROL_SUPPORT /** * @brief Read the current and maximum transmit power levels of the local Controller on the ACL connection and the PHY. * Read result will be returned by @ref app_gap_callback with cb_type @ref GAP_MSG_LE_RF_INFO with * opcode @ref GAP_LE_RF_ENHANCED_READ_TRANSMIT_POWER_LEVEL. * * @param[in] conn_id Connection ID * @param[in] phy phy physical: @ref T_GAP_LE_RF_POWER_CONTROL_PHYS_TYPE. * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * @retval GAP_CAUSE_NON_CONN: Set request sent fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; uint8_t conn_id; cause = le_rf_enhanced_read_transmit_power_level(conn_id, phy); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_2_POWER_CONTROL_SUPPORT case GAP_LE_RF_ENHANCED_READ_TRANSMIT_POWER_LEVEL: APP_PRINT_INFO5("GAP_LE_RF_ENHANCED_READ_TRANSMIT_POWER_LEVEL:conn id %d, cause 0x%x, phy %d, cur trans power level %d, max trans power level %d", p_le_rf_cb->data.p_le_rf_enhanced_read_transmit_power_level_rsp->conn_id, p_le_rf_cb->data.p_le_rf_enhanced_read_transmit_power_level_rsp->cause, p_le_rf_cb->data.p_le_rf_enhanced_read_transmit_power_level_rsp->phy, p_le_rf_cb->data.p_le_rf_enhanced_read_transmit_power_level_rsp->cur_tx_power_level, p_le_rf_cb->data.p_le_rf_enhanced_read_transmit_power_level_rsp->max_tx_power_level); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_enhanced_read_transmit_power_level(uint8_t conn_id, T_GAP_LE_RF_POWER_CONTROL_PHYS_TYPE phy); /** * @brief Read the transmit power level used by the remote Controller on the ACL connection and the PHY. * Read result will be returned by @ref app_gap_callback with cb_type @ref GAP_MSG_LE_RF_INFO with * opcode @ref GAP_LE_RF_TRANSMIT_POWER_REPORTING_INFO. * * @param[in] conn_id Connection ID * @param[in] phy phy physical: @ref T_GAP_LE_RF_POWER_CONTROL_PHYS_TYPE. * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * @retval GAP_CAUSE_NON_CONN: Set request sent fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; uint8_t conn_id; cause = le_rf_read_remote_transmit_power_level(conn_id, phy); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_2_POWER_CONTROL_SUPPORT case GAP_LE_RF_READ_REMOTE_TRANSMIT_POWER_LEVEL: APP_PRINT_INFO2("GAP_LE_RF_SET_TRANSMIT_POWER_REPORTING_ENABLE:conn id %d, cause 0x%x", p_le_rf_cb->data.p_le_rf_read_remote_transmit_power_level_rsp->conn_id, p_le_rf_cb->data.p_le_rf_read_remote_transmit_power_level_rsp->cause); break; case GAP_LE_RF_TRANSMIT_POWER_REPORTING_INFO: APP_PRINT_INFO7("GAP_LE_RF_TRANSMIT_POWER_REPORTING_INFO:conn id %d, cause 0x%x, reason 0x%x, phy %d, transmit power level %d, transmit power level flag %d, delta %d", p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->conn_id, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->cause, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->reason, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->phy, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->tx_power_level, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->tx_power_level_flag, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->delta); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_read_remote_transmit_power_level(uint8_t conn_id, T_GAP_LE_RF_POWER_CONTROL_PHYS_TYPE phy); /** * @brief Enable or disable the reporting to the local Host of transmit power level changes * in the local and remote Controllers for the ACL connection. * * @param[in] conn_id Connection ID * @param[in] local_enable enable or disable local transmit power reports * @param[in] remote_enable enable or disable remote transmit power reports * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * @retval GAP_CAUSE_NON_CONN: Set request sent fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; uint8_t conn_id; cause = le_rf_set_transmit_power_reporting_enable(conn_id, local_enable, remote_enable); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_2_POWER_CONTROL_SUPPORT case GAP_LE_RF_SET_TRANSMIT_POWER_REPORTING_ENABLE: APP_PRINT_INFO2("GAP_LE_RF_SET_TRANSMIT_POWER_REPORTING_ENABLE:conn id %d, cause 0x%x", p_le_rf_cb->data.p_le_rf_set_transmit_power_reporting_enable_rsp->conn_id, p_le_rf_cb->data.p_le_rf_set_transmit_power_reporting_enable_rsp->cause); break; case GAP_LE_RF_TRANSMIT_POWER_REPORTING_INFO: APP_PRINT_INFO7("GAP_LE_RF_TRANSMIT_POWER_REPORTING_INFO:conn id %d, cause 0x%x, reason 0x%x, phy %d, transmit power level %d, transmit power level flag %d, delta %d", p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->conn_id, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->cause, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->reason, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->phy, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->tx_power_level, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->tx_power_level_flag, p_le_rf_cb->data.p_le_rf_transmit_power_reporting_info->delta); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_set_transmit_power_reporting_enable(uint8_t conn_id, uint8_t local_enable, uint8_t remote_enable); #endif #if F_BT_LE_5_2_PATH_LOSS_MONITORING_SUPPORT /** * @brief Set the path loss threshold reporting parameters for the ACL connection * * @param[in] conn_id Connection ID * @param[in] high_threshold High threshold for the path loss Units: dB 0xFF: High Threshold unused * @param[in] high_hysteresis Hysteresis value for the high threshold Units: dB * @param[in] low_threshold Low threshold for the path loss Units: dB * @param[in] low_hysteresis Hysteresis value for the low threshold Units: dB * @param[in] min_time_spent Minimum time in number of connection events to be observed once the path crosses the threshold before an event is generated. * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * @retval GAP_CAUSE_NON_CONN: Set request sent fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; uint8_t conn_id; cause = le_rf_set_path_loss_reporting_params(conn_id, high_threshold, high_hysteresis, low_threshold, low_hysteresis, min_time_spent); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_2_PATH_LOSS_MONITORING_SUPPORT case GAP_LE_RF_SET_PATH_LOSS_REPORTING_PARAMS: APP_PRINT_INFO2("GAP_LE_RF_SET_PATH_LOSS_REPORTING_PARAMS:conn id %d, cause 0x%x", p_le_rf_cb->data.p_le_rf_set_path_loss_reporting_params_rsp->conn_id, p_le_rf_cb->data.p_le_rf_set_path_loss_reporting_params_rsp->cause); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_set_path_loss_reporting_params(uint8_t conn_id, uint8_t high_threshold, uint8_t high_hysteresis, uint8_t low_threshold, uint8_t low_hysteresis, uint16_t min_time_spent); /** * @brief Enable or disable path loss reporting. * * @param[in] conn_id Connection ID * @param[in] enable enable or disable path loss reporting * @retval GAP_CAUSE_SUCCESS: Send request success. * @retval GAP_CAUSE_SEND_REQ_FAILED: Send request fail. * @retval GAP_CAUSE_NON_CONN: Set request sent fail. * * Example usage * \code{.c} void test(void) { T_GAP_CAUSE cause; uint8_t conn_id; cause = le_rf_set_path_loss_reporting_enable(conn_id, enable); } T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data) { T_APP_RESULT result = APP_RESULT_SUCCESS; T_LE_CB_DATA *p_data = (T_LE_CB_DATA *)p_cb_data; T_GAP_LE_RF_CB *p_le_rf_cb = NULL; switch (cb_type) { ... case GAP_MSG_LE_RF_INFO: APP_PRINT_INFO0("GAP_MSG_LE_RF_INFO"); p_le_rf_cb = (T_GAP_LE_RF_CB *)p_data->p_le_cb_data; switch (p_le_rf_cb->opcode) { ... #if F_BT_LE_5_2_PATH_LOSS_MONITORING_SUPPORT case GAP_LE_RF_SET_PATH_LOSS_REPORTING_ENABLE: APP_PRINT_INFO2("GAP_LE_RF_SET_PATH_LOSS_REPORTING_ENABLE:conn id %d, cause 0x%x", p_le_rf_cb->data.p_le_rf_set_path_loss_reporting_enable_rsp->conn_id, p_le_rf_cb->data.p_le_rf_set_path_loss_reporting_enable_rsp->cause); break; case GAP_LE_RF_PATH_LOSS_THRESHOLD_INFO: APP_PRINT_INFO3("GAP_LE_RF_PATH_LOSS_THRESHOLD_INFO:conn id %d, current path loss %d, zone entered %d", p_le_rf_cb->data.p_le_rf_path_loss_threshold_info->conn_id, p_le_rf_cb->data.p_le_rf_path_loss_threshold_info->current_path_loss, p_le_rf_cb->data.p_le_rf_path_loss_threshold_info->zone_entered); break; #endif ... } ... } * \endcode */ T_GAP_CAUSE le_rf_set_path_loss_reporting_enable(uint8_t conn_id, uint8_t enable); #endif #ifdef __cplusplus } #endif #endif /* GAP_LE_RF_H */