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 <stdint.h> 60 #include <stdbool.h> 61 #include "gr55xx_sys.h" 62 #include "ble_prf_types.h" 63 #include "custom_config.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 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 prf_date_time_t date_time; /**< Date Time. */ 95 ndcs_dst_offset_t dst_offset; /**< Daylight Saving Time Offset. */ 96 } ndcs_time_dst_t; 97 /** @} */ 98 99 /** 100 * @defgroup NDCS_FUNCTION Functions 101 * @{ 102 */ 103 /** 104 ***************************************************************************************** 105 * @brief Initialize an NDCS instance and add in the DB. 106 * 107 * @param[in] char_mask: Mask for mandatory characteristic in NDCS. 108 * 109 * @return Result of service initialization. 110 ***************************************************************************************** 111 */ 112 sdk_err_t ndcs_service_init(uint8_t char_mask); 113 114 /** 115 ***************************************************************************************** 116 * @brief Update day time. 117 * 118 * @param[in] p_day_time: Pointer to day time. 119 ***************************************************************************************** 120 */ 121 void ndcs_day_time_update(prf_date_time_t *p_day_time); 122 123 /** 124 ***************************************************************************************** 125 * @brief Update DST offset. 126 * 127 * @param[in] dst_offset: DST offset. 128 ***************************************************************************************** 129 */ 130 void ndcs_dst_offset_update(ndcs_dst_offset_t dst_offset); 131 /** @} */ 132 133 #endif 134 /** @} */ 135 /** @} */ 136 137