mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component bt:added the advertising & scanning API to the bt project
This commit is contained in:
parent
fcf664276f
commit
94442708f5
@ -4888,6 +4888,28 @@ void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data)
|
|||||||
BTA_DM_BLE_ADV_CHNL_MAP);
|
BTA_DM_BLE_ADV_CHNL_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_BleSetAdvParamsStartAdv
|
||||||
|
**
|
||||||
|
** Description This function is called to set all of the advertising parameters.
|
||||||
|
**
|
||||||
|
** Parameters: None.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data)
|
||||||
|
{
|
||||||
|
BTM_BleSetAdvParamsStartAdv(p_data->ble_set_adv_params_all.adv_int_min,
|
||||||
|
p_data->ble_set_adv_params_all.adv_int_max,
|
||||||
|
p_data->ble_set_adv_params_all.adv_type,
|
||||||
|
p_data->ble_set_adv_params_all.addr_type_own,
|
||||||
|
p_data->ble_set_adv_params_all.p_dir_bda,
|
||||||
|
p_data->ble_set_adv_params_all.channel_map,
|
||||||
|
p_data->ble_set_adv_params_all.adv_filter_policy);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function bta_dm_ble_set_adv_config
|
** Function bta_dm_ble_set_adv_config
|
||||||
|
@ -1004,6 +1004,42 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||||
|
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
|
||||||
|
tBLE_BD_ADDR *p_dir_bda)
|
||||||
|
{
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL));
|
||||||
|
|
||||||
|
p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_All_EVT;
|
||||||
|
|
||||||
|
p_msg->adv_int_min = adv_int_min;
|
||||||
|
p_msg->adv_int_max = adv_int_max;
|
||||||
|
p_msg->adv_type = adv_type;
|
||||||
|
p_msg->addr_type_own = addr_type_own;
|
||||||
|
p_msg->channel_map = chnl_map;
|
||||||
|
p_msg->adv_filter_policy = adv_fil_pol;
|
||||||
|
if (p_dir_bda != NULL)
|
||||||
|
{
|
||||||
|
p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1);
|
||||||
|
memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
bta_sys_sendmsg(p_msg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** BLE ADV data management API
|
** BLE ADV data management API
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
@ -1498,7 +1534,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
|
|||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
||||||
{
|
{ ///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
|
||||||
tBTA_DM_API_LOCAL_PRIVACY *p_msg;
|
tBTA_DM_API_LOCAL_PRIVACY *p_msg;
|
||||||
|
|
||||||
@ -1534,7 +1570,7 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
|||||||
void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
||||||
tBTA_BLE_MULTI_ADV_CBACK *p_cback,
|
tBTA_BLE_MULTI_ADV_CBACK *p_cback,
|
||||||
void *p_ref)
|
void *p_ref)
|
||||||
{
|
{ ///This function just used for vendor debug
|
||||||
tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
|
tBTA_DM_API_BLE_MULTI_ADV_ENB *p_msg;
|
||||||
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
|
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB);
|
||||||
|
|
||||||
@ -1572,6 +1608,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
|
void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
|
||||||
{
|
{
|
||||||
|
///This function just used for vendor debug
|
||||||
tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
|
tBTA_DM_API_BLE_MULTI_ADV_PARAM *p_msg;
|
||||||
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
|
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
|
||||||
|
|
||||||
@ -1608,7 +1645,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
|
|||||||
void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
|
void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
|
||||||
tBTA_BLE_AD_MASK data_mask,
|
tBTA_BLE_AD_MASK data_mask,
|
||||||
tBTA_BLE_ADV_DATA *p_data)
|
tBTA_BLE_ADV_DATA *p_data)
|
||||||
{
|
{ ///This function just used for vendor debug
|
||||||
tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg;
|
tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg;
|
||||||
UINT16 len = sizeof(tBTA_DM_API_BLE_MULTI_ADV_DATA) ;
|
UINT16 len = sizeof(tBTA_DM_API_BLE_MULTI_ADV_DATA) ;
|
||||||
|
|
||||||
@ -1638,7 +1675,7 @@ void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
|
|||||||
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
|
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void BTA_BleDisableAdvInstance (UINT8 inst_id)
|
void BTA_BleDisableAdvInstance (UINT8 inst_id) //this function just used for vendor debug
|
||||||
{
|
{
|
||||||
tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
|
tBTA_DM_API_BLE_MULTI_ADV_DISABLE *p_msg;
|
||||||
|
|
||||||
|
@ -102,6 +102,10 @@ enum
|
|||||||
BTA_DM_API_LOCAL_PRIVACY_EVT,
|
BTA_DM_API_LOCAL_PRIVACY_EVT,
|
||||||
#endif
|
#endif
|
||||||
BTA_DM_API_BLE_ADV_PARAM_EVT,
|
BTA_DM_API_BLE_ADV_PARAM_EVT,
|
||||||
|
|
||||||
|
/*******This event added by Yulong at 2016/10/20 to
|
||||||
|
support setting the ble advertising param by the APP******/
|
||||||
|
BTA_DM_API_BLE_ADV_PARAM_All_EVT,
|
||||||
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
|
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
|
||||||
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
|
BTA_DM_API_BLE_SET_SCAN_RSP_EVT,
|
||||||
BTA_DM_API_BLE_BROADCAST_EVT,
|
BTA_DM_API_BLE_BROADCAST_EVT,
|
||||||
@ -514,6 +518,20 @@ typedef struct
|
|||||||
tBLE_BD_ADDR *p_dir_bda;
|
tBLE_BD_ADDR *p_dir_bda;
|
||||||
}tBTA_DM_API_BLE_ADV_PARAMS;
|
}tBTA_DM_API_BLE_ADV_PARAMS;
|
||||||
|
|
||||||
|
/* set adv parameter for BLE advertising */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BT_HDR hdr;
|
||||||
|
UINT16 adv_int_min;
|
||||||
|
UINT16 adv_int_max;
|
||||||
|
UINT8 adv_type;
|
||||||
|
tBLE_ADDR_TYPE addr_type_own;
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP channel_map;
|
||||||
|
tBTM_BLE_AFP adv_filter_policy;
|
||||||
|
tBLE_BD_ADDR *p_dir_bda;
|
||||||
|
}tBTA_DM_API_BLE_ADV_PARAMS_ALL;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BT_HDR hdr;
|
BT_HDR hdr;
|
||||||
@ -733,6 +751,7 @@ typedef union
|
|||||||
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
|
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
|
||||||
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
|
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
|
||||||
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
||||||
|
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||||
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
||||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||||
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
|
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
|
||||||
@ -1134,6 +1153,7 @@ extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
|||||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||||
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
||||||
|
extern void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data);
|
||||||
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
||||||
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
|
||||||
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
|
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
|
||||||
|
@ -99,6 +99,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] =
|
|||||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||||
#endif
|
#endif
|
||||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||||
|
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||||
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSPT */
|
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSPT */
|
||||||
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
||||||
|
@ -921,7 +921,7 @@ typedef struct
|
|||||||
} tBTA_DM_BOND_CANCEL_CMPL;
|
} tBTA_DM_BOND_CANCEL_CMPL;
|
||||||
|
|
||||||
/* Union of all security callback structures */
|
/* Union of all security callback structures */
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
tBTA_DM_ENABLE enable; /* BTA enabled */
|
tBTA_DM_ENABLE enable; /* BTA enabled */
|
||||||
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
|
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
|
||||||
@ -1918,6 +1918,13 @@ extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
|
extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||||
tBLE_BD_ADDR *p_dir_bda);
|
tBLE_BD_ADDR *p_dir_bda);
|
||||||
|
|
||||||
|
extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||||
|
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
|
||||||
|
tBLE_BD_ADDR *p_dir_bda);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTA_DmSearchExt
|
** Function BTA_DmSearchExt
|
||||||
|
@ -256,7 +256,7 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy)
|
|||||||
BD_ADDR p_addr_ptr= {0};
|
BD_ADDR p_addr_ptr= {0};
|
||||||
UINT8 adv_mode = p_cb->adv_mode;
|
UINT8 adv_mode = p_cb->adv_mode;
|
||||||
|
|
||||||
BTM_TRACE_EVENT ("BTM_BleUpdateAdvFilterPolicy");
|
BTM_TRACE_EVENT ("BTM_BleUpdateAdvFilterPolicy\n");
|
||||||
|
|
||||||
if (!controller_get_interface()->supports_ble())
|
if (!controller_get_interface()->supports_ble())
|
||||||
return;
|
return;
|
||||||
@ -1074,6 +1074,69 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_BleSetAdvParamsStartAdv
|
||||||
|
**
|
||||||
|
** Description This function is called to set all of the advertising parameters.
|
||||||
|
**
|
||||||
|
** Parameters: None.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
|
||||||
|
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp)
|
||||||
|
{
|
||||||
|
tBTM_LE_RANDOM_CB *p_addr_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||||
|
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
|
tBTM_STATUS status = BTM_SUCCESS;
|
||||||
|
|
||||||
|
BTM_TRACE_EVENT ("BTM_BleSetAdvParams\n");
|
||||||
|
|
||||||
|
if (!controller_get_interface()->supports_ble())
|
||||||
|
return BTM_ILLEGAL_VALUE;
|
||||||
|
|
||||||
|
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||||
|
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX))
|
||||||
|
{
|
||||||
|
return BTM_ILLEGAL_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_cb->adv_interval_min = adv_int_min;
|
||||||
|
p_cb->adv_interval_max = adv_int_max;
|
||||||
|
p_cb->adv_chnl_map = chnl_map;
|
||||||
|
p_addr_cb->own_addr_type = own_bda_type;
|
||||||
|
p_cb->evt_type = adv_type;
|
||||||
|
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||||
|
|
||||||
|
if (p_dir_bda)
|
||||||
|
{
|
||||||
|
memcpy(&p_cb->direct_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
BTM_TRACE_EVENT ("update params for an active adv\n");
|
||||||
|
|
||||||
|
btm_ble_stop_adv();
|
||||||
|
|
||||||
|
/* update adv params */
|
||||||
|
btsnd_hcic_ble_write_adv_params (adv_int_min,
|
||||||
|
adv_int_max,
|
||||||
|
adv_type,
|
||||||
|
own_bda_type,
|
||||||
|
p_dir_bda->type,
|
||||||
|
p_dir_bda->bda,
|
||||||
|
chnl_map,
|
||||||
|
p_cb->afp);
|
||||||
|
|
||||||
|
btm_ble_start_adv();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM_BleReadAdvParams
|
** Function BTM_BleReadAdvParams
|
||||||
@ -1888,7 +1951,7 @@ tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode)
|
|||||||
own_addr_type = p_addr_cb->own_addr_type;
|
own_addr_type = p_addr_cb->own_addr_type;
|
||||||
UINT16 adv_int_min, adv_int_max;
|
UINT16 adv_int_min, adv_int_max;
|
||||||
|
|
||||||
BTM_TRACE_EVENT ("%s mode=0x%0x combined_mode=0x%x", __FUNCTION__, mode, combined_mode);
|
BTM_TRACE_EVENT ("%s mode=0x%0x combined_mode=0x%x\n", __FUNCTION__, mode, combined_mode);
|
||||||
|
|
||||||
/*** Check mode parameter ***/
|
/*** Check mode parameter ***/
|
||||||
if (mode > BTM_BLE_MAX_CONNECTABLE)
|
if (mode > BTM_BLE_MAX_CONNECTABLE)
|
||||||
|
@ -941,6 +941,24 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
|
|||||||
tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
|
tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
|
||||||
tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
|
tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTM_BleSetAdvParamsStartAdv
|
||||||
|
**
|
||||||
|
** Description This function is called to set all of the advertising parameters.
|
||||||
|
**
|
||||||
|
** Parameters: None.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
|
||||||
|
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM_BleWriteAdvData
|
** Function BTM_BleWriteAdvData
|
||||||
|
@ -13,7 +13,62 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bt_app_api.h"
|
#include "bt_app_api.h"
|
||||||
|
#include "btm_ble_api.h"
|
||||||
|
|
||||||
|
void API_Ble_AppConfigAdvData(tESP_BLE_ADV_DATA *adv_data,
|
||||||
|
tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
|
||||||
|
{
|
||||||
|
if(adv_data != NULL)
|
||||||
|
{
|
||||||
|
ESP_AppBleConfigadvData(adv_data, p_adv_data_cback);
|
||||||
|
}else{
|
||||||
|
LOG_ERROR("The adv_data is NULL\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(++adv_data != NULL)
|
||||||
|
{
|
||||||
|
ESP_AppBleSetScanRsp(adv_data,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params)
|
||||||
|
{
|
||||||
|
if (!API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||||
|
!API_BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid advertisting interval parameters.\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ble_adv_params->adv_type < API_NON_DISCOVERABLE) &&
|
||||||
|
(ble_adv_params->adv_type > API_BROADCASTER_MODE) )
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid advertisting type parameters.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ble_adv_params->adv_filter_policy < API_ADV_NON_CONN) &&
|
||||||
|
(ble_adv_params->adv_filter_policy > API_ADV_DIRECT) )
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid advertisting type parameters.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
BTA_DmSetBleAdvParamsAll(ble_adv_params->adv_int_min,
|
||||||
|
ble_adv_params->adv_int_max,
|
||||||
|
ble_adv_params->adv_type,
|
||||||
|
ble_adv_params->addr_type_own,
|
||||||
|
ble_adv_params->channel_map,
|
||||||
|
ble_adv_params->adv_filter_policy,
|
||||||
|
ble_adv_params->p_dir_bda);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,35 @@
|
|||||||
****************************************************************************************
|
****************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "bt_types.h"
|
||||||
|
#include "bt_app_defs.h"
|
||||||
|
|
||||||
|
typedef tBTA_SET_ADV_DATA_CMPL_CBACK tAPI_SET_ADV_DATA_CMPL_CBACK ;
|
||||||
|
typedef tBTA_STATUS tAPI_STATUS;
|
||||||
|
|
||||||
|
extern void API_Ble_AppConfigAdvData(tESP_BLE_ADV_DATA *adv_data,
|
||||||
|
tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||||
|
|
||||||
|
extern void API_Ble_SetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
|
||||||
|
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||||
|
|
||||||
|
extern void API_Ble_SetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||||
|
UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
|
||||||
|
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
|
||||||
|
|
||||||
|
|
||||||
|
extern void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params);
|
||||||
|
|
||||||
|
extern void API_Ble_AppStopAdvertising(void);
|
||||||
|
|
||||||
|
extern void API_Ble_AppUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
|
||||||
|
UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||||
|
|
||||||
|
extern void API_Ble_SetPacketDataLength(BD_ADDR remote_device, UINT16 tx_data_length);
|
||||||
|
|
||||||
|
extern void API_Ble_SetRandAddress(BD_ADDR rand_addr);
|
||||||
|
|
||||||
|
extern void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable);
|
||||||
|
|
||||||
|
|
||||||
|
void API_Ble_PrfEnable();
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#include "bta_api.h"
|
#include "bta_api.h"
|
||||||
#include "btm_ble_api.h"
|
#include "btm_ble_api.h"
|
||||||
|
|
||||||
|
#define API_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||||
|
|
||||||
|
|
||||||
|
#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == API_BLE_CONN_PARAM_UNDEF))
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BLE_ADV_DATA_IDX,
|
BLE_ADV_DATA_IDX,
|
||||||
@ -8,12 +14,57 @@ enum
|
|||||||
ADV_SCAN_IDX_MAX
|
ADV_SCAN_IDX_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Advertising mode
|
||||||
|
enum api_adv_type
|
||||||
|
{
|
||||||
|
/// Mode in non-discoverable
|
||||||
|
API_NON_DISCOVERABLE,
|
||||||
|
/// Mode in general discoverable
|
||||||
|
API_GEN_DISCOVERABLE,
|
||||||
|
/// Mode in limited discoverable
|
||||||
|
API_LIM_DISCOVERABLE,
|
||||||
|
/// Broadcaster mode which is a non discoverable and non connectable mode.
|
||||||
|
API_BROADCASTER_MODE,
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *adv_name; //set the device name to be sent on the advertising
|
char *adv_name; //set the device name to be sent on the advertising
|
||||||
tBTA_BLE_ADV_DATA ble_adv_data;
|
tBTA_BLE_ADV_DATA ble_adv_data;
|
||||||
}tESP_BLE_ADV_DATA;
|
}tESP_BLE_ADV_DATA;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UINT16 adv_int_min;
|
||||||
|
UINT16 adv_int_max;
|
||||||
|
tBLE_BD_ADDR *p_dir_bda;
|
||||||
|
}tESP_BLE_ADV_PARAM;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UINT16 adv_int_min;
|
||||||
|
UINT16 adv_int_max;
|
||||||
|
UINT8 adv_type;
|
||||||
|
tBLE_ADDR_TYPE addr_type_own;
|
||||||
|
tBTM_BLE_ADV_CHNL_MAP channel_map;
|
||||||
|
tBTM_BLE_AFP adv_filter_policy;
|
||||||
|
tBLE_BD_ADDR *p_dir_bda;
|
||||||
|
}tESP_API_BLE_ADV_PARAMS_ALL;
|
||||||
|
|
||||||
|
|
||||||
extern void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data,
|
extern void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data,
|
||||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user