Skip to content

Commit

Permalink
发布core(0035)和script(2.2.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhutianhua committed Jun 13, 2020
1 parent 981af9c commit 8a9870e
Show file tree
Hide file tree
Showing 64 changed files with 575 additions and 204 deletions.
5 changes: 4 additions & 1 deletion core/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Luat_VXXXX_ASR1802:不支持浮点数和math库
Luat_VXXXX_ASR1802_FLOAT:支持浮点数和math库

用户二次开发有两个分区可用,脚本区和文件系统区
脚本区:通过Luatools烧写的所有文件,都存放在此区域,目前总空间为524KB,不同版本的core可能会有差异,以版本每次的更新记录为准
脚本区:通过Luatools烧写的所有文件,都存放在此区域
0032版本之前的脚本总空间为524KB
0032以及0032版本之后的脚本总空间为1MB

文件系统区:程序运行过程中实时创建的文件都会存放在此区域,目前总空间为800多KB,不同版本的core可能会有差异,可通过rtos.get_fs_free_size()查询剩余的文件系统可用空间


Expand Down
30 changes: 29 additions & 1 deletion core/release notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
版本号:Luat_V0029_ASR1802_XXX.lod
版本号:Luat_V0035_ASR1802_XXX.lod
发布时间:2020/06/12 11:59
修改记录:
(1)修正“socket连接服务器概率性无结果返回”的问题


版本号:Luat_V0033_ASR1802_XXX.lod
发布时间:2020/04/21 10:30
修改记录:
(1)修正“socket链接服务器失败”的问题
(2)支持rtos.get_temperature获取芯片温度功能


版本号:Luat_V0032_ASR1802_XXX.lod
发布时间:2020/04/21 10:30
修改记录:
(1)修正“错误域名解析时,导致Lua被阻塞30秒”的问题
(2)脚本区空间扩大为1M字节


版本号:Luat_V0031_ASR1802_XXX.lod
发布时间:2020/03/19 22:37
修改记录:
(1)优化“因为LTE协议版本低导致某些地方注册不上4G网络”的问题
(2)支持usb at口在data和at功能之间的切换功能



版本号:Luat_V0029_ASR1802_XXX.lod
发布时间:2020/01/19 11:02
修改记录:
(1)修正“aes des ecb 不填充加密可能导致死循环”重启的问题
Expand Down
27 changes: 27 additions & 0 deletions script_LuaTask/demo/crypto/private.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAx0+zurC2NFWgULkhQ4rEAvPeNnuxBz/0kbjbhrGNlD0gLccO
ZdQHihJqwRdX2IuDDhienfNX+9qIeQgkf3owzp082k93I2ky/QLwNDvN9loDJ0Zv
eIk0kwwz9yJZqD1FIiFabO+DkSVx+e+26yIKQjnS0i0D3IulzOGulSt56OuIl0/a
/fgFWQqfMWoLL4cyBQBEFuQth0fTACTsY6XAQ3e2kshD0cMT3U55hJmCCbxFuJ+Q
WOgtUuLt1SqlqZoYo/rYNQj5yBc3fd9HKXzLvmoKUMxFIW6Ez/ddubPx6F4B0eyz
V3oZ8Fp6I4WsMDDoUxJIYQ1Z4Yg6l9lkwqdAzwIDAQABAoIBAQCdMAiJBfDM2XLz
9u16/SeVRItN4MM++nuBqY7IbaNA8+w67jA2sr+3bsruueA4Ed8r8NK3s0ECidjz
yy4ts0pmyK9DZUSKkt75l6WlLD1FOrwd73jeUSc7iXY6Q8b93kR1pGRSYZsbj7KR
8TILwu7gSAYyZ/oRp7j9Gke7sWwV+rdgQAwlI/0Pkv7pCFEfSLe0pdG60mt80s6O
tgW0m/xlCp+X20zmObh9DivBsera2hPUAVDM95pPaQLC2gxq2TD4BdglizcENLqA
Mp9djr/hT0DfLzBu5DxDtki3bwN+pDlH9yabU328iJn6e5Lx5sPUOKG/XZKQAmlq
ZTqIJl6hAoGBAOm7Tgfb0dZLAbycjPLW5SWagc/IYqlUHLs2RIMiGYWEFdTWEPNg
PSFHL8B5TX8h4TwCpm4nXimxouAwgxNCrKblpaEtZ5RSZ+cw1Dzf/jBoRFgOa842
pmhWdZ2gIdnWcx1FNcig4csrnEtAg505zYPBpnVUJGFSdR+2woWVHRC3AoGBANpM
43YC6jtcNlxqNl3wCWH3k8ATAopGpuQSZ76VPCUHUwocjUoThbxtNwm4EY2xxjjc
41iqQFPGKcion3PeDwQ8o87fHkIgwx9DBcrMgB2CtWa+cFsICmVxOQTE/CSLFroh
oPtxLGWNWNewZAgFXhWm9uJ0SD812ML9TupJGoipAoGAQuxzqkJhsdcmNygoH3wy
fnLgCmuY/FzuIRinw1hnMFiim59zmQwMVNP6M0VIUEeWI0Wq+81f49ZOCZ06WrBz
mRIWO7ExgEGcKJFNo+SK9rdUIlZ2vcPeH+/pm2l3Z9VEfrQLc1fFbxQcm1tsk/8x
/jDbharDA+7FRIBi8DbC7L8CgYEAlxXL/6s4zeiePwvLoOw2sjUVb0Q459bKPuN2
JfNHcyFEmaT1LKWiU60LAJECpRy64jQOrRj3+IMX/CaoZRr1LauCe/T0DjR6lzJd
2eP7b3E9d2SqgnZoK5lXKzPihrA1BJGtxxim74oKSQ1tzhdY7IdoK4brUcREx39l
lMUPtjECgYAnoVCSO2DWOIKg8L35rghUr3/LpNPqqoK8QwIh/iOK4LDOPXQzNgc2
v3YzGQPKuk2cDXaRam+WtABFgZl2NTIGxct/AwQbu0LjGBsoQpJRcMjAIH46lEP+
XuGVYywF+LxuRKfJCcdO0RudQ1BiB5sWuTH9jfoHZHyMSJKZ/re6lg==
-----END RSA PRIVATE KEY-----
9 changes: 9 additions & 0 deletions script_LuaTask/demo/crypto/public.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx0+zurC2NFWgULkhQ4rE
AvPeNnuxBz/0kbjbhrGNlD0gLccOZdQHihJqwRdX2IuDDhienfNX+9qIeQgkf3ow
zp082k93I2ky/QLwNDvN9loDJ0ZveIk0kwwz9yJZqD1FIiFabO+DkSVx+e+26yIK
QjnS0i0D3IulzOGulSt56OuIl0/a/fgFWQqfMWoLL4cyBQBEFuQth0fTACTsY6XA
Q3e2kshD0cMT3U55hJmCCbxFuJ+QWOgtUuLt1SqlqZoYo/rYNQj5yBc3fd9HKXzL
vmoKUMxFIW6Ez/ddubPx6F4B0eyzV3oZ8Fp6I4WsMDDoUxJIYQ1Z4Yg6l9lkwqdA
zwIDAQAB
-----END PUBLIC KEY-----
36 changes: 35 additions & 1 deletion script_LuaTask/demo/crypto/testCrypto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,39 @@ local function aesTest()
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","NONE",encodeStr,"12345678901234567890123456789012","1234567890666666"))
end

--rsa算法测试
local function rsaTest()
--local plainStr = "1234567890asdfghjklzxcvbnm"
local plainStr = "firmId=10015&model=zw-sp300&sn=W01201910300000108&version=1.0.0"

--公钥加密(2048bit,这个bit与实际公钥的bit要保持一致)
local encryptStr = crypto.rsa_encrypt("PUBLIC_KEY",io.readFile("/lua/public.key"),2048,"PUBLIC_CRYPT",plainStr)
log.info("rsaTest.encrypt",encryptStr:toHex())
--私钥解密(2048bit,这个bit与实际私钥的bit要保持一致)
local decryptStr = crypto.rsa_decrypt("PRIVATE_KEY",io.readFile("/lua/private.key"),2048,"PRIVATE_CRYPT",encryptStr)
log.info("rsaTest.decrypt",decryptStr) --此处的decryptStr应该与plainStr相同


--私钥签名(2048bit,这个bit与实际私钥的bit要保持一致)
local signStr = crypto.rsa_sha256_sign("PRIVATE_KEY",io.readFile("/lua/private.key"),2048,"PRIVATE_CRYPT",plainStr)
log.info("rsaTest.signStr",signStr:toHex())
--公钥验签(2048bit,这个bit与实际公钥的bit要保持一致)
local verifyResult = crypto.rsa_sha256_verify("PUBLIC_KEY",io.readFile("/lua/public.key"),2048,"PUBLIC_CRYPT",signStr,plainStr)
log.info("rsaTest.verify",verifyResult)



--私钥解密某个客户的公钥加密密文
encryptStr = string.fromHex("af750a8c95f9d973a033686488197cffacb8c1b2b5a15ea8779a48a72a1cdb2f9c948fe5ce0ac231a16de16b5fb609f62ec81c7646c1f018e333860627b5d4853cfe77f71ea7e4573323905faf0a759d59729d2afb80e46ff1f1b715227b599a14f3b9feb676f1feb1c2acd97f4d494124237a720ca781a16a2b600c17e348a5fdd3c374384276147b93ce93cc5a005a0aaf1581cdb7d58bfa84b4e4d7263efc02bf7ad80b15937ce8b37ced4e1ef8899be5c2a7d338cb5c4784c6b8a1cb31e7ecd1ec48597a02050b1190a3e13f2253a35e8cbc094c0af28b968f05a7f946a7a8cf3f9da2013d53ee51ca74279f8f36662e093b37db83caef5b18b666d405d4")
decryptStr = crypto.rsa_decrypt("PRIVATE_KEY",io.readFile("/lua/private.key"),2048,"PRIVATE_CRYPT",encryptStr)
log.info("rsaTest.decrypt",decryptStr)

--公钥验签某个客户的私钥签名密文
signStr = string.fromHex("7251fd625c01ac41e277d11b5b795962ba42d89a645eb9fe2241b2d8a9b6b5b6ea70e23e6933ef1324495749abde0e31eaf4fefe6d09f9270c0510790bd6075595717522539b7b70b798bdc216dae3873389644d73b04ecaeb01b25831904955a891d2459334a3f9f1e4558f7f99906c35f94c377f7f95cf0d3e062d8eb513fd723ad8b3981027b09126fbeb72d5fe4554a32b9c270f8f46032ede59387769b1fb090f0b4be15aaac2744a666dfbde7c04e02979f1c1b4e4c0f23c6bb9f60941312850caf41442d68ad7c9e939b7305ac6712ad31427f1c1d7b4f68001df9ce03367bd35e401a420f526aee3c96c2caaccb9a8db09b30930172b4c2847725d05")
verifyResult = crypto.rsa_sha256_verify("PUBLIC_KEY",io.readFile("/lua/public.key"),2048,"PUBLIC_CRYPT",signStr,"firmId=10015&model=zw-sp300&sn=W01201910300000108&version=1.0.0")
log.info("rsaTest.verifyResult customer",verifyResult)
end

--- 算法测试入口
-- @return
local function cryptoTest()
Expand All @@ -336,7 +369,8 @@ local function cryptoTest()
hmacSha256Test()
-- xxtea 需要lod打开支持
-- xxteaTest()
--pcall(rsaTest)
print("test end")
end

sys.timerStart(cryptoTest,2000)
sys.timerStart(cryptoTest,6000)
3 changes: 2 additions & 1 deletion script_LuaTask/demo/gpio/gpioSingle/testGpioSingle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ getGpio54Fnc = pins.setup(pio.P1_22,gpio54IntFnc)
pmd.ldoset(x,pmd.VLDO6)
x=0时:关闭LDO
x=1时:LDO输出1.8V
x=2时:LDO输出2.5V
x=2时:LDO输出1.9V
x=3时:LDO输出2.5V
x=4时:LDO输出2.8V
x=5时:LDO输出2.9V
x=6时:LDO输出3.1V
x=7时:LDO输出3.3V
x=8时:LDO输出1.7V
]]

4 changes: 2 additions & 2 deletions script_LuaTask/demo/mqtt/sync/readme.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sendWaitRecv����������ʱ��������������������ݣ���Ҫ�ȵ��������ݳ�ʱ�����յ����ݲŻ����������ݷ��ͳ�ȥ
sendInterruptRecv����������ʱpublish��Ϣ�������ж����ݽ��յ������������������
sendWaitRecv��ʾ������Ӧ����Էḻ
sendInterruptRecv��ʾ������Ӧ����Լ
7 changes: 2 additions & 5 deletions script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttInMsg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ module(...,package.seeall)
function proc(mqttClient)
local result,data
while true do
result,data = mqttClient:receive(2000)
result,data = mqttClient:receive(60000,"APP_SOCKET_SEND_DATA")
--接收到数据
if result then
log.info("mqttInMsg.proc",data.topic,string.toHex(data.payload))

--TODO:根据需求自行处理data.payload

--如果mqttOutMsg中有等待发送的数据,则立即退出本循环
if mqttOutMsg.waitForSend() then return true end
else
break
end
end

return result or data=="timeout"
return result or data=="timeout" or data=="APP_SOCKET_SEND_DATA"
end
7 changes: 1 addition & 6 deletions script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttOutMsg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local msgQueue = {}

