Skip to content

Commit 0ca7314

Browse files
committed
Check if system time.h was overrided, if so make getTime() return 0
1 parent cfb5aee commit 0ca7314

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/WiFi.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#if defined(ARDUINO_ARCH_AVR) && (__AVR_LIBC_MAJOR__ < 2)
20+
#ifdef ARDUINO_ARCH_AVR
21+
#include <avr/version.h>
22+
#if (__AVR_LIBC_MAJOR__ < 2)
2123
#define WIFI_101_NO_TIME_H
2224
#endif
25+
#endif
2326

2427
#ifndef WIFI_101_NO_TIME_H
2528
#include <time.h>
2629
#endif
2730

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
35+
2836
#include "WiFi101.h"
2937

3038
extern "C" {
@@ -919,6 +927,7 @@ int WiFiClass::ping(IPAddress host, uint8_t ttl)
919927
uint32_t WiFiClass::getTime()
920928
{
921929
#ifdef WIFI_101_NO_TIME_H
930+
#warning "No system <time.h> header included, WiFi.getTime() will always return 0"
922931
return 0;
923932
#else
924933
tstrSystemTime systemTime;

0 commit comments

Comments
 (0)