#include "stack/include/btu.h"
#include "utl.h"
-#if (BTA_HH_LE_INCLUDED == TRUE)
#include "bta_hh_int.h"
-#endif
using base::StringPrintf;
using bluetooth::Uuid;
bta_gattc_cb.state = BTA_GATTC_STATE_DISABLING;
/* don't deregister HH GATT IF */
/* HH GATT IF will be deregistered by bta_hh_le_deregister when disable HH */
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (!bta_hh_le_is_hh_gatt_if(bta_gattc_cb.cl_rcb[i].client_if)) {
-#endif
bta_gattc_deregister(&bta_gattc_cb.cl_rcb[i]);
-#if (BTA_HH_LE_INCLUDED == TRUE)
}
-#endif
}
/* no registered apps, indicate disable completed */
if (p_clcb == NULL) return;
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* filter this event just for BTA HH LE GATT client,
* In the future, if we want to enable encryption complete event
* for all GATT clients, we can remove this code
if (!bta_hh_le_is_hh_gatt_if(gattc_if)) {
return;
}
-#endif
VLOG(1) << __func__ << ": cif:" << +gattc_if;
bta_hh_cb.cb_index[xx] = BTA_HH_IDX_INVALID;
}
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (status == BTA_HH_OK) {
bta_hh_le_enable();
} else
-#endif
{
/* signal BTA call back event */
tBTA_HH bta_hh;
*
******************************************************************************/
void bta_hh_disc_cmpl(void) {
-#if (BTA_HH_LE_INCLUDED == TRUE)
HID_HostDeregister();
bta_hh_le_deregister();
-#else
tBTA_HH_STATUS status = BTA_HH_OK;
/* Deregister with lower layer */
p_cb->mode = p_data->api_conn.mode;
bta_hh_cb.p_cur = p_cb;
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) {
bta_hh_le_open_conn(p_cb, p_data->api_conn.bd_addr);
return;
}
-#endif
/* if previously virtually cabled device, skip SDP */
if (p_cb->app_id) {
tBTA_HH_CBDATA disc_dat;
tHID_STATUS status;
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_cb->is_le_device)
bta_hh_le_api_disc_act(p_cb);
else
-#endif
{
/* found an active connection */
disc_dat.handle =
bta_hh_co_open(p_cb->hid_handle, p_cb->sub_class, p_cb->attr_mask,
p_cb->app_id);
-#if (BTA_HH_LE_INCLUDED == TRUE)
conn.status = p_cb->status;
conn.le_hid = p_cb->is_le_device;
conn.scps_supported = p_cb->scps_supported;
if (!p_cb->is_le_device)
-#endif
{
/* inform role manager */
bta_sys_conn_open(BTA_ID_HH, p_cb->app_id, p_cb->addr);
}
/* set protocol mode when not default report mode */
if (p_cb->mode != BTA_HH_PROTO_RPT_MODE
-#if (BTA_HH_LE_INCLUDED == TRUE)
&& !p_cb->is_le_device
-#endif
) {
if ((HID_HostWriteDev(dev_handle, HID_TRANS_SET_PROTOCOL,
HID_PAR_PROTOCOL_BOOT_MODE, 0, 0, NULL)) !=
******************************************************************************/
void bta_hh_get_dscp_act(tBTA_HH_DEV_CB* p_cb,
UNUSED_ATTR tBTA_HH_DATA* p_data) {
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_cb->is_le_device) {
bta_hh_le_get_dscp_act(p_cb);
} else
-#endif
(*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH*)&p_cb->dscp_info);
}
dev_info.bda = p_dev_info->bda;
/* initialize callback data */
if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) {
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) {
dev_info.handle = bta_hh_le_add_device(p_cb, p_dev_info);
if (dev_info.handle != BTA_HH_INVALID_HANDLE)
dev_info.status = BTA_HH_OK;
} else
-#endif
if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask,
&dev_handle) == HID_SUCCESS) {
dev_info.handle = dev_handle;
dev_info.status = BTA_HH_OK;
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* update DI information */
bta_hh_update_di_info(p_cb, p_dev_info->dscp_info.vendor_id,
p_dev_info->dscp_info.product_id,
p_dev_info->dscp_info.version,
p_dev_info->dscp_info.flag);
-#else
- bta_hh_update_di_info(p_cb, p_dev_info->dscp_info.vendor_id,
- p_dev_info->dscp_info.product_id,
- p_dev_info->dscp_info.version, 0);
-
-#endif
/* add to BTA device list */
bta_hh_add_device_to_list(
p_cb, dev_handle, p_dev_info->attr_mask,
dev_info.handle = (uint8_t)p_dev_info->hdr.layer_specific;
dev_info.bda = p_cb->addr;
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_cb->is_le_device) {
bta_hh_le_remove_dev_bg_conn(p_cb);
bta_hh_sm_execute(p_cb, BTA_HH_API_CLOSE_EVT, NULL);
bta_hh_clean_up_kdev(p_cb);
} else
-#endif
{
if (HID_HostRemoveDev(dev_info.handle) == HID_SUCCESS) {
dev_info.status = BTA_HH_OK;
uint16_t event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
BTA_HH_FST_TRANS_CB_EVT;
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_cb->is_le_device)
bta_hh_le_write_dev_act(p_cb, p_data);
else
-#endif
{
cbdata.handle = p_cb->hid_handle;
}
}
#endif
-#endif /* BTA_HH_INCLUDED */
******************************************************************************/
void BTA_HhSendData(uint8_t dev_handle, UNUSED_ATTR const RawAddress& dev_bda,
BT_HDR* p_data) {
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_data->layer_specific != BTA_HH_RPTT_OUTPUT) {
APPL_TRACE_ERROR(
"ERROR! Wrong report type! Write Command only valid for output "
"report!");
return;
}
-#endif
bta_hh_snd_write_dev(dev_handle, HID_TRANS_DATA,
(uint8_t)p_data->layer_specific, 0, 0, p_data);
}
#include "bta_sys.h"
#include "utl.h"
-#if (BTA_HH_LE_INCLUDED == TRUE)
#include "bta_gatt_api.h"
-#endif
/* can be moved to bta_api.h */
#define BTA_HH_MAX_RPT_CHARS 8
BTA_HH_API_GET_DSCP_EVT,
BTA_HH_API_MAINT_DEV_EVT,
BTA_HH_OPEN_CMPL_EVT,
-#if (BTA_HH_LE_INCLUDED == TRUE)
BTA_HH_GATT_CLOSE_EVT,
BTA_HH_GATT_OPEN_EVT,
BTA_HH_START_ENC_EVT,
BTA_HH_ENC_CMPL_EVT,
BTA_HH_GATT_ENC_CMPL_EVT,
-#endif
/* not handled by execute state machine */
BTA_HH_API_ENABLE_EVT,
BTA_HH_NULL_ST,
BTA_HH_IDLE_ST,
BTA_HH_W4_CONN_ST,
- BTA_HH_CONN_ST
-#if (BTA_HH_LE_INCLUDED == TRUE)
- ,
- BTA_HH_W4_SEC
-#endif
- ,
+ BTA_HH_CONN_ST,
+ BTA_HH_W4_SEC,
BTA_HH_INVALID_ST /* Used to check invalid states before executing SM function
- */
+ */
};
typedef uint8_t tBTA_HH_STATE;
uint8_t t_type;
uint8_t param;
uint8_t rpt_id;
-#if (BTA_HH_LE_INCLUDED == TRUE)
uint8_t srvc_id;
-#endif
uint16_t data;
BT_HDR* p_data;
} tBTA_HH_CMD_DATA;
tBTA_HH_DEV_DSCP_INFO dscp_info;
} tBTA_HH_MAINT_DEV;
-#if (BTA_HH_LE_INCLUDED == TRUE)
typedef struct {
BT_HDR hdr;
uint16_t conn_id;
uint16_t scan_int;
uint16_t scan_win;
} tBTA_HH_SCPP_UPDATE;
-#endif
+
/* union of all event data types */
typedef union {
BT_HDR hdr;
tBTA_HH_CBACK_DATA hid_cback;
tBTA_HH_STATUS status;
tBTA_HH_MAINT_DEV api_maintdev;
-#if (BTA_HH_LE_INCLUDED == TRUE)
tBTA_HH_LE_CLOSE le_close;
tBTA_GATTC_OPEN le_open;
tBTA_HH_SCPP_UPDATE le_scpp_update;
tBTA_GATTC_ENC_CMPL_CB le_enc_cmpl;
-#endif
} tBTA_HH_DATA;
-#if (BTA_HH_LE_INCLUDED == TRUE)
typedef struct {
uint8_t index;
bool in_use;
/* check to see if th edevice handle is a LE device handle */
#define BTA_HH_IS_LE_DEV_HDL(x) ((x)&0xf0)
#define BTA_HH_IS_LE_DEV_HDL_VALID(x) (((x) >> 4) <= BTA_HH_LE_MAX_KNOWN)
-#endif
/* device control block */
typedef struct {
tBTA_HH_PROTO_MODE mode; /* protocol mode */
tBTA_HH_STATE state; /* CB state */
-#if (BTA_HH_LE_INCLUDED == TRUE)
#define BTA_HH_LE_DISC_NONE 0x00
#define BTA_HH_LE_DISC_HIDS 0x01
#define BTA_HH_LE_DISC_DIS 0x02
#define BTA_HH_LE_SCPS_NOTIFY_SPT 0x01
#define BTA_HH_LE_SCPS_NOTIFY_ENB 0x02
uint8_t scps_notify; /* scan refresh supported/notification enabled */
-#endif
bool security_pending;
} tBTA_HH_DEV_CB;
block idx, used in sdp */
uint8_t cb_index[BTA_HH_MAX_KNOWN]; /* maintain a CB index
map to dev handle */
-#if (BTA_HH_LE_INCLUDED == TRUE)
uint8_t le_cb_index[BTA_HH_LE_MAX_KNOWN]; /* maintain a CB index map to LE dev
handle */
tGATT_IF gatt_if;
-#endif
tBTA_HH_CBACK* p_cback; /* Application callbacks */
tSDP_DISCOVERY_DB* p_disc_db;
uint8_t trace_level; /* tracing level */
#include "bta_hh_int.h"
#include "osi/include/osi.h"
-#if (BTA_HH_LE_INCLUDED == TRUE)
-
#include <string.h>
#include <base/bind.h>
}
}
}
-
-#endif
BTA_HH_MAINT_DEV_ACT,
BTA_HH_OPEN_CMPL_ACT,
BTA_HH_OPEN_FAILURE,
-#if (BTA_HH_LE_INCLUDED == TRUE)
BTA_HH_GATT_CLOSE,
BTA_HH_LE_OPEN_FAIL,
BTA_HH_GATT_OPEN,
BTA_HH_START_SEC,
BTA_HH_SEC_CMPL,
BTA_HH_GATT_ENC_CMPL,
-#endif
BTA_HH_NUM_ACTIONS
};
/* action functions */
const tBTA_HH_ACTION bta_hh_action[] = {
- bta_hh_api_disc_act, bta_hh_open_act, bta_hh_close_act, bta_hh_data_act,
- bta_hh_ctrl_dat_act, bta_hh_handsk_act, bta_hh_start_sdp, bta_hh_sdp_cmpl,
- bta_hh_write_dev_act, bta_hh_get_dscp_act, bta_hh_maint_dev_act,
- bta_hh_open_cmpl_act, bta_hh_open_failure
-#if (BTA_HH_LE_INCLUDED == TRUE)
- ,
- bta_hh_gatt_close, bta_hh_le_open_fail, bta_hh_gatt_open,
- bta_hh_start_security, bta_hh_security_cmpl, bta_hh_le_notify_enc_cmpl
-#endif
-};
+ bta_hh_api_disc_act, bta_hh_open_act, bta_hh_close_act,
+ bta_hh_data_act, bta_hh_ctrl_dat_act, bta_hh_handsk_act,
+ bta_hh_start_sdp, bta_hh_sdp_cmpl, bta_hh_write_dev_act,
+ bta_hh_get_dscp_act, bta_hh_maint_dev_act, bta_hh_open_cmpl_act,
+ bta_hh_open_failure, bta_hh_gatt_close, bta_hh_le_open_fail,
+ bta_hh_gatt_open, bta_hh_start_security, bta_hh_security_cmpl,
+ bta_hh_le_notify_enc_cmpl};
/* state table information */
#define BTA_HH_ACTION 0 /* position of action */
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST},
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST},
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST}
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* BTA_HH_GATT_CLOSE_EVT */,
{BTA_HH_IGNORE, BTA_HH_IDLE_ST}
/* BTA_HH_GATT_OPEN_EVT */,
{BTA_HH_IGNORE, BTA_HH_IDLE_ST}
/* BTA_HH_GATT_ENC_CMPL_EVT */,
{BTA_HH_IGNORE, BTA_HH_IDLE_ST}
-#endif
-
};
const uint8_t bta_hh_st_w4_conn[][BTA_HH_NUM_COLS] = {
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST},
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST},
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST}
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* BTA_HH_GATT_CLOSE_EVT */,
{BTA_HH_LE_OPEN_FAIL, BTA_HH_IDLE_ST}
/* BTA_HH_GATT_OPEN_EVT */,
{BTA_HH_IGNORE, BTA_HH_W4_CONN_ST}
/* BTA_HH_GATT_ENC_CMPL_EVT */,
{BTA_HH_IGNORE, BTA_HH_W4_CONN_ST}
-#endif
};
const uint8_t bta_hh_st_connected[][BTA_HH_NUM_COLS] = {
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_GET_DSCP_ACT, BTA_HH_CONN_ST},
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_CONN_ST},
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST}
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* BTA_HH_GATT_CLOSE_EVT */,
{BTA_HH_GATT_CLOSE, BTA_HH_IDLE_ST}
/* BTA_HH_GATT_OPEN_EVT */,
{BTA_HH_IGNORE, BTA_HH_CONN_ST}
/* BTA_HH_GATT_ENC_CMPL_EVT */,
{BTA_HH_IGNORE, BTA_HH_CONN_ST}
-#endif
};
-#if (BTA_HH_LE_INCLUDED == TRUE)
+
const uint8_t bta_hh_st_w4_sec[][BTA_HH_NUM_COLS] = {
/* Event Action Next state */
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC},
/* BTA_HH_START_ENC_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC},
/* BTA_HH_ENC_CMPL_EVT */ {BTA_HH_SEC_CMPL, BTA_HH_W4_CONN_ST},
/* BTA_HH_GATT_ENC_CMPL_EVT */ {BTA_HH_GATT_ENC_CMPL, BTA_HH_W4_SEC}};
-#endif
/* type for state table */
typedef const uint8_t (*tBTA_HH_ST_TBL)[BTA_HH_NUM_COLS];
/* state table */
const tBTA_HH_ST_TBL bta_hh_st_tbl[] = {bta_hh_st_idle, bta_hh_st_w4_conn,
- bta_hh_st_connected
-#if (BTA_HH_LE_INCLUDED == TRUE)
- ,
- bta_hh_st_w4_sec
-#endif
-};
+ bta_hh_st_connected, bta_hh_st_w4_sec};
/*****************************************************************************
* Global data
return "BTA_HH_API_GET_DSCP_EVT";
case BTA_HH_OPEN_CMPL_EVT:
return "BTA_HH_OPEN_CMPL_EVT";
-#if (BTA_HH_LE_INCLUDED == TRUE)
case BTA_HH_GATT_CLOSE_EVT:
return "BTA_HH_GATT_CLOSE_EVT";
case BTA_HH_GATT_OPEN_EVT:
return "BTA_HH_START_ENC_EVT";
case BTA_HH_ENC_CMPL_EVT:
return "BTA_HH_ENC_CMPL_EVT";
-#endif
default:
return "unknown HID Host event code";
}
return "BTA_HH_W4_CONN_ST";
case BTA_HH_CONN_ST:
return "BTA_HH_CONN_ST";
-#if (BTA_HH_LE_INCLUDED == TRUE)
case BTA_HH_W4_SEC:
return "BTA_HH_W4_SEC";
-#endif
default:
return "unknown HID Host state";
}
uint8_t index;
if (p_cb->hid_handle != BTA_HH_INVALID_HANDLE) {
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (p_cb->is_le_device)
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] =
BTA_HH_IDX_INVALID;
else
-#endif
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
}
******************************************************************************/
void bta_hh_update_di_info(tBTA_HH_DEV_CB* p_cb, uint16_t vendor_id,
uint16_t product_id, uint16_t version,
-#if (BTA_HH_LE_INCLUDED == TRUE)
uint8_t flag)
-#else
- UNUSED_ATTR uint8_t flag)
-#endif
{
#if (BTA_HH_DEBUG == TRUE)
APPL_TRACE_DEBUG("vendor_id = 0x%2x product_id = 0x%2x version = 0x%2x",
p_cb->dscp_info.vendor_id = vendor_id;
p_cb->dscp_info.product_id = product_id;
p_cb->dscp_info.version = version;
-#if (BTA_HH_LE_INCLUDED == TRUE)
p_cb->dscp_info.flag = flag;
-#endif
}
/*******************************************************************************
*
uint8_t bta_hh_dev_handle_to_cb_idx(uint8_t dev_handle) {
uint8_t index = BTA_HH_IDX_INVALID;
-#if (BTA_HH_LE_INCLUDED == TRUE)
if (BTA_HH_IS_LE_DEV_HDL(dev_handle)) {
if (BTA_HH_IS_LE_DEV_HDL_VALID(dev_handle))
index = bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(dev_handle)];
dev_handle, index);
#endif
} else
-#endif
/* regular HID device checking */
if (dev_handle < BTA_HH_MAX_KNOWN)
index = bta_hh_cb.cb_index[dev_handle];
#include "bta_api.h"
#include "hidh_api.h"
-#if (BTA_HH_LE_INCLUDED == TRUE)
#include "gatt_api.h"
-#endif
/*****************************************************************************
* Constants and Type Definitions
#define BTA_HH_IDX_INVALID 0xff
#define BTA_HH_MAX_KNOWN HID_HOST_MAX_DEVICES
-#if (BTA_HH_LE_INCLUDED == TRUE)
/* GATT_MAX_PHY_CHANNEL can not exceed 14 for the design of BTA HH */
#if GATT_MAX_PHY_CHANNEL > 14
#define BTA_HH_LE_MAX_KNOWN 14
#endif
#define BTA_HH_MAX_DEVICE (HID_HOST_MAX_DEVICES + BTA_HH_LE_MAX_KNOWN)
-#else
-#define BTA_HH_MAX_DEVICE HID_HOST_MAX_DEVICES
-#endif
/* invalid device handle */
#define BTA_HH_INVALID_HANDLE 0xff
uint16_t
ssr_min_tout; /* SSR min timeout, BTA_HH_SSR_PARAM_INVALID if unknown */
uint8_t ctry_code; /*Country Code.*/
-#if (BTA_HH_LE_INCLUDED == TRUE)
#define BTA_HH_LE_REMOTE_WAKE 0x01
#define BTA_HH_LE_NORMAL_CONN 0x02
uint8_t flag;
-#endif
tBTA_HH_DEV_DESCR descriptor;
} tBTA_HH_DEV_DSCP_INFO;
RawAddress bda; /* HID device bd address */
tBTA_HH_STATUS status; /* operation status */
uint8_t handle; /* device handle */
-#if (BTA_HH_LE_INCLUDED == TRUE)
bool le_hid; /* is LE devices? */
bool scps_supported; /* scan parameter service supported */
-#endif
} tBTA_HH_CONN;
extern void bta_hh_co_get_rpt_rsp(uint8_t dev_handle, uint8_t status,
uint8_t* p_rpt, uint16_t len);
-#if (BTA_HH_LE_INCLUDED == TRUE)
/*******************************************************************************
*
* Function bta_hh_le_co_rpt_info
extern void bta_hh_le_co_reset_rpt_cache(const RawAddress& remote_bda,
uint8_t app_id);
-#endif /* #if (BTA_HH_LE_INCLUDED == TRUE) */
-
#endif /* BTA_HH_CO_H */
const char* dev_path = "/dev/uhid";
-#if (BTA_HH_LE_INCLUDED == TRUE)
#include "btif_config.h"
#define BTA_HH_NV_LOAD_MAX 16
static tBTA_HH_RPT_CACHE_ENTRY sReportCache[BTA_HH_NV_LOAD_MAX];
-#endif
#define GET_RPT_RSP_OFFSET 9
#define THREAD_NORMAL_PRIORITY 0
#define BT_HH_THREAD "bt_hh_thread"
}
}
-#if (BTA_HH_LE_INCLUDED == TRUE)
/*******************************************************************************
*
* Function bta_hh_le_co_rpt_info
BTIF_TRACE_DEBUG("%s() - Reset cache for bda %s", __func__, bdstr);
}
-
-#endif // (BTA_HH_LE_INCLUDED == TRUE)
#define BTA_HH_ROLE BTA_MASTER_ROLE_PREF
#endif
-#ifndef BTA_HH_LE_INCLUDED
-#define BTA_HH_LE_INCLUDED TRUE
-#endif
-
#ifndef BTA_AV_SINK_INCLUDED
#define BTA_AV_SINK_INCLUDED FALSE
#endif