mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
Merge branch 'feat/bt_distance_test' into 'master'
feat(bt): Add APIs to read ACL real RSSI and read/write tx power of inq/iscan/page/pscan/ACL Closes BT-4155 See merge request espressif/esp-idf!45601
This commit is contained in:
@@ -56,6 +56,97 @@ static void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read
|
||||
|
||||
#define BTM_DEV_REPLY_TIMEOUT 3 /* 3 second timeout waiting for responses */
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
static void btm_read_acl_real_rssi_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_acl_real_rssi_cmpl_cb;
|
||||
tBTM_ACL_REAL_RSSI_RESULTS results;
|
||||
UINT16 handle = 0;
|
||||
tACL_CONN *p_acl_cb = NULL;
|
||||
|
||||
btu_stop_timer(&btm_cb.devcb.acl_real_rssi_timer);
|
||||
btm_cb.devcb.p_acl_real_rssi_cmpl_cb = NULL;
|
||||
|
||||
memset(&results, 0, sizeof(results));
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
results.hci_status = HCI_ERR_UNSPECIFIED;
|
||||
|
||||
if (p1 == NULL || p1->p_param_buf == NULL || p1->param_len < 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
UINT8 *p = p1->p_param_buf;
|
||||
STREAM_TO_UINT8(results.hci_status, p);
|
||||
if (results.hci_status != HCI_SUCCESS) {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Expected payload (after status): [handle:2][rssi:1]
|
||||
if (p1->param_len < 1 + 3) {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
goto out;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT16(handle, p);
|
||||
STREAM_TO_UINT8(results.rssi, p);
|
||||
results.status = BTM_SUCCESS;
|
||||
|
||||
p_acl_cb = btm_handle_to_acl(handle);
|
||||
if (p_acl_cb) {
|
||||
memcpy(results.rem_bda, p_acl_cb->remote_addr, BD_ADDR_LEN);
|
||||
}
|
||||
|
||||
out:
|
||||
if (p_cb) {
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_ReadAclRealRSSI(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tACL_CONN *p;
|
||||
tBTM_ACL_REAL_RSSI_RESULTS result;
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
|
||||
/* If someone already waiting on the result, do not allow another */
|
||||
if (btm_cb.devcb.p_acl_real_rssi_cmpl_cb) {
|
||||
result.status = BTM_BUSY;
|
||||
(*p_cb)(&result);
|
||||
return (BTM_BUSY);
|
||||
}
|
||||
|
||||
p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
|
||||
if (p != (tACL_CONN *)NULL) {
|
||||
btu_start_timer(&btm_cb.devcb.acl_real_rssi_timer, BTU_TTYPE_BTM_ACL, BTM_DEV_REPLY_TIMEOUT);
|
||||
btm_cb.devcb.p_acl_real_rssi_cmpl_cb = p_cb;
|
||||
|
||||
UINT8 param[2];
|
||||
UINT8 *pp = param;
|
||||
UINT16_TO_STREAM(pp, p->hci_handle);
|
||||
|
||||
tBTM_STATUS st = BTM_VendorSpecificCommand(HCI_VENDOR_BT_RD_ACL_REAL_RSSI,
|
||||
sizeof(param),
|
||||
param,
|
||||
btm_read_acl_real_rssi_vsc_cmpl_cb);
|
||||
if (st != BTM_CMD_STARTED) {
|
||||
btm_cb.devcb.p_acl_real_rssi_cmpl_cb = NULL;
|
||||
btu_stop_timer(&btm_cb.devcb.acl_real_rssi_timer);
|
||||
result.status = BTM_NO_RESOURCES;
|
||||
(*p_cb)(&result);
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
return (BTM_CMD_STARTED);
|
||||
}
|
||||
|
||||
/* If here, no BD Addr found */
|
||||
result.status = BTM_UNKNOWN_ADDR;
|
||||
(*p_cb)(&result);
|
||||
return (BTM_UNKNOWN_ADDR);
|
||||
}
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_acl_init
|
||||
|
||||
454
components/bt/host/bluedroid/stack/btm/btm_bredr_pwr_ctrl.c
Normal file
454
components/bt/host/bluedroid/stack/btm/btm_bredr_pwr_ctrl.c
Normal file
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains functions for BR/EDR power control.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "stack/bt_types.h"
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/btu.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "btm_int.h"
|
||||
#include "stack/hcidefs.h"
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#define BTM_BREDR_PWR_CTRL_REPLY_TIMEOUT 3 /* 3 second timeout waiting for responses */
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
static void btm_read_new_conn_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_read_new_conn_tx_pwr_lvl_cmpl_cb;
|
||||
tBTM_READ_NEW_CONN_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
btu_stop_timer(&btm_cb.devcb.read_new_conn_tx_pwr_lvl_timer);
|
||||
btm_cb.devcb.p_read_new_conn_tx_pwr_lvl_cmpl_cb = NULL;
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.status = BTM_ERR_PROCESSING;
|
||||
result.hci_status = HCI_ERR_UNSPECIFIED;
|
||||
|
||||
if (p1 == NULL || p1->p_param_buf == NULL || p1->param_len < 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
UINT8 *p = p1->p_param_buf;
|
||||
STREAM_TO_UINT8(result.hci_status, p);
|
||||
if (result.hci_status != HCI_SUCCESS) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (p1->param_len < 1 + 2) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(result.pwr_lvl_min, p);
|
||||
STREAM_TO_UINT8(result.pwr_lvl_max, p);
|
||||
result.status = BTM_SUCCESS;
|
||||
|
||||
out:
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_ReadNewConnTxPwrLvl(tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTM_STATUS status;
|
||||
tBTM_READ_NEW_CONN_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
if (btm_cb.devcb.p_read_new_conn_tx_pwr_lvl_cmpl_cb) {
|
||||
result.status = BTM_BUSY;
|
||||
(*p_cb)(&result);
|
||||
return BTM_BUSY;
|
||||
}
|
||||
|
||||
btu_start_timer(&btm_cb.devcb.read_new_conn_tx_pwr_lvl_timer,
|
||||
BTU_TTYPE_BTM_BREDR_PWR_CTRL,
|
||||
BTM_BREDR_PWR_CTRL_REPLY_TIMEOUT);
|
||||
btm_cb.devcb.p_read_new_conn_tx_pwr_lvl_cmpl_cb = p_cb;
|
||||
|
||||
status = BTM_VendorSpecificCommand(HCI_VENDOR_BT_RD_NEW_CONN_TX_PWR_LVL,
|
||||
0, NULL, btm_read_new_conn_tx_pwr_lvl_vsc_cmpl_cb);
|
||||
if (status != BTM_CMD_STARTED) {
|
||||
btm_cb.devcb.p_read_new_conn_tx_pwr_lvl_cmpl_cb = NULL;
|
||||
btu_stop_timer(&btm_cb.devcb.read_new_conn_tx_pwr_lvl_timer);
|
||||
result.status = status;
|
||||
(*p_cb)(&result);
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
|
||||
static void btm_write_new_conn_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_write_new_conn_tx_pwr_lvl_cmpl_cb;
|
||||
tBTM_WRITE_NEW_CONN_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
btu_stop_timer(&btm_cb.devcb.write_new_conn_tx_pwr_lvl_timer);
|
||||
btm_cb.devcb.p_write_new_conn_tx_pwr_lvl_cmpl_cb = NULL;
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.status = BTM_ERR_PROCESSING;
|
||||
result.hci_status = HCI_ERR_UNSPECIFIED;
|
||||
|
||||
if (p1 == NULL || p1->p_param_buf == NULL || p1->param_len < 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
UINT8 *p = p1->p_param_buf;
|
||||
STREAM_TO_UINT8(result.hci_status, p);
|
||||
if (result.hci_status != HCI_SUCCESS) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
result.status = BTM_SUCCESS;
|
||||
|
||||
out:
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_WriteNewConnTxPwrLvl(INT8 pwr_lvl_min, INT8 pwr_lvl_max, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTM_STATUS status;
|
||||
tBTM_WRITE_NEW_CONN_TX_PWR_LVL_RESULTS result;
|
||||
UINT8 param[2];
|
||||
UINT8 *p = param;
|
||||
|
||||
if (btm_cb.devcb.p_write_new_conn_tx_pwr_lvl_cmpl_cb) {
|
||||
result.status = BTM_BUSY;
|
||||
(*p_cb)(&result);
|
||||
return BTM_BUSY;
|
||||
}
|
||||
|
||||
btu_start_timer(&btm_cb.devcb.write_new_conn_tx_pwr_lvl_timer,
|
||||
BTU_TTYPE_BTM_BREDR_PWR_CTRL,
|
||||
BTM_BREDR_PWR_CTRL_REPLY_TIMEOUT);
|
||||
btm_cb.devcb.p_write_new_conn_tx_pwr_lvl_cmpl_cb = p_cb;
|
||||
|
||||
INT8_TO_STREAM(p, pwr_lvl_min);
|
||||
INT8_TO_STREAM(p, pwr_lvl_max);
|
||||
status = BTM_VendorSpecificCommand(HCI_VENDOR_BT_WR_NEW_CONN_TX_PWR_LVL,
|
||||
sizeof(param), param, btm_write_new_conn_tx_pwr_lvl_vsc_cmpl_cb);
|
||||
if (status != BTM_CMD_STARTED) {
|
||||
btm_cb.devcb.p_write_new_conn_tx_pwr_lvl_cmpl_cb = NULL;
|
||||
btu_stop_timer(&btm_cb.devcb.write_new_conn_tx_pwr_lvl_timer);
|
||||
result.status = status;
|
||||
(*p_cb)(&result);
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
|
||||
static void btm_read_tx_pwr_lvl_vsc_cmpl_cb(tBTM_TX_PWR_LVL_TYPE type, tBTM_VSC_CMPL *p1,
|
||||
TIMER_LIST_ENT *timer, tBTM_CMPL_CB **pp_cb)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = *pp_cb;
|
||||
tBTM_READ_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
btu_stop_timer(timer);
|
||||
*pp_cb = NULL;
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = BTM_ERR_PROCESSING;
|
||||
result.hci_status = HCI_ERR_UNSPECIFIED;
|
||||
|
||||
if (p1 == NULL || p1->p_param_buf == NULL || p1->param_len < 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
UINT8 *p = p1->p_param_buf;
|
||||
STREAM_TO_UINT8(result.hci_status, p);
|
||||
if (result.hci_status != HCI_SUCCESS) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (p1->param_len < 1 + 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(result.tx_power, p);
|
||||
result.status = BTM_SUCCESS;
|
||||
|
||||
out:
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
}
|
||||
|
||||
static void btm_read_inq_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_read_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_INQ, p1,
|
||||
&btm_cb.devcb.read_inq_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_read_inq_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
|
||||
static void btm_read_page_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_read_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_PAGE, p1,
|
||||
&btm_cb.devcb.read_page_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_read_page_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
|
||||
static void btm_read_pscan_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_read_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_PSCAN, p1,
|
||||
&btm_cb.devcb.read_pscan_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_read_pscan_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
tBTM_STATUS BTM_ReadBredrTxPwrLvl(tBTM_TX_PWR_LVL_TYPE type, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
UINT16 opcode;
|
||||
TIMER_LIST_ENT *timer;
|
||||
tBTM_CMPL_CB **pp_cb;
|
||||
tBTM_VSC_CMPL_CB *p_vsc_cb;
|
||||
|
||||
tBTM_STATUS status;
|
||||
tBTM_READ_TX_PWR_LVL_RESULTS result;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
switch (type) {
|
||||
case BTM_TX_PWR_LVL_ISCAN:
|
||||
// standard HCI
|
||||
return BTM_ReadInquiryRspTxPower(p_cb);
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
case BTM_TX_PWR_LVL_INQ:
|
||||
opcode = HCI_VENDOR_BT_RD_INQ_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.read_inq_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_read_inq_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_read_inq_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
case BTM_TX_PWR_LVL_PAGE:
|
||||
opcode = HCI_VENDOR_BT_RD_PAGE_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.read_page_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_read_page_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_read_page_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
case BTM_TX_PWR_LVL_PSCAN:
|
||||
opcode = HCI_VENDOR_BT_RD_PSCAN_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.read_pscan_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_read_pscan_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_read_pscan_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
default:
|
||||
BTM_TRACE_ERROR("BTM_ReadBredrTxPwrLvl invalid type: %d", type);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
if (*pp_cb) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = BTM_BUSY;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_BUSY;
|
||||
}
|
||||
|
||||
btu_start_timer(timer, BTU_TTYPE_BTM_BREDR_PWR_CTRL, BTM_BREDR_PWR_CTRL_REPLY_TIMEOUT);
|
||||
*pp_cb = p_cb;
|
||||
|
||||
status = BTM_VendorSpecificCommand(opcode, 0, NULL, p_vsc_cb);
|
||||
if (status != BTM_CMD_STARTED) {
|
||||
*pp_cb = NULL;
|
||||
btu_stop_timer(timer);
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = status;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
}
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
static void btm_write_tx_pwr_lvl_vsc_cmpl_cb(tBTM_TX_PWR_LVL_TYPE type, tBTM_VSC_CMPL *p1,
|
||||
TIMER_LIST_ENT *timer, tBTM_CMPL_CB **pp_cb)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = *pp_cb;
|
||||
tBTM_WRITE_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
btu_stop_timer(timer);
|
||||
*pp_cb = NULL;
|
||||
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = BTM_ERR_PROCESSING;
|
||||
result.hci_status = HCI_ERR_UNSPECIFIED;
|
||||
|
||||
if (p1 == NULL || p1->p_param_buf == NULL || p1->param_len < 1) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
UINT8 *p = p1->p_param_buf;
|
||||
STREAM_TO_UINT8(result.hci_status, p);
|
||||
if (result.hci_status != HCI_SUCCESS) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
result.status = BTM_SUCCESS;
|
||||
|
||||
out:
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
}
|
||||
|
||||
static void btm_write_iscan_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_write_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_ISCAN, p1,
|
||||
&btm_cb.devcb.write_iscan_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_write_iscan_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
|
||||
static void btm_write_page_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_write_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_PAGE, p1,
|
||||
&btm_cb.devcb.write_page_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_write_page_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
|
||||
static void btm_write_pscan_tx_pwr_lvl_vsc_cmpl_cb(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
btm_write_tx_pwr_lvl_vsc_cmpl_cb(BTM_TX_PWR_LVL_PSCAN, p1,
|
||||
&btm_cb.devcb.write_pscan_tx_pwr_lvl_timer,
|
||||
&btm_cb.devcb.p_write_pscan_tx_pwr_lvl_cmpl_cb);
|
||||
}
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
tBTM_STATUS BTM_WriteBredrTxPwrLvl(tBTM_TX_PWR_LVL_TYPE type, INT8 tx_power, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
UINT16 opcode;
|
||||
TIMER_LIST_ENT *timer;
|
||||
tBTM_CMPL_CB **pp_cb;
|
||||
tBTM_VSC_CMPL_CB *p_vsc_cb;
|
||||
|
||||
tBTM_STATUS status;
|
||||
tBTM_WRITE_TX_PWR_LVL_RESULTS result;
|
||||
UINT8 param[1];
|
||||
UINT8 *p = param;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
switch (type) {
|
||||
case BTM_TX_PWR_LVL_INQ:
|
||||
// standard HCI
|
||||
return BTM_WriteInquiryTxPower(tx_power, p_cb);
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
case BTM_TX_PWR_LVL_ISCAN:
|
||||
opcode = HCI_VENDOR_BT_WR_ISCAN_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.write_iscan_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_write_iscan_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_write_iscan_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
case BTM_TX_PWR_LVL_PAGE:
|
||||
opcode = HCI_VENDOR_BT_WR_PAGE_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.write_page_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_write_page_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_write_page_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
case BTM_TX_PWR_LVL_PSCAN:
|
||||
opcode = HCI_VENDOR_BT_WR_PSCAN_TX_PWR_LVL;
|
||||
timer = &btm_cb.devcb.write_pscan_tx_pwr_lvl_timer;
|
||||
pp_cb = &btm_cb.devcb.p_write_pscan_tx_pwr_lvl_cmpl_cb;
|
||||
p_vsc_cb = btm_write_pscan_tx_pwr_lvl_vsc_cmpl_cb;
|
||||
break;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
default:
|
||||
BTM_TRACE_ERROR("BTM_WriteBredrTxPwrLvl invalid type: %d", type);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
if (*pp_cb) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = BTM_BUSY;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_BUSY;
|
||||
}
|
||||
|
||||
btu_start_timer(timer, BTU_TTYPE_BTM_BREDR_PWR_CTRL, BTM_BREDR_PWR_CTRL_REPLY_TIMEOUT);
|
||||
*pp_cb = p_cb;
|
||||
|
||||
INT8_TO_STREAM(p, tx_power);
|
||||
status = BTM_VendorSpecificCommand(opcode, sizeof(param), param, p_vsc_cb);
|
||||
if (status != BTM_CMD_STARTED) {
|
||||
*pp_cb = NULL;
|
||||
btu_stop_timer(timer);
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = type;
|
||||
result.status = status;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_bredr_pwr_ctrl_timeout
|
||||
**
|
||||
** Description This function processes a BR/EDR power control vsc timeout.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_bredr_pwr_ctrl_timeout(TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
if (p_tle == &btm_cb.devcb.write_inq_txpwer_timer) {
|
||||
btm_write_inq_tx_power_complete(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.read_iscan_txpwer_timer) {
|
||||
btm_read_iscan_tx_power_complete(NULL);
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
} else if (p_tle == &btm_cb.devcb.read_new_conn_tx_pwr_lvl_timer) {
|
||||
btm_read_new_conn_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.write_new_conn_tx_pwr_lvl_timer) {
|
||||
btm_write_new_conn_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.read_inq_tx_pwr_lvl_timer) {
|
||||
btm_read_inq_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.read_page_tx_pwr_lvl_timer) {
|
||||
btm_read_page_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.read_pscan_tx_pwr_lvl_timer) {
|
||||
btm_read_pscan_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.write_iscan_tx_pwr_lvl_timer) {
|
||||
btm_write_iscan_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.write_page_tx_pwr_lvl_timer) {
|
||||
btm_write_page_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
} else if (p_tle == &btm_cb.devcb.write_pscan_tx_pwr_lvl_timer) {
|
||||
btm_write_pscan_tx_pwr_lvl_vsc_cmpl_cb(NULL);
|
||||
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
@@ -1100,23 +1100,79 @@ tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda)
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
if (btm_cb.devcb.p_txpwer_cmpl_cb) {
|
||||
tBTM_READ_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
if (btm_cb.devcb.p_read_iscan_txpwer_cmpl_cb) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = BTM_TX_PWR_LVL_ISCAN;
|
||||
result.status = BTM_BUSY;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return (BTM_BUSY);
|
||||
}
|
||||
|
||||
btu_start_timer (&btm_cb.devcb.txpwer_timer, BTU_TTYPE_BTM_ACL, BTM_INQ_REPLY_TIMEOUT );
|
||||
|
||||
|
||||
btm_cb.devcb.p_txpwer_cmpl_cb = p_cb;
|
||||
btu_start_timer (&btm_cb.devcb.read_iscan_txpwer_timer, BTU_TTYPE_BTM_BREDR_PWR_CTRL, BTM_INQ_REPLY_TIMEOUT );
|
||||
btm_cb.devcb.p_read_iscan_txpwer_cmpl_cb = p_cb;
|
||||
|
||||
if (!btsnd_hcic_read_inq_tx_power ()) {
|
||||
btm_cb.devcb.p_txpwer_cmpl_cb = NULL;
|
||||
btu_stop_timer (&btm_cb.devcb.txpwer_timer);
|
||||
btm_cb.devcb.p_read_iscan_txpwer_cmpl_cb = NULL;
|
||||
btu_stop_timer (&btm_cb.devcb.read_iscan_txpwer_timer);
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = BTM_TX_PWR_LVL_ISCAN;
|
||||
result.status = BTM_NO_RESOURCES;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return (BTM_NO_RESOURCES);
|
||||
} else {
|
||||
return (BTM_CMD_STARTED);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_WriteInquiryTxPower
|
||||
**
|
||||
** Description This command writes the inquiry transmit power level used
|
||||
** to transmit inquiry response packets.
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_WriteInquiryTxPower(INT8 tx_power, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTM_WRITE_TX_PWR_LVL_RESULTS result;
|
||||
|
||||
if (btm_cb.devcb.p_write_inq_txpwer_cmpl_cb) {
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = BTM_TX_PWR_LVL_INQ;
|
||||
result.status = BTM_BUSY;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_BUSY;
|
||||
}
|
||||
|
||||
btu_start_timer(&btm_cb.devcb.write_inq_txpwer_timer, BTU_TTYPE_BTM_BREDR_PWR_CTRL, BTM_INQ_REPLY_TIMEOUT);
|
||||
btm_cb.devcb.p_write_inq_txpwer_cmpl_cb = p_cb;
|
||||
|
||||
if (!btsnd_hcic_write_inq_tx_power(tx_power)) {
|
||||
btm_cb.devcb.p_write_inq_txpwer_cmpl_cb = NULL;
|
||||
btu_stop_timer(&btm_cb.devcb.write_inq_txpwer_timer);
|
||||
memset(&result, 0, sizeof(result));
|
||||
result.type = BTM_TX_PWR_LVL_INQ;
|
||||
result.status = BTM_NO_RESOURCES;
|
||||
if (p_cb) {
|
||||
(*p_cb)(&result);
|
||||
}
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/*********************************************************************************
|
||||
@@ -2187,40 +2243,77 @@ void btm_inq_rmt_name_failed (void)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_read_linq_tx_power_complete
|
||||
** Function btm_read_iscan_tx_power_complete
|
||||
**
|
||||
** Description read inquiry tx power level complete callback function.
|
||||
** Description read inquiry scan tx power level complete callback function.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_read_linq_tx_power_complete(UINT8 *p)
|
||||
void btm_read_iscan_tx_power_complete(UINT8 *p)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_txpwer_cmpl_cb;
|
||||
tBTM_INQ_TXPWR_RESULTS results;
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_read_iscan_txpwer_cmpl_cb;
|
||||
tBTM_READ_TX_PWR_LVL_RESULTS results;
|
||||
|
||||
btu_stop_timer (&btm_cb.devcb.txpwer_timer);
|
||||
memset(&results, 0, sizeof(results));
|
||||
results.type = BTM_TX_PWR_LVL_ISCAN;
|
||||
|
||||
btu_stop_timer (&btm_cb.devcb.read_iscan_txpwer_timer);
|
||||
/* If there was a callback registered for read inq tx power, call it */
|
||||
btm_cb.devcb.p_txpwer_cmpl_cb = NULL;
|
||||
btm_cb.devcb.p_read_iscan_txpwer_cmpl_cb = NULL;
|
||||
|
||||
if (p_cb) {
|
||||
STREAM_TO_UINT8 (results.hci_status, p);
|
||||
if (p) {
|
||||
STREAM_TO_UINT8 (results.hci_status, p);
|
||||
|
||||
if (results.hci_status == HCI_SUCCESS) {
|
||||
results.status = BTM_SUCCESS;
|
||||
if (results.hci_status == HCI_SUCCESS) {
|
||||
results.status = BTM_SUCCESS;
|
||||
|
||||
STREAM_TO_UINT8 (results.tx_power, p);
|
||||
BTM_TRACE_EVENT ("BTM INQ TX POWER Complete: tx_power %d, hci status 0x%02x\n",
|
||||
results.tx_power, results.hci_status);
|
||||
STREAM_TO_UINT8 (results.tx_power, p);
|
||||
BTM_TRACE_EVENT ("BTM INQ TX POWER Complete: tx_power %d, hci status 0x%02x\n",
|
||||
results.tx_power, results.hci_status);
|
||||
} else {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
}
|
||||
} else {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_write_inq_tx_power_complete
|
||||
**
|
||||
** Description write inquiry tx power level complete callback function.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_write_inq_tx_power_complete(UINT8 *p)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_write_inq_txpwer_cmpl_cb;
|
||||
tBTM_WRITE_TX_PWR_LVL_RESULTS results;
|
||||
|
||||
memset(&results, 0, sizeof(results));
|
||||
results.type = BTM_TX_PWR_LVL_INQ;
|
||||
|
||||
btu_stop_timer(&btm_cb.devcb.write_inq_txpwer_timer);
|
||||
btm_cb.devcb.p_write_inq_txpwer_cmpl_cb = NULL;
|
||||
|
||||
if (p_cb) {
|
||||
if (p) {
|
||||
STREAM_TO_UINT8(results.hci_status, p);
|
||||
results.status = (results.hci_status == HCI_SUCCESS) ? BTM_SUCCESS : BTM_ERR_PROCESSING;
|
||||
} else {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
}
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_WriteEIR
|
||||
|
||||
@@ -199,6 +199,47 @@ tBTM_CMPL_CB *p_rln_cmpl_cb; /* Callback function to be called when
|
||||
TIMER_LIST_ENT rssi_timer;
|
||||
tBTM_CMPL_CB *p_rssi_cmpl_cb; /* Callback function to be called when */
|
||||
/* read rssi function completes */
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
TIMER_LIST_ENT acl_real_rssi_timer;
|
||||
tBTM_CMPL_CB *p_acl_real_rssi_cmpl_cb; /* Callback function to be called when */
|
||||
/* read acl real rssi function completes */
|
||||
|
||||
TIMER_LIST_ENT read_new_conn_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_read_new_conn_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* read new connection transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT write_new_conn_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_write_new_conn_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* write new connection transmit power level function completes */
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
TIMER_LIST_ENT read_page_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_read_page_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* read page transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT write_page_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_write_page_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* write page transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT read_pscan_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_read_pscan_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* read page scan transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT write_pscan_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_write_pscan_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* write page scan transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT read_inq_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_read_inq_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* read inquiry transmit power level function completes */
|
||||
|
||||
TIMER_LIST_ENT write_iscan_tx_pwr_lvl_timer;
|
||||
tBTM_CMPL_CB *p_write_iscan_tx_pwr_lvl_cmpl_cb; /* Callback function to be called when */
|
||||
/* write inquiry scan transmit power level function completes */
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTM_CMPL_CB *p_ble_ch_map_cmpl_cb; /* Callback function to be called when */
|
||||
#endif // #if BLE_INCLUDED == TRUE
|
||||
@@ -210,11 +251,15 @@ tBTM_CMPL_CB *p_lnk_qual_cmpl_cb;/* Callback function to be called when
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/* read link quality function completes */
|
||||
TIMER_LIST_ENT txpwer_timer;
|
||||
tBTM_CMPL_CB *p_txpwer_cmpl_cb; /* Callback function to be called when */
|
||||
TIMER_LIST_ENT read_iscan_txpwer_timer;
|
||||
tBTM_CMPL_CB *p_read_iscan_txpwer_cmpl_cb; /* Callback function to be called when */
|
||||
/* read inq scan tx power function completes */
|
||||
|
||||
TIMER_LIST_ENT write_inq_txpwer_timer;
|
||||
tBTM_CMPL_CB *p_write_inq_txpwer_cmpl_cb; /* Callback function to be called when */
|
||||
/* write inq tx power function completes */
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/* read inq tx power function completes */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
TIMER_LIST_ENT qossu_timer;
|
||||
tBTM_CMPL_CB *p_qossu_cmpl_cb; /* Callback function to be called when */
|
||||
@@ -1082,6 +1127,18 @@ BOOLEAN btm_inq_find_bdaddr (BD_ADDR p_bda);
|
||||
|
||||
BOOLEAN btm_lookup_eir(BD_ADDR_PTR p_rem_addr);
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
void btm_read_iscan_tx_power_complete (UINT8 *p);
|
||||
void btm_write_inq_tx_power_complete (UINT8 *p);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/* Internal functions provided by btm_bredr_pwr_ctrl.c
|
||||
*******************************************
|
||||
*/
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
void btm_bredr_pwr_ctrl_timeout(TIMER_LIST_ENT *p_tle);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/* Internal functions provided by btm_acl.c
|
||||
********************************************
|
||||
*/
|
||||
@@ -1253,7 +1310,6 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_
|
||||
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
|
||||
void btm_sec_conn_req (UINT8 *bda, UINT8 *dc);
|
||||
void btm_create_conn_cancel_complete (UINT8 *p, UINT16 evt_len);
|
||||
void btm_read_linq_tx_power_complete (UINT8 *p);
|
||||
|
||||
void btm_sec_init (UINT8 sec_mode);
|
||||
void btm_sec_dev_reset (void);
|
||||
|
||||
@@ -1245,7 +1245,10 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
case HCI_READ_INQ_TX_POWER_LEVEL:
|
||||
btm_read_linq_tx_power_complete (p);
|
||||
btm_read_iscan_tx_power_complete (p);
|
||||
break;
|
||||
case HCI_WRITE_INQ_TX_POWER_LEVEL:
|
||||
btm_write_inq_tx_power_complete(p);
|
||||
break;
|
||||
case HCI_SET_AFH_CHANNELS:
|
||||
btm_set_afh_channels_complete(p);
|
||||
|
||||
@@ -412,6 +412,11 @@ static void btu_general_alarm_process(void *param)
|
||||
case BTU_TTYPE_BTM_SET_PAGE_TO:
|
||||
btm_page_to_setup_timeout(p_tle);
|
||||
break;
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
case BTU_TTYPE_BTM_BREDR_PWR_CTRL:
|
||||
btm_bredr_pwr_ctrl_timeout(p_tle);
|
||||
break;
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
default:
|
||||
for (int i = 0; i < BTU_MAX_REG_TIMER; i++) {
|
||||
if (btu_cb.timer_reg[i].timer_cb == NULL) {
|
||||
|
||||
@@ -1672,6 +1672,28 @@ BOOLEAN btsnd_hcic_read_inq_tx_power (void)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 tx_power)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_INQ_TX_POWER)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_INQ_TX_POWER;
|
||||
p->offset = 0;
|
||||
|
||||
UINT16_TO_STREAM (pp, HCI_WRITE_INQ_TX_POWER_LEVEL);
|
||||
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_INQ_TX_POWER);
|
||||
INT8_TO_STREAM (pp, tx_power);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif)
|
||||
{
|
||||
BT_HDR *p;
|
||||
|
||||
@@ -795,6 +795,66 @@ typedef struct {
|
||||
BD_ADDR rem_bda;
|
||||
} tBTM_RSSI_RESULTS;
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
/* Structure returned with read ACL real RSSI event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadAclRealRSSI call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
INT8 rssi;
|
||||
BD_ADDR rem_bda;
|
||||
} tBTM_ACL_REAL_RSSI_RESULTS;
|
||||
|
||||
/* Structure returned with read new connection transmit power level event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadNewConnTxPwrLvl call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
INT8 pwr_lvl_min;
|
||||
INT8 pwr_lvl_max;
|
||||
} tBTM_READ_NEW_CONN_TX_PWR_LVL_RESULTS;
|
||||
|
||||
/* Structure returned with write new connection transmit power level event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_WriteNewConnTxPwrLvl call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
} tBTM_WRITE_NEW_CONN_TX_PWR_LVL_RESULTS;
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/* BR/EDR tx power level type for inq/iscan/page/pscan control */
|
||||
typedef enum {
|
||||
BTM_TX_PWR_LVL_INQ = 0,
|
||||
BTM_TX_PWR_LVL_ISCAN,
|
||||
BTM_TX_PWR_LVL_PAGE,
|
||||
BTM_TX_PWR_LVL_PSCAN,
|
||||
BTM_TX_PWR_LVL_MAX,
|
||||
} tBTM_TX_PWR_LVL_TYPE;
|
||||
|
||||
/* Structure returned with read inq/iscan/page/pscan tx power level event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadBredrTxPwrLvl/BTM_ReadInquiryRspTxPower call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
INT8 tx_power;
|
||||
tBTM_TX_PWR_LVL_TYPE type;
|
||||
} tBTM_READ_TX_PWR_LVL_RESULTS;
|
||||
|
||||
/* Structure returned with write inq/iscan/page/pscan tx power level event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_WriteBredrTxPwrLvl/BTM_WriteInquiryTxPower call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
tBTM_TX_PWR_LVL_TYPE type;
|
||||
} tBTM_WRITE_TX_PWR_LVL_RESULTS;
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/* Structure returned with read channel map event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadChannelMap call.
|
||||
*/
|
||||
@@ -866,16 +926,6 @@ typedef struct {
|
||||
UINT8 hci_status;
|
||||
} tBTM_BLE_SET_CHANNELS_RESULTS;
|
||||
|
||||
/* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadInquiryRspTxPower call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
INT8 tx_power;
|
||||
} tBTM_INQ_TXPWR_RESULTS;
|
||||
|
||||
|
||||
enum {
|
||||
BTM_ACL_CONN_CMPL_EVT,
|
||||
BTM_ACL_DISCONN_CMPL_EVT
|
||||
@@ -2788,6 +2838,7 @@ tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
|
||||
//extern
|
||||
tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda);
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadInquiryRspTxPower
|
||||
@@ -2802,6 +2853,21 @@ tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda);
|
||||
//extern
|
||||
tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_WriteInquiryTxPower
|
||||
**
|
||||
** Description This command writes the inquiry transmit power level used
|
||||
** to transmit inquiry response packets.
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_WriteInquiryTxPower(INT8 tx_power, tBTM_CMPL_CB *p_cb);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if SDP_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3008,6 +3074,88 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
|
||||
//extern
|
||||
tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
#if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadAclRealRSSI
|
||||
**
|
||||
** Description This function is called to read ACL real RSSI.
|
||||
** The RSSI of results are returned in the callback.
|
||||
** (tBTM_ACL_REAL_RSSI_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_UNKNOWN_ADDR if no active link with bd addr specified
|
||||
** BTM_BUSY if command is already in progress
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadAclRealRSSI(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadNewConnTxPwrLvl
|
||||
**
|
||||
** Description This function is called to read new connection transmit power level.
|
||||
** The new connection transmit power level value returned in the callback.
|
||||
** (tBTM_READ_NEW_CONN_TX_PWR_LVL_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadNewConnTxPwrLvl(tBTM_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_WriteNewConnTxPwrLvl
|
||||
**
|
||||
** Description This function is called to write new connection transmit power level.
|
||||
** The new connection transmit power level value returned in the callback.
|
||||
** (tBTM_WRITE_NEW_CONN_TX_PWR_LVL_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_WriteNewConnTxPwrLvl(INT8 pwr_lvl_min, INT8 pwr_lvl_max, tBTM_CMPL_CB *p_cb);
|
||||
#endif // #if (ESP_BT_CLASSIC_ENABLE_POWER_CTRL_VSC == TRUE)
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadBredrTxPwrLvl
|
||||
**
|
||||
** Description This function is called to read inq/iscan/page/pscan transmit power level.
|
||||
** The corresponding transmit power level value returned in the callback.
|
||||
** (tBTM_READ_TX_PWR_LVL_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
** BTM_ILLEGAL_VALUE if type is invalid
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadBredrTxPwrLvl(tBTM_TX_PWR_LVL_TYPE type, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_WriteBredrTxPwrLvl
|
||||
**
|
||||
** Description This function is called to write inq/iscan/page/pscan transmit power level.
|
||||
** The corresponding write status returned in the callback.
|
||||
** (tBTM_WRITE_TX_PWR_LVL_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
** BTM_NO_RESOURCES if couldn't allocate memory to issue command
|
||||
** BTM_BUSY if command is already in progress
|
||||
** BTM_ILLEGAL_VALUE if type is invalid
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_WriteBredrTxPwrLvl(tBTM_TX_PWR_LVL_TYPE type, INT8 tx_power, tBTM_CMPL_CB *p_cb);
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_ReadChannelMap
|
||||
|
||||
@@ -169,6 +169,9 @@ typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
|
||||
/* BTU internal timer for set page timeout*/
|
||||
#define BTU_TTYPE_BTM_SET_PAGE_TO 111
|
||||
|
||||
/* BTU internal timer for BR/EDR power control*/
|
||||
#define BTU_TTYPE_BTM_BREDR_PWR_CTRL 112
|
||||
|
||||
/* BTU Task Signal */
|
||||
typedef enum {
|
||||
SIG_BTU_START_UP = 0,
|
||||
|
||||
@@ -512,6 +512,15 @@
|
||||
#define HCI_SUBCODE_BT_SET_AFH_REPORTING_MODE 0x09
|
||||
#define HCI_SUBCODE_BT_MASK_RMT_AFH_CH_CLASS 0x0A
|
||||
#define HCI_SUBCODE_BT_WR_AUTO_RATE_INIT_ENABLE 0x0B
|
||||
#define HCI_SUBCODE_BT_RD_ACL_REAL_RSSI 0x11
|
||||
#define HCI_SUBCODE_BT_RD_NEW_CONN_TX_PWR_LVL 0x12
|
||||
#define HCI_SUBCODE_BT_WR_NEW_CONN_TX_PWR_LVL 0x13
|
||||
#define HCI_SUBCODE_BT_RD_PAGE_TX_PWR_LVL 0x14
|
||||
#define HCI_SUBCODE_BT_WR_PAGE_TX_PWR_LVL 0x15
|
||||
#define HCI_SUBCODE_BT_RD_PSCAN_TX_PWR_LVL 0x16
|
||||
#define HCI_SUBCODE_BT_WR_PSCAN_TX_PWR_LVL 0x17
|
||||
#define HCI_SUBCODE_BT_RD_INQ_TX_PWR_LVL 0x18
|
||||
#define HCI_SUBCODE_BT_WR_ISCAN_TX_PWR_LVL 0x19
|
||||
#define HCI_SUBCODE_BT_MAX 0x7F
|
||||
|
||||
#define HCI_ESP_VENDOR_OPCODE_BUILD(ogf, group, subcode) ((ogf << 10) | (group <<7) | (subcode << 0))
|
||||
@@ -561,6 +570,15 @@
|
||||
#define HCI_VENDOR_BT_SET_AFH_REPORTING_MODE HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_SET_AFH_REPORTING_MODE)
|
||||
#define HCI_VENDOR_BT_MASK_RMT_AFH_CH_CLASS HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_MASK_RMT_AFH_CH_CLASS)
|
||||
#define HCI_VENDOR_BT_WR_AUTO_RATE_INIT_ENABLE HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_WR_AUTO_RATE_INIT_ENABLE)
|
||||
#define HCI_VENDOR_BT_RD_ACL_REAL_RSSI HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_RD_ACL_REAL_RSSI)
|
||||
#define HCI_VENDOR_BT_RD_NEW_CONN_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_RD_NEW_CONN_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_WR_NEW_CONN_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_WR_NEW_CONN_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_RD_PAGE_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_RD_PAGE_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_WR_PAGE_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_WR_PAGE_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_RD_PSCAN_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_RD_PSCAN_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_WR_PSCAN_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_WR_PSCAN_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_RD_INQ_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_RD_INQ_TX_PWR_LVL)
|
||||
#define HCI_VENDOR_BT_WR_ISCAN_TX_PWR_LVL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BT, HCI_SUBCODE_BT_WR_ISCAN_TX_PWR_LVL)
|
||||
|
||||
/* subcode for multi adv feature */
|
||||
#define BTM_BLE_MULTI_ADV_SET_PARAM 0x01
|
||||
|
||||
@@ -509,6 +509,11 @@ BOOLEAN btsnd_hcic_read_inq_tx_power (void);
|
||||
|
||||
#define HCIC_PARAM_SIZE_R_TX_POWER 0
|
||||
|
||||
/* Write Inquiry Tx Power Level */
|
||||
BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 tx_power);
|
||||
|
||||
#define HCIC_PARAM_SIZE_W_INQ_TX_POWER 1
|
||||
|
||||
/* Read Default Erroneous Data Reporting */
|
||||
BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user