mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(bt/bluedroid): Add ext adv and privacy status check
This commit is contained in:
parent
2fc2876109
commit
b5425ffa5c
@ -141,18 +141,34 @@ uint32_t btc_get_ble_status(void)
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
// Number of recorded devices
|
||||
extern uint8_t btm_ble_sec_dev_active_count(void);
|
||||
if (btm_ble_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_KEYS);
|
||||
}
|
||||
|
||||
// Number of saved bonded devices
|
||||
if (btc_storage_get_num_ble_bond_devices()) {
|
||||
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
// Privacy enabled
|
||||
extern uint8_t btm_ble_privacy_is_enabled(void);
|
||||
if (btm_ble_privacy_is_enabled()) {
|
||||
status |= BIT(BTC_BLE_STATUS_PRIVACY);
|
||||
}
|
||||
#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);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
// Number of active extended advertsing
|
||||
extern uint8_t btm_ble_ext_adv_active_count(void);
|
||||
if (btm_ble_ext_adv_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_EXT_ADV);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Number of active ACL connection
|
||||
extern uint8_t btm_acl_active_count(void);
|
||||
|
@ -31,13 +31,15 @@ typedef enum {
|
||||
#define BTC_BLE_STATUS_IDLE 0
|
||||
typedef enum {
|
||||
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||
BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist
|
||||
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||
BTC_BLE_STATUS_CONN, // Connection exist
|
||||
BTC_BLE_STATUS_DEV, // Device record exist
|
||||
BTC_BLE_STATUS_KEYS, // Device keys 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
|
||||
BTC_BLE_STATUS_PRIVACY, // Privacy enabled
|
||||
} tBTC_BLE_STATUS;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
@ -2931,4 +2931,31 @@ uint8_t btm_ble_scan_active_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
uint8_t btm_ble_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) && (p_dev_rec->ble.key_type != BTM_LE_KEY_NONE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
uint8_t btm_ble_privacy_is_enabled(void)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
return (p_cb->privacy_mode != BTM_PRIVACY_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
@ -27,6 +27,7 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len,
|
||||
typedef struct {
|
||||
uint16_t ter_con_handle;
|
||||
bool invalid;
|
||||
bool enabled;
|
||||
UINT8 instance;
|
||||
int duration;
|
||||
int max_events;
|
||||
@ -538,6 +539,7 @@ end:
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
||||
{
|
||||
adv_record[i].invalid = false;
|
||||
adv_record[i].enabled = false;
|
||||
adv_record[i].instance = INVALID_VALUE;
|
||||
adv_record[i].duration = INVALID_VALUE;
|
||||
adv_record[i].max_events = INVALID_VALUE;
|
||||
@ -548,6 +550,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = false;
|
||||
adv_record[index].enabled = false;
|
||||
adv_record[index].instance = INVALID_VALUE;
|
||||
adv_record[index].duration = INVALID_VALUE;
|
||||
adv_record[index].max_events = INVALID_VALUE;
|
||||
@ -561,6 +564,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = true;
|
||||
adv_record[index].enabled = true;
|
||||
adv_record[index].instance = ext_adv[i].instance;
|
||||
adv_record[index].duration = ext_adv[i].duration;
|
||||
adv_record[index].max_events = ext_adv[i].max_events;
|
||||
@ -1194,6 +1198,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params)
|
||||
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE;
|
||||
adv_record[params->adv_handle].invalid = false;
|
||||
}
|
||||
adv_record[params->adv_handle].enabled = false;
|
||||
|
||||
memcpy(&cb_params.adv_term, params, sizeof(tBTM_BLE_ADV_TERMINAT));
|
||||
|
||||
@ -1309,6 +1314,19 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par
|
||||
|
||||
}
|
||||
|
||||
uint8_t btm_ble_ext_adv_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) {
|
||||
if (adv_record[i].enabled == true) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
@ -133,20 +133,3 @@ uint8_t btm_acl_active_count(void)
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user