MCPcopy Create free account
hub / github.com/SmingHub/Sming / onClockUpdating

Function onClockUpdating

samples/MeteoControl/app/application.cpp:125–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123const int clockUpdateIntervalMs = 10 * 60 * 1000; // Update web clock every 10 minutes
124
125int onClockUpdating(HttpConnection& client, bool successful)
126{
127 auto& response = *client.getResponse();
128
129 if(!successful) {
130 Serial << _F("CLOCK UPDATE FAILED, ") << response.code << " " << toString(response.code) << endl;
131 lastClockUpdate = 0;
132 return -1;
133 }
134
135 // Extract date header from response
136 clockValue = response.headers.getServerDate();
137 if(clockValue.isNull()) {
138 clockValue = response.headers.getLastModifiedDate();
139 }
140 if(!clockValue.isNull()) {
141 clockValue.addMilliseconds(ActiveConfig.AddTZ * 1000 * 60 * 60);
142 }
143
144 return 0;
145}
146
147void refreshClockTime()
148{

Callers

nothing calls this directly

Calls 6

getResponseMethod · 0.80
getServerDateMethod · 0.80
getLastModifiedDateMethod · 0.80
addMillisecondsMethod · 0.80
toStringFunction · 0.50
isNullMethod · 0.45

Tested by

no test coverage detected