From 979e3421c8111a56ebfcf176f6383df58eed52ea Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Wed, 10 Jun 2015 21:04:38 -0700 Subject: [PATCH] Fix mnc-dev <-> master merge errors Change-Id: If4d56229de7d47289560a12205feb7e33ac6fcf5 --- bta/dm/bta_dm_act.c | 22 +++++- bta/dm/bta_dm_api.c | 51 +++++++++++--- bta/dm/bta_dm_int.h | 15 +++-- bta/dm/bta_dm_main.c | 7 +- bta/include/bta_api.h | 35 +++++++--- btif/co/bta_ag_co.c | 2 + btif/src/btif_dm.c | 4 ++ btif/src/btif_gatt_client.c | 94 +++++++++++++++++++++++--- stack/btm/btm_ble.c | 12 ++-- stack/btm/btm_ble_adv_filter.c | 6 +- stack/btm/btm_ble_batchscan.c | 9 ++- stack/btm/btm_ble_bgconn.c | 72 ++++++++++++++------ stack/btm/btm_ble_gap.c | 148 ++++++++++++++++++++++++++++++----------- stack/btm/btm_ble_int.h | 8 ++- stack/include/btm_api.h | 3 +- stack/include/btm_ble_api.h | 31 ++++++--- stack/include/gatt_api.h | 2 +- stack/include/hcidefs.h | 3 + stack/include/hcimsgs.h | 1 + 19 files changed, 399 insertions(+), 126 deletions(-) diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c index 34f779bd6..5775296d8 100644 --- a/bta/dm/bta_dm_act.c +++ b/bta/dm/bta_dm_act.c @@ -4677,12 +4677,30 @@ void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data) ** ** Function bta_dm_ble_set_scan_params ** +** Description This function sets BLE scan parameters. +** +** Parameters: +** +*******************************************************************************/ +void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data) +{ + BTM_BleSetScanParams(p_data->ble_set_scan_params.client_if, + p_data->ble_set_scan_params.scan_int, + p_data->ble_set_scan_params.scan_window, + p_data->ble_set_scan_params.scan_mode, + p_data->ble_set_scan_params.scan_param_setup_cback); +} + +/******************************************************************************* +** +** Function bta_dm_ble_set_conn_scan_params +** ** Description This function set the preferred connection scan parameters. ** ** Parameters: ** *******************************************************************************/ -void bta_dm_ble_set_scan_params (tBTA_DM_MSG *p_data) +void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data) { BTM_BleSetConnScanParams(p_data->ble_set_scan_params.scan_int, p_data->ble_set_scan_params.scan_window); @@ -4759,7 +4777,7 @@ void bta_dm_ble_observe (tBTA_DM_MSG *p_data) } /******************************************************************************* ** -** Function bta_dm_ble_set_scan_params +** Function bta_dm_ble_set_adv_params ** ** Description This function set the adv parameters. ** diff --git a/bta/dm/bta_dm_api.c b/bta/dm/bta_dm_api.c index 53488a232..c9566e96f 100644 --- a/bta/dm/bta_dm_api.c +++ b/bta/dm/bta_dm_api.c @@ -904,23 +904,52 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr, ** Returns void ** *******************************************************************************/ -void BTA_DmSetBleConnScanParams(UINT16 scan_interval, UINT16 scan_window ) +void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window) { -#if BLE_INCLUDED == TRUE - tBTA_DM_API_BLE_SCAN_PARAMS *p_msg; - - if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) + tBTA_DM_API_BLE_SCAN_PARAMS *p_msg; + if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS)); - - p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT; - + p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT; p_msg->scan_int = scan_interval; p_msg->scan_window = scan_window; + bta_sys_sendmsg(p_msg); + } +} + +/******************************************************************************* +** +** Function BTA_DmSetBleScanParams +** +** 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_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval, + UINT32 scan_window, tBLE_SCAN_MODE scan_mode, + tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback) +{ + tBTA_DM_API_BLE_SCAN_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) + { + memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS)); + p_msg->hdr.event = BTA_DM_API_BLE_SCAN_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->scan_param_setup_cback = scan_param_setup_cback; bta_sys_sendmsg(p_msg); } -#endif } /******************************************************************************* @@ -1085,7 +1114,7 @@ extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max, ** Returns None ** *******************************************************************************/ -extern void BTA_DmBleEnableBatchScan(tBTA_BLE_SCAN_MODE scan_mode, +extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode, UINT32 scan_interval, UINT32 scan_window, tBTA_BLE_DISCARD_RULE discard_rule, tBLE_ADDR_TYPE addr_type, @@ -1142,7 +1171,7 @@ extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value) ** Returns None ** *******************************************************************************/ -extern void BTA_DmBleReadScanReports(tBTA_BLE_SCAN_MODE scan_type, +extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type, tBTA_DM_BLE_REF_VALUE ref_value) { tBTA_DM_API_READ_SCAN_REPORTS *p_msg; diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h index 4cf663bff..b7c85ddea 100644 --- a/bta/dm/bta_dm_int.h +++ b/bta/dm/bta_dm_int.h @@ -90,6 +90,7 @@ enum BTA_DM_API_BLE_SET_BG_CONN_TYPE, BTA_DM_API_BLE_CONN_PARAM_EVT, BTA_DM_API_BLE_SCAN_PARAM_EVT, + BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT, BTA_DM_API_BLE_OBSERVE_EVT, BTA_DM_API_UPDATE_CONN_PARAM_EVT, #if BLE_PRIVACY_SPT == TRUE @@ -454,9 +455,12 @@ typedef struct /* set scan parameter for BLE connections */ typedef struct { - BT_HDR hdr; - UINT16 scan_int; - UINT16 scan_window; + BT_HDR hdr; + tBTA_GATTC_IF client_if; + UINT32 scan_int; + UINT32 scan_window; + tBLE_SCAN_MODE scan_mode; + tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback; }tBTA_DM_API_BLE_SCAN_PARAMS; /* Data type for start/stop observe */ @@ -545,7 +549,7 @@ typedef struct typedef struct { BT_HDR hdr; - tBTA_BLE_SCAN_MODE scan_mode; + tBTA_BLE_BATCH_SCAN_MODE scan_mode; UINT32 scan_int; UINT32 scan_window; tBTA_BLE_DISCARD_RULE discard_rule; @@ -562,7 +566,7 @@ typedef struct typedef struct { BT_HDR hdr; - tBTA_BLE_SCAN_MODE scan_type; + tBTA_BLE_BATCH_SCAN_MODE scan_type; tBTA_DM_BLE_REF_VALUE ref_value; } tBTA_DM_API_READ_SCAN_REPORTS; @@ -1060,6 +1064,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_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); extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data); diff --git a/bta/dm/bta_dm_main.c b/bta/dm/bta_dm_main.c index 450151a21..27c4682ec 100644 --- a/bta/dm/bta_dm_main.c +++ b/bta/dm/bta_dm_main.c @@ -85,14 +85,15 @@ const tBTA_DM_ACTION bta_dm_action[] = bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */ bta_dm_security_grant, bta_dm_ble_set_bg_conn_type, - bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */ - bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */ + bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */ + bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */ + bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */ bta_dm_ble_observe, bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */ #if BLE_PRIVACY_SPT == TRUE bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */ #endif - bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */ + bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_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_RSP_EVT */ bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */ diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h index 0fbf20e24..4bc4d7567 100644 --- a/bta/include/bta_api.h +++ b/bta/include/bta_api.h @@ -459,11 +459,11 @@ typedef struct enum { - BTA_BLE_SCAN_MODE_PASS=1, - BTA_BLE_SCAN_MODE_ACTI=2, - BTA_BLE_SCAN_MODE_PASS_ACTI=3 + BTA_BLE_BATCH_SCAN_MODE_PASS = 1, + BTA_BLE_BATCH_SCAN_MODE_ACTI = 2, + BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3 }; -typedef UINT8 tBTA_BLE_SCAN_MODE; +typedef UINT8 tBTA_BLE_BATCH_SCAN_MODE; enum { @@ -1867,8 +1867,27 @@ extern void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr, ** Returns void ** *******************************************************************************/ -extern void BTA_DmSetBleConnScanParams(UINT16 scan_interval, - UINT16 scan_window ); +extern void BTA_DmSetBleConnScanParams(UINT32 scan_interval, + UINT32 scan_window); + +/******************************************************************************* +** +** Function BTA_DmSetBleScanParams +** +** 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_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); /******************************************************************************* ** @@ -2199,7 +2218,7 @@ extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max, ** Returns None ** *******************************************************************************/ -extern void BTA_DmBleEnableBatchScan(tBTA_BLE_SCAN_MODE scan_mode, +extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode, UINT32 scan_interval, UINT32 scan_window, tBTA_BLE_DISCARD_RULE discard_rule, tBLE_ADDR_TYPE addr_type, @@ -2217,7 +2236,7 @@ extern void BTA_DmBleEnableBatchScan(tBTA_BLE_SCAN_MODE scan_mode, ** Returns None ** *******************************************************************************/ -extern void BTA_DmBleReadScanReports(tBTA_BLE_SCAN_MODE scan_type, +extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type, tBTA_DM_BLE_REF_VALUE ref_value); /******************************************************************************* diff --git a/btif/co/bta_ag_co.c b/btif/co/bta_ag_co.c index 31f58d825..e18cc9d9d 100755 --- a/btif/co/bta_ag_co.c +++ b/btif/co/bta_ag_co.c @@ -18,6 +18,8 @@ #define LOG_TAG "bt_btif_bta_ag" +#include + #include "bta/include/bta_ag_api.h" #include "hci/include/hci_audio.h" #include "osi/include/osi.h" diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index ee01347c7..24aad27a6 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -1946,6 +1946,10 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) local_le_features.version_supported = cmn_vsc_cb.version_supported; local_le_features.total_trackable_advertisers = cmn_vsc_cb.total_trackable_advertisers; + + local_le_features.extended_scan_support = cmn_vsc_cb.extended_scan_support > 0; + local_le_features.debug_logging_supported = cmn_vsc_cb.debug_logging_supported > 0; + memcpy(prop.val, &local_le_features, prop.len); HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, BT_STATUS_SUCCESS, 1, &prop); break; diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c index 283a53105..295f74a1c 100644 --- a/btif/src/btif_gatt_client.c +++ b/btif/src/btif_gatt_client.c @@ -116,7 +116,8 @@ typedef enum { #define BTIF_GATT_OBSERVE_EVT 0x1000 #define BTIF_GATTC_RSSI_EVT 0x1001 -#define BTIF_GATTC_SCAN_FILTER_EVT 0x1003 +#define BTIF_GATTC_SCAN_FILTER_EVT 0x1003 +#define BTIF_GATTC_SCAN_PARAM_EVT 0x1004 #define ENABLE_BATCH_SCAN 1 #define DISABLE_BATCH_SCAN 0 @@ -143,7 +144,7 @@ typedef struct uint8_t batch_scan_full_max; uint8_t batch_scan_trunc_max; uint8_t batch_scan_notify_threshold; - tBTA_BLE_SCAN_MODE scan_mode; + tBTA_BLE_BATCH_SCAN_MODE scan_mode; uint32_t scan_interval; uint32_t scan_window; tBTA_BLE_DISCARD_RULE discard_rule; @@ -190,8 +191,8 @@ typedef struct uint16_t conn_id; uint16_t len; uint16_t mask; - uint16_t scan_interval; - uint16_t scan_window; + uint32_t scan_interval; + uint32_t scan_window; uint8_t client_if; uint8_t action; uint8_t is_direct; @@ -250,6 +251,62 @@ static void btif_multi_adv_stop_cb(void *p_tle) btif_gattc_multi_adv_disable(client_if); // Does context switch } +static btgattc_error_t btif_gattc_translate_btm_status(tBTM_STATUS status) +{ + switch(status) + { + case BTM_SUCCESS: + case BTM_SUCCESS_NO_SECURITY: + return BT_GATTC_COMMAND_SUCCESS; + + case BTM_CMD_STARTED: + return BT_GATTC_COMMAND_STARTED; + + case BTM_BUSY: + return BT_GATTC_COMMAND_BUSY; + + case BTM_CMD_STORED: + return BT_GATTC_COMMAND_STORED; + + case BTM_NO_RESOURCES: + return BT_GATTC_NO_RESOURCES; + + case BTM_MODE_UNSUPPORTED: + case BTM_WRONG_MODE: + case BTM_MODE4_LEVEL4_NOT_SUPPORTED: + return BT_GATTC_MODE_UNSUPPORTED; + + case BTM_ILLEGAL_VALUE: + case BTM_SCO_BAD_LENGTH: + return BT_GATTC_ILLEGAL_VALUE; + + case BTM_UNKNOWN_ADDR: + return BT_GATTC_UNKNOWN_ADDR; + + case BTM_DEVICE_TIMEOUT: + return BT_GATTC_DEVICE_TIMEOUT; + + case BTM_FAILED_ON_SECURITY: + case BTM_REPEATED_ATTEMPTS: + case BTM_NOT_AUTHORIZED: + return BT_GATTC_SECURITY_ERROR; + + case BTM_DEV_RESET: + case BTM_ILLEGAL_ACTION: + return BT_GATTC_INCORRECT_STATE; + + case BTM_BAD_VALUE_RET: + return BT_GATTC_INVALID_CONTROLLER_OUTPUT; + + case BTM_DELAY_CHECK: + return BT_GATTC_DELAYED_ENCRYPTION_CHECK; + + case BTM_ERR_PROCESSING: + default: + return BT_GATTC_ERR_PROCESSING; + } +} + static void btapp_gattc_req_data(UINT16 event, char *p_dest, char *p_src) { tBTA_GATTC *p_dest_data = (tBTA_GATTC*) p_dest; @@ -579,9 +636,7 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) { btif_gattc_add_remote_bdaddr(p_btif_cb->bd_addr.address, p_btif_cb->addr_type); btif_gattc_update_properties(p_btif_cb); - } - } dev_type = p_btif_cb->device_type; @@ -779,6 +834,14 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) break; } + case BTIF_GATTC_SCAN_PARAM_EVT: + { + btif_gattc_cb_t *p_btif_cb = (btif_gattc_cb_t *)p_param; + HAL_CBACK(bt_gatt_callbacks, client->scan_parameter_setup_completed_cb, + p_btif_cb->client_if, btif_gattc_translate_btm_status(p_btif_cb->status)); + break; + } + default: LOG_ERROR("%s: Unhandled event (%d)!", __FUNCTION__, event); break; @@ -1011,6 +1074,16 @@ static void btm_read_rssi_cb (tBTM_RSSI_RESULTS *p_result) (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL); } +static void bta_scan_param_setup_cb(tGATT_IF client_if, tBTM_STATUS status) +{ + btif_gattc_cb_t btif_cb; + + btif_cb.status = status; + btif_cb.client_if = client_if; + btif_transfer_context(btif_gattc_upstreams_evt, BTIF_GATTC_SCAN_PARAM_EVT, + (char *)&btif_cb, sizeof(btif_gattc_cb_t), NULL); +} + static void bta_scan_filt_cfg_cb(tBTA_DM_BLE_PF_ACTION action, tBTA_DM_BLE_SCAN_COND_OP cfg_op, tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_STATUS status, tBTA_DM_BLE_REF_VALUE ref_value) @@ -1641,8 +1714,11 @@ static void btgattc_handle_event(uint16_t event, char* p_param) } case BTIF_GATTC_SET_SCAN_PARAMS: - BTM_BleSetScanParams(p_cb->scan_interval, p_cb->scan_window, BTM_BLE_SCAN_MODE_ACTI); + { + BTA_DmSetBleScanParams(p_cb->client_if, p_cb->scan_interval, p_cb->scan_window, + BTM_BLE_SCAN_MODE_ACTI, bta_scan_param_setup_cb); break; + } case BTIF_GATTC_CONFIG_STORAGE_PARAMS: { @@ -2118,10 +2194,12 @@ static bt_status_t btif_gattc_scan_filter_enable(int client_if, bool enable) (char*) &btif_filt_cb, sizeof(btgatt_adv_filter_cb_t), NULL); } -static bt_status_t btif_gattc_set_scan_parameters(int scan_interval, int scan_window) +static bt_status_t btif_gattc_set_scan_parameters(int client_if, int scan_interval, + int scan_window) { CHECK_BTGATT_INIT(); btif_gattc_cb_t btif_cb; + btif_cb.client_if = client_if; btif_cb.scan_interval = scan_interval; btif_cb.scan_window = scan_window; return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_SCAN_PARAMS, diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c index 45f8e6f79..595489865 100644 --- a/stack/btm/btm_ble.c +++ b/stack/btm/btm_ble.c @@ -500,14 +500,14 @@ void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data) ** Returns void ** *******************************************************************************/ -void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window) +void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window) { #if SMP_INCLUDED == TRUE tBTM_BLE_CB *p_ble_cb = &btm_cb.ble_ctr_cb; BOOLEAN new_param = FALSE; - if (BTM_BLE_VALID_PRAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && - BTM_BLE_VALID_PRAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX)) + if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && + BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX)) { if (p_ble_cb->scan_int != scan_interval) { @@ -560,9 +560,9 @@ void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, tout: %u", min_conn_int, max_conn_int, slave_latency, supervision_tout); - if (BTM_BLE_VALID_PRAM(min_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && - BTM_BLE_VALID_PRAM(max_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && - BTM_BLE_VALID_PRAM(supervision_tout, BTM_BLE_CONN_SUP_TOUT_MIN, BTM_BLE_CONN_SUP_TOUT_MAX) && + if (BTM_BLE_ISVALID_PARAM(min_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && + BTM_BLE_ISVALID_PARAM(max_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && + BTM_BLE_ISVALID_PARAM(supervision_tout, BTM_BLE_CONN_SUP_TOUT_MIN, BTM_BLE_CONN_SUP_TOUT_MAX) && (slave_latency <= BTM_BLE_CONN_LATENCY_MAX || slave_latency == BTM_BLE_CONN_PARAM_UNDEF)) { if (p_dev_rec) diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.c index ad6a56ca5..74dddddcd 100644 --- a/stack/btm/btm_ble_adv_filter.c +++ b/stack/btm/btm_ble_adv_filter.c @@ -1106,12 +1106,12 @@ tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, tBTM_BLE_PF_FILT_INDEX filt_i UINT8_TO_STREAM(p, p_filt_params->rssi_low_thres); /* set onlost timeout */ UINT16_TO_STREAM(p, p_filt_params->lost_timeout); - /* set num_of_track_entries for firmware supporting v0.90 spec and greater */ - if (cmn_ble_vsc_cb.version_supported > 0) + /* set num_of_track_entries for firmware greater than L-release version */ + if (cmn_ble_vsc_cb.version_supported > BTM_VSC_CHIP_CAPABILITY_L_VERSION) UINT16_TO_STREAM(p, p_filt_params->num_of_tracking_entries); } - if (0 == cmn_ble_vsc_cb.version_supported) + if (cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_L_VERSION) len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN; else len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN + diff --git a/stack/btm/btm_ble_batchscan.c b/stack/btm/btm_ble_batchscan.c index d8add82f0..3b6d2a9b3 100644 --- a/stack/btm/btm_ble_batchscan.c +++ b/stack/btm/btm_ble_batchscan.c @@ -82,9 +82,8 @@ void btm_ble_batchscan_filter_track_adv_vse_cback(UINT8 len, UINT8 *p) memset(&adv_data, 0 , sizeof(tBTM_BLE_TRACK_ADV_DATA)); BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); adv_data.client_if = (UINT8)ble_advtrack_cb.ref_value; - if (cmn_ble_vsc_cb.version_supported > 0) + if (cmn_ble_vsc_cb.version_supported > BTM_VSC_CHIP_CAPABILITY_L_VERSION) { - /* Based on spec v0.90 */ STREAM_TO_UINT8(adv_data.filt_index, p); STREAM_TO_UINT8(adv_data.advertiser_state, p); STREAM_TO_UINT8(adv_data.advertiser_info_present, p); @@ -115,7 +114,7 @@ void btm_ble_batchscan_filter_track_adv_vse_cback(UINT8 len, UINT8 *p) } else { - /* Based on spec v0.52 */ + /* Based on L-release version */ STREAM_TO_UINT8(adv_data.filt_index, p); STREAM_TO_UINT8(adv_data.addr_type, p); STREAM_TO_BDADDR(adv_data.bd_addr.address, p); @@ -742,8 +741,8 @@ tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, /* Only 16 bits will be used for scan interval and scan window as per agreement with Google */ /* So the standard LE range would suffice for scan interval and scan window */ - if ((BTM_BLE_VALID_PRAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) || - BTM_BLE_VALID_PRAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX)) + if ((BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) || + BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX)) && (BTM_BLE_BATCH_SCAN_MODE_PASS == scan_mode || BTM_BLE_BATCH_SCAN_MODE_ACTI == scan_mode || BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI == scan_mode) && (BTM_BLE_DISCARD_OLD_ITEMS == discard_rule || diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c index 9e7ce9c4b..f66ef9fbd 100644 --- a/stack/btm/btm_ble_bgconn.c +++ b/stack/btm/btm_ble_bgconn.c @@ -112,21 +112,33 @@ static bool background_connections_pending() { ** ** Function btm_update_scanner_filter_policy ** -** Description This function update the filter policy of scnner or advertiser. +** Description This function updates the filter policy of scanner *******************************************************************************/ void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy) { tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var; - BTM_TRACE_EVENT ("btm_update_scanner_filter_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__); 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; + p_inq->scan_type = p_inq->scan_type == BTM_BLE_SCAN_MODE_NONE ? BTM_BLE_SCAN_MODE_ACTI : p_inq->scan_type; - btsnd_hcic_ble_set_scan_params (p_inq->scan_type, - (UINT16)(!p_inq->scan_interval ? BTM_BLE_GAP_DISC_SCAN_INT : p_inq->scan_interval), - (UINT16)(!p_inq->scan_window ? BTM_BLE_GAP_DISC_SCAN_WIN : p_inq->scan_window), - btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, - scan_policy); + if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) + { + btsnd_hcic_ble_set_scan_params(p_inq->scan_type, (UINT16)scan_interval, + (UINT16)scan_window, + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, + scan_policy); + } + else + { + btm_ble_send_extended_scan_params(p_inq->scan_type, scan_interval, scan_window, + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, + scan_policy); + } } /******************************************************************************* ** @@ -452,14 +464,13 @@ BOOLEAN btm_ble_start_auto_conn(BOOLEAN start) ** Returns BOOLEAN: selective connectino procedure is started. ** *******************************************************************************/ -BOOLEAN btm_ble_start_select_conn(BOOLEAN start,tBTM_BLE_SEL_CBACK *p_select_cback) +BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cback) { tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; UINT32 scan_int = p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int; UINT32 scan_win = p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win; - scan_int = (p_cb->scan_int == BTM_BLE_CONN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int; - scan_win = (p_cb->scan_win == BTM_BLE_CONN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win; + BTM_TRACE_EVENT ("%s", __func__); if (start) { @@ -473,13 +484,30 @@ BOOLEAN btm_ble_start_select_conn(BOOLEAN start,tBTM_BLE_SEL_CBACK *p_select_c btm_update_scanner_filter_policy(SP_ADV_WL); btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_PASS; - if (!btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS, /* use passive scan by default */ - scan_int, /* scan interval */ - scan_win, /* scan window */ - p_cb->addr_mgnt_cb.own_addr_type, - SP_ADV_WL) /* process advertising packets only from devices in the White List */ - ) - return FALSE; + /* Process advertising packets only from devices in the white list */ + if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) + { + /* use passive scan by default */ + if (!btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS, + scan_int, + scan_win, + p_cb->addr_mgnt_cb.own_addr_type, + SP_ADV_WL)) + { + return FALSE; + } + } + else + { + if (!btm_ble_send_extended_scan_params(BTM_BLE_SCAN_MODE_PASS, + scan_int, + scan_win, + p_cb->addr_mgnt_cb.own_addr_type, + SP_ADV_WL)) + { + return FALSE; + } + } if (!btm_ble_topology_check(BTM_BLE_STATE_PASSIVE_SCAN)) { @@ -492,11 +520,11 @@ BOOLEAN btm_ble_start_select_conn(BOOLEAN start,tBTM_BLE_SEL_CBACK *p_select_c btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN); #endif if (!btsnd_hcic_ble_set_scan_enable(TRUE, TRUE)) /* duplicate filtering enabled */ - return FALSE; + return FALSE; - /* mark up inquiry status flag */ - p_cb->scan_activity |= BTM_LE_SELECT_CONN_ACTIVE; - p_cb->wl_state |= BTM_BLE_WL_SCAN; + /* mark up inquiry status flag */ + p_cb->scan_activity |= BTM_LE_SELECT_CONN_ACTIVE; + p_cb->wl_state |= BTM_BLE_WL_SCAN; } } else diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c index 154f047c8..43d0f3638 100644 --- a/stack/btm/btm_ble_gap.c +++ b/stack/btm/btm_ble_gap.c @@ -53,7 +53,9 @@ #define BTM_EXT_BLE_RMT_NAME_TIMEOUT 30 #define MIN_ADV_LENGTH 2 -#define BTM_NEW_VSC_CHIP_CAPBLTY_RSP_LEN 13 +#define BTM_VSC_CHIP_CAPABILITY_RSP_LEN_L_RELEASE 9 + +static tBTM_BLE_VSC_CB cmn_ble_vsc_cb; #if BLE_VND_INCLUDED == TRUE static tBTM_BLE_CTRL_FEATURES_CBACK *p_ctrl_le_feature_rd_cmpl_cback = NULL; @@ -286,6 +288,47 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) } } + +/******************************************************************************* +** +** Function btm_ble_send_extended_scan_params +** +** Description This function sends out the extended scan parameters command to the controller +** +** Parameters scan_type - Scan type +** scan_int - Scan interval +** scan_win - Scan window +** addr_type_own - Own address type +** scan_filter_policy - Scan filter policy +** +** Returns TRUE or FALSE +** +*******************************************************************************/ +BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int, + UINT32 scan_win, UINT8 addr_type_own, + UINT8 scan_filter_policy) +{ + UINT8 scan_param[HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM]; + UINT8 *pp_scan = scan_param; + + memset(scan_param, 0, HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM); + + UINT8_TO_STREAM(pp_scan, scan_type); + UINT32_TO_STREAM(pp_scan, scan_int); + UINT32_TO_STREAM(pp_scan, scan_win); + UINT8_TO_STREAM(pp_scan, addr_type_own); + UINT8_TO_STREAM(pp_scan, scan_filter_policy); + + BTM_TRACE_DEBUG("%s, %d, %d", __func__, scan_int, scan_win); + if ((BTM_VendorSpecificCommand(HCI_BLE_EXTENDED_SCAN_PARAMS_OCF, + HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM, scan_param, NULL)) != BTM_SUCCESS) + { + BTM_TRACE_ERROR("%s error sending extended scan parameters", __func__); + return FALSE; + } + return TRUE; +} + /******************************************************************************* ** ** Function BTM_BleObserve @@ -443,7 +486,6 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start) return status; } -#if BLE_VND_INCLUDED == TRUE /******************************************************************************* ** ** Function btm_vsc_brcm_features_complete @@ -455,31 +497,44 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start) *******************************************************************************/ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_params) { - UINT8 status = 0xFF, *p; +#if BLE_VND_INCLUDED == TRUE + UINT8 status = 0xFF; + UINT8 *p; - BTM_TRACE_DEBUG("btm_ble_vendor_capability_vsc_cmpl_cback"); + BTM_TRACE_DEBUG("%s", __func__); /* Check status of command complete event */ - if ((p_vcs_cplt_params->opcode == HCI_BLE_VENDOR_CAP_OCF) &&(p_vcs_cplt_params->param_len > 0)) + if ((p_vcs_cplt_params->opcode == HCI_BLE_VENDOR_CAP_OCF) && + (p_vcs_cplt_params->param_len > 0)) { p = p_vcs_cplt_params->p_param_buf; - STREAM_TO_UINT8 (status, p); + STREAM_TO_UINT8(status, p); } if (status == HCI_SUCCESS) { - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.adv_inst_max, p); - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.rpa_offloading, p); - STREAM_TO_UINT16 (btm_cb.cmn_ble_vsc_cb.tot_scan_results_strg, p); - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.max_irk_list_sz, p); - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.filter_support, p); - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.max_filter, p); - STREAM_TO_UINT8 (btm_cb.cmn_ble_vsc_cb.energy_support, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.adv_inst_max, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.rpa_offloading, p); + STREAM_TO_UINT16(btm_cb.cmn_ble_vsc_cb.tot_scan_results_strg, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.max_irk_list_sz, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.filter_support, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.max_filter, p); + STREAM_TO_UINT8(btm_cb.cmn_ble_vsc_cb.energy_support, p); + + if (p_vcs_cplt_params->param_len > BTM_VSC_CHIP_CAPABILITY_RSP_LEN_L_RELEASE) + { + STREAM_TO_UINT16(btm_cb.cmn_ble_vsc_cb.version_supported, p); + } + else + { + btm_cb.cmn_ble_vsc_cb.version_supported = BTM_VSC_CHIP_CAPABILITY_L_VERSION; + } if (btm_cb.cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_M_VERSION) { - STREAM_TO_UINT16 (btm_cb.cmn_ble_vsc_cb.version_supported, p); - STREAM_TO_UINT16 (btm_cb.cmn_ble_vsc_cb.total_trackable_advertisers, p); + STREAM_TO_UINT16(btm_cb.cmn_ble_vsc_cb.total_trackable_advertisers, p); + STREAM_TO_UINT16(btm_cb.cmn_ble_vsc_cb.extended_scan_support, p); + STREAM_TO_UINT16(btm_cb.cmn_ble_vsc_cb.debug_logging_supported, p); } btm_cb.cmn_ble_vsc_cb.values_read = TRUE; } @@ -493,17 +548,13 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_ btm_ble_multi_adv_init(); if (btm_cb.cmn_ble_vsc_cb.max_filter > 0) - { btm_ble_adv_filter_init(); - } #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) /* VS capability included and non-4.2 device */ if (btm_cb.cmn_ble_vsc_cb.max_irk_list_sz > 0 && controller_get_interface()->get_ble_resolving_list_max_size() == 0) - { btm_ble_resolving_list_init(btm_cb.cmn_ble_vsc_cb.max_irk_list_sz); - } #endif if (btm_cb.cmn_ble_vsc_cb.tot_scan_results_strg > 0) @@ -511,8 +562,8 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_ if (p_ctrl_le_feature_rd_cmpl_cback != NULL) p_ctrl_le_feature_rd_cmpl_cback(status); -} #endif +} /******************************************************************************* ** @@ -977,8 +1028,8 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; - if (!BTM_BLE_VALID_PRAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || - !BTM_BLE_VALID_PRAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) + 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; } @@ -1052,39 +1103,58 @@ void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, ** ** Function BTM_BleSetScanParams ** -** Description This function is called to set Scan parameters. +** Description This function is called to set scan parameters. ** -** Parameters adv_int_min: minimum advertising interval -** adv_int_max: maximum advertising interval -** p_dir_bda: connectable direct initiator's LE device address -** chnl_map: advertising channel map. -** scan_type: active scan or passive scan +** Parameters client_if - Client IF +** scan_interval - Scan interval +** scan_window - Scan window +** scan_mode - Scan mode +** scan_setup_status_cback - Scan param setup status callback ** ** Returns void ** *******************************************************************************/ -void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window, tBTM_BLE_SCAN_MODE scan_mode) +void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window, + tBLE_SCAN_MODE scan_mode, + 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 (" BTM_BleSetScanParams"); + BTM_TRACE_EVENT ("%s", __func__); if (!controller_get_interface()->supports_ble()) - return ; + return; - if (BTM_BLE_VALID_PRAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && - BTM_BLE_VALID_PRAM(scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) && - (scan_mode == BTM_BLE_SCAN_MODE_ACTI || scan_mode == BTM_BLE_SCAN_MODE_PASS)) + /* If not supporting extended scan support, use the older range for checking */ + if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) { - p_cb->scan_type = scan_mode; + 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_CONN_PARAM_UNDEF != scan_interval) - p_cb->scan_interval = scan_interval; + 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; - if (BTM_BLE_CONN_PARAM_UNDEF != scan_window) - p_cb->scan_window = scan_window; + 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", scan_interval, scan_window); } diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h index 79038b82d..13359183b 100644 --- a/stack/btm/btm_ble_int.h +++ b/stack/btm/btm_ble_int.h @@ -96,6 +96,9 @@ typedef UINT8 tBTM_BLE_SEC_REQ_ACT; /* BLE ADDR type ID bit */ #define BLE_ADDR_TYPE_ID_BIT 0x02 +#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55 +#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95 + typedef struct { UINT16 data_mask; @@ -117,7 +120,7 @@ typedef struct #define BTM_BLE_ADV_DATA_LEN_MAX 31 #define BTM_BLE_CACHE_ADV_DATA_MAX 62 -#define BTM_BLE_VALID_PRAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF)) +#define BTM_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF)) #define BTM_BLE_PRIVATE_ADDR_INT 900 /* 15 minutes minimum for random address refreshing */ @@ -353,6 +356,9 @@ extern void btm_ble_stop_scan(void); extern void btm_clear_all_pending_le_entry(void); extern void btm_ble_stop_scan(); +extern BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int, + UINT32 scan_win, UINT8 addr_type_own, + UINT8 scan_filter_policy); extern void btm_ble_stop_inquiry(void); extern void btm_ble_init (void); extern void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched); diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h index 2c43aeefd..a7c3f9d01 100644 --- a/stack/include/btm_api.h +++ b/stack/include/btm_api.h @@ -64,7 +64,8 @@ enum BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */ BTM_MODE4_LEVEL4_NOT_SUPPORTED /* 20 Secure Connections Only Mode can't be supported */ }; -typedef UINT8 tBTM_STATUS; + +typedef uint8_t tBTM_STATUS; #if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) typedef enum diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h index 253ad96bd..84d26e3e3 100644 --- a/stack/include/btm_ble_api.h +++ b/stack/include/btm_ble_api.h @@ -55,7 +55,7 @@ typedef UINT32 tBTM_BLE_REF_VALUE; #define BTM_BLE_SCAN_MODE_PASS 0 #define BTM_BLE_SCAN_MODE_ACTI 1 #define BTM_BLE_SCAN_MODE_NONE 0xff -typedef UINT8 tBTM_BLE_SCAN_MODE; +typedef UINT8 tBLE_SCAN_MODE; #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0 #define BTM_BLE_BATCH_SCAN_MODE_PASS 1 @@ -364,8 +364,10 @@ typedef struct UINT8 max_filter; UINT8 energy_support; BOOLEAN values_read; - UINT16 version_supported; - UINT16 total_trackable_advertisers; + UINT16 version_supported; + UINT16 total_trackable_advertisers; + UINT8 extended_scan_support; + UINT8 debug_logging_supported; }tBTM_BLE_VSC_CB; /* slave preferred connection interval range */ @@ -504,6 +506,8 @@ typedef struct tBTM_BLE_MULTI_ADV_OPQ op_q; }tBTM_BLE_MULTI_ADV_CB; +typedef UINT8 tGATT_IF; + typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value); typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format, UINT8 num_records, UINT16 total_len, @@ -862,6 +866,7 @@ typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match); typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda); typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt); +typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status); tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb; @@ -972,15 +977,19 @@ extern void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); ** ** Description This function is called to set Scan parameters. ** -** Parameters adv_int_min: minimum advertising interval -** adv_int_max: maximum advertising interval -** scan_type: scan mode. +** Parameters client_if - Client IF value +** scan_interval - Scan interval +** scan_window - Scan window +** scan_type - Scan type +** scan_setup_status_cback - Scan setup status callback ** ** Returns void ** *******************************************************************************/ -extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window, - tBTM_BLE_SCAN_MODE scan_type); +extern 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_BleGetVendorCapabilities @@ -1057,13 +1066,13 @@ extern tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value); ** ** Description This function is called to read batch scan reports ** -** Parameters tBTM_BLE_SCAN_MODE scan_mode - Scan mode report to be read out +** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback ** ** Returns tBTM_STATUS ** *******************************************************************************/ -extern tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_SCAN_MODE scan_mode, +extern tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode, tBTM_BLE_REF_VALUE ref_value); /******************************************************************************* @@ -1374,7 +1383,7 @@ extern void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, ** Returns void ** *******************************************************************************/ -extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window); +extern void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window); /****************************************************************************** ** diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h index 3c8b50404..c00fcae6e 100644 --- a/stack/include/gatt_api.h +++ b/stack/include/gatt_api.h @@ -20,6 +20,7 @@ #include "bt_target.h" #include "gattdefs.h" +#include "btm_ble_api.h" /***************************************************************************** ** Constants @@ -548,7 +549,6 @@ typedef struct } tGATT_DISC_RES; -typedef UINT8 tGATT_IF; #define GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP 0 /* start a idle timer for this duration when no application need to use the link */ diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h index 04c5ed665..42dcd48a1 100644 --- a/stack/include/hcidefs.h +++ b/stack/include/hcidefs.h @@ -364,6 +364,9 @@ /* Energy info OCF */ #define HCI_BLE_ENERGY_INFO_OCF (0x0159 | HCI_GRP_VENDOR_SPECIFIC) +/* Extended BLE Scan parameters OCF */ +#define HCI_BLE_EXTENDED_SCAN_PARAMS_OCF (0x0160 | HCI_GRP_VENDOR_SPECIFIC) + /* subcode for multi adv feature */ #define BTM_BLE_MULTI_ADV_SET_PARAM 0x01 #define BTM_BLE_MULTI_ADV_WRITE_ADV_DATA 0x02 diff --git a/stack/include/hcimsgs.h b/stack/include/hcimsgs.h index 672f5fb4c..b59cbfa5a 100644 --- a/stack/include/hcimsgs.h +++ b/stack/include/hcimsgs.h @@ -680,6 +680,7 @@ extern void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, #define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1 #define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2 #define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6 +#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11 /* ULP HCI command */ extern BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask); -- 2.11.0