This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC3235S:获取给定时区的 UTC 时间和本地时间

Guru**** 2390755 points
Other Parts Discussed in Thread: CC3235S

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1256082/cc3235s-getting-utc-time-and-local-time-of-given-time-zone

器件型号:CC3235S

您好!

我使用的是 CC3235S 模块。 在我的应用程序中、我希望获取 UTC 时间以及 给定时区的时间。 当前我使用以下代码获得 UTC 时间:

_i8 configOpt = SL_DEVICE_GENERAL_DATE_TIME;
SlDateTime_t dt;

sl_DeviceGet (SL_DEVICE_General、&configOpt、
sizeof (SlDateTime_t)、(unsigned char *)(&dt);

如何获取给定时区的时间? 我在 SDK 中引用了 local_time 示例、我可以找到像 ClockSync_setTimeZone ()和 ClockSync_get (&netTime)这样的 API。  

如果我使用   ClockSync_setTimeZone()设置时区 ,那么 ClockSync_get (&netTime)将返回设置时区的时间吗? 如果是、我是否仍能使用上面给出的现有代码获得 UTC 时间?

如果有任何其他解决方案来同时获取 UTC 时间和时区、请提出建议。

谢谢。
普拉德普

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    ClockSync (请参阅 source/ti/net/utils 下的实现)是一个在 MCU RTC 顶部工作的软件模块。 它使用 SNTP 来跟踪 UTC。 当使用这个模块时,只有 ClockSync_Get ()可以被用来读取时间(它不更新 RTC ,而是保留 UTC 的偏移量)。

    它也是处理时区问题的唯一模块。

    如果  使用 ClockSync、您还可以将其设置为更新 NWP 时钟(然后 NWP 将包含时区偏移)。

    sl_DeviceGet ()-从 NWP 读取时间。   

    因此、基本上由用户决定是使用 UTC、还是由自己处理时区、还是让 ClockSync 处理(然后、他需要在需要时转换回 UTC)。

    您 可以直接 SNTP 更新 NWP (请参阅 source/ti/net/sntp)以维持 UTC 时钟、然后可以 sl_DeviceGet 读取 UTC 和 ClockSync_Get ()以随时区读取。 NWP 只需要证书验证的日期、因此时区不会产生很大影响。