-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathntp.h
More file actions
33 lines (26 loc) · 691 Bytes
/
ntp.h
File metadata and controls
33 lines (26 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef NTP_H
#define NTP_H
#include<ctime>
#include<NTPClient.h>
#include<ArduinoIoTCloud.h>
class NTPHandler
{
public:
NTPHandler();
NTPHandler(long timeOffset);
unsigned long getEpochTime(); // return the epoch time
int getHour();
int getMinute();
int getSecond();
int getYear();
int getMonth();
int getDay();
long getTimeOffset();
void updateNTP(); // update epoch time with NTP server
private:
unsigned long epochTime;
long timeOffset;
struct tm timeInfo;
void updateTimeInfo(); // convert epoch time normal format
};
#endif