-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
674 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
|
||
_G.sys = require("sys") | ||
|
||
print('Go') | ||
-- print('Go') | ||
|
||
sys.timerStart(function() | ||
log.info("timer", "timeout once") | ||
end, 1000) | ||
-- sys.timerStart(function() | ||
-- log.info("timer", "timeout once") | ||
-- end, 1000) | ||
|
||
sys.timerLoopStart(function() | ||
log.info("timer", "3s repeat") | ||
end, 3000) | ||
-- sys.timerLoopStart(function() | ||
-- log.info("timer", "3s repeat") | ||
-- end, 3000) | ||
|
||
sys.taskInit(function() | ||
while 1 do | ||
sys.wait(1000) | ||
log.info("lua", rtos.meminfo()) | ||
log.info("sys", rtos.meminfo("sys")) | ||
end | ||
|
||
end) | ||
|
||
sys.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,53 @@ | ||
|
||
-- LuaTools需要PROJECT和VERSION这两个信息 | ||
PROJECT = "httpdemo" | ||
VERSION = "1.0.0" | ||
|
||
_G.sys = require("sys") | ||
require "sysplus" | ||
|
||
sys.taskInit(function() | ||
sys.wait(100) | ||
local code, headers, body = http.request("GET", "https://www.air32.cn").wait() | ||
log.info("http", code, json.encode(headers), body) | ||
sys.waitUntil("IP_READY") | ||
-- local code, headers, body = http.request("GET", "https://www.air32.cn").wait() | ||
-- log.info("http", code, json.encode(headers), body) | ||
local code, headers, body = http.request("POST", "http://ql.betterforyou.com.cn:9090/ck/app/appUpgrade/findMiniUpgrade?equId=QL10000001&equType=1").wait() | ||
log.info("http.get", code, headers, body) | ||
|
||
log.info("GoGoGo") | ||
sys.wait(1000) | ||
|
||
local code, headers, body = http.request("GET", "https://air32.cn").wait() | ||
log.info("http", code, json.encode(headers), body) | ||
local body = io.readFile("/luadb/wifi.json") | ||
local code, headers, body = http.request("POST", "http://wifi.air32.cn/wifi", nil, body).wait() | ||
log.info("http", code, json.encode(headers), #body) | ||
-- log.info("http", "body", #body) | ||
-- log.info("http", "body", body) | ||
|
||
socket.sslLog(5) | ||
local httpplus = require "httpplus" | ||
-- local code, resp = httpplus.request({url="https://vaviri-back-ph4lj.ondigitalocean.app/state"}) | ||
local code, resp = httpplus.request({ | ||
url="http://wifi.air32.cn/wifi", | ||
body=io.readFile("/luadb/wifi.json"), | ||
headers={"Content-Type", "application/json"}, | ||
method="POST"} | ||
) | ||
local body = resp.body:query() | ||
-- log.info("http", code, json.encode(resp.headers), #body) | ||
log.info("http", "body", #body) | ||
log.info("http", "body", body) | ||
log.info("http", "body", body:toHex()) | ||
|
||
-- body = io.readFile("/luadb/gzip") | ||
-- log.info("gzip", #body) | ||
-- -- log.info("http", miniz.uncompress(body:sub(11))) | ||
-- log.info("http", miniz.uncompress(body:sub(11), 0)) | ||
-- log.info("http", body:toHex()) | ||
|
||
-- local code, headers, body = http.request("GET", "http://quan.suning.com/getSysTime.do", {Accept="*/*", ["User-Agent"]="ABC"}, nil, {debug=true}) | ||
-- log.info("http", code, json.encode(headers), body) | ||
|
||
-- local code, resp = httpplus.request({url="http://quan.suning.com/getSysTime.do"}) | ||
-- log.info("http", code, resp.body:query()) | ||
end) | ||
|
||
sys.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"imei":"861551056435449","wifis":[{"mac":"6EB158564935","rssi":-46},{"mac":"6CB158A64935","rssi":-47},{"mac":"88C397CE0E89","rssi":-62},{"mac":"8EC397CE0E89","rssi":-63},{"mac":"A439B3D208A2","rssi":-68},{"mac":"AA39B3D208A2","rssi":-70},{"mac":"50D2F516AA9D","rssi":-76},{"mac":"8CDEF97FEB89","rssi":-78},{"mac":"345BBBF2D112","rssi":-78},{"mac":"6C06D6080B30","rssi":-82},{"mac":"92DEF97FEB89","rssi":-86},{"mac":"3446ECF3AEE1","rssi":-86},{"mac":"0C31DCC75D34","rssi":-86},{"mac":"3446ECD3AEDC","rssi":-87},{"mac":"1475905ABE04","rssi":-89},{"mac":"143CC39C61CC","rssi":-89},{"mac":"3095E361696D","rssi":-91},{"mac":"CC08FB75FE85","rssi":-91},{"mac":"3295E311696D","rssi":-92},{"mac":"A29D7E7E6223","rssi":-93}],"iccid":"89860323750207458090","unique_id":"3238363435061A4C4330","key":"freedemo"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
-- LuaTools需要PROJECT和VERSION这两个信息 | ||
PROJECT = "ftpdemo" | ||
VERSION = "1.0.0" | ||
|
||
--[[ | ||
本demo需要ftp库, 大部分能联网的设备都具有这个库 | ||
ftp也是内置库, 无需require | ||
]] | ||
|
||
-- sys库是标配 | ||
_G.sys = require("sys") | ||
--[[特别注意, 使用ftp库需要下列语句]] | ||
_G.sysplus = require("sysplus") | ||
|
||
sys.taskInit(function() | ||
----------------------------- | ||
-- 统一联网函数, 可自行删减 | ||
---------------------------- | ||
if wlan and wlan.connect then | ||
-- wifi 联网, ESP32系列均支持 | ||
local ssid = "luatos1234" | ||
local password = "12341234" | ||
log.info("wifi", ssid, password) | ||
-- TODO 改成esptouch配网 | ||
-- LED = gpio.setup(12, 0, gpio.PULLUP) | ||
wlan.init() | ||
wlan.setMode(wlan.STATION) | ||
wlan.connect(ssid, password, 1) | ||
local result, data = sys.waitUntil("IP_READY", 30000) | ||
log.info("wlan", "IP_READY", result, data) | ||
device_id = wlan.getMac() | ||
elseif rtos.bsp() == "AIR105" then | ||
-- w5500 以太网, 当前仅Air105支持 | ||
-- w5500.init(spi.SPI_2, 24000000, pin.PB03, pin.PC00, pin.PC03) | ||
w5500.init(spi.HSPI_0, 24000000, pin.PC14, pin.PC01, pin.PC00) | ||
log.info("auto mac", w5500.getMac():toHex()) | ||
w5500.config() --默认是DHCP模式 | ||
w5500.bind(socket.ETH0) | ||
-- LED = gpio.setup(62, 0, gpio.PULLUP) | ||
sys.wait(1000) | ||
-- TODO 获取mac地址作为device_id | ||
elseif mobile then | ||
-- Air780E/Air600E系列 | ||
--mobile.simid(2) | ||
-- LED = gpio.setup(27, 0, gpio.PULLUP) | ||
device_id = mobile.imei() | ||
sys.waitUntil("IP_READY", 30000) | ||
end | ||
|
||
-- -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件 | ||
-- if crypto.cipher_suites then | ||
-- log.info("cipher", "suites", json.encode(crypto.cipher_suites())) | ||
-- end | ||
while true do | ||
sys.wait(1000) | ||
log.info("ftp 启动") | ||
print(ftp.login(nil,"121.43.224.154",21,"ftp_user","3QujbiMG").wait()) | ||
|
||
print(ftp.command("NOOP").wait()) | ||
print(ftp.command("SYST").wait()) | ||
|
||
print(ftp.command("TYPE I").wait()) | ||
print(ftp.command("PWD").wait()) | ||
print(ftp.command("MKD QWER").wait()) | ||
print(ftp.command("CWD /QWER").wait()) | ||
|
||
print(ftp.command("CDUP").wait()) | ||
print(ftp.command("RMD QWER").wait()) | ||
|
||
print(ftp.command("LIST").wait()) | ||
|
||
-- io.writeFile("/1222.txt", "23noianfdiasfhnpqw39fhawe;fuibnnpw3fheaios;fna;osfhisao;fadsfl") | ||
-- print(ftp.push("/1222.txt","/12222.txt").wait()) | ||
|
||
print(ftp.pull("/122224.txt","/122224.txt").wait()) | ||
|
||
local f = io.open("/122224.txt", "r") | ||
if f then | ||
local data = f:read("*a") | ||
f:close() | ||
log.info("fs", "writed data", data) | ||
else | ||
log.info("fs", "open file for read failed") | ||
end | ||
|
||
print(ftp.command("DELE /12222.txt").wait()) | ||
print(ftp.push("/122224.txt","/12222.txt").wait()) | ||
print(ftp.close().wait()) | ||
log.info("meminfo", rtos.meminfo("sys")) | ||
sys.wait(15000) | ||
end | ||
|
||
|
||
end) | ||
|
||
|
||
-- 用户代码已结束--------------------------------------------- | ||
-- 结尾总是这一句 | ||
sys.run() | ||
-- sys.run()之后后面不要加任何语句!!!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
_G.sys = require("sys") | ||
|
||
PROJECT = "logtest" | ||
VERSION = "1.0.0" | ||
|
||
sys.taskInit(function() | ||
local tm = { | ||
year = 2023, | ||
month = 11, | ||
mon = 11, | ||
day = 22, | ||
hour = 15, | ||
min = 30, | ||
sec = 44 | ||
} | ||
local lla = { | ||
lat = "113.5", | ||
lng = "022.5" | ||
} | ||
log.info(">>", json.encode(os.date("!*t"))) | ||
local aid = libgnss.casic_aid(tm, lla) | ||
log.info("AID", aid:toHex()) | ||
-- BACE38000B010000000000605C400000000000803640000000000000000000000000D43A1341 | ||
-- 0000000000000000000000000000000000000000F108 00 23 FD 23 B1 E5 | ||
-- BACE38000B010000000000605C400000000000803640000000000000000000000000D43A1341 | ||
-- 0000000000000000000000000000000060FD0601F108 00 23 5D 21 B8 E6 | ||
-- BACE38000B010000000000605C400000000000803640000000000000000000000000D43A1341 | ||
-- 0000000000000000000000000000000000000000F108 00 23 FD 23 B1 E5 | ||
|
||
local str = "$GNRMC,000625.00,A,3557.35652,N,13854.27058,E,1.681,73.98,111223,,,A,V*32\r\n" | ||
-- libgnss.init() | ||
libgnss.parse(str) | ||
log.info("GNSS", libgnss.getIntLocation()) | ||
log.info("GNSS", 1.681 * 1852) | ||
log.info("GNSS", libgnss.getIntLocation(1)) | ||
log.info("GNSS", libgnss.getIntLocation(2)) | ||
log.info("GNSS", libgnss.getIntLocation(3)) | ||
end) | ||
|
||
sys.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
_G.sys = require("sys") | ||
|
||
sys.taskInit(function() | ||
sys.waitUntil("IP_READY") | ||
while 1 do | ||
socket.sntp() | ||
sys.waitUntil("NTP_UPDATE", 10000) | ||
local tm = socket.ntptm() | ||
log.info("tm数据", json.encode(tm)) | ||
log.info("时间戳", string.format("%u.%03d", tm.tsec, tm.tms)) | ||
sys.wait(5000) | ||
end | ||
end) | ||
|
||
sys.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
sys = require "sys" | ||
log.info("lvgl", lvgl.init()) | ||
|
||
local function event_handler(obj, event) | ||
log.info("event", event) | ||
end | ||
|
||
sys.taskInit(function() | ||
local sw1 = lvgl.switch_create(lvgl.scr_act(), nil); | ||
lvgl.obj_align(sw1, nil, lvgl.ALIGN_CENTER, 0, -50); | ||
lvgl.obj_set_event_cb(sw1, event_handler); | ||
|
||
while 1 do | ||
sys.wait(1000) | ||
lvgl.switch_on(sw1, lvgl.ANIM_ON) | ||
sys.wait(1000) | ||
lvgl.switch_off(sw1, lvgl.ANIM_OFF) | ||
end | ||
end) | ||
|
||
sys.run() | ||
|
Oops, something went wrong.