Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
40d34dbd
Commit
40d34dbd
authored
Apr 20, 2021
by
Eric Duminil
Browse files
Only set time when NTP didn't run
parent
917d1df9
Pipeline
#2940
passed with stage
in 1 minute and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/util.cpp
View file @
40d34dbd
...
...
@@ -32,13 +32,14 @@ String macToID() {
namespace
ntp
{
WiFiUDP
ntpUDP
;
NTPClient
timeClient
(
ntpUDP
,
config
::
ntp_server
,
config
::
utc_offset_in_seconds
,
60000UL
);
bool
connected_at_least_once
=
false
;
void
initialize
()
{
timeClient
.
begin
();
}
void
update
()
{
timeClient
.
update
();
connected_at_least_once
|=
timeClient
.
update
();
}
void
getLocalTime
(
char
*
timestamp
)
{
...
...
@@ -50,6 +51,9 @@ namespace ntp {
timeClient
.
getFormattedDate
(
time
);
Serial
.
print
(
F
(
"Current time : "
));
Serial
.
println
(
time
);
if
(
connected_at_least_once
)
{
Serial
.
println
(
F
(
"NTP update already happened. Not changing anything."
));
}
Serial
.
print
(
F
(
"Setting UNIX time to : "
));
Serial
.
println
(
unix_seconds
);
timeClient
.
setEpochTime
(
unix_seconds
-
seconds
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment