diff --git a/script_LuaTask/demo/console/main.lua b/script_LuaTask/demo/console/main.lua index a9540e2..d4fc5d0 100644 --- a/script_LuaTask/demo/console/main.lua +++ b/script_LuaTask/demo/console/main.lua @@ -15,6 +15,7 @@ LOG_LEVEL = log.LOGLEVEL_TRACE 2、最后一次是调用log.openTrace(true,1,115200)配置日志输出端口,此时要关闭输出日志,直接调用log.openTrace(false,1)即可 ]] --log.openTrace(true,1,115200) + require "sys" require "net" @@ -38,6 +39,7 @@ require "httpv2" require "wdt" wdt.setup(pio.P0_30, pio.P0_31) ]] + --加载网络指示灯功能模块 --根据自己的项目需求和硬件配置决定:1、是否加载此功能模块;2、配置指示灯引脚 --合宙官方出售的Air800和Air801开发板上的指示灯引脚为pio.P0_28,其他开发板上的指示灯引脚为pio.P1_1 @@ -45,16 +47,18 @@ wdt.setup(pio.P0_30, pio.P0_31) --netLed.setup(true,pio.P1_1) --网络指示灯功能模块中,默认配置了各种工作状态下指示灯的闪烁规律,参考netLed.lua中ledBlinkTime配置的默认值 --如果默认值满足不了需求,此处调用netLed.updateBlinkTime去配置闪烁时长 + --加载错误日志管理功能模块【强烈建议打开此功能】 --如下2行代码,只是简单的演示如何使用errDump功能,详情参考errDump的api require "errDump" --- errDump.request("udp://ota.airm2m.com:9072") +errDump.request("udp://ota.airm2m.com:9072") --加载远程升级功能模块【强烈建议打开此功能】 --如下3行代码,只是简单的演示如何使用update功能,详情参考update的api以及demo/update --PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K" --require "update" --update.request() + --加载GPS功能测试模块 --启动系统框架 sys.init(0, 0) diff --git a/script_LuaTask/doc/lib/index.html b/script_LuaTask/doc/lib/index.html index 44c2924..116f513 100644 --- a/script_LuaTask/doc/lib/index.html +++ b/script_LuaTask/doc/lib/index.html @@ -248,7 +248,7 @@

Modules

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/aLiYun.html b/script_LuaTask/doc/lib/modules/aLiYun.html index 2be02dc..b38195e 100644 --- a/script_LuaTask/doc/lib/modules/aLiYun.html +++ b/script_LuaTask/doc/lib/modules/aLiYun.html @@ -374,7 +374,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/aLiYunOta.html b/script_LuaTask/doc/lib/modules/aLiYunOta.html index bd507b3..8c6599e 100644 --- a/script_LuaTask/doc/lib/modules/aLiYunOta.html +++ b/script_LuaTask/doc/lib/modules/aLiYunOta.html @@ -232,7 +232,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/agps.html b/script_LuaTask/doc/lib/modules/agps.html index 6845f67..bb41e34 100644 --- a/script_LuaTask/doc/lib/modules/agps.html +++ b/script_LuaTask/doc/lib/modules/agps.html @@ -113,7 +113,7 @@

Info:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/audio.html b/script_LuaTask/doc/lib/modules/audio.html index c9077f5..c2ef66b 100644 --- a/script_LuaTask/doc/lib/modules/audio.html +++ b/script_LuaTask/doc/lib/modules/audio.html @@ -345,7 +345,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/cc.html b/script_LuaTask/doc/lib/modules/cc.html index c531b0b..1d53afe 100644 --- a/script_LuaTask/doc/lib/modules/cc.html +++ b/script_LuaTask/doc/lib/modules/cc.html @@ -584,7 +584,7 @@

Fields

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/clib.html b/script_LuaTask/doc/lib/modules/clib.html index 634108a..3012561 100644 --- a/script_LuaTask/doc/lib/modules/clib.html +++ b/script_LuaTask/doc/lib/modules/clib.html @@ -164,7 +164,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/common.html b/script_LuaTask/doc/lib/modules/common.html index fc3032d..5b71ff4 100644 --- a/script_LuaTask/doc/lib/modules/common.html +++ b/script_LuaTask/doc/lib/modules/common.html @@ -722,7 +722,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/console.html b/script_LuaTask/doc/lib/modules/console.html index 36ec96b..5fcaee8 100644 --- a/script_LuaTask/doc/lib/modules/console.html +++ b/script_LuaTask/doc/lib/modules/console.html @@ -161,7 +161,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/errDump.html b/script_LuaTask/doc/lib/modules/errDump.html index 1421fc2..272151d 100644 --- a/script_LuaTask/doc/lib/modules/errDump.html +++ b/script_LuaTask/doc/lib/modules/errDump.html @@ -237,7 +237,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/gizwits.html b/script_LuaTask/doc/lib/modules/gizwits.html index 0d88c6e..dde635b 100644 --- a/script_LuaTask/doc/lib/modules/gizwits.html +++ b/script_LuaTask/doc/lib/modules/gizwits.html @@ -401,7 +401,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
diff --git a/script_LuaTask/doc/lib/modules/gps.html b/script_LuaTask/doc/lib/modules/gps.html index f518f90..f90d21b 100644 --- a/script_LuaTask/doc/lib/modules/gps.html +++ b/script_LuaTask/doc/lib/modules/gps.html @@ -172,6 +172,12 @@