local function insertMsg(topic,payload,qos,user)
table.insert(msgQueue,{t=topic,p=payload,q=qos,user=user})
sys.publish("APP_SOCKET_SEND_DATA")
end

local function pubQos0TestCb(result)
Expand Down Expand Up @@ -53,12 +54,6 @@ function unInit()
end
end

--- MQTT客户端是否有数据等待发送
-- @return 有数据等待发送返回true,否则返回false
-- @usage mqttOutMsg.waitForSend()
function waitForSend()
return #msgQueue > 0
end

--- MQTT客户端数据发送处理
-- @param mqttClient,MQTT客户端对象
Expand Down
4 changes: 2 additions & 2 deletions script_LuaTask/demo/socket/sync/readme.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sendWaitRecv����������ʱ��������������������ݣ���Ҫ�ȵ��������ݳ�ʱ�����յ����ݲŻ����������ݷ��ͳ�ȥ
sendInterruptRecv����������ʱpublish��Ϣ�������ж����ݽ��յ������������������
sendWaitRecv��ʾ������Ӧ����Էḻ
sendInterruptRecv��ʾ������Ӧ����Լ
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ module(...,package.seeall)
function proc(socketClient)
local result,data
while true do
result,data = socketClient:recv(2000)
result,data = socketClient:recv(60000,"APP_SOCKET_SEND_DATA")
--接收到数据
if result then
log.info("socketInMsg.proc",data)

--TODO:根据需求自行处理data

--如果socketOutMsg中有等待发送的数据,则立即退出本循环
if socketOutMsg.waitForSend() then return true end
else
break
end
end

return result or data=="timeout"
return result or data=="timeout" or data=="APP_SOCKET_SEND_DATA"
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local msgQueue = {}

local function insertMsg(data,user)
table.insert(msgQueue,{data=data,user=user})
sys.publish("APP_SOCKET_SEND_DATA")
end

local function sndHeartCb(result)
Expand Down Expand Up @@ -53,12 +54,6 @@ function unInit()
end
end

--- socket客户端是否有数据等待发送
-- @return 有数据等待发送返回true,否则返回false
-- @usage socketOutMsg.waitForSend()
function waitForSend()
return #msgQueue > 0
end

--- socket客户端数据发送处理
-- @param socketClient,socket客户端对象
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ module(...,package.seeall)
function proc(socketClient)
local result,data
while true do
result,data = socketClient:recv(2000)
result,data = socketClient:recv(60000,"APP_SOCKET_SEND_DATA")
--接收到数据
if result then
log.info("socketInMsg.proc",data)

sys.publish("SOCKET_RECV_DATA",data)

--如果socketOutMsg中有等待发送的数据,则立即退出本循环
if socketOutMsg.waitForSend() then return true end
else
break
end
end

return result or data=="timeout"
return result or data=="timeout" or data=="APP_SOCKET_SEND_DATA"
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local msgQueue = {}

local function insertMsg(data,user)
table.insert(msgQueue,{data=data,user=user})
sys.publish("APP_SOCKET_SEND_DATA")
end


Expand All @@ -26,13 +27,6 @@ function unInit()
end
end

--- socket客户端是否有数据等待发送
-- @return 有数据等待发送返回true,否则返回false
-- @usage socketOutMsg.waitForSend()
function waitForSend()
return #msgQueue > 0
end

