FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.

Dependencies:   mbed FXOS8700CQ MODSERIAL

Committer:
jwhammel
Date:
Mon Apr 29 04:24:38 2019 +0000
Revision:
85:0cf65ceb4492
Parent:
84:fc8c9b39723a
We have added an alarm trigger that gets sent to AT&T Flow.

Who changed what in which revision?

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