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 "gr_includes.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 /**< Maximum number of NDCS connections. */
70 #define NDCS_TIME_WITH_DST_VAL_LEN 8 /**< Length of Time with DST value. */
71 #define NDCS_CHAR_FULL 0x07 /**< Bit mask for mandatory characteristic in NDCS. */
72 /** @} */
73
74 /**
75 * @defgroup NDCS_ENUM Enumerations
76 * @{
77 */
78 /**@brief Daylight Saving Time Offset. */
79 typedef enum
80 {
81 NDCS_DST_OFFSET_STANDAR_TIME, /**< Standard Time. */
82 NDCS_DST_OFFSET_HALF_HOUR, /**< Half An Hour Daylight Time (+0.5h). */
83 NDCS_DST_OFFSET_DAYLIGHT_TIME, /**< Daylight Time (+1h). */
84 NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME /**< Double Daylight Time (+2h). */
85 } ndcs_dst_offset_t;
86 /** @} */
87
88 /**
89 * @defgroup NDCS_STRUCT Structures
90 * @{
91 */
92 /**@brief Time with DST. */
93 typedef struct
94 {
95 prf_date_time_t date_time; /**< Date Time. */
96 ndcs_dst_offset_t dst_offset; /**< Daylight Saving Time Offset. */
97 } ndcs_time_dst_t;
98 /** @} */
99
100 /**
101 * @defgroup NDCS_FUNCTION Functions
102 * @{
103 */
104 /**
105 *****************************************************************************************
106 * @brief Initialize an NDCS instance and add in the DB.
107 *
108 * @param[in] char_mask: Mask for mandatory characteristic in NDCS.
109 *
110 * @return Result of service initialization.
111 *****************************************************************************************
112 */
113 sdk_err_t ndcs_service_init(uint8_t char_mask);
114
115 /**
116 *****************************************************************************************
117 * @brief Update day time.
118 *
119 * @param[in] p_day_time: Pointer to day time.
120 *****************************************************************************************
121 */
122 void ndcs_day_time_update(prf_date_time_t *p_day_time);
123
124 /**
125 *****************************************************************************************
126 * @brief Update DST offset.
127 *
128 * @param[in] dst_offset: DST offset.
129 *****************************************************************************************
130 */
131 void ndcs_dst_offset_update(ndcs_dst_offset_t dst_offset);
132 /** @} */
133
134 #endif
135 /** @} */
136 /** @} */
137
NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME
@ NDCS_DST_OFFSET_DOUB_DAYLIGHT_TIME
Definition: ndcs.h:84
ndcs_time_dst_t::dst_offset
ndcs_dst_offset_t dst_offset
Definition: ndcs.h:96
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.
gr_includes.h
Include Files API.
ndcs_time_dst_t::date_time
prf_date_time_t date_time
Definition: ndcs.h:95
NDCS_DST_OFFSET_STANDAR_TIME
@ NDCS_DST_OFFSET_STANDAR_TIME
Definition: ndcs.h:81
ble_prf_types.h
Profile/Service Common Types.
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:290
prf_date_time_t
The date and time structure. The packed size is 7 bytes.
Definition: ble_prf_types.h:101
NDCS_DST_OFFSET_DAYLIGHT_TIME
@ NDCS_DST_OFFSET_DAYLIGHT_TIME
Definition: ndcs.h:83
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
Definition: ndcs.h:82
ndcs_time_dst_t
Time with DST.
Definition: ndcs.h:94
ndcs_dst_offset_t
ndcs_dst_offset_t
Daylight Saving Time Offset.
Definition: ndcs.h:80