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
d406bf02b5
commit
4ff5528a23
@ -141,18 +141,34 @@ uint32_t btc_get_ble_status(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (SMP_INCLUDED == TRUE)
|
#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
|
// Number of saved bonded devices
|
||||||
if (btc_storage_get_num_ble_bond_devices()) {
|
if (btc_storage_get_num_ble_bond_devices()) {
|
||||||
status |= BIT(BTC_BLE_STATUS_BOND);
|
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
|
||||||
// Number of recorded devices
|
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||||
extern uint8_t btdm_sec_dev_active_count(void);
|
// Number of active extended advertsing
|
||||||
if (btdm_sec_dev_active_count()) {
|
extern uint8_t btm_ble_ext_adv_active_count(void);
|
||||||
status |= BIT(BTC_BLE_STATUS_DEV);
|
if (btm_ble_ext_adv_active_count()) {
|
||||||
|
status |= BIT(BTC_BLE_STATUS_EXT_ADV);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Number of active ACL connection
|
// Number of active ACL connection
|
||||||
extern uint8_t btm_acl_active_count(void);
|
extern uint8_t btm_acl_active_count(void);
|
||||||
|
@ -31,13 +31,15 @@ typedef enum {
|
|||||||
#define BTC_BLE_STATUS_IDLE 0
|
#define BTC_BLE_STATUS_IDLE 0
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||||
|
BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist
|
||||||
BTC_BLE_STATUS_SCAN, // Scanning exist
|
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||||
BTC_BLE_STATUS_CONN, // Connection 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_BOND, // Bond info exist
|
||||||
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
||||||
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
||||||
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
||||||
|
BTC_BLE_STATUS_PRIVACY, // Privacy enabled
|
||||||
} tBTC_BLE_STATUS;
|
} 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);
|
||||||
|
@ -2931,4 +2931,31 @@ uint8_t btm_ble_scan_active_count(void)
|
|||||||
return count;
|
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 */
|
#endif /* BLE_INCLUDED */
|
||||||
|
@ -27,6 +27,7 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len,
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t ter_con_handle;
|
uint16_t ter_con_handle;
|
||||||
bool invalid;
|
bool invalid;
|
||||||
|
bool enabled;
|
||||||
UINT8 instance;
|
UINT8 instance;
|
||||||
int duration;
|
int duration;
|
||||||
int max_events;
|
int max_events;
|
||||||
@ -540,6 +541,7 @@ end:
|
|||||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
||||||
{
|
{
|
||||||
adv_record[i].invalid = false;
|
adv_record[i].invalid = false;
|
||||||
|
adv_record[i].enabled = false;
|
||||||
adv_record[i].instance = INVALID_VALUE;
|
adv_record[i].instance = INVALID_VALUE;
|
||||||
adv_record[i].duration = INVALID_VALUE;
|
adv_record[i].duration = INVALID_VALUE;
|
||||||
adv_record[i].max_events = INVALID_VALUE;
|
adv_record[i].max_events = INVALID_VALUE;
|
||||||
@ -550,6 +552,7 @@ end:
|
|||||||
{
|
{
|
||||||
uint8_t index = ext_adv[i].instance;
|
uint8_t index = ext_adv[i].instance;
|
||||||
adv_record[index].invalid = false;
|
adv_record[index].invalid = false;
|
||||||
|
adv_record[index].enabled = false;
|
||||||
adv_record[index].instance = INVALID_VALUE;
|
adv_record[index].instance = INVALID_VALUE;
|
||||||
adv_record[index].duration = INVALID_VALUE;
|
adv_record[index].duration = INVALID_VALUE;
|
||||||
adv_record[index].max_events = INVALID_VALUE;
|
adv_record[index].max_events = INVALID_VALUE;
|
||||||
@ -563,6 +566,7 @@ end:
|
|||||||
{
|
{
|
||||||
uint8_t index = ext_adv[i].instance;
|
uint8_t index = ext_adv[i].instance;
|
||||||
adv_record[index].invalid = true;
|
adv_record[index].invalid = true;
|
||||||
|
adv_record[index].enabled = true;
|
||||||
adv_record[index].instance = ext_adv[i].instance;
|
adv_record[index].instance = ext_adv[i].instance;
|
||||||
adv_record[index].duration = ext_adv[i].duration;
|
adv_record[index].duration = ext_adv[i].duration;
|
||||||
adv_record[index].max_events = ext_adv[i].max_events;
|
adv_record[index].max_events = ext_adv[i].max_events;
|
||||||
@ -1196,6 +1200,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].ter_con_handle = INVALID_VALUE;
|
||||||
adv_record[params->adv_handle].invalid = false;
|
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));
|
memcpy(&cb_params.adv_term, params, sizeof(tBTM_BLE_ADV_TERMINAT));
|
||||||
|
|
||||||
@ -1311,6 +1316,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)
|
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||||
|
|
||||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||||
|
@ -133,20 +133,3 @@ uint8_t btm_acl_active_count(void)
|
|||||||
|
|
||||||
return 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;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user