From ab9fd0232deac5252e998a6ec8da84f942fb4479 Mon Sep 17 00:00:00 2001 From: zhutianhua Date: Wed, 24 Jul 2019 15:05:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83core(V0035)=E5=92=8Cscript=5F?= =?UTF-8?q?LuaTask(V2.3.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/release notes.txt | 11 ++- script_LuaTask/demo/console/main.lua | 27 +++--- script_LuaTask/demo/uart/v3/demo.lua | 6 +- script_LuaTask/doc/lib/index.html | 2 +- script_LuaTask/doc/lib/modules/aLiPay.html | 2 +- script_LuaTask/doc/lib/modules/aLiYun.html | 95 ++++++++++++++++++- script_LuaTask/doc/lib/modules/aLiYunOta.html | 2 +- script_LuaTask/doc/lib/modules/agps.html | 2 +- script_LuaTask/doc/lib/modules/audio.html | 18 +++- script_LuaTask/doc/lib/modules/cc.html | 2 +- script_LuaTask/doc/lib/modules/clib.html | 2 +- script_LuaTask/doc/lib/modules/common.html | 2 +- script_LuaTask/doc/lib/modules/console.html | 2 +- script_LuaTask/doc/lib/modules/errDump.html | 2 +- script_LuaTask/doc/lib/modules/gizwits.html | 2 +- script_LuaTask/doc/lib/modules/gps.html | 2 +- script_LuaTask/doc/lib/modules/gpsv2.html | 32 ++++++- script_LuaTask/doc/lib/modules/http.html | 2 +- script_LuaTask/doc/lib/modules/httpv2.html | 2 +- script_LuaTask/doc/lib/modules/lbsLoc.html | 2 +- script_LuaTask/doc/lib/modules/led.html | 2 +- script_LuaTask/doc/lib/modules/link.html | 2 +- script_LuaTask/doc/lib/modules/log.html | 2 +- script_LuaTask/doc/lib/modules/misc.html | 2 +- script_LuaTask/doc/lib/modules/mqtt.html | 12 ++- script_LuaTask/doc/lib/modules/net.html | 2 +- script_LuaTask/doc/lib/modules/netLed.html | 2 +- script_LuaTask/doc/lib/modules/ntp.html | 2 +- script_LuaTask/doc/lib/modules/nvm.html | 2 +- script_LuaTask/doc/lib/modules/patch.html | 2 +- script_LuaTask/doc/lib/modules/pb.html | 2 +- script_LuaTask/doc/lib/modules/pins.html | 2 +- script_LuaTask/doc/lib/modules/pm.html | 2 +- script_LuaTask/doc/lib/modules/powerKey.html | 2 +- script_LuaTask/doc/lib/modules/record.html | 20 +++- script_LuaTask/doc/lib/modules/ril.html | 2 +- script_LuaTask/doc/lib/modules/scanCode.html | 2 +- script_LuaTask/doc/lib/modules/sim.html | 2 +- script_LuaTask/doc/lib/modules/sms.html | 2 +- script_LuaTask/doc/lib/modules/socket.html | 12 ++- script_LuaTask/doc/lib/modules/sys.html | 2 +- script_LuaTask/doc/lib/modules/uiWin.html | 2 +- script_LuaTask/doc/lib/modules/update.html | 2 +- script_LuaTask/doc/lib/modules/utils.html | 43 ++++++++- script_LuaTask/doc/lib/modules/wdt.html | 2 +- script_LuaTask/lib/aLiYun.lua | 42 +++++++- script_LuaTask/lib/aLiYunOta.lua | 4 + script_LuaTask/lib/audio.lua | 63 +++++++++--- script_LuaTask/lib/errDump.lua | 2 +- script_LuaTask/lib/gpsv2.lua | 53 +++++------ script_LuaTask/lib/httpv2.lua | 2 +- script_LuaTask/lib/mqtt.lua | 7 +- script_LuaTask/lib/record.lua | 39 +++++--- script_LuaTask/lib/socket.lua | 30 +++--- script_LuaTask/lib/sys.lua | 2 +- script_LuaTask/lib/utils.lua | 2 +- script_LuaTask/release notes.txt | 15 ++- 57 files changed, 455 insertions(+), 152 deletions(-) diff --git a/core/release notes.txt b/core/release notes.txt index 8e1302c..d9ac7b0 100644 --- a/core/release notes.txt +++ b/core/release notes.txt @@ -1,4 +1,13 @@ -版本号:Luat_V0034_8955_XXX.lod +版本号:Luat_V0035_8955_XXX.lod +发布时间:2019/07/24 14:15 +修改记录: + (1)修正“aes和des加密时,不填充方式加密错误”的问题 + (2)修正“aes和des加密时内存泄漏”的问题 + (3)新增pio.pin.setbounce接口,可设置中断防抖时间;在设置中断前调用有效,例如pio.pin.setbounce(10),表示中断防抖时间为10ms + + + +版本号:Luat_V0034_8955_XXX.lod 发布时间:2019/05/24 13:50 修改记录: (1)支持SHA256算法,使用说明参考crypto脚本的demo diff --git a/script_LuaTask/demo/console/main.lua b/script_LuaTask/demo/console/main.lua index fc20c39..abdcba1 100644 --- a/script_LuaTask/demo/console/main.lua +++ b/script_LuaTask/demo/console/main.lua @@ -32,12 +32,7 @@ console.setup(1, 115200) require "httpv2" require "pins" require "gpsv2" -pins.setup(pio.P0_28, 1) -local pwb = pins.setup(pio.P0_3, nil, pio.PULLDOWN) -sys.timerStart(function() - pwb(0) - rtos.poweroff() -end, 10000) +-- require "tm1637" --加载硬件看门狗功能模块 --根据自己的硬件配置决定:1、是否加载此功能模块;2、配置Luat模块复位单片机引脚和互相喂狗引脚 --合宙官方出售的Air201开发板上有硬件看门狗,所以使用官方Air201开发板时,必须加载此功能模块 @@ -51,16 +46,16 @@ wdt.setup(pio.P0_30, pio.P0_31) --require "netLed" --netLed.setup(true,pio.P1_1) --网络指示灯功能模块中,默认配置了各种工作状态下指示灯的闪烁规律,参考netLed.lua中ledBlinkTime配置的默认值 ---如果默认值满足不了需求,此处调用netLed.updateBlinkTime去配置闪烁时长 ---加载错误日志管理功能模块【强烈建议打开此功能】 ---如下2行代码,只是简单的演示如何使用errDump功能,详情参考errDump的api -require "errDump" -errDump.request("udp://ota.airm2m.com:9072") - ---加载远程升级功能模块【强烈建议打开此功能】 ---如下3行代码,只是简单的演示如何使用update功能,详情参考update的api以及demo/update ---PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K" ---require "update" +--如果默认值满足不了需求,此处调用netLed.updateBlinkTime去配置闪烁时长 +--加载错误日志管理功能模块【强烈建议打开此功能】 +--如下2行代码,只是简单的演示如何使用errDump功能,详情参考errDump的api +require "errDump" +errDump.request("udp://ota.airm2m.com:9072") + +--加载远程升级功能模块【强烈建议打开此功能】 +--如下3行代码,只是简单的演示如何使用update功能,详情参考update的api以及demo/update +--PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K" +--require "update" --update.request() --加载GPS功能测试模块 --启动系统框架 diff --git a/script_LuaTask/demo/uart/v3/demo.lua b/script_LuaTask/demo/uart/v3/demo.lua index 7da2ee3..7718585 100644 --- a/script_LuaTask/demo/uart/v3/demo.lua +++ b/script_LuaTask/demo/uart/v3/demo.lua @@ -13,12 +13,12 @@ module(..., package.seeall) -- 串口ID,串口读缓冲区 local UART_ID, sendQueue = 1, {} -- 串口超时,串口准备好后发布的消息 -local uartimeout, recvReady = 25, "UART_RECV_ID" +local uartimeout, recvReady = 500, "UART_RECV_ID" --保持系统处于唤醒状态,不会休眠 pm.wake("mcuart") uart.setup(UART_ID, 115200, 8, uart.PAR_NONE, uart.STOP_1) -uart.on(1, "receive", function(uid) - table.insert(sendQueue, uart.read(uid, 1460)) +uart.on(1, "receive", function(uid, length) + table.insert(sendQueue, uart.read(uid, length)) sys.timerStart(sys.publish, uartimeout, recvReady) end) diff --git a/script_LuaTask/doc/lib/index.html b/script_LuaTask/doc/lib/index.html index 23f868f..f663da7 100644 --- a/script_LuaTask/doc/lib/index.html +++ b/script_LuaTask/doc/lib/index.html @@ -253,7 +253,7 @@

Modules

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/aLiPay.html b/script_LuaTask/doc/lib/modules/aLiPay.html index 4de735a..9646a6e 100644 --- a/script_LuaTask/doc/lib/modules/aLiPay.html +++ b/script_LuaTask/doc/lib/modules/aLiPay.html @@ -506,7 +506,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/aLiYun.html b/script_LuaTask/doc/lib/modules/aLiYun.html index f33c964..4951b5e 100644 --- a/script_LuaTask/doc/lib/modules/aLiYun.html +++ b/script_LuaTask/doc/lib/modules/aLiYun.html @@ -102,6 +102,24 @@

Info:

Functions

+ + + + + + + + + + + + @@ -220,13 +220,25 @@

Usage:

- stop () + stop ([cbFnc=nil])
停止音频播放
+

Parameters:

+

Returns:

+ + + +
+ sleep () + 断开阿里云物联网套件的连接,并且不再重连
+ wakeup () + 重新打开阿里云物联网套件的连接
+ sleepStatus () + 查看打开阿里云物联网套件的是否允许连接状态
setup (productKey[, productSecret=nil], getDeviceNameFnc, getDeviceSecretFnc[, setDeviceSecretFnc=nil]) @@ -141,6 +159,81 @@

Functions

Functions

+
+ + + sleep () + +
+
+
断开阿里云物联网套件的连接,并且不再重连
+ + + +

Returns:

+
    +
  • +
    nil
    +
+ + + +

Usage:

+
    +
  • aLiYun.sleep()
    +
+ +
+
+ + + wakeup () + +
+
+
重新打开阿里云物联网套件的连接
+ + + +

Returns:

+
    +
  • +
    nil
    +
+ + + +

Usage:

+
    +
  • aLiYun.wakeup()
    +
+ +
+
+ + + sleepStatus () + +
+
+
查看打开阿里云物联网套件的是否允许连接状态
+ + + +

Returns:

+
    +
  • +
    bool 是否允许连接阿里云
    +
+ + + +

Usage:

+
    +
  • local ar = aLiYun.sleepStatus()
    +
+ +
@@ -375,7 +468,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/aLiYunOta.html b/script_LuaTask/doc/lib/modules/aLiYunOta.html index f90e6c0..5793da7 100644 --- a/script_LuaTask/doc/lib/modules/aLiYunOta.html +++ b/script_LuaTask/doc/lib/modules/aLiYunOta.html @@ -233,7 +233,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/agps.html b/script_LuaTask/doc/lib/modules/agps.html index 43ffacb..fc16316 100644 --- a/script_LuaTask/doc/lib/modules/agps.html +++ b/script_LuaTask/doc/lib/modules/agps.html @@ -114,7 +114,7 @@

Info:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/audio.html b/script_LuaTask/doc/lib/modules/audio.html index 8eba9d2..3d47241 100644 --- a/script_LuaTask/doc/lib/modules/audio.html +++ b/script_LuaTask/doc/lib/modules/audio.html @@ -111,7 +111,7 @@

Functions

- stop () + stop ([cbFnc=nil]) 停止音频播放
获取GPSGSV解析后的CNO数据
+ openLog (v) + 是否显示日志

@@ -299,7 +305,7 @@

Usage:

@@ -923,6 +929,28 @@

Usage:

+ +
+ + + openLog (v) + +
+
+
是否显示日志
+ + +

Parameters:

+ + + + + +
@@ -931,7 +959,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/http.html b/script_LuaTask/doc/lib/modules/http.html index 7c32f03..8b02acd 100644 --- a/script_LuaTask/doc/lib/modules/http.html +++ b/script_LuaTask/doc/lib/modules/http.html @@ -236,7 +236,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/httpv2.html b/script_LuaTask/doc/lib/modules/httpv2.html index a5b9062..37bf1f7 100644 --- a/script_LuaTask/doc/lib/modules/httpv2.html +++ b/script_LuaTask/doc/lib/modules/httpv2.html @@ -189,7 +189,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/lbsLoc.html b/script_LuaTask/doc/lib/modules/lbsLoc.html index 81b7a18..bed99ab 100644 --- a/script_LuaTask/doc/lib/modules/lbsLoc.html +++ b/script_LuaTask/doc/lib/modules/lbsLoc.html @@ -210,7 +210,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/led.html b/script_LuaTask/doc/lib/modules/led.html index e5fe69f..c859b6a 100644 --- a/script_LuaTask/doc/lib/modules/led.html +++ b/script_LuaTask/doc/lib/modules/led.html @@ -256,7 +256,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/link.html b/script_LuaTask/doc/lib/modules/link.html index 40e7410..c95e23f 100644 --- a/script_LuaTask/doc/lib/modules/link.html +++ b/script_LuaTask/doc/lib/modules/link.html @@ -104,7 +104,7 @@

Info:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/log.html b/script_LuaTask/doc/lib/modules/log.html index 2b41443..b6723ee 100644 --- a/script_LuaTask/doc/lib/modules/log.html +++ b/script_LuaTask/doc/lib/modules/log.html @@ -401,7 +401,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/misc.html b/script_LuaTask/doc/lib/modules/misc.html index 6bbe74e..0fde4fd 100644 --- a/script_LuaTask/doc/lib/modules/misc.html +++ b/script_LuaTask/doc/lib/modules/misc.html @@ -555,7 +555,7 @@

Returns:

generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
diff --git a/script_LuaTask/doc/lib/modules/mqtt.html b/script_LuaTask/doc/lib/modules/mqtt.html index 49004d6..d755627 100644 --- a/script_LuaTask/doc/lib/modules/mqtt.html +++ b/script_LuaTask/doc/lib/modules/mqtt.html @@ -107,7 +107,7 @@

Functions

- mqttc:connect (host, port[, transport="tcp"][, cert=nil]) + mqttc:connect (host, port[, transport="tcp"][, cert=nil], timeout) 连接mqtt服务器 @@ -218,7 +218,7 @@

Usage:

- mqttc:connect (host, port[, transport="tcp"][, cert=nil]) + mqttc:connect (host, port[, transport="tcp"][, cert=nil], timeout)
@@ -250,6 +250,10 @@

Parameters:

clientPassword = "123456", --客户端证书文件密码[可选] } +
  • timeout + number +
     链接服务器最长超时时间
    +
  • Returns:

    @@ -262,7 +266,7 @@

    Returns:

    Usage:

    @@ -460,7 +464,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/net.html b/script_LuaTask/doc/lib/modules/net.html index f66edd1..7f59a0c 100644 --- a/script_LuaTask/doc/lib/modules/net.html +++ b/script_LuaTask/doc/lib/modules/net.html @@ -619,7 +619,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/netLed.html b/script_LuaTask/doc/lib/modules/netLed.html index 1ef3823..4ef0f62 100644 --- a/script_LuaTask/doc/lib/modules/netLed.html +++ b/script_LuaTask/doc/lib/modules/netLed.html @@ -209,7 +209,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/ntp.html b/script_LuaTask/doc/lib/modules/ntp.html index 7aa58f2..3ec05f9 100644 --- a/script_LuaTask/doc/lib/modules/ntp.html +++ b/script_LuaTask/doc/lib/modules/ntp.html @@ -312,7 +312,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/nvm.html b/script_LuaTask/doc/lib/modules/nvm.html index 10e1d45..3068baf 100644 --- a/script_LuaTask/doc/lib/modules/nvm.html +++ b/script_LuaTask/doc/lib/modules/nvm.html @@ -426,7 +426,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/patch.html b/script_LuaTask/doc/lib/modules/patch.html index 5fdaf48..d37029c 100644 --- a/script_LuaTask/doc/lib/modules/patch.html +++ b/script_LuaTask/doc/lib/modules/patch.html @@ -104,7 +104,7 @@

    Info:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/pb.html b/script_LuaTask/doc/lib/modules/pb.html index 68abc1c..0991d53 100644 --- a/script_LuaTask/doc/lib/modules/pb.html +++ b/script_LuaTask/doc/lib/modules/pb.html @@ -289,7 +289,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/pins.html b/script_LuaTask/doc/lib/modules/pins.html index 2fbcfda..d9252e0 100644 --- a/script_LuaTask/doc/lib/modules/pins.html +++ b/script_LuaTask/doc/lib/modules/pins.html @@ -208,7 +208,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/pm.html b/script_LuaTask/doc/lib/modules/pm.html index 0310269..a47a10a 100644 --- a/script_LuaTask/doc/lib/modules/pm.html +++ b/script_LuaTask/doc/lib/modules/pm.html @@ -227,7 +227,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/powerKey.html b/script_LuaTask/doc/lib/modules/powerKey.html index e69ee03..40d1268 100644 --- a/script_LuaTask/doc/lib/modules/powerKey.html +++ b/script_LuaTask/doc/lib/modules/powerKey.html @@ -169,7 +169,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/record.html b/script_LuaTask/doc/lib/modules/record.html index 8070394..09dda08 100644 --- a/script_LuaTask/doc/lib/modules/record.html +++ b/script_LuaTask/doc/lib/modules/record.html @@ -107,7 +107,7 @@

    Functions

    - stop () + stop ([cbFnc=nil]) 停止录音 @@ -193,20 +193,32 @@

    Usage:

    - stop () + stop ([cbFnc=nil])
    停止录音
    +

    Parameters:

    +

    Usage:

    @@ -373,7 +385,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/ril.html b/script_LuaTask/doc/lib/modules/ril.html index f23f22e..455eded 100644 --- a/script_LuaTask/doc/lib/modules/ril.html +++ b/script_LuaTask/doc/lib/modules/ril.html @@ -285,7 +285,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/scanCode.html b/script_LuaTask/doc/lib/modules/scanCode.html index 13cf55f..e93602b 100644 --- a/script_LuaTask/doc/lib/modules/scanCode.html +++ b/script_LuaTask/doc/lib/modules/scanCode.html @@ -161,7 +161,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/sim.html b/script_LuaTask/doc/lib/modules/sim.html index db2077c..cf8c80c 100644 --- a/script_LuaTask/doc/lib/modules/sim.html +++ b/script_LuaTask/doc/lib/modules/sim.html @@ -306,7 +306,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/sms.html b/script_LuaTask/doc/lib/modules/sms.html index d9ebf0a..3ff2bd0 100644 --- a/script_LuaTask/doc/lib/modules/sms.html +++ b/script_LuaTask/doc/lib/modules/sms.html @@ -208,7 +208,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/socket.html b/script_LuaTask/doc/lib/modules/socket.html index a06d8de..6047d91 100644 --- a/script_LuaTask/doc/lib/modules/socket.html +++ b/script_LuaTask/doc/lib/modules/socket.html @@ -114,7 +114,7 @@

    Functions

    - mt:connect (address, port) + mt:connect (address, port, timeout) 连接服务器 @@ -266,7 +266,7 @@

    Usage:

    - mt:connect (address, port) + mt:connect (address, port, timeout)
    @@ -282,6 +282,10 @@

    Parameters:

  • port
     string或者number类型,服务器端口
  • +
  • timeout + number +
     链接服务器最长超时时间
    +
  • Returns:

    @@ -294,7 +298,7 @@

    Returns:

    Usage:

    @@ -645,7 +649,7 @@

    Fields

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/sys.html b/script_LuaTask/doc/lib/modules/sys.html index d14f9e5..38b822a 100644 --- a/script_LuaTask/doc/lib/modules/sys.html +++ b/script_LuaTask/doc/lib/modules/sys.html @@ -770,7 +770,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/uiWin.html b/script_LuaTask/doc/lib/modules/uiWin.html index 61817db..5c7cd2d 100644 --- a/script_LuaTask/doc/lib/modules/uiWin.html +++ b/script_LuaTask/doc/lib/modules/uiWin.html @@ -229,7 +229,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/update.html b/script_LuaTask/doc/lib/modules/update.html index e299c34..cbe84af 100644 --- a/script_LuaTask/doc/lib/modules/update.html +++ b/script_LuaTask/doc/lib/modules/update.html @@ -184,7 +184,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/utils.html b/script_LuaTask/doc/lib/modules/utils.html index a163eec..75b959c 100644 --- a/script_LuaTask/doc/lib/modules/utils.html +++ b/script_LuaTask/doc/lib/modules/utils.html @@ -112,6 +112,12 @@

    Functions

    将HEX字符串转成Lua字符串,如"313233616263"转为"123abc", 函数里加入了过滤分隔符,可以过滤掉大部分分隔符(可参见正则表达式中\s和\p的范围)。 + + string.toValue (str) + + 返回字符串tonumber的转义字符串(用来支持超过31位整数的转换) + + string.utf8Len (str) @@ -279,6 +285,41 @@

    Usage:

    string.fromHex("313233616263") -> "123abc" + +
    + + + string.toValue (str) + +
    +
    +
    返回字符串tonumber的转义字符串(用来支持超过31位整数的转换)
    + + +

    Parameters:

    + + +

    Returns:

    +
      +
    1. +
      str 转换后的lua 二进制字符串
    2. +
    3. +
      len 转换了多少个字符
    4. +
    + + + +

    Usage:

    + +
    @@ -757,7 +798,7 @@

    Returns:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/doc/lib/modules/wdt.html b/script_LuaTask/doc/lib/modules/wdt.html index d5faf8c..979d145 100644 --- a/script_LuaTask/doc/lib/modules/wdt.html +++ b/script_LuaTask/doc/lib/modules/wdt.html @@ -197,7 +197,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2019-05-24 14:23:11 +Last updated 2019-07-24 14:51:23
    diff --git a/script_LuaTask/lib/aLiYun.lua b/script_LuaTask/lib/aLiYun.lua index 7e74c72..9e4a91d 100644 --- a/script_LuaTask/lib/aLiYun.lua +++ b/script_LuaTask/lib/aLiYun.lua @@ -15,6 +15,7 @@ module(..., package.seeall) local sProductKey,sProductSecret,sGetDeviceNameFnc,sGetDeviceSecretFnc,sSetDeviceSecretFnc local sKeepAlive,sCleanSession,sWill local isSleep--休眠,不去重连服务器 +local sErrHandleCo,sErrHandleCb,sErrHandleTmout local outQueue = { @@ -43,9 +44,9 @@ local function procSubscribe(client) end local function procReceive(client) - local r,data + local r,data,s while true do - r,data = client:receive(2000) + r,data,s = client:receive(60000,"aliyun_publish_ind") --接收到数据 if r and data~="timeout" then log.info("aLiYun.procReceive",data.topic,string.toHex(data.payload)) @@ -61,6 +62,12 @@ local function procReceive(client) --如果有等待发送的数据,则立即退出本循环 if #outQueue["PUBLISH"]>0 then return true,"procReceive" end + elseif data == "aliyun_publish_ind" and s:find("disconnect") then--主动断开 + client:disconnect() + return false,"procReceive" + elseif data == "aliyun_publish_ind" and s:find("send") then--来数据要发了 + log.info("aliyun aliyun_publish_ind") + return true,"procReceive" else break end @@ -79,18 +86,30 @@ local function procSend(client) return true,"procSend" end ---不去进行重连操作 +--- 断开阿里云物联网套件的连接,并且不再重连 +-- @return nil +-- @usage +-- aLiYun.sleep() function sleep() isSleep = true log.info("aLiYun.sleep","open sleep, stop try reconnect") + sys.publish("aliyun_publish_ind","disconnect") end +--- 重新打开阿里云物联网套件的连接 +-- @return nil +-- @usage +-- aLiYun.wakeup() function wakeup() isSleep = false sys.publish("ALITUN_WAKEUP") log.info("aLiYun.wakeup","exit sleep") end +--- 查看打开阿里云物联网套件的是否允许连接状态 +-- @return bool 是否允许连接阿里云 +-- @usage +-- local ar = aLiYun.sleepStatus() function sleepStatus() return isSleep end @@ -126,6 +145,7 @@ function clientDataTask(host,tPorts,clientId,user,password) if not result then log.warn("aLiYun.clientDataTask."..prompt.." error") break end end if not result then break end + if sErrHandleCo then coroutine.resume(sErrHandleCo,"feed") end end else log.warn("aLiYun.clientDataTask."..prompt.." error") @@ -291,6 +311,8 @@ end -- aLiYun.publish("/b0FMK1Ga5cp/862991234567890/update","test",1,cbFnc,"cbFncPara") function publish(topic,payload,qos,cbFnc,cbPara) insert("PUBLISH",topic,qos,payload,cbFnc,cbPara) + sys.publish("aliyun_publish_ind","send") + log.info("aliyun aliyun_publish_ind","publish") end --- 注册事件的处理函数 @@ -308,3 +330,17 @@ end function on(evt,cbFnc) evtCb[evt] = cbFnc end + +function setErrHandle(cbFnc,tmout) + sErrHandleCb = cbFnc + sErrHandleTmout = tmout or 150 + if not sErrHandleCo then + sErrHandleCo = sys.taskInit(function() + while true do + if sys.wait(sErrHandleTmout*1000) == nil then + sErrHandleCb() + end + end + end) + end +end diff --git a/script_LuaTask/lib/aLiYunOta.lua b/script_LuaTask/lib/aLiYunOta.lua index ee9ee02..5116819 100644 --- a/script_LuaTask/lib/aLiYunOta.lua +++ b/script_LuaTask/lib/aLiYunOta.lua @@ -37,6 +37,10 @@ local function otaCb(result,filePath,md5,size) local calMD5 = crypto.md5(filePath,"file") result = (string.upper(calMD5) == string.upper(md5)) log.info("aLiYunOta.otaCb cmp md5",result,calMD5,md5) + end + if not result then + verRpt() + os.remove(filePath) end if gCb then gCb(result,filePath) diff --git a/script_LuaTask/lib/audio.lua b/script_LuaTask/lib/audio.lua index 1f802b6..7bbb9cd 100644 --- a/script_LuaTask/lib/audio.lua +++ b/script_LuaTask/lib/audio.lua @@ -13,6 +13,7 @@ require "utils" module(..., package.seeall) local req = ril.request +local stopCbFnc --音频播放的协程ID local taskID @@ -25,7 +26,7 @@ local taskID --sDup:当前播放的音频是否需要重复播放 --sDupInterval:如果sDup为true,此值表示重复播放的间隔(单位毫秒),默认无间隔 --sStrategy:优先级相同时的播放策略,0(表示继续播放正在播放的音频,忽略请求播放的新音频),1(表示停止正在播放的音频,播放请求播放的新音频) -local sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval,sStrategy +local sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval,sStrategy,sStopingType local function update(priority,type,path,vol,cb,dup,dupInterval) print("audio.update",sPriority,priority,type,path,vol,cb,dup,dupInterval) @@ -35,6 +36,7 @@ local function update(priority,type,path,vol,cb,dup,dupInterval) --此处第三个参数传入table是因为publish接口无法处理nil后面的参数 sys.publish("AUDIO_PLAY_END","NEW",{pri=priority,typ=type,pth=path,vl=vol,c=cb,dp=dup,dpIntval=dupInterval}) else + log.error("audio.update","priority error") return false end else @@ -47,7 +49,7 @@ end local function playEnd(result) log.info("audio.playEnd",result,sCb) local cb = sCb - sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval = nil + sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval,sStopingType = nil if cb then cb(result) end end @@ -63,9 +65,16 @@ local function taskAudio() if isTtsApi() then audiocore.openTTS() local _,result = sys.waitUntil("TTS_OPEN_IND") - if not result then return false end - - audiocore.playTTS(common.utf8ToUcs2(text)) + if result then + audiocore.playTTS(common.utf8ToUcs2(text)) + else + audiocore.stopTTS() + sys.waitUntil("TTS_STOP_IND") + audiocore.closeTTS() + sys.waitUntil("TTS_CLOSE_IND") + _,result = sys.waitUntil("TTS_OPEN_IND") + if not result then return false end + end else req("AT+QTTS=1") req(string.format("AT+QTTS=%d,\"%s\"",2,string.toHex(common.utf8ToUcs2(text)))) end @@ -117,7 +126,7 @@ local function taskAudio() if sType==nil then break end end else - stopFnc[sType](sPath) + stopFnc[sType or sStopingType](sPath) playEnd(0) if sType==nil then break end end @@ -232,7 +241,10 @@ end -- @usage audio.play(0,"FILE","/ldata/call.mp3",7,cbFnc) -- @usage 更多用法参考demo/audio/testAudio.lua function play(priority,type,path,vol,cbFnc,dup,dupInterval) - if not update(priority,type,path,vol or 4,cbFnc,dup,dupInterval or 0) then return false end + if not update(priority,type,path,vol or 4,cbFnc,dup,dupInterval or 0) then + log.error("audio.play","sync error") + return false + end if not sType or not taskID or coroutine.status(taskID)=="dead" then taskID = sys.taskInit(taskAudio) end @@ -240,20 +252,49 @@ function play(priority,type,path,vol,cbFnc,dup,dupInterval) end --- 停止音频播放 +-- @function[opt=nil] cbFnc,停止音频播放的回调函数(停止结果通过此函数通知用户),回调函数的调用形式为: +-- cbFnc(result) +-- result:number类型 +-- 0表示停止成功 +-- 1表示之前已经发送了停止动作,请耐心等待停止结果的回调 -- @return nil -- @usage audio.stop() -function stop() +function stop(cbFnc) + log.info("audio.stop",sType,cbFnc) + if stopCbFnc and cbFnc then cbFnc(1) return end if sType then if sType=="FILE" then audiocore.stop() elseif (sType=="TTS" and not isTtsApi()) or sType=="TTSCC" then req("AT+QTTS=3") + elseif sType=="TTS" and isTtsApi() then + sStopingType = "TTS" elseif sType=="RECORD" then f,d=record.getSize() req("AT+AUDREC=1,0,3," .. sPath .. "," .. d*1000) + --audiocore.stop() + if cbFnc then + stopCbFnc = cbFnc + function recordPlayInd() + --sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval = nil + sys.publish("AUDIO_PLAY_END","STOP","RECORD") + if stopCbFnc then stopCbFnc(0) stopCbFnc=nil end + sys.unsubscribe("LIB_RECORD_PLAY_END_IND",recordPlayInd) + end + sys.subscribe("LIB_RECORD_PLAY_END_IND",recordPlayInd) + else + local typ = sType + sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval = nil + sys.publish("AUDIO_PLAY_END","STOP",typ) + end + end + if sType~="RECORD" then + local typ = sType + sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval = nil + sys.publish("AUDIO_PLAY_END","STOP",typ) + if cbFnc then cbFnc(0) end end - local typ = sType - sPriority,sType,sPath,sVol,sCb,sDup,sDupInterval = nil - sys.publish("AUDIO_PLAY_END","STOP",typ) + else + if cbFnc then cbFnc(0) end end end diff --git a/script_LuaTask/lib/errDump.lua b/script_LuaTask/lib/errDump.lua index ccf2268..10d5fb7 100644 --- a/script_LuaTask/lib/errDump.lua +++ b/script_LuaTask/lib/errDump.lua @@ -176,7 +176,7 @@ function setNetworkLog(flag) updateNetworkLog() end end) - procer("NET_STATE_REGISTER",function() onceGsmRegistered=true end) + procer("NET_STATE_REGISTERED",function() onceGsmRegistered=true end) procer("GPRS_ATTACH",function(value) if value then onceGprsAttached = true diff --git a/script_LuaTask/lib/gpsv2.lua b/script_LuaTask/lib/gpsv2.lua index b6b576a..7810af0 100644 --- a/script_LuaTask/lib/gpsv2.lua +++ b/script_LuaTask/lib/gpsv2.lua @@ -44,23 +44,21 @@ local gpgsvTab, bdgsvTab = {}, {} local gsvCnoTab = {} -- 基站定位坐标 local lbs_lat, lbs_lng - +-- 日志开关 +local isLog = true --解析GPS模块返回的信息 local function parseNmea(s) if not s or s == "" then return end - log.warn("定位模块上报的信息:", s) + if isLog then log.warn("定位模块上报的信息:", s) end local lat, lng, spd, cog, gpsFind, gpsTime, gpsDate, locSateCnt, hdp, latTyp, lngTyp, altd if s:match("GGA") then lat, latTyp, lng, lngTyp, gpsFind, locSateCnt, hdp, altd, sep = s:match("GGA,%d+%.%d+,(%d+%.%d+),([NS]),(%d+%.%d+),([EW]),(%d),(%d+),([%d%.]*),(.*),M,(.*),M") if (gpsFind == "1" or gpsFind == "2" or gpsFind == "4") and altd then - -- fixFlag = true altitude = altd usedSateCnt = locSateCnt - Ggalng, Ggalat = (lngTyp == "W" and "-" or "") .. lng, (latTyp == "S" and "-" or "") .. lat Sep = sep - else - -- fixFlag = false - end + end + Ggalng, Ggalat = (lngTyp == "W" and "-" or "") .. lng, (latTyp == "S" and "-" or "") .. lat latitudeType, longitudeType, latitude, longitude = latTyp, lngTyp, lat, lng elseif s:match("GSA") then local satesn = s:match("GSA,%w*,%d*,(%d*,%d*,%d*,%d*,%d*,%d*,%d*,%d*,%d*,%d*,%d*,%d*,)") or "" @@ -117,7 +115,9 @@ local function parseNmea(s) latitudeType, longitudeType, latitude, longitude = latTyp, lngTyp, lat, lng if gpsFind == "A" and gpsTime and gpsDate and gpsTime ~= "" and gpsDate ~= "" then local yy, mm, dd, h, m, s = tonumber(gpsDate:sub(5, 6)), tonumber(gpsDate:sub(3, 4)), tonumber(gpsDate:sub(1, 2)), tonumber(gpsTime:sub(1, 2)), tonumber(gpsTime:sub(3, 4)), tonumber(gpsTime:sub(5, 6)) - UtcTime = {year = 2000 + yy, month = mm, day = dd, hour = h, min = m, sec = s} + UtcTime = os.date("*t", os.time({year = 2000 + yy, month = mm, day = dd, hour = h, min = m, sec = s}) + 28800) + misc.setClock(UtcTime) + sys.publish("GPS_TIMING_SUCCEED") end elseif s:match("VTG") then kmHour = s:match("VTG,%d*%.*%d*,%w*,%d*%.*%d*,%w*,%d*%.*%d*,%w*,(%d*%.*%d*)") @@ -213,22 +213,23 @@ end --- 打开GPS模块 -- @number id,UART ID,支持1和2,1表示UART1,2表示UART2 -- @number baudrate,波特率,支持1200,2400,4800,9600,10400,14400,19200,28800,38400,57600,76800,115200,230400,460800,576000,921600,1152000,4000000 --- @nunber mode,功耗模式0正常功耗,2周期唤醒,8跟踪模式 +-- @nunber mode,功耗模式0正常功耗,2周期唤醒 -- @number sleepTm,间隔唤醒的时间 秒 -- @param fnc,外部模块使用的电源管理函数 -- @return 无 -- @usage gpsv2.open() -- @usage gpsv2.open(2, 115200, 0, 1) -- 打开GPS,串口2,波特率115200,正常功耗模式,1秒1个点 --- @usage gpsv2.open(2, 115200, 2, 1, 5) -- 打开GPS,串口2,波特率115200,周期低功耗模式1秒输出,5秒睡眠 +-- @usage gpsv2.open(2, 115200, 2, 5) -- 打开GPS,串口2,波特率115200,周期低功耗模式1秒输出,5秒睡眠 function open(id, baudrate, mode, sleepTm, fnc) - sleepTm = tonumber(sleepTm) and sleepTm * 1000 or 5000 - pm.wake("gpsv2.lua") uartID, uartBaudrate = tonumber(id) or uartID, tonumber(baudrate) or uartBaudrate - log.info("GPS-UARTR-ID and buad:", id, baudrate, uartID, uartBaudrate) + mode, sleepTm = tonumber(mode) or 0, tonumber(sleepTm) and sleepTm * 1000 or 1000 + pm.wake("gpsv2.lua") + uart.close(uartID) uart.setup(uartID, uartBaudrate, 8, uart.PAR_NONE, uart.STOP_1) if fnc and type(fnc) == "function" then fnc() else + pmd.ldoset(7, pmd.LDO_VIB) pmd.ldoset(7, pmd.LDO_VCAM) rtos.sys32k_clk_out(1) end @@ -236,7 +237,6 @@ function open(id, baudrate, mode, sleepTm, fnc) local fullPowerMode = false local wakeFlag = false ---------------------------------- 初始化GPS任务-------------------------------------------- - pmd.ldoset(7, pmd.LDO_VIB) -- 获取基站定位坐标 lbsLoc.request(getlbs, nil, timeout) --连接服务器下载星历 @@ -306,18 +306,6 @@ function open(id, baudrate, mode, sleepTm, fnc) end parseNmea(read()) end - -- if fixFlag and fullPowerMode then - -- setRunMode(mode, 1000, sleepTm) - -- fullPowerMode = false - -- sys.timerStopAll(restart) - -- elseif not fixFlag and not fullPowerMode then - -- sys.timerStart(restart, 300 * 1000, 2) - -- while openFlag do - -- setRunMode(0) - -- if read():match("PGKC001,105,(3)") then break end - -- end - -- fullPowerMode = true - -- end end sys.publish("GPS_CLOSE_MSG") log.info("GPS 任务结束退出!") @@ -335,6 +323,7 @@ function close(id, fnc) if fnc and type(fnc) == "function" then fnc() else + pmd.ldoset(0, pmd.LDO_VIB) pmd.ldoset(0, pmd.LDO_VCAM) rtos.sys32k_clk_out(0) end @@ -451,16 +440,15 @@ end -- @usage gpsv2.getLocation() function getDegLocation() local lng, lat = getIntLocation() - lng, lat = string.format("%d.%07d", lng / 10 ^ 7, lng % 10 ^ 7), string.format("%d.%07d", lat / 10 ^ 7, lat % 10 ^ 7) - lng = float and tonumber(lng) or lng - lat = float and tonumber(lat) or lat - return lng, lat + if float then return lng / 10 ^ 7, lat / 10 ^ 7 end + return string.format("%d.%07d", lng / 10 ^ 7, lng % 10 ^ 7), string.format("%d.%07d", lat / 10 ^ 7, lat % 10 ^ 7) end --- 获取度分格式的经纬度信息ddmm.mmmm -- @return string,string,返回度格式的字符串经度,维度,符号(正东负西,正北负南) -- @usage gpsv2.getCentLocation() function getCentLocation() + if float then return tonumber(Ggalng or 0), tonumber(Ggalat or 0) end return Ggalng or 0, Ggalat or 0 end @@ -548,3 +536,8 @@ end function getCno() return gsvCnoTab end + +--- 是否显示日志 +function openLog(v) + isLog = v == nil and true or v +end diff --git a/script_LuaTask/lib/httpv2.lua b/script_LuaTask/lib/httpv2.lua index 2ff3118..15c4efa 100644 --- a/script_LuaTask/lib/httpv2.lua +++ b/script_LuaTask/lib/httpv2.lua @@ -57,7 +57,7 @@ function request(method, url, timeout, params, data, ctype, basic, headers, cert ["Keep-Alive"] = 'timeout=20', } end - ssl = string.find(rtos.get_version(), 'SSL') + ssl = string.find(rtos.get_version(), 'SSL') or string.find(rtos.get_version(), '8955F') -- 处理url的协议头和鉴权 _, offset, https = url:find("^(%a+)://") _, idx, auth = url:find("(.-:.-)@", (offset or 0) + 1) diff --git a/script_LuaTask/lib/mqtt.lua b/script_LuaTask/lib/mqtt.lua index bf970f3..5911ddc 100644 --- a/script_LuaTask/lib/mqtt.lua +++ b/script_LuaTask/lib/mqtt.lua @@ -297,9 +297,10 @@ end -- clientKey = "client.key", --客户端私钥文件(Base64编码 X.509格式) -- clientPassword = "123456", --客户端证书文件密码[可选] -- } +-- @number timeout, 链接服务器最长超时时间 -- @return result true表示成功,false或者nil表示失败 --- @usage mqttc = mqtt.client("clientid-123", nil, nil, false); mqttc:connect("mqttserver.com", 1883, "tcp") -function mqttc:connect(host, port, transport, cert) +-- @usage mqttc = mqtt.client("clientid-123", nil, nil, false); mqttc:connect("mqttserver.com", 1883, "tcp", 5) +function mqttc:connect(host, port, transport, cert, timeout) if self.connected then log.info("mqtt.client:connect", "has connected") return false @@ -317,7 +318,7 @@ function mqttc:connect(host, port, transport, cert) self.io = socket.tcp(transport == "tcp_ssl" or type(cert) == "table", cert) - if not self.io:connect(host, port) then + if not self.io:connect(host, port, timeout) then log.info("mqtt.client:connect", "connect host fail") return false end diff --git a/script_LuaTask/lib/record.lua b/script_LuaTask/lib/record.lua index ae51895..6f7497b 100644 --- a/script_LuaTask/lib/record.lua +++ b/script_LuaTask/lib/record.lua @@ -15,6 +15,7 @@ local stoping local duration local recordCallback --local flag_s=false +local stopCbFnc --- 开始录音 -- @param seconds 录音时长,单位:秒 @@ -36,9 +37,22 @@ function start(seconds, cb) end --- 停止录音 --- @usage record.stop() -function stop() - if not recording or stoping then return end +-- @function[opt=nil] cbFnc,停止录音的回调函数(停止结果通过此函数通知用户),回调函数的调用形式为: +-- cbFnc(result) +-- result:number类型 +-- 0表示停止成功 +-- 1表示之前已经发送了停止动作,请耐心等待停止结果的回调 +-- @usage record.stop(cb) +function stop(cbFnc) + if not recording then + if cbFnc then cbFnc(0) end + return + end + if stoping then + if cbFnc then cbFnc(1) end + return + end + stopCbFnc = cbFnc ril.request("AT+AUDREC=0,0,0," .. ID .. "," .. duration) stoping = true end @@ -108,17 +122,15 @@ ril.regUrc("+AUDREC", function(data) if recordCallback then recordCallback(result, size) recordCallback = nil end recording = false stoping = false + if stopCbFnc then stopCbFnc(0) stopCbFnc=nil end --录音播放相关 elseif action=="2" then + sys.publish("LIB_RECORD_PLAY_END_IND") if size > 0 then - --if not flag_s then - sys.publish("AUDIO_PLAY_END","SUCCESS") - --else - --flag_s=false - --end - else - sys.publish("AUDIO_PLAY_END","ERROR") - end + sys.publish("AUDIO_PLAY_END","SUCCESS") + else + sys.publish("AUDIO_PLAY_END","ERROR") + end end end end) @@ -133,7 +145,10 @@ ril.regRsp("+AUDREC", function(cmd, success) recording = false end elseif action == '0' then - if stoping and not success then stoping = false end -- 失败直接结束,成功则等到+AUDREC上报才判定停止录音成功 + if stoping and not success then -- 失败直接结束,成功则等到+AUDREC上报才判定停止录音成功 + if stopCbFnc then stopCbFnc(0) stopCbFnc=nil end + stoping = false + end --停止播放录音 elseif action=="3" then --flag_s=true diff --git a/script_LuaTask/lib/socket.lua b/script_LuaTask/lib/socket.lua index b35cd04..60d9885 100644 --- a/script_LuaTask/lib/socket.lua +++ b/script_LuaTask/lib/socket.lua @@ -42,7 +42,8 @@ end local function stopConnectTimer(tSocket, id) if id and tSocket[id] and tSocket[id].co and coroutine.status(tSocket[id].co) == "suspended" - and (tSocket[id].wait == "+SSLCONNECT" or (tSocket[id].protocol == "UDP" and tSocket[id].wait == "+CIPSTART")) then + and (tSocket[id].wait == "+SSLCONNECT" or tSocket[id].wait == "+CIPSTART") then + -- and (tSocket[id].wait == "+SSLCONNECT" or (tSocket[id].protocol == "UDP" and tSocket[id].wait == "+CIPSTART")) then sys.timerStop(coroutine.resume, tSocket[id].co, false, "TIMEOUT") end end @@ -84,7 +85,6 @@ local function onSocketURC(data, prefix) log.error('socket: urc on nil socket', data, id, tSocket[id], socketsSsl[id]) return end - if result == "CONNECT OK" or result:match("CONNECT ERROR") or result:match("CONNECT FAIL") then if tSocket[id].wait == "+CIPSTART" or tSocket[id].wait == "+SSLCONNECT" then stopConnectTimer(tSocket, id) @@ -205,8 +205,9 @@ end -- @string address 服务器地址,支持ip和域名 -- @param port string或者number类型,服务器端口 -- @return bool result true - 成功,false - 失败 --- @usage c = socket.tcp(); c:connect(); -function mt:connect(address, port) +-- @number timeout, 链接服务器最长超时时间 +-- @usage c = socket.tcp(); c:connect("www.baidu.com",80,5); +function mt:connect(address, port, timeout) assert(self.co == coroutine.running(), "socket:connect: coroutine mismatch") if not link.isReady() then @@ -237,7 +238,7 @@ function mt:connect(address, port) end end - sslInit() + sslInit() req(string.format("AT+SSLCREATE=%d,\"%s\",%d", self.id, address .. ":" .. port, (self.cert and self.cert.caCert) and 0 or 1)) self.created = true for i = 1, #tConfigCert do @@ -247,7 +248,8 @@ function mt:connect(address, port) else req(string.format("AT+CIPSTART=%d,\"%s\",\"%s\",%s", self.id, self.protocol, address, port)) end - if self.ssl or self.protocol == "UDP" then sys.timerStart(coroutine.resume, 120000, self.co, false, "TIMEOUT") end + -- if self.ssl or self.protocol == "UDP" then sys.timerStart(coroutine.resume, 120000, self.co, false, "TIMEOUT") end + sys.timerStart(coroutine.resume, (timeout or 120) * 1000, self.co, false, "TIMEOUT") ril.regUrc((self.ssl and "SSL&" or "") .. self.id, onSocketURC) self.wait = self.ssl and "+SSLCONNECT" or "+CIPSTART" @@ -284,7 +286,7 @@ function mt:connect(address, port) if r == false then if self.ssl then self:sslDestroy() end - sys.publish("LIB_SOCKET_CONNECT_FAIL_IND",self.ssl,self.protocol,address,port) + sys.publish("LIB_SOCKET_CONNECT_FAIL_IND", self.ssl, self.protocol, address, port) return false end self.connected = true @@ -315,7 +317,7 @@ function mt:asyncSelect(keepAlive, pingreq) self.wait = self.ssl and "+SSLSEND" or "+CIPSEND" if not coroutine.yield() then if self.ssl then self:sslDestroy() end - sys.publish("LIB_SOCKET_SEND_FAIL_IND",self.ssl,self.protocol,self.address,self.port) + sys.publish("LIB_SOCKET_SEND_FAIL_IND", self.ssl, self.protocol, self.address, self.port) return false end end @@ -383,7 +385,7 @@ function mt:send(data) self.wait = self.ssl and "+SSLSEND" or "+CIPSEND" if not coroutine.yield() then if self.ssl then self:sslDestroy() end - sys.publish("LIB_SOCKET_SEND_FAIL_IND",self.ssl,self.protocol,self.address,self.port) + sys.publish("LIB_SOCKET_SEND_FAIL_IND", self.ssl, self.protocol, self.address, self.port) return false end end @@ -514,19 +516,19 @@ local function onResponse(cmd, success, response, intermediate) return end - if prefix=='+CIPSEND' then - if response:match("%d, *([%u%d :]+)")~='SEND OK' then + if prefix == '+CIPSEND' then + if response:match("%d, *([%u%d :]+)") ~= 'SEND OK' then local acceptLen = response:match("DATA ACCEPT:%d,(%d+)") if acceptLen then - if acceptLen~=cmd:match("AT%+%u+=%d,(%d+)") then + if acceptLen ~= cmd:match("AT%+%u+=%d,(%d+)") then success = false end else success = false end end - elseif prefix=="+SSLSEND" then - if response:match("%d, *([%u%d :]+)")~='SEND OK' then + elseif prefix == "+SSLSEND" then + if response:match("%d, *([%u%d :]+)") ~= 'SEND OK' then success = false end end diff --git a/script_LuaTask/lib/sys.lua b/script_LuaTask/lib/sys.lua index 7069884..47c8e4a 100644 --- a/script_LuaTask/lib/sys.lua +++ b/script_LuaTask/lib/sys.lua @@ -10,7 +10,7 @@ require "patch" module(..., package.seeall) -- lib脚本版本号,只要lib中的任何一个脚本做了修改,都需要更新此版本号 -SCRIPT_LIB_VER = "2.3.2" +SCRIPT_LIB_VER = "2.3.3" -- TaskID最大值 local TASK_TIMER_ID_MAX = 0x1FFFFFFF diff --git a/script_LuaTask/lib/utils.lua b/script_LuaTask/lib/utils.lua index cea6dda..0550761 100644 --- a/script_LuaTask/lib/utils.lua +++ b/script_LuaTask/lib/utils.lua @@ -35,7 +35,7 @@ function string.fromHex(hex) end) end --- 返回字符串tonumber的转义字符串(用来支持超过31位整数的转换) +--- 返回字符串tonumber的转义字符串(用来支持超过31位整数的转换) -- @string str 输入字符串 -- @return str 转换后的lua 二进制字符串 -- @return len 转换了多少个字符 diff --git a/script_LuaTask/release notes.txt b/script_LuaTask/release notes.txt index 4d8a8b7..5427f85 100644 --- a/script_LuaTask/release notes.txt +++ b/script_LuaTask/release notes.txt @@ -1,4 +1,17 @@ -发布时间:2019/05/24 14:22 +发布时间:2019/07/24 14:45 +修改记录: + 一、lib脚本修改 + lib脚本版本号:2.3.3 + (1)aLiYun.lua:新增aLiYun.setErrHandle接口,可设置阿里云任务运行异常时的错误处理动作 + (2)aLiYun.lua:新增“OTA升级失败时,主动上报旧版本号以及删除已下载文件”的功能 + (3)audio.lua:优化音频播放的冲突管理机制 + (4)socket.lua:connect接口新增timeout参数,允许用户设置最长连接IP等待超时,默认120秒 + (5)mqtt.lua:connect接口新增timeout参数,允许用户设置最长连接IP等待超时,默认120秒 + + + + +发布时间:2019/05/24 14:22 修改记录: 一、lib脚本修改 lib脚本版本号:2.3.2