LOGGER  Logger
Data Logging using ESP8266
Macros | Functions | Variables
timeservices.h File Reference
#include <arduino.h>
#include "basetype.h"

Go to the source code of this file.

Macros

#define timeservicesHedit   2
 version of this include file
 

Functions

void timeservicesInit ()
 Initialize time services, call once at system startup.
 
void timeservicesLoop ()
 
time_t timeServicesGetNTPtime ()
 
String timeservicesDumpTime (time_t t)
 
void dumpAmountOfTime (Print *pPrint, time_t seconds)
 
EXTERNDEF void dumpAmountOfTimeMS (Print *pPrint, uint32_t milliAmount)
 
bool timeservicesTimeIsValid ()
 
void timeservicesConfigurationPage ()
 display the time configuration page
 

Variables

bool timeservicesTimeWasManuallySet
 Set to true if time was set by a console command. More...
 
bool timeservicesReportRequired
 

Detailed Description

NTP time service routines

Function Documentation

void dumpAmountOfTime ( Print *  pPrint,
time_t  seconds 
)

Dump an amount of time

Parameters
pPrintwhere to output the time
secondsamount of time to dump
EXTERNDEF void dumpAmountOfTimeMS ( Print *  pPrint,
uint32_t  milliAmount 
)

Dump an amount of time

Parameters
pPrintwhere to output the time
milliAmountamount of time to dump in ms
String timeservicesDumpTime ( time_t  t)

Convert a UNIX time to a string

Parameters
ttime to convert
Returns
string form of the time
time_t timeServicesGetNTPtime ( )

Fetch time from an NTP server

Returns
: time as reported by NTP server, 0 on errors

Send an NTP packet and wait for the response, return the Unix time

To lower the memory footprint, no buffers are allocated for sending and receiving the NTP packets. Four bytes of memory are allocated for transmision, the rest is random garbage collected from the data memory segment, and the received packet is read one byte at a time. The Unix time is returned, that is, seconds from 1970-01-01T00:00.

Returns
: the current UNIX time, 0 on failure
void timeservicesLoop ( )

Perform periodic tasks managing timeservices. Call frequently as the system runs. Does not block.

bool timeservicesTimeIsValid ( )

Determine if time has a valid value. Time might be set manually or retrieved from the web.

Returns
true if time has been set

Variable Documentation

bool timeservicesReportRequired

Set this flag to trigger a time report. Safe to set in an ISR.

bool timeservicesTimeWasManuallySet

Set to true if time was set by a console command.

Set to true when time is set by a console command. This gets reset if the time is automatically set from the web.