Skip to content

Commit 62088a4

Browse files
authored
Merge pull request #34 from aaronjamt/master
Potential fix for `gettimeofday` for Arduino
2 parents c6d562e + 1a7b7a3 commit 62088a4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/utils.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,36 @@ int add_iso8601_utc_datetime(char *buf, size_t size)
148148
return strftime(buf, size, "%Y-%m-%dT%H:%M:%SZ", &timeinfo);
149149
}
150150

151+
#elif defined(ARDUINO)
152+
153+
#ifndef _TIMEVAL_DEFINED
154+
struct timeval {
155+
long tv_sec; // seconds since epoch
156+
long tv_usec; // microseconds
157+
};
158+
#endif
159+
160+
#ifndef _TIMEZONE_DEFINED
161+
struct timezone {
162+
int tz_minuteswest; // minutes west of UTC
163+
int tz_dsttime; // daylight saving time flag
164+
};
165+
#endif
166+
167+
int gettimeofday(struct timeval * tp, struct timezone * tzp)
168+
{
169+
ARG_UNUSED(tzp);
170+
tp->tv_sec = micros() / 1000000;
171+
tp->tv_usec = micros() % 1000000;
172+
return 0;
173+
}
174+
175+
int add_iso8601_utc_datetime(char* buf, size_t size) {
176+
ARG_UNUSED(buf);
177+
ARG_UNUSED(size);
178+
return 0;
179+
}
180+
151181
#elif defined(__BARE_METAL__)
152182

153183
#ifndef _TIMEVAL_DEFINED

0 commit comments

Comments
 (0)