iot_sntp.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2021 Huawei Device Co., Ltd.
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #ifndef __IOT_SNTP_H
  16. #define __IOT_SNTP_H
  17. #include <time.h>
  18. /**
  19. * @brief Additional introduction for the key members in struct tm
  20. * struct timeval maybe defines as following
  21. * int tm_sec; seconds (0 - 60)
  22. * int tm_min; minutes (0 - 59)
  23. * int tm_hour; hours (0 - 23)
  24. * int tm_mday; day of month (1 - 31)
  25. * int tm_mon; month of year (0 - 11)
  26. * int tm_year; year - 1900
  27. * int tm_wday; day of week (Sunday = 0)
  28. * int tm_yday; day of year (0 - 365)
  29. * int tm_isdst; is summer time in effect?
  30. * char *tm_zone; abbreviation of timezone name
  31. * long tm_gmtoff; offset from UTC in seconds
  32. *
  33. */
  34. /**
  35. * @brief Get the ntp time from ntp server (local RTC TIME);Could only be used after the
  36. * Network is ok and the tcpip is initialized ok
  37. *
  38. * @param localTimeZone indicates the local timezone, and could be -11 to 11, 0 means the UTC+0,
  39. * positive means east while negative means west, 8 means UTC+8, like China
  40. * @param rtcTime is a pointer to storage the rtc time if the return value is 0, and must not
  41. * be NULL
  42. * @return Returns 0 success while -1 failed; The content in rtcTime Only be valid when returns 0
  43. *
  44. */
  45. int SntpGetRtcTime(int localTimeZone, struct tm *rtcTime);
  46. #endif /* __IOT_SNTP_H */