Wirepas SDK
rtc.h File Reference

Go to the source code of this file.

Typedefs

typedef uint64_t rtc_timestamp_t
 
typedef void(* on_rtc_initialized) (void)
 Callback called the first time RTC time is aquired from network. More...
 

Functions

rtc_res_e RTC_init (void)
 Initialize the stack state library. More...
 
rtc_res_e RTC_getUTCTime (rtc_timestamp_t *now)
 Get current expected RTC time from node. More...
 
rtc_res_e RTC_getLocalTime (rtc_timestamp_t *now)
 Get current expected RTC time with timezone from node. More...
 
rtc_res_e RTC_getTimezoneOffsetInSeconds (long *timezoneOffsetInSeconds)
 Get configured timezone offset of the node. More...
 
rtc_res_e RTC_addInitializeCb (on_rtc_initialized callback)
 Add a new callback to be informed when RTC time is available from network. More...
 
rtc_res_e RTC_removeInitializedCb (on_rtc_initialized callback)
 Remove an event callback from the list. Removed item fields are all set to 0. More...
 

Enumerations

enum  rtc_res_e {
  RTC_RES_OK = 0, RTC_UNAVAILABLE_YET = 1, RTC_NO_MORE_CALLBACKS = 2, RTC_UNKNOWN_CALLBACK = 3,
  RTC_INVALID_VALUE = 4, RTC_UNINITIALIZED = 5
}
 List of return code. More...
 
enum  provisioning_data_ids_e { RTC_ID_TIMESTAMP = 0, RTC_ID_TIMEZONE_OFFSET = 1 }
 List of Wirepas Ids for TLV encoded provisioning data. More...
 

Macros

#define RTC_VERSION   (uint16_t)(1)
 

Typedef Documentation

◆ on_rtc_initialized

typedef void(* on_rtc_initialized) (void)

Callback called the first time RTC time is aquired from network.

Note
It is up to registered module to call RTC_getUTCTime() in the callback

Definition at line 50 of file rtc.h.

◆ rtc_timestamp_t

typedef uint64_t rtc_timestamp_t

Definition at line 43 of file rtc.h.

Function Documentation

◆ RTC_addInitializeCb()

rtc_res_e RTC_addInitializeCb ( on_rtc_initialized  callback)

Add a new callback to be informed when RTC time is available from network.

Parameters
callbackNew callback
Returns
RTC_RES_OK if ok. See rtc_res_e for other result codes.

◆ RTC_getLocalTime()

rtc_res_e RTC_getLocalTime ( rtc_timestamp_t now)

Get current expected RTC time with timezone from node.

Parameters
nowCurrent local time if return code is RTC_RES_OK
Returns
Return code of the operation rtc_res_e

◆ RTC_getTimezoneOffsetInSeconds()

rtc_res_e RTC_getTimezoneOffsetInSeconds ( long *  timezoneOffsetInSeconds)

Get configured timezone offset of the node.

Parameters
timezoneOffsetInSecondstimezone offset of the local time if return code is RTC_RES_OK
Returns
Return code of the operation rtc_res_e

◆ RTC_getUTCTime()

rtc_res_e RTC_getUTCTime ( rtc_timestamp_t now)

Get current expected RTC time from node.

Parameters
nowCurrent RTC time if return code is RTC_RES_OK
Returns
Return code of the operation rtc_res_e
Note
RTC time must have been received from network in the last 50 days.

◆ RTC_init()

rtc_res_e RTC_init ( void  )

Initialize the stack state library.

Returns
Return code of operation

◆ RTC_removeInitializedCb()

rtc_res_e RTC_removeInitializedCb ( on_rtc_initialized  callback)

Remove an event callback from the list. Removed item fields are all set to 0.

Parameters
callbackcallback to remove.
Returns
RTC_RES_OK if ok. See app_res_e for other result codes.

Enumeration Type Documentation

◆ provisioning_data_ids_e

List of Wirepas Ids for TLV encoded provisioning data.

Enumerator
RTC_ID_TIMESTAMP 
RTC_ID_TIMEZONE_OFFSET 

Definition at line 37 of file rtc.h.

◆ rtc_res_e

enum rtc_res_e

List of return code.

Enumerator
RTC_RES_OK 

Operation is successful

RTC_UNAVAILABLE_YET 

RTC is not yet available from network

RTC_NO_MORE_CALLBACKS 

Cannot register new callback

RTC_UNKNOWN_CALLBACK 

Callback is not known

RTC_INVALID_VALUE 

One or more parameter value is invalid

RTC_UNINITIALIZED 

The library has not been initialized.

Definition at line 20 of file rtc.h.

21 {
23  RTC_RES_OK = 0,
34 } rtc_res_e;

Macro Definition Documentation

◆ RTC_VERSION

#define RTC_VERSION   (uint16_t)(1)

Definition at line 14 of file rtc.h.

RTC_UNKNOWN_CALLBACK
@ RTC_UNKNOWN_CALLBACK
Definition: rtc.h:29
RTC_UNINITIALIZED
@ RTC_UNINITIALIZED
Definition: rtc.h:33
provisioning_data_ids_e
provisioning_data_ids_e
List of Wirepas Ids for TLV encoded provisioning data.
Definition: rtc.h:37
RTC_UNAVAILABLE_YET
@ RTC_UNAVAILABLE_YET
Definition: rtc.h:25
RTC_NO_MORE_CALLBACKS
@ RTC_NO_MORE_CALLBACKS
Definition: rtc.h:27
RTC_INVALID_VALUE
@ RTC_INVALID_VALUE
Definition: rtc.h:31
RTC_ID_TIMESTAMP
@ RTC_ID_TIMESTAMP
Definition: rtc.h:39
rtc_res_e
rtc_res_e
List of return code.
Definition: rtc.h:20
RTC_ID_TIMEZONE_OFFSET
@ RTC_ID_TIMEZONE_OFFSET
Definition: rtc.h:40
RTC_RES_OK
@ RTC_RES_OK
Definition: rtc.h:23