|
|
5 years ago | |
|---|---|---|
| .github | 5 years ago | |
| bsp | 5 years ago | |
| docs | 5 years ago | |
| lua | 5 years ago | |
| luat | 5 years ago | |
| mind | 5 years ago | |
| script | 5 years ago | |
| tools | 5 years ago | |
| .gitignore | 5 years ago | |
| .gitmodules | 5 years ago | |
| LICENSE | 6 years ago | |
| Makefile.inc | 5 years ago | |
| README.md | 5 years ago | |
| docs.md | 6 years ago | |
| logo.jpg | 6 years ago | |
| luatos.code-workspace | 5 years ago | |
| system.jpg | 6 years ago | |
| tool.lua | 6 years ago |

LuatOS是运行在嵌入式硬件的实时操作系统,只需要少量内存的flash空间就能运行,用户编写lua代码就可完成各种功能
Lua base RTOS, build for many embedded systems
QQ群: 1061642968
详细代码请查阅 script/app/playit/main.lua
local sys = require("sys")
sys.subscribe("WLAN_READY", function ()
print("!!! wlan ready event !!!")
-- 马上进行时间同步
socket.ntpSync()
end)
disp.init("ssd1306")
display_str("Booting ...")
-- 配网回调
sys.subscribe("WLAN_PW_RE", function(ssid, password)
if ssid then
log.info(TAG, "airkiss GOT", ssid, password)
local conf = {ssid=ssid,password=password}
json.encodeFile(conf, "/wlan.json")
else
log.info(TAG, "airkiss fail")
end
end)
-- 业务流程, 联网后定时发送温度数据到服务器
sys.taskInit(function()
while 1 do
if wlan.ready() then
sys.wait(1000)
local temp = (sensor.ds18b20(28) or "")
http.get("http://site0.cn/api/w60x/report/ds18b20?mac=" .. wlan.get_mac() .. "&temp=" .. tostring(temp), {}, function()
log.info("network", "http complete, sleep 5s", code, body)
sys.publish("HTTP_DONE")
end)
display_str("Temp: " .. temp .. " rssi:" .. tostring(wlan.rssi()))
sys.waitUntil("HTTP_DONE", 5000)
else
log.warn("main", "wlan is not ready yet")
sys.waitUntil("WLAN_READY", 30000)
end
end
end)
-- 主循环, 必须加
sys.run()