Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.
source/nordic_sdk/components/ble/common/ble_date_time.h@19:47192cb9def7, 2016-04-07 (annotated)
- Committer:
- vcoubard
- Date:
- Thu Apr 07 17:37:40 2016 +0100
- Revision:
- 19:47192cb9def7
- Parent:
- 10:233fefd8162b
- Child:
- 20:a90c48eb1d30
Synchronized with git rev 9251259f
Author: Liyou Zhou
Copy over coresponding files from nordic-sdk 9.0.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 19:47192cb9def7 | 1 | /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. |
vcoubard | 19:47192cb9def7 | 2 | * |
vcoubard | 19:47192cb9def7 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
vcoubard | 19:47192cb9def7 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
vcoubard | 19:47192cb9def7 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
vcoubard | 19:47192cb9def7 | 6 | * |
vcoubard | 19:47192cb9def7 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
vcoubard | 19:47192cb9def7 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
vcoubard | 19:47192cb9def7 | 9 | * the file. |
vcoubard | 19:47192cb9def7 | 10 | */ |
Vincent Coubard |
0:f2542974c862 | 11 | |
vcoubard | 1:ebc0e0ef0a11 | 12 | /* Attention! |
vcoubard | 1:ebc0e0ef0a11 | 13 | * To maintain compliance with Nordic Semiconductor ASAs Bluetooth profile |
Vincent Coubard |
0:f2542974c862 | 14 | * qualification listings, this section of source code must not be modified. |
Vincent Coubard |
0:f2542974c862 | 15 | */ |
Vincent Coubard |
0:f2542974c862 | 16 | |
Vincent Coubard |
0:f2542974c862 | 17 | /** @file |
Vincent Coubard |
0:f2542974c862 | 18 | * @brief Contains definition of ble_date_time structure. |
Vincent Coubard |
0:f2542974c862 | 19 | */ |
Vincent Coubard |
0:f2542974c862 | 20 | |
Vincent Coubard |
0:f2542974c862 | 21 | /** @file |
Vincent Coubard |
0:f2542974c862 | 22 | * |
Vincent Coubard |
0:f2542974c862 | 23 | * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type |
Vincent Coubard |
0:f2542974c862 | 24 | * @{ |
Vincent Coubard |
0:f2542974c862 | 25 | * @ingroup ble_sdk_lib |
Vincent Coubard |
0:f2542974c862 | 26 | * @brief Definition of ble_date_time_t type. |
Vincent Coubard |
0:f2542974c862 | 27 | */ |
Vincent Coubard |
0:f2542974c862 | 28 | |
Vincent Coubard |
0:f2542974c862 | 29 | #ifndef BLE_DATE_TIME_H__ |
Vincent Coubard |
0:f2542974c862 | 30 | #define BLE_DATE_TIME_H__ |
Vincent Coubard |
0:f2542974c862 | 31 | |
Vincent Coubard |
0:f2542974c862 | 32 | #include <stdint.h> |
Vincent Coubard |
0:f2542974c862 | 33 | |
Vincent Coubard |
0:f2542974c862 | 34 | /**@brief Date and Time structure. */ |
Vincent Coubard |
0:f2542974c862 | 35 | typedef struct |
Vincent Coubard |
0:f2542974c862 | 36 | { |
Vincent Coubard |
0:f2542974c862 | 37 | uint16_t year; |
Vincent Coubard |
0:f2542974c862 | 38 | uint8_t month; |
Vincent Coubard |
0:f2542974c862 | 39 | uint8_t day; |
Vincent Coubard |
0:f2542974c862 | 40 | uint8_t hours; |
Vincent Coubard |
0:f2542974c862 | 41 | uint8_t minutes; |
Vincent Coubard |
0:f2542974c862 | 42 | uint8_t seconds; |
Vincent Coubard |
0:f2542974c862 | 43 | } ble_date_time_t; |
Vincent Coubard |
0:f2542974c862 | 44 | |
Vincent Coubard |
0:f2542974c862 | 45 | static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time, |
Vincent Coubard |
0:f2542974c862 | 46 | uint8_t * p_encoded_data) |
Vincent Coubard |
0:f2542974c862 | 47 | { |
Vincent Coubard |
0:f2542974c862 | 48 | uint8_t len = uint16_encode(p_date_time->year, p_encoded_data); |
vcoubard | 1:ebc0e0ef0a11 | 49 | |
Vincent Coubard |
0:f2542974c862 | 50 | p_encoded_data[len++] = p_date_time->month; |
Vincent Coubard |
0:f2542974c862 | 51 | p_encoded_data[len++] = p_date_time->day; |
Vincent Coubard |
0:f2542974c862 | 52 | p_encoded_data[len++] = p_date_time->hours; |
Vincent Coubard |
0:f2542974c862 | 53 | p_encoded_data[len++] = p_date_time->minutes; |
Vincent Coubard |
0:f2542974c862 | 54 | p_encoded_data[len++] = p_date_time->seconds; |
vcoubard | 1:ebc0e0ef0a11 | 55 | |
Vincent Coubard |
0:f2542974c862 | 56 | return len; |
Vincent Coubard |
0:f2542974c862 | 57 | } |
Vincent Coubard |
0:f2542974c862 | 58 | |
Vincent Coubard |
0:f2542974c862 | 59 | static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time, |
Vincent Coubard |
0:f2542974c862 | 60 | const uint8_t * p_encoded_data) |
Vincent Coubard |
0:f2542974c862 | 61 | { |
Vincent Coubard |
0:f2542974c862 | 62 | uint8_t len = sizeof(uint16_t); |
vcoubard | 1:ebc0e0ef0a11 | 63 | |
Vincent Coubard |
0:f2542974c862 | 64 | p_date_time->year = uint16_decode(p_encoded_data); |
Vincent Coubard |
0:f2542974c862 | 65 | p_date_time->month = p_encoded_data[len++]; |
vcoubard | 1:ebc0e0ef0a11 | 66 | p_date_time->day = p_encoded_data[len++]; |
Vincent Coubard |
0:f2542974c862 | 67 | p_date_time->hours = p_encoded_data[len++]; |
Vincent Coubard |
0:f2542974c862 | 68 | p_date_time->minutes = p_encoded_data[len++]; |
Vincent Coubard |
0:f2542974c862 | 69 | p_date_time->seconds = p_encoded_data[len++]; |
vcoubard | 1:ebc0e0ef0a11 | 70 | |
Vincent Coubard |
0:f2542974c862 | 71 | return len; |
Vincent Coubard |
0:f2542974c862 | 72 | } |
Vincent Coubard |
0:f2542974c862 | 73 | |
Vincent Coubard |
0:f2542974c862 | 74 | #endif // BLE_DATE_TIME_H__ |
Vincent Coubard |
0:f2542974c862 | 75 | |
vcoubard | 1:ebc0e0ef0a11 | 76 | /** @} */ |