cgms_racp.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file cgms_racp.h
5 *
6 * @brief Continuous Continuous Glucose Monitoring Monitoring Service Record Access Control Point 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_CGMS_RACP Continuous Continuous Glucose Monitoring Monitoring Service Record Access Control Point (CGMS_RACP)
46 * @{
47 * @brief Continuous Continuous Glucose Monitoring Monitoring Service Record Access Control Point module.
48 *
49 * @details This module implements Continuous Glucose Monitoring Service Record Access Control Point (RACP), includeding
50 * parsing, executing and responsing RACP from Client.
51 */
52
53 #ifndef __CGMS_RACP_H__
54 #define __CGMS_RACP_H__
55
56 /*
57 * INCLUDE FILES
58 ****************************************************************************************
59 */
60 #include "gr_includes.h"
61
62
63 /**
64 * @defgroup CGMS_RACP_MACRO Defines
65 * @{
66 */
67 #define CGMS_RACP_FILTER_TIME_OFFSET_LEN 2
68 /** @} */
69
70 /**
71 * @defgroup CGMS_RACP_ENUM Enumerations
72 * @{
73 */
74 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point Operation Codes. */
75 typedef enum
76 {
77 CGMS_RACP_OP_RESERVED, /**< Reserved for future use. */
78 CGMS_RACP_OP_REP_STRD_RECS, /**< Report stored records (Operator: Value from Operator Table). */
79 CGMS_RACP_OP_DEL_STRD_RECS, /**< Delete stored records (Operator: Value from Operator Table). */
80 CGMS_RACP_OP_ABORT_OP, /**< Abort operation (Operator: Null 'value of 0x00 from Operator Table'). */
81 CGMS_RACP_OP_REP_NB_OF_STRD_RECS, /**< Report number of stored records (Operator: Value from Operator Table). */
82 CGMS_RACP_OP_NB_OF_STRD_RECS_RSP, /**< Number of stored records response (Operator: Null 'value of 0x00 from Operator Table'). */
83 CGMS_RACP_OP_RSP_CODE, /**< Response Code (Operator: Null 'value of 0x00 from Operator Table'). */
84 } cgms_racp_op_code_t;
85
86 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point Operator. */
87 typedef enum
88 {
89 CGMS_RACP_OPERATOR_NULL, /**< NULL. */
90 CGMS_RACP_OPERATOR_ALL_RECS, /**< All records. */
91 CGMS_RACP_OPERATOR_LE_OR_EQ, /**< Less than or equal to. */
92 CGMS_RACP_OPERATOR_GT_OR_EQ, /**< Greater than or equal to. */
93 CGMS_RACP_OPERATOR_WITHIN_RANGE_OF, /**< Within rang of (inclusive). */
94 CGMS_RACP_OPERATOR_FIRST_REC, /**< First record(i.e. oldest record). */
95 CGMS_RACP_OPERATOR_LAST_REC, /**< Last record (i.e. most recent record). */
96 } cgms_racp_operator_t;
97
98 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point Response codes. */
99 typedef enum
100 {
101 CGMS_RACP_RSP_RESERVED, /**< Reserved for future use. */
102 CGMS_RACP_RSP_SUCCESS, /**< Normal response for successful operation. */
103 CGMS_RACP_RSP_OP_CODE_NOT_SUP, /**< Normal response if unsupported Op Code is received. */
104 CGMS_RACP_RSP_INVALID_OPERATOR, /**< Normal response if Operator received does not meet the requirements of the service (e.g. Null was expected). */
105 CGMS_RACP_RSP_OPERATOR_NOT_SUP, /**< Normal response if unsupported Operator is received. */
106 CGMS_RACP_RSP_INVALID_OPERAND, /**< Normal response if Operand received does not meet the requirements of the service. */
107 CGMS_RACP_RSP_NO_RECS_FOUND, /**< Normal response if request to report stored records or request to delete stored records resulted in no records meeting criteria. */
108 CGMS_RACP_RSP_ABORT_UNSUCCESSFUL, /**< Normal response if request for Abort cannot be completed. */
109 CGMS_RACP_RSP_PROCEDURE_NOT_COMPLETED, /**< Normal response if unable to complete a procedure for any reason. */
110 CGMS_RACP_RSP_OPERAND_NOT_SUP, /**< Normal response if unsupported Operand is received. */
111 CGMS_RACP_RSP_VALID_DECODE = 0xff /**< User-defined response if RACP request is valid for CGMS. */
112 } cgms_racp_operand_t;
113
114 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point filter types. */
115 typedef enum
116 {
117 CGMS_RACP_FILTER_RESERVED, /**< Reserved for future use. */
118 CGMS_RACP_FILTER_TIME_OFFSET,
119 } cgms_racp_filter_type_t;
120 /** @} */
121
122 /**
123 * @defgroup CGMS_RACP_STRUCT Structures
124 * @{
125 */
126 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point request value. */
127 typedef struct
128 {
129 cgms_racp_op_code_t op_code; /**< Continuous Glucose Monitoring Recoerd Access Control Point Operation Code. */
130 cgms_racp_operator_t operator; /**< Continuous Glucose Monitoring Recoerd Access Control Point Operator. */
131 cgms_racp_filter_type_t filter_type; /**< Continuous Glucose Monitoring Recoerd Access Control Point filter types. */
132 union
133 {
134 struct
135 {
136 uint16_t min;
137 uint16_t max;
138 } time_offset;
139 } filter_param; /**< Filter param. */
140 } cgms_racp_req_t;
141
142 /**@brief Continuous Glucose Monitoring Recoerd Access Control Point response value. */
143 typedef struct
144 {
145 cgms_racp_op_code_t op_code; /**< Continuous Glucose Monitoring Recoerd Access Control Point Operation Code. */
146 cgms_racp_operator_t operator; /**< Continuous Glucose Monitoring Recoerd Access Control Point Operator. */
147 union
148 {
149 uint16_t num_of_record; /**< Number of record (if op_code = CGMS_RACP_OP_REP_NB_OF_STRD_RECS). */
150 struct
151 {
152 cgms_racp_op_code_t op_code; /**< Request Op Code. */
153 cgms_racp_operand_t status; /**< Command Status (if op_code = CGMS_RACP_OP_RSP_CODE). */
154 } rsp; /**< Response. */
155 } operand; /**< Response operand. */
156 } cgms_racp_rsp_t;
157 /** @} */
158
159 /**
160 * @defgroup CGMS_RACP_FUNCTION Functions
161 * @{
162 */
163 /**
164 *****************************************************************************************
165 * @brief Decode record access control point request.
166 *
167 * @param[in] p_data: Pointer to data.
168 * @param[in] length: Length of data.
169 * @param[out] p_racp_req: Potnter to buffer saved decode result.
170 *
171 * @return Record access control point request decode result.
172 *****************************************************************************************
173 */
174 cgms_racp_operand_t cgms_racp_req_decode(const uint8_t *p_data, uint16_t length, cgms_racp_req_t *p_racp_req);
175
176 /**
177 *****************************************************************************************
178 * @brief Encode record access control point response.
179 *
180 * @param[in] p_racp_rsp: Pointer to buffer saved response.
181 * @param[out] p_encoded_buffer: Pointer to buffer where the encoded data will be written.
182 *
183 * @return Length of encode data.
184 *****************************************************************************************
185 */
186 uint16_t cgms_racp_rsp_encode(cgms_racp_rsp_t *p_racp_rsp, uint8_t *p_encoded_buffer);
187 /** @} */
188
189 #endif
190 /** @} */
191 /** @} */
192
CGMS_RACP_RSP_SUCCESS
@ CGMS_RACP_RSP_SUCCESS
Normal response for successful operation.
Definition: cgms_racp.h:102
CGMS_RACP_RSP_VALID_DECODE
@ CGMS_RACP_RSP_VALID_DECODE
User-defined response if RACP request is valid for CGMS.
Definition: cgms_racp.h:111
CGMS_RACP_RSP_INVALID_OPERATOR
@ CGMS_RACP_RSP_INVALID_OPERATOR
Normal response if Operator received does not meet the requirements of the service (e....
Definition: cgms_racp.h:104
CGMS_RACP_FILTER_TIME_OFFSET
@ CGMS_RACP_FILTER_TIME_OFFSET
Definition: cgms_racp.h:118
CGMS_RACP_OP_NB_OF_STRD_RECS_RSP
@ CGMS_RACP_OP_NB_OF_STRD_RECS_RSP
Number of stored records response (Operator: Null 'value of 0x00 from Operator Table').
Definition: cgms_racp.h:82
cgms_racp_req_t::op_code
cgms_racp_op_code_t op_code
Continuous Glucose Monitoring Recoerd Access Control Point Operation Code.
Definition: cgms_racp.h:129
CGMS_RACP_OPERATOR_ALL_RECS
@ CGMS_RACP_OPERATOR_ALL_RECS
All records.
Definition: cgms_racp.h:90
CGMS_RACP_RSP_PROCEDURE_NOT_COMPLETED
@ CGMS_RACP_RSP_PROCEDURE_NOT_COMPLETED
Normal response if unable to complete a procedure for any reason.
Definition: cgms_racp.h:109
cgms_racp_req_t::max
uint16_t max
Definition: cgms_racp.h:137
CGMS_RACP_OP_REP_NB_OF_STRD_RECS
@ CGMS_RACP_OP_REP_NB_OF_STRD_RECS
Report number of stored records (Operator: Value from Operator Table).
Definition: cgms_racp.h:81
CGMS_RACP_OP_DEL_STRD_RECS
@ CGMS_RACP_OP_DEL_STRD_RECS
Delete stored records (Operator: Value from Operator Table).
Definition: cgms_racp.h:79
cgms_racp_filter_type_t
cgms_racp_filter_type_t
Continuous Glucose Monitoring Recoerd Access Control Point filter types.
Definition: cgms_racp.h:116
gr_includes.h
Include Files API.
CGMS_RACP_RSP_OPERAND_NOT_SUP
@ CGMS_RACP_RSP_OPERAND_NOT_SUP
Normal response if unsupported Operand is received.
Definition: cgms_racp.h:110
CGMS_RACP_RSP_ABORT_UNSUCCESSFUL
@ CGMS_RACP_RSP_ABORT_UNSUCCESSFUL
Normal response if request for Abort cannot be completed.
Definition: cgms_racp.h:108
cgms_racp_operand_t
cgms_racp_operand_t
Continuous Glucose Monitoring Recoerd Access Control Point Response codes.
Definition: cgms_racp.h:100
CGMS_RACP_RSP_INVALID_OPERAND
@ CGMS_RACP_RSP_INVALID_OPERAND
Normal response if Operand received does not meet the requirements of the service.
Definition: cgms_racp.h:106
CGMS_RACP_OPERATOR_FIRST_REC
@ CGMS_RACP_OPERATOR_FIRST_REC
First record(i.e.
Definition: cgms_racp.h:94
CGMS_RACP_OP_ABORT_OP
@ CGMS_RACP_OP_ABORT_OP
Abort operation (Operator: Null 'value of 0x00 from Operator Table').
Definition: cgms_racp.h:80
CGMS_RACP_OPERATOR_WITHIN_RANGE_OF
@ CGMS_RACP_OPERATOR_WITHIN_RANGE_OF
Within rang of (inclusive).
Definition: cgms_racp.h:93
CGMS_RACP_RSP_OPERATOR_NOT_SUP
@ CGMS_RACP_RSP_OPERATOR_NOT_SUP
Normal response if unsupported Operator is received.
Definition: cgms_racp.h:105
CGMS_RACP_OPERATOR_NULL
@ CGMS_RACP_OPERATOR_NULL
NULL.
Definition: cgms_racp.h:89
cgms_racp_req_t
Continuous Glucose Monitoring Recoerd Access Control Point request value.
Definition: cgms_racp.h:128
CGMS_RACP_OPERATOR_GT_OR_EQ
@ CGMS_RACP_OPERATOR_GT_OR_EQ
Greater than or equal to.
Definition: cgms_racp.h:92
cgms_racp_rsp_t::num_of_record
uint16_t num_of_record
Number of record (if op_code = CGMS_RACP_OP_REP_NB_OF_STRD_RECS).
Definition: cgms_racp.h:149
cgms_racp_req_t::min
uint16_t min
Definition: cgms_racp.h:136
CGMS_RACP_FILTER_RESERVED
@ CGMS_RACP_FILTER_RESERVED
Reserved for future use.
Definition: cgms_racp.h:117
cgms_racp_op_code_t
cgms_racp_op_code_t
Continuous Glucose Monitoring Recoerd Access Control Point Operation Codes.
Definition: cgms_racp.h:76
CGMS_RACP_RSP_NO_RECS_FOUND
@ CGMS_RACP_RSP_NO_RECS_FOUND
Normal response if request to report stored records or request to delete stored records resulted in n...
Definition: cgms_racp.h:107
cgms_racp_req_t::filter_type
cgms_racp_filter_type_t filter_type
Continuous Glucose Monitoring Recoerd Access Control Point filter types.
Definition: cgms_racp.h:131
CGMS_RACP_RSP_RESERVED
@ CGMS_RACP_RSP_RESERVED
Reserved for future use.
Definition: cgms_racp.h:101
CGMS_RACP_OP_RESERVED
@ CGMS_RACP_OP_RESERVED
Reserved for future use.
Definition: cgms_racp.h:77
cgms_racp_req_decode
cgms_racp_operand_t cgms_racp_req_decode(const uint8_t *p_data, uint16_t length, cgms_racp_req_t *p_racp_req)
Decode record access control point request.
cgms_racp_operator_t
cgms_racp_operator_t
Continuous Glucose Monitoring Recoerd Access Control Point Operator.
Definition: cgms_racp.h:88
cgms_racp_rsp_encode
uint16_t cgms_racp_rsp_encode(cgms_racp_rsp_t *p_racp_rsp, uint8_t *p_encoded_buffer)
Encode record access control point response.
CGMS_RACP_OP_RSP_CODE
@ CGMS_RACP_OP_RSP_CODE
Response Code (Operator: Null 'value of 0x00 from Operator Table').
Definition: cgms_racp.h:83
CGMS_RACP_RSP_OP_CODE_NOT_SUP
@ CGMS_RACP_RSP_OP_CODE_NOT_SUP
Normal response if unsupported Op Code is received.
Definition: cgms_racp.h:103
CGMS_RACP_OPERATOR_LAST_REC
@ CGMS_RACP_OPERATOR_LAST_REC
Last record (i.e.
Definition: cgms_racp.h:95
cgms_racp_rsp_t
Continuous Glucose Monitoring Recoerd Access Control Point response value.
Definition: cgms_racp.h:144
CGMS_RACP_OP_REP_STRD_RECS
@ CGMS_RACP_OP_REP_STRD_RECS
Report stored records (Operator: Value from Operator Table).
Definition: cgms_racp.h:78
cgms_racp_rsp_t::op_code
cgms_racp_op_code_t op_code
Continuous Glucose Monitoring Recoerd Access Control Point Operation Code.
Definition: cgms_racp.h:145
CGMS_RACP_OPERATOR_LE_OR_EQ
@ CGMS_RACP_OPERATOR_LE_OR_EQ
Less than or equal to.
Definition: cgms_racp.h:91
cgms_racp_rsp_t::status
cgms_racp_operand_t status
Command Status (if op_code = CGMS_RACP_OP_RSP_CODE).
Definition: cgms_racp.h:153