ARM mbed M2X API Client: The ARM mbed client library is used to send/receive data to/from AT&T's M2X service from mbed LPC1768 microcontrollers.
Dependents: m2x-demo-all M2X_MTS_ACCEL_DEMO M2X_MTS_Accel M2X_K64F_ACCEL ... more
Diff: TimeService.h
- Revision:
- 22:4d895e732765
- Parent:
- 21:6878944d2ce2
--- a/TimeService.h Sat Jan 02 02:29:43 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -#ifndef TimeService_h -#define TimeService_h - -class M2XStreamClient; - -// A ISO8601 timestamp generation service for M2X. -// It uses the Time API provided by the M2X server to initialize -// clock, then uses millis() function provided by Arduino to calculate -// time advancements so as to reduce API query times. -// -// Right now, this service only works with 32-bit timestamp, meaning that -// this service won't work after 03:14:07 UTC on 19 January 2038. However, -// a similar service that uses 64-bit timestamp can be implemented following -// the logic here. -class TimeService { -public: - TimeService(M2XStreamClient* client); - - // Initialize the time service. Notice the TimeService instance is only - // working after calling this function successfully. - int init(); - - // Reset the internal recorded time by calling M2X Time API again. Normally, - // you don't need to call this manually. TimeService will handle Arduino clock - // overflow automatically - int reset(); - - // Fills ISO8601 formatted timestamp into the buffer provided. +length+ should - // contains the maximum supported length of the buffer when calling. For now, - // the buffer should be able to store 25 characters for a full ISO8601 formatted - // timestamp, otherwise, an error will be returned. - int getTimestamp(char* buffer, int* length); -private: - M2XStreamClient* _client; - int32_t _server_timestamp; - uint32_t _local_last_milli; - Timer _timer; -}; - -#endif /* TimeService_h */