ntptime - 网络时间同步
2025-09-05
该模块用于网络时间同步。
BC25PA平台电信卡开卡时需要说明SIM卡须支持此类业务,移动联通一般不限制(开卡时需要和运营商确认)。
获取ntp服务器 #
ntptime.host
#
返回值描述:
- 返回当前的ntp服务器,默认为"ntp.aliyun.com"。
设置ntp服务器 #
ntptime.sethost
#
参数描述:
-
host
- ntp服务器地址,字符串类型
返回值描述:
- 成功返回整型值0,失败返回整型值-1。
同步ntp时间 #
ntptime.settime
#
参数描述:
-
timezone
- int类型,可选参数,时区设置,默认为0, 范围 (-12~12)。(-数为西时区,正数为东时区) -
use_rhost
- int类型,可选参数,ntptime.host 对时失败时,是否使用备用服务器继续尝试对时,默认为1,使用备用服务器,设为0时,仅使用ntptime.host对时。 -
timeout
- int类型,可选参数,socket网络请求超时时间(单位为秒),默认为10,范围:>0。
返回值描述:
-
成功返回整型值
0
,失败返回整型值-1
。
示例: