sntp.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef LWIP_SNTP_H
  2. #define LWIP_SNTP_H
  3. #include "lwip/opt.h"
  4. #include "lwip/ip_addr.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef long time_t;
  9. /** The maximum number of SNTP servers that can be set */
  10. #ifndef SNTP_MAX_SERVERS
  11. #define SNTP_MAX_SERVERS 3
  12. #endif
  13. /** Set this to 1 to implement the callback function called by dhcp when
  14. * NTP servers are received. */
  15. #ifndef SNTP_GET_SERVERS_FROM_DHCP
  16. #define SNTP_GET_SERVERS_FROM_DHCP 0//LWIP_DHCP_GET_NTP_SRV
  17. #endif
  18. /* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */
  19. #ifndef SNTP_SERVER_DNS
  20. #define SNTP_SERVER_DNS 1
  21. #endif
  22. bool sntp_get_timetype(void);
  23. void sntp_set_receive_time_size(void);
  24. /** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
  25. * #define SNTP_SERVER_ADDRESS "pool.ntp.org"
  26. */
  27. uint32 sntp_get_current_timestamp();
  28. char* sntp_get_real_time(long t);
  29. void sntp_init(void);
  30. void sntp_stop(void);
  31. sint8 sntp_get_timezone(void);
  32. bool sntp_set_timezone(sint8 timezone);
  33. void sntp_setserver(u8_t idx, ip_addr_t *addr);
  34. ip_addr_t sntp_getserver(u8_t idx);
  35. #if SNTP_SERVER_DNS
  36. void sntp_setservername(u8_t idx, char *server);
  37. char *sntp_getservername(u8_t idx);
  38. #endif /* SNTP_SERVER_DNS */
  39. #if SNTP_GET_SERVERS_FROM_DHCP
  40. void sntp_servermode_dhcp(int set_servers_from_dhcp);
  41. #else /* SNTP_GET_SERVERS_FROM_DHCP */
  42. #define sntp_servermode_dhcp(x)
  43. #endif /* SNTP_GET_SERVERS_FROM_DHCP */
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif /* LWIP_SNTP_H */