ndcs.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file ndcs.h
5 *
6 * @brief Next DST Change 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_NDCS Next DST Change Service (NDCS)
46 * @{
47 * @brief Next DST Change Service module.
48 *
49 * @details The Next DST Change Service exposes the Time with DST characteristic. This module
50 * implements the Next DST Change Service with Time with DST characteristics.
51 *
52 * The application must call \ref ndcs_service_init() to add Next DST Change Service
53 * and Time with DST characteristic to the BLE Stack database.
54 */
55
56 #ifndef __NDCS_H__
57 #define __NDCS_H__
58
59 #include "gr55xx_sys.h"
60 #include "ble_prf_types.h"
61 #include "custom_config.h"
62 #include <stdint.h>
63 #include <stdbool.h>
64
65 /**
66 * @defgroup NDCS_MACRO Defines
67 * @{
68 */
69 #define NDCS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
70 10 : CFG_MAX_CONNECTIONS) /**< Maximum number of NDCS connections. */
71 #define NDCS_TIME_WITH_DST_VAL_LEN 8 /**< Length of Time with DST value. */
72 #define NDCS_CHAR_FULL 0x07 /**< Bit mask for mandatory characteristic in NDCS. */
73 /** @} */
74
75 /**
76 * @defgroup NDCS_ENUM Enumerations
77 * @{
78 */
79 /**@brief Daylight Saving Time Offset. */
80 typedef enum
81 {
82 NDCS_DST_OFFSET_STANDAR_TIME, /**< Standard Time. */
83 NDCS_DST_OFFSET_HALF_HOUR, /**< Half An Hour Daylight Time (+0.5h). */
84 NDCS_DST_OFFSET_DAYLIGHT_TIME, /**< Daylight Time (+1h). */
85 NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME /**< Double Daylight Time (+2h). */
86 } ndcs_dst_offset_t;
87 /** @} */
88
89 /**
90 * @defgroup NDCS_STRUCT Structures
91 * @{
92 */
93 /**@brief Time with DST. */
94 typedef struct
95 {
96 prf_date_time_t date_time; /**< Date Time. */
97 ndcs_dst_offset_t dst_offset; /**< Daylight Saving Time Offset. */
98 } ndcs_time_dst_t;
99 /** @} */
100
101 /**
102 * @defgroup NDCS_FUNCTION Functions
103 * @{
104 */
105 /**
106 *****************************************************************************************
107 * @brief Initialize an NDCS instance and add in the DB.
108 *
109 * @param[in] char_mask: Mask for mandatory characteristic in NDCS.
110 *
111 * @return Result of service initialization.
112 *****************************************************************************************
113 */
114 sdk_err_t ndcs_service_init(uint8_t char_mask);
115
116 /**
117 *****************************************************************************************
118 * @brief Update day time.
119 *
120 * @param[in] p_day_time: Pointer to day time.
121 *****************************************************************************************
122 */
123 void ndcs_day_time_update(prf_date_time_t *p_day_time);
124
125 /**
126 *****************************************************************************************
127 * @brief Update DST offset.
128 *
129 * @param[in] dst_offset: DST offset.
130 *****************************************************************************************
131 */
132 void ndcs_dst_offset_update(ndcs_dst_offset_t dst_offset);
133 /** @} */
134
135 #endif
136 /** @} */
137 /** @} */
138
NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME
@ NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME
Double Daylight Time (+2h).
Definition: ndcs.h:85
ndcs_time_dst_t::dst_offset
ndcs_dst_offset_t dst_offset
Daylight Saving Time Offset.
Definition: ndcs.h:97
ndcs_dst_offset_update
void ndcs_dst_offset_update(ndcs_dst_offset_t dst_offset)
Update DST offset.
ndcs_service_init
sdk_err_t ndcs_service_init(uint8_t char_mask)
Initialize an NDCS instance and add in the DB.
ndcs_time_dst_t::date_time
prf_date_time_t date_time
Date Time.
Definition: ndcs.h:96
gr55xx_sys.h
GR55XX System API.
NDCS_DST_OFFSET_STANDAR_TIME
@ NDCS_DST_OFFSET_STANDAR_TIME
Standard Time.
Definition: ndcs.h:82
ble_prf_types.h
Profile/Service Common Types.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
prf_date_time_t
The date and time structure.
Definition: ble_prf_types.h:101
NDCS_DST_OFFSET_DAYLIGHT_TIME
@ NDCS_DST_OFFSET_DAYLIGHT_TIME
Daylight Time (+1h).
Definition: ndcs.h:84
ndcs_day_time_update
void ndcs_day_time_update(prf_date_time_t *p_day_time)
Update day time.
NDCS_DST_OFFSET_HALF_HOUR
@ NDCS_DST_OFFSET_HALF_HOUR
Half An Hour Daylight Time (+0.5h).
Definition: ndcs.h:83
ndcs_time_dst_t
Time with DST.
Definition: ndcs.h:95
ndcs_dst_offset_t
ndcs_dst_offset_t
Daylight Saving Time Offset.
Definition: ndcs.h:81