|
|
4 kuukautta sitten | |
|---|---|---|
| .. | ||
| main.lua | 4 kuukautta sitten | |
| readme.md | 4 kuukautta sitten | |
| rtc_app.lua | 4 kuukautta sitten | |
1、main.lua:主程序入口;
2、rtc_app.lua:无网络时初始化并每秒打印东八区本地时间与 UTC 时间;有网络时等待 NTP 授时后,同样每秒打印更新后的东八区本地时间与 UTC 时间;
1、第一种场景演示:无网络情况下,rtc时钟初始化并每秒打印东八区本地时间与 UTC 时间。
2、第二种场景演示:连接上wifi网络,等待 NTP 授时后每秒打印更新后的东八区本地时间与 UTC 时间。
1、Air8101核心板一块:
2、TYPE-C USB数据线一根 ,Air8101核心板和数据线的硬件接线方式为:
Air8101核心板通过TYPE-C USB口供电;(5V / 3.3V 供电 拨动开关 拨到 3.3V供电一端,功耗测试开关 拨到 OFF)
TYPE-C USB数据线直接插到开发板的TYPE-C USB座子,另外一端连接电脑USB口;
1、 Luatools下载调试工具
2、 固件版本:LuatOS-SoC_V1006__Air8101,固件地址,如有最新固件请用最新 8101固件下载
1、搭建好硬件环境
2、demo脚本代码rtc_app.lua中,按照自己的需求启用对应的task函数
4、Luatools烧录内核固件和修改后的demo脚本代码
5、烧录成功后,代码会自动运行,查看打印日志,如果正常运行,会打印ntp时间同步成功、本地时间以及RTC时间等信息,如下log显示:
选择运行rtc_task2()函数,打印日志如下:
[2025-11-12 16:08:30.682] luat:D(6111):ulwip:IP_READY 2 192.168.31.226
[2025-11-12 16:08:30.682] luat:U(6112):I/user.dnsproxy 开始监听
[2025-11-12 16:08:30.682] luat:D(6113):sntp:query ntp.aliyun.com
[2025-11-12 16:08:30.682] luat:D(6113):DNS:ntp.aliyun.com state 0 id 1 ipv6 0 use dns server0, try 0
[2025-11-12 16:08:30.682] luat:D(6113):net:adatper 2 dns server 192.168.31.1
[2025-11-12 16:08:30.682] luat:D(6113):net:dns udp sendto 192.168.31.1:53 from 192.168.31.226
[2025-11-12 16:08:30.682] luat:D(6115):wlan:event_module 2 event_id 0
[2025-11-12 16:08:30.748] luat:I(6145):DNS:dns all done ,now stop
[2025-11-12 16:08:30.748] luat:D(6146):net:connect 203.107.6.88:123 UDP
[2025-11-12 16:08:30.748] luat:D(6175):sntp:Unix timestamp: 1762934909
[2025-11-12 16:08:30.748] luat:U(6177):I/user.os.date() Wed Nov 12 16:08:29 2025
[2025-11-12 16:08:30.748] luat:U(6178):I/user.循环rtc时间 {"year":2025,"min":8,"hour":8,"mon":11,"sec":29,"day":12}
[2025-11-12 16:08:31.739] luat:U(7175):I/user.os.date() Wed Nov 12 16:08:29 2025
[2025-11-12 16:08:31.739] luat:U(7175):I/user.循环rtc时间 {"year":2025,"min":8,"hour":8,"mon":11,"sec":29,"day":12}
[2025-11-12 16:08:32.732] luat:U(8176):I/user.os.date() Wed Nov 12 16:08:31 2025
[2025-11-12 16:08:32.732] luat:U(8177):I/user.循环rtc时间 {"year":2025,"min":8,"hour":8,"mon":11,"sec":31,"day":12}
[2025-11-12 16:08:33.755] luat:U(9177):I/user.os.date() Wed Nov 12 16:08:32 2025
[2025-11-12 16:08:33.755] luat:U(9178):I/user.循环rtc时间 {"year":2025,"min":8,"hour":8,"mon":11,"sec":32,"day":12}
选择运行rtc_task1()函数,打印日志如下:
[2025-11-11 13:47:52.540][000000000.643] I/user.main rtc_demo 001.000.000
[2025-11-11 13:47:52.557][000000000.651] I/user.rtc.timezone() 32
[2025-11-11 13:47:52.575][000000000.652] I/user.rtc初始时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":53,"day":28}
[2025-11-11 13:47:52.615][000000000.652] I/user.rtc设置后的本地时间 Tue Oct 28 16:10:53 2025
[2025-11-11 13:47:52.644][000000000.653] I/user.os.date() Tue Oct 28 16:10:53 2025
[2025-11-11 13:47:52.667][000000000.653] I/user.循环rtc时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":53,"day":28}
[2025-11-11 13:47:53.318][000000001.654] I/user.os.date() Tue Oct 28 16:10:53 2025
[2025-11-11 13:47:53.335][000000001.655] I/user.循环rtc时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":53,"day":28}
[2025-11-11 13:47:53.577][000000002.655] I/user.os.date() Tue Oct 28 16:10:54 2025
[2025-11-11 13:47:53.586][000000002.656] I/user.循环rtc时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":54,"day":28}
[2025-11-11 13:47:54.577][000000003.656] I/user.os.date() Tue Oct 28 16:10:55 2025
[2025-11-11 13:47:54.618][000000003.657] I/user.循环rtc时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":55,"day":28}
[2025-11-11 13:47:55.581][000000004.657] I/user.os.date() Tue Oct 28 16:10:57 2025
[2025-11-11 13:47:55.597][000000004.658] I/user.循环rtc时间 {"year":2025,"min":10,"hour":8,"mon":10,"sec":57,"day":28}