LE: Add support for the HID-over-GATT profile (1/3)
bug:8330048
Change-Id: I5727161b0a87700487bee96cdffa8fd169034204
diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h
index 3a7ed1d..2181f31 100644
--- a/stack/include/btm_api.h
+++ b/stack/include/btm_api.h
@@ -1185,9 +1185,9 @@
#define BTM_SEC_SERVICE_TE_PHONE_ACCESS 30
#define BTM_SEC_SERVICE_ME_PHONE_ACCESS 31
-#define BTM_SEC_SERVICE_HID_SEC_CTRL 32
-#define BTM_SEC_SERVICE_HID_NOSEC_CTRL 33
-#define BTM_SEC_SERVICE_HID_INTR 34
+#define BTM_SEC_SERVICE_HIDH_SEC_CTRL 32
+#define BTM_SEC_SERVICE_HIDH_NOSEC_CTRL 33
+#define BTM_SEC_SERVICE_HIDH_INTR 34
#define BTM_SEC_SERVICE_BIP 35
#define BTM_SEC_SERVICE_BIP_REF 36
#define BTM_SEC_SERVICE_AVDTP 37
@@ -1272,9 +1272,9 @@
#define BTM_SEC_TRUST_ME_PHONE_ACCESS (1 << BTM_SEC_SERVICE_ME_PHONE_ACCESS)
/* 0..31 bits of mask[1] (Most Significant Word) */
-#define BTM_SEC_TRUST_HID_CTRL (1 << (BTM_SEC_SERVICE_HID_SEC_CTRL - 32))
-#define BTM_SEC_TRUST_HID_NOSEC_CTRL (1 << (BTM_SEC_SERVICE_HID_NOSEC_CTRL - 32))
-#define BTM_SEC_TRUST_HID_INTR (1 << (BTM_SEC_SERVICE_HID_INTR - 32))
+#define BTM_SEC_TRUST_HIDH_CTRL (1 << (BTM_SEC_SERVICE_HIDH_SEC_CTRL - 32))
+#define BTM_SEC_TRUST_HIDH_NOSEC_CTRL (1 << (BTM_SEC_SERVICE_HIDH_NOSEC_CTRL - 32))
+#define BTM_SEC_TRUST_HIDH_INTR (1 << (BTM_SEC_SERVICE_HIDH_INTR - 32))
#define BTM_SEC_TRUST_BIP (1 << (BTM_SEC_SERVICE_BIP - 32))
#define BTM_SEC_TRUST_BIP_REF (1 << (BTM_SEC_SERVICE_BIP_REF - 32))
#define BTM_SEC_TRUST_AVDTP (1 << (BTM_SEC_SERVICE_AVDTP - 32))
diff --git a/stack/include/gattdefs.h b/stack/include/gattdefs.h
index e2150f2..38e18f3 100644
--- a/stack/include/gattdefs.h
+++ b/stack/include/gattdefs.h
@@ -57,4 +57,69 @@
#define GATT_UUID_GATT_SRV_CHGD 0x2A05
/* Attribute Protocol Test */
+/* Link Loss Service */
+#define GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
+#define GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
+
+/* Time Profile */
+/* Current Time Service */
+#define GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
+#define GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
+#define GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
+
+/* NwA Profile */
+#define GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
+#define GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
+
+/* phone alert */
+#define GATT_UUID_ALERT_STATUS 0x2A40 /* alert status */
+#define GATT_UUID_RINGER_CP 0x2A42 /* ringer control point */
+#define GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
+
+/* Glucose Service */
+#define GATT_UUID_GM_MEASUREMENT 0x2A18
+#define GATT_UUID_GM_CONTEXT 0x2A34
+#define GATT_UUID_GM_CONTROL_POINT 0x2A52
+#define GATT_UUID_GM_FEATURE 0x2A51
+
+/* device infor characteristic */
+#define GATT_UUID_SYSTEM_ID 0x2A23
+#define GATT_UUID_MODEL_NUMBER_STR 0x2A24
+#define GATT_UUID_SERIAL_NUMBER_STR 0x2A25
+#define GATT_UUID_FW_VERSION_STR 0x2A26
+#define GATT_UUID_HW_VERSION_STR 0x2A27
+#define GATT_UUID_SW_VERSION_STR 0x2A28
+#define GATT_UUID_MANU_NAME 0x2A29
+#define GATT_UUID_IEEE_DATA 0x2A2A
+#define GATT_UUID_PNP_ID 0x2A50
+
+/* HID characteristics */
+#define GATT_UUID_HID_INFORMATION 0x2A4A
+#define GATT_UUID_HID_REPORT_MAP 0x2A4B
+#define GATT_UUID_HID_CONTROL_POINT 0x2A4C
+#define GATT_UUID_HID_REPORT 0x2A4D
+#define GATT_UUID_HID_PROTO_MODE 0x2A4E
+#define GATT_UUID_HID_BT_KB_INPUT 0x2A22
+#define GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
+#define GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
+
+/* Battery Service char */
+#define GATT_UUID_BATTERY_LEVEL 0x2A19
+
+#define GATT_UUID_SC_CONTROL_POINT 0x2A55
+#define GATT_UUID_SENSOR_LOCATION 0x2A5D
+
+/* RUNNERS SPEED AND CADENCE SERVICE */
+#define GATT_UUID_RSC_MEASUREMENT 0x2A53
+#define GATT_UUID_RSC_FEATURE 0x2A54
+
+/* CYCLING SPEED AND CADENCE SERVICE */
+#define GATT_UUID_CSC_MEASUREMENT 0x2A5B
+#define GATT_UUID_CSC_FEATURE 0x2A5C
+
+
+/* Scan Parameter charatceristics */
+#define GATT_UUID_SCAN_INT_WINDOW 0x2A4F
+#define GATT_UUID_SCAN_REFRESH 0x2A31
+
#endif
diff --git a/stack/include/hiddefs.h b/stack/include/hiddefs.h
index e29a4c4..bf5d021 100644
--- a/stack/include/hiddefs.h
+++ b/stack/include/hiddefs.h
@@ -49,6 +49,7 @@
HID_ERR_L2CAP_FAILED,
HID_ERR_AUTH_FAILED,
HID_ERR_SDP_BUSY,
+ HID_ERR_GATT,
HID_ERR_INVALID = 0xFF
};
diff --git a/stack/include/hidh_api.h b/stack/include/hidh_api.h
index 4662630..27e8ac5 100644
--- a/stack/include/hidh_api.h
+++ b/stack/include/hidh_api.h
@@ -42,6 +42,7 @@
#define HID_SSR_MIN_TOUT 0x0100
#define HID_SEC_REQUIRED 0x8000
+#define HID_ATTR_MASK_IGNORE 0
/*****************************************************************************
@@ -76,6 +77,7 @@
HID_HDEV_EVT_VC_UNPLUG
};
typedef void (tHID_HOST_DEV_CALLBACK) (UINT8 dev_handle,
+ BD_ADDR addr,
UINT8 event, /* Event from HID-DEVICE. */
UINT32 data, /* Integer data corresponding to the event.*/
BT_HDR *p_buf ); /* Pointer data corresponding to the event. */
@@ -205,6 +207,18 @@
/*******************************************************************************
**
+** Function hid_known_hid_device
+**
+** Description This function checks if this device is of type HID Device
+**
+** Returns TRUE if device exists else FALSE
+**
+*******************************************************************************/
+BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
+
+
+/*******************************************************************************
+**
** Function HID_HostSetTraceLevel
**
** Description This function sets the trace level for HID Host. If called with
diff --git a/stack/include/srvc_api.h b/stack/include/srvc_api.h
new file mode 100644
index 0000000..b67a14f
--- /dev/null
+++ b/stack/include/srvc_api.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Name: srvc_api.h
+** Function this file contains the definitions for the DIS API
+**
+**
+** Copyright (c) 1999-2011, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+#ifndef SRVC_DIS_API_H
+#define SRVC_DIS_API_H
+
+#include "bt_target.h"
+#include "gatt_api.h"
+#include "gattdefs.h"
+
+#define DIS_SUCCESS GATT_SUCCESS
+#define DIS_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER
+#define DIS_NO_RESOURCES GATT_NO_RESOURCES
+typedef UINT8 tDIS_STATUS;
+
+
+/*****************************************************************************
+** Data structure for DIS
+*****************************************************************************/
+
+#define DIS_ATTR_SYS_ID_BIT 0x0001
+#define DIS_ATTR_MODEL_NUM_BIT 0x0002
+#define DIS_ATTR_SERIAL_NUM_BIT 0x0004
+#define DIS_ATTR_FW_NUM_BIT 0x0008
+#define DIS_ATTR_HW_NUM_BIT 0x0010
+#define DIS_ATTR_SW_NUM_BIT 0x0020
+#define DIS_ATTR_MANU_NAME_BIT 0x0040
+#define DIS_ATTR_IEEE_DATA_BIT 0x0080
+#define DIS_ATTR_PNP_ID_BIT 0x0100
+typedef UINT16 tDIS_ATTR_MASK;
+
+#define DIS_ATTR_ALL_MASK 0xffff
+
+typedef tDIS_ATTR_MASK tDIS_ATTR_BIT ;
+
+typedef struct
+{
+ UINT16 len;
+ UINT8 *p_data;
+}tDIS_STRING;
+
+typedef struct
+{
+ UINT16 vendor_id;
+ UINT16 product_id;
+ UINT16 product_version;
+ UINT8 vendor_id_src;
+
+}tDIS_PNP_ID;
+
+typedef union
+{
+ UINT64 system_id;
+ tDIS_PNP_ID pnp_id;
+ tDIS_STRING data_str;
+}tDIS_ATTR;
+
+#define DIS_MAX_STRING_DATA 7
+
+typedef struct
+{
+ UINT16 attr_mask;
+ UINT64 system_id;
+ tDIS_PNP_ID pnp_id;
+ UINT8 *data_string[DIS_MAX_STRING_DATA];
+}tDIS_VALUE;
+
+
+typedef void (tDIS_READ_CBACK)(BD_ADDR addr, tDIS_VALUE *p_dis_value);
+
+/*****************************************************************************
+** Data structure used by Battery Service
+*****************************************************************************/
+typedef struct
+{
+ BD_ADDR remote_bda;
+ BOOLEAN need_rsp;
+ UINT16 clt_cfg;
+}tBA_WRITE_DATA;
+
+#define BA_READ_CLT_CFG_REQ 1
+#define BA_READ_PRE_FMT_REQ 2
+#define BA_READ_RPT_REF_REQ 3
+#define BA_READ_LEVEL_REQ 4
+#define BA_WRITE_CLT_CFG_REQ 5
+
+typedef void (tBA_CBACK)(UINT8 app_id, UINT8 event, tBA_WRITE_DATA *p_data);
+
+#define BA_LEVEL_NOTIFY 0x01
+#define BA_LEVEL_PRE_FMT 0x02
+#define BA_LEVEL_RPT_REF 0x04
+typedef UINT8 tBA_LEVEL_DESCR;
+
+typedef struct
+{
+ BOOLEAN is_pri;
+ tBA_LEVEL_DESCR ba_level_descr;
+ tGATT_TRANSPORT transport;
+ tBA_CBACK *p_cback;
+
+}tBA_REG_INFO;
+
+typedef union
+{
+ UINT8 ba_level;
+ UINT16 clt_cfg;
+ tGATT_CHAR_RPT_REF rpt_ref;
+ tGATT_CHAR_PRES pres_fmt;
+}tBA_RSP_DATA;
+
+/*****************************************************************************
+** External Function Declarations
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*****************************************************************************
+** Service Engine API
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function srvc_eng_init
+**
+** Description Initializa the GATT Service engine, register a GATT application
+** as for a central service management.
+**
+*******************************************************************************/
+ GATT_API extern tGATT_STATUS srvc_eng_init (void);
+
+
+/*****************************************************************************
+** DIS Server Function
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function DIS_SrInit
+**
+** Description Initializa the Device Information Service Server.
+**
+*******************************************************************************/
+ GATT_API extern tDIS_STATUS DIS_SrInit (tDIS_ATTR_MASK dis_attr_mask);
+/*******************************************************************************
+**
+** Function DIS_SrUpdate
+**
+** Description Update the DIS server attribute values
+**
+*******************************************************************************/
+ GATT_API extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info);
+/*****************************************************************************
+** DIS Client Function
+*****************************************************************************/
+/*******************************************************************************
+**
+** Function DIS_ReadDISInfo
+**
+** Description Read remote device DIS information.
+**
+** Returns void
+**
+*******************************************************************************/
+ GATT_API extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback);
+
+/*******************************************************************************
+** BATTERY SERVICE API
+*******************************************************************************/
+/*******************************************************************************
+**
+** Function Battery_Instantiate
+**
+** Description Instantiate a Battery service
+**
+*******************************************************************************/
+ GATT_API extern UINT16 Battery_Instantiate (UINT8 app_id, tBA_REG_INFO *p_reg_info);
+
+/*******************************************************************************
+**
+** Function Battery_Rsp
+**
+** Description Respond to a battery service request
+**
+*******************************************************************************/
+ GATT_API extern void Battery_Rsp (UINT8 app_id, tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp);
+/*******************************************************************************
+**
+** Function Battery_Notify
+**
+** Description Send battery level notification
+**
+*******************************************************************************/
+ GATT_API extern void Battery_Notify (UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level);
+
+
+#ifdef __cplusplus
+
+}
+#endif
+
+#endif
+
+