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_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;
/// Advertising data maximum length
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 */
} 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;
/**
*******************************************************************************/
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
** 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
#if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
p_msg->privacy_enable = privacy_enable;
-
+ p_msg->set_local_privacy_cback = set_local_privacy_cback;
bta_sys_sendmsg(p_msg);
}
#else
typedef struct {
BT_HDR hdr;
BOOLEAN privacy_enable;
+ tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
} tBTA_DM_API_LOCAL_PRIVACY;
/* set scan parameter for BLE connections */
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 */
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
** Description Enable/disable privacy on the local device
**
** Parameters: privacy_enable - enable/disabe privacy on remote device.
-**
+** set_local_privacy_cback -callback to be called with result
** 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);
/*******************************************************************************
**
case BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED:
esp_status = ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED;
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:
esp_status = ESP_BT_STATUS_FAIL;
break;
}
}
+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)
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
}
}
-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)
case ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, param);
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:
break;
break;
}
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;
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
btsnd_hcic_ble_set_random_addr(p_cb->private_addr);
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 */
btu_stop_timer_oneshot(&p_cb->raddr_timer_ent);
} else {
/* random address set failure */
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;
+ }
}
}
/*******************************************************************************
** 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
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_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */
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_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 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
**
*******************************************************************************/
//extern
-BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable);
+BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
/*******************************************************************************
**
tBTM_BLE_ADDR_CBACK *p_generate_cback;
void *p;
TIMER_LIST_ENT raddr_timer_ent;
+ tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
} tBTM_LE_RANDOM_CB;
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10