sntp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __SNTP_H__
  2. #define __SNTP_H__
  3. #include "os_type.h"
  4. #ifdef LWIP_OPEN_SRC
  5. #include "lwip/ip_addr.h"
  6. #else
  7. #include "ip_addr.h"
  8. #endif
  9. /**
  10. * get the seconds since Jan 01, 1970, 00:00 (GMT + 8)
  11. */
  12. uint32 sntp_get_current_timestamp();
  13. /**
  14. * get real time (GTM + 8 time zone)
  15. */
  16. char* sntp_get_real_time(long t);
  17. /**
  18. * SNTP get time_zone default GMT + 8
  19. */
  20. sint8 sntp_get_timezone(void);
  21. /**
  22. * SNTP set time_zone (default GMT + 8)
  23. */
  24. bool sntp_set_timezone(sint8 timezone);
  25. /**
  26. * Initialize this module.
  27. * Send out request instantly or after SNTP_STARTUP_DELAY(_FUNC).
  28. */
  29. void sntp_init(void);
  30. /**
  31. * Stop this module.
  32. */
  33. void sntp_stop(void);
  34. /**
  35. * Initialize one of the NTP servers by IP address
  36. *
  37. * @param numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS
  38. * @param dnsserver IP address of the NTP server to set
  39. */
  40. void sntp_setserver(unsigned char idx, ip_addr_t *addr);
  41. /**
  42. * Obtain one of the currently configured by IP address (or DHCP) NTP servers
  43. *
  44. * @param numdns the index of the NTP server
  45. * @return IP address of the indexed NTP server or "ip_addr_any" if the NTP
  46. * server has not been configured by address (or at all).
  47. */
  48. ip_addr_t sntp_getserver(unsigned char idx);
  49. /**
  50. * Initialize one of the NTP servers by name
  51. *
  52. * @param numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS,now sdk support SNTP_MAX_SERVERS = 3
  53. * @param dnsserver DNS name of the NTP server to set, to be resolved at contact time
  54. */
  55. void sntp_setservername(unsigned char idx, char *server);
  56. /**
  57. * Obtain one of the currently configured by name NTP servers.
  58. *
  59. * @param numdns the index of the NTP server
  60. * @return IP address of the indexed NTP server or NULL if the NTP
  61. * server has not been configured by name (or at all)
  62. */
  63. char *sntp_getservername(unsigned char idx);
  64. #define sntp_servermode_dhcp(x)
  65. #endif