arduino-snapclient
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
SnapTime Class Reference

The the sys/time functions are used to represent the server time. The local time will be measured with the help of the Arduino millis() method. This class provides the basic functionality to translate between local and server time. More...

#include <SnapTime.h>

Public Member Functions

uint32_t localMillis ()
 
bool printLocalTime (const char *msg)
 
uint32_t serverMillis ()
 Provides the current server time in ms.
 
void setTimeDifferenceClientServerMs (uint32_t diff)
 Record the last time difference between client and server.
 
void setupSNTPTime ()
 
timeval time ()
 Provides the actual time as timeval.
 
timeval timeDifference (timeval t1, timeval t2)
 
int timeDifferenceClientServerMs ()
 Provides the avg latecy in milliseconds.
 
uint32_t timeDifferenceMs (timeval t1, timeval t2)
 
uint32_t toMillis (timeval tv)
 
uint32_t toMillis (uint32_t sec, uint32_t usec)
 
void updateServerTime (timeval &server)
 

Static Public Member Functions

static SnapTimeinstance ()
 

Protected Attributes

bool has_sntp_time = false
 
uint32_t local_ms
 
uint32_t server_ms = 0
 
timeval server_time
 
const char * TAG = "SnapTime"
 
uint32_t time_diff = 0
 
uint32_t time_update_count = 0
 

Detailed Description

The the sys/time functions are used to represent the server time. The local time will be measured with the help of the Arduino millis() method. This class provides the basic functionality to translate between local and server time.

Author
Phil Schatzmann
Version
0.1
Date
2023-10-28

The documentation for this class was generated from the following file: