Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nrf51-sdk by
ble_date_time.h
00001 /* 00002 * Copyright (c) Nordic Semiconductor ASA 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other 00016 * contributors to this software may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00024 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00026 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 * 00031 */ 00032 00033 /* Attention! 00034 * To maintain compliance with Nordic Semiconductor ASA's Bluetooth profile 00035 * qualification listings, this section of source code must not be modified. 00036 */ 00037 00038 /** @file 00039 * @brief Contains definition of ble_date_time structure. 00040 */ 00041 00042 /** @file 00043 * 00044 * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type 00045 * @{ 00046 * @ingroup ble_sdk_lib 00047 * @brief Definition of ble_date_time_t type. 00048 */ 00049 00050 #ifndef BLE_DATE_TIME_H__ 00051 #define BLE_DATE_TIME_H__ 00052 00053 #include <stdint.h> 00054 00055 /**@brief Date and Time structure. */ 00056 typedef struct 00057 { 00058 uint16_t year; 00059 uint8_t month; 00060 uint8_t day; 00061 uint8_t hours; 00062 uint8_t minutes; 00063 uint8_t seconds; 00064 } ble_date_time_t; 00065 00066 static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time, 00067 uint8_t * p_encoded_data) 00068 { 00069 uint8_t len = uint16_encode(p_date_time->year, p_encoded_data); 00070 00071 p_encoded_data[len++] = p_date_time->month; 00072 p_encoded_data[len++] = p_date_time->day; 00073 p_encoded_data[len++] = p_date_time->hours; 00074 p_encoded_data[len++] = p_date_time->minutes; 00075 p_encoded_data[len++] = p_date_time->seconds; 00076 00077 return len; 00078 } 00079 00080 static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time, 00081 const uint8_t * p_encoded_data) 00082 { 00083 uint8_t len = sizeof(uint16_t); 00084 00085 p_date_time->year = uint16_decode(p_encoded_data); 00086 p_date_time->month = p_encoded_data[len++]; 00087 p_date_time->day = p_encoded_data[len++]; 00088 p_date_time->hours = p_encoded_data[len++]; 00089 p_date_time->minutes = p_encoded_data[len++]; 00090 p_date_time->seconds = p_encoded_data[len++]; 00091 00092 return len; 00093 } 00094 00095 #endif // BLE_DATE_TIME_H__ 00096 00097 /** @} */
Generated on Tue Jul 12 2022 14:11:18 by
