Skip to content

Commit feb22b4

Browse files
authored
Merge pull request #113 from sandeepmistry/avr-core-backwards-compat
Backwards compatibility for older AVR core versions
2 parents 274c701 + 0ca7314 commit feb22b4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/WiFi.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#ifdef ARDUINO_ARCH_AVR
21+
#include <avr/version.h>
22+
#if (__AVR_LIBC_MAJOR__ < 2)
23+
#define WIFI_101_NO_TIME_H
24+
#endif
25+
#endif
26+
27+
#ifndef WIFI_101_NO_TIME_H
2028
#include <time.h>
29+
#endif
30+
31+
#if !defined(_TIME_H_) && !defined(TIME_H)
32+
// another library overrided the time.h header
33+
#define WIFI_101_NO_TIME_H
34+
#endif
2135

2236
#include "WiFi101.h"
2337

@@ -912,6 +926,10 @@ int WiFiClass::ping(IPAddress host, uint8_t ttl)
912926

913927
uint32_t WiFiClass::getTime()
914928
{
929+
#ifdef WIFI_101_NO_TIME_H
930+
#warning "No system <time.h> header included, WiFi.getTime() will always return 0"
931+
return 0;
932+
#else
915933
tstrSystemTime systemTime;
916934

917935
_resolve = (uint32_t)&systemTime;
@@ -946,6 +964,7 @@ uint32_t WiFiClass::getTime()
946964
}
947965

948966
return t;
967+
#endif
949968
}
950969

951970
WiFiClass WiFi;

0 commit comments

Comments
 (0)