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;
|
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->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
|
||||||
p_msg->disc_mode = disc_mode;
|
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;
|
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->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
|
||||||
p_msg->p_param= p_param;
|
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);
|
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;
|
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
|
#if BLE_INCLUDED == TRUE
|
||||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL *p_msg;
|
tBTA_DM_API_BLE_ADV_PARAMS_ALL *p_msg;
|
||||||
|
|
||||||
APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max);
|
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",
|
||||||
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS_ALL *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL))) != NULL)
|
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));
|
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL));
|
||||||
|
|
||||||
|
@ -790,7 +790,7 @@
|
|||||||
* resolution, local address rotation etc.
|
* resolution, local address rotation etc.
|
||||||
*/
|
*/
|
||||||
#ifndef BLE_PRIVACY_SPT
|
#ifndef BLE_PRIVACY_SPT
|
||||||
#define BLE_PRIVACY_SPT TRUE
|
#define BLE_PRIVACY_SPT FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -38,6 +38,22 @@
|
|||||||
|
|
||||||
tBUTTON_CB_ENV button_cb_env;
|
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;
|
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;
|
break;
|
||||||
case BTA_GATTS_CONNECT_EVT:
|
case BTA_GATTS_CONNECT_EVT:
|
||||||
//set the connection flag to true
|
//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));
|
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();
|
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_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
tBTM_STATUS status = BTM_SUCCESS;
|
tBTM_STATUS status = BTM_SUCCESS;
|
||||||
|
|
||||||
BTM_TRACE_EVENT ("BTM_BleSetAdvParams\n");
|
BTM_TRACE_EVENT ("BTM_BleSetAdvParamsStartAdv\n");
|
||||||
|
|
||||||
if (!controller_get_interface()->supports_ble())
|
if (!controller_get_interface()->supports_ble())
|
||||||
return BTM_ILLEGAL_VALUE;
|
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_addr_cb->own_addr_type = own_bda_type;
|
||||||
p_cb->evt_type = adv_type;
|
p_cb->evt_type = adv_type;
|
||||||
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||||
|
p_cb->afp = afp;
|
||||||
|
|
||||||
if (p_dir_bda)
|
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_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
tBTM_STATUS rt = BTM_NO_RESOURCES;
|
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))
|
if (!btm_ble_adv_states_operation (btm_ble_topology_check, p_cb->evt_type))
|
||||||
return BTM_WRONG_MODE;
|
return BTM_WRONG_MODE;
|
||||||
|
|
||||||
@ -3202,6 +3203,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
|||||||
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||||
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
|
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
|
||||||
rt = BTM_SUCCESS;
|
rt = BTM_SUCCESS;
|
||||||
|
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
|
||||||
}
|
}
|
||||||
else
|
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)
|
void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
||||||
{
|
{
|
||||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
|
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 */
|
/* Some device may request a connection before we are done with the HCI_Reset sequence */
|
||||||
if (!controller_get_interface()->get_is_ready())
|
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);
|
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||||
return;
|
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))
|
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);
|
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2759,7 +2759,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
|||||||
{
|
{
|
||||||
if (!p_dev_rec)
|
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);
|
btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2770,7 +2770,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc)
|
|||||||
&&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)
|
&&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD)
|
||||||
&&(!memcmp (btm_cb.pairing_bda, bda, BD_ADDR_LEN)))
|
&&(!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 */
|
/* incoming connection from bonding device is rejected */
|
||||||
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT;
|
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_REJECTED_CONNECT;
|
||||||
@ -4426,7 +4426,8 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
|||||||
UINT8 bit_shift = 0;
|
UINT8 bit_shift = 0;
|
||||||
|
|
||||||
btm_acl_resubmit_page();
|
btm_acl_resubmit_page();
|
||||||
|
|
||||||
|
BTM_TRACE_ERROR ("%s\n",__func__);
|
||||||
/* Commenting out trace due to obf/compilation problems.
|
/* Commenting out trace due to obf/compilation problems.
|
||||||
*/
|
*/
|
||||||
#if (BT_USE_TRACES == TRUE)
|
#if (BT_USE_TRACES == TRUE)
|
||||||
|
@ -58,6 +58,8 @@ void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_ERROR("API_Ble_AppStartAdvertising\n");
|
||||||
|
|
||||||
///
|
///
|
||||||
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
|
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
|
||||||
ble_adv_params->adv_int_max,
|
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*/
|
/*set connectable,discoverable, pairable and paired only modes of local device*/
|
||||||
tBTA_DM_DISC disc_mode = BTA_DM_BLE_GENERAL_DISCOVERABLE;
|
tBTA_DM_DISC disc_mode = BTA_DM_BLE_GENERAL_DISCOVERABLE;
|
||||||
tBTA_DM_CONN conn_mode = BTA_DM_BLE_CONNECTABLE;
|
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))
|
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||||
/* Enable local privacy */
|
/* 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_ijiazu_manu = {sizeof(ijiazu_manu),ijiazu_manu}; /* manufacturer data */
|
||||||
tBTA_BLE_MANU p_wechat_manu = {sizeof(wechat_manu),wechat_manu};
|
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};
|
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);
|
AirSync_Init(NULL);
|
||||||
#endif ///WX_AIRSYNC_CFG
|
#endif ///WX_AIRSYNC_CFG
|
||||||
|
|
||||||
API_Ble_AppStartAdvertising(&adv_params);
|
//API_Ble_AppStartAdvertising(&adv_params);
|
||||||
/*start advetising*/
|
/*start advetising*/
|
||||||
// BTA_GATTS_Listen(server_if, true, NULL);
|
// 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);
|
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
|
enum api_adv_filter
|
||||||
{
|
{
|
||||||
/// Start non connectable advertising
|
///Allow both scan and connection requests from anyone
|
||||||
API_ADV_NON_CONN,
|
ADV_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||||
/// Start undirected connectable advertising
|
///Allow both scan req from White List devices only and connection req from anyone
|
||||||
API_ADV_UNDIRECT,
|
ADV_ALLOW_SCAN_WLST_CON_ANY,
|
||||||
/// Start directed connectable advertising
|
///Allow both scan req from anyone and connection req from White List devices only
|
||||||
API_ADV_DIRECT_LOW_DUTY,
|
ADV_ALLOW_SCAN_ANY_CON_WLST,
|
||||||
/// Start directed connectable advertising
|
///Allow scan and connection requests from White List devices only
|
||||||
API_ADV_DIRECT
|
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
|
/// Own BD address source of the device
|
||||||
|
@ -15,7 +15,7 @@ void pingTask(void *pvParameters)
|
|||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
printf("ping\n");
|
//printf("ping\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user