test

Fork of nRF51822 by Nordic Semiconductor

Committer:
GlimwormBeacons
Date:
Sat Oct 10 09:19:50 2015 +0000
Revision:
448:b71e96a821de
Parent:
387:b13ab9a7ddb9
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 371:8f7d2137727a 1 /*
rgrover1 371:8f7d2137727a 2 * Copyright (c) Nordic Semiconductor ASA
rgrover1 371:8f7d2137727a 3 * All rights reserved.
rgrover1 371:8f7d2137727a 4 *
rgrover1 371:8f7d2137727a 5 * Redistribution and use in source and binary forms, with or without modification,
rgrover1 371:8f7d2137727a 6 * are permitted provided that the following conditions are met:
rgrover1 371:8f7d2137727a 7 *
rgrover1 371:8f7d2137727a 8 * 1. Redistributions of source code must retain the above copyright notice, this
rgrover1 371:8f7d2137727a 9 * list of conditions and the following disclaimer.
rgrover1 371:8f7d2137727a 10 *
rgrover1 371:8f7d2137727a 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
rgrover1 371:8f7d2137727a 12 * list of conditions and the following disclaimer in the documentation and/or
rgrover1 371:8f7d2137727a 13 * other materials provided with the distribution.
rgrover1 371:8f7d2137727a 14 *
rgrover1 371:8f7d2137727a 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
rgrover1 371:8f7d2137727a 16 * contributors to this software may be used to endorse or promote products
rgrover1 371:8f7d2137727a 17 * derived from this software without specific prior written permission.
rgrover1 371:8f7d2137727a 18 *
rgrover1 371:8f7d2137727a 19 *
rgrover1 371:8f7d2137727a 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
rgrover1 371:8f7d2137727a 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rgrover1 371:8f7d2137727a 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rgrover1 371:8f7d2137727a 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
rgrover1 371:8f7d2137727a 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rgrover1 371:8f7d2137727a 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rgrover1 371:8f7d2137727a 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
rgrover1 371:8f7d2137727a 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rgrover1 371:8f7d2137727a 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
rgrover1 371:8f7d2137727a 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rgrover1 371:8f7d2137727a 30 *
rgrover1 371:8f7d2137727a 31 */
rgrover1 371:8f7d2137727a 32
rgrover1 371:8f7d2137727a 33 /* Attention!
rgrover1 371:8f7d2137727a 34 * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile
rgrover1 371:8f7d2137727a 35 * qualification listings, this section of source code must not be modified.
rgrover1 371:8f7d2137727a 36 */
rgrover1 371:8f7d2137727a 37
rgrover1 371:8f7d2137727a 38 /** @file
rgrover1 371:8f7d2137727a 39 * @brief Contains definition of ble_date_time structure.
rgrover1 371:8f7d2137727a 40 */
rgrover1 371:8f7d2137727a 41
rgrover1 371:8f7d2137727a 42 /** @file
rgrover1 371:8f7d2137727a 43 *
rgrover1 371:8f7d2137727a 44 * @defgroup ble_sdk_srv_date_time BLE Date Time characteristic type
rgrover1 371:8f7d2137727a 45 * @{
rgrover1 371:8f7d2137727a 46 * @ingroup ble_sdk_lib
rgrover1 371:8f7d2137727a 47 * @brief Definition of ble_date_time_t type.
rgrover1 371:8f7d2137727a 48 */
rgrover1 371:8f7d2137727a 49
rgrover1 371:8f7d2137727a 50 #ifndef BLE_DATE_TIME_H__
rgrover1 371:8f7d2137727a 51 #define BLE_DATE_TIME_H__
rgrover1 371:8f7d2137727a 52
rgrover1 371:8f7d2137727a 53 #include <stdint.h>
rgrover1 371:8f7d2137727a 54
rgrover1 371:8f7d2137727a 55 /**@brief Date and Time structure. */
rgrover1 371:8f7d2137727a 56 typedef struct
rgrover1 371:8f7d2137727a 57 {
rgrover1 371:8f7d2137727a 58 uint16_t year;
rgrover1 371:8f7d2137727a 59 uint8_t month;
rgrover1 371:8f7d2137727a 60 uint8_t day;
rgrover1 371:8f7d2137727a 61 uint8_t hours;
rgrover1 371:8f7d2137727a 62 uint8_t minutes;
rgrover1 371:8f7d2137727a 63 uint8_t seconds;
rgrover1 371:8f7d2137727a 64 } ble_date_time_t;
rgrover1 371:8f7d2137727a 65
rgrover1 371:8f7d2137727a 66 static __INLINE uint8_t ble_date_time_encode(const ble_date_time_t * p_date_time,
rgrover1 371:8f7d2137727a 67 uint8_t * p_encoded_data)
rgrover1 371:8f7d2137727a 68 {
rgrover1 371:8f7d2137727a 69 uint8_t len = uint16_encode(p_date_time->year, p_encoded_data);
rgrover1 371:8f7d2137727a 70
rgrover1 371:8f7d2137727a 71 p_encoded_data[len++] = p_date_time->month;
rgrover1 371:8f7d2137727a 72 p_encoded_data[len++] = p_date_time->day;
rgrover1 371:8f7d2137727a 73 p_encoded_data[len++] = p_date_time->hours;
rgrover1 371:8f7d2137727a 74 p_encoded_data[len++] = p_date_time->minutes;
rgrover1 371:8f7d2137727a 75 p_encoded_data[len++] = p_date_time->seconds;
rgrover1 371:8f7d2137727a 76
rgrover1 371:8f7d2137727a 77 return len;
rgrover1 371:8f7d2137727a 78 }
rgrover1 371:8f7d2137727a 79
rgrover1 371:8f7d2137727a 80 static __INLINE uint8_t ble_date_time_decode(ble_date_time_t * p_date_time,
rgrover1 371:8f7d2137727a 81 const uint8_t * p_encoded_data)
rgrover1 371:8f7d2137727a 82 {
rgrover1 371:8f7d2137727a 83 uint8_t len = sizeof(uint16_t);
rgrover1 371:8f7d2137727a 84
rgrover1 371:8f7d2137727a 85 p_date_time->year = uint16_decode(p_encoded_data);
rgrover1 371:8f7d2137727a 86 p_date_time->month = p_encoded_data[len++];
rgrover1 371:8f7d2137727a 87 p_date_time->day = p_encoded_data[len++];
rgrover1 371:8f7d2137727a 88 p_date_time->hours = p_encoded_data[len++];
rgrover1 371:8f7d2137727a 89 p_date_time->minutes = p_encoded_data[len++];
rgrover1 371:8f7d2137727a 90 p_date_time->seconds = p_encoded_data[len++];
rgrover1 371:8f7d2137727a 91
rgrover1 371:8f7d2137727a 92 return len;
rgrover1 371:8f7d2137727a 93 }
rgrover1 371:8f7d2137727a 94
rgrover1 371:8f7d2137727a 95 #endif // BLE_DATE_TIME_H__
rgrover1 371:8f7d2137727a 96
rgrover1 371:8f7d2137727a 97 /** @} */