-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathESP8266_NTP.ino
34 lines (29 loc) · 930 Bytes
/
ESP8266_NTP.ino
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
34
/*
* Project: DuinoCoinRig
* File: ESP8266_NTP
* Version: 0.1
* Purpose: Central NTP management
* Author: Frank Niggemann
*/
/***********************************************************************************************************************
* Code NTP
**********************************************************************************************************************/
/**
* Initializes the NTP part of the software
*/
void ntpSetup() {
logMessage("Ntp", "ntpSetup", "MethodName", "");
timeClient.begin();
}
/**
* Returns the current UNIX timestamp
*
* @return unsigned long The current UNIX timestamp
*/
unsigned long ntpGetTimestamp() {
logMessage("Ntp", "ntpGetTimestamp", "MethodName", "");
timeClient.update();
unsigned long timestamp = timeClient.getEpochTime();
logMessage("Ntp", "ntpGetTimestamp", "MethodDetail", "Return timestamp " + String(timestamp));
return timestamp;
}