From 0f5efe2685433188fea21ebc913d6d7ea48eed75 Mon Sep 17 00:00:00 2001 From: zhutianhua Date: Tue, 22 Jan 2019 18:14:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83core(V0033)=E5=92=8Cscript(V1?= =?UTF-8?q?.2.3)=E5=92=8Cscript=5FLuaTask(V2.3.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/release notes.txt | 29 +- script/demo/qrcode/qrcode.lua | 4 +- script/lib/linkssl.lua | 4 +- script/lib/net.lua | 16 +- script/lib/sys.lua | 8 +- script/release notes.txt | 986 ++++++++-------- script_LuaTask/demo/Air168/main.lua | 1 - script_LuaTask/demo/console/main.lua | 22 +- script_LuaTask/demo/crypto/testCrypto.lua | 10 + script_LuaTask/demo/gps/readme.txt | 1 + script_LuaTask/demo/gps/{ => v1}/main.lua | 0 script_LuaTask/demo/gps/{ => v1}/testGps.lua | 0 .../demo/{gpsv2 => gps/v2}/main.lua | 0 .../demo/{gpsv2 => gps/v2}/testGps.lua | 0 script_LuaTask/demo/i2c/testI2c.lua | 5 + script_LuaTask/demo/mqtt/sync/readme.txt | 2 + .../sync/sendInterruptRecv}/main.lua | 0 .../sync/sendInterruptRecv}/testMqtt.lua | 6 +- .../demo/mqtt/{ => sync/sendWaitRecv}/ca.crt | 0 .../mqtt/{ => sync/sendWaitRecv}/main.lua | 0 .../{ => sync/sendWaitRecv}/mqttInMsg.lua | 0 .../{ => sync/sendWaitRecv}/mqttOutMsg.lua | 0 .../mqtt/{ => sync/sendWaitRecv}/mqttTask.lua | 0 .../{ => socket/async}/asyncSocket/main.lua | 0 .../async}/asyncSocket/testSocket.lua | 0 .../async}/asyncSocketCallback/main.lua | 0 .../async}/asyncSocketCallback/testSocket.lua | 0 script_LuaTask/demo/socket/readme.txt | 2 + script_LuaTask/demo/socket/sync/readme.txt | 2 + .../sync/sendInterruptRecv}/main.lua | 0 .../sync/sendInterruptRecv}/testSocket.lua | 0 .../sendWaitRecv}/longConnection/main.lua | 0 .../longConnection/socketInMsg.lua | 0 .../longConnection/socketOutMsg.lua | 0 .../longConnection/socketTask.lua | 0 .../longConnectionTransparent/main.lua | 0 .../longConnectionTransparent/mcuUart.lua | 0 .../longConnectionTransparent/socketInMsg.lua | 0 .../socketOutMsg.lua | 0 .../longConnectionTransparent/socketTask.lua | 0 .../sendWaitRecv}/shortConnection/main.lua | 0 .../shortConnection/socketTask.lua | 0 .../shortConnectionFlymode/main.lua | 0 .../shortConnectionFlymode/socketTask.lua | 0 script_LuaTask/demo/uart/{ => v1}/main.lua | 0 script_LuaTask/demo/uart/{ => v1}/mcu101.bin | Bin .../demo/uart/{ => v1}/testUart.lua | 0 .../demo/uart/{ => v1}/testUartSentFile.lua | 0 .../demo/uart/{ => v1}/testUartTask.lua | 0 .../demo/{uartv2 => uart/v2}/demo.lua | 0 .../demo/{uartv2 => uart/v2}/main.lua | 0 .../demo/{uartv3 => uart/v3}/demo.lua | 0 .../demo/{uartv3 => uart/v3}/main.lua | 0 script_LuaTask/doc/lib/index.html | 2 +- script_LuaTask/doc/lib/modules/aLiYun.html | 2 +- script_LuaTask/doc/lib/modules/aLiYunOta.html | 2 +- script_LuaTask/doc/lib/modules/agps.html | 2 +- script_LuaTask/doc/lib/modules/audio.html | 2 +- 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 | 4 +- script_LuaTask/doc/lib/modules/http.html | 2 +- script_LuaTask/doc/lib/modules/httpv2.html | 2 +- script_LuaTask/doc/lib/modules/lbsLoc.html | 19 +- 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 | 2 +- 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 | 2 +- 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 | 2 +- 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 | 168 ++- script_LuaTask/doc/lib/modules/wdt.html | 2 +- script_LuaTask/lib/agps.lua | 4 +- script_LuaTask/lib/console.lua | 7 +- script_LuaTask/lib/gizwits.lua | 2 +- script_LuaTask/lib/gpsv2.lua | 1026 ++++++++--------- script_LuaTask/lib/httpv2.lua | 336 +++--- script_LuaTask/lib/lbsLoc.lua | 32 +- script_LuaTask/lib/mqtt.lua | 4 +- script_LuaTask/lib/patch.lua | 4 +- script_LuaTask/lib/socket.lua | 35 +- script_LuaTask/lib/sys.lua | 2 +- script_LuaTask/lib/utils.lua | 99 +- script_LuaTask/release notes.txt | 27 +- 106 files changed, 1651 insertions(+), 1292 deletions(-) create mode 100644 script_LuaTask/demo/gps/readme.txt rename script_LuaTask/demo/gps/{ => v1}/main.lua (100%) rename script_LuaTask/demo/gps/{ => v1}/testGps.lua (100%) rename script_LuaTask/demo/{gpsv2 => gps/v2}/main.lua (100%) rename script_LuaTask/demo/{gpsv2 => gps/v2}/testGps.lua (100%) create mode 100644 script_LuaTask/demo/mqtt/sync/readme.txt rename script_LuaTask/demo/{testMqtt => mqtt/sync/sendInterruptRecv}/main.lua (100%) rename script_LuaTask/demo/{testMqtt => mqtt/sync/sendInterruptRecv}/testMqtt.lua (89%) rename script_LuaTask/demo/mqtt/{ => sync/sendWaitRecv}/ca.crt (100%) rename script_LuaTask/demo/mqtt/{ => sync/sendWaitRecv}/main.lua (100%) rename script_LuaTask/demo/mqtt/{ => sync/sendWaitRecv}/mqttInMsg.lua (100%) rename script_LuaTask/demo/mqtt/{ => sync/sendWaitRecv}/mqttOutMsg.lua (100%) rename script_LuaTask/demo/mqtt/{ => sync/sendWaitRecv}/mqttTask.lua (100%) rename script_LuaTask/demo/{ => socket/async}/asyncSocket/main.lua (100%) rename script_LuaTask/demo/{ => socket/async}/asyncSocket/testSocket.lua (100%) rename script_LuaTask/demo/{ => socket/async}/asyncSocketCallback/main.lua (100%) rename script_LuaTask/demo/{ => socket/async}/asyncSocketCallback/testSocket.lua (100%) create mode 100644 script_LuaTask/demo/socket/readme.txt create mode 100644 script_LuaTask/demo/socket/sync/readme.txt rename script_LuaTask/demo/{testSocket => socket/sync/sendInterruptRecv}/main.lua (100%) rename script_LuaTask/demo/{testSocket => socket/sync/sendInterruptRecv}/testSocket.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnection/main.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnection/socketInMsg.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnection/socketOutMsg.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnection/socketTask.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnectionTransparent/main.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnectionTransparent/mcuUart.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnectionTransparent/socketInMsg.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnectionTransparent/socketOutMsg.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/longConnectionTransparent/socketTask.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/shortConnection/main.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/shortConnection/socketTask.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/shortConnectionFlymode/main.lua (100%) rename script_LuaTask/demo/socket/{ => sync/sendWaitRecv}/shortConnectionFlymode/socketTask.lua (100%) rename script_LuaTask/demo/uart/{ => v1}/main.lua (100%) rename script_LuaTask/demo/uart/{ => v1}/mcu101.bin (100%) rename script_LuaTask/demo/uart/{ => v1}/testUart.lua (100%) rename script_LuaTask/demo/uart/{ => v1}/testUartSentFile.lua (100%) rename script_LuaTask/demo/uart/{ => v1}/testUartTask.lua (100%) rename script_LuaTask/demo/{uartv2 => uart/v2}/demo.lua (100%) rename script_LuaTask/demo/{uartv2 => uart/v2}/main.lua (100%) rename script_LuaTask/demo/{uartv3 => uart/v3}/demo.lua (100%) rename script_LuaTask/demo/{uartv3 => uart/v3}/main.lua (100%) diff --git a/core/release notes.txt b/core/release notes.txt index 47258f3..e98b74c 100644 --- a/core/release notes.txt +++ b/core/release notes.txt @@ -1,13 +1,36 @@ -版本号:Luat_V0032_8955_XXX.lod +版本号:Luat_V0033_8955_XXX.lod +发布时间:2019/01/22 15:34 +修改记录: + (1)新增I2C1和I2C2功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air268、Air268F、Air168 + 【新功能使用说明】:参考i2c脚本的demo + (2)新增“查询是否为虚拟SIM卡”功能 + 【新功能重要性】:一般 + 【新功能影响模块】:所有模块 + 【新功能使用说明】:脚本中新增了一个接口sim.getType(),参考API说明 + (3)修正“打开串口DMA接收功能后,HOST口数据接收出错”的问题 + 【问题重要性】:一般 + 【问题影响模块】:所有模块 + 【问题出现概率】:0031和0032版本必现,只有用到HOST口的数据接收功能时,才需要关注此问题 + (4)新增“crypto.hmac_sha256接口” + 【新功能重要性】:一般 + 【新功能影响模块】:所有模块 + 【新功能使用说明】:参考crypto脚本的demo + + + + +版本号:Luat_V0032_8955_XXX.lod 发布时间:2018/12/07 10:17 修改记录: (1)disp.cameraopen接口增加是否镜像的参数 【新功能重要性】:一般 - 【新功能影响模块】:Air268F、Air68 + 【新功能影响模块】:Air268F、Air168 【新功能使用说明】:参考Air268F和Air168的脚本demo (2)发布支持Air168模块的lod 【新功能重要性】:一般 - 【新功能影响模块】:Air68 + 【新功能影响模块】:Air168 【新功能使用说明】:参考Air168的脚本demo diff --git a/script/demo/qrcode/qrcode.lua b/script/demo/qrcode/qrcode.lua index 98dfb07..50901fe 100644 --- a/script/demo/qrcode/qrcode.lua +++ b/script/demo/qrcode/qrcode.lua @@ -18,7 +18,7 @@ local width, data = qrencode.encode('http://www.openluat.com') --- disp.putqrcode(data, width, display_width, x, y) ʾά -- @param data qrencode.encodeصĶά -- @param width άݵʵʿ --- @param display_width άʵʾ +-- @param display_width άʵʾ,ʾȿҪ -- @param x άʾʼx -- @param y άʾʼy @@ -26,7 +26,7 @@ local width, data = qrencode.encode('http://www.openluat.com') local function appQRCode() disp.clear() disp.drawrect(0, 0, WIDTH-1, HEIGHT-1, WHITE) - local displayWidth = (WIDTH>HEIGHT and HEIGHT or WIDTH)-4 + local displayWidth = 100 disp.putqrcode(data, width, displayWidth, (WIDTH-displayWidth)/2, (HEIGHT-displayWidth)/2) disp.update() end diff --git a/script/lib/linkssl.lua b/script/lib/linkssl.lua index 23b796b..a0b4ebd 100644 --- a/script/lib/linkssl.lua +++ b/script/lib/linkssl.lua @@ -352,8 +352,8 @@ end ֵ ]] local function usersckntfy(id) - --һڲϢ"USER_SOCKET_CONNECT"֪ͨûsocket״̬仯 - if not linklist[id].tag then sys.dispatch("USER_SOCKET_CONNECT",usersckisactive()) end + --һڲϢ"USER_SOCKETSSL_CONNECT"֪ͨûsocket״̬仯 + if not linklist[id].tag then sys.dispatch("USER_SOCKETSSL_CONNECT",usersckisactive()) end end --[[ diff --git a/script/lib/net.lua b/script/lib/net.lua index 652d98c..9a2a834 100644 --- a/script/lib/net.lua +++ b/script/lib/net.lua @@ -53,7 +53,8 @@ local cellinfo,flymode,csqswitch,cengswitch,multicellcb = {} --ledontimeָʾƵʱ() --ledofftimeָʾϨʱ() --usersckconnectûsocketǷϺ̨ -local ledstate,ledontime,ledofftime,usersckconnect = "INIT",0,0 +--userscksslconnectûsocketǷϺ̨ +local ledstate,ledontime,ledofftime,usersckconnect,userscksslconnect = "INIT",0,0 --ledflgָʾƿ --ledpinָʾƿ --ledvalidֵƽָʾƣ1Ϊߣ0Ϊ @@ -609,7 +610,7 @@ end ֵ ]] function procled() - print("procled",ledflg,ledstate,flymode,usersckconnect,cgatt,state) + print("procled",ledflg,ledstate,flymode,usersckconnect,userscksslconnect,cgatt,state) --ָʾƹ if ledflg then local newstate,newontime,newofftime = "IDLE",ledidleon,ledidleoff @@ -619,7 +620,7 @@ function procled() elseif simerrsta then newstate,newontime,newofftime = "SIMERR",ledsimerron,ledsimerroff --ûsocketӵ˺̨ - elseif usersckconnect then + elseif usersckconnect or userscksslconnect then newstate,newontime,newofftime = "SCK",ledsckon,ledsckoff --GPRS elseif cgatt then @@ -651,6 +652,14 @@ local function usersckind(v) end end +local function userscksslind(v) + print("userscksslind",v) + if userscksslconnect~=v then + userscksslconnect = v + procled() + end +end + --[[ cgattind ڲϢNET_GPRS_READYĴ @@ -713,6 +722,7 @@ local procer = FLYMODE_IND = flyind, SYS_WORKMODE_IND = workmodeind, USER_SOCKET_CONNECT = usersckind, + USER_SOCKETSSL_CONNECT = userscksslind, NET_GPRS_READY = cgattind, CELL_INFO_IND = cellinfoind, } diff --git a/script/lib/sys.lua b/script/lib/sys.lua index e277ca7..8e20116 100644 --- a/script/lib/sys.lua +++ b/script/lib/sys.lua @@ -25,7 +25,7 @@ local assert = base.assert local tonumber = base.tonumber --libű汾ţֻҪlibеκһű޸ģҪ´˰汾 -SCRIPT_LIB_VER = "1.2.2" +SCRIPT_LIB_VER = "1.2.3" --Ƿű쳣ʱ űsys.restartӿʱ --Ƿйĵȴ¼ @@ -727,13 +727,13 @@ function setrestart(flg,tag) if flg and restartflg==0 and restartpending then restart("restartpending") end end -local msg,msgpara +local msg,msgpara,msgpara2 function saferun() --while true do --ڲϢ runqmsg() --ȡⲿϢ - msg,msgpara = rtos.receive(rtos.INF_TIMEOUT) + msg,msgpara,msgpara2 = rtos.receive(rtos.INF_TIMEOUT) --صΪ0%ûӦýűûж塰͵ػ򡱣ûԶػʱ if --[[not lprfun and ]]not lpring and type(msg) == "table" and msg.id == rtos.MSG_PMD and msg.level == 0 then @@ -781,7 +781,7 @@ function saferun() -- else if uartprocs[msgpara] ~= nil then - uartprocs[msgpara]() + uartprocs[msgpara](msgpara,msgpara2) else handlers[msg](msg,msgpara) end diff --git a/script/release notes.txt b/script/release notes.txt index 7854059..b3ff71e 100644 --- a/script/release notes.txt +++ b/script/release notes.txt @@ -1,485 +1,501 @@ -ʱ䣺2018/11/05 13:25 -޸ļ¼ - һlibű޸ - libű汾ţ1.2.2 - (1)updatehttp.lua޷ûԶurl - ҪԡҪ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣ʹóȻʹõǺĹٷurl - ʽ߼ - (2)sys.luasys.setRestoreӿڣýű쳣ʱǷԭʼд汾 - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵Զ°汾°汾﷨쳣ĬϻԶ˵ԭʼд汾ʹsys.setRestoreӿڿǷָ - (3)agpsupgpd.luaʹfloatܵlodʱagpsܻᵼgps쳣 - ҪԡҪ - Ӱģ顿Air800Air801 - ָʡ - ԭ򡿣floatlod£һĽСagps߼ - ʽԳȡ - (4)link.lualink.setTcpResendParaӿڣTCPشش - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵ʵʲԷ֣ijЩС⣬շʱ - ˰汾Luatű+0028lodĬϴش4Σÿ16룬һСݷ͵ʱ64룬ζŷʧܣϿٴ - ͻɸԼIJƷʹóô˽ӿȥã - ƷܴܽܺʱDzƵߣͿԵsetTcpResendPara(12,16)Ϊܵط - ƷҪܹٵĸ֪ͽԽƵߣͿԵsetTcpResendParaԼ - - - - -ʱ䣺2018/06/14 10:48 -޸ļ¼ - һlibű޸ - libű汾ţ1.2.1 - (1)lbsloc.luaѯγʧʱtraceϢĹ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵traceϢٵĶλѯγʧܵԭ - (2)ril.luaSNʶĸַ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡдSNаĸַȡSNʧ - ûĿʹSN򣬲пд˳ĸַµ˰汾 - ԭ򡿣ȡSNʱʶĸ - ʽȡʱʶַ - (3)link.lua,linkssl.luaŻյʱڴʹá - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡյʱԵڴ治 - ԭ򡿣յʱԭʹLua..ƴַ˷ʽᵼڴʹóɱ - ʽʹtable.concatƴַڴɱӵ - (4)aliyuniotauthssl.lua֤ʧʱһϢALIYUN_AUTH_ERROR֪ͨĹ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - (5)net.luaɾƶsimӪ̵mncĹܴʩĹ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣ƶmncűдȡƣȻֹܴʩһ¿һʹòŻ - ʽ8955ĵײlodѾmnc⣬ԽűҪܴʩ - (6)ril.lualink.luaơlink.setretrymodeӿڡĹܣĬΪܵ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵ݷʱTCPЭ㣺ԭĬϵԴΪ3ΣÿԵʱʱΪ8룻µĬֵΪԴΪ4ΣÿԵʱʱΪ16롣 - ӴԴͳʱʱ䣬绷̫õ£ݷ͵ijɹʡ绷Ϻõ£޸ĿԺԲ - demoű޸ - (1)apnapndemoʾAPN - - - - -ʱ䣺2018/06/11 16:20 -޸ļ¼ - һlibű޸ - libű汾ţ1.2.0 - (1)ntp.luaNTPNTPı˳ - ¹ҪԡҪ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵˼ѵĹNTPʹʱע⣺ - ntpģöѹNTPͬʱ䣬ܱ֤κʱκεص㶼ܰٷְͬȷʱ - ûĿеҵ߼ϸʱͬܣҪʹʹñģ飬ʹԼӦ÷ͬʱ - (2)link.luaƶĬAPNCMNET޸ΪCMIOT - ¹ҪԡҪ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵ûӳƶʹԭCMNET޷ʹCMIOT޸ΪCMIOT - (3)gps.luaagps.luagpsرպٴgpsgpsλ - ҪԡҪ - Ӱģ顿Air800 - ָʡ - ԭ򡿣ٴδGPSʱûдλúʱݵGPSоƬ޷GPSλ൱GPSоƬ붨λûЧ - ʽÿοGPSдϴιرǰλãվλûGPSλã͵ǰʱ - (4)http.luahttps.lua֧֡base64ϴļĹ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵οhttpdemo˵ - (5)sys.luaɾʹõcoreǷΪ°汾ж - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ˵ֻѵǰ°汾coreû;ֿɲҪţɾ˹ - (6)ril.luasocketʱ̫ӡǰ200ֽڵ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ˵Ƶʹʱӡǰ200ֽڵݣٴӡڴʱ - - - -ʱ䣺2018/05/16 14:00 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.9 - (1)http.luahttps.luarequest֮󣬻ص֮ǰdestroyӿڣһʱ﷨ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣request֮һ30Ķʱõclientdestroyʱ󣬵ûֹͣʱԶʱʱ䵽֮󣬵client - ʽdestroyʱرնʱ - (2)http.luahttps.luaresponseͷûContent-Lengthchunkʱ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣û - ʽӶԴĴرջ߳ʱ֮󣬵ûص - (3)http.luahttps.luagetstatusӿڹܴ󡱵 - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣ʵִ - ʽʵ - (4)http.luahttps.luaʧУdisconnectdestroyᵼ﷨ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣disconnectdestroyclient idûйرʱʱclient ididǷ﷨ - ʽdisconnectdestroyʱرʱ - (5)pins.luaderegӿ֮ٵregӿڣᵼ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ߸ - ԭ򡿣dereg֮regظʼѾregpinţ - ʽregظʼѾʼpin - (6)update.luaʧܣʱɾصͷļϵͳռ - (7)updatehttp.luaʧܣʱɾصͷļϵͳռ䣻ʧܣӡصʧϢ - (8)õ/Ĺܴ룬ָ֧lod¹쳣 - ҪԡҪ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡʹָ֧lod - ԭ򡿣֮ǰĽűlibǸݲָ֧lodƵģ3/2=1ʹָ֧lod3/2=1.5֧lod¾Ϳܹ쳣 - ʽa/bĴȫ޸Ϊ(a-(a%b))/b - (9)aliyuniotssl.luaMQTTͨĽӿsetMqtt - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵clean sessionwillkeep alive - demoű޸ - (1)gpio/gpio_setpullĹʾdemo - (2)õ/Ĺܴ룬ָ֧lod¹쳣 - (3)ʹuart.readĵطȥû壩 - (4)gpsNMEAݵĴӡ - (5)aliyun_ssl_huadong2ӡsetMqttӿڡĹʾ - - - - -ʱ䣺2018/04/24 18:34 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.8 - (1)nvm.luaӲʱдļļݳָĬֵ - ҪԡҪ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡʳ - ԭ򡿣дļʱӲ磬ɲļݳ´οʹòļ⵽󣬾ԶָΪĬֵ - ʽдļʱдһļУȻɾļļΪļ´οʼʱļͱļĸȷʹĸ - - - -ʱ䣺2018/04/02 22:42 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.7 - (1)aliyuniotsslauthӰƽ豸֤ʧܡ - ҪԡҪ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣42ոһκ̨ȥHTTPӦеһDZѡֶΣնѴֶε˱ѡֶ飬¼ʧ - ʽնټDZѡֶΡͬʱ밢ƵĹͨΪ˼Ѿ豸˷DZѡֶΡǻǿҽûlibű1.1.7ԱԺȥֶΣ³ͬ - demoű޸ - (1)call_recͨ¼demo - (2)demomain.luaжrequire"wdt"ע˵ - - - -ʱ䣺2018/02/26 15:44 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.6 - (1)linksslssl socketӵ£½һsslӣ֤ʧܡ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣sslӵ£һʼ־ΪTRUE˱־ᵼº֤޷ִеij - ʽ֤鵼빦ܺͳʼ־ٹ - (2)aliyuniototaOTA豸̼Ĺ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵ڰiot̨ϣοaliyun_ssl_huadong2demo˵ - demoű޸ - (1)aliyun_ssl_huadong2OTAܵʹ˵ - (2)proto_buffer"google proto bufferdemo"Ҫϴڵ0020汾lodʹ - (3)crypto"ļmd5ֵ"ʹ˵Ҫϴڵ0020汾lodʹ - (4)default޸ĹܣÿһΣuart1uart2дΪLuatATʾ - (5)httphttpshttphttpsdemoУȡݱ浽ļʱʧܣű - (6)crypto"aes.encryptaes.decrypt"ӿڵʹ˵Ҫϴڵ0020汾lodʹ - - - -ʱ䣺2018/02/12 00:21 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.5 - (1)http,httpsŻhttpݽ߼requestʱ֧ļַĻϷ - Ҫԡ΢ - Ӱģ顿Air202Air800Air801Air201Air208 - Żʽȥಿ֣ŻchunkݵĽʽ - (2)misccore V0016汾ʼmisc.setimeimisc.setsnӿڣûԶصдimeiдsnɹ󣬲Զ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208core V0016汾ʼд - ָʡ - ԭ򡿣coreV0016֮汾ŻļϵͳддIMEIдSN֮󣬲Ϳ԰ٷְٱ֤дɹ0015Լ֮ǰİ汾дIMEIдSN֮󣬱ܱ֤дɹԴV0016ʼûűmisc.setimeimisc.setsnӿ֮󣬱ΪsetimeisetsnĽӿڶ岻 - ʽűжϣcore V0016֮İ汾дimeiдsn֮ӿ֤豸 - (3)mqttmqttsslӶϿԶĹУԵ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡϵֻͣ绷dzȶkeepaliveʱ϶̣2ڣ£пܳ - ԭ򡿣һkeep aliveĶʱ3keep alive+ͨ쳣ûűûк쳣ӶϿûͣʱУܳʱ䶼ʧܣԺܶΣԵʱkeep aliveʱʱ䣬 - ʽӶϿ󣬹رkeep aliveʱ - (4)sysuart.setupΪжϽݺڵsys.reguart֮ǰuartյݣsys.reguart֮󣬻صԶղݡ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡ - ԭ򡿣uartжϽݵԭǣcoreжյݺ󣬻֪ͨűڽűreguart֮ǰղ֪ͨϢģӶcoreеĽһֱûбȡյݾͲԵ֪ͨϢű - ʽsys.reguartӿһûűԿƵreguartʱǷ֮ǰյݣպ󣬺յݾͿԽյˡcore V0019֮İ汾ʹ - (4)updatehttpͨHTTPGET֧ԶĹ - ¹Ҫԡһ - ¹Ӱģ顿Air202Air800Air801Air201Air208 - ¹˵HTTPϣնģͨHTTPGETԡֱʹLuatiotվߡûдHTTP֧GET - demoű޸ - (1)http,httpsrcvcbfileûжstatusȷԣֱʹ - (2)update_httpͨHTTPGETִܵʾdemo֧LuatûԽ - (3)uiļԶʧܡ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208core V0016汾ʼд - ָʡ - ԭ򡿣coreV0016֮汾ļϵͳеļ·ܳ31ֽڣԶ°汾ĽűԴļǴ洢ļϵͳеģԱҪļȣļ洢ʧܣҲʧܡűļ·/lua/XXX.luaļcolor_standard_spi_st7735.lua·Ϊ/lua/color_standard_spi_st7735.luaһ34ֽڣ31ֽڣԶͻʧܣԴļͼƬƵ֤ļȷLuaűļ·/ldata/XXX.yyy - ʽǼʱűļijȣ׺ܳ31-5(/lua/ij)=26ֽڣԴļijȣ׺ܳ31-7(/ldata/ij)=24ֽ - ʱļ׺һeԼʱĽűļȣ׺ܳ25ֽڣԴļijȣ׺ܳ23ֽ - - - -ʱ䣺2018/01/20 09:20 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.4 - (1)http,httpshttpʧʱͳɹdzʱûյκӦʱûͨص֪ͨûӦýű򡱵 - Ҫԡ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡʹõhttphttpsʱ쳣״̬(źŲվ)߸ʳ֣ʱѳ - ԭ򡿣쳣ʱʵ·ʧܻ߽ղӦݣִʱû֪ͨûűеĻصû֪˴Ӱ߼ - ʽʧʱһ"SEND"ûصsckerrcbУûյκӦݣ30볬ʱ󣬴3ûصrcvcbУʹ÷ʽοhttphttpsdemo - (2)agps,agpsupgpd쳣ʱagpsִжϣGPS򿪺ûбرգӶ𹦺ƫߡ - Ҫԡ - Ӱģ顿Air800Air801 - ָʡʹõagpsʱ쳣״̬(źŲվ)߸ʳ֣ʱѳ - ԭ򡿣agps֮ǰGPS쳣ʱʵ֮ͨųַʧܻ߽ղӦ쳣ִʱûйرGPSGPSһֱڿ״̬Ӷ𹦺ƫ - ʽɹ󣬲ȥGPSдGPSģУдɹ20볬ʱȥرGPS - (3)http,httpsյHTTPճʱ - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡʹõhttphttpsʱƵʣ21ʱ׳֣Ƶʷʱѳ - ԭ򡿣ƵʷʱLuat coreݸLuat scriptݳճʱscriptûãΪݷǷӶͨrcvcbش - ʽhttpͷϢеContent-LengthֵжϺbodyݣյݳֵֻȡֵָλá¸ѭм - (4)keypadkeypad.setupʱһnilʱpowerkey - Ҫԡһ - Ӱģ顿Air202Air800Air801Air201Air208 - ָʡʹõkeypadܡҵkeypad.setup,һnilpowerkeyֻҪͬʱЩ֣֮ - ԭ򡿣setupӿڣһnilʱkeypad.luaеġʱ䡱ΪnilڰpowerkeyʱʱһʱʱΪnil - ʽʱ䴫nilʱֵĬϵ3000 - (5)nvm߲ļдٶ - Ҫԡ΢ - Ӱģ顿Air202Air800Air801Air201Air208 - Żʽԭnvm.setӿڻдļ޸ĺֻдһΣɴЧ - demoű޸ - (1)http,httpsʾhttpʧʱͳɹdzʱûյκӦʱĴ쳣 - - - -ʱ䣺2018/01/17 22:23 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.3 - (1)linksslsslûca֤ʱ - (2)ril֧SSL - (3)nvmļУ쳣ϵ磬Եºһֱ - demoű޸ - (1)uiILI9341ICLCDʾ - (2)socket_ssl/long_connection_verify_server_and_clientsocket ssl˫֤ʾ - (3)https/verify_server_and_clienthttps˫֤ʾ - - - -ʱ䣺2018/01/03 18:32 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.2 - (1)http֧֡POSTԶContent-Lengthײ - (2)mqttssl֧tls1.2汾 - (3)https֧https - demoű޸ - (1)mqtt_sslʾαУ˵֤ - (2)httpsӰٶҳhttps://www.baidu.com,ʾhttpsʹ - - - -ʱ䣺2017/12/08 13:23 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.1 - (1)http֧֡httpӦbodyԶ浽ļ - demoű޸ - (1)http֧֡httpӦbodyԶ浽ļ - - -ʱ䣺2017/11/18 14:47 -޸ļ¼ - һlibű޸ - libű汾ţ1.1.0 - (1)httprequestʱԶheadʱ쳣 - (2)agpsظ1η - (3)agpsupgpdsocket idܺsocket idͻ - (4)mqttmqttsslunsubscribeȡĽӿ - demoű޸ - (1)socket_ssl淶ca֤ļĺ׺ - - - -ʱ䣺2017/10/29 16:33 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.9 - (1)audiottsʱµttsţµtts쳣 - (2)gpsagpsģ飬gps޷ - (3)sys1.0.71.0.8 libűгֵġԶĽűйд﷨ʱ޷Զ˵дԭʼű - (4)֧֡socketӳʱֱӵlink.shutرsocketӣȽرյǰӣȻԶֻжʧܣȥlink.shut - demoű޸ - (1)audioʾttsʱµttsšĹ - (2)i2cʾi2c.sendi2c.recvӿڵʹ - (3)socketsocket_ssl֧֡socketӳʱֱӵlink.shutرsocketӣȽرյǰӣȻԶֻжʧܣȥlink.shut - - - -ʱ䣺2017/9/18 16:49 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.8 - (1)smsԶƴӡ - (2)wdt޸ӲʹõĬ - (3)linksslmqttsslŻsslĿ߼ - (4)sysMODULE_TYPEõǿƼ - demoű޸ - (1)gpio_singleldogpioƵע˵ - (2)main.luaӶMODULE_TYPE - (3)uiSPIӿڵLCDʾܣ׼SPIšLCDרSPIšڰ - (4)spispidemo - (5)fsļϵͳʣռ䡢Ŀ¼Ĺʹʾ - - - -ʱ䣺2017/9/5 11:58 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.7 - (1)keypadpowerkeyĴ - (2)smsյijûԶƴӡ - (3)sysupdatedbgԶdbgϱУֹ﷨sys.restartӿڡܡ - (4)patch.lua·װjson.decodeӿڣdecodeķֵʹ÷ʽοjsondemo - (5)http.luachunkʱ󡱵 - (6)nvm.luatableͲֵǿձֵʱʧܡ - (7)mqtt.luamqttssl.lua֧֡ûԶ쳣򡱵Ĺ - demoű޸ - (1)default֧֡йгpower keyԶػ - (2)jsonjson.decodeӿӷֵʾ - (3)mqttmqttssl֧һĬϵ쳣 - (4)i2c淶 - (5)update<Ҫ.txt> - - - -ʱ䣺2017/8/18 10:31 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.6 - (1)uiwinisactivebug - (2)wdtsetupӿڣ֧Զι - demoű޸ - (1)adcע - (2)uiŻṹ - (3)crypto֧sha1hmac_sha1㷨 - (4)gpio_singleӵѹGPIOĿ˵ - (5)i2c淶i2c idΪ2֮ǰ0 - - - -ʱ䣺2017/8/8 13:40 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.5 - (1)miscopenpwmӿڵע˵ - demoű޸ - (1)aliyun_ssl_huadong2޸ProductKeyϢ֧ӲŹ - (2)mono_lcdƹ - (3)defaultȱһոIDEд󣬳﷨󡱵 - - - -ʱ䣺2017/7/26 11:19 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.4 - (1)net.luaƶPLMNFLPMNбе޷ע硱 - (2)mqtt.luamqttssl.lua - tmqtt:disconnectӿڶϿӺԶ - tmqtt:setcleansessionӿ - (3)aliyuniotssl.luaaliyuniotsslauth.luaְ֧ƻ2ڵ - (4)misc.lua֧pwm - demoű޸ - (1)socket_ssl\long_connectiondemoCA֤ļ - (2)fsʾļӿڵʹ - (3)format_stringʾݸʽתӿڵʹ - (4)uartuartɺ첽Ϣ֪ͨܵʹ˵ - (5)adcʾadcܵʹ˵ - (6)cryptoע - (7)mqttmqtt_sslʾtmqtt:setcleansessionӿڵʹ˵ - (8)aliyun_ssl_huadong2ְ֧ƻ2ڵ - (9)pwm֧pwm - - -ʱ䣺2017/7/7 11:44 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.3 - (1)link.luaӹ̺ݷ͹TCPЭĽӿsetretrymode - (2)mqtt.lua,mqttssl.luapublishӿ֧retain - - - -ʱ䣺2017/6/30 22:34 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.2 - (1)sys.luaײ汾ʱӡһ棬ϱϢdbg - (2)link.luaû˼ʧܻص󣬸Բִлص - (3)update.luaԻ - demoű޸ - (1)update\Luat_iot_server_daemondemo֧iot̨ԶԼϢϱ - - - -ʱ䣺2017/6/27 20:41 -޸ļ¼ - һlibű޸ - libű汾ţ1.0.1 - (1)sys.lua - dbgģ鲻ϱsys.restartԭֵ - ӿLuaڴԶٶ - (2)dbg.lua޸ӿڵʾǰ׺ - (3)link.lua - setiperrcbӿڣüIP糬ʱʧܺĻص - dbgģ顢updateģ顢ntpģûӦsocketʱijͻ - - - -ʱ䣺2017/5/31 13:17 -޸ļ¼ - һη \ No newline at end of file +发布时间:2019/01/22 17:45 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.2.3 + (1)sys.lua:新增“串口接收到新数据时,携带串口id和数据长度”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:所有模块 + 【新功能说明】:需要配合core 0031以及以上版本才能支持 + (2)linkssl.lua,net.lua:修正“ssl连接会导致net模块的网络指示灯工作不正常”的问题 + 【问题重要性】:一般 + 【问题影响模块】:所有模块 + 【问题出现概率】:必现 + + + + +发布时间:2018/11/05 13:25 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.2.2 + (1)updatehttp.lua:修正“无法设置用户自定义的url”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:变量使用出错,导致仍然使用的是合宙的官方url + 【问题解决方式】:修正逻辑错误 + (2)sys.lua:新增sys.setRestore接口,可设置脚本运行异常出错时是否回退原始烧写版本 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:远程升级新版本后,如果新版本出现运行语法异常,默认会自动回退到原始的烧写版本,使用sys.setRestore接口可设置是否恢复 + (3)agpsupgpd.lua:修正“使用float功能的lod时,agps功能会导致gps功能异常”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air800、Air801 + 【问题出现概率】:必现 + 【问题出现原因】:在float的lod下,有一个除法运算的结果变成小数,导致agps的逻辑出错 + 【问题解决方式】:对除法运算做取整操作 + (4)link.lua:新增link.setTcpResendPara接口,可设置TCP层的重传次数和重传间隔 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:经过实际测试发现,某些小区本身的网络有问题,数据收发存在延时; + 此版本的Luat脚本+0028的lod,默认处理是重传4次,每次最大间隔是16秒,如果在一个小区内数据发送的延时超过64秒,意味着发送失败,会主动断开连接再次重连 + 客户可根据自己的产品使用场景,调用此接口去灵活配置: + 如果产品能接受很大延时,但是不接受频繁掉线,就可以调用setTcpResendPara(12,16)设置为尽可能的重发 + 如果产品要求能够快速的感知发送结果,可以接受频繁掉线,就可以调用setTcpResendPara根据自己的需求进行设置 + + + + +发布时间:2018/06/14 10:48 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.2.1 + (1)lbsloc.lua:新增“查询经纬度失败时,在trace中输出错误描述信息”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:在trace中输出错误描述信息,方便快速的定位查询经纬度失败的原因 + (2)ril.lua:修正“SN区域不识别除字母和数字外的其他字符”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:如果写入的SN中包含除字母和数字外的其他字符,则读取SN失败 + 如果用户项目中使用了SN区域,并且有可能写入了除字母和数字外的其他字符,则必须更新到此版本 + 【问题出现原因】:读取SN时,仅识别字母和数字 + 【问题解决方式】:读取时,识别任意字符 + (3)link.lua,linkssl.lua:优化“连续接收到大量数据时的内存使用”功能 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:连续收到大量数据时,会概率性导致内存不足的问题 + 【问题出现原因】:连续收到大量数据时,原来使用Lua的..来拼接字符串,此方式会导致内存的使用成倍的增长 + 【问题解决方式】:使用table.concat来拼接字符串,不存在内存成倍增加的问题 + (4)aliyuniotauthssl.lua:新增“阿里云认证失败时,产生一个消息ALIYUN_AUTH_ERROR通知”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + (5)net.lua:删除“移动sim卡限制所属运营商的mnc的规避措施”的功能 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:极低 + 【问题出现原因】:如果移动卡限制了所属的正常mnc,则脚本会重新写卡取消限制,然后主动重启。这种规避措施,一般在新卡第一次使用才会出现 + 【问题解决方式】:8955的底层lod已经解决了限制正常mnc的问题,所以脚本不需要再做规避措施 + (6)ril.lua、link.lua:完善“link.setretrymode接口”的功能,默认设置为尽可能的重试 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:数据发送时,TCP协议层:原来默认的重试次数为3次,每次重试的最大超时时间为8秒;新的默认值改为重试次数为4次,每次重试的最大超时时间为16秒。 + 加大重试次数和超时时间,在网络环境不太好的情况下,会提高数据发送的成功率。对于网络环境较好的情况下,此修改可以忽略不计 + 二、demo脚本修改 + (1)apn:新增apn的demo,演示如何设置APN + + + + +发布时间:2018/06/11 16:20 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.2.0 + (1)ntp.lua:增加NTP服务器,调整NTP服务器的遍历顺序 + 【新功能重要性】:重要 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:增加了几个免费的公共NTP服务器,使用时注意: + ntp功能模块采用多个免费公共的NTP服务器来同步时间,不能保证任何时间任何地点都能百分百同步到正确的时间 + 如果用户项目中的业务逻辑严格依赖于时间同步功能,则不要使用使用本功能模块,建议使用自己的应用服务器来同步时间 + (2)link.lua:移动卡默认APN由CMNET修改为CMIOT + 【新功能重要性】:重要 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:有用户反映,移动物联网卡,使用原来的CMNET,可能无法正常上网,使用CMIOT正常,所以修改为CMIOT + (3)gps.lua、agps.lua:修正“gps关闭后,再打开gps,gps定位慢”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air800 + 【问题出现概率】:必现 + 【问题出现原因】:再次打开GPS时,没有写入位置和时间数据到GPS芯片,就无法加速GPS定位,相当于GPS芯片的秒定位功能没有生效 + 【问题解决方式】:每次开启GPS,都写入上次关闭前的位置(基站位置或者GPS位置)和当前的时间数据 + (4)http.lua,https.lua:支持“以base64编码上传文件”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:参考http的demo说明 + (5)sys.lua:删除“检查使用的core是否为最新版本”的判断 + 【功能重要性】:一般 + 【功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【功能说明】:这个功能只是提醒当前有新版本的core,并没有其他用途;会给部分开发者造成不必要的困扰,故删除此功能 + (6)ril.lua:socket发送数据时,如果数据太长,仅打印前200字节的数据 + 【功能重要性】:一般 + 【功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【功能说明】:频繁发送大量数据时,仅仅打印前200字节的数据,减少打印对内存和时间的消耗 + + + +发布时间:2018/05/16 14:00 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.9 + (1)http.lua,https.lua:修正“request之后,回调函数之前,调用destroy接口,过一段时间会出现语法错误重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:request之后有一个30秒的定时器会用到client对象,destroy时销毁了这个对象,但是没有停止定时器,所以定时器时间到之后,调用client对象出错 + 【问题解决方式】:destroy时关闭定时器 + (2)http.lua,https.lua:修正“response的头中没有Content-Length和chunk编码时,解析出错”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:代码中没处理这种情况 + 【问题解决方式】:添加对此种情况的处理,服务器关闭或者超时之后,调用用户回调 + (3)http.lua,https.lua:修正“getstatus接口功能错误”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:代码实现错误 + 【问题解决方式】:重新实现 + (4)http.lua,https.lua:修正“连接失败重连过程中,如果调用了disconnect和destroy,会导致重连代码语法错误重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:disconnect和destroy销毁了client id,但是没有关闭重连定时器,重连定时器会引用client id,id非法导致语法错误 + 【问题解决方式】:disconnect和destroy时关闭重连定时器 + (5)pins.lua:修正“调用dereg接口之后,再调用reg接口,会导致重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:高概率 + 【问题出现原因】:dereg之后,再重新reg,会重复初始化所有已经reg过的pin脚,引起重启 + 【问题解决方式】:reg不再重复初始化已经初始化pin脚 + (6)update.lua:如果升级包下载失败,及时删除已下载的升级包,释放文件系统空间 + (7)updatehttp.lua:如果升级包下载失败,及时删除已下载的升级包,释放文件系统空间;如果升级失败,打印出来服务器返回的升级失败信息 + (8)修正“所有用到除法/的功能代码,在支持浮点数的lod下工作异常”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:使用支持浮点数的lod,必现 + 【问题出现原因】:之前的脚本lib是根据不支持浮点数的lod设计的,例如3/2=1;但是如果使用支持浮点数的lod,3/2=1.5,所以在支付浮点数的lod下就可能工作异常了 + 【问题解决方式】:a/b的代码全部修改为(a-(a%b))/b + (9)aliyuniotssl.lua:新增“设置MQTT数据通道参数”的接口setMqtt + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:可以设置clean session、will、keep alive参数 + 二、demo脚本修改 + (1)gpio/gpio_setpull:新增配置上下拉的功能演示demo + (2)修正“所有用到除法/的功能代码,在支持浮点数的lod下工作异常”的问题 + (3)所有使用uart.read的地方,去掉第三个参数(第三个参数没有意义) + (4)gps:增加NMEA数据的打印输出 + (5)aliyun_ssl_huadong2:增加“setMqtt接口”的功能演示代码 + + + + +发布时间:2018/04/24 18:34 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.8 + (1)nvm.lua:修正“硬件掉电时,如果正在写参数文件,可能造成文件内容出错,恢复成默认值”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:概率出现 + 【问题出现原因】:写文件时,如果硬件掉电,可能造成参数文件内容出错,下次开机使用参数文件,检测到错误,就自动恢复为默认值 + 【问题解决方式】:写文件时,先写到一个备份文件中,然后删除参数文件,备份文件改名为参数文件。下次开机初始化时,会检查参数文件和备份文件,哪个正确使用哪个 + + + +发布时间:2018/04/02 22:42 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.7 + (1)aliyuniotsslauth:修正“连接阿里云进行设备认证失败”的问题 + 【问题重要性】:重要 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:阿里云在4月2日更新一次后台后,去掉了HTTP应答行中的一个非必选字段,但是终端软件把此字段当成了必选字段来检查,导致检查失败 + 【问题解决方式】:终端软件不再检查非必选字段。同时经过与阿里云的沟通,他们为了兼容我们已经量产的设备,重新添加了非必选字段。但是还是强烈建议用户升级lib脚本到1.1.7,以避免以后阿里云再去掉此字段,导致出现同样的问题 + 二、demo脚本修改 + (1)call_rec:新增通话中录音的demo + (2)完善所有demo的main.lua中对require"wdt"的注释说明 + + + +发布时间:2018/02/26 15:44 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.6 + (1)linkssl:修正“存在ssl socket连接的情况下,再新建一个ssl连接,新连接配置证书失败”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:存在ssl连接的情况下,有一个初始化标志设置为TRUE,此标志会导致后续的新连接证书无法执行导入的程序 + 【问题解决方式】:证书导入功能和初始化标志不再关联 + (2)aliyuniotota:新增“阿里云OTA(设备固件升级)”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:升级包放在阿里云iot控制台上,参考aliyun_ssl_huadong2的demo说明 + 二、demo脚本修改 + (1)aliyun_ssl_huadong2:新增阿里云OTA功能的使用说明 + (2)proto_buffer:新增"google proto buffer编解码测试demo",需要配合大于等于0020版本的lod使用 + (3)crypto:新增"计算文件的md5值"的使用说明,需要配合大于等于0020版本的lod使用 + (4)default:修改功能,每秒一次,uart1和uart2向外输出“烧写的软件为Luat软件,不是AT软件”的提示 + (5)http、https:修正“http和https的demo中,获取的数据保存到文件中时,如果保存失败,脚本重启”的问题 + (6)crypto:新增"aes.encrypt和aes.decrypt"接口的使用说明,需要配合大于等于0020版本的lod使用 + + + +发布时间:2018/02/12 00:21 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.5 + (1)http,https:优化http数据接收逻辑;request时支持文件和字符串的混合发送 + 【重要性】:轻微 + 【影响模块】:Air202、Air800、Air801、Air201、Air208 + 【优化方式】:去除冗余部分,优化chunk传输数据的解析方式 + (2)misc:修正“core V0016版本开始,misc.setimei和misc.setsn接口,如果用户不传入自定义回调函数,写imei或者写sn成功后,不会自动重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208,从core V0016版本开始才有此问题 + 【问题出现概率】:必现 + 【问题出现原因】:core从V0016之后版本,优化了文件系统读写操作,写IMEI和写SN之后,不用重启软件,就可以百分百保证写成功;但是0015以及之前的版本,写IMEI和写SN之后,必须重启才能保证写成功;所以从V0016开始,用户脚本调用misc.setimei和misc.setsn接口之后,表现为不再重启,与setimei和setsn的接口定义不符 + 【问题解决方式】:脚本主动判断,如果是core V0016之后的版本,写imei和写sn之后,主动调用重启接口来保证设备重启 + (3)mqtt、mqttssl:修正“连接断开后,在自动重连的过程中,概率性导致重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:较低,只有在网络环境非常不稳定,并且keepalive时间较短(例如2分钟以内)的情况下,才有可能出现 + 【问题出现原因】:有一个“keep alive的定时器,如果3倍keep alive+半分钟与服务器通信异常,并且用户脚本没有函数处理这种异常,则会重启”,连接断开后,没有停掉这个定时器,在重连过程中,如果很长时间都连接失败,会重试很多次,这个重试的时间如果超过keep alive定时器时间,则引起重启 + 【问题解决方式】:连接断开后,关闭keep alive定时器 + (4)sys:修正“调用uart.setup配置为中断接收数据后,在调用sys.reguart之前,uart收到了数据,调用sys.reguart之后,回调函数永远收不到数据”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:必现 + 【问题出现原因】:uart中断接收数据的原理是:core中断收到数据后,会通知脚本,在脚本reguart之前,是收不到这个通知消息的,从而导致core中的接收数据一直没有被读取,后续才收到数据就不会产生性的通知消息到脚本 + 【问题解决方式】:sys.reguart接口增加一个参数,用户脚本可以控制调用reguart时,是否清空之前接收的数据,清空后,后续收到的数据就可以接收到了。必须配合core V0019之后的版本使用 + (4)updatehttp:新增“通过HTTP的GET命令下载升级包,支持远程升级”的功能 + 【新功能重要性】:一般 + 【新功能影响模块】:Air202、Air800、Air801、Air201、Air208 + 【新功能说明】:升级包放在HTTP服务器上,终端模块通过HTTP的GET命令下载升级包。可以“直接使用Luat的iot网站配置升级”,或者“用户自行搭建HTTP服务器,支持GET命令下载升级包” + 二、demo脚本修改 + (1)http,https:修正“rcvcbfile函数中没有判断status的正确性,直接使用其他参数,可能引起重启”的问题 + (2)update_http:新增通过HTTP的GET命令执行升级功能的演示demo,支持Luat服务器和用户自建服务器升级 + (3)ui:修正“文件名过长导致远程升级失败”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208,从core V0016版本开始才有此问题 + 【问题出现概率】:必现 + 【问题出现原因】:core从V0016之后版本,文件系统中的完整文件路径不能超过31字节,远程升级后新版本的脚本和资源文件,是存储在文件系统中的,所以必须要限制文件名长度,否则文件存储失败,升级也就失败。脚本文件的完整路径是/lua/XXX.lua,例如文件color_standard_spi_st7735.lua的完整路径为/lua/color_standard_spi_st7735.lua,一共34字节,超过了31字节,所以远程升级就会失败;资源文件(例如图片、音频、证书文件等非Lua脚本文件)的完整路径是/ldata/XXX.yyy + 【问题解决方式】:非加密升级时:脚本文件名的长度(包括后缀)不能超过31-5(/lua/的长度)=26字节,资源文件名的长度(包括后缀)不能超过31-7(/ldata/的长度)=24字节 + 加密升级时:文件后缀会添加一个e,所以加密升级时的脚本文件名长度(包括后缀)不能超过25字节,资源文件名的长度(包括后缀)不能超过23字节 + + + +发布时间:2018/01/20 09:20 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.4 + (1)http,https:修正“http请求发送失败时,或者请求发送成功,但是超时没收到任何应答时,没有通过回调函数通知用户应用脚本程序”的问题 + 【问题重要性】:严重 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:使用到http或者https功能时,在网络异常状态下(例如信号差,基站容量饱和),会高概率出现;网络正常时,很难出现 + 【问题出现原因】:在网络异常时,会概率导致发送失败或者接收不到应答数据,出现此问题时,没有通知到用户脚本中的回调函数,导致用户不知道出现了错误,影响后续逻辑处理 + 【问题解决方式】:请求发送失败时,传入一个"SEND"参数到用户回调sckerrcb中;没有收到任何应答数据,30秒超时后,传入错误码3到用户回调rcvcb中;使用方式参考http和https的demo + (2)agps,agpsupgpd:修正“网络异常时,agps功能执行中断,导致GPS被打开后没有被关闭,从而引起功耗偏高”的问题 + 【问题重要性】:严重 + 【问题影响模块】:Air800、Air801 + 【问题出现概率】:使用到agps功能时,在网络异常状态下(例如信号差,基站容量饱和),会高概率出现;网络正常时,很难出现 + 【问题出现原因】:连接agps星历服务器之前,会打开GPS;在网络异常时,会概率导致与星历服务器之间的通信出现发送失败或者接收不到应答数据异常,出现此问题时,没有关闭GPS,导致GPS一直处于开启状态,从而引起功耗偏高 + 【问题解决方式】:从星历服务器成功下载星历后,才去打开GPS,写星历到GPS模块中,写成功或者20秒超时都会去关闭GPS + (3)http,https:修正“收到多个HTTP报文粘包时,解析出错”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:使用到http或者https功能时,当服务器高频率(例如至少2秒以内1个包)发送数据时,容易出现;低频率发送时,很难出现 + 【问题出现原因】:服务器高频率发送时,从Luat core传递给Luat script的数据出现了粘包,此时script没处理好,就认为数据非法,从而通过rcvcb返回错误 + 【问题解决方式】:根据http头信息中的Content-Length值,判断后续body数据内容,如果收到的数据超过了这个值,只获取到此值指定的位置。后续数据在下个循环中继续解析处理 + (4)keypad:修正“调用keypad.setup时第一个参数传入nil时,按下powerkey键会重启”的问题 + 【问题重要性】:一般 + 【问题影响模块】:Air202、Air800、Air801、Air201、Air208 + 【问题出现概率】:使用到keypad功能、并且调用了keypad.setup,第一个参数传入了nil,当按下powerkey键会重启。只要同时满足这些条件,此问题必现;反之不出现 + 【问题出现原因】:调用setup接口,第一个参数传入nil时,把keypad.lua中的“长按键时间”变量设置为了nil,在按下powerkey键时,会用这个长按键时间启动一个定时器,这个时间为nil,所以重启 + 【问题解决方式】:长按键时间传入nil时,赋值默认的3000毫秒 + (5)nvm:提高参数文件的写入速度 + 【重要性】:轻微 + 【影响模块】:Air202、Air800、Air801、Air201、Air208 + 【优化方式】:原来nvm.set接口会写多次文件,修改后只写一次,可大大提高效率 + 二、demo脚本修改 + (1)http,https:演示“http请求发送失败时,或者请求发送成功,但是超时没收到任何应答时”的错误异常处理 + + + +发布时间:2018/01/17 22:23 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.3 + (1)linkssl:修正“ssl连接没有配置ca证书时会重启”的问题 + (2)ril:支持SSL多连接 + (3)nvm:修正“保存参数文件过程中,如果异常断电,会概率性导致后续开机一直重启”的问题 + 二、demo脚本修改 + (1)ui:新增ILI9341驱动IC的LCD示例 + (2)socket_ssl/long_connection_verify_server_and_client:新增socket ssl双向认证的示例 + (3)https/verify_server_and_client:新增https双向认证的示例 + + + +发布时间:2018/01/03 18:32 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.2 + (1)http:支持“POST”方法,自动添加Content-Length首部 + (2)mqttssl:支持tls1.2版本 + (3)https:支持https + 二、demo脚本修改 + (1)mqtt_ssl:演示如何编码校验服务器端的证书 + (2)https:连接百度主页https://www.baidu.com,演示https的使用 + + + +发布时间:2017/12/08 13:23 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.1 + (1)http:支持“http应答body自动保存到文件”功能 + 二、demo脚本修改 + (1)http:支持“http应答body自动保存到文件”功能 + + +发布时间:2017/11/18 14:47 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.1.0 + (1)http:修正“request时存在自定义head时异常重启”的问题 + (2)agps:修正“开机会重复连接1次服务器”的问题 + (3)agpsupgpd:修正“连接星历服务器的socket id可能和其他socket id冲突”的问题 + (4)mqtt、mqttssl:新增unsubscribe取消订阅主题的接口 + 二、demo脚本修改 + (1)socket_ssl:规范ca证书文件的后缀名 + + + +发布时间:2017/10/29 16:33 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.9 + (1)audio:修正“tts播放时,请求新的tts播放,新的tts播放异常”的问题 + (2)gps:修正“不加载agps模块,gps无法正常工作”的问题 + (3)sys:修正1.0.7和1.0.8 lib脚本中出现的“远程升级的脚本运行过程中存在语法错误时,无法自动回退到烧写的原始脚本”的问题 + (4)支持“单个socket连接出错时,不再直接调用link.shut关闭所有socket连接,先仅关闭当前出错的连接,然后自动重连,只有多次重连连续失败,才去调用link.shut” + 二、demo脚本修改 + (1)audio:演示“tts播放时,请求新的tts播放”的功能 + (2)i2c:演示“i2c.send和i2c.recv”接口的使用 + (3)socket、socket_ssl:支持“单个socket连接出错时,不再直接调用link.shut关闭所有socket连接,先仅关闭当前出错的连接,然后自动重连,只有多次重连连续失败,才去调用link.shut” + + + +发布时间:2017/9/18 16:49 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.8 + (1)sms:修正“长短信自动拼接”的问题 + (2)wdt:修改硬件狗使用的默认引脚 + (3)linkssl、mqttssl:优化ssl的控制逻辑 + (4)sys:新增对MODULE_TYPE配置的强制检查 + 二、demo脚本修改 + (1)gpio_single:修正ldo对gpio控制的注释说明 + (2)所有main.lua中增加对MODULE_TYPE的配置 + (3)ui:完善SPI接口的LCD显示功能(标准SPI引脚、LCD专用SPI引脚、黑白屏、彩屏) + (4)spi:新增spi的demo + (5)fs:新增文件系统剩余空间、创建目录的功能使用示例 + + + +发布时间:2017/9/5 11:58 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.7 + (1)keypad:新增powerkey按键的处理功能 + (2)sms:修正“收到的长短信没有自动拼接”的问题 + (3)sys、update、dbg:新增“远程升级或者dbg上报过程中,禁止“语法错误或者sys.restart接口”的重启功能” + (4)patch.lua:重新封装json.decode接口,增加decode的返回值。使用方式参考json的demo + (5)http.lua:修正“chunk传输数据时解包错误”的问题 + (6)nvm.lua:修正“table类型参数如果旧值是空表,设置新值时失败”的问题 + (7)mqtt.lua、mqttssl.lua:支持“用户自定义异常处理程序”的功能 + 二、demo脚本修改 + (1)default:支持“开机运行过程中长按power key按键,自动关机”功能 + (2)json:json.decode接口增加返回值表示解析结果 + (3)mqtt、mqttssl:支持一种默认的异常处理程序 + (4)i2c:规范代码 + (5)update:添加<重要提醒.txt> + + + +发布时间:2017/8/18 10:31 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.6 + (1)uiwin:修正isactive的bug + (2)wdt:新增setup接口,支持自定义喂狗引脚 + 二、demo脚本修改 + (1)adc:完善注释 + (2)ui:优化代码结构 + (3)crypto:支持sha1和hmac_sha1算法 + (4)gpio_single:添加电压域对GPIO的控制说明 + (5)i2c:规范i2c id为2,兼容之前的0 + + + +发布时间:2017/8/8 13:40 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.5 + (1)misc:修正openpwm接口的注释说明 + 二、demo脚本修改 + (1)aliyun_ssl_huadong2:修改ProductKey信息,软件上支持硬件看门狗 + (2)mono_lcd:完善功能 + (3)default:修正“由于缺少一个空格,IDE烧写后,出现语法错误”的问题 + + + +发布时间:2017/7/26 11:19 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.4 + (1)net.lua:修正“移动PLMN被放入FLPMN列表中导致无法注册网络”的问题 + (2)mqtt.lua、mqttssl.lua: + 修正“tmqtt:disconnect接口断开连接后,又自动重连”的问题 + 新增tmqtt:setcleansession接口 + (3)aliyuniotssl.lua、aliyuniotsslauth.lua:支持阿里云华东2节点 + (4)misc.lua:支持pwm输出功能 + 二、demo脚本修改 + (1)socket_ssl\long_connection的demo:更换服务器CA证书文件 + (2)新增fs:演示文件操作接口的使用 + (3)新增format_string:演示数据格式转换接口的使用 + (4)uart:新增“uart发送数据完成后,异步消息通知”功能的使用说明 + (5)新增adc:演示adc功能的使用说明 + (6)crypto:完善注释 + (7)mqtt、mqtt_ssl:演示tmqtt:setcleansession接口的使用说明 + (8)新增aliyun_ssl_huadong2:支持阿里云华东2节点 + (9)新增pwm:支持pwm输出功能 + + +发布时间:2017/7/7 11:44 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.3 + (1)link.lua:新增“设置连接过程和数据发送过程中TCP协议的重连参数”的接口setretrymode + (2)mqtt.lua,mqttssl.lua:publish接口支持retain参数的设置 + + + +发布时间:2017/6/30 22:34 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.2 + (1)sys.lua:底层版本不是最新时,仅打印一个警告,不再上报错误信息到dbg服务器 + (2)link.lua:修正“用户设置了激活数据网络失败回调函数后,概率性不会执行回调”的问题 + (3)update.lua:完善重试机制 + 二、demo脚本修改 + (1)新增update\Luat_iot_server_daemon的demo:支持iot后台的远程升级以及调试信息上报功能 + + + +发布时间:2017/6/27 20:41 +修改记录: + 一、lib脚本修改 + lib脚本版本号:1.0.1 + (1)sys.lua: + 修正“dbg模块不能上报sys.restart原因值”的问题 + 加快Lua内存自动回收速度 + (2)dbg.lua:修改重启接口的提示前缀 + (3)link.lua: + 新增setiperrcb接口,可设置激活IP数据网络超时失败后的回调函数 + 修正“dbg模块、update模块、ntp模块和用户应用socket重连时”的冲突问题 + + + +发布时间:2017/5/31 13:17 +修改记录: + 第一次发布 \ No newline at end of file diff --git a/script_LuaTask/demo/Air168/main.lua b/script_LuaTask/demo/Air168/main.lua index 7d535fb..5af15dd 100644 --- a/script_LuaTask/demo/Air168/main.lua +++ b/script_LuaTask/demo/Air168/main.lua @@ -60,7 +60,6 @@ require"color_lcd_spi_st7735l" require"testCamera" require"keypad" require"windows" - --启动系统框架 sys.init(0, 0) sys.run() diff --git a/script_LuaTask/demo/console/main.lua b/script_LuaTask/demo/console/main.lua index d4fc5d0..d57dad9 100644 --- a/script_LuaTask/demo/console/main.lua +++ b/script_LuaTask/demo/console/main.lua @@ -46,17 +46,17 @@ 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/crypto/testCrypto.lua b/script_LuaTask/demo/crypto/testCrypto.lua index a3854af..3cdd57d 100644 --- a/script_LuaTask/demo/crypto/testCrypto.lua +++ b/script_LuaTask/demo/crypto/testCrypto.lua @@ -105,6 +105,15 @@ local function sha256Test() end end +local function hmacSha256Test() + if type(crypto.hmac_sha256)=="function" then + local originStr = "asdasdsadasweqcdsjghjvcb" + local signKey = "12345689012345" + log.info("testCrypto.hmac_sha256",crypto.hmac_sha256(originStr,signKey)) + end +end + + --- crc算法测试 -- @return 无 -- @usage crcTest() @@ -337,6 +346,7 @@ local function test() crcTest() aesTest() flowMd5Test() + hmacSha256Test() --xxtea 需要lod打开支持 xxteaTest() end diff --git a/script_LuaTask/demo/gps/readme.txt b/script_LuaTask/demo/gps/readme.txt new file mode 100644 index 0000000..fdf5876 --- /dev/null +++ b/script_LuaTask/demo/gps/readme.txt @@ -0,0 +1 @@ +v1v2gpsʹ÷ʽԼĿ󣬲οlib apiĵdemoѡʹúַʽ \ No newline at end of file diff --git a/script_LuaTask/demo/gps/main.lua b/script_LuaTask/demo/gps/v1/main.lua similarity index 100% rename from script_LuaTask/demo/gps/main.lua rename to script_LuaTask/demo/gps/v1/main.lua diff --git a/script_LuaTask/demo/gps/testGps.lua b/script_LuaTask/demo/gps/v1/testGps.lua similarity index 100% rename from script_LuaTask/demo/gps/testGps.lua rename to script_LuaTask/demo/gps/v1/testGps.lua diff --git a/script_LuaTask/demo/gpsv2/main.lua b/script_LuaTask/demo/gps/v2/main.lua similarity index 100% rename from script_LuaTask/demo/gpsv2/main.lua rename to script_LuaTask/demo/gps/v2/main.lua diff --git a/script_LuaTask/demo/gpsv2/testGps.lua b/script_LuaTask/demo/gps/v2/testGps.lua similarity index 100% rename from script_LuaTask/demo/gpsv2/testGps.lua rename to script_LuaTask/demo/gps/v2/testGps.lua diff --git a/script_LuaTask/demo/i2c/testI2c.lua b/script_LuaTask/demo/i2c/testI2c.lua index 412d368..4d6ac02 100644 --- a/script_LuaTask/demo/i2c/testI2c.lua +++ b/script_LuaTask/demo/i2c/testI2c.lua @@ -76,6 +76,11 @@ local function init1() end end +--如下一行代码,表示是否启用i2c id复用功能,0表示不启用,1表示启用,默认启用 +--如果启用了i2c id复用功能,i2c id 0和2都表示i2c3 +--如果不启用i2c id复用功能,i2c id 0、1、2分别表示i2c1、i2c2、i2c3 +--仅0033以及以后的core才支持“此复用功能设置”以及“i2c1和i2c2的功能” +--i2c.set_id_dup(0) --init和init1接口演示了两套i2c软件接口的使用方式 --init() init1() diff --git a/script_LuaTask/demo/mqtt/sync/readme.txt b/script_LuaTask/demo/mqtt/sync/readme.txt new file mode 100644 index 0000000..9aa161a --- /dev/null +++ b/script_LuaTask/demo/mqtt/sync/readme.txt @@ -0,0 +1,2 @@ +sendWaitRecvʱݣҪȵݳʱյݲŻݷͳȥ +sendInterruptRecvʱpublishϢжݽյ \ No newline at end of file diff --git a/script_LuaTask/demo/testMqtt/main.lua b/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/main.lua similarity index 100% rename from script_LuaTask/demo/testMqtt/main.lua rename to script_LuaTask/demo/mqtt/sync/sendInterruptRecv/main.lua diff --git a/script_LuaTask/demo/testMqtt/testMqtt.lua b/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua similarity index 89% rename from script_LuaTask/demo/testMqtt/testMqtt.lua rename to script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua index 0cc8cdd..fe0238d 100644 --- a/script_LuaTask/demo/testMqtt/testMqtt.lua +++ b/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua @@ -12,9 +12,9 @@ local host, port = "lbsmqtt.airm2m.com", 1884 -- 测试MQTT的任务代码 sys.taskInit(function() - while not socket.isReady() do sys.wait(1000) end - local mqttc = mqtt.client(misc.getImei(), 300, "user", "password") while true do + while not socket.isReady() do sys.wait(1000) end + local mqttc = mqtt.client(misc.getImei(), 300, "user", "password") while not mqttc:connect(host, port) do sys.wait(2000) end if mqttc:subscribe(string.format("/device/%s/req", misc.getImei())) then if mqttc:publish(string.format("/device/%s/report", misc.getImei()), "test publish " .. os.time()) then @@ -28,6 +28,8 @@ sys.taskInit(function() elseif data == "timeout" then log.info("这是等待超时主动上报数据的显示!") mqttc:publish(string.format("/device/%s/report", misc.getImei()), "test publish " .. os.time()) + else + break end end end diff --git a/script_LuaTask/demo/mqtt/ca.crt b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/ca.crt similarity index 100% rename from script_LuaTask/demo/mqtt/ca.crt rename to script_LuaTask/demo/mqtt/sync/sendWaitRecv/ca.crt diff --git a/script_LuaTask/demo/mqtt/main.lua b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/main.lua similarity index 100% rename from script_LuaTask/demo/mqtt/main.lua rename to script_LuaTask/demo/mqtt/sync/sendWaitRecv/main.lua diff --git a/script_LuaTask/demo/mqtt/mqttInMsg.lua b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttInMsg.lua similarity index 100% rename from script_LuaTask/demo/mqtt/mqttInMsg.lua rename to script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttInMsg.lua diff --git a/script_LuaTask/demo/mqtt/mqttOutMsg.lua b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttOutMsg.lua similarity index 100% rename from script_LuaTask/demo/mqtt/mqttOutMsg.lua rename to script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttOutMsg.lua diff --git a/script_LuaTask/demo/mqtt/mqttTask.lua b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua similarity index 100% rename from script_LuaTask/demo/mqtt/mqttTask.lua rename to script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua diff --git a/script_LuaTask/demo/asyncSocket/main.lua b/script_LuaTask/demo/socket/async/asyncSocket/main.lua similarity index 100% rename from script_LuaTask/demo/asyncSocket/main.lua rename to script_LuaTask/demo/socket/async/asyncSocket/main.lua diff --git a/script_LuaTask/demo/asyncSocket/testSocket.lua b/script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua similarity index 100% rename from script_LuaTask/demo/asyncSocket/testSocket.lua rename to script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua diff --git a/script_LuaTask/demo/asyncSocketCallback/main.lua b/script_LuaTask/demo/socket/async/asyncSocketCallback/main.lua similarity index 100% rename from script_LuaTask/demo/asyncSocketCallback/main.lua rename to script_LuaTask/demo/socket/async/asyncSocketCallback/main.lua diff --git a/script_LuaTask/demo/asyncSocketCallback/testSocket.lua b/script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua similarity index 100% rename from script_LuaTask/demo/asyncSocketCallback/testSocket.lua rename to script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua diff --git a/script_LuaTask/demo/socket/readme.txt b/script_LuaTask/demo/socket/readme.txt new file mode 100644 index 0000000..d68c87d --- /dev/null +++ b/script_LuaTask/demo/socket/readme.txt @@ -0,0 +1,2 @@ +async첽socket +syncͬsocket \ No newline at end of file diff --git a/script_LuaTask/demo/socket/sync/readme.txt b/script_LuaTask/demo/socket/sync/readme.txt new file mode 100644 index 0000000..9aa161a --- /dev/null +++ b/script_LuaTask/demo/socket/sync/readme.txt @@ -0,0 +1,2 @@ +sendWaitRecvʱݣҪȵݳʱյݲŻݷͳȥ +sendInterruptRecvʱpublishϢжݽյ \ No newline at end of file diff --git a/script_LuaTask/demo/testSocket/main.lua b/script_LuaTask/demo/socket/sync/sendInterruptRecv/main.lua similarity index 100% rename from script_LuaTask/demo/testSocket/main.lua rename to script_LuaTask/demo/socket/sync/sendInterruptRecv/main.lua diff --git a/script_LuaTask/demo/testSocket/testSocket.lua b/script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua similarity index 100% rename from script_LuaTask/demo/testSocket/testSocket.lua rename to script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua diff --git a/script_LuaTask/demo/socket/longConnection/main.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/main.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnection/main.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/main.lua diff --git a/script_LuaTask/demo/socket/longConnection/socketInMsg.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketInMsg.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnection/socketInMsg.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketInMsg.lua diff --git a/script_LuaTask/demo/socket/longConnection/socketOutMsg.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketOutMsg.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnection/socketOutMsg.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketOutMsg.lua diff --git a/script_LuaTask/demo/socket/longConnection/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnection/socketTask.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua diff --git a/script_LuaTask/demo/socket/longConnectionTransparent/main.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/main.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnectionTransparent/main.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/main.lua diff --git a/script_LuaTask/demo/socket/longConnectionTransparent/mcuUart.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/mcuUart.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnectionTransparent/mcuUart.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/mcuUart.lua diff --git a/script_LuaTask/demo/socket/longConnectionTransparent/socketInMsg.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketInMsg.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnectionTransparent/socketInMsg.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketInMsg.lua diff --git a/script_LuaTask/demo/socket/longConnectionTransparent/socketOutMsg.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketOutMsg.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnectionTransparent/socketOutMsg.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketOutMsg.lua diff --git a/script_LuaTask/demo/socket/longConnectionTransparent/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua similarity index 100% rename from script_LuaTask/demo/socket/longConnectionTransparent/socketTask.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua diff --git a/script_LuaTask/demo/socket/shortConnection/main.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/main.lua similarity index 100% rename from script_LuaTask/demo/socket/shortConnection/main.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/main.lua diff --git a/script_LuaTask/demo/socket/shortConnection/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua similarity index 100% rename from script_LuaTask/demo/socket/shortConnection/socketTask.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua diff --git a/script_LuaTask/demo/socket/shortConnectionFlymode/main.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/main.lua similarity index 100% rename from script_LuaTask/demo/socket/shortConnectionFlymode/main.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/main.lua diff --git a/script_LuaTask/demo/socket/shortConnectionFlymode/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua similarity index 100% rename from script_LuaTask/demo/socket/shortConnectionFlymode/socketTask.lua rename to script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua diff --git a/script_LuaTask/demo/uart/main.lua b/script_LuaTask/demo/uart/v1/main.lua similarity index 100% rename from script_LuaTask/demo/uart/main.lua rename to script_LuaTask/demo/uart/v1/main.lua diff --git a/script_LuaTask/demo/uart/mcu101.bin b/script_LuaTask/demo/uart/v1/mcu101.bin similarity index 100% rename from script_LuaTask/demo/uart/mcu101.bin rename to script_LuaTask/demo/uart/v1/mcu101.bin diff --git a/script_LuaTask/demo/uart/testUart.lua b/script_LuaTask/demo/uart/v1/testUart.lua similarity index 100% rename from script_LuaTask/demo/uart/testUart.lua rename to script_LuaTask/demo/uart/v1/testUart.lua diff --git a/script_LuaTask/demo/uart/testUartSentFile.lua b/script_LuaTask/demo/uart/v1/testUartSentFile.lua similarity index 100% rename from script_LuaTask/demo/uart/testUartSentFile.lua rename to script_LuaTask/demo/uart/v1/testUartSentFile.lua diff --git a/script_LuaTask/demo/uart/testUartTask.lua b/script_LuaTask/demo/uart/v1/testUartTask.lua similarity index 100% rename from script_LuaTask/demo/uart/testUartTask.lua rename to script_LuaTask/demo/uart/v1/testUartTask.lua diff --git a/script_LuaTask/demo/uartv2/demo.lua b/script_LuaTask/demo/uart/v2/demo.lua similarity index 100% rename from script_LuaTask/demo/uartv2/demo.lua rename to script_LuaTask/demo/uart/v2/demo.lua diff --git a/script_LuaTask/demo/uartv2/main.lua b/script_LuaTask/demo/uart/v2/main.lua similarity index 100% rename from script_LuaTask/demo/uartv2/main.lua rename to script_LuaTask/demo/uart/v2/main.lua diff --git a/script_LuaTask/demo/uartv3/demo.lua b/script_LuaTask/demo/uart/v3/demo.lua similarity index 100% rename from script_LuaTask/demo/uartv3/demo.lua rename to script_LuaTask/demo/uart/v3/demo.lua diff --git a/script_LuaTask/demo/uartv3/main.lua b/script_LuaTask/demo/uart/v3/main.lua similarity index 100% rename from script_LuaTask/demo/uartv3/main.lua rename to script_LuaTask/demo/uart/v3/main.lua diff --git a/script_LuaTask/doc/lib/index.html b/script_LuaTask/doc/lib/index.html index d2c006f..7a8b319 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/aLiYun.html b/script_LuaTask/doc/lib/modules/aLiYun.html index 37cfece..bf91aaa 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/aLiYunOta.html b/script_LuaTask/doc/lib/modules/aLiYunOta.html index f238a94..d7c1118 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/agps.html b/script_LuaTask/doc/lib/modules/agps.html index 8a29d6b..9d7c6fd 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/audio.html b/script_LuaTask/doc/lib/modules/audio.html index 362e42a..fce95e3 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/cc.html b/script_LuaTask/doc/lib/modules/cc.html index 6bccb0c..b695e0f 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/clib.html b/script_LuaTask/doc/lib/modules/clib.html index cd12606..2b29db0 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/common.html b/script_LuaTask/doc/lib/modules/common.html index 8e964bf..32546ae 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/console.html b/script_LuaTask/doc/lib/modules/console.html index 095054d..19d6a73 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/errDump.html b/script_LuaTask/doc/lib/modules/errDump.html index 4f85cee..8af8b3c 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/gizwits.html b/script_LuaTask/doc/lib/modules/gizwits.html index b443229..8b01e8b 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/gps.html b/script_LuaTask/doc/lib/modules/gps.html index 658ce2c..29c4705 100644 --- a/script_LuaTask/doc/lib/modules/gps.html +++ b/script_LuaTask/doc/lib/modules/gps.html @@ -1286,7 +1286,7 @@

Fields

generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/gpsv2.html b/script_LuaTask/doc/lib/modules/gpsv2.html index 4a804da..a47cde5 100644 --- a/script_LuaTask/doc/lib/modules/gpsv2.html +++ b/script_LuaTask/doc/lib/modules/gpsv2.html @@ -297,6 +297,8 @@

Returns:

Usage:

@@ -926,7 +928,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/http.html b/script_LuaTask/doc/lib/modules/http.html index 55e2e67..b7fee68 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/httpv2.html b/script_LuaTask/doc/lib/modules/httpv2.html index be76612..11fa7f8 100644 --- a/script_LuaTask/doc/lib/modules/httpv2.html +++ b/script_LuaTask/doc/lib/modules/httpv2.html @@ -188,7 +188,7 @@

Usage:

generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
diff --git a/script_LuaTask/doc/lib/modules/lbsLoc.html b/script_LuaTask/doc/lib/modules/lbsLoc.html index 299d5dc..1ebef25 100644 --- a/script_LuaTask/doc/lib/modules/lbsLoc.html +++ b/script_LuaTask/doc/lib/modules/lbsLoc.html @@ -128,10 +128,21 @@

Parameters:

  • cbFnc function
    用户回调函数,回调函数的调用形式为:
    -              cbFnc(result,lat,lng,addr)
    -              result:number类型,0表示成功,1表示网络环境尚未就绪,2表示连接服务器失败,3表示发送数据失败,4表示接收服务器应答超时,5表示服务器返回查询失败;为0时,后面的3个参数才有意义
    +              cbFnc(result,lat,lng,addr,dateTime,locType)
    +              result:number类型
    +                      0表示成功
    +                      1表示网络环境尚未就绪
    +                      2表示连接服务器失败
    +                      3表示发送数据失败
    +                      4表示接收服务器应答超时
    +                      5表示服务器返回查询失败
    +                      6表示socket已满,创建socket失败
    +                      为0时,后面的5个参数才有意义
                   lat:string类型或者nil,纬度,整数部分3位,小数部分7位,例如"031.2425864"
    -              lng:string类型或者nil,经度,整数部分3位,小数部分7位,例如"121.4736522"
    + lng:string类型或者nil,经度,整数部分3位,小数部分7位,例如"121.4736522" + addr:无意义,保留使用 + dateTime:无意义,保留使用 + locType:string类型,位置类型,"LBS"表示基站定位位置,"WIFI"表示WIFI定位位置
  • reqAddr bool @@ -198,7 +209,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/led.html b/script_LuaTask/doc/lib/modules/led.html index 3b34c02..7cc9e9e 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/link.html b/script_LuaTask/doc/lib/modules/link.html index 64faa0e..a568b98 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/log.html b/script_LuaTask/doc/lib/modules/log.html index de5e754..234fb49 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/misc.html b/script_LuaTask/doc/lib/modules/misc.html index ff23966..5613a44 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/mqtt.html b/script_LuaTask/doc/lib/modules/mqtt.html index 0a1a27f..7ffad9b 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/net.html b/script_LuaTask/doc/lib/modules/net.html index f1e20b9..c4c95d3 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/netLed.html b/script_LuaTask/doc/lib/modules/netLed.html index b2c19cd..b02e59e 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/ntp.html b/script_LuaTask/doc/lib/modules/ntp.html index 43eb653..f3bcb2c 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/nvm.html b/script_LuaTask/doc/lib/modules/nvm.html index dcf3b9a..c2f148e 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/patch.html b/script_LuaTask/doc/lib/modules/patch.html index 2ed85a3..aaf0db3 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/pb.html b/script_LuaTask/doc/lib/modules/pb.html index 192a10f..baabe30 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/pins.html b/script_LuaTask/doc/lib/modules/pins.html index 0039c46..264b155 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/pm.html b/script_LuaTask/doc/lib/modules/pm.html index 41c0e7c..5cb0e87 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/powerKey.html b/script_LuaTask/doc/lib/modules/powerKey.html index 270f260..b3da67f 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/record.html b/script_LuaTask/doc/lib/modules/record.html index 7e58a4a..5fcf2cc 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/ril.html b/script_LuaTask/doc/lib/modules/ril.html index 1ca87ed..c8f0656 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/scanCode.html b/script_LuaTask/doc/lib/modules/scanCode.html index 2e35b86..4e257aa 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/sim.html b/script_LuaTask/doc/lib/modules/sim.html index 6e6d97e..a3a60f5 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/sms.html b/script_LuaTask/doc/lib/modules/sms.html index 0d7f8be..bf35df4 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/socket.html b/script_LuaTask/doc/lib/modules/socket.html index d47f316..aac4807 100644 --- a/script_LuaTask/doc/lib/modules/socket.html +++ b/script_LuaTask/doc/lib/modules/socket.html @@ -595,7 +595,7 @@

    Fields

    generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/sys.html b/script_LuaTask/doc/lib/modules/sys.html index c99e413..838c6ef 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/uiWin.html b/script_LuaTask/doc/lib/modules/uiWin.html index c6d2b7a..db6eedf 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/update.html b/script_LuaTask/doc/lib/modules/update.html index 8f3dc30..90778f9 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-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/utils.html b/script_LuaTask/doc/lib/modules/utils.html index 5e50c25..6d2f522 100644 --- a/script_LuaTask/doc/lib/modules/utils.html +++ b/script_LuaTask/doc/lib/modules/utils.html @@ -90,7 +90,7 @@

    Module utils

    Info:

    @@ -117,12 +117,36 @@

    Functions

    返回utf8编码字符串的长度 + + string.utf8ToTable (str) + + 返回utf8编码字符串的单个utf8字符的table + + + + string.rawurlEncode (str) + + 返回字符串的 RFC3986 编码 + + string.urlEncode (str) 返回字符串的urlEncode编码 + + table.gsort (t, f) + + 返回一个迭代器函数,每次调用函数都会返回hash表的排序后的键值对 + + + + table.rconcat (l) + + table.concat的增强版,支持嵌套字符串数组 + + string.formatNumberThousands (num) @@ -283,7 +307,72 @@

    Returns:

    Usage:

    + + +
    + + + string.utf8ToTable (str) + +
    +
    +
    返回utf8编码字符串的单个utf8字符的table
    + + +

    Parameters:

    +
      +
    • str + string +
      utf8编码的字符串,支持中文
      +
    • +
    + +

    Returns:

    +
      +
    • +
      table,utf8字符串的table
      +
    + + + +

    Usage:

    +
      +
    • local t = string.utf8ToTable("中国2018")
      +
    + +
    +
    + + + string.rawurlEncode (str) + +
    +
    +
    返回字符串的 RFC3986 编码
    + + +

    Parameters:

    +
      +
    • str + string +
      要转换编码的字符串,支持UTF8编码中文
      +
    • +
    + +

    Returns:

    +
      +
    • +
      str, RFC3986 编码的字符串
      +
    + + + +

    Usage:

    +
      +
    • local str = string.rawurlEncode("####133") ,str == "%23%23%23%23133"
      +
    • local str = string.rawurlEncode("中国2018") , str == "%e4%b8%ad%e5%9b%bd2018"
    @@ -301,7 +390,7 @@

    Parameters:

    @@ -315,7 +404,76 @@

    Returns:

    Usage:

    + + +
    + + + table.gsort (t, f) + +
    +
    +
    返回一个迭代器函数,每次调用函数都会返回hash表的排序后的键值对
    + + +

    Parameters:

    +
      +
    • t + table +
       要排序的hash表
      +
    • +
    • f +
       自定义排序函数
      +
    • +
    + +

    Returns:

    +
      +
    • +
      function.
      +
    + + + +

    Usage:

    +
      +
    • test = {a=1,f=9,d=2,c=8,b=5}
      +
    • for name,line in pairsByKeys(test) do print(name,line) end
      +
    + +
    +
    + + + table.rconcat (l) + +
    +
    +
    table.concat的增强版,支持嵌套字符串数组
    + + +

    Parameters:

    +
      +
    • l + table +
      嵌套字符串数组
      +
    • +
    + +

    Returns:

    +
      +
    • +
      string
      +
    + + + +

    Usage:

    +
      +
    • print(table.rconcat({"a",{" nice "}," and ", {{" long "},{" list "}}}))
    @@ -598,7 +756,7 @@

    Returns:

    generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/doc/lib/modules/wdt.html b/script_LuaTask/doc/lib/modules/wdt.html index 1b5d0cc..b858f4f 100644 --- a/script_LuaTask/doc/lib/modules/wdt.html +++ b/script_LuaTask/doc/lib/modules/wdt.html @@ -196,7 +196,7 @@

    Usage:

    generated by LDoc 1.4.6 -Last updated 2018-12-06 16:40:02 +Last updated 2019-01-22 18:03:27
    diff --git a/script_LuaTask/lib/agps.lua b/script_LuaTask/lib/agps.lua index d1e1b67..4bb3324 100644 --- a/script_LuaTask/lib/agps.lua +++ b/script_LuaTask/lib/agps.lua @@ -79,9 +79,9 @@ local function writeEphBegin() end local function downloadEphCb(result,prompt,head,body) - log.info("testHttp.cbFnc",result,prompt) + log.info("agps.downloadEphCb",result,prompt) runTimer() - if result and body then + if result and prompt=="200" and body then if gps.isFix() then io.writeFile(EPH_TIME_FILE,tostring(os.time())) else diff --git a/script_LuaTask/lib/console.lua b/script_LuaTask/lib/console.lua index 8404058..d0ee146 100644 --- a/script_LuaTask/lib/console.lua +++ b/script_LuaTask/lib/console.lua @@ -26,7 +26,7 @@ local function write(s) end local function on_wait_event_timeout() - coroutine.resume(console_task, "TIEMOUT") + coroutine.resume(console_task, "TIMEOUT") end local function wait_event(event, timeout) @@ -95,11 +95,12 @@ local function main_loop() -- 用xpcall执行用户输入的脚本,可以捕捉脚本的错误 xpcall(function() -- 执行用户输入的脚本 - local f = loadstring(line) + local f = assert(loadstring(line.." ")) setfenv(f, execute_env) f() end, - function() -- 错误输出 + function(err) -- 错误输出 + write(err .. '\r\n') write(debug.traceback()) end) if wait_event_flag then diff --git a/script_LuaTask/lib/gizwits.lua b/script_LuaTask/lib/gizwits.lua index bfa0b7c..40ed70b 100644 --- a/script_LuaTask/lib/gizwits.lua +++ b/script_LuaTask/lib/gizwits.lua @@ -345,7 +345,7 @@ function clientAuthTask() local retryCnt = 0 while true do local body = "mac="..sgetDeviceNameFnc().."&passcode="..getDeviceSecretFnc() - if sgetAuthkey ~= nil then + if sgetAuthkey ~= nil and sgetAuthkey() ~= nil then log.info("sgetAuthkey",sgetAuthkey()) body = body.."&auth_key="..sgetAuthkey() end --当有sgetAuthkey的时候就加上这个参数 diff --git a/script_LuaTask/lib/gpsv2.lua b/script_LuaTask/lib/gpsv2.lua index db8b291..61d798b 100644 --- a/script_LuaTask/lib/gpsv2.lua +++ b/script_LuaTask/lib/gpsv2.lua @@ -1,513 +1,513 @@ ---- 模块功能:GPS模块管理 --- @module gpsv2 --- @author openLuat --- @license MIT --- @copyright openLuat --- @release 2018.08.28 -require "pm" -require "httpv2" -require "utils" -require "lbsLoc" -module(..., package.seeall) - --- GPS任务线程ID -local GPS_CO ---串口配置 -local uartID, uartBaudrate = 2, 115200 --- 星历的保存地址 -local GPD_FILE = "/ephdat.bin" --- 下载超时设置单位分钟 -local timeout = 5 * 60000 --- 设置星历和基站定位的循环定时器时间 -local EPH_UPDATE_INTERVAL = 4 * 3600 --- 星历写入标记 -local ephFlag = false ---GPS开启标志,true表示开启状态,false或者nil表示关闭状态 -local openFlag ---GPS定位标志,true表示,其余表示未定位 -local fixFlag = false --- 经纬度类型和数据 -local latitudeType, latitude, longitudeType, longitude = "N", "", "E", "" --- 海拔,速度,时速,方向角 -local altitude, speed, kmHour, azimuth = "0", "0", "0", "0" --- 参与定位的卫星个数,GPS和北斗可见卫星个数 -local usedSateCnt, viewedGpsSateCnt, viewedBdSateCnt = "0", "0", "0" --- 可用卫星号,UTC时间 -local SateSn, UtcTime --- 大地高,度分经度,度分纬度 -local Sep, Ggalng, Ggalat --- GPS和北斗GSV解析保存的表 -local gpgsvTab, bdgsvTab = {}, {} --- GPGSV解析后的CNO信息 -local gsvCnoTab = {} --- 基站定位坐标 -local lbs_lat, lbs_lng - ---解析GPS模块返回的信息 -local function parseNmea(s) - if not s or s == "" then return end - log.info("定位模块上报的信息:", s) - 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 - 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 "" - if #satesn > 0 and s:match("%d+,") then SateSn = satesn end - elseif s:match("GPGSV") then - local curnum, lineno, sateNum, gsv_str = s:match("GPGSV,(%d),(%d),(%d+),(.*)%*.*") - if curnum and lineno and sateNum and gsv_str then - if tonumber(lineno) == 1 then - gpgsvTab = {} - gsvCnoTab = {} - gpgsvTab.sateNum = sateNum - gpgsvTab.sateType = "GPS" - end - for i = 1, 4 do - local msg = {id, elevation, azimuth, cno} - -- 找到的字符串的开始位置,结束位置,仰角,方位角,载波信噪比 - msg.id, msg.elevation, msg.azimuth, msg.cno, gsv_str = gsv_str:match("(%d+),([%-]*%d*),(%d*),(%d*)(.*)") - if not msg.id then break end - msg.id, msg.elevation, msg.azimuth, msg.cno = tonumber(msg.id) or 0, tonumber(msg.elevation) or 0, tonumber(msg.azimuth) or 0, tonumber(msg.cno) or 0 - table.insert(gpgsvTab, msg) - table.insert(gsvCnoTab, msg.cno) - end - viewedGpsSateCnt = sateNum or "0" - end - -- log.info("GPGSV is value:", json.encode(gsvCnoTab)) - elseif s:match("BDGSV") then - local curnum, lineno, sateNum, gsv_str = s:match("GPGSV,(%d),(%d),(%d+),(.*)%*.*") - if curnum and lineno and sateNum and gsv_str then - if tonumber(lineno) == 1 then - bdgsvTab = {} - bdgsvTab.sateNum = sateNum - bdgsvTab.sateType = "BD" - end - -- 将同一消息编号的归类插入同一个编号中 - for i = 1, 4 do - local msg = {id, elevation, azimuth, cno} - -- 找到的字符串的开始位置,结束位置,仰角,方位角,载波信噪比 - msg.id, msg.elevation, msg.azimuth, msg.cno, gsv_str = gsv_str:match("(%d+),([%-]*%d*),(%d*),(%d*)(.*)") - if not msg.id then break end - msg.id, msg.elevation, msg.azimuth, msg.cno = tonumber(msg.id) or 0, tonumber(msg.elevation) or 0, tonumber(msg.azimuth) or 0, tonumber(msg.cno) or 0 - table.insert(bdgsvTab, msg) - end - end - viewedBdSateCnt = sateNum or "0" - elseif s:match("RMC") then - gpsTime, gpsFind, lat, latTyp, lng, lngTyp, spd, cog, gpsDate = s:match("RMC,(%d%d%d%d%d%d)%.%d+,(%w),(%d*%.*%d*),([NS]*),(%d*%.*%d*),([EW]*),(.-),(.-),(%d%d%d%d%d%d),") - if gpsFind == "A" and cog then - fixFlag = true - speed = spd - azimuth = cog - else - fixFlag = false - end - 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} - end - elseif s:match("VTG") then - kmHour = s:match("VTG,%d*%.*%d*,%w*,%d*%.*%d*,%w*,%d*%.*%d*,%w*,(%d*%.*%d*)") - if fixFlag then sys.publish("GPS_MSG_REPORT") end - end -end - --- 阻塞模式读取串口数据,需要线程支持 --- @return 返回以\r\n结尾的一行数据 --- @usage local str = gpsv2.read() -local function read() - local cache_data = "" - local co = coroutine.running() - while true do - local s = uart.read(uartID, "*l") - if s == "" then - uart.on(uartID, "receive", function()coroutine.resume(co) end) - coroutine.yield() - uart.on(uartID, "receive") - else - cache_data = cache_data .. s - if cache_data:find("\r\n") then return cache_data end - end - end -end --- GPS串口写命令操作 --- @string cmd,GPS指令(cmd格式:"$PGKC149,1,115200*"或者"$PGKC149,1,115200*XX\r\n") --- @bool isFull,cmd是否为完整的指令格式,包括校验和以及\r\n;true表示完整,false或者nil为不完整 --- @return nil --- @usage gpsv2.writeCmd(cmd) -local function writeCmd(cmd, isFull) - local tmp = cmd - if not isFull then - tmp = 0 - for i = 2, cmd:len() - 1 do - tmp = bit.bxor(tmp, cmd:byte(i)) - end - tmp = cmd .. (string.format("%02X", tmp)):upper() .. "\r\n" - end - uart.write(uartID, tmp) - log.info("gpsv2.writecmd", tmp) ---log.info("gpsv2.writecmd",tmp:toHex()) -end - --- GPS串口写数据操作 --- @string str,HEX形式的字符串 --- @return 无 --- @usage gpsv2.writeData(str) -local function writeData(str) - uart.write(uartID, (str:fromHex())) -end --- AIR530的校验和算法 -local function hexCheckSum(str) - local sum = 0 - for i = 5, str:len(), 2 do - sum = bit.bxor(sum, tonumber(str:sub(i, i + 1), 16)) - end - return string.upper(string.format("%02X", sum)) -end -local function setFastFix(lat, lng) - if not lat or not lng or not openFlag or os.time() < 1514779200 then return end - local tm = os.date("*t") - tm = common.timeZoneConvert(tm.year, tm.month, tm.day, tm.hour, tm.min, tm.sec, 8, 0) - t = tm.year .. "," .. tm.month .. "," .. tm.day .. "," .. tm.hour .. "," .. tm.min .. "," .. tm.sec .. "*" - -- log.info("写入秒定位需要的坐标和时间:", lat, lng, t) - writeCmd("$PGKC634," .. t) - writeCmd("$PGKC634," .. t) - writeCmd("$PGKC635," .. lat .. "," .. lng .. ",0," .. t) -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跟踪模式 --- @number sleepTm,间隔唤醒的时间 秒 --- @param fnc,外部模块使用的电源管理函数 --- @return 无 --- @usage gpsv2.open() -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 - 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_VCAM) - rtos.sys32k_clk_out(1) - end - openFlag = true - local fullPowerMode = false - log.info("----------------------------------- GPS OPEN -----------------------------------") - GPS_CO = sys.taskInit(function() - read() - setReport(sleepTm > 10000 and 10000 or sleepTm) - while openFlag do - if not fixFlag and not ephFlag and io.exists(GPD_FILE) and os.time() > 1514779200 then - local tmp, data, len = "", io.readFile(GPD_FILE):toHex() - -- 切换到BINARY模式 - while read():toHex() ~= "AAF00C0001009500039B0D0A" do writeCmd("$PGKC149,1,115200*") end - log.info("模块写星历数据开始!") - -- 写入星历数据 - local cnt = 0 -- 包序号 - for i = 1, #data, 1024 do - tmp = data:sub(i, i + 1023) - if tmp:len() < 1024 then tmp = tmp .. ("F"):rep(1024 - tmp:len()) end - tmp = "AAF00B026602" .. string.format("%04X", cnt):upper() .. tmp - tmp = tmp .. hexCheckSum(tmp) .. "0D0A" - writeData(tmp) - for j = 1, 30 do - local ack, len = read():toHex() - if len == 12 or ack:find("AAF00C0003") then break end - end - cnt = cnt + 1 - end - -- 发送GPD传送结束语句 - writeData("aaf00b006602ffff6f0d0a") - -- 切换为NMEA接收模式 - writeData("aaf00e0095000000c20100580d0a") - while not read():find("$G") do writeData("aaf00e0095000000c20100580d0a") end - setFastFix(lbs_lat, lbs_lng) - ephFlag = true - fullPowerMode = true - log.info("模块写星历数据完成!") - else - if fixFlag and fullPowerMode then - setRunMode(sleepTm > 5000 and mode or 0, 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 - setReport(sleepTm > 10000 and 10000 or sleepTm) - fullPowerMode = true - end - parseNmea(read()) - end - end - sys.publish("GPS_CLOSE_MSG") - log.info("GPS 任务结束退出!") - end) -end ---- 关闭GPS模块 --- @param fnc,外部模块使用的电源管理函数 --- @return 无 --- @usage gpsv2.close() -function close(id, fnc) - openFlag = false - fixFlag = false - while GPS_CO ~= nil and coroutine.status(GPS_CO) ~= "dead" do coroutine.resume(GPS_CO) end - uart.close(tonumber(id) or uartID) - if fnc and type(fnc) == "function" then - fnc() - else - pmd.ldoset(0, pmd.LDO_VCAM) - rtos.sys32k_clk_out(0) - end - pm.sleep("gpsv2.lua") - sys.timerStopAll(restart) - log.info("----------------------------------- GPS CLOSE -----------------------------------") -end ---- 重启GPS模块 --- @number r,重启方式-0:外部电源重置; 1:热启动; 2:温启动; 3:冷启动 --- @return 无 --- @usage gpsv2.restart() -function restart(r) - r = tonumber(r) or 1 - if r > 0 and r < 4 then writeCmd("$PGKC030," .. r .. "*") end -end - ---- 设置GPS模块搜星模式. --- 如果使用的是Air800或者Air530,不调用此接口配置,则默认同时开启GPS和北斗定位 --- @number gps,GPS定位系统,1是打开,0是关闭 --- @number beidou,中国北斗定位系统,1是打开,0是关闭 --- @number glonass,俄罗斯Glonass定位系统,1是打开,0是关闭 --- @number galieo,欧盟伽利略定位系统,1是打开,0是关闭 --- @return nil --- @usage gpsv2.setAeriaMode(1,1,0,0) -function setAerialMode(gps, beidou, glonass, galieo) - local gps = gps or 0 - local glonass = glonass or 0 - local beidou = beidou or 0 - local galieo = galieo or 0 - if gps + glonass + beidou + galieo == 0 then gps = 1; beidou = 1 end - if openFlag then writeCmd("$PGKC115," .. gps .. "," .. glonass .. "," .. beidou .. "," .. galieo .. "*") end -end - ---- 设置GPS模块的运行模式. --- 如果不调用此接口配置,则默认为正常运行模式 --- @number mode,运行模式 --- 0:正常运行模式 --- 1:周期超低功耗跟踪模式 --- 2:周期低功耗模式 --- 4:直接进入超低功耗跟踪模式 --- 8:自动低功耗模式,可以通过串口唤醒 --- 9:自动超低功耗跟踪模式,需要force on来唤醒 --- @number runTm,单位毫秒,mode为1或者2时表示运行时长,其余mode时此值无意义 --- @number sleepTm,单位毫秒,mode为1或者2时表示睡眠时长,其余mode时此值无意义 --- @return nil --- @usage gpsv2.setRunMode(0,1000) --- @usage gpsv2.setRunMode(1,5000,2000) -function setRunMode(mode, runTm, sleepTm) - local rt, st = tonumber(runTm) or "", tonumber(sleepTm) or "" - if openFlag then - writeCmd("$PGKC105," .. mode .. ((mode == 1 or mode == 2) and ("," .. rt .. "," .. st) or "") .. "*") - end -end - ---- 设置NMEA消息上报的间隔 --- @number tm,上报消息的间隔时间 --- @return 无 --- @usage gpsv2.setReport(tm) -function setReport(tm) - if openFlag then - tm = tonumber(tm) or 1000 - if tm > 10000 then tm = 10000 end - if tm < 200 then tm = 200 end - writeCmd("$PGKC101," .. tm .. "*") - end -end - ---- 获取GPS模块是否处于开启状态 --- @return bool result,true表示开启状态,false或者nil表示关闭状态 --- @usage gpsv2.isOpen() -function isOpen() - return openFlag -end - ---- 获取GPS模块是否定位成功 --- @return bool result,true表示定位成功,false或者nil表示定位失败 --- @usage gpsv2.isFix() -function isFix() - return fixFlag -end - ---- 获取返回值为度的10&7方的整数值(度*10^7的值) --- @return number,number,INT32整数型,经度,维度,符号(正东负西,正北负南) --- @usage gpsv2.getIntLocation() -function getIntLocation() - local lng, lat = "0.0", "0.0" - lng = longitudeType == "W" and ("-" .. longitude) or longitude - lat = latitudeType == "S" and ("-" .. latitude) or latitude - if lng and lat and lng ~= "" and lat ~= "" then - local integer, decimal = lng:match("(%d+).(%d+)") - if tonumber(integer) and tonumber(decimal) then - decimal = decimal:sub(1, 7) - lng = (integer / 100) * 10 ^ 7 + ((integer % 100) * 10 ^ 7 + decimal * 10 ^ (7 - #decimal)) / 60 - integer, decimal = lat:match("(%d+).(%d+)") - decimal = decimal:sub(1, 7) - lat = (integer / 100) * 10 ^ 7 + ((integer % 100) * 10 ^ 7 + decimal * 10 ^ (7 - #decimal)) / 60 - return lng, lat - end - end - return 0, 0 -end ---- 获取基站定位的经纬度信息dd.dddd -function getDeglbs() - return lbs_lng or "0.0", lbs_lat or "0.0" -end - ---- 获取度格式的经纬度信息dd.dddddd --- @return string,string,返回度格式的字符串经度,维度,符号(正东负西,正北负南) --- @usage gpsv2.getLocation() -function getDegLocation() - local lng, lat = getIntLocation() - 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() - return Ggalng or "", Ggalat or "" -end - ---- 获取海拔 --- @return number altitude,海拔,单位米 --- @usage gpsv2.getAltitude() -function getAltitude() - return tonumber(altitude:match("(%d+)") or "0") -end - ---- 获取速度 --- @return number kmSpeed,第一个返回值为公里每小时的速度 --- @return number nmSpeed,第二个返回值为海里每小时的速度 --- @usage gpsv2.getSpeed() -function getSpeed() - local integer = tonumber(speed:match("(%d+)") or "0") - return (integer * 1852 - (integer * 1852 % 1000)) / 1000, integer -end - ---- 获取时速(KM/H)的整数型和浮点型(字符串) -function getKmHour() - return tonumber(kmHour:match("(%d+)") or "0"), kmHour or "0" -end - ---- 获取方向角 --- @return number Azimuth,方位角 --- @usage gpsv2.getAzimuth() -function getAzimuth() - return tonumber(azimuth:match("(%d+)") or "0") -end - ---- 获取可见卫星的个数 --- @return number count,可见卫星的个数 --- @usage gpsv2.getViewedSateCnt() -function getViewedSateCnt() - return tonumber(viewedGpsSateCnt) or 0 + tonumber(viewedBdSateCnt) or 0 -end - ---- 获取定位使用的卫星个数 --- @return number count,定位使用的卫星个数 --- @usage gpsv2.getUsedSateCnt() -function getUsedSateCnt() - return tonumber(usedSateCnt or "0") -end - ---- 获取RMC语句中的UTC时间 --- 只有同时满足如下两个条件,返回值才有效 --- 1、开启了GPS,并且定位成功 --- 2、调用setParseItem接口,第一个参数设置为true --- @return table utcTime,UTC时间,nil表示无效,例如{year=2018,month=4,day=24,hour=11,min=52,sec=10} --- @usage gpsv2.getUtcTime() -function getUtcTime() - return UtcTime -end - ---- 获取定位使用的大地高 --- @return number sep,大地高 --- @usage gpsv2.getSep() -function getSep() - return tonumber(Sep or "0") -end - ---- 获取GSA语句中的可见卫星号 --- 只有同时满足如下两个条件,返回值才有效 --- 1、开启了GPS,并且定位成功 --- 2、调用setParseItem接口,第三个参数设置为true --- @return string viewedSateId,可用卫星号,""表示无效 --- @usage gpsv2.getSateSn() -function getSateSn() - return SateSn or "" -end ---- 获取BDGSV解析结果 --- @return table, GSV解析后的数组 --- @usage gpsv2.getBDGsv() -function getBDGsv() - return bdgsvTab -end ---- 获取GPGSV解析结果 --- @return table, GSV解析后的数组 --- @usage gpsv2.getGPGsv() -function getGPGsv() - return gpgsvTab -end ---- 获取GPSGSV解析后的CNO数据 -function getCno() - return gsvCnoTab -end - --- 定时自动下载坐标和星历的任务 -local function getlbs(result, lat, lng, addr) - if result and lat and lng then - lbs_lat, lbs_lng = lat, lng - setFastFix(lat, lng) - end -end - -local function saveEph(timeout) - sys.taskInit(function() - while true do - local code, head, data = httpv2.request("GET", "download.openluat.com/9501-xingli/brdcGPD.dat_rda", timeout) - if tonumber(code) and tonumber(code) == 200 then - log.info("保存下载的星历:", io.writeFile(GPD_FILE, data)) - ephFlag = false - break - end - end - end) -end - -pmd.ldoset(7, pmd.LDO_VIB) --- 打开GPS,串口2,波特率115200,跟踪模式 --- open(2, 115200, 8, 5) --- open(2, 115200, 2, 1, 5) --- 获取基站定位坐标 -lbsLoc.request(getlbs, nil, timeout) ---连接服务器下载星历 -saveEph(timeout) --- 自动定时下载定位坐标 -sys.timerLoopStart(function()lbsLoc.request(getlbs, nil, timeout) end, EPH_UPDATE_INTERVAL * 1000) --- 自动定时下载星历数据 -sys.timerLoopStart(saveEph, EPH_UPDATE_INTERVAL * 1000, timeout) +--- 模块功能:GPS模块管理 +-- @module gpsv2 +-- @author openLuat +-- @license MIT +-- @copyright openLuat +-- @release 2018.08.28 +require "pm" +require "httpv2" +require "utils" +require "lbsLoc" +module(..., package.seeall) + +-- GPS任务线程ID +local GPS_CO +--串口配置 +local uartID, uartBaudrate = 2, 115200 +-- 星历的保存地址 +local GPD_FILE = "/ephdat.bin" +-- 下载超时设置单位分钟 +local timeout = 5 * 60000 +-- 设置星历和基站定位的循环定时器时间 +local EPH_UPDATE_INTERVAL = 4 * 3600 +-- 星历写入标记 +local ephFlag = false +--GPS开启标志,true表示开启状态,false或者nil表示关闭状态 +local openFlag +--GPS定位标志,true表示,其余表示未定位 +local fixFlag = false +-- 经纬度类型和数据 +local latitudeType, latitude, longitudeType, longitude = "N", "", "E", "" +-- 海拔,速度,时速,方向角 +local altitude, speed, kmHour, azimuth = "0", "0", "0", "0" +-- 参与定位的卫星个数,GPS和北斗可见卫星个数 +local usedSateCnt, viewedGpsSateCnt, viewedBdSateCnt = "0", "0", "0" +-- 可用卫星号,UTC时间 +local SateSn, UtcTime +-- 大地高,度分经度,度分纬度 +local Sep, Ggalng, Ggalat +-- GPS和北斗GSV解析保存的表 +local gpgsvTab, bdgsvTab = {}, {} +-- GPGSV解析后的CNO信息 +local gsvCnoTab = {} +-- 基站定位坐标 +local lbs_lat, lbs_lng + +--解析GPS模块返回的信息 +local function parseNmea(s) + if not s or s == "" then return end + log.info("定位模块上报的信息:", s) + 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 + 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 "" + if #satesn > 0 and s:match("%d+,") then SateSn = satesn end + elseif s:match("GPGSV") then + local curnum, lineno, sateNum, gsv_str = s:match("GPGSV,(%d),(%d),(%d+),(.*)%*.*") + if curnum and lineno and sateNum and gsv_str then + if tonumber(lineno) == 1 then + gpgsvTab = {} + gsvCnoTab = {} + gpgsvTab.sateNum = sateNum + gpgsvTab.sateType = "GPS" + end + for i = 1, 4 do + local msg = {id, elevation, azimuth, cno} + -- 找到的字符串的开始位置,结束位置,仰角,方位角,载波信噪比 + msg.id, msg.elevation, msg.azimuth, msg.cno, gsv_str = gsv_str:match("(%d+),([%-]*%d*),(%d*),(%d*)(.*)") + if not msg.id then break end + msg.id, msg.elevation, msg.azimuth, msg.cno = tonumber(msg.id) or 0, tonumber(msg.elevation) or 0, tonumber(msg.azimuth) or 0, tonumber(msg.cno) or 0 + table.insert(gpgsvTab, msg) + table.insert(gsvCnoTab, msg.cno) + end + viewedGpsSateCnt = sateNum or "0" + end + -- log.info("GPGSV is value:", json.encode(gsvCnoTab)) + elseif s:match("BDGSV") then + local curnum, lineno, sateNum, gsv_str = s:match("GPGSV,(%d),(%d),(%d+),(.*)%*.*") + if curnum and lineno and sateNum and gsv_str then + if tonumber(lineno) == 1 then + bdgsvTab = {} + bdgsvTab.sateNum = sateNum + bdgsvTab.sateType = "BD" + end + -- 将同一消息编号的归类插入同一个编号中 + for i = 1, 4 do + local msg = {id, elevation, azimuth, cno} + -- 找到的字符串的开始位置,结束位置,仰角,方位角,载波信噪比 + msg.id, msg.elevation, msg.azimuth, msg.cno, gsv_str = gsv_str:match("(%d+),([%-]*%d*),(%d*),(%d*)(.*)") + if not msg.id then break end + msg.id, msg.elevation, msg.azimuth, msg.cno = tonumber(msg.id) or 0, tonumber(msg.elevation) or 0, tonumber(msg.azimuth) or 0, tonumber(msg.cno) or 0 + table.insert(bdgsvTab, msg) + end + end + viewedBdSateCnt = sateNum or "0" + elseif s:match("RMC") then + gpsTime, gpsFind, lat, latTyp, lng, lngTyp, spd, cog, gpsDate = s:match("RMC,(%d%d%d%d%d%d)%.%d+,(%w),(%d*%.*%d*),([NS]*),(%d*%.*%d*),([EW]*),(.-),(.-),(%d%d%d%d%d%d),") + if gpsFind == "A" and cog then + fixFlag = true + speed = spd + azimuth = cog + else + fixFlag = false + end + 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} + end + elseif s:match("VTG") then + kmHour = s:match("VTG,%d*%.*%d*,%w*,%d*%.*%d*,%w*,%d*%.*%d*,%w*,(%d*%.*%d*)") + if fixFlag then sys.publish("GPS_MSG_REPORT", 1) else sys.publish("GPS_MSG_NOREPORT", 0) end + end +end + +-- 阻塞模式读取串口数据,需要线程支持 +-- @return 返回以\r\n结尾的一行数据 +-- @usage local str = gpsv2.read() +local function read() + local cache_data = "" + local co = coroutine.running() + while true do + local s = uart.read(uartID, "*l") + if s == "" then + uart.on(uartID, "receive", function()coroutine.resume(co) end) + coroutine.yield() + uart.on(uartID, "receive") + else + cache_data = cache_data .. s + if cache_data:find("\r\n") then return cache_data end + end + end +end +-- GPS串口写命令操作 +-- @string cmd,GPS指令(cmd格式:"$PGKC149,1,115200*"或者"$PGKC149,1,115200*XX\r\n") +-- @bool isFull,cmd是否为完整的指令格式,包括校验和以及\r\n;true表示完整,false或者nil为不完整 +-- @return nil +-- @usage gpsv2.writeCmd(cmd) +local function writeCmd(cmd, isFull) + local tmp = cmd + if not isFull then + tmp = 0 + for i = 2, cmd:len() - 1 do + tmp = bit.bxor(tmp, cmd:byte(i)) + end + tmp = cmd .. (string.format("%02X", tmp)):upper() .. "\r\n" + end + uart.write(uartID, tmp) + log.info("gpsv2.writecmd", tmp) +--log.info("gpsv2.writecmd",tmp:toHex()) +end + +-- GPS串口写数据操作 +-- @string str,HEX形式的字符串 +-- @return 无 +-- @usage gpsv2.writeData(str) +local function writeData(str) + uart.write(uartID, (str:fromHex())) +end +-- AIR530的校验和算法 +local function hexCheckSum(str) + local sum = 0 + for i = 5, str:len(), 2 do + sum = bit.bxor(sum, tonumber(str:sub(i, i + 1), 16)) + end + return string.upper(string.format("%02X", sum)) +end +local function setFastFix(lat, lng) + if not lat or not lng or not openFlag or os.time() < 1514779200 then return end + local tm = os.date("*t") + tm = common.timeZoneConvert(tm.year, tm.month, tm.day, tm.hour, tm.min, tm.sec, 8, 0) + t = tm.year .. "," .. tm.month .. "," .. tm.day .. "," .. tm.hour .. "," .. tm.min .. "," .. tm.sec .. "*" + -- log.info("写入秒定位需要的坐标和时间:", lat, lng, t) + writeCmd("$PGKC634," .. t) + writeCmd("$PGKC634," .. t) + writeCmd("$PGKC635," .. lat .. "," .. lng .. ",0," .. t) +end + +-- 定时自动下载坐标和星历的任务 +local function getlbs(result, lat, lng, addr) + if result and lat and lng then + lbs_lat, lbs_lng = lat, lng + setFastFix(lat, lng) + end +end + +local function saveEph(timeout) + sys.taskInit(function() + while true do + local code, head, data = httpv2.request("GET", "download.openluat.com/9501-xingli/brdcGPD.dat_rda", timeout) + if tonumber(code) and tonumber(code) == 200 then + log.info("保存下载的星历:", io.writeFile(GPD_FILE, data)) + ephFlag = false + break + end + end + end) +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跟踪模式 +-- @number sleepTm,间隔唤醒的时间 秒 +-- @param fnc,外部模块使用的电源管理函数 +-- @return 无 +-- @usage gpsv2.open() +-- @usage gpsv2.open(2, 115200, 8, 5) -- 打开GPS,串口2,波特率115200,超低功耗跟踪模式 +-- @usage gpsv2.open(2, 115200, 2, 1, 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 + 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_VCAM) + rtos.sys32k_clk_out(1) + end + openFlag = true + local fullPowerMode = false + ---------------------------------- 初始化GPS任务-------------------------------------------- + pmd.ldoset(7, pmd.LDO_VIB) + -- 获取基站定位坐标 + lbsLoc.request(getlbs, nil, timeout) + --连接服务器下载星历 + saveEph(timeout) + -- 自动定时下载定位坐标 + sys.timerLoopStart(function()lbsLoc.request(getlbs, nil, timeout) end, EPH_UPDATE_INTERVAL * 1000) + -- 自动定时下载星历数据 + sys.timerLoopStart(saveEph, EPH_UPDATE_INTERVAL * 1000, timeout) + log.info("----------------------------------- GPS OPEN -----------------------------------") + GPS_CO = sys.taskInit(function() + read() + setReport(sleepTm > 10000 and 10000 or sleepTm) + while openFlag do + if not fixFlag and not ephFlag and io.exists(GPD_FILE) and os.time() > 1514779200 then + local tmp, data, len = "", io.readFile(GPD_FILE):toHex() + -- 切换到BINARY模式 + while read():toHex() ~= "AAF00C0001009500039B0D0A" do writeCmd("$PGKC149,1,115200*") end + log.info("模块写星历数据开始!") + -- 写入星历数据 + local cnt = 0 -- 包序号 + for i = 1, #data, 1024 do + tmp = data:sub(i, i + 1023) + if tmp:len() < 1024 then tmp = tmp .. ("F"):rep(1024 - tmp:len()) end + tmp = "AAF00B026602" .. string.format("%04X", cnt):upper() .. tmp + tmp = tmp .. hexCheckSum(tmp) .. "0D0A" + writeData(tmp) + for j = 1, 30 do + local ack, len = read():toHex() + if len == 12 or ack:find("AAF00C0003") then break end + end + cnt = cnt + 1 + end + -- 发送GPD传送结束语句 + writeData("aaf00b006602ffff6f0d0a") + -- 切换为NMEA接收模式 + writeData("aaf00e0095000000c20100580d0a") + while not read():find("$G") do writeData("aaf00e0095000000c20100580d0a") end + setFastFix(lbs_lat, lbs_lng) + ephFlag = true + fullPowerMode = true + log.info("模块写星历数据完成!") + else + if fixFlag and fullPowerMode then + setRunMode(sleepTm > 5000 and mode or 0, 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 + setReport(sleepTm > 10000 and 10000 or sleepTm) + fullPowerMode = true + end + parseNmea(read()) + end + end + sys.publish("GPS_CLOSE_MSG") + log.info("GPS 任务结束退出!") + end) +end +--- 关闭GPS模块 +-- @param fnc,外部模块使用的电源管理函数 +-- @return 无 +-- @usage gpsv2.close() +function close(id, fnc) + openFlag = false + fixFlag = false + while GPS_CO ~= nil and coroutine.status(GPS_CO) ~= "dead" do coroutine.resume(GPS_CO) end + uart.close(tonumber(id) or uartID) + if fnc and type(fnc) == "function" then + fnc() + else + pmd.ldoset(0, pmd.LDO_VCAM) + rtos.sys32k_clk_out(0) + end + pm.sleep("gpsv2.lua") + sys.timerStopAll(restart) + log.info("----------------------------------- GPS CLOSE -----------------------------------") +end +--- 重启GPS模块 +-- @number r,重启方式-0:外部电源重置; 1:热启动; 2:温启动; 3:冷启动 +-- @return 无 +-- @usage gpsv2.restart() +function restart(r) + r = tonumber(r) or 1 + if r > 0 and r < 4 then writeCmd("$PGKC030," .. r .. "*") end +end + +--- 设置GPS模块搜星模式. +-- 如果使用的是Air800或者Air530,不调用此接口配置,则默认同时开启GPS和北斗定位 +-- @number gps,GPS定位系统,1是打开,0是关闭 +-- @number beidou,中国北斗定位系统,1是打开,0是关闭 +-- @number glonass,俄罗斯Glonass定位系统,1是打开,0是关闭 +-- @number galieo,欧盟伽利略定位系统,1是打开,0是关闭 +-- @return nil +-- @usage gpsv2.setAeriaMode(1,1,0,0) +function setAerialMode(gps, beidou, glonass, galieo) + local gps = gps or 0 + local glonass = glonass or 0 + local beidou = beidou or 0 + local galieo = galieo or 0 + if gps + glonass + beidou + galieo == 0 then gps = 1; beidou = 1 end + if openFlag then writeCmd("$PGKC115," .. gps .. "," .. glonass .. "," .. beidou .. "," .. galieo .. "*") end +end + +--- 设置GPS模块的运行模式. +-- 如果不调用此接口配置,则默认为正常运行模式 +-- @number mode,运行模式 +-- 0:正常运行模式 +-- 1:周期超低功耗跟踪模式 +-- 2:周期低功耗模式 +-- 4:直接进入超低功耗跟踪模式 +-- 8:自动低功耗模式,可以通过串口唤醒 +-- 9:自动超低功耗跟踪模式,需要force on来唤醒 +-- @number runTm,单位毫秒,mode为1或者2时表示运行时长,其余mode时此值无意义 +-- @number sleepTm,单位毫秒,mode为1或者2时表示睡眠时长,其余mode时此值无意义 +-- @return nil +-- @usage gpsv2.setRunMode(0,1000) +-- @usage gpsv2.setRunMode(1,5000,2000) +function setRunMode(mode, runTm, sleepTm) + local rt, st = tonumber(runTm) or "", tonumber(sleepTm) or "" + if openFlag then + writeCmd("$PGKC105," .. mode .. ((mode == 1 or mode == 2) and ("," .. rt .. "," .. st) or "") .. "*") + end +end + +--- 设置NMEA消息上报的间隔 +-- @number tm,上报消息的间隔时间 +-- @return 无 +-- @usage gpsv2.setReport(tm) +function setReport(tm) + if openFlag then + tm = tonumber(tm) or 1000 + if tm > 10000 then tm = 10000 end + if tm < 200 then tm = 200 end + writeCmd("$PGKC101," .. tm .. "*") + end +end + +--- 获取GPS模块是否处于开启状态 +-- @return bool result,true表示开启状态,false或者nil表示关闭状态 +-- @usage gpsv2.isOpen() +function isOpen() + return openFlag +end + +--- 获取GPS模块是否定位成功 +-- @return bool result,true表示定位成功,false或者nil表示定位失败 +-- @usage gpsv2.isFix() +function isFix() + return fixFlag +end + +--- 获取返回值为度的10&7方的整数值(度*10^7的值) +-- @return number,number,INT32整数型,经度,维度,符号(正东负西,正北负南) +-- @usage gpsv2.getIntLocation() +function getIntLocation() + local lng, lat = "0.0", "0.0" + lng = longitudeType == "W" and ("-" .. longitude) or longitude + lat = latitudeType == "S" and ("-" .. latitude) or latitude + if lng and lat and lng ~= "" and lat ~= "" then + local integer, decimal = lng:match("(%d+).(%d+)") + if tonumber(integer) and tonumber(decimal) then + decimal = decimal:sub(1, 7) + lng = (integer / 100) * 10 ^ 7 + ((integer % 100) * 10 ^ 7 + decimal * 10 ^ (7 - #decimal)) / 60 + integer, decimal = lat:match("(%d+).(%d+)") + decimal = decimal:sub(1, 7) + lat = (integer / 100) * 10 ^ 7 + ((integer % 100) * 10 ^ 7 + decimal * 10 ^ (7 - #decimal)) / 60 + return lng, lat + end + end + return 0, 0 +end +--- 获取基站定位的经纬度信息dd.dddd +function getDeglbs() + return lbs_lng or "0.0", lbs_lat or "0.0" +end + +--- 获取度格式的经纬度信息dd.dddddd +-- @return string,string,返回度格式的字符串经度,维度,符号(正东负西,正北负南) +-- @usage gpsv2.getLocation() +function getDegLocation() + local lng, lat = getIntLocation() + 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() + return Ggalng or "", Ggalat or "" +end + +--- 获取海拔 +-- @return number altitude,海拔,单位米 +-- @usage gpsv2.getAltitude() +function getAltitude() + return tonumber(altitude:match("(%d+)") or "0") +end + +--- 获取速度 +-- @return number kmSpeed,第一个返回值为公里每小时的速度 +-- @return number nmSpeed,第二个返回值为海里每小时的速度 +-- @usage gpsv2.getSpeed() +function getSpeed() + local integer = tonumber(speed:match("(%d+)") or "0") + return (integer * 1852 - (integer * 1852 % 1000)) / 1000, integer +end + +--- 获取时速(KM/H)的整数型和浮点型(字符串) +function getKmHour() + return tonumber(kmHour:match("(%d+)") or "0"), kmHour or "0" +end + +--- 获取方向角 +-- @return number Azimuth,方位角 +-- @usage gpsv2.getAzimuth() +function getAzimuth() + return tonumber(azimuth:match("(%d+)") or "0") +end + +--- 获取可见卫星的个数 +-- @return number count,可见卫星的个数 +-- @usage gpsv2.getViewedSateCnt() +function getViewedSateCnt() + return tonumber(viewedGpsSateCnt) or 0 + tonumber(viewedBdSateCnt) or 0 +end + +--- 获取定位使用的卫星个数 +-- @return number count,定位使用的卫星个数 +-- @usage gpsv2.getUsedSateCnt() +function getUsedSateCnt() + return tonumber(usedSateCnt or "0") +end + +--- 获取RMC语句中的UTC时间 +-- 只有同时满足如下两个条件,返回值才有效 +-- 1、开启了GPS,并且定位成功 +-- 2、调用setParseItem接口,第一个参数设置为true +-- @return table utcTime,UTC时间,nil表示无效,例如{year=2018,month=4,day=24,hour=11,min=52,sec=10} +-- @usage gpsv2.getUtcTime() +function getUtcTime() + return UtcTime +end + +--- 获取定位使用的大地高 +-- @return number sep,大地高 +-- @usage gpsv2.getSep() +function getSep() + return tonumber(Sep or "0") +end + +--- 获取GSA语句中的可见卫星号 +-- 只有同时满足如下两个条件,返回值才有效 +-- 1、开启了GPS,并且定位成功 +-- 2、调用setParseItem接口,第三个参数设置为true +-- @return string viewedSateId,可用卫星号,""表示无效 +-- @usage gpsv2.getSateSn() +function getSateSn() + return SateSn or "" +end +--- 获取BDGSV解析结果 +-- @return table, GSV解析后的数组 +-- @usage gpsv2.getBDGsv() +function getBDGsv() + return bdgsvTab +end +--- 获取GPGSV解析结果 +-- @return table, GSV解析后的数组 +-- @usage gpsv2.getGPGsv() +function getGPGsv() + return gpgsvTab +end +--- 获取GPSGSV解析后的CNO数据 +function getCno() + return gsvCnoTab +end diff --git a/script_LuaTask/lib/httpv2.lua b/script_LuaTask/lib/httpv2.lua index cfe00bb..5e3e63d 100644 --- a/script_LuaTask/lib/httpv2.lua +++ b/script_LuaTask/lib/httpv2.lua @@ -1,160 +1,176 @@ ---- 模块功能:HTTP客户端 --- @module httpv2 --- @author 稀饭放姜 --- @license MIT --- @copyright OpenLuat.com --- @release 2017.10.23 -require 'socket' -require 'utils' -module(..., package.seeall) - -local Content_type = {'application/x-www-form-urlencoded', 'application/json', 'application/octet-stream'} - --- 处理表的url编码 -function urlencodeTab(params) - local msg = {} - for k, v in pairs(params) do - table.insert(msg, string.urlEncode(k) .. '=' .. string.urlEncode(v)) - table.insert(msg, '&') - end - table.remove(msg) - return table.concat(msg) -end ---- HTTP客户端 --- @string method,提交方式"GET" or "POST" --- @string url,HTTP请求超链接 --- @number timeout,超时时间 --- @param params,table类型,请求发送的查询字符串,通常为键值对表 --- @param data,table类型,正文提交的body,通常为键值对、json或文件对象类似的表 --- @number ctype,Content-Type的类型(可选1,2,3),默认1:"urlencode",2:"json",3:"octet-stream" --- @string basic,HTTP客户端的authorization basic验证的"username:password" --- @param headers,table类型,HTTP headers部分 --- @param 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", --客户端证书文件密码[可选] --- } --- @return string,table,string,正常返回response_code, response_header, response_body --- @return string,string,错误返回 response_code, error_message --- @usage local c, h, b = httpv2.request(url, method, headers, body) --- @usage local r, e = httpv2.request("http://wrong.url/ ") -function request(method, url, timeout, params, data, ctype, basic, headers, cert) - local response_header, response_code, response_body = {} - local _, idx, offset, ssl, auth, https, host, port, path - headers = headers or { - ['User-Agent'] = 'Mozilla/4.0', - ['Accept'] = '*/*', - ['Accept-Language'] = 'zh-CN,zh,cn', - ['Content-Type'] = 'application/x-www-form-urlencoded', - ['Content-Length'] = '0', - ['Connection'] = 'close' - } - ssl = string.find(rtos.get_version(), 'SSL') - -- 处理url的协议头和鉴权 - _, offset, https = url:find("^(%a+)://") - _, idx, auth = url:find("(.-:.-)@", (offset or 0) + 1) - offset = idx or offset - -- 判断SSL支持是否满足 - if not ssl and https and https:lower() == "https" then return '401', 'SOCKET_SSL_ERROR' end - -- 对host:port整形 - if url:match("^[^/]+:(%d+)", (offset or 0) + 1) then - _, offset, host, port = url:find("^([^/]+):(%d+)", (offset or 0) + 1) - elseif url:find("(.-)/", (offset or 0) + 1) then - _, offset, host = url:find("(.-)/", (offset or 0) + 1) - offset = offset - 1 - else - offset, host = #url, url:sub((offset or 0) + 1, -1) - end - if not host then return '105', 'ERR_NAME_NOT_RESOLVED' end - if not headers.Host then headers["Host"] = host end - port = port or (https == "https" and 443 or 80) - path = url:sub(offset + 1, -1) - path = path == "" and "/" or path - -- 处理查询字符串 - if params ~= nil and type(params) == 'table' then path = path .. '?' .. urlencodeTab(params) end - -- 处理HTTP协议body部分的数据 - ctype = ctype or 2 - headers['Content-Type'] = Content_type[ctype] - if ctype == 1 and type(data) == 'table' then - data = urlencodeTab(data) - headers['Content-Length'] = #data or 0 - elseif ctype == 2 and data ~= nil then - data = type(data) == 'string' and data or (type(data) == 'table' and json.encode(data)) or "" - headers['Content-Length'] = #data or 0 - elseif ctype == 3 and type(data) == 'string' then - headers['Content-Length'] = io.filesize(data) or 0 - end - -- 处理HTTP Basic Authorization 验证 - if auth then - headers['Authorization'] = 'Basic ' .. crypto.base64_encode(auth, #auth) - elseif type(basic) == 'string' then - headers['Authorization'] = 'Basic ' .. crypto.base64_encode(basic, #basic) - end - -- 处理headers部分 - local str = "" - for k, v in pairs(headers) do str = str .. k .. ": " .. v .. "\r\n" end - -- 发送请求报文 - while not socket.isReady() do sys.wait(1000) end - local c = socket.tcp(https == "https", cert) - if not c:connect(host, port) then - c:close() - return '502', 'SOCKET_CONN_ERROR' - end - if ctype ~= 3 then - str = method .. ' ' .. path .. ' HTTP/1.0\r\n' .. str .. '\r\n\r\n' .. (data or "") .. '\r\n' - if not c:send(str) then - c:close() - return '426', 'SOCKET_SEND_ERROR' - end - else - str = method .. ' ' .. path .. ' HTTP/1.0\r\n' .. str .. '\r\n\r\n' - if not c:send(str) then - c:close() - return '426', 'SOCKET_SEND_ERROR' - end - local file = io.open(data, 'r') - if file then - while true do - local dat = file:read(1460) - if dat == nil then - io.close(file) - break - end - if not c:send(dat) then - io.close(file) - c:close() - return '426', 'SOCKET_SEND_ERROR' - end - end - end - if not c:send('\r\n') then - c:close() - return '426', 'SOCKET_SEND_ERROR' - end - end - ------------------------------------ 接收服务器返回消息部分 ------------------------------------ - local msg, str = {}, "" - local r, s = c:recv(timeout) - if not r then - c:close() - return '503', 'SOCKET_RECV_TIMOUT' - end - -- 处理状态代码 - _, idx, response_code = s:find("%s(%d+)%s.-\r\n") - _, offset = s:find('\r\n\r\n') - if not idx or not offset then return '501', 'SERVER_NOT_RESPONSE' end - log.info('httpv2.response code and message:', response_code) - -- 处理headers代码 - for k, v in string.gmatch(s:sub(idx + 1, offset), "(.-):%s*(.-)\r\n") do response_header[k] = v end - -- 处理body - while true do - table.insert(msg, s) - r, s = c:recv(timeout) - if not r then break end - end - c:close() - str = table.concat(msg) or "" - local gzip = response_header["Content-Encoding"] == "gzip" - return response_code, response_header, gzip and ((zlib.inflate(str:sub((offset or 0) + 1, -1))):read()) or str:sub((offset or 0) + 1, -1) -end +--- 模块功能:HTTP客户端 +-- @module httpv2 +-- @author 稀饭放姜 +-- @license MIT +-- @copyright OpenLuat.com +-- @release 2017.10.23 +require 'socket' +require 'utils' +module(..., package.seeall) + +local Content_type = {'application/x-www-form-urlencoded', 'application/json', 'application/octet-stream'} + +-- 处理表的url编码 +function urlencodeTab(params) + local msg = {} + for k, v in pairs(params) do + table.insert(msg, string.urlEncode(k) .. '=' .. string.urlEncode(v)) + table.insert(msg, '&') + end + table.remove(msg) + return table.concat(msg) +end +--- HTTP客户端 +-- @string method,提交方式"GET" or "POST" +-- @string url,HTTP请求超链接 +-- @number timeout,超时时间 +-- @param params,table类型,请求发送的查询字符串,通常为键值对表 +-- @param data,table类型,正文提交的body,通常为键值对、json或文件对象类似的表 +-- @number ctype,Content-Type的类型(可选1,2,3),默认1:"urlencode",2:"json",3:"octet-stream" +-- @string basic,HTTP客户端的authorization basic验证的"username:password" +-- @param headers,table类型,HTTP headers部分 +-- @param 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", --客户端证书文件密码[可选] +-- } +-- @return string,table,string,正常返回response_code, response_header, response_body +-- @return string,string,错误返回 response_code, error_message +-- @usage local c, h, b = httpv2.request(url, method, headers, body) +-- @usage local r, e = httpv2.request("http://wrong.url/ ") +function request(method, url, timeout, params, data, ctype, basic, headers, cert, fnc) + local response_header, response_code, response_body = {} + local _, idx, offset, ssl, auth, https, host, port, path + headers = headers or { + ['User-Agent'] = 'Mozilla/4.0', + ['Accept'] = '*/*', + ['Accept-Language'] = 'zh-CN,zh,cn', + ['Content-Type'] = 'application/x-www-form-urlencoded', + ['Content-Length'] = '0', + ['Connection'] = 'Keep-alive', + ["Keep-Alive"] = 'timeout=20', + } + ssl = string.find(rtos.get_version(), 'SSL') + -- 处理url的协议头和鉴权 + _, offset, https = url:find("^(%a+)://") + _, idx, auth = url:find("(.-:.-)@", (offset or 0) + 1) + offset = idx or offset + -- 判断SSL支持是否满足 + if not ssl and https and https:lower() == "https" then return '401', 'SOCKET_SSL_ERROR' end + -- 对host:port整形 + if url:match("^[^/]+:(%d+)", (offset or 0) + 1) then + _, offset, host, port = url:find("^([^/]+):(%d+)", (offset or 0) + 1) + elseif url:find("(.-)/", (offset or 0) + 1) then + _, offset, host = url:find("(.-)/", (offset or 0) + 1) + offset = offset - 1 + else + offset, host = #url, url:sub((offset or 0) + 1, -1) + end + if not host then return '105', 'ERR_NAME_NOT_RESOLVED' end + if not headers.Host then headers["Host"] = host end + port = port or (https == "https" and 443 or 80) + path = url:sub(offset + 1, -1) + path = path == "" and "/" or path + -- 处理查询字符串 + if params ~= nil and type(params) == 'table' then path = path .. '?' .. urlencodeTab(params) end + -- 处理HTTP协议body部分的数据 + ctype = ctype or 2 + headers['Content-Type'] = Content_type[ctype] + if ctype == 1 and type(data) == 'table' then + data = urlencodeTab(data) + headers['Content-Length'] = #data or 0 + elseif ctype == 2 and data ~= nil then + data = type(data) == 'string' and data or (type(data) == 'table' and json.encode(data)) or "" + headers['Content-Length'] = #data or 0 + elseif ctype == 3 and type(data) == 'string' then + headers['Content-Length'] = io.fileSize(data) or 0 + elseif data and type(data) == "string" then + headers['Content-Length'] = #data or 0 + end + -- 处理HTTP Basic Authorization 验证 + if auth then + headers['Authorization'] = 'Basic ' .. crypto.base64_encode(auth, #auth) + elseif type(basic) == 'string' then + headers['Authorization'] = 'Basic ' .. crypto.base64_encode(basic, #basic) + end + -- 处理headers部分 + local str = "" + for k, v in pairs(headers) do str = str .. k .. ": " .. v .. "\r\n" end + -- 发送请求报文 + while not socket.isReady() do sys.wait(1000) end + local c = socket.tcp(https == "https", cert) + if not c:connect(host, port) then + c:close() + return '502', 'SOCKET_CONN_ERROR' + end + if ctype ~= 3 then + str = method .. ' ' .. path .. ' HTTP/1.1\r\n' .. str .. '\r\n' .. (data or "") .. '\r\n' + -- log.info("发送的http报文:", str) + if not c:send(str) then + c:close() + return '426', 'SOCKET_SEND_ERROR' + end + else + str = method .. ' ' .. path .. ' HTTP/1.1\r\n' .. str .. '\r\n' + if not c:send(str) then + c:close() + return '426', 'SOCKET_SEND_ERROR' + end + local file = io.open(data, 'r') + if file then + while true do + local dat = file:read(8192) + if dat == nil then + io.close(file) + break + end + if not c:send(dat) then + io.close(file) + c:close() + return '426', 'SOCKET_SEND_ERROR' + end + end + end + if not c:send('\r\n') then + c:close() + return '426', 'SOCKET_SEND_ERROR' + end + end + ------------------------------------ 接收服务器返回消息部分 ------------------------------------ + local msg, str = {}, "" + local r, s = c:recv(timeout) + if not r then + c:close() + return '503', 'SOCKET_RECV_TIMOUT' + end + -- 处理状态代码 + _, idx, response_code = s:find("%s(%d+)%s.-\r\n") + _, offset = s:find('\r\n\r\n') + if not idx or not offset then return '501', 'SERVER_NOT_RESPONSE' end + log.info('httpv2.response code:', response_code) + -- 处理headers代码 + for k, v in string.gmatch(s:sub(idx + 1, offset), "(.-):%s*(.-)\r\n") do response_header[k] = v end + local len = response_header["Content-Range"] and tonumber(response_header["Content-Range"]:match("/(%d+)")) or tonumber(response_header["Content-Length"]) or 2147483648 + + s = s:sub((offset or 0) + 1, -1) + local cnt = #s + if tonumber(response_code) == 200 or tonumber(response_code) == 206 then + -- 处理body + while true do + if type(fnc) == "function" then + fnc(s, len) + else + table.insert(msg, s) + end + if cnt >= len then break end + r, s = c:recv(timeout) + if not r then break end + cnt = cnt + #s + end + s = table.concat(msg) or "" + end + c:close() + local gzip = response_header["Content-Encoding"] == "gzip" + return response_code, response_header, gzip and ((zlib.inflate(s)):read()) or s +end diff --git a/script_LuaTask/lib/lbsLoc.lua b/script_LuaTask/lib/lbsLoc.lua index ec991a3..dc68411 100644 --- a/script_LuaTask/lib/lbsLoc.lua +++ b/script_LuaTask/lib/lbsLoc.lua @@ -42,16 +42,15 @@ local function enCellInfo(s) end local function enWifiInfo(tWifi) - local ret,k,v = "" - if tWifi and #tWifi>0 then - ret = string.char(#tWifi) + local ret,cnt,k,v = "",0 + if tWifi then for k,v in pairs(tWifi) do log.info("lbsLoc.enWifiInfo",k,v) ret = ret..pack.pack("Ab",(k:gsub(":","")):fromHex(),v+255) + cnt = cnt+1 end end - - return ret + return string.char(cnt)..ret end local function trans(str) @@ -72,7 +71,7 @@ local function taskClient(cbFnc,reqAddr,timeout,productKey,host,port,reqTime,req local reqStr = pack.pack("bAbAAAA", productKey:len(), productKey, - (reqAddr and 2 or 0)+(reqTime and 4 or 0)+((reqWifi and #reqWifi~=0) and 16 or 0), + (reqAddr and 2 or 0)+(reqTime and 4 or 0)+(reqWifi and 16 or 0), "", common.numToBcdNum(misc.getImei()), enCellInfo(net.getCellInfoExt()), @@ -80,6 +79,7 @@ local function taskClient(cbFnc,reqAddr,timeout,productKey,host,port,reqTime,req log.info("reqStr",reqStr:toHex()) while true do sck = socket.udp() + if not sck then cbFnc(6) return end if sck:connect(host,port) then while true do if sck:send(reqStr) then @@ -87,12 +87,13 @@ local function taskClient(cbFnc,reqAddr,timeout,productKey,host,port,reqTime,req if result then sck:close() log.info("lbcLoc receive",data:toHex()) - if data:len()>=11 and data:byte(1)==0 then + if data:len()>=11 and (data:byte(1)==0 or data:byte(1)==0xFF) then cbFnc(0, trans(common.bcdNumToNum(data:sub(2,6))), trans(common.bcdNumToNum(data:sub(7,11))), reqAddr and data:sub(13,12+data:byte(12)) or nil, - data:sub(reqAddr and (13+data:byte(12)) or 12,-1)) + data:sub(reqAddr and (13+data:byte(12)) or 12,-1), + (data:byte(1)==0) and "LBS" or "WIFI") else log.warn("lbsLoc.query","根据基站查询经纬度失败") if data:byte(1)==2 then @@ -128,10 +129,21 @@ end --- 发送根据基站查询经纬度请求(仅支持中国区域的位置查询) -- @function cbFnc,用户回调函数,回调函数的调用形式为: --- cbFnc(result,lat,lng,addr) --- result:number类型,0表示成功,1表示网络环境尚未就绪,2表示连接服务器失败,3表示发送数据失败,4表示接收服务器应答超时,5表示服务器返回查询失败;为0时,后面的3个参数才有意义 +-- cbFnc(result,lat,lng,addr,dateTime,locType) +-- result:number类型 +-- 0表示成功 +-- 1表示网络环境尚未就绪 +-- 2表示连接服务器失败 +-- 3表示发送数据失败 +-- 4表示接收服务器应答超时 +-- 5表示服务器返回查询失败 +-- 6表示socket已满,创建socket失败 +-- 为0时,后面的5个参数才有意义 -- lat:string类型或者nil,纬度,整数部分3位,小数部分7位,例如"031.2425864" -- lng:string类型或者nil,经度,整数部分3位,小数部分7位,例如"121.4736522" +-- addr:无意义,保留使用 +-- dateTime:无意义,保留使用 +-- locType:string类型,位置类型,"LBS"表示基站定位位置,"WIFI"表示WIFI定位位置 -- @bool[opt=nil] reqAddr,此参数无意义,保留 -- @number[opt=20000] timeout,请求超时时间,单位毫秒,默认20000毫秒 -- @string[opt=nil] productKey,IOT网站上的产品证书,此参数可选,用户如果在main.lua中定义了PRODUCT_KEY变量,就不需要传入此参数 diff --git a/script_LuaTask/lib/mqtt.lua b/script_LuaTask/lib/mqtt.lua index 0b4a093..013761c 100644 --- a/script_LuaTask/lib/mqtt.lua +++ b/script_LuaTask/lib/mqtt.lua @@ -258,6 +258,7 @@ function mqttc:waitfor(id, timeout, msg) end while true do + local insertCache = true local r, data, param = self:read(timeout, msg) if r then if data.id == PUBLISH then @@ -272,12 +273,13 @@ function mqttc:waitfor(id, timeout, msg) log.info("mqtt.client:waitfor", "send ack fail", data.id == PUBREC and "PUBREC" or "PUBCOMP") return false end + insertCache = false end if data.id == id then return true, data end - table.insert(self.cache, data) + if insertCache then table.insert(self.cache, data) end else return false, data, param end diff --git a/script_LuaTask/lib/patch.lua b/script_LuaTask/lib/patch.lua index 10328a2..45df063 100644 --- a/script_LuaTask/lib/patch.lua +++ b/script_LuaTask/lib/patch.lua @@ -64,11 +64,11 @@ coroutine.resume = function(...) local traceBack = debug.traceback(co) traceBack = (traceBack and traceBack~="") and (arg[2].."\r\n"..traceBack) or arg[2] if errDump and errDump.appendErr and type(errDump.appendErr)=="function" then - errDump.appendErr(traceBack) - if _G.COROUTINE_ERROR_RESTART then rtos.restart() end + errDump.appendErr(traceBack) else log.error("coroutine.resume",traceBack) end + if _G.COROUTINE_ERROR_RESTART then rtos.restart() end end return unpack(arg) end diff --git a/script_LuaTask/lib/socket.lua b/script_LuaTask/lib/socket.lua index 1b6c6b5..ef3a148 100644 --- a/script_LuaTask/lib/socket.lua +++ b/script_LuaTask/lib/socket.lua @@ -48,6 +48,8 @@ local function stopConnectTimer(tSocket, id) end local function errorInd(error) + local coSuspended = {} + for k, v in pairs({sockets, socketsSsl}) do --if #v ~= 0 then for _, c in pairs(v) do -- IP状态出错时,通知所有已连接的socket @@ -56,12 +58,19 @@ local function errorInd(error) c.error = error if c.co and coroutine.status(c.co) == "suspended" then stopConnectTimer(v, c.id) - coroutine.resume(c.co, false) + --coroutine.resume(c.co, false) + table.insert(coSuspended,c.co) end --end end --end end + + for k, v in pairs(coSuspended) do + if v and coroutine.status(v) == "suspended" then + coroutine.resume(v, false) + end + end end sys.subscribe("IP_ERROR_IND", function()errorInd('IP_ERROR_IND') end) @@ -123,6 +132,7 @@ local function socket(protocol, cert) wait = "", connected = false, iSubscribe = false, + subMessage = nil, } tSocket = (ssl and socketsSsl or sockets) @@ -357,7 +367,7 @@ function mt:send(data) return false end - for i = 1, string.len(data), SENDSIZE do + for i = 1, string.len(data or ""), SENDSIZE do -- 按最大MTU单元对data分包 local stepData = string.sub(data, i, i + SENDSIZE - 1) --发送AT命令执行数据发送 @@ -386,13 +396,14 @@ function mt:recv(timeout, msg) return false end if msg and not self.iSubscribe then - self.iSubscribe = true - sys.subscribe(msg, function(data) - table.insert(self.output, data or "") - if self.wait == "+RECEIVE" then coroutine.resume(self.co, false) end - end) + self.iSubscribe = msg + self.subMessage = function(data) + if data then table.insert(self.output, data) end + if self.wait == "+RECEIVE" or self.wait == "+SSL RECEIVE" then coroutine.resume(self.co, 0xAA) end + end + sys.subscribe(msg, self.subMessage) end - if #self.output ~= 0 then sys.publish(msg) end + if msg and #self.output ~= 0 then sys.publish(msg, false) end if #self.input == 0 then self.wait = self.ssl and "+SSL RECEIVE" or "+RECEIVE" if timeout and timeout > 0 then @@ -407,7 +418,7 @@ function mt:recv(timeout, msg) -- end if r == nil then return false, "timeout" - elseif r == false then + elseif r == 0xAA then local dat = table.concat(self.output) self.output = {} return false, msg, dat @@ -445,10 +456,14 @@ end -- @usage c = socket.tcp(); c:connect(); c:send("123"); c:close() function mt:close() assert(self.co == coroutine.running(), "socket:close: coroutine mismatch") + if self.iSubscribe then + sys.unsubscribe(self.iSubscribe, self.subMessage) + self.iSubscribe = false + end if self.connected or self.created then self.connected = false self.created = false - req((self.ssl and "AT+SSLDESTROY=" or "AT+CIPCLOSE=") .. self.id) + req(self.ssl and ("AT+SSLDESTROY=" .. self.id) or ("AT+CIPCLOSE=" .. self.id .. ",0")) self.wait = self.ssl and "+SSLDESTROY" or "+CIPCLOSE" coroutine.yield() socketStatusNtfy() diff --git a/script_LuaTask/lib/sys.lua b/script_LuaTask/lib/sys.lua index 76ff547..71548a2 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.0" +SCRIPT_LIB_VER = "2.3.1" -- TaskID最大值 local TASK_TIMER_ID_MAX = 0x1FFFFFFF diff --git a/script_LuaTask/lib/utils.lua b/script_LuaTask/lib/utils.lua index 888835e..3c5ed3d 100644 --- a/script_LuaTask/lib/utils.lua +++ b/script_LuaTask/lib/utils.lua @@ -3,7 +3,7 @@ -- @author openLuat -- @license MIT -- @copyright openLuat --- @release 2017.10.19 +-- @release 2019.01.05 module(..., package.seeall) --- 将Lua字符串转成HEX字符串,如"123abc"转为"313233616263" @@ -49,37 +49,88 @@ end --- 返回utf8编码字符串的长度 -- @string str,utf8编码的字符串,支持中文 -- @return number,返回字符串长度 --- @usage local cnt = string.utf8Len("中国"),str = 2 +-- @usage local cnt = string.utf8Len("中国a"),cnt == 3 function string.utf8Len(str) - local len = #str - local left = len - local cnt = 0 - local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc} - while left ~= 0 do - local tmp = string.byte(str, -left) - local i = #arr - while arr[i] do - if tmp >= arr[i] then - left = left - i - break - end - i = i - 1 - end - cnt = cnt + 1 + local _, count = string.gsub(str, "[^\128-\193]", "") + return count +end + +--- 返回utf8编码字符串的单个utf8字符的table +-- @string str,utf8编码的字符串,支持中文 +-- @return table,utf8字符串的table +-- @usage local t = string.utf8ToTable("中国2018") +function string.utf8ToTable(str) + local tab = {} + for uchar in string.gfind(str, "[%z\1-\127\194-\244][\128-\191]*") do + tab[#tab + 1] = uchar end - return cnt + return tab end --- 将一个字符转为urlEncode编码 -local function urlEncodeChar(c) - return "%" .. string.format("%02X", string.byte(c)) + +--- 返回字符串的 RFC3986 编码 +-- @string str,要转换编码的字符串,支持UTF8编码中文 +-- @return str, RFC3986 编码的字符串 +-- @usage local str = string.rawurlEncode("####133") ,str == "%23%23%23%23133" +-- @usage local str = string.rawurlEncode("中国2018") , str == "%e4%b8%ad%e5%9b%bd2018" +function string.rawurlEncode(str) + local t = str:utf8ToTable() + for i = 1, #t do + if #t[i] == 1 then + t[i] = string.gsub(string.gsub(t[i], "([^%w_%~%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end), " ", "%%20") + else + t[i] = string.gsub(t[i], ".", function(c) return string.format("%%%02X", string.byte(c)) end) + end + end + return table.concat(t) end + --- 返回字符串的urlEncode编码 --- @string str,要转换编码的字符串 +-- @string str,要转换编码的字符串,支持UTF8编码中文 -- @return str,urlEncode编码的字符串 --- @usage string.urlEncode("####133") +-- @usage local str = string.urlEncode("####133") ,str == "%23%23%23%23133" +-- @usage local str = string.urlEncode("中国2018") , str == "%e4%b8%ad%e5%9b%bd2018" function string.urlEncode(str) - return string.gsub(string.gsub(string.gsub(tostring(str), "\n", "\r\n"), "([^%w%.%- ])", urlEncodeChar), " ", "+") + local t = str:utf8ToTable() + for i = 1, #t do + if #t[i] == 1 then + t[i] = string.gsub(string.gsub(t[i], "([^%w_%*%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end), " ", "+") + else + t[i] = string.gsub(t[i], ".", function(c) return string.format("%%%02X", string.byte(c)) end) + end + end + return table.concat(t) +end + +--- 返回一个迭代器函数,每次调用函数都会返回hash表的排序后的键值对 +-- @table t, 要排序的hash表 +-- @param f, 自定义排序函数 +-- @return function. +-- @usage test = {a=1,f=9,d=2,c=8,b=5} +-- @usage for name,line in pairsByKeys(test) do print(name,line) end +function table.gsort(t, f) + local a = {} + for n in pairs(t) do a[#a + 1] = n end + table.sort(a, f) + local i = 0 + return function() + i = i + 1 + return a[i], t[a[i]] + end end + +--- table.concat的增强版,支持嵌套字符串数组 +-- @table l,嵌套字符串数组 +-- @return string +-- @usage print(table.rconcat({"a",{" nice "}," and ", {{" long "},{" list "}}})) +function table.rconcat(l) + if type(l) ~= "table" then return l end + local res = {} + for i = 1, #l do + res[i] = rconcat(l[i]) + end + return table.concat(res) +end + --- 返回数字的千位符号格式 -- @number num,数字 -- @return string,千位符号的数字字符串 diff --git a/script_LuaTask/release notes.txt b/script_LuaTask/release notes.txt index 88ea88d..0ab8c65 100644 --- a/script_LuaTask/release notes.txt +++ b/script_LuaTask/release notes.txt @@ -1,4 +1,22 @@ -发布时间:2018/12/06 16:26 +发布时间:2019/01/22 17:41 +修改记录: + 一、lib脚本修改 + lib脚本版本号:2.3.1 + (1)mqtt.lua:修正“mqtt publish qos为2时的内存泄漏”问题 + 【问题重要性】:重要 + 【问题影响模块】:所有模块 + 【问题出现概率】:必现 + (2)lbsLoc.lua:1、新增socket创建失败的错误值返回;2、新增WIFI定位功能 + (3)socket.lua:修正一处代码隐患,可能由于用户脚本的某种使用方式,导致一处for循环运行异常 + 二、demo脚本修改 + (1)crypto:新增crypto.hmac_sha256算法的使用示例 + (2)i2c:新增i2c1和i2c2的使用示例 + (3)整理socket、mqtt、uart的demo目录 + + + + +发布时间:2018/12/06 16:26 修改记录: 一、lib脚本修改 lib脚本版本号:2.3.0 @@ -14,6 +32,7 @@ (3)Air268F:修正拍照测试时图像镜像的问题,需要配合Luat_VXXXX_8955F或者合Luat_VXXXX_8955F_FLOAT的版本使用,XXXX最低为0032 + 发布时间:2018/12/03 10:04 修改记录: 一、lib脚本修改 @@ -140,11 +159,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接口无法返回此小区信息”的问题