テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8468a4403fea 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8468a4403fea 2 *
jksoft 0:8468a4403fea 3 * The information contained herein is property of Nordic Semiconductor ASA.
jksoft 0:8468a4403fea 4 * Terms and conditions of usage are described in detail in NORDIC
jksoft 0:8468a4403fea 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
jksoft 0:8468a4403fea 6 *
jksoft 0:8468a4403fea 7 * Licensees are granted free, non-transferable use of the information. NO
jksoft 0:8468a4403fea 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jksoft 0:8468a4403fea 9 * the file.
jksoft 0:8468a4403fea 10 */
jksoft 0:8468a4403fea 11
jksoft 0:8468a4403fea 12 /* Attention!
jksoft 0:8468a4403fea 13 * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile
jksoft 0:8468a4403fea 14 * qualification listings, this section of source code must not be modified.
jksoft 0:8468a4403fea 15 */
jksoft 0:8468a4403fea 16
jksoft 0:8468a4403fea 17 /** @file
jksoft 0:8468a4403fea 18 * @brief Contains definition of ble_date_time structure.
jksoft 0:8468a4403fea 19 */
jksoft 0:8468a4403fea 20
jksoft 0:8468a4403fea 21 /** @file
jksoft 0:8468a4403fea 22 *
jksoft 0:8468a4403fea 23 * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type
jksoft 0:8468a4403fea 24 * @{
jksoft 0:8468a4403fea 25 * @ingroup ble_sdk_srv
jksoft 0:8468a4403fea 26 * @brief Definition of ble_date_time_t type.
jksoft 0:8468a4403fea 27 */
jksoft 0:8468a4403fea 28
jksoft 0:8468a4403fea 29 #ifndef BLE_DATE_TIME_H__
jksoft 0:8468a4403fea 30 #define BLE_DATE_TIME_H__
jksoft 0:8468a4403fea 31
jksoft 0:8468a4403fea 32 #include <stdint.h>
jksoft 0:8468a4403fea 33
jksoft 0:8468a4403fea 34 /**@brief Date and Time structure. */
jksoft 0:8468a4403fea 35 typedef struct
jksoft 0:8468a4403fea 36 {
jksoft 0:8468a4403fea 37 uint16_t year;
jksoft 0:8468a4403fea 38 uint8_t month;
jksoft 0:8468a4403fea 39 uint8_t day;
jksoft 0:8468a4403fea 40 uint8_t hours;
jksoft 0:8468a4403fea 41 uint8_t minutes;
jksoft 0:8468a4403fea 42 uint8_t seconds;
jksoft 0:8468a4403fea 43 } ble_date_time_t;
jksoft 0:8468a4403fea 44
jksoft 0:8468a4403fea 45 static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time,
jksoft 0:8468a4403fea 46 uint8_t * p_encoded_data)
jksoft 0:8468a4403fea 47 {
jksoft 0:8468a4403fea 48 uint8_t len = uint16_encode(p_date_time->year, p_encoded_data);
jksoft 0:8468a4403fea 49
jksoft 0:8468a4403fea 50 p_encoded_data[len++] = p_date_time->month;
jksoft 0:8468a4403fea 51 p_encoded_data[len++] = p_date_time->day;
jksoft 0:8468a4403fea 52 p_encoded_data[len++] = p_date_time->hours;
jksoft 0:8468a4403fea 53 p_encoded_data[len++] = p_date_time->minutes;
jksoft 0:8468a4403fea 54 p_encoded_data[len++] = p_date_time->seconds;
jksoft 0:8468a4403fea 55
jksoft 0:8468a4403fea 56 return len;
jksoft 0:8468a4403fea 57 }
jksoft 0:8468a4403fea 58
jksoft 0:8468a4403fea 59 static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time,
jksoft 0:8468a4403fea 60 const uint8_t * p_encoded_data)
jksoft 0:8468a4403fea 61 {
jksoft 0:8468a4403fea 62 uint8_t len = sizeof(uint16_t);
jksoft 0:8468a4403fea 63
jksoft 0:8468a4403fea 64 p_date_time->year = uint16_decode(p_encoded_data);
jksoft 0:8468a4403fea 65 p_date_time->month = p_encoded_data[len++];
jksoft 0:8468a4403fea 66 p_date_time->day = p_encoded_data[len++];
jksoft 0:8468a4403fea 67 p_date_time->hours = p_encoded_data[len++];
jksoft 0:8468a4403fea 68 p_date_time->minutes = p_encoded_data[len++];
jksoft 0:8468a4403fea 69 p_date_time->seconds = p_encoded_data[len++];
jksoft 0:8468a4403fea 70
jksoft 0:8468a4403fea 71 return len;
jksoft 0:8468a4403fea 72 }
jksoft 0:8468a4403fea 73
jksoft 0:8468a4403fea 74 #endif // BLE_DATE_TIME_H__
jksoft 0:8468a4403fea 75
jksoft 0:8468a4403fea 76 /** @} */