Skip to content

Commit ef7c4dc

Browse files
cfriedtMaureenHelm
authored andcommitted
net: lib: ocpp: use sys_clock_gettime() instead of gettimeofday()
Use the native zephyr sys_clock_gettime() call instead of the XSI gettimeofday(), since XSI is not required here and would normally require CONFIG_XSI_SINGLE_PROCESS to be selected. Signed-off-by: Chris Friedt <[email protected]>
1 parent e197c31 commit ef7c4dc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

subsys/net/lib/ocpp/ocpp.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66

77
#include "ocpp_i.h"
8-
#include <sys/time.h>
8+
9+
#include <time.h>
10+
11+
#include <zephyr/sys/clock.h>
912

1013
LOG_MODULE_REGISTER(ocpp, CONFIG_OCPP_LOG_LEVEL);
1114

@@ -68,11 +71,11 @@ int ocpp_find_pdu_from_literal(const char *msg)
6871

6972
void ocpp_get_utc_now(char utc[CISTR25])
7073
{
71-
struct timeval tv;
74+
struct timespec ts;
7275
struct tm htime = {0};
7376

74-
gettimeofday(&tv, NULL);
75-
gmtime_r(&tv.tv_sec, &htime);
77+
sys_clock_gettime(SYS_CLOCK_REALTIME, &ts);
78+
gmtime_r(&ts.tv_sec, &htime);
7679

7780
snprintk(utc, CISTR25, "%04hu-%02hu-%02huT%02hu:%02hu:%02huZ",
7881
htime.tm_year + 1900,

0 commit comments

Comments
 (0)