• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  *****************************************************************************************
3  *
4  * @file dis.h
5  *
6  * @brief Device Information Service API.
7  *
8  *****************************************************************************************
9  * @attention
10   #####Copyright (c) 2019 GOODIX
11   All rights reserved.
12 
13     Redistribution and use in source and binary forms, with or without
14     modification, are permitted provided that the following conditions are met:
15   * Redistributions of source code must retain the above copyright
16     notice, this list of conditions and the following disclaimer.
17   * Redistributions in binary form must reproduce the above copyright
18     notice, this list of conditions and the following disclaimer in the
19     documentation and/or other materials provided with the distribution.
20   * Neither the name of GOODIX nor the names of its contributors may be used
21     to endorse or promote products derived from this software without
22     specific prior written permission.
23 
24   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34   POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38 /**
39  * @addtogroup BLE_SRV BLE Services
40  * @{
41  * @brief Definitions and prototypes for the BLE Service interface.
42  */
43 
44 /**
45  * @defgroup BLE_SDK_DIS Device Information Service (DIS)
46  * @{
47  * @brief Definitions and prototypes for the DIS interface.
48  *
49  * @details The Device Information Service exposes manufacturer and/or vendor information
50  *          about a device.This module implements the Device Information Service with all
51  *          optional characteristics.
52  *
53  *          After \ref dis_init_t variable is initialized, the application should call
54  *          \ref dis_service_init() to add a Device Information Service and the characteristics
55  *          which are selected by \ref dis_init_t.char_mask to the BLE Stack database.
56  *          However the value of those characteristics locates in user space. The application
57  *          should make sure the spaces for those values are available and those values will not be
58  *          changed during the connection.
59  *
60  */
61 
62 #ifndef __DIS_H__
63 #define __DIS_H__
64 
65 #include <stdint.h>
66 #include "gr55xx_sys.h"
67 #include "custom_config.h"
68 
69 /**
70  * @defgroup DIS_MACRO Defines
71  * @{
72  */
73 #define DIS_CONNECTION_MAX                  (10 < CFG_MAX_CONNECTIONS ? \
74                                              10 : CFG_MAX_CONNECTIONS)   /**< Maximum number of DIS connections. \
75                                                                              The value is configurable. */
76 #define DIS_SYS_ID_LEN                      8     /**< System ID length. */
77 #define DIS_PNP_ID_LEN                      7     /**< PnP ID length. */
78 #define DIS_VAL_MAX_LEN                     128   /**< Maximal length for Characteristic values - 128 bytes. */
79 #define DIS_IEEE_CERTIF_MIN_LEN             6     /**< IEEE Certification length (min 6 bytes). */
80 
81 /**
82  * @defgroup DIS_CHAR_MASK Characteristics Mask
83  * @{
84  * @brief Bit masks for the initialization of \ref dis_init_t.char_mask.
85  */
86 #define DIS_CHAR_SYSTEM_ID_SUP              0x00000006      /**< Bit mask of the System ID. */
87 #define DIS_CHAR_MODEL_NUMBER_SUP           0x00000018      /**< Bit mask of the Model Number. */
88 #define DIS_CHAR_SERIAL_NUMBER_SUP          0x00000060      /**< Bit mask of the Serial Number. */
89 #define DIS_CHAR_FIRMWARE_REV_SUP           0x00000180      /**< Bit mask of the Firmware Revision. */
90 #define DIS_CHAR_HARDWARE_REV_SUP           0x00000600      /**< Bit mask of the Hardware Revision. */
91 #define DIS_CHAR_SOFTWARE_REV_SUP           0x00001800      /**< Bit mask of the Software Revision. */
92 #define DIS_CHAR_MANUFACTURER_NAME_SUP      0x00006000      /**< Bit mask of the Manufacturer Name. */
93 #define DIS_CHAR_11073_CERT_DATA_SUP        0x00018000      /**< Bit mask of the IEEE 11073-20601 \
94                                                                  Regulatory Certification Data List. */
95 #define DIS_CHAR_PNP_ID_SUP                 0x00060000      /**< Bit mask of the PnP ID. */
96 #define DIS_CHAR_FULL                       0x0007ffff      /**< Bit mask of the full characteristic. */
97 /** @} */
98 
99 /**
100  * @defgroup DIS_IEEE_11073_BODY IEEE 11073-20601 Authoritative Body Type
101  * @{
102  */
103 #define DIS_11073_BODY_EMPTY                0              /**< Empty body type. */
104 #define DIS_11073_BODY_IEEE                 1              /**< IEEE body type. */
105 #define DIS_11073_BODY_CONTINUA             2              /**< Continua body type. */
106 #define DIS_11073_BODY_EXP                  254            /**< Exp body type. */
107 /** @} */
108 /** @} */
109 
110 /**
111  * @defgroup DIS_STRUCT Structures
112  * @{
113  */
114 /**@brief UTF-8 string data type. */
115 typedef struct {
116     uint8_t  length;              /**< String length. */
117     char     *p_str;               /**< String data. */
118 } dis_string_t;
119 
120 /**@brief System ID parameters. The first field is the LSOs and the second
121  *        field contains the MSOs. */
122 typedef struct {
123     uint8_t manufacturer_id[5];   /**< Manufacturer-defined ID. */
124     uint8_t org_unique_id[3];     /**< Organizationally unique ID (OUI) which is issued by IEEE. */
125 } dis_sys_id_t;
126 
127 /**@brief IEEE 11073-20601 Regulatory Certification Data List Structure. */
128 typedef struct {
129     char     *p_list;              /**< Pointer to the list which contains the encoded opaque
130                                    *   structure based on IEEE 11073-20601 specification. */
131     uint8_t  list_len;            /**< Length of the list. */
132 } dis_reg_cert_data_list_t;
133 
134 /**@brief PnP ID parameters */
135 typedef struct {
136     uint8_t  vendor_id_source;    /**< Vendor ID Source. */
137     uint16_t vendor_id;           /**< Vendor ID. */
138     uint16_t product_id;          /**< Product ID. */
139     uint16_t product_version;     /**< Product Version. */
140 } dis_pnp_id_t;
141 
142 /**@brief Device Information Service init structure. This contains all options
143  *        and data needed for initialization of the service. */
144 typedef struct {
145     uint32_t
146     char_mask;            /**< Initial mask of Supported characteristics, and configured with \ref DIS_CHAR_MASK. */
147     dis_string_t              manufact_name_str;    /**< Initial manufacturer Name String. */
148     dis_string_t              model_num_str;        /**< Initial model Number String. */
149     dis_string_t              serial_num_str;       /**< Initial serial Number String. */
150     dis_string_t              hw_rev_str;           /**< Initial hardware Revision String. */
151     dis_string_t              fw_rev_str;           /**< Initial firmware Revision String. */
152     dis_string_t              sw_rev_str;           /**< Initial software Revision String. */
153     dis_sys_id_t             *p_sys_id;             /**< Initial system ID. */
154     dis_reg_cert_data_list_t  reg_cert_data_list;   /**< Initial IEEE 11073-20601 Regulatory Certification Data List. */
155     dis_pnp_id_t             *p_pnp_id;             /**< Initial PnP ID. */
156 } dis_init_t;
157 /** @} */
158 
159 /**
160  * @defgroup DIS_FUNCTION Functions
161  * @{
162  */
163 /**
164  *****************************************************************************************
165  * @brief Initialize a Device Information Service instance and add in the database.
166  *
167  * @param[in] p_dis_init: Pointer to Device Information Service initialization variable.
168  *
169  * @return Result of service initialization.
170  *****************************************************************************************
171  */
172 sdk_err_t dis_service_init(dis_init_t *p_dis_init);
173 /** @} */
174 
175 #endif
176 /** @} */
177 /** @} */
178