LOGGER  Logger
Data Logging using ESP8266
Macros | Functions | Variables
timeservices.cpp File Reference
#include "timeservices.h"
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <Time.h>
#include "dataservices.h"
#include "security.h"
#include "webpages.h"
#include "webservices.h"

Macros

#define timeServicesEdit   2
 version of this module
 

Functions

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

Variables

const int timeZone = 0
 Time zone used by library functions.
 
EXTERNVAR bool timeservicesTimeWasManuallySet
 Set to true if time was set by a console command. More...
 
EXTERNVAR bool timeservicesReportRequired
 

Detailed Description

Time syncronization services

Function Documentation

EXTERNDEF 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
EXTERNDEF String timeservicesDumpTime ( time_t  t)

Convert a UNIX time to a string

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

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
EXTERNDEF void timeservicesLoop ( )

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

EXTERNDEF 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

EXTERNVAR bool timeservicesReportRequired

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

EXTERNVAR 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.