IoTivity-Lite
plgd_time.h File Reference

Time synchronization from an external endpoint. More...

#include "util/oc_features.h"
#include "oc_endpoint.h"
#include "oc_export.h"
#include "oc_ri.h"
#include "port/oc_clock.h"
#include "util/oc_compiler.h"
#include "oc_pki.h"
#include <stdbool.h>

Typedefs

typedef int(* plgd_set_system_time_fn_t) (oc_clock_time_t time, void *user_data)
 Function used to set time on the whole system invoked whenever the plgd time is updated. More...
 
typedef void(* plgd_time_on_fetch_fn_t) (oc_status_t code, oc_clock_time_t time, void *data)
 Callback invoked when plgd_time_fetch request receives a response or timeouts. More...
 

Enumerations

enum  plgd_time_fetch_flags_t { PLGD_TIME_FETCH_FLAG_TCP_SESSION_OPENED }
 
enum  plgd_time_status_t { PLGD_TIME_STATUS_SYNCING = 1 , PLGD_TIME_STATUS_IN_SYNC , PLGD_TIME_STATUS_IN_SYNC_FROM_STORAGE }
 

Functions

oc_clock_time_t plgd_time (void)
 Calculate current plgd time. More...
 
void plgd_time_configure (bool use_in_mbedtls, plgd_set_system_time_fn_t set_system_time, void *set_system_time_data)
 Configure the plgd time feature. More...
 
bool plgd_time_dump (void)
 Save persistent data of the plgd time resource to storage. More...
 
bool plgd_time_fetch (plgd_time_fetch_config_t fetch, unsigned *flags)
 Fetch time from an endpoint by a GET request. More...
 
plgd_time_fetch_config_t plgd_time_fetch_config (const oc_endpoint_t *endpoint, const char *uri, plgd_time_on_fetch_fn_t on_fetch, void *on_fetch_data, uint16_t timeout, int selected_identity_credid, bool disable_time_verification)
 Convenience wrapper to create plgd_time_fetch_config_t with default \ verification function. More...
 
plgd_time_fetch_config_t plgd_time_fetch_config_with_custom_verification (const oc_endpoint_t *endpoint, const char *uri, plgd_time_on_fetch_fn_t on_fetch, void *on_fetch_data, uint16_t timeout, int selected_identity_credid, oc_pki_verify_certificate_cb_t verify, oc_pki_user_data_t verify_data)
 Convenience wrapper to create plgd_time_fetch_config_t with a custom verification function. More...
 
bool plgd_time_is_active (void)
 Plgd time is active (ie it is set to a valid, non-zero value). More...
 
oc_clock_time_t plgd_time_last_synced_time (void)
 Get the latest synchronization time. More...
 
bool plgd_time_load (void)
 Load persistent data of the plgd time resource from storage. More...
 
unsigned long plgd_time_seconds (void)
 Calculate the number of seconds since the Unix Epoch. More...
 
void plgd_time_set_status (plgd_time_status_t status)
 Set plgd time status. More...
 
int plgd_time_set_time (oc_clock_time_t time)
 Synchronize the plgd time. More...
 
plgd_time_status_t plgd_time_status (void)
 Get plgd time status. More...
 

Detailed Description

Time synchronization from an external endpoint.

Author
Daniel Adam