--- socket客户端数据发送处理
-- @param socketClient,socket客户端对象
-- @return 处理成功返回true,处理出错返回false
Expand Down
6 changes: 2 additions & 4 deletions script_LuaTask/demo/socketSsl/longConnection/socketInMsg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ module(...,package.seeall)
function proc(socketClient)
local result,data
while true do
result,data = socketClient:recv(2000)
result,data = socketClient:recv(60000,"APP_SOCKET_SEND_DATA")
--接收到数据
if result then
log.info("socketInMsg.proc",data)

--TODO:根据需求自行处理data

--如果socketOutMsg中有等待发送的数据,则立即退出本循环
if socketOutMsg.waitForSend() then return true end
else
break
end
end

return result or data=="timeout"
return result or data=="timeout" or data=="APP_SOCKET_SEND_DATA"
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local msgQuene = {}

local function insertMsg(data,user)
table.insert(msgQuene,{data=data,user=user})
sys.publish("APP_SOCKET_SEND_DATA")
end

local function sndGetCb(result)
Expand Down Expand Up @@ -42,13 +43,6 @@ function unInit()
end
end

--- socket客户端是否有数据等待发送
-- @return 有数据等待发送返回true,否则返回false
-- @usage socketOutMsg.waitForSend()
function waitForSend()
return #msgQuene > 0
end

--- socket客户端数据发送处理
-- @param socketClient,socket客户端对象
-- @return 处理成功返回true,处理出错返回false
Expand Down
52 changes: 52 additions & 0 deletions script_LuaTask/demo/softdog/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--必须在这个位置定义PROJECT和VERSION变量
--PROJECT:ascii string类型,可以随便定义,只要不使用,就行
--VERSION:ascii string类型,如果使用Luat物联云平台固件升级的功能,必须按照"X.X.X"定义,X表示1位数字;否则可随便定义
PROJECT = "LUAT_SOFT_DOG"
VERSION = "1.0.0"

--加载日志功能模块,并且设置日志输出等级
--如果关闭调用log模块接口输出的日志,等级设置为log.LOG_SILENT即可
require "log"
LOG_LEVEL = log.LOGLEVEL_TRACE
--[[
如果使用UART输出日志,打开这行注释的代码"--log.openTrace(true,1,115200)"即可,根据自己的需求修改此接口的参数
如果要彻底关闭脚本中的输出日志(包括调用log模块接口和Lua标准print接口输出的日志),执行log.openTrace(false,第二个参数跟调用openTrace接口打开日志的第二个参数相同),例如:
1、没有调用过sys.opntrace配置日志输出端口或者最后一次是调用log.openTrace(true,nil,921600)配置日志输出端口,此时要关闭输出日志,直接调用log.openTrace(false)即可
2、最后一次是调用log.openTrace(true,1,115200)配置日志输出端口,此时要关闭输出日志,直接调用log.openTrace(false,1)即可
]]
--log.openTrace(true,1,115200)

require "sys"

require "net"
--每1分钟查询一次GSM信号强度
--每1分钟查询一次基站信息
net.startQueryAll(60000, 60000)

--加载控制台调试功能模块(此处代码配置的是uart2,波特率115200)
--此功能模块不是必须的,根据项目需求决定是否加载
--使用时注意:控制台使用的uart不要和其他功能使用的uart冲突
--使用说明参考demo/console下的《console功能使用说明.docx》
--require "console"
--console.setup(2, 115200)

--加载网络指示灯和LTE指示灯功能模块
--根据自己的项目需求和硬件配置决定:1、是否加载此功能模块;2、配置指示灯引脚
--合宙官方出售的Air720开发板上的网络指示灯引脚为pio.P2_0,LTE指示灯引脚为pio.P2_1
require "netLed"
netLed.setup(true,pio.P2_0,pio.P2_1)
--网络指示灯功能模块中,默认配置了各种工作状态下指示灯的闪烁规律,参考netLed.lua中ledBlinkTime配置的默认值
--如果默认值满足不了需求,此处调用netLed.updateBlinkTime去配置闪烁时长
--LTE指示灯功能模块中,配置的是注册上4G网络,灯就常亮,其余任何状态灯都会熄灭

--加载错误日志管理功能模块【强烈建议打开此功能】
--如下2行代码,只是简单的演示如何使用errDump功能,详情参考errDump的api
require "errDump"
errDump.request("udp://ota.airm2m.com:9072")

--加载软狗功能测试模块
require "testSoftDog"

--启动系统框架
sys.init(0, 0)
sys.run()
Loading

0 comments on commit 8a9870e

Please sign in to comment.