srvc_api.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 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. #ifndef SRVC_DIS_API_H
  19. #define SRVC_DIS_API_H
  20. #include "common/bt_target.h"
  21. #include "stack/gatt_api.h"
  22. #include "stack/gattdefs.h"
  23. #define DIS_SUCCESS GATT_SUCCESS
  24. #define DIS_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER
  25. #define DIS_NO_RESOURCES GATT_NO_RESOURCES
  26. typedef UINT8 tDIS_STATUS;
  27. /*****************************************************************************
  28. ** Data structure for DIS
  29. *****************************************************************************/
  30. #define DIS_ATTR_SYS_ID_BIT 0x0001
  31. #define DIS_ATTR_MODEL_NUM_BIT 0x0002
  32. #define DIS_ATTR_SERIAL_NUM_BIT 0x0004
  33. #define DIS_ATTR_FW_NUM_BIT 0x0008
  34. #define DIS_ATTR_HW_NUM_BIT 0x0010
  35. #define DIS_ATTR_SW_NUM_BIT 0x0020
  36. #define DIS_ATTR_MANU_NAME_BIT 0x0040
  37. #define DIS_ATTR_IEEE_DATA_BIT 0x0080
  38. #define DIS_ATTR_PNP_ID_BIT 0x0100
  39. typedef UINT16 tDIS_ATTR_MASK;
  40. #define DIS_ATTR_ALL_MASK 0xffff
  41. typedef tDIS_ATTR_MASK tDIS_ATTR_BIT ;
  42. typedef struct {
  43. UINT16 len;
  44. UINT8 *p_data;
  45. } tDIS_STRING;
  46. typedef struct {
  47. UINT16 vendor_id;
  48. UINT16 product_id;
  49. UINT16 product_version;
  50. UINT8 vendor_id_src;
  51. } tDIS_PNP_ID;
  52. typedef union {
  53. UINT64 system_id;
  54. tDIS_PNP_ID pnp_id;
  55. tDIS_STRING data_str;
  56. } tDIS_ATTR;
  57. #define DIS_MAX_STRING_DATA 7
  58. typedef struct {
  59. UINT16 attr_mask;
  60. UINT64 system_id;
  61. tDIS_PNP_ID pnp_id;
  62. UINT8 *data_string[DIS_MAX_STRING_DATA];
  63. } tDIS_VALUE;
  64. typedef void (tDIS_READ_CBACK)(BD_ADDR addr, tDIS_VALUE *p_dis_value);
  65. /*****************************************************************************
  66. ** Data structure used by Battery Service
  67. *****************************************************************************/
  68. typedef struct {
  69. BD_ADDR remote_bda;
  70. BOOLEAN need_rsp;
  71. UINT16 clt_cfg;
  72. } tBA_WRITE_DATA;
  73. #define BA_READ_CLT_CFG_REQ 1
  74. #define BA_READ_PRE_FMT_REQ 2
  75. #define BA_READ_RPT_REF_REQ 3
  76. #define BA_READ_LEVEL_REQ 4
  77. #define BA_WRITE_CLT_CFG_REQ 5
  78. typedef void (tBA_CBACK)(UINT8 app_id, UINT8 event, tBA_WRITE_DATA *p_data);
  79. #define BA_LEVEL_NOTIFY 0x01
  80. #define BA_LEVEL_PRE_FMT 0x02
  81. #define BA_LEVEL_RPT_REF 0x04
  82. typedef UINT8 tBA_LEVEL_DESCR;
  83. typedef struct {
  84. BOOLEAN is_pri;
  85. tBA_LEVEL_DESCR ba_level_descr;
  86. tGATT_TRANSPORT transport;
  87. tBA_CBACK *p_cback;
  88. } tBA_REG_INFO;
  89. typedef union {
  90. UINT8 ba_level;
  91. UINT16 clt_cfg;
  92. tGATT_CHAR_RPT_REF rpt_ref;
  93. tGATT_CHAR_PRES pres_fmt;
  94. } tBA_RSP_DATA;
  95. /*****************************************************************************
  96. ** External Function Declarations
  97. *****************************************************************************/
  98. #ifdef __cplusplus
  99. extern "C"
  100. {
  101. #endif
  102. /*****************************************************************************
  103. ** Service Engine API
  104. *****************************************************************************/
  105. /*******************************************************************************
  106. **
  107. ** Function srvc_eng_init
  108. **
  109. ** Description Initializa the GATT Service engine, register a GATT application
  110. ** as for a central service management.
  111. **
  112. *******************************************************************************/
  113. extern tGATT_STATUS srvc_eng_init (void);
  114. /*****************************************************************************
  115. ** DIS Server Function
  116. *****************************************************************************/
  117. /*******************************************************************************
  118. **
  119. ** Function DIS_SrInit
  120. **
  121. ** Description Initializa the Device Information Service Server.
  122. **
  123. *******************************************************************************/
  124. extern tDIS_STATUS DIS_SrInit (tDIS_ATTR_MASK dis_attr_mask);
  125. /*******************************************************************************
  126. **
  127. ** Function DIS_SrUpdate
  128. **
  129. ** Description Update the DIS server attribute values
  130. **
  131. *******************************************************************************/
  132. extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info);
  133. /*****************************************************************************
  134. ** DIS Client Function
  135. *****************************************************************************/
  136. /*******************************************************************************
  137. **
  138. ** Function DIS_ReadDISInfo
  139. **
  140. ** Description Read remote device DIS information.
  141. **
  142. ** Returns void
  143. **
  144. *******************************************************************************/
  145. extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback,
  146. tDIS_ATTR_MASK mask);
  147. /*******************************************************************************
  148. ** BATTERY SERVICE API
  149. *******************************************************************************/
  150. /*******************************************************************************
  151. **
  152. ** Function Battery_Instantiate
  153. **
  154. ** Description Instantiate a Battery service
  155. **
  156. *******************************************************************************/
  157. extern UINT16 Battery_Instantiate (UINT8 app_id, tBA_REG_INFO *p_reg_info);
  158. /*******************************************************************************
  159. **
  160. ** Function Battery_Rsp
  161. **
  162. ** Description Respond to a battery service request
  163. **
  164. *******************************************************************************/
  165. extern void Battery_Rsp (UINT8 app_id, tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp);
  166. /*******************************************************************************
  167. **
  168. ** Function Battery_Notify
  169. **
  170. ** Description Send battery level notification
  171. **
  172. *******************************************************************************/
  173. extern void Battery_Notify (UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level);
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif