mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-06 10:07:55 +00:00
Added API to send VSC to set power control rssi
This commit is contained in:
committed by
Abhinav Kudnar
parent
066bfccb8b
commit
f2c0ef7e80
@@ -76,6 +76,82 @@ int ble_gap_wl_tx_rmv(const ble_addr_t *addrs);
|
||||
*/
|
||||
int ble_gap_wl_tx_clear(void);
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
#if MYNEWT_VAL(BLE_HCI_VS)
|
||||
|
||||
#define ESP_1M_LOW (-70)
|
||||
#define ESP_1M_HIGH (-60)
|
||||
#define ESP_2M_LOW (-68)
|
||||
#define ESP_2M_HIGH (-58)
|
||||
#define ESP_S2_LOW (-75)
|
||||
#define ESP_S2_HIGH (-65)
|
||||
#define ESP_S8_LOW (-80)
|
||||
#define ESP_S8_HIGH (-70)
|
||||
#define ESP_MIN_TIME (15)
|
||||
|
||||
/* Represents the set of lower / upper values of rssi of given chip
|
||||
*
|
||||
* Lower Limit Values Range: -54 to -80
|
||||
* Upper Limit Values Range: -40 to -70
|
||||
*
|
||||
* */
|
||||
struct ble_gap_set_auto_pcl_params {
|
||||
|
||||
/* Connection Handle of the ACL Link */
|
||||
int16_t conn_handle;
|
||||
|
||||
/* The Lower RSSI limit when 1M phy is used */
|
||||
int8_t m1_lower_limit;
|
||||
|
||||
/* The Upper RSSI limit when 1M phy is used */
|
||||
int8_t m1_upper_limit;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
/* The Lower RSSI limit when 2M phy is used */
|
||||
int8_t m2_lower_limit;
|
||||
|
||||
/* The Upper RSSI limit when 2M phy is used */
|
||||
int8_t m2_upper_limit;
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
/* The Lower RSSI limit when S2 Coded phy is used */
|
||||
int8_t s2_lower_limit;
|
||||
|
||||
/* The Upper RSSI limit when S2 Coded phy is used */
|
||||
int8_t s2_upper_limit;
|
||||
|
||||
/* The Lower RSSI limit when S8 Coded phy is used */
|
||||
int8_t s8_lower_limit;
|
||||
|
||||
/* The Upper RSSI limit when S8 Coded phy is used */
|
||||
int8_t s8_upper_limit;
|
||||
#endif
|
||||
|
||||
/* Number of tx/rx packets to wait before initiating the LE power control Request.
|
||||
* The default value is (min time spent variable = (tx/rxpackets 15)).*/
|
||||
uint8_t min_time_spent;
|
||||
};
|
||||
|
||||
/**
|
||||
* This API is used to initiate the LE Power Control Request Procedure for the ACL connection
|
||||
* identified by the conn_handle parameter and other parameters.
|
||||
*
|
||||
* The parameters passed are used by controller for the subsquent LE Power Control Requests
|
||||
* that get initiated across all the connections.
|
||||
*
|
||||
* The Min_Time_Spent parameter indicates the number of tx/rx packets that the Controller
|
||||
* shall observe the RSSI has crossed the threshold (upper and lower limit of active phy)
|
||||
* before the controller initiates the LE POWER CONTROL PROCEDURE in the link layer.
|
||||
*
|
||||
* @param params Instance of ble_gap_set_auto_pcl_params with different parameters
|
||||
*
|
||||
* @return 0 on success; nonzero on failure.
|
||||
*/
|
||||
int ble_gap_set_auto_pcl_param(struct ble_gap_set_auto_pcl_params *params);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7130,6 +7130,75 @@ ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle,
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_POWER_CONTROL) && MYNEWT_VAL(BLE_HCI_VS)
|
||||
static int
|
||||
ble_gap_pcl_param_validate(struct ble_gap_set_auto_pcl_params *params)
|
||||
{
|
||||
if(params->m1_upper_limit < params->m1_lower_limit ||
|
||||
params->m2_upper_limit < params->m2_lower_limit ||
|
||||
params->s2_upper_limit < params->s2_lower_limit ||
|
||||
params->s8_upper_limit < params->s8_lower_limit)
|
||||
return BLE_HS_EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ble_gap_set_auto_pcl_param(struct ble_gap_set_auto_pcl_params *params)
|
||||
{
|
||||
int8_t vs_cmd[11] = { 0, 0,
|
||||
ESP_1M_LOW, ESP_1M_HIGH,
|
||||
ESP_2M_LOW, ESP_2M_HIGH,
|
||||
ESP_S2_LOW, ESP_S2_HIGH,
|
||||
ESP_S8_LOW, ESP_S8_HIGH,
|
||||
ESP_MIN_TIME };
|
||||
|
||||
if (!ble_hs_is_enabled()) {
|
||||
return BLE_HS_EDISABLED;
|
||||
}
|
||||
|
||||
if(ble_gap_pcl_param_validate(params))
|
||||
return BLE_HS_EINVAL;
|
||||
|
||||
vs_cmd[0] = (uint8_t)(params->conn_handle & 0xFF);
|
||||
vs_cmd[1] = (uint8_t)((params->conn_handle >> 8) & 0xFF);
|
||||
|
||||
if(params->m1_lower_limit)
|
||||
vs_cmd[2] = params->m1_lower_limit;
|
||||
|
||||
if(params->m1_upper_limit)
|
||||
vs_cmd[3] = params->m1_upper_limit;
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
if(params->m2_lower_limit)
|
||||
vs_cmd[4] = params->m2_lower_limit;
|
||||
|
||||
if(params->m2_upper_limit)
|
||||
vs_cmd[5] = params->m2_upper_limit;
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
if(params->s2_lower_limit)
|
||||
vs_cmd[6] = params->s2_lower_limit;
|
||||
|
||||
if(params->s2_upper_limit)
|
||||
vs_cmd[7] = params->s2_upper_limit;
|
||||
|
||||
if(params->s8_lower_limit)
|
||||
vs_cmd[8] = params->s8_lower_limit;
|
||||
|
||||
if(params->s8_upper_limit)
|
||||
vs_cmd[9] = params->s8_upper_limit;
|
||||
#endif
|
||||
|
||||
if(params->min_time_spent)
|
||||
vs_cmd[10] = params->min_time_spent;
|
||||
|
||||
return ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_PCL_SET_RSSI ,
|
||||
&vs_cmd, sizeof(vs_cmd), NULL, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ble_gap_deinit(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user