Skip to content

Commit ced5b74

Browse files
authored
NTP Timezone & Enable/Disable Setting (#80)
* quick and dirty WIP to investigate timezones, currently only building under esp8266 platform much of the status stuff has been stripped for now, to test the concepts * support set of common features across ESP32/ESP8266 WRT timezone and sntp return dates as ISO format strings * remove time library, and timelib fix which is no longer required * fix the icons * remove temporary changes to demo project
1 parent 59326c6 commit ced5b74

File tree

16 files changed

+621
-185
lines changed

16 files changed

+621
-185
lines changed

data/config/ntpSettings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2-
"server": "pool.ntp.org",
3-
"interval": 3600
2+
"enabled": true,
3+
"server": "time.google.com",
4+
"tz_label": "Europe/London",
5+
"tz_format": "GMT0BST,M3.5.0/1,M10.5.0"
46
}

interface/.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Change the IP address to that of your ESP device to enable local development of the UI.
22
# Remember to also enable CORS in platformio.ini before uploading the code to the device.
3-
REACT_APP_ENDPOINT_ROOT=http://192.168.0.20/rest/
3+
REACT_APP_ENDPOINT_ROOT=http://192.168.0.29/rest/

interface/src/constants/NTPStatus.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
import * as Highlight from '../constants/Highlight';
22

3-
export const NTP_TIME_NOT_SET = 0;
4-
export const NTP_TIME_NEEDS_SYNC = 1;
5-
export const NTP_TIME_SET = 2;
3+
export const NTP_INACTIVE = 0;
4+
export const NTP_ACTIVE = 1;
65

7-
export const isSynchronized = ntpStatus => ntpStatus && (ntpStatus.status === NTP_TIME_NEEDS_SYNC || ntpStatus.status === NTP_TIME_SET);
6+
export const isNtpActive = ntpStatus => ntpStatus && ntpStatus.status === NTP_ACTIVE;
87

98
export const ntpStatusHighlight = ntpStatus => {
10-
switch (ntpStatus.status){
11-
case NTP_TIME_SET:
9+
switch (ntpStatus.status) {
10+
case NTP_INACTIVE:
11+
return Highlight.IDLE;
12+
case NTP_ACTIVE:
1213
return Highlight.SUCCESS;
13-
case NTP_TIME_NEEDS_SYNC:
14-
return Highlight.WARN;
15-
case NTP_TIME_NOT_SET:
1614
default:
1715
return Highlight.ERROR;
1816
}
1917
}
2018

2119
export const ntpStatus = ntpStatus => {
22-
switch (ntpStatus.status){
23-
case NTP_TIME_SET:
24-
return "Synchronized";
25-
case NTP_TIME_NEEDS_SYNC:
26-
return "Synchronization required";
27-
case NTP_TIME_NOT_SET:
28-
return "Time not set"
20+
switch (ntpStatus.status) {
21+
case NTP_INACTIVE:
22+
return "Inactive";
23+
case NTP_ACTIVE:
24+
return "Active";
2925
default:
3026
return "Unknown";
3127
}

0 commit comments

Comments
 (0)