1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00
David J. Fiddes d7abafea2f Remove duplication and incompatible declarations in sntp.h (#6610)
This removes definitions relating to the built-in SNTP client that
are LwIP v1 specific. Instead of duplicating these pull in the
LwIP header that correspond to the required functions depending on
the version of the stack being used.

Without this fix calls to sntp_getserver() work but return invalid
data and can lead to stack exhaustion.

Update the NTP-TZ-DST example to use the Arduino sntp.h header
rather than duplicate the conditional checks to use the LwIP header.

Tests:
 - Build against a simple SNTP API demonstratin app and all
   LwIP configurations. Verify that the app runs for an extended
   period and that the expected results are obtained.
2019-10-06 15:25:34 -07:00

40 lines
624 B
C

#ifndef __SNTP_H__
#define __SNTP_H__
#include "os_type.h"
#include "lwip/init.h"
#include "lwip/ip_addr.h"
#if LWIP_VERSION_MAJOR == 1
#include "lwip/sntp.h"
#else
#include "lwip/apps/sntp.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* get the seconds since Jan 01, 1970, 00:00 (GMT + 8)
*/
uint32 sntp_get_current_timestamp();
/**
* get real time (GTM + 8 time zone)
*/
char* sntp_get_real_time(long t);
/**
* SNTP get time_zone default GMT + 8
*/
sint8 sntp_get_timezone(void);
/**
* SNTP set time_zone (default GMT + 8)
*/
bool sntp_set_timezone(sint8 timezone);
#ifdef __cplusplus
}
#endif
#endif