gls_db.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gls_db.h
5  *
6  * @brief Glucose Service Database 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_GLS_DB Glucose Service Database (GLS_DB)
46  * @{
47  * @brief Glucose Service Database module.
48  *
49  * @details This module implements at database of stored glucose measurement values, application
50  * can add, delete, get and clear glucose measurement records in database after database
51  * environment variables are initialized.
52  */
53 
54 #ifndef __GLS_DB_H__
55 #define __GLS_DB_H__
56 
57 #include "gls.h"
58 #include "gls_racp.h"
59 #include <stdint.h>
60 #include <stdbool.h>
61 
62 /**
63  * @defgroup GLS_DB_MAROC Defines
64  * @{
65  */
66 #define GLS_DB_RECORDS_MAX 20 /**< Maximum glucose measurement values records stored. */
67 /** @} */
68 
69 
70 /**
71  * @defgroup GLS_DB_FUNCTION Functions
72  * @{
73  */
74 /**
75  *****************************************************************************************
76  * @brief Initialize the glucose record database.
77  *****************************************************************************************
78  */
79 void gls_db_init(void);
80 
81 /**
82  *****************************************************************************************
83  * @brief Add a record at the end of the database.
84  *
85  * @details This call adds a record as the last record in the database.
86  *
87  * @param[in] p_rec: Pointer to record to add to database.
88  *
89  * @return If add successfully or not.
90  *****************************************************************************************
91  */
93 
94 /**
95  *****************************************************************************************
96  * @brief Delete a database entry.
97  *
98  * @details This call deletes a record from the database.
99  *
100  * @param[in] rec_idx: Index of record to delete.
101  *
102  * @return If delete successfully or not.
103  *****************************************************************************************
104  */
105 bool gls_db_record_delete(uint8_t rec_idx);
106 
107 /**
108  *****************************************************************************************
109  * @brief Get the number of records in the database.
110  *
111  * @return Number of records in the database.
112  *****************************************************************************************
113  */
114 uint16_t gls_db_records_num_get(void);
115 
116 /**
117  *****************************************************************************************
118  * @brief Get the number of records satisfying the filtering condition.
119  *
120  * @return Number of records filtered.
121  *****************************************************************************************
122  */
124 
125 /**
126  *****************************************************************************************
127  * @brief Get a record from the database.
128  *
129  * @details This call returns a specified record from the database.
130  *
131  * @param[in] rec_idx: Index of the record to retrieve.
132  * @param[out] p_rec: Pointer to record structure where retrieved record is copied to.
133  *
134  * @return If get successfully or not.
135  *****************************************************************************************
136  */
137 bool gls_db_record_get(uint8_t rec_idx, gls_rec_t *p_rec);
138 
139 /**
140  *****************************************************************************************
141  * @brief Clear database.
142  *****************************************************************************************
143  */
145 /** @} */
146 
147 #endif
148 /** @} */
149 /** @} */
gls.h
Glucose Service API.
gls_db_record_clear
void gls_db_record_clear(void)
Clear database.
gls_racp.h
Glucose Service Record Access Control Point API.
gls_db_init
void gls_db_init(void)
Initialize the glucose record database.
gls_db_filter_records_num_get
uint16_t gls_db_filter_records_num_get(gls_racp_filter_t *p_filter)
Get the number of records satisfying the filtering condition.
gls_db_record_add
bool gls_db_record_add(gls_rec_t *p_rec)
Add a record at the end of the database.
gls_db_record_get
bool gls_db_record_get(uint8_t rec_idx, gls_rec_t *p_rec)
Get a record from the database.
gls_db_records_num_get
uint16_t gls_db_records_num_get(void)
Get the number of records in the database.
gls_racp_filter_t
Glucose Recoerd Access Control Point filter value.
Definition: gls_racp.h:132
gls_rec_t
Glucose measurement record.
Definition: gls.h:329
gls_db_record_delete
bool gls_db_record_delete(uint8_t rec_idx)
Delete a database entry.