mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component bt:Change the profile function method to new API
This commit is contained in:
parent
5ede46f213
commit
d6db871068
@ -207,7 +207,7 @@ void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 p
|
||||
|
||||
tBTA_DM_API_SET_VISIBILITY *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
|
||||
if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_API_SET_VISIBILITY))) != NULL)
|
||||
{
|
||||
p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
|
||||
p_msg->disc_mode = disc_mode;
|
||||
@ -690,7 +690,7 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param)
|
||||
{
|
||||
tBTA_DM_API_EXECUTE_CBACK *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
|
||||
if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_API_EXECUTE_CBACK))) != NULL)
|
||||
{
|
||||
p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
|
||||
p_msg->p_param= p_param;
|
||||
@ -1025,9 +1025,10 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
|
||||
APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max);
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
|
||||
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS)
|
||||
+ sizeof(tBLE_BD_ADDR))) != NULL)
|
||||
{
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS));
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS)+sizeof(tBLE_BD_ADDR));
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_EVT;
|
||||
|
||||
@ -1053,9 +1054,11 @@ void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL *p_msg;
|
||||
|
||||
APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max);
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS_ALL *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL))) != NULL)
|
||||
APPL_TRACE_ERROR ("BTA_DmSetBleAdvParamsAll: %d, %d\n", adv_int_min, adv_int_max);
|
||||
APPL_TRACE_ERROR ("adv_type = %d, addr_type_own = %d, chnl_map = %d, adv_fil_pol = %d\n",
|
||||
adv_type,addr_type_own,chnl_map,adv_fil_pol);
|
||||
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS_ALL *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL)
|
||||
+ sizeof(tBLE_BD_ADDR))) != NULL)
|
||||
{
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL));
|
||||
|
||||
|
@ -790,7 +790,7 @@
|
||||
* resolution, local address rotation etc.
|
||||
*/
|
||||
#ifndef BLE_PRIVACY_SPT
|
||||
#define BLE_PRIVACY_SPT TRUE
|
||||
#define BLE_PRIVACY_SPT FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -38,6 +38,22 @@
|
||||
|
||||
tBUTTON_CB_ENV button_cb_env;
|
||||
|
||||
tBLE_BD_ADDR p_peer_bda = {
|
||||
.type = API_PUBLIC_ADDR,
|
||||
.bda = {0}
|
||||
};
|
||||
|
||||
tESP_API_BLE_ADV_PARAMS_ALL adv_params =
|
||||
{
|
||||
.adv_int_min = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||
.adv_int_max = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||
.adv_type = API_NON_DISCOVERABLE,
|
||||
.addr_type_own = API_PUBLIC_ADDR,
|
||||
.channel_map = API_BLE_ADV_CHNL_MAP,
|
||||
.adv_filter_policy = ADV_ALLOW_SCAN_ANY_CON_ANY,
|
||||
.p_dir_bda = &p_peer_bda
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -172,6 +188,9 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
///Start advertising
|
||||
LOG_ERROR("\nStart sent the ADV.\n");
|
||||
API_Ble_AppStartAdvertising(&adv_params);
|
||||
break;
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
|
@ -1051,7 +1051,7 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
memcpy(&p_cb->direct_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
|
||||
}
|
||||
|
||||
BTM_TRACE_EVENT ("update params for an active adv");
|
||||
BTM_TRACE_EVENT ("update params for an active adv\n");
|
||||
|
||||
btm_ble_stop_adv();
|
||||
|
||||
@ -1094,7 +1094,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
tBTM_STATUS status = BTM_SUCCESS;
|
||||
|
||||
BTM_TRACE_EVENT ("BTM_BleSetAdvParams\n");
|
||||
BTM_TRACE_EVENT ("BTM_BleSetAdvParamsStartAdv\n");
|
||||
|
||||
if (!controller_get_interface()->supports_ble())
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
@ -1111,6 +1111,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
p_addr_cb->own_addr_type = own_bda_type;
|
||||
p_cb->evt_type = adv_type;
|
||||
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||
p_cb->afp = afp;
|
||||
|
||||
if (p_dir_bda)
|
||||
{
|
||||
@ -3180,7 +3181,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
||||
{
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
tBTM_STATUS rt = BTM_NO_RESOURCES;
|
||||
|
||||
BTM_TRACE_EVENT ("btm_ble_start_adv\n");
|
||||
if (!btm_ble_adv_states_operation (btm_ble_topology_check, p_cb->evt_type))
|
||||
return BTM_WRONG_MODE;
|
||||
|
||||
@ -3202,6 +3203,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
||||
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
|
||||
rt = BTM_SUCCESS;
|
||||
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2731,11 +2731,11 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
|
||||
|
||||
BTM_TRACE_ERROR ("%s\n",__func__);
|
||||
/* Some device may request a connection before we are done with the HCI_Reset sequence */
|
||||
if (!controller_get_interface()->get_is_ready())
|
||||
{
|
||||
BTM_TRACE_EVENT ("Security Manager: connect request when device not ready");
|
||||
BTM_TRACE_ERROR ("Security Manager: connect request when device not ready\n");
|
||||
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||
return;
|
||||
}
|
||||
@ -2747,7 +2747,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
||||
{
|
||||
if (!p_dev_rec || !(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED))
|
||||
{
|
||||
BTM_TRACE_EVENT ("Security Manager: connect request from non-paired device");
|
||||
BTM_TRACE_ERROR ("Security Manager: connect request from non-paired device\n");
|
||||
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||
return;
|
||||
}
|
||||
@ -2759,7 +2759,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
||||
{
|
||||
if (!p_dev_rec)
|
||||
{
|
||||
BTM_TRACE_EVENT ("Security Manager: connect request from not paired device");
|
||||
BTM_TRACE_ERROR ("Security Manager: connect request from not paired device\n");
|
||||
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||
return;
|
||||
}
|
||||
@ -2770,7 +2770,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
||||
&&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)
|
||||
&&(!memcmp (btm_cb.pairing_bda, bda, BD_ADDR_LEN)))
|
||||
{
|
||||
BTM_TRACE_EVENT ("Security Manager: reject connect request from bonding device");
|
||||
BTM_TRACE_ERROR ("Security Manager: reject connect request from bonding device\n");
|
||||
|
||||
/* incoming connection from bonding device is rejected */
|
||||
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT;
|
||||
@ -4427,6 +4427,7 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
||||
|
||||
btm_acl_resubmit_page();
|
||||
|
||||
BTM_TRACE_ERROR ("%s\n",__func__);
|
||||
/* Commenting out trace due to obf/compilation problems.
|
||||
*/
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
|
@ -58,6 +58,8 @@ void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params)
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_ERROR("API_Ble_AppStartAdvertising\n");
|
||||
|
||||
///
|
||||
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
|
||||
ble_adv_params->adv_int_max,
|
||||
|
@ -252,7 +252,7 @@ static void bt_app_dm_upstreams_evt(UINT16 event, char *p_param)
|
||||
/*set connectable,discoverable, pairable and paired only modes of local device*/
|
||||
tBTA_DM_DISC disc_mode = BTA_DM_BLE_GENERAL_DISCOVERABLE;
|
||||
tBTA_DM_CONN conn_mode = BTA_DM_BLE_CONNECTABLE;
|
||||
BTA_DmSetVisibility(disc_mode, conn_mode, (UINT8)BTA_DM_NON_PAIRABLE, (UINT8)BTA_DM_CONN_ALL);
|
||||
//BTA_DmSetVisibility(disc_mode, conn_mode, (UINT8)BTA_DM_NON_PAIRABLE, (UINT8)BTA_DM_CONN_ALL);
|
||||
|
||||
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
/* Enable local privacy */
|
||||
|
@ -80,16 +80,7 @@ UINT8 wechat_manu[] = {0x00,0x00,0x18,0xfe,0x34,0x6a,0x86,0x2e};
|
||||
tBTA_BLE_MANU p_ijiazu_manu = {sizeof(ijiazu_manu),ijiazu_manu}; /* manufacturer data */
|
||||
tBTA_BLE_MANU p_wechat_manu = {sizeof(wechat_manu),wechat_manu};
|
||||
|
||||
tESP_API_BLE_ADV_PARAMS_ALL adv_params =
|
||||
{
|
||||
.adv_int_min = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||
.adv_int_max = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||
.adv_type = API_GEN_DISCOVERABLE,
|
||||
.addr_type_own = API_PUBLIC_ADDR,
|
||||
.channel_map = API_BLE_ADV_CHNL_MAP,
|
||||
.adv_filter_policy = API_ADV_UNDIRECT,
|
||||
{API_PUBLIC_ADDR,NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
BD_ADDR rand_ijiazu_addr = {0x00,0x02,0x5B,0x00,0x32,0x55};
|
||||
@ -269,7 +260,7 @@ static void bta_gatts_set_adv_data_cback(tBTA_STATUS call_status)
|
||||
AirSync_Init(NULL);
|
||||
#endif ///WX_AIRSYNC_CFG
|
||||
|
||||
API_Ble_AppStartAdvertising(&adv_params);
|
||||
//API_Ble_AppStartAdvertising(&adv_params);
|
||||
/*start advetising*/
|
||||
// BTA_GATTS_Listen(server_if, true, NULL);
|
||||
}
|
||||
|
@ -166,5 +166,3 @@ extern void API_Ble_GattsCancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda,
|
||||
|
||||
extern void API_Ble_GattsClose(UINT16 conn_id);
|
||||
|
||||
|
||||
void API_Ble_PrfEnable (void);
|
||||
|
@ -41,14 +41,16 @@ enum api_adv_type
|
||||
|
||||
enum api_adv_filter
|
||||
{
|
||||
/// Start non connectable advertising
|
||||
API_ADV_NON_CONN,
|
||||
/// Start undirected connectable advertising
|
||||
API_ADV_UNDIRECT,
|
||||
/// Start directed connectable advertising
|
||||
API_ADV_DIRECT_LOW_DUTY,
|
||||
/// Start directed connectable advertising
|
||||
API_ADV_DIRECT
|
||||
///Allow both scan and connection requests from anyone
|
||||
ADV_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||
///Allow both scan req from White List devices only and connection req from anyone
|
||||
ADV_ALLOW_SCAN_WLST_CON_ANY,
|
||||
///Allow both scan req from anyone and connection req from White List devices only
|
||||
ADV_ALLOW_SCAN_ANY_CON_WLST,
|
||||
///Allow scan and connection requests from White List devices only
|
||||
ADV_ALLOW_SCAN_WLST_CON_WLST,
|
||||
///Enumeration end value for advertising filter policy value check
|
||||
ADV_ALLOW_SCAN_END
|
||||
};
|
||||
|
||||
/// Own BD address source of the device
|
||||
|
@ -15,7 +15,7 @@ void pingTask(void *pvParameters)
|
||||
{
|
||||
while (1) {
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
printf("ping\n");
|
||||
//printf("ping\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user