File tree Expand file tree Collapse file tree 5 files changed +22
-0
lines changed Expand file tree Collapse file tree 5 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -773,10 +773,14 @@ paths:
773773 x-stoplight :
774774 id : 7h1cpgfjj5j9j
775775 format : date-time
776+ uptime :
777+ type : integer
778+ description : EVSE gateway uptime, in seconds
776779 required :
777780 - time
778781 - offset
779782 - local_time
783+ - uptime
780784 operationId : get-time
781785 description : Gets the time set on the OpenEVSE
782786 post :
Original file line number Diff line number Diff line change @@ -175,3 +175,6 @@ properties:
175175 limit_version :
176176 type : integer
177177 description : /limit endpoint current version
178+ uptime :
179+ type : integer
180+ description : EVSE gateway uptime, in seconds
Original file line number Diff line number Diff line change @@ -173,4 +173,6 @@ extern String serial;
173173
174174void restart_system ();
175175
176+ uint64_t uptimeMillis ();
177+
176178#endif // _EMONESP_H
Original file line number Diff line number Diff line change 175175loop () {
176176 Profile_Start (loop);
177177
178+ uptimeMillis ();
179+
178180 Profile_Start (Mongoose);
179181 Mongoose.poll (0 );
180182 Profile_End (Mongoose, 10 );
@@ -340,3 +342,13 @@ void handle_serial()
340342 }
341343 }
342344}
345+
346+ // inspired from https://www.snad.cz/en/2018/12/21/uptime-and-esp8266/
347+ uint64_t uptimeMillis ()
348+ {
349+ static uint32_t low32, high32;
350+ uint32_t new_low32 = millis ();
351+ if (new_low32 < low32) high32++;
352+ low32 = new_low32;
353+ return (uint64_t ) high32 << 32 | low32;
354+ }
Original file line number Diff line number Diff line change @@ -278,4 +278,5 @@ void TimeManager::serialise(JsonDocument &doc)
278278 doc[" time" ] = time;
279279 doc[" local_time" ] = local_time;
280280 doc[" offset" ] = offset;
281+ doc[" uptime" ] = uptimeMillis () / 1000 ;
281282}
You can’t perform that action at this time.
0 commit comments