IOTIO

Dependencies:   Nucleo_BLE_API_IOTIO Nucleo_BLE_BlueNRG Nucleo_BLE_DemoApp Nucleo_Sensor_Shield mbed

Dependents:   Nucleo_BLE_Demo_IOTIO

Fork of Nucleo_BLE_Demo by Cortex Challenge Team

Committer:
16038618
Date:
Sat Oct 29 15:11:28 2016 +0000
Revision:
1:4bdfa7d7e8bf
IOTIO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
16038618 1:4bdfa7d7e8bf 1 /* mbed Microcontroller Library
16038618 1:4bdfa7d7e8bf 2 * Copyright (c) 2006-2013 ARM Limited
16038618 1:4bdfa7d7e8bf 3 *
16038618 1:4bdfa7d7e8bf 4 * Licensed under the Apache License, Version 2.0 (the "License");
16038618 1:4bdfa7d7e8bf 5 * you may not use this file except in compliance with the License.
16038618 1:4bdfa7d7e8bf 6 * You may obtain a copy of the License at
16038618 1:4bdfa7d7e8bf 7 *
16038618 1:4bdfa7d7e8bf 8 * http://www.apache.org/licenses/LICENSE-2.0
16038618 1:4bdfa7d7e8bf 9 *
16038618 1:4bdfa7d7e8bf 10 * Unless required by applicable law or agreed to in writing, software
16038618 1:4bdfa7d7e8bf 11 * distributed under the License is distributed on an "AS IS" BASIS,
16038618 1:4bdfa7d7e8bf 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16038618 1:4bdfa7d7e8bf 13 * See the License for the specific language governing permissions and
16038618 1:4bdfa7d7e8bf 14 * limitations under the License.
16038618 1:4bdfa7d7e8bf 15 */
16038618 1:4bdfa7d7e8bf 16
16038618 1:4bdfa7d7e8bf 17 #include <time.h>
16038618 1:4bdfa7d7e8bf 18
16038618 1:4bdfa7d7e8bf 19 #ifdef __cplusplus
16038618 1:4bdfa7d7e8bf 20 extern "C" {
16038618 1:4bdfa7d7e8bf 21 #endif
16038618 1:4bdfa7d7e8bf 22
16038618 1:4bdfa7d7e8bf 23 /** Implementation of the C time.h functions
16038618 1:4bdfa7d7e8bf 24 *
16038618 1:4bdfa7d7e8bf 25 * Provides mechanisms to set and read the current time, based
16038618 1:4bdfa7d7e8bf 26 * on the microcontroller Real-Time Clock (RTC), plus some
16038618 1:4bdfa7d7e8bf 27 * standard C manipulation and formating functions.
16038618 1:4bdfa7d7e8bf 28 *
16038618 1:4bdfa7d7e8bf 29 * Example:
16038618 1:4bdfa7d7e8bf 30 * @code
16038618 1:4bdfa7d7e8bf 31 * #include "mbed.h"
16038618 1:4bdfa7d7e8bf 32 *
16038618 1:4bdfa7d7e8bf 33 * int main() {
16038618 1:4bdfa7d7e8bf 34 * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
16038618 1:4bdfa7d7e8bf 35 *
16038618 1:4bdfa7d7e8bf 36 * while(1) {
16038618 1:4bdfa7d7e8bf 37 * time_t seconds = time(NULL);
16038618 1:4bdfa7d7e8bf 38 *
16038618 1:4bdfa7d7e8bf 39 * printf("Time as seconds since January 1, 1970 = %d\n", seconds);
16038618 1:4bdfa7d7e8bf 40 *
16038618 1:4bdfa7d7e8bf 41 * printf("Time as a basic string = %s", ctime(&seconds));
16038618 1:4bdfa7d7e8bf 42 *
16038618 1:4bdfa7d7e8bf 43 * char buffer[32];
16038618 1:4bdfa7d7e8bf 44 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
16038618 1:4bdfa7d7e8bf 45 * printf("Time as a custom formatted string = %s", buffer);
16038618 1:4bdfa7d7e8bf 46 *
16038618 1:4bdfa7d7e8bf 47 * wait(1);
16038618 1:4bdfa7d7e8bf 48 * }
16038618 1:4bdfa7d7e8bf 49 * }
16038618 1:4bdfa7d7e8bf 50 * @endcode
16038618 1:4bdfa7d7e8bf 51 */
16038618 1:4bdfa7d7e8bf 52
16038618 1:4bdfa7d7e8bf 53 /** Set the current time
16038618 1:4bdfa7d7e8bf 54 *
16038618 1:4bdfa7d7e8bf 55 * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
16038618 1:4bdfa7d7e8bf 56 * to the time represented by the number of seconds since January 1, 1970
16038618 1:4bdfa7d7e8bf 57 * (the UNIX timestamp).
16038618 1:4bdfa7d7e8bf 58 *
16038618 1:4bdfa7d7e8bf 59 * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
16038618 1:4bdfa7d7e8bf 60 *
16038618 1:4bdfa7d7e8bf 61 * Example:
16038618 1:4bdfa7d7e8bf 62 * @code
16038618 1:4bdfa7d7e8bf 63 * #include "mbed.h"
16038618 1:4bdfa7d7e8bf 64 *
16038618 1:4bdfa7d7e8bf 65 * int main() {
16038618 1:4bdfa7d7e8bf 66 * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
16038618 1:4bdfa7d7e8bf 67 * }
16038618 1:4bdfa7d7e8bf 68 * @endcode
16038618 1:4bdfa7d7e8bf 69 */
16038618 1:4bdfa7d7e8bf 70 void set_time(time_t t);
16038618 1:4bdfa7d7e8bf 71
16038618 1:4bdfa7d7e8bf 72 /** Attach an external RTC to be used for the C time functions
16038618 1:4bdfa7d7e8bf 73 *
16038618 1:4bdfa7d7e8bf 74 * Do not call this function from an interrupt while an RTC read/write operation may be occurring
16038618 1:4bdfa7d7e8bf 75 *
16038618 1:4bdfa7d7e8bf 76 * @param read_rtc pointer to function which returns current UNIX timestamp
16038618 1:4bdfa7d7e8bf 77 * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
16038618 1:4bdfa7d7e8bf 78 * @param init_rtc pointer to funtion which initializes RTC, can be NULL
16038618 1:4bdfa7d7e8bf 79 * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
16038618 1:4bdfa7d7e8bf 80 */
16038618 1:4bdfa7d7e8bf 81 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
16038618 1:4bdfa7d7e8bf 82
16038618 1:4bdfa7d7e8bf 83 #ifdef __cplusplus
16038618 1:4bdfa7d7e8bf 84 }
16038618 1:4bdfa7d7e8bf 85 #endif