mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'feat/support_get_bluedroid_status_v4.4' into 'release/v4.4'
Support get status of bluedroid host (backport v4.4) See merge request espressif/esp-idf!28884
This commit is contained in:
@ -1073,6 +1073,14 @@ config BT_SMP_ENABLE
|
|||||||
depends on BT_BLUEDROID_ENABLED
|
depends on BT_BLUEDROID_ENABLED
|
||||||
default BT_CLASSIC_ENABLED || BT_BLE_SMP_ENABLE
|
default BT_CLASSIC_ENABLED || BT_BLE_SMP_ENABLE
|
||||||
|
|
||||||
|
config BT_SMP_MAX_BONDS
|
||||||
|
int "BT/BLE maximum bond device count"
|
||||||
|
depends on BT_SMP_ENABLE
|
||||||
|
range 1 32
|
||||||
|
default 15
|
||||||
|
help
|
||||||
|
The number of security records for peer devices.
|
||||||
|
|
||||||
config BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
config BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||||
bool "Report adv data and scan response individually when BLE active scan"
|
bool "Report adv data and scan response individually when BLE active scan"
|
||||||
depends on BT_BLUEDROID_ENABLED && BT_BLE_ENABLED
|
depends on BT_BLUEDROID_ENABLED && BT_BLE_ENABLED
|
||||||
|
@ -510,6 +510,10 @@ UINT8 bta_gattc_co_find_hash_in_cache(hash_key_t hash_key)
|
|||||||
|
|
||||||
UINT8 bta_gattc_co_get_addr_num(void)
|
UINT8 bta_gattc_co_get_addr_num(void)
|
||||||
{
|
{
|
||||||
|
if (cache_env == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return cache_env->num_addr;
|
return cache_env->num_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,4 +534,17 @@ void bta_gattc_deinit(void)
|
|||||||
FREE_AND_RESET(bta_gattc_cb_ptr);
|
FREE_AND_RESET(bta_gattc_cb_ptr);
|
||||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t bta_gattc_cl_rcb_active_count(void)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < BTA_GATTC_CL_MAX; i ++) {
|
||||||
|
if (bta_gattc_cb.cl_rcb[i].in_use) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */
|
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */
|
||||||
|
@ -152,4 +152,17 @@ void bta_gatts_deinit(void)
|
|||||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t bta_gatts_srvc_active_count(void)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++) {
|
||||||
|
if (bta_gatts_cb.srvc_cb[i].in_use) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GATTS_INCLUDED */
|
#endif /* GATTS_INCLUDED */
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "btc/btc_task.h"
|
#include "btc/btc_task.h"
|
||||||
#include "btc/btc_main.h"
|
#include "btc/btc_main.h"
|
||||||
@ -124,3 +116,77 @@ void btc_main_call_handler(btc_msg_t *msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t btc_get_ble_status(void)
|
||||||
|
{
|
||||||
|
uint32_t status = BTC_BLE_STATUS_IDLE;
|
||||||
|
|
||||||
|
#if (BLE_INCLUDED == TRUE)
|
||||||
|
// Number of active advertising
|
||||||
|
extern uint8_t btm_ble_adv_active_count(void);
|
||||||
|
if (btm_ble_adv_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_ADV);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of active scanning
|
||||||
|
extern uint8_t btm_ble_scan_active_count(void);
|
||||||
|
if (btm_ble_scan_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_SCAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of active GATT tcb
|
||||||
|
extern uint8_t gatt_tcb_active_count(void);
|
||||||
|
if (gatt_tcb_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (SMP_INCLUDED == TRUE)
|
||||||
|
// Number of saved bonded devices
|
||||||
|
if (btc_storage_get_num_ble_bond_devices()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Number of recorded devices
|
||||||
|
extern uint8_t btdm_sec_dev_active_count(void);
|
||||||
|
if (btdm_sec_dev_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_DEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of active ACL connection
|
||||||
|
extern uint8_t btm_acl_active_count(void);
|
||||||
|
if (btm_acl_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of active L2C plcb
|
||||||
|
extern uint8_t l2cu_plcb_active_count(void);
|
||||||
|
if (l2cu_plcb_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (GATTC_INCLUDED == TRUE)
|
||||||
|
// Number of registered GATTC APP
|
||||||
|
extern uint8_t bta_gattc_cl_rcb_active_count(void);
|
||||||
|
if (bta_gattc_cl_rcb_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_GATTC_APP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Number of saved GATTC cache
|
||||||
|
extern UINT8 bta_gattc_co_get_addr_num(void);
|
||||||
|
if (bta_gattc_co_get_addr_num()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_GATTC_CACHE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (GATTS_INCLUDED == TRUE)
|
||||||
|
// Number of registered GATTS service
|
||||||
|
extern uint8_t bta_gatts_srvc_active_count(void);
|
||||||
|
if (bta_gatts_srvc_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_GATTS_SRVC);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#ifndef __BTC_BT_MAIN_H__
|
#ifndef __BTC_BT_MAIN_H__
|
||||||
#define __BTC_BT_MAIN_H__
|
#define __BTC_BT_MAIN_H__
|
||||||
@ -36,6 +28,18 @@ typedef enum {
|
|||||||
BTC_MAIN_FUTURE_NUM,
|
BTC_MAIN_FUTURE_NUM,
|
||||||
} btc_main_future_type_t;
|
} btc_main_future_type_t;
|
||||||
|
|
||||||
|
#define BTC_BLE_STATUS_IDLE 0
|
||||||
|
typedef enum {
|
||||||
|
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||||
|
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||||
|
BTC_BLE_STATUS_CONN, // Connection exist
|
||||||
|
BTC_BLE_STATUS_DEV, // Device record exist
|
||||||
|
BTC_BLE_STATUS_BOND, // Bond info exist
|
||||||
|
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
||||||
|
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
||||||
|
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
||||||
|
} tBTC_BLE_STATUS;
|
||||||
|
|
||||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -198,6 +198,12 @@
|
|||||||
#define UC_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
#define UC_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BT_SMP_MAX_BONDS
|
||||||
|
#define UC_BT_SMP_MAX_BONDS CONFIG_BT_SMP_MAX_BONDS
|
||||||
|
#else
|
||||||
|
#define UC_BT_SMP_MAX_BONDS 8
|
||||||
|
#endif
|
||||||
|
|
||||||
//Device Nane Maximum Length
|
//Device Nane Maximum Length
|
||||||
#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN
|
#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||||
#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN
|
#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||||
|
@ -866,13 +866,9 @@
|
|||||||
#define BTM_DEFAULT_SCO_MODE 2
|
#define BTM_DEFAULT_SCO_MODE 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The number of security records for peer devices. 100 AS Default*/
|
/* The number of security records for peer devices. 15 AS Default*/
|
||||||
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
|
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
|
||||||
#if SMP_INCLUDED == TRUE
|
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
|
||||||
#define BTM_SEC_MAX_DEVICE_RECORDS 15 // 100
|
|
||||||
#else
|
|
||||||
#define BTM_SEC_MAX_DEVICE_RECORDS 8
|
|
||||||
#endif /* SMP_INCLUDED == TRUE */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The number of security records for services. 32 AS Default*/
|
/* The number of security records for services. 32 AS Default*/
|
||||||
|
@ -2907,5 +2907,28 @@ BOOLEAN btm_get_current_conn_params(BD_ADDR bda, UINT16 *interval, UINT16 *laten
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t btm_ble_adv_active_count(void)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
|
|
||||||
|
if (p_cb->state & BTM_BLE_ADVERTISING) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t btm_ble_scan_active_count(void)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
|
|
||||||
|
if (p_cb->state & BTM_BLE_SCANNING) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BLE_INCLUDED */
|
#endif /* BLE_INCLUDED */
|
||||||
|
@ -117,3 +117,36 @@ void btm_free(void)
|
|||||||
btm_ble_sem_free();
|
btm_ble_sem_free();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t btm_acl_active_count(void)
|
||||||
|
{
|
||||||
|
list_node_t *p_node = NULL;
|
||||||
|
tACL_CONN *p_acl_conn = NULL;
|
||||||
|
uint8_t count = 0;
|
||||||
|
|
||||||
|
for (p_node = list_begin(btm_cb.p_acl_db_list); p_node; p_node = list_next(p_node)) {
|
||||||
|
p_acl_conn = list_node(p_node);
|
||||||
|
if (p_acl_conn && p_acl_conn->in_use) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t btdm_sec_dev_active_count(void)
|
||||||
|
{
|
||||||
|
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||||
|
list_node_t *p_node = NULL;
|
||||||
|
uint8_t count = 0;
|
||||||
|
|
||||||
|
/* First look for the non-paired devices for the oldest entry */
|
||||||
|
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||||
|
p_dev_rec = list_node(p_node);
|
||||||
|
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
@ -1231,4 +1231,20 @@ void gatt_set_local_mtu(uint16_t mtu)
|
|||||||
gatt_default.local_mtu = mtu;
|
gatt_default.local_mtu = mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t gatt_tcb_active_count(void)
|
||||||
|
{
|
||||||
|
tGATT_TCB *p_tcb = NULL;
|
||||||
|
list_node_t *p_node = NULL;
|
||||||
|
uint8_t count = 0;
|
||||||
|
|
||||||
|
for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||||
|
p_tcb = list_node(p_node);
|
||||||
|
if (p_tcb && p_tcb->in_use && (p_tcb->ch_state != GATT_CH_CLOSE)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BLE_INCLUDED */
|
#endif /* BLE_INCLUDED */
|
||||||
|
@ -31,12 +31,6 @@ static const char *tag = "UHCI";
|
|||||||
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_UART_TXD_OUT) | (1ULL<<GPIO_UART_RTS_OUT))
|
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_UART_TXD_OUT) | (1ULL<<GPIO_UART_RTS_OUT))
|
||||||
#define GPIO_INPUT_PIN_SEL ((1ULL<<GPIO_UART_RXD_IN) | (1ULL<<GPIO_UART_CTS_IN))
|
#define GPIO_INPUT_PIN_SEL ((1ULL<<GPIO_UART_RXD_IN) | (1ULL<<GPIO_UART_CTS_IN))
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
|
|
||||||
#define HCI_UART_FLOW_CTRL_ENABLE CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
|
|
||||||
#else
|
|
||||||
#define HCI_UART_FLOW_CTRL_ENABLE FALSE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Operation functions for HCI UART Transport Layer
|
// Operation functions for HCI UART Transport Layer
|
||||||
static bool hci_uart_tl_init(void);
|
static bool hci_uart_tl_init(void);
|
||||||
static void hci_uart_tl_deinit(void);
|
static void hci_uart_tl_deinit(void);
|
||||||
@ -211,7 +205,7 @@ void uhci_uart_install(void)
|
|||||||
.data_bits = UART_DATA_8_BITS,
|
.data_bits = UART_DATA_8_BITS,
|
||||||
.parity = UART_PARITY_DISABLE,
|
.parity = UART_PARITY_DISABLE,
|
||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
#if (HCI_UART_FLOW_CTRL_ENABLE == TRUE)
|
#ifdef CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
|
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
|
||||||
#else
|
#else
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||||
|
Reference in New Issue
Block a user