Functions

设置GPS模块的运行模式. + + setNemaReportFreq ([rmc=1][, gga=1][, gsa=1][, gsv=1][, vtg=1][, gll=0]) + + 设置NEMA语句的输出频率. + + setLocationFilter ([seconds=0]) @@ -707,6 +713,64 @@

Usage:

  • gps.setRunMode(1,5000,2000)
    + +
    + + + setNemaReportFreq ([rmc=1][, gga=1][, gsa=1][, gsv=1][, vtg=1][, gll=0]) + +
    +
    +
    设置NEMA语句的输出频率.
    + + +

    Parameters:

    + + +

    Returns:

    + + + + +

    Usage:

    + +
    @@ -1222,7 +1286,7 @@

    Fields

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/gpsv2.html b/script_LuaTask/doc/lib/modules/gpsv2.html index 464cfd6..f8d005c 100644 --- a/script_LuaTask/doc/lib/modules/gpsv2.html +++ b/script_LuaTask/doc/lib/modules/gpsv2.html @@ -926,7 +926,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/http.html b/script_LuaTask/doc/lib/modules/http.html index be2b9f6..e43a491 100644 --- a/script_LuaTask/doc/lib/modules/http.html +++ b/script_LuaTask/doc/lib/modules/http.html @@ -235,7 +235,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/httpv2.html b/script_LuaTask/doc/lib/modules/httpv2.html index 45f3ad8..9886416 100644 --- a/script_LuaTask/doc/lib/modules/httpv2.html +++ b/script_LuaTask/doc/lib/modules/httpv2.html @@ -100,7 +100,7 @@

    Functions

    @@ -116,7 +116,7 @@

    Functions

    - request (method, url, timeout, params, data, ctype, basic, headers) + request (method, url, timeout, params, data, ctype, basic, headers, cert)
    @@ -154,6 +154,14 @@

    Parameters:

  • headers
    table类型,HTTP headers部分
  • +
  • cert +
    table类型,此参数可选,默认值为: nil,ssl连接需要的证书配置,只有ssl参数为true时,才参数才有意义,cert格式如下:
    + {
    +  caCert = "ca.crt", --CA证书文件(Base64编码 X.509格式),如果存在此参数,则表示客户端会对服务器的证书进行校验;不存在则不校验
    +  clientCert = "client.crt", --客户端证书文件(Base64编码 X.509格式),服务器对客户端的证书进行校验时会用到此参数
    +  clientKey = "client.key", --客户端私钥文件(Base64编码 X.509格式) clientPassword = "123456", --客户端证书文件密码[可选]
    +  }
    +
  • Returns:

    @@ -180,7 +188,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/lbsLoc.html b/script_LuaTask/doc/lib/modules/lbsLoc.html index cc6f2c7..be905fe 100644 --- a/script_LuaTask/doc/lib/modules/lbsLoc.html +++ b/script_LuaTask/doc/lib/modules/lbsLoc.html @@ -198,7 +198,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/led.html b/script_LuaTask/doc/lib/modules/led.html index a2ba48a..8a60ad4 100644 --- a/script_LuaTask/doc/lib/modules/led.html +++ b/script_LuaTask/doc/lib/modules/led.html @@ -255,7 +255,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/link.html b/script_LuaTask/doc/lib/modules/link.html index 3a9c52e..2faf037 100644 --- a/script_LuaTask/doc/lib/modules/link.html +++ b/script_LuaTask/doc/lib/modules/link.html @@ -103,7 +103,7 @@

    Info:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/log.html b/script_LuaTask/doc/lib/modules/log.html index b074c0c..e567e9d 100644 --- a/script_LuaTask/doc/lib/modules/log.html +++ b/script_LuaTask/doc/lib/modules/log.html @@ -400,7 +400,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/misc.html b/script_LuaTask/doc/lib/modules/misc.html index 4da35c8..d9fe1ab 100644 --- a/script_LuaTask/doc/lib/modules/misc.html +++ b/script_LuaTask/doc/lib/modules/misc.html @@ -554,7 +554,7 @@

    Returns:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/mqtt.html b/script_LuaTask/doc/lib/modules/mqtt.html index 3dd3145..174b542 100644 --- a/script_LuaTask/doc/lib/modules/mqtt.html +++ b/script_LuaTask/doc/lib/modules/mqtt.html @@ -460,7 +460,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/net.html b/script_LuaTask/doc/lib/modules/net.html index 083a50d..9c89bbf 100644 --- a/script_LuaTask/doc/lib/modules/net.html +++ b/script_LuaTask/doc/lib/modules/net.html @@ -618,7 +618,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/netLed.html b/script_LuaTask/doc/lib/modules/netLed.html index eaf34e0..ec9c800 100644 --- a/script_LuaTask/doc/lib/modules/netLed.html +++ b/script_LuaTask/doc/lib/modules/netLed.html @@ -208,7 +208,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/ntp.html b/script_LuaTask/doc/lib/modules/ntp.html index 172ace6..540dc82 100644 --- a/script_LuaTask/doc/lib/modules/ntp.html +++ b/script_LuaTask/doc/lib/modules/ntp.html @@ -311,7 +311,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/nvm.html b/script_LuaTask/doc/lib/modules/nvm.html index 7b6a4c8..bce9cb7 100644 --- a/script_LuaTask/doc/lib/modules/nvm.html +++ b/script_LuaTask/doc/lib/modules/nvm.html @@ -425,7 +425,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/patch.html b/script_LuaTask/doc/lib/modules/patch.html index a6bd47f..2393e45f 100644 --- a/script_LuaTask/doc/lib/modules/patch.html +++ b/script_LuaTask/doc/lib/modules/patch.html @@ -103,7 +103,7 @@

    Info:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/pb.html b/script_LuaTask/doc/lib/modules/pb.html index e5a34aa..8643d29 100644 --- a/script_LuaTask/doc/lib/modules/pb.html +++ b/script_LuaTask/doc/lib/modules/pb.html @@ -288,7 +288,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/pins.html b/script_LuaTask/doc/lib/modules/pins.html index 6db1575..83c8555 100644 --- a/script_LuaTask/doc/lib/modules/pins.html +++ b/script_LuaTask/doc/lib/modules/pins.html @@ -207,7 +207,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/pm.html b/script_LuaTask/doc/lib/modules/pm.html index ed8f59f..1281c3f 100644 --- a/script_LuaTask/doc/lib/modules/pm.html +++ b/script_LuaTask/doc/lib/modules/pm.html @@ -226,7 +226,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/powerKey.html b/script_LuaTask/doc/lib/modules/powerKey.html index dd0f905..b9b5928 100644 --- a/script_LuaTask/doc/lib/modules/powerKey.html +++ b/script_LuaTask/doc/lib/modules/powerKey.html @@ -168,7 +168,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/record.html b/script_LuaTask/doc/lib/modules/record.html index 0a1a433..2a0d914 100644 --- a/script_LuaTask/doc/lib/modules/record.html +++ b/script_LuaTask/doc/lib/modules/record.html @@ -372,7 +372,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/ril.html b/script_LuaTask/doc/lib/modules/ril.html index 5112fe6..b31bc79 100644 --- a/script_LuaTask/doc/lib/modules/ril.html +++ b/script_LuaTask/doc/lib/modules/ril.html @@ -284,7 +284,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/scanCode.html b/script_LuaTask/doc/lib/modules/scanCode.html index 0b74a38..d63465f 100644 --- a/script_LuaTask/doc/lib/modules/scanCode.html +++ b/script_LuaTask/doc/lib/modules/scanCode.html @@ -160,7 +160,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/sim.html b/script_LuaTask/doc/lib/modules/sim.html index 9edbaa1..72350f2 100644 --- a/script_LuaTask/doc/lib/modules/sim.html +++ b/script_LuaTask/doc/lib/modules/sim.html @@ -274,7 +274,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/sms.html b/script_LuaTask/doc/lib/modules/sms.html index 2690e10..e8957e1 100644 --- a/script_LuaTask/doc/lib/modules/sms.html +++ b/script_LuaTask/doc/lib/modules/sms.html @@ -207,7 +207,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/socket.html b/script_LuaTask/doc/lib/modules/socket.html index ba1ead5..a3c42e3 100644 --- a/script_LuaTask/doc/lib/modules/socket.html +++ b/script_LuaTask/doc/lib/modules/socket.html @@ -485,7 +485,7 @@

    Fields

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/sys.html b/script_LuaTask/doc/lib/modules/sys.html index e4d682f..28ebdb1 100644 --- a/script_LuaTask/doc/lib/modules/sys.html +++ b/script_LuaTask/doc/lib/modules/sys.html @@ -769,7 +769,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/uiWin.html b/script_LuaTask/doc/lib/modules/uiWin.html index ead3bdb..c24c011 100644 --- a/script_LuaTask/doc/lib/modules/uiWin.html +++ b/script_LuaTask/doc/lib/modules/uiWin.html @@ -228,7 +228,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/update.html b/script_LuaTask/doc/lib/modules/update.html index bcf71b8..7c8e738 100644 --- a/script_LuaTask/doc/lib/modules/update.html +++ b/script_LuaTask/doc/lib/modules/update.html @@ -183,7 +183,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/utils.html b/script_LuaTask/doc/lib/modules/utils.html index d878166..1759945 100644 --- a/script_LuaTask/doc/lib/modules/utils.html +++ b/script_LuaTask/doc/lib/modules/utils.html @@ -164,6 +164,12 @@

    Functions

    + + + +
    - request (method, url, timeout, params, data, ctype, basic, headers) + request (method, url, timeout, params, data, ctype, basic, headers, cert) HTTP客户端
    返回文件大小
    + io.readStream (path, offset, len) + 返回指定位置读取的字符串

    @@ -548,6 +554,42 @@

    Usage:

  • locan cnt = io.fileSize("/ldata/call.txt")
    + +
    + + + io.readStream (path, offset, len) + +
    +
    +
    返回指定位置读取的字符串
    + + +

    Parameters:

    +
      +
    • path + string +
      文件路径全名例如:"/ldata/call.txt"
      +
    • +
    • offset + number +
      要读取的指定位置
      +
    • +
    • len + number +
      要读取的字节数
      +
    • +
    + +

    Returns:

    +
      +
    • +
      string,返回要读取的数据,读取失败返回nil
      +
    + + + +
    @@ -556,7 +598,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/doc/lib/modules/wdt.html b/script_LuaTask/doc/lib/modules/wdt.html index c1299d1..91af9b4 100644 --- a/script_LuaTask/doc/lib/modules/wdt.html +++ b/script_LuaTask/doc/lib/modules/wdt.html @@ -104,6 +104,13 @@

    Functions

    配置模块与看门狗通讯IO并启动任务 + + + restart (rst, wd) + + 硬件看门狗立即重启模块 + 调用此接口前,必须保证wdt.setup已经被执行过 +
    @@ -146,6 +153,41 @@

    Usage:

  • setup(pio.P0_31,pio.P0_29)
    + +
    + + + restart (rst, wd) + +
    +
    +
    硬件看门狗立即重启模块
    + 调用此接口前,必须保证wdt.setup已经被执行过
    + + +

    Parameters:

    +
      +
    • rst +
       -- 模块复位单片机引脚(pio.P0_31)
      +
    • +
    • wd +
        -- 模块和单片机相互喂狗引脚(pio.P0_29)
      +
    • +
    + +

    Returns:

    +
      +
    • +
      nil
      +
    + + + +

    Usage:

    +
      +
    • wdt.restart()
      +
    +
    @@ -154,7 +196,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-11-07 18:24:40 +Last updated 2018-11-26 16:32:37
    diff --git a/script_LuaTask/lib/aLiYun.lua b/script_LuaTask/lib/aLiYun.lua index 36c8bc0..bc80f17 100644 --- a/script_LuaTask/lib/aLiYun.lua +++ b/script_LuaTask/lib/aLiYun.lua @@ -98,6 +98,7 @@ function clientDataTask(host,tPorts,clientId,user,password) if evtCb["connect"] then evtCb["connect"](true) end local result,prompt = procSubscribe(mqttClient) + outQueue["SUBSCRIBE"] = {} if result then local procs,k,v = {procReceive,procSend} while true do diff --git a/script_LuaTask/lib/gps.lua b/script_LuaTask/lib/gps.lua index 691bf5b..f28bbc7 100644 --- a/script_LuaTask/lib/gps.lua +++ b/script_LuaTask/lib/gps.lua @@ -41,11 +41,13 @@ local powerCbFnc uartBaudrate = 115200 local uartID,uartDatabits,uartParity,uartStopbits = 2,8,uart.PAR_NONE,uart.STOP_1 --搜星模式命令字符串,"$PGKC115," .. gps .. "," .. glonass .. "," .. beidou .. "," .. galieo .. "*" -local aerialModeStr = "" +local aerialModeStr,aerialModeSetted = "" --运行模式命令字符串,"$PGKC105," .. mode .. "," .. rt .. "," .. st .. "*" -local runModeStr = "" +local runModeStr,runModeSetted = "" --正常运行模式下NMEA数据上报间隔命令字符串,"$PGKC101," .. interval .. "*" -local nmeaReportStr = "" +local nmeaReportStr,nmeaReportSetted = "" +--每种NEMA数据的输出频率命令字符串 +local nmeaReportFreqStr,nmeaReportFreqSetted = "" --NMEA数据处理模式,0表示仅gps.lua内部处理,1表示仅用户自己处理,2表示gps.lua和用户同时处理 --用户处理一条NMEA数据的回调函数 local nmeaMode,nmeaCbFnc = 0 @@ -186,6 +188,7 @@ local function parseNmea(s) if filterSeconds>0 and fixed and not fixFlag and not filteredFlag then if not sys.timerIsActive(filterTimerFnc) then log.info("gps.filterTimerFnc begin") + sys.publish("GPS_STATE","LOCATION_FILTER") sys.timerStart(filterTimerFnc,filterSeconds*1000) end return @@ -223,6 +226,7 @@ local function taskRead() cacheData = cacheData..s local d1,d2,nemaStr = sfind(cacheData,"\r\n") while d1 do + writePendingCmds() nemaStr = ssub(cacheData,1,d2) cacheData = ssub(cacheData,d2+1,-1) @@ -258,6 +262,13 @@ function writeCmd(cmd,isFull) --log.info("gps.writecmd",tmp:toHex()) end +function writePendingCmds() + if not aerialModeSetted and aerialModeStr~="" then writeCmd(aerialModeStr) aerialModeSetted=true end + if not runModeSetted and runModeStr~="" then writeCmd(runModeStr) runModeSetted=true end + if not nmeaReportSetted and nmeaReportStr~="" then writeCmd(nmeaReportStr) nmeaReportSetted=true end + if not nmeaReportFreqSetted and nmeaReportFreqStr~="" then writeCmd(nmeaReportFreqStr) nmeaReportFreqSetted=true end +end + local function _open() if openFlag then return end pm.wake("gps.lua") @@ -272,10 +283,7 @@ local function _open() openFlag = true sys.publish("GPS_STATE","OPEN") fixFlag,filteredFlag = false - Ggalng,Ggalat,Gsv,Sep = "","","" - if aerialModeStr~="" then writeCmd(aerialModeStr) aerialModeStr="" end - if runModeStr~="" then writeCmd(runModeStr) runModeStr="" end - if nmeaReportStr~="" then writeCmd(nmeaReportStr) nmeaReportStr="" end + Ggalng,Ggalat,Gsv,Sep = "","","" log.info("gps._open") end @@ -294,6 +302,7 @@ local function _close() fixFlag,filteredFlag = false sys.timerStop(filterTimerFnc) Ggalng,Ggalat,Gsv,Sep = "","","" + aerialModeSetted,runModeSetted,nmeaReportSetted,nmeaReportFreqSetted = nil log.info("gps._close") end @@ -582,8 +591,10 @@ function setAerialMode(gps,beidou,glonass,galieo) local beidou = beidou or 0 local galieo = galieo or 0 if gps+glonass+beidou+galieo == 0 then gps=1 beidou=1 end - aerialModeStr = "$PGKC115,"..gps..","..glonass..","..beidou..","..galieo.."*" - if isOpen() then writeCmd(aerialModeStr) aerialModeStr="" end + local tmpStr = "$PGKC115,"..gps..","..glonass..","..beidou..","..galieo.."*" + if tmpStr~=aerialModeStr then + aerialModeStr,aerialModeSetted = tmpStr + end end @@ -619,11 +630,28 @@ function setRunMode(mode,runTm,sleepTm) if rt>10000 then rt=10000 end if rt<200 then rt=200 end nmeaReportStr = "$PGKC101,"..rt.."*" - if isOpen() then writeCmd(nmeaReportStr) nmeaReportStr="" end end - runModeStr = "$PGKC105,"..mode..((mode==1 or mode==2) and (","..rt..","..st) or "").."*" - if isOpen() then writeCmd(runModeStr) runModeStr="" end + local tmpStr = "$PGKC105,"..mode..((mode==1 or mode==2) and (","..rt..","..st) or "").."*" + if tmpStr~=runModeStr then + runModeStr,runModeSetted = tmpStr + end +end + +--- 设置NEMA语句的输出频率. +-- @number[opt=1] rmc,单位秒,RMC语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @number[opt=1] gga,单位秒,GGA语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @number[opt=1] gsa,单位秒,GSA语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @number[opt=1] gsv,单位秒,GSV语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @number[opt=1] vtg,单位秒,VTG语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @number[opt=0] gll,单位秒,GLL语句输出频率,取值范围0到10之间的整数,0表示不输出 +-- @return nil +-- @usage gps.setNemaReportFreq(5,0,0,0,0,0) +function setNemaReportFreq(rmc,gga,gsa,gsv,vtg,gll) + local tmpStr = "$PGKC242,"..(gll or 0)..","..(rmc or 1)..","..(vtg or 1)..","..(gga or 1)..","..(gsa or 1)..","..(gsv or 1)..",0,0,0,0,0,0,0,0,0,0,0,0,0".."*" + if tmpStr~=nmeaReportFreqStr then + nmeaReportFreqStr,nmeaReportFreqSetted = tmpStr + end end --- 设置GPS定位成功后经纬度的过滤时间. diff --git a/script_LuaTask/lib/link.lua b/script_LuaTask/lib/link.lua index 57741d8..4202ee4 100644 --- a/script_LuaTask/lib/link.lua +++ b/script_LuaTask/lib/link.lua @@ -78,7 +78,7 @@ ril.regUrc("STATE", function(data) return elseif status == "IP INITIAL" then if net.getState() ~= 'REGISTERED' then return end - request(string.format('AT+CSTT="%s","%s","%s"', apnname, username, password)) + request(string.format('AT+CSTT="%s","%s","%s"', apnname, username or "", password or "")) request("AT+CIICR") elseif status == "IP START" then request("AT+CIICR") diff --git a/script_LuaTask/lib/socket.lua b/script_LuaTask/lib/socket.lua index 1344da1..2687483 100644 --- a/script_LuaTask/lib/socket.lua +++ b/script_LuaTask/lib/socket.lua @@ -40,8 +40,9 @@ local function socketStatusNtfy() sys.publish("SOCKET_ACTIVE", isSocketActive() or isSocketActive(true)) end -local function stopSslConnectTimer(tSocket,id) - if id and tSocket[id].ssl and tSocket[id].co and coroutine.status(tSocket[id].co) == "suspended" and tSocket[id].wait=="+SSLCONNECT" then +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 sys.timerStop(coroutine.resume,tSocket[id].co,false,"TIMEOUT") end end @@ -54,7 +55,7 @@ local function errorInd(error) if error == 'CLOSED' and not c.ssl then c.connected = false socketStatusNtfy() end c.error = error if c.co and coroutine.status(c.co) == "suspended" then - stopSslConnectTimer(v, c.id) + stopConnectTimer(v, c.id) coroutine.resume(c.co, false) end --end @@ -74,23 +75,23 @@ 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 - stopSslConnectTimer(tSocket,id) + stopConnectTimer(tSocket,id) coroutine.resume(tSocket[id].co, result == "CONNECT OK") else log.error("socket: error urc", tSocket[id].wait) end return end - + if tag == "SSL" and string.find(result, "ERROR:") == 1 then return end - + if string.find(result, "ERROR") or result == "CLOSED" then if result == 'CLOSED' and not tSocket[id].ssl then tSocket[id].connected = false socketStatusNtfy() end tSocket[id].error = result - stopSslConnectTimer(tSocket,id) + stopConnectTimer(tSocket,id) coroutine.resume(tSocket[id].co, false) end end @@ -103,7 +104,7 @@ local function socket(protocol, cert) log.warn("socket.socket: too many sockets") return nil end - + local co = coroutine.running() if not co then log.warn("socket.socket: socket must be called in coroutine") @@ -119,10 +120,10 @@ local function socket(protocol, cert) input = {}, wait = "", } - + tSocket = (ssl and socketsSsl or sockets) tSocket[id] = o - + return setmetatable(o, mt) end --- 创建基于TCP的socket对象 @@ -159,7 +160,7 @@ local function sslInit() sslInited = true req("AT+SSLINIT") end - + local i, item for i = 1, #tSslInputCert do item = table.remove(tSslInputCert, 1) @@ -193,17 +194,17 @@ end -- @usage c = socket.tcp(); c:connect(); function mt.__index:connect(address, port) assert(self.co == coroutine.running(), "socket:connect: coroutine mismatch") - + if not link.isReady() then log.info("socket.connect: ip not ready") return false end - + if cc and cc.anyCallExist() then log.info("socket:connect: call exist, cannot connect") return false end - + if self.ssl then local tConfigCert, i = {} if self.cert then @@ -220,7 +221,7 @@ function mt.__index:connect(address, port) table.insert(tConfigCert, "AT+SSLCERT=1," .. self.id .. ",\"localprivatekey\",\"" .. self.cert.clientKey .. "\"") end end - + sslInit() self.address = address req(string.format("AT+SSLCREATE=%d,\"%s\",%d", self.id, address .. ":" .. port, (self.cert and self.cert.caCert) and 0 or 1)) @@ -229,19 +230,19 @@ function mt.__index:connect(address, port) req(tConfigCert[i]) end req("AT+SSLCONNECT=" .. self.id) - sys.timerStart(coroutine.resume,120000,self.co,false,"TIMEOUT") 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 + ril.regUrc((self.ssl and "SSL&" or "") .. self.id, onSocketURC) self.wait = self.ssl and "+SSLCONNECT" or "+CIPSTART" - + local r, s = coroutine.yield() - + if r == false and s == "DNS" then if self.ssl then self:sslDestroy()self.error = nil end - + require "http" --请求腾讯云免费HttpDns解析 http.request("GET", "119.29.29.29/d?dn=" .. address, nil, nil, nil, 40000, @@ -250,7 +251,7 @@ function mt.__index:connect(address, port) sys.publish("SOCKET_HTTPDNS_RESULT", result, statusCode, head, body) end) local _, result, statusCode, head, body = sys.waitUntil("SOCKET_HTTPDNS_RESULT") - + --DNS解析成功 if result and statusCode == "200" and body and body:match("^[%d%.]+") then return self:connect(body:match("^([%d%.]+)"), port) @@ -266,7 +267,7 @@ function mt.__index:connect(address, port) end end end - + if r == false then if self.ssl then self:sslDestroy() end return false @@ -289,7 +290,7 @@ function mt.__index:send(data) log.warn('socket.client:send', 'closed') return false end - + for i = 1, string.len(data), SENDSIZE do -- 按最大MTU单元对data分包 local stepData = string.sub(data, i, i + SENDSIZE - 1) @@ -318,7 +319,7 @@ function mt.__index:recv(timeout, msg) log.warn('socket.client:recv', 'error', self.error) return false end - + if #self.input == 0 then self.wait = self.ssl and "+SSL RECEIVE" or "+RECEIVE" if timeout and timeout > 0 then @@ -336,7 +337,7 @@ function mt.__index:recv(timeout, msg) return coroutine.yield() end end - + if self.protocol == "UDP" then return true, table.remove(self.input) else @@ -390,7 +391,7 @@ local function onResponse(cmd, success, response, intermediate) log.warn('socket: response on nil socket', cmd, response) return end - + if cmd:match("^AT%+SSLCREATE") then tSocket[id].createResp = response end @@ -402,7 +403,7 @@ local function onResponse(cmd, success, response, intermediate) if (prefix == '+CIPSEND' or prefix == "+SSLSEND") and response:match("%d, *([%u%d :]+)") ~= 'SEND OK' then success = false end - + local reason, address if not success then if prefix == "+CIPSTART" then @@ -414,9 +415,9 @@ local function onResponse(cmd, success, response, intermediate) reason = "DNS" end end - + if not reason and not success then tSocket[id].error = response end - stopSslConnectTimer(tSocket,id) + stopConnectTimer(tSocket,id) coroutine.resume(tSocket[id].co, success, reason) end end @@ -468,7 +469,7 @@ ril.regUrc("+SSL RECEIVE", onSocketReceiveUrc) function printStatus() log.info('socket.printStatus', 'valid id', table.concat(valid), table.concat(validSsl)) - + for m, n in pairs({sockets, socketsSsl}) do for _, client in pairs(n) do for k, v in pairs(client) do diff --git a/script_LuaTask/lib/sys.lua b/script_LuaTask/lib/sys.lua index 4c7bfa0..368c8f2 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.1.9" +SCRIPT_LIB_VER = "2.2.0" -- TaskID最大值 local TASK_TIMER_ID_MAX = 0x1FFFFFFF diff --git a/script_LuaTask/lib/wdt.lua b/script_LuaTask/lib/wdt.lua index a321f12..6c77c63 100644 --- a/script_LuaTask/lib/wdt.lua +++ b/script_LuaTask/lib/wdt.lua @@ -8,12 +8,15 @@ module(..., package.seeall) require "pins" +local restarting + --[[模块和看门狗互喂任务 -- @return 无 -- @usage local RST_SCMWD_PIN,RST_SCMWD_PIN -- @usage taskWdt() --]] -local function taskWdt(rst, wd) +local function taskWdt(rst, wd, restartFlag) + local wdtRestartAirFlag = restartFlag -- 初始化喂狗引脚电平(初始高电平,喂狗拉低2秒) rst(1) wd(1) @@ -21,12 +24,14 @@ local function taskWdt(rst, wd) while true do -- 模块 ---> 看门狗 喂脉冲 wd(0) - log.info("wdt.taskWdt", "AirM2M --> WATCHDOG : OK") + log.info("wdt.taskWdt", "AirM2M --> WATCHDOG : OK", wdtRestartAirFlag, restarting) + if not wdtRestartAirFlag and restarting then return end sys.wait(2000) -- 看门狗 ---> 模块 喂脉冲 wd(nil, true) for i = 1, 30 do if 0 ~= wd() then + if not wdtRestartAirFlag and restarting then return end sys.wait(100) else log.info("wdt.taskWdt", "AirM2M <-- WatchDog : OK") @@ -37,12 +42,14 @@ local function taskWdt(rst, wd) -- 复位狗 rst(0) log.error("wdt.taskWdt", "WatchDog <--> AirM2M didn't respond : wdt reset 153b") + if not wdtRestartAirFlag and restarting then return end sys.wait(100) rst(1) end end -- 2分钟后再喂 - sys.wait(120000) + if not wdtRestartAirFlag and restarting then return end + sys.wait(wdtRestartAirFlag and 1500 or 120000) wd(0, true) end end @@ -55,3 +62,18 @@ end function setup(rst, wd) sys.taskInit(taskWdt, rst and pins.setup(rst, 0, pio.PULLUP) or function() end, pins.setup(wd, 0, pio.PULLUP)) end + +--- 硬件看门狗立即重启模块 +-- 调用此接口前,必须保证wdt.setup已经被执行过 +-- @param rst -- 模块复位单片机引脚(pio.P0_31) +-- @param wd -- 模块和单片机相互喂狗引脚(pio.P0_29) +-- @return nil +-- @usage wdt.restart() +function restart(rst, wd) + if not restarting then + restarting = true + if rst then pins.close(rst) end + pins.close(wd) + sys.taskInit(taskWdt, rst and pins.setup(rst, 0, pio.PULLUP) or function() end, pins.setup(wd, 0, pio.PULLUP),true) + end +end diff --git a/script_LuaTask/release notes.txt b/script_LuaTask/release notes.txt index 88e2cec..aee9b36 100644 --- a/script_LuaTask/release notes.txt +++ b/script_LuaTask/release notes.txt @@ -1,4 +1,31 @@ -发布时间:2018/11/08 11:12 +发布时间:2018/11/26 10:51 +修改记录: + 一、lib脚本修改 + lib脚本版本号:2.2.0 + (1)socket.lua:修正“在执行:recv方法后,如果如果wait协程,在wait过程中,收到数据,会导致数据丢失”的问题 + 【问题重要性】:一般 + 【问题影响模块】:所有模块 + 【问题出现概率】:必现 + 【问题出现原因】:接受完数据后未将wait值清空,导致未将接收到的数据存储下来 + 【问题解决方式】:接收数据后及时清空wait值 + (2)gps.lua:新增setNemaReportFreq接口,可设置每种NMEA语句的输出频率 + 【新功能重要性】:一般 + 【问题影响模块】:Air800、Air801 + 【新功能说明】: 参考API说明 + (3)socket.lua:新增UDP连接超时处理功能 + 【新功能重要性】:一般 + 【问题影响模块】:所有模块 + 【新功能说明】: 默认两分钟没有连接成功,则返回连接超时失败 + (4)aLiYun.lua:修正“阿里云重连时,会重复发送订阅消息”的问题 + 【问题重要性】:一般 + 【问题影响模块】:所有模块 + 【问题出现概率】:必现 + 【问题出现原因】:每次重连都会新增一个订阅消息 + 【问题解决方式】:重连前清空订阅消息列表 + + + +发布时间:2018/11/08 11:12 修改记录: 一、lib脚本修改 lib脚本版本号:2.1.9 @@ -86,11 +113,11 @@ (3)socket.lua、link.lua、ril.lua:新增免费的腾讯云httpDns域名解析功能、新增socket.setDnsParser接口功能 【新功能重要性】:一般 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 - 【新功能说明】:可设置用户自定义的DNS解析器,通过域名连接服务器时,DNS解析的过程如下: + 【新功能说明】:可设置用户自定义的DNS解析器,通过域名连接服务器时,DNS解析的过程如下: - 1、使用core中提供的方式,连接运营商DNS服务器解析,如果解析成功,则结束;如果解析失败,走第2步 + 1、使用core中提供的方式,连接运营商DNS服务器解析,如果解析成功,则结束;如果解析失败,走第2步 - 2、使用脚本lib中提供的免费腾讯云HttpDns解析,如果解析成功,则结束;如果解析失败,走第3步 + 2、使用脚本lib中提供的免费腾讯云HttpDns解析,如果解析成功,则结束;如果解析失败,走第3步 3、如果存在用户自定义的DNS解析器,则使用此处用户自定义的DNS解析器去解析 (4)net.lua:修正“小区信号强度小于10时,getCellInfo、getCellInfoExt、getMultiCell接口无法返回此小区信息”的问题