1 /****************************************************************************** 2 * 3 * Copyright 1999-2013 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #ifndef SRVC_DIS_API_H 20 #define SRVC_DIS_API_H 21 22 #include "bt_target.h" 23 #include "gatt_api.h" 24 #include "gattdefs.h" 25 #include "types/bt_transport.h" 26 27 #define DIS_SUCCESS GATT_SUCCESS 28 #define DIS_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER 29 #define DIS_NO_RESOURCES GATT_NO_RESOURCES 30 typedef uint8_t tDIS_STATUS; 31 32 /***************************************************************************** 33 * Data structure for DIS 34 ****************************************************************************/ 35 36 #define DIS_ATTR_SYS_ID_BIT 0x0001 37 #define DIS_ATTR_MODEL_NUM_BIT 0x0002 38 #define DIS_ATTR_SERIAL_NUM_BIT 0x0004 39 #define DIS_ATTR_FW_NUM_BIT 0x0008 40 #define DIS_ATTR_HW_NUM_BIT 0x0010 41 #define DIS_ATTR_SW_NUM_BIT 0x0020 42 #define DIS_ATTR_MANU_NAME_BIT 0x0040 43 #define DIS_ATTR_IEEE_DATA_BIT 0x0080 44 #define DIS_ATTR_PNP_ID_BIT 0x0100 45 typedef uint16_t tDIS_ATTR_MASK; 46 47 typedef tDIS_ATTR_MASK tDIS_ATTR_BIT; 48 49 typedef struct { 50 uint16_t len; 51 uint8_t* p_data; 52 } tDIS_STRING; 53 54 typedef struct { 55 uint16_t vendor_id; 56 uint16_t product_id; 57 uint16_t product_version; 58 uint8_t vendor_id_src; 59 60 } tDIS_PNP_ID; 61 62 typedef union { 63 uint64_t system_id; 64 tDIS_PNP_ID pnp_id; 65 tDIS_STRING data_str; 66 } tDIS_ATTR; 67 68 #define DIS_MAX_STRING_DATA 7 69 70 typedef struct { 71 uint16_t attr_mask; 72 uint64_t system_id; 73 tDIS_PNP_ID pnp_id; 74 uint8_t* data_string[DIS_MAX_STRING_DATA]; 75 } tDIS_VALUE; 76 77 typedef void(tDIS_READ_CBACK)(const RawAddress& addr, tDIS_VALUE* p_dis_value); 78 79 /***************************************************************************** 80 * Data structure used by Battery Service 81 ****************************************************************************/ 82 typedef struct { 83 RawAddress remote_bda; 84 bool need_rsp; 85 uint16_t clt_cfg; 86 } tBA_WRITE_DATA; 87 88 #define BA_READ_CLT_CFG_REQ 1 89 #define BA_READ_PRE_FMT_REQ 2 90 #define BA_READ_RPT_REF_REQ 3 91 #define BA_READ_LEVEL_REQ 4 92 #define BA_WRITE_CLT_CFG_REQ 5 93 94 typedef void(tBA_CBACK)(uint8_t app_id, uint8_t event, tBA_WRITE_DATA* p_data); 95 96 #define BA_LEVEL_NOTIFY 0x01 97 #define BA_LEVEL_PRE_FMT 0x02 98 #define BA_LEVEL_RPT_REF 0x04 99 typedef uint8_t tBA_LEVEL_DESCR; 100 101 typedef struct { 102 bool is_pri; 103 tBA_LEVEL_DESCR ba_level_descr; 104 tBT_TRANSPORT transport; 105 tBA_CBACK* p_cback; 106 107 } tBA_REG_INFO; 108 109 typedef union { 110 uint8_t ba_level; 111 uint16_t clt_cfg; 112 tGATT_CHAR_RPT_REF rpt_ref; 113 tGATT_CHAR_PRES pres_fmt; 114 } tBA_RSP_DATA; 115 116 /***************************************************************************** 117 * External Function Declarations 118 ****************************************************************************/ 119 /***************************************************************************** 120 * Service Engine API 121 ****************************************************************************/ 122 /******************************************************************************* 123 * 124 * Function srvc_eng_init 125 * 126 * Description Initializa the GATT Service engine, register a GATT 127 * application as for a central service management. 128 * 129 ******************************************************************************/ 130 extern tGATT_STATUS srvc_eng_init(void); 131 132 /***************************************************************************** 133 * DIS Server Function 134 ****************************************************************************/ 135 136 /******************************************************************************* 137 * 138 * Function DIS_SrInit 139 * 140 * Description Initializa the Device Information Service Server. 141 * 142 ******************************************************************************/ 143 extern tDIS_STATUS DIS_SrInit(tDIS_ATTR_MASK dis_attr_mask); 144 /******************************************************************************* 145 * 146 * Function DIS_SrUpdate 147 * 148 * Description Update the DIS server attribute values 149 * 150 ******************************************************************************/ 151 extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR* p_info); 152 /***************************************************************************** 153 * DIS Client Function 154 ****************************************************************************/ 155 /******************************************************************************* 156 * 157 * Function DIS_ReadDISInfo 158 * 159 * Description Read remote device DIS information. 160 * 161 * Returns void 162 * 163 ******************************************************************************/ 164 extern bool DIS_ReadDISInfo(const RawAddress& peer_bda, 165 tDIS_READ_CBACK* p_cback, tDIS_ATTR_MASK mask); 166 167 #endif 168