OmEspHelpers
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
OmNtp Class Reference

#include <OmNtp.h>

Classes

class  OmNtpStats
 

Public Member Functions

void setWifiAvailable (bool wifiAvailable)
 
void tick (unsigned int deltaMillis)
 
void setTimeZone (int hourOffset)
 
int getTimeZone ()
 
void getLocalTime ()
 
void setTimeUrl (const char *timeUrl)
 
void setTimeUrlOffset (int hoursFromTimeUrl)
 
bool getTime (int &hourOut, int &minuteOut, int &secondOut)
 
bool getTime (int &hourOut, int &minuteOut, float &secondOut)
 
const char * getTimeString ()
 
bool getUTime (uint32_t &uTimeOut, int &uFracOut)
 
uint32_t getUTime ()
 

Static Public Member Functions

static OmNtpntp ()
 
static void sGetTimeOfDay (int &minuteWithinDayOut, float &secondWithinMinuteOut)
 Static methods to get the time, and return -1's if time does not exist in space.
 

Public Attributes

OmNtpStats stats
 
WiFiClient client
 

Detailed Description

class to keep a local clock synchronized from a server

Member Function Documentation

◆ getLocalTime()

void OmNtp::getLocalTime ( )

Issue a request to an http service, the url you set with setTimeUrl().

◆ getTime() [1/2]

bool OmNtp::getTime ( int &  hourOut,
int &  minuteOut,
float &  secondOut 
)

Get the time of day in two handy integers and a float.

◆ getTime() [2/2]

bool OmNtp::getTime ( int &  hourOut,
int &  minuteOut,
int &  secondOut 
)

Get the time of day in three handy integers.

◆ getTimeString()

const char * OmNtp::getTimeString ( )

Get the time of day in a handy string like HH:MM:SS.

(It's a static char[], by the way.)

◆ ntp()

OmNtp * OmNtp::ntp ( )
static

Get the last-created ntp instance, if any

◆ setTimeUrl()

void OmNtp::setTimeUrl ( const char *  timeUrl)

URL to a server under your control that gives the current time.

OmNtp will deduce the timezone relative to NTP from it, also.

Https not supported, just http.

◆ setTimeUrlOffset()

void OmNtp::setTimeUrlOffset ( int  hoursFromTimeUrl)

if the time is calculated from a TimeUrl, add this offset to it.

for example, I use a CA timeUrl for my lamps in Arkansas so I set

it to 2.

◆ setTimeZone()

void OmNtp::setTimeZone ( int  hourOffset)

This number gets added to UTC for your time zone. It ranges

from -12 to +12. California in December needs -8.

◆ setWifiAvailable()

void OmNtp::setWifiAvailable ( bool  wifiAvailable)

Call this after wifi properly established

◆ tick()

void OmNtp::tick ( unsigned int  deltaMillis)

Call this in your loop(). Assumes about 20-50 ms interval.

Member Data Documentation

◆ client

WiFiClient OmNtp::client

client is public field so you can use it for URL queries too.


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