component bt:Added the BLE scan API to the bt project

This commit is contained in:
yulong
2016-10-25 05:07:36 -04:00
parent 94442708f5
commit 78d1fd5306
11 changed files with 194 additions and 16 deletions

View File

@@ -4738,6 +4738,27 @@ void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data)
p_data->ble_set_scan_params.scan_param_setup_cback);
}
/*******************************************************************************
**
** Function bta_dm_ble_set_scan_fil_params
**
** Description This function sets BLE scan filter & parameters.
**
** Parameters:
**
*******************************************************************************/
void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data)
{
BTM_BleSetScanFilterParams (p_data->ble_set_scan_fil_params.client_if,
p_data->ble_set_scan_fil_params.scan_int,
p_data->ble_set_scan_fil_params.scan_window,
p_data->ble_set_scan_fil_params.scan_mode,
p_data->ble_set_scan_fil_params.addr_type_own,
p_data->ble_set_scan_fil_params.scan_filter_policy,
p_data->ble_set_scan_fil_params.scan_param_setup_cback);
}
/*******************************************************************************
**
** Function bta_dm_ble_set_conn_scan_params
@@ -4857,7 +4878,7 @@ void bta_dm_ble_observe (tBTA_DM_MSG *p_data)
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb))!= BTM_CMD_STARTED)
{
tBTA_DM_SEARCH data;
APPL_TRACE_WARNING(" %s BTM_BleObserve failed. status %d",__FUNCTION__,status);
APPL_TRACE_WARNING(" %s BTM_BleObserve failed. status %d\n",__FUNCTION__,status);
data.inq_cmpl.num_resps = 0;
if (bta_dm_search_cb.p_scan_cback)
{
@@ -4890,7 +4911,7 @@ void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data)
/*******************************************************************************
**
** Function BTM_BleSetAdvParamsStartAdv
** Function bta_dm_ble_set_adv_params_all
**
** Description This function is called to set all of the advertising parameters.
**

View File

@@ -860,6 +860,8 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
}
#endif
}
/*******************************************************************************
**
** Function BTA_DmSetBlePrefConnParams
@@ -965,6 +967,44 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
}
}
/*******************************************************************************
**
** Function BTA_DmSetBleScanFilterParams
**
** Description This function is called to set scan parameters
**
** Parameters: client_if - Client IF
** scan_interval - scan interval
** scan_window - scan window
** scan_mode - scan mode
** scan_param_setup_status_cback - Set scan param status callback
**
** Returns void
**
*******************************************************************************/
void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
{
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_FILTER_PARAMS))) != NULL)
{
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_FILTER_PARAMS));
p_msg->hdr.event = BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT;
p_msg->client_if = client_if;
p_msg->scan_int = scan_interval;
p_msg->scan_window = scan_window;
p_msg->scan_mode = scan_mode;
p_msg->addr_type_own = addr_type_own;
p_msg->scan_filter_policy = scan_fil_poilcy;
p_msg->scan_param_setup_cback = scan_param_setup_cback;
}
}
/*******************************************************************************
**
** Function BTA_DmSetBleAdvParams
@@ -1930,7 +1970,7 @@ void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cb
{
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
tBTA_DM_API_ENABLE_SCAN_FILTER *p_msg;
APPL_TRACE_API ("BTA_DmEnableScanFilter: %d", action);
APPL_TRACE_API ("BTA_DmEnableScanFilter: %d\n", action);
UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);

View File

@@ -90,6 +90,9 @@ enum
BTA_DM_API_BLE_CONN_PARAM_EVT,
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
BTA_DM_API_BLE_SCAN_PARAM_EVT,
/*******This event added by Yulong at 2016/10/25 to
support the scan filter setting for the APP******/
BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT,
BTA_DM_API_BLE_OBSERVE_EVT,
BTA_DM_API_UPDATE_CONN_PARAM_EVT,
/*******This event added by Yulong at 2016/9/9 to
@@ -476,6 +479,19 @@ typedef struct
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
}tBTA_DM_API_BLE_SCAN_PARAMS;
typedef struct
{
BT_HDR hdr;
tBTA_GATTC_IF client_if;
UINT32 scan_int;
UINT32 scan_window;
tBLE_SCAN_MODE scan_mode;
UINT8 addr_type_own;
UINT8 scan_filter_policy;
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
}tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
/* set scan parameter for BLE connections */
typedef struct
{
@@ -747,6 +763,7 @@ typedef union
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
tBTA_DM_API_BLE_CONN_SCAN_PARAMS ble_set_conn_scan_params;
tBTA_DM_API_BLE_SCAN_PARAMS ble_set_scan_params;
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params;
tBTA_DM_API_BLE_OBSERVE ble_observe;
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
@@ -1145,6 +1162,7 @@ extern void bta_dm_security_grant (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data);
extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);

View File

@@ -87,7 +87,8 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] =
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
bta_dm_ble_observe,
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
/*******This handler function added by Yulong at 2016/9/9 to
support the random address setting for the APP******/

View File

@@ -1901,6 +1901,27 @@ extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_mode,
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_status_cback);
/*******************************************************************************
**
** Function BTA_DmSetBleScanFilterParams
**
** Description This function is called to set scan parameters
**
** Parameters: client_if - Client IF
** scan_interval - scan interval
** scan_window - scan window
** scan_mode - scan mode
** scan_param_setup_status_cback - Set scan param status callback
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
/*******************************************************************************
**
** Function BTA_DmSetBleAdvParams

View File

@@ -26,9 +26,9 @@
#define ATT_UUID_128_LEN 0x0010
#define ATT_UUID_32_LEN 0x0004
#define WX_AIRSYNC_CFG 1
#define WX_AIRSYNC_CFG 0
#define BUT_PROFILE_CFG 1
#define HIDD_LE_PROFILE_CFG 1
#define HIDD_LE_PROFILE_CFG 0
/*
* Type Definition

View File

@@ -120,7 +120,7 @@ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy)
UINT32 scan_interval = !p_inq->scan_interval ? BTM_BLE_GAP_DISC_SCAN_INT : p_inq->scan_interval;
UINT32 scan_window = !p_inq->scan_window ? BTM_BLE_GAP_DISC_SCAN_WIN : p_inq->scan_window;
BTM_TRACE_EVENT ("%s", __func__);
BTM_TRACE_EVENT ("%s\n", __func__);
p_inq->sfp = scan_policy;
p_inq->scan_type = p_inq->scan_type == BTM_BLE_SCAN_MODE_NONE ? BTM_BLE_SCAN_MODE_ACTI : p_inq->scan_type;

View File

@@ -351,7 +351,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration,
UINT32 scan_interval = !p_inq->scan_interval ? BTM_BLE_GAP_DISC_SCAN_INT : p_inq->scan_interval;
UINT32 scan_window = !p_inq->scan_window ? BTM_BLE_GAP_DISC_SCAN_WIN : p_inq->scan_window;
BTM_TRACE_EVENT ("%s : scan_type:%d, %d, %d", __func__, btm_cb.btm_inq_vars.scan_type,
BTM_TRACE_EVENT ("%s : scan_type:%d, %d, %d\n", __func__, btm_cb.btm_inq_vars.scan_type,
p_inq->scan_interval, p_inq->scan_window);
if (!controller_get_interface()->supports_ble())
@@ -1193,7 +1193,7 @@ void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_
UINT32 max_scan_interval;
UINT32 max_scan_window;
BTM_TRACE_EVENT ("%s", __func__);
BTM_TRACE_EVENT ("%s\n", __func__);
if (!controller_get_interface()->supports_ble())
return;
@@ -1226,12 +1226,65 @@ void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_
if (scan_setup_status_cback != NULL)
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
BTM_TRACE_ERROR("Illegal params: scan_interval = %d scan_window = %d",
BTM_TRACE_ERROR("Illegal params: scan_interval = %d scan_window = %d\n",
scan_interval, scan_window);
}
}
void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, tBTM_BLE_SFP scan_filter_policy,
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback)
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
UINT32 max_scan_interval;
UINT32 max_scan_window;
BTM_TRACE_EVENT ("%s\n", __func__);
if (!controller_get_interface()->supports_ble())
return;
/* If not supporting extended scan support, use the older range for checking */
if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0)
{
max_scan_interval = BTM_BLE_SCAN_INT_MAX;
max_scan_window = BTM_BLE_SCAN_WIN_MAX;
}
else
{
/* If supporting extended scan support, use the new extended range for checking */
max_scan_interval = BTM_BLE_EXT_SCAN_INT_MAX;
max_scan_window = BTM_BLE_EXT_SCAN_WIN_MAX;
}
if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, max_scan_interval) &&
BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, max_scan_window) &&
(scan_mode == BTM_BLE_SCAN_MODE_ACTI || scan_mode == BTM_BLE_SCAN_MODE_PASS))
{
p_cb->scan_type = scan_mode;
p_cb->scan_interval = scan_interval;
p_cb->scan_window = scan_window;
p_cb->sfp = scan_filter_policy;
btsnd_hcic_ble_set_scan_params(p_cb->scan_type, (UINT16)scan_interval,
(UINT16)scan_window,
addr_type_own,
scan_filter_policy);
if (scan_setup_status_cback != NULL)
scan_setup_status_cback(client_if, BTM_SUCCESS);
}
else
{
if (scan_setup_status_cback != NULL)
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
BTM_TRACE_ERROR("Illegal params: scan_interval = %d scan_window = %d\n",
scan_interval, scan_window);
}
}
/*******************************************************************************
**
** Function BTM_BleWriteScanRsp

View File

@@ -464,13 +464,13 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
tGAP_ATTR *p_db_attr = gap_cb.gatt_attr;
UINT8 i = 0;
GAP_TRACE_EVENT("GAP_BleAttrDBUpdate attr_uuid=0x%04x", attr_uuid);
GAP_TRACE_EVENT("GAP_BleAttrDBUpdate attr_uuid=0x%04x\n", attr_uuid);
for (i = 0; i < GAP_MAX_CHAR_NUM; i ++, p_db_attr ++)
{
if (p_db_attr->uuid == attr_uuid)
{
GAP_TRACE_EVENT("Found attr_uuid=0x%04x", attr_uuid);
GAP_TRACE_EVENT("Found attr_uuid=0x%04x\n", attr_uuid);
switch (attr_uuid)
{
@@ -630,7 +630,7 @@ static void gap_ble_c_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
op_type = p_clcb->cl_op_uuid;
GAP_TRACE_EVENT ("gap_ble_c_cmpl_cback() - op_code: 0x%02x status: 0x%02x read_type: 0x%04x", op, status, op_type);
GAP_TRACE_EVENT ("gap_ble_c_cmpl_cback() - op_code: 0x%02x status: 0x%02x read_type: 0x%04x\n", op, status, op_type);
/* Currently we only issue read commands */
if (op != GATTC_OPTYPE_READ)
return;
@@ -660,7 +660,7 @@ static void gap_ble_c_cmpl_cback (UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
break;
case GATT_UUID_GAP_DEVICE_NAME:
GAP_TRACE_EVENT ("GATT_UUID_GAP_DEVICE_NAME");
GAP_TRACE_EVENT ("GATT_UUID_GAP_DEVICE_NAME\n");
len = (UINT16)strlen((char *)pp);
if (len > GAP_CHAR_DEV_NAME_SIZE)
len = GAP_CHAR_DEV_NAME_SIZE;

View File

@@ -680,7 +680,7 @@ tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
if ( (p_reg == NULL) || (p_tcb == NULL))
{
GATT_TRACE_ERROR ("GATTS_HandleValueNotification Unknown conn_id: %u ", conn_id);
GATT_TRACE_ERROR ("GATTS_HandleValueNotification Unknown conn_id: %u \n", conn_id);
return(tGATT_STATUS) GATT_INVALID_CONN_ID;
}
@@ -689,7 +689,7 @@ tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
notif.handle = attr_handle;
notif.len = val_len;
memcpy (notif.value, p_val, val_len);
notif.auth_req = GATT_AUTH_REQ_NONE;;
notif.auth_req = GATT_AUTH_REQ_NONE;
if ((p_buf = attp_build_sr_msg (p_tcb, GATT_HANDLE_VALUE_NOTIF, (tGATT_SR_MSG *)&notif))
!= NULL)

View File

@@ -1029,6 +1029,30 @@ void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval,
UINT32 scan_window, tBLE_SCAN_MODE scan_type,
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
/*******************************************************************************
**
** Function BTM_BleSetScanFilterParams
**
** Description This function is called to set Scan Filter & parameters.
**
** Parameters client_if - Client IF value
** scan_interval - Scan interval
** scan_window - Scan window
** scan_type - Scan type
** addr_type_own - owner address type
** scan_filter_policy - scan filter policy
** scan_setup_status_cback - Scan setup status callback
**
** Returns void
**
*******************************************************************************/
void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, tBTM_BLE_SFP scan_filter_policy,
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
/*******************************************************************************
**
** Function BTM_BleGetVendorCapabilities