mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: add set local privacy func callback
This commit is contained in:
parent
002f38fa8f
commit
fc05851b05
@ -93,6 +93,7 @@ typedef enum {
|
|||||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
|
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
|
||||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
||||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt lenght complete, the event comes */
|
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt lenght complete, the event comes */
|
||||||
|
ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */
|
||||||
} esp_gap_ble_cb_event_t;
|
} esp_gap_ble_cb_event_t;
|
||||||
|
|
||||||
/// Advertising data maximum length
|
/// Advertising data maximum length
|
||||||
@ -539,6 +540,12 @@ typedef union {
|
|||||||
esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */
|
esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */
|
||||||
esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */
|
esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */
|
||||||
} pkt_data_lenth_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */
|
} pkt_data_lenth_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */
|
||||||
|
/**
|
||||||
|
* @brief ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT
|
||||||
|
*/
|
||||||
|
struct ble_local_privacy_cmpl_evt_param {
|
||||||
|
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
|
||||||
|
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||||
} esp_ble_gap_cb_param_t;
|
} esp_ble_gap_cb_param_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4601,7 +4601,7 @@ void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data)
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
||||||
{
|
{
|
||||||
BTM_BleConfigPrivacy (p_data->ble_local_privacy.privacy_enable);
|
BTM_BleConfigPrivacy (p_data->ble_local_privacy.privacy_enable, p_data->ble_local_privacy.set_local_privacy_cback);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1575,7 +1575,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
|
|||||||
** Returns void
|
** Returns void
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
|
||||||
{
|
{
|
||||||
///This function used the irk to generate the resolve address
|
///This function used the irk to generate the resolve address
|
||||||
#if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
|
#if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
|
||||||
@ -1586,7 +1586,7 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
|||||||
|
|
||||||
p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
|
p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
|
||||||
p_msg->privacy_enable = privacy_enable;
|
p_msg->privacy_enable = privacy_enable;
|
||||||
|
p_msg->set_local_privacy_cback = set_local_privacy_cback;
|
||||||
bta_sys_sendmsg(p_msg);
|
bta_sys_sendmsg(p_msg);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -444,6 +444,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
BT_HDR hdr;
|
BT_HDR hdr;
|
||||||
BOOLEAN privacy_enable;
|
BOOLEAN privacy_enable;
|
||||||
|
tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||||
} tBTA_DM_API_LOCAL_PRIVACY;
|
} tBTA_DM_API_LOCAL_PRIVACY;
|
||||||
|
|
||||||
/* set scan parameter for BLE connections */
|
/* set scan parameter for BLE connections */
|
||||||
|
@ -404,6 +404,8 @@ typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
|
|||||||
|
|
||||||
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
||||||
|
|
||||||
|
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||||
|
|
||||||
/* advertising channel map */
|
/* advertising channel map */
|
||||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||||
@ -2035,11 +2037,11 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr);
|
|||||||
** Description Enable/disable privacy on the local device
|
** Description Enable/disable privacy on the local device
|
||||||
**
|
**
|
||||||
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
||||||
**
|
** set_local_privacy_cback -callback to be called with result
|
||||||
** Returns void
|
** Returns void
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable);
|
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
|
@ -145,6 +145,12 @@ static esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status)
|
|||||||
case BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED:
|
case BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED:
|
||||||
esp_status = ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED;
|
esp_status = ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED;
|
||||||
break;
|
break;
|
||||||
|
case BTM_SET_PRIVACY_SUCCESS:
|
||||||
|
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||||
|
break;
|
||||||
|
case BTM_SET_PRIVACY_FAIL:
|
||||||
|
esp_status = ESP_BT_STATUS_FAIL;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
esp_status = ESP_BT_STATUS_FAIL;
|
esp_status = ESP_BT_STATUS_FAIL;
|
||||||
break;
|
break;
|
||||||
@ -661,6 +667,23 @@ static void btc_set_pkt_length_callback(UINT8 status, tBTM_LE_SET_PKT_DATA_LENGT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void btc_set_local_privacy_callback(UINT8 status)
|
||||||
|
{
|
||||||
|
esp_ble_gap_cb_param_t param;
|
||||||
|
bt_status_t ret;
|
||||||
|
btc_msg_t msg;
|
||||||
|
msg.sig = BTC_SIG_API_CB;
|
||||||
|
msg.pid = BTC_PID_GAP_BLE;
|
||||||
|
msg.act = ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT;
|
||||||
|
param.local_privacy_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||||
|
ret = btc_transfer_context(&msg, ¶m,
|
||||||
|
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||||
|
|
||||||
|
if (ret != BT_STATUS_SUCCESS) {
|
||||||
|
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (SMP_INCLUDED == TRUE)
|
#if (SMP_INCLUDED == TRUE)
|
||||||
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
|
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
|
||||||
@ -756,9 +779,9 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void btc_ble_config_local_privacy(bool privacy_enable)
|
static void btc_ble_config_local_privacy(bool privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
|
||||||
{
|
{
|
||||||
BTA_DmBleConfigLocalPrivacy(privacy_enable);
|
BTA_DmBleConfigLocalPrivacy(privacy_enable, set_local_privacy_cback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void btc_ble_disconnect(BD_ADDR bd_addr)
|
static void btc_ble_disconnect(BD_ADDR bd_addr)
|
||||||
@ -837,6 +860,9 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
|||||||
case ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT:
|
case ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT:
|
||||||
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, param);
|
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, param);
|
||||||
break;
|
break;
|
||||||
|
case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
|
||||||
|
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, param);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1000,7 +1026,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY:
|
case BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY:
|
||||||
btc_ble_config_local_privacy(arg->cfg_local_privacy.privacy_enable);
|
btc_ble_config_local_privacy(arg->cfg_local_privacy.privacy_enable, btc_set_local_privacy_callback);
|
||||||
break;
|
break;
|
||||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
||||||
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
|
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
|
||||||
|
@ -60,6 +60,10 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
|
|||||||
btsnd_hcic_ble_set_random_addr(p_cb->private_addr);
|
btsnd_hcic_ble_set_random_addr(p_cb->private_addr);
|
||||||
|
|
||||||
p_cb->own_addr_type = BLE_ADDR_RANDOM;
|
p_cb->own_addr_type = BLE_ADDR_RANDOM;
|
||||||
|
if (p_cb->set_local_privacy_cback){
|
||||||
|
(*p_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS);
|
||||||
|
p_cb->set_local_privacy_cback = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* start a periodical timer to refresh random addr */
|
/* start a periodical timer to refresh random addr */
|
||||||
btu_stop_timer_oneshot(&p_cb->raddr_timer_ent);
|
btu_stop_timer_oneshot(&p_cb->raddr_timer_ent);
|
||||||
@ -73,6 +77,10 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
|
|||||||
} else {
|
} else {
|
||||||
/* random address set failure */
|
/* random address set failure */
|
||||||
BTM_TRACE_DEBUG("set random address failed");
|
BTM_TRACE_DEBUG("set random address failed");
|
||||||
|
if (p_cb->set_local_privacy_cback){
|
||||||
|
(*p_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL);
|
||||||
|
p_cb->set_local_privacy_cback = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -640,10 +640,16 @@ void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on)
|
|||||||
** Returns BOOLEAN privacy mode set success; otherwise failed.
|
** Returns BOOLEAN privacy mode set success; otherwise failed.
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode)
|
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
|
||||||
{
|
{
|
||||||
#if BLE_PRIVACY_SPT == TRUE
|
#if BLE_PRIVACY_SPT == TRUE
|
||||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||||
|
tBTM_LE_RANDOM_CB *random_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||||
|
if (random_cb){
|
||||||
|
random_cb->set_local_privacy_cback = set_local_privacy_cback;
|
||||||
|
}else{
|
||||||
|
BTM_TRACE_ERROR("%s,random_cb = NULL", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
BTM_TRACE_EVENT ("%s\n", __func__);
|
BTM_TRACE_EVENT ("%s\n", __func__);
|
||||||
|
|
||||||
|
@ -69,7 +69,9 @@ enum {
|
|||||||
BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
|
BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
|
||||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED, /* 20 Secure Connections Only Mode can't be supported */
|
BTM_MODE4_LEVEL4_NOT_SUPPORTED, /* 20 Secure Connections Only Mode can't be supported */
|
||||||
BTM_PEER_LE_DATA_LEN_UNSUPPORTED, /* 21 peer setting data length is unsupported*/
|
BTM_PEER_LE_DATA_LEN_UNSUPPORTED, /* 21 peer setting data length is unsupported*/
|
||||||
BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED /* 22 controller setting data length is unsupported*/
|
BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/
|
||||||
|
BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */
|
||||||
|
BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint8_t tBTM_STATUS;
|
typedef uint8_t tBTM_STATUS;
|
||||||
@ -175,6 +177,8 @@ typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM
|
|||||||
|
|
||||||
typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
|
typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
|
||||||
|
|
||||||
|
typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
|
** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
|
||||||
|
@ -1596,7 +1596,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
|
|||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
//extern
|
//extern
|
||||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable);
|
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
|
@ -185,6 +185,7 @@ typedef struct {
|
|||||||
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
||||||
void *p;
|
void *p;
|
||||||
TIMER_LIST_ENT raddr_timer_ent;
|
TIMER_LIST_ENT raddr_timer_ent;
|
||||||
|
tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||||
} tBTM_LE_RANDOM_CB;
|
} tBTM_LE_RANDOM_CB;
|
||||||
|
|
||||||
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
||||||
|
Loading…
x
Reference in New Issue
Block a user