From 3af73ef3d570b72e324c1550096fd9c911a89e24 Mon Sep 17 00:00:00 2001 From: zhutianhua Date: Fri, 24 May 2019 15:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83script=5FLuaTask=EF=BC=882.3.?= =?UTF-8?q?2=EF=BC=89=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=EF=BC=9A=20=20=20=20=20=E4=B8=80=E3=80=81lib=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=09lib=E8=84=9A=E6=9C=AC=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=EF=BC=9A2.3.2=20=09(1)aLiPay.lua=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=94=AF=E4=BB=98=E5=AE=9D=E5=8A=9F=E8=83=BD=20=09(2)?= =?UTF-8?q?errDump.lua=EF=BC=9A=E6=96=B0=E5=A2=9E=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E4=B8=8A=E6=8A=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=09(3)socket.lua=EF=BC=9A=E6=96=B0=E5=A2=9EsetSendM?= =?UTF-8?q?ode=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=8F=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=91=E9=80=81=E6=A8=A1=E5=BC=8F=EF=BC=88?= =?UTF-8?q?=E5=BF=AB=E5=8F=91=E8=BF=98=E6=98=AF=E6=85=A2=E5=8F=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/readme.txt | 4 +- core/release notes.txt | 13 +- script_LuaTask/demo/aLiPay/main.lua | 65 +++ script_LuaTask/demo/aLiPay/testALiPay.lua | 167 ++++++ script_LuaTask/demo/console/main.lua | 13 +- script_LuaTask/demo/crypto/testCrypto.lua | 42 +- .../mqtt/sync/sendInterruptRecv/testMqtt.lua | 2 + .../demo/mqtt/sync/sendWaitRecv/mqttTask.lua | 2 + .../socket/async/asyncSocket/testSocket.lua | 3 +- .../async/asyncSocketCallback/testSocket.lua | 3 +- .../sync/sendInterruptRecv/testSocket.lua | 3 + .../longConnection/socketTask.lua | 2 + .../longConnectionTransparent/socketTask.lua | 2 + .../shortConnection/socketTask.lua | 2 + .../shortConnectionFlymode/socketTask.lua | 2 + .../demo/ui/mono_std_spi_st7571.lua | 105 ++++ script_LuaTask/doc/lib/index.html | 7 +- script_LuaTask/doc/lib/modules/aLiPay.html | 514 ++++++++++++++++++ script_LuaTask/doc/lib/modules/aLiYun.html | 3 +- script_LuaTask/doc/lib/modules/aLiYunOta.html | 3 +- script_LuaTask/doc/lib/modules/agps.html | 3 +- script_LuaTask/doc/lib/modules/audio.html | 3 +- script_LuaTask/doc/lib/modules/cc.html | 3 +- script_LuaTask/doc/lib/modules/clib.html | 3 +- script_LuaTask/doc/lib/modules/common.html | 3 +- script_LuaTask/doc/lib/modules/console.html | 3 +- script_LuaTask/doc/lib/modules/errDump.html | 41 +- script_LuaTask/doc/lib/modules/gizwits.html | 3 +- script_LuaTask/doc/lib/modules/gps.html | 45 +- script_LuaTask/doc/lib/modules/gpsv2.html | 13 +- script_LuaTask/doc/lib/modules/http.html | 3 +- script_LuaTask/doc/lib/modules/httpv2.html | 3 +- script_LuaTask/doc/lib/modules/lbsLoc.html | 3 +- script_LuaTask/doc/lib/modules/led.html | 3 +- script_LuaTask/doc/lib/modules/link.html | 3 +- script_LuaTask/doc/lib/modules/log.html | 3 +- script_LuaTask/doc/lib/modules/misc.html | 3 +- script_LuaTask/doc/lib/modules/mqtt.html | 16 +- script_LuaTask/doc/lib/modules/net.html | 3 +- script_LuaTask/doc/lib/modules/netLed.html | 3 +- script_LuaTask/doc/lib/modules/ntp.html | 3 +- script_LuaTask/doc/lib/modules/nvm.html | 3 +- script_LuaTask/doc/lib/modules/patch.html | 3 +- script_LuaTask/doc/lib/modules/pb.html | 3 +- script_LuaTask/doc/lib/modules/pins.html | 3 +- script_LuaTask/doc/lib/modules/pm.html | 3 +- script_LuaTask/doc/lib/modules/powerKey.html | 3 +- script_LuaTask/doc/lib/modules/record.html | 3 +- script_LuaTask/doc/lib/modules/ril.html | 3 +- script_LuaTask/doc/lib/modules/scanCode.html | 3 +- script_LuaTask/doc/lib/modules/sim.html | 3 +- script_LuaTask/doc/lib/modules/sms.html | 3 +- script_LuaTask/doc/lib/modules/socket.html | 56 +- script_LuaTask/doc/lib/modules/sys.html | 5 +- script_LuaTask/doc/lib/modules/uiWin.html | 3 +- script_LuaTask/doc/lib/modules/update.html | 3 +- script_LuaTask/doc/lib/modules/utils.html | 5 +- script_LuaTask/doc/lib/modules/wdt.html | 3 +- script_LuaTask/lib/aLiPay.lua | 252 +++++++++ script_LuaTask/lib/aLiYun.lua | 47 +- script_LuaTask/lib/cc.lua | 1 + script_LuaTask/lib/errDump.lua | 99 +++- script_LuaTask/lib/gizwits.lua | 66 ++- script_LuaTask/lib/gps.lua | 10 +- script_LuaTask/lib/gpsv2.lua | 113 ++-- script_LuaTask/lib/httpv2.lua | 28 +- script_LuaTask/lib/lbsLoc.lua | 2 +- script_LuaTask/lib/link.lua | 10 +- script_LuaTask/lib/misc.lua | 1 - script_LuaTask/lib/mqtt.lua | 12 +- script_LuaTask/lib/net.lua | 12 +- script_LuaTask/lib/pins.lua | 24 +- script_LuaTask/lib/record.lua | 12 +- script_LuaTask/lib/ril.lua | 14 + script_LuaTask/lib/socket.lua | 64 ++- script_LuaTask/lib/sys.lua | 4 +- script_LuaTask/lib/utils.lua | 4 +- script_LuaTask/release notes.txt | 13 +- 78 files changed, 1815 insertions(+), 204 deletions(-) create mode 100644 script_LuaTask/demo/aLiPay/main.lua create mode 100644 script_LuaTask/demo/aLiPay/testALiPay.lua create mode 100644 script_LuaTask/demo/ui/mono_std_spi_st7571.lua create mode 100644 script_LuaTask/doc/lib/modules/aLiPay.html create mode 100644 script_LuaTask/lib/aLiPay.lua diff --git a/core/readme.txt b/core/readme.txt index 4d3accf..cfea60c 100644 --- a/core/readme.txt +++ b/core/readme.txt @@ -55,4 +55,6 @@ LuaDB 其中Lua运行内存1024KB,Luat框架引用的一些lua模块需要占用一定的运行内存,可通过sys.lua中的run函数中的代码--print("mem:",base.collectgarbage("count"))实时打印已占用的空间 -因flash空间有限,TTS_UI和TTS2的最后一个版本是0028,以后不再发布新的TTS_UI版本;如果同时使用这两项功能,购买Air202F或者Air268F模块,使用Luat_VXXXX_8955F.lod +因flash空间有限: +TTS_UI和TTS2的最后一个版本是0028,以后不再发布新的TTS_UI和TTS2版本;如果同时使用这两项功能,购买Air202F或者Air268F模块,使用Luat_VXXXX_8955F.lod +TTS1的最后一个版本是0033,以后不再发布新的TTS1版本;如果同时使用这两项功能,购买Air202F或者Air268F模块,使用Luat_VXXXX_8955F.lod diff --git a/core/release notes.txt b/core/release notes.txt index e98b74c..8e1302c 100644 --- a/core/release notes.txt +++ b/core/release notes.txt @@ -1,4 +1,15 @@ -锘跨増鏈彿锛歀uat_V0033_8955_XXX.lod +锘跨増鏈彿锛歀uat_V0034_8955_XXX.lod +鍙戝竷鏃堕棿锛2019/05/24 13:50 +淇敼璁板綍锛 + (1)鏀寔SHA256绠楁硶锛屼娇鐢ㄨ鏄庡弬鑰僣rypto鑴氭湰鐨刣emo + (2)CRC16绠楁硶鏀寔鑷畾涔夊弬鏁版ā鍨嬶紝浣跨敤璇存槑鍙傝僣rypto鑴氭湰鐨刣emo + (3)鏀寔DES ECB绠楁硶 + (4)鏀寔鏀粯瀹濆姛鑳斤紝浣跨敤璇存槑鍙傝僡LiPay鑴氭湰demo + (5)鏀寔uart.set_rs485_oe鎺ュ彛锛屽彲閰嶇疆rs485 io浣胯兘 + + + +鐗堟湰鍙凤細Luat_V0033_8955_XXX.lod 鍙戝竷鏃堕棿锛2019/01/22 15:34 淇敼璁板綍锛 (1)鏂板I2C1鍜孖2C2鍔熻兘 diff --git a/script_LuaTask/demo/aLiPay/main.lua b/script_LuaTask/demo/aLiPay/main.lua new file mode 100644 index 0000000..0f99355 --- /dev/null +++ b/script_LuaTask/demo/aLiPay/main.lua @@ -0,0 +1,65 @@ +--蹇呴』鍦ㄨ繖涓綅缃畾涔塒ROJECT鍜孷ERSION鍙橀噺 +--PROJECT锛歛scii string绫诲瀷锛屽彲浠ラ殢渚垮畾涔夛紝鍙涓嶄娇鐢,灏辫 +--VERSION锛歛scii string绫诲瀷锛屽鏋滀娇鐢↙uat鐗╄仈浜戝钩鍙板浐浠跺崌绾х殑鍔熻兘锛屽繀椤绘寜鐓"X.X.X"瀹氫箟锛孹琛ㄧず1浣嶆暟瀛楋紱鍚﹀垯鍙殢渚垮畾涔 +PROJECT = "ALIPAY" +VERSION = "2.0.0" + +--鍔犺浇鏃ュ織鍔熻兘妯″潡锛屽苟涓旇缃棩蹇楄緭鍑虹瓑绾 +--濡傛灉鍏抽棴璋冪敤log妯″潡鎺ュ彛杈撳嚭鐨勬棩蹇楋紝绛夌骇璁剧疆涓簂og.LOG_SILENT鍗冲彲 +require "log" +LOG_LEVEL = log.LOGLEVEL_TRACE +--[[ +濡傛灉浣跨敤UART杈撳嚭鏃ュ織锛屾墦寮杩欒娉ㄩ噴鐨勪唬鐮"--log.openTrace(true,1,115200)"鍗冲彲锛屾牴鎹嚜宸辩殑闇姹備慨鏀规鎺ュ彛鐨勫弬鏁 +濡傛灉瑕佸交搴曞叧闂剼鏈腑鐨勮緭鍑烘棩蹇楋紙鍖呮嫭璋冪敤log妯″潡鎺ュ彛鍜孡ua鏍囧噯print鎺ュ彛杈撳嚭鐨勬棩蹇楋級锛屾墽琛宭og.openTrace(false,绗簩涓弬鏁拌窡璋冪敤openTrace鎺ュ彛鎵撳紑鏃ュ織鐨勭浜屼釜鍙傛暟鐩稿悓)锛屼緥濡傦細 +1銆佹病鏈夎皟鐢ㄨ繃sys.opntrace閰嶇疆鏃ュ織杈撳嚭绔彛鎴栬呮渶鍚庝竴娆℃槸璋冪敤log.openTrace(true,nil,921600)閰嶇疆鏃ュ織杈撳嚭绔彛锛屾鏃惰鍏抽棴杈撳嚭鏃ュ織锛岀洿鎺ヨ皟鐢╨og.openTrace(false)鍗冲彲 +2銆佹渶鍚庝竴娆℃槸璋冪敤log.openTrace(true,1,115200)閰嶇疆鏃ュ織杈撳嚭绔彛锛屾鏃惰鍏抽棴杈撳嚭鏃ュ織锛岀洿鎺ヨ皟鐢╨og.openTrace(false,1)鍗冲彲 +]] +--log.openTrace(true,1,115200) + +require "sys" + +require "net" +--姣1鍒嗛挓鏌ヨ涓娆SM淇″彿寮哄害 +--姣1鍒嗛挓鏌ヨ涓娆″熀绔欎俊鎭 +net.startQueryAll(60000, 60000) + +--鍔犺浇鎺у埗鍙拌皟璇曞姛鑳芥ā鍧楋紙姝ゅ浠g爜閰嶇疆鐨勬槸uart1锛屾尝鐗圭巼115200锛 +--姝ゅ姛鑳芥ā鍧椾笉鏄繀椤荤殑锛屾牴鎹」鐩渶姹傚喅瀹氭槸鍚﹀姞杞 +--浣跨敤鏃舵敞鎰忥細鎺у埗鍙颁娇鐢ㄧ殑uart涓嶈鍜屽叾浠栧姛鑳戒娇鐢ㄧ殑uart鍐茬獊 +--require "console" +--console.setup(1, 115200) + +--鍔犺浇纭欢鐪嬮棬鐙楀姛鑳芥ā鍧 +--鏍规嵁鑷繁鐨勭‖浠堕厤缃喅瀹氾細1銆佹槸鍚﹀姞杞芥鍔熻兘妯″潡锛2銆侀厤缃甃uat妯″潡澶嶄綅鍗曠墖鏈哄紩鑴氬拰浜掔浉鍠傜嫍寮曡剼 +--鍚堝畽瀹樻柟鍑哄敭鐨凙ir201寮鍙戞澘涓婃湁纭欢鐪嬮棬鐙楋紝鎵浠ヤ娇鐢ㄥ畼鏂笰ir201寮鍙戞澘鏃讹紝蹇呴』鍔犺浇姝ゅ姛鑳芥ā鍧 +--[[ +require "wdt" +wdt.setup(pio.P0_30, pio.P0_31) +]] + +--鍔犺浇缃戠粶鎸囩ず鐏姛鑳芥ā鍧 +--鏍规嵁鑷繁鐨勯」鐩渶姹傚拰纭欢閰嶇疆鍐冲畾锛1銆佹槸鍚﹀姞杞芥鍔熻兘妯″潡锛2銆侀厤缃寚绀虹伅寮曡剼 +--鍚堝畽瀹樻柟鍑哄敭鐨凙ir800鍜孉ir801寮鍙戞澘涓婄殑鎸囩ず鐏紩鑴氫负pio.P0_28锛屽叾浠栧紑鍙戞澘涓婄殑鎸囩ず鐏紩鑴氫负pio.P1_1 +--require "netLed" +--netLed.setup(true,pio.P1_1) +--缃戠粶鎸囩ず鐏姛鑳芥ā鍧椾腑锛岄粯璁ら厤缃簡鍚勭宸ヤ綔鐘舵佷笅鎸囩ず鐏殑闂儊瑙勫緥锛屽弬鑰僴etLed.lua涓璴edBlinkTime閰嶇疆鐨勯粯璁ゅ +--濡傛灉榛樿鍊兼弧瓒充笉浜嗛渶姹傦紝姝ゅ璋冪敤netLed.updateBlinkTime鍘婚厤缃棯鐑佹椂闀 + +--鍔犺浇閿欒鏃ュ織绠$悊鍔熻兘妯″潡銆愬己鐑堝缓璁墦寮姝ゅ姛鑳姐 +--濡備笅2琛屼唬鐮侊紝鍙槸绠鍗曠殑婕旂ず濡備綍浣跨敤errDump鍔熻兘锛岃鎯呭弬鑰僥rrDump鐨刟pi +require "errDump" +errDump.request("udp://ota.airm2m.com:9072") + +--鍔犺浇杩滅▼鍗囩骇鍔熻兘妯″潡銆愬己鐑堝缓璁墦寮姝ゅ姛鑳斤紝濡傛灉浣跨敤浜嗛樋閲屼簯鐨凮TA鍔熻兘锛屽彲浠ヤ笉鎵撳紑姝ゅ姛鑳姐 +--濡備笅3琛屼唬鐮侊紝鍙槸绠鍗曠殑婕旂ず濡備綍浣跨敤update鍔熻兘锛岃鎯呭弬鑰僽pdate鐨刟pi浠ュ強demo/update +--PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K" +--require "update" +--update.request() + +--鍔犺浇鏀粯瀹濆姛鑳芥祴璇曟ā鍧 +require "testALiPay" + + +--鍚姩绯荤粺妗嗘灦 +sys.init(0, 0) +sys.run() diff --git a/script_LuaTask/demo/aLiPay/testALiPay.lua b/script_LuaTask/demo/aLiPay/testALiPay.lua new file mode 100644 index 0000000..8990bd9 --- /dev/null +++ b/script_LuaTask/demo/aLiPay/testALiPay.lua @@ -0,0 +1,167 @@ +--- 妯″潡鍔熻兘锛氭敮浠樺疂鍔熻兘娴嬭瘯. +-- @author openLuat +-- @module aLiYun.testALiYun +-- @license MIT +-- @copyright openLuat +-- @release 2019.03.31 + +module(...,package.seeall) + +require"aLiPay" +require"misc" +require"pm" + +--[[ +1銆佸鎴峰~鍐欒殏铓侀噾鏈岻OT璁惧淇℃伅褰曞叆妯℃澘涔嬪悗锛屽彂閫佺粰铓傝殎閲戞湇宸ヤ綔浜哄憳 +2銆佽殏铓侀噾鏈嶅伐浣滀汉鍛樺鐞嗕箣鍚庯紝浼氬彂閫佸嚭鏉ョ被浼间簬涓嬮潰鐨勯厤缃弬鏁扮粰瀹㈡埛: +鏈哄叿鍚嶇О锛氳嚜鍔╁敭鍗栨満閫氫俊妯″潡 +Item ID锛2019031301993185 +渚涘簲鍟嗭細涓婃捣鍚堝畽閫氫俊绉戞妧鏈夐檺鍏徃渚涘簲鍟 +Supplier ID锛201903131900940927 +璁惧绫诲埆 DEVICE_CATEGORY锛歋MART_RETAIL_MODULE +]] +--娉ㄦ剰锛氫笅闈㈢殑鍙傛暟鏄悎瀹欒嚜宸辩殑椤圭洰鍙傛暟锛屽鎴风涓娆℃祴璇曟椂锛屼竴瀹氳鏇存崲鑷繁鐨勯」鐩弬鏁 +--鍥犱负璁惧鍙兘鍦ㄧ涓娆$粦瀹氱殑椤圭洰涓嬩娇鐢 +--璁惧渚涘簲鍟嗙紪鍙,浣跨敤铓傝殎閲戞湇瀹㈡湇浜哄憳鎻愪緵鐨凷upplier ID鍙傛暟锛屽鏋滄暣鏈鸿澶囦緵搴斿晢鍜屾ā鍧椾緵搴斿晢鏄悓涓瀹讹紝鍒欎娇鐢ㄦā鍧椾緵搴斿晢鐨凷upplier ID鍙傛暟 +local sDeviceSupplier = "201903131900940927" +--璁惧杩愯惀鍟嗙紪鍙,浣跨敤铓傝殎閲戞湇瀹㈡湇浜哄憳鎻愪緵鐨凷upplier ID鍙傛暟锛屽鏋滄暣鏈鸿澶囪繍钀ュ晢鍜屾暣鏈鸿澶囦緵搴斿晢鏄悓涓瀹讹紝鍒欎娇鐢ㄦ暣鏈鸿澶囪繍钀ュ晢鐨凷upplier ID鍙傛暟 +local sMerchantUser = "201903131900940927" +--浜у搧韬唤璇嗗埆鍙,浣跨敤铓傝殎閲戞湇瀹㈡湇浜哄憳鎻愪緵鐨処tem ID鍙傛暟 +local sItemId = "2019031301993185" +--璁惧琛屼笟鍜岃澶囧舰鎬佺殑绮剧畝鎻忚堪,浣跨敤铓傝殎閲戞湇瀹㈡湇浜哄憳鎻愪緵鐨勮澶囩被鍒 DEVICE_CATEGORY 鍙傛暟 +local sProductKey = "SMART_RETAIL_MODULE" + + +--[[ +鍑芥暟鍚嶏細getDeviceSecret +鍔熻兘 锛氳幏鍙栬澶囩殑搴忓垪鍙 +鍙傛暟 锛氭棤 +杩斿洖鍊硷細璁惧搴忓垪鍙 +]] +local function getTerminalId() + --榛樿浣跨敤璁惧鐨凷N浣滀负璁惧搴忓垪鍙凤紝鐢ㄦ埛鍙互鏍规嵁椤圭洰闇姹傝嚜琛屼慨鏀 + return misc.getSn() + + --鐢ㄦ埛鍗曚綋娴嬭瘯鏃讹紝鍙互鍦ㄦ澶勭洿鎺ヨ繑鍥炲浐瀹氱殑瀛楃涓 + --return "IGIFHFACBFHIDEB" + --return "8ad5569a57cf038c" +end + +--鏀粯瀹濆鎴风鏄惁澶勪簬杩炴帴鐘舵 +local sConnected + +local sendTransactionDataCnt,sendProductInfoDataCnt,sendActDataCnt = 0,0,0 +local signCnt = 0; + +local sendTransactionDataFailCnt = 0 +--浜ゆ槗鏁版嵁缂撳瓨缁撴灉鍥炶皟 +local function sendTransactionDataCbFnc(result) + log.info("testALiPay.sendTransactionDataCbFnc",result,sendTransactionDataCnt) + if result then + sys.timerStart(sendTransactionDataTest,5000) + sendTransactionDataFailCnt = 0 + else + sys.timerStart(sendTransactionDataTest,50000) + sendTransactionDataFailCnt = sendTransactionDataFailCnt+1 + --鍥犱负鐩墠鏃犳硶鑾峰彇鏀粯瀹濊繛鎺ョ姸鎬侊紝浠ュ強浜ゆ槗鏁版嵁鍙戦佺粨鏋 + --濡傛灉杩炵画10娆$紦瀛樹氦鏄撴暟鎹け璐ワ紝鍙互鑰冭檻閲嶅惎 + --if( sendTransactionDataFailCnt>=50 then sys.restart("testAlipay.sendTransactionDataFail") end + end +end + +--缂撳瓨涓鏉′氦鏄撴暟鎹 +function sendTransactionDataTest() + log.info("testALiPay.sendTransactionDataTest",sConnected) + if sConnected then + sendTransactionDataCnt = sendTransactionDataCnt+1 + aLiPay.sendTransactionData("122345","",12,"","",sendTransactionDataCbFnc) + --[[ + if sendTransactionDataCnt%3==0 then + aLiPay.sendTransactionData("88899998888","98765",1234,4,5,sendTransactionDataCbFnc) + elseif sendTransactionDataCnt%3==1 then + aLiPay.sendTransactionData("12345698765",nil,nil,nil,1,sendTransactionDataCbFnc) + elseif sendTransactionDataCnt%3==2 then + aLiPay.sendTransactionData("12345698765","",100,"","",sendTransactionDataCbFnc) + end + ]] + end +end + +--浜у搧瑙勬牸鏁版嵁缂撳瓨缁撴灉鍥炶皟 +local function sendProductInfoDataCbFnc(result) + log.info("testALiPay.sendProductInfoDataCbFnc",result,sendProductInfoDataCnt) + --鏍规嵁铓傝殎閲戞湇鏂囨。璇存槑锛屼骇鍝佽鏍间俊鎭暟鎹紝姣忔寮鏈哄彧闇瑕佷笂鎶ヤ竴娆″嵆鍙 + if not result then + sys.timerStart(sendProductInfoDataTest,10000) + end +end + +--缂撳瓨涓鏉′骇鍝佽鏍间俊鎭暟鎹 +function sendProductInfoDataTest() + log.info("testALiPay.sendProductInfoDataTest",sConnected) + if sConnected then + sendProductInfoDataCnt = sendProductInfoDataCnt+1 + aLiPay.sendProductInfoData(0x01,sendProductInfoDataCbFnc) + end +end + +--琛屼负鏁版嵁缂撳瓨缁撴灉鍥炶皟 +local function sendActDataCbFnc(result) + log.info("testALiPay.sendActDataCbFnc",result,sendActDataCnt) + if result then + --鏍规嵁铓傝殎閲戞湇鏂囨。璇存槑锛岃涓烘暟鎹紝姣忓ぉ涓婃姤涓夋鍗冲彲 + sys.timerStart(sendActDataTest,8*3600*1000) + else + sys.timerStart(sendActDataTest,10000) + end +end + +--缂撳瓨涓鏉¤涓烘暟鎹 +function sendActDataTest() + log.info("testALiPay.sendActDataTest",sConnected) + if sConnected then + sendActDataCnt = sendActDataCnt+1 + aLiPay.sendActData(5,6,sendActDataCbFnc) + end +end + +--鍔犵鏁版嵁缁撴灉鍥炶皟 +local function signCbFnc(result,data) + log.info("testALiPay.signCbFnc",result,data) + sys.timerStart(signTest,5000) +end + +--鍔犵涓鏉℃暟鎹 +function signTest() + log.info("testALiPay.signTest") + signCnt = signCnt+1 + local amount = nil + if signCnt%2==0 then amount=tostring(signCnt) end + aLiPay.sign((signCnt%4)+1,"sign_data_"..signCnt,amount,signCbFnc) +end + + +--- 杩炴帴缁撴灉鐨勫鐞嗗嚱鏁 +-- @bool result锛岃繛鎺ョ粨鏋滐紝true琛ㄧず杩炴帴鎴愬姛锛宖alse鎴栬卬il琛ㄧず杩炴帴澶辫触 +local function connectCbFnc(result) + log.info("testALiPay.connectCbFnc",result) + sConnected = result + if result then + --鎵撳嵃璁惧鐨刡iztid + log.info("testALiPay.connectCbFnc","biztid",aLiPay.getBiztid()) + --涓婃姤浜ゆ槗鏁版嵁 + sendTransactionDataTest() + --涓婃姤浜у搧瑙勬牸淇℃伅鏁版嵁 + --sendProductInfoDataTest() + --涓婃姤琛屼负鏁版嵁 + --sendActDataTest() + --鍔犵 + --signTest() + --娴嬭瘯alipay鍏抽棴鍔熻兘 + --sys.timerStart(aLiPay.close,60000,function(result) log.info("testALiPay.closeCb",result) end) + end +end + +aLiPay.setup(sDeviceSupplier,sMerchantUser,sItemId,sProductKey,getTerminalId) +aLiPay.on("connect",connectCbFnc) + diff --git a/script_LuaTask/demo/console/main.lua b/script_LuaTask/demo/console/main.lua index d57dad9..fc20c39 100644 --- a/script_LuaTask/demo/console/main.lua +++ b/script_LuaTask/demo/console/main.lua @@ -15,7 +15,6 @@ LOG_LEVEL = log.LOGLEVEL_TRACE 2銆佹渶鍚庝竴娆℃槸璋冪敤log.openTrace(true,1,115200)閰嶇疆鏃ュ織杈撳嚭绔彛锛屾鏃惰鍏抽棴杈撳嚭鏃ュ織锛岀洿鎺ヨ皟鐢╨og.openTrace(false,1)鍗冲彲 ]] --log.openTrace(true,1,115200) - require "sys" require "net" @@ -31,7 +30,14 @@ require "misc" require "console" console.setup(1, 115200) require "httpv2" - +require "pins" +require "gpsv2" +pins.setup(pio.P0_28, 1) +local pwb = pins.setup(pio.P0_3, nil, pio.PULLDOWN) +sys.timerStart(function() + pwb(0) + rtos.poweroff() +end, 10000) --鍔犺浇纭欢鐪嬮棬鐙楀姛鑳芥ā鍧 --鏍规嵁鑷繁鐨勭‖浠堕厤缃喅瀹氾細1銆佹槸鍚﹀姞杞芥鍔熻兘妯″潡锛2銆侀厤缃甃uat妯″潡澶嶄綅鍗曠墖鏈哄紩鑴氬拰浜掔浉鍠傜嫍寮曡剼 --鍚堝畽瀹樻柟鍑哄敭鐨凙ir201寮鍙戞澘涓婃湁纭欢鐪嬮棬鐙楋紝鎵浠ヤ娇鐢ㄥ畼鏂笰ir201寮鍙戞澘鏃讹紝蹇呴』鍔犺浇姝ゅ姛鑳芥ā鍧 @@ -39,7 +45,6 @@ require "httpv2" require "wdt" wdt.setup(pio.P0_30, pio.P0_31) ]] - --鍔犺浇缃戠粶鎸囩ず鐏姛鑳芥ā鍧 --鏍规嵁鑷繁鐨勯」鐩渶姹傚拰纭欢閰嶇疆鍐冲畾锛1銆佹槸鍚﹀姞杞芥鍔熻兘妯″潡锛2銆侀厤缃寚绀虹伅寮曡剼 --鍚堝畽瀹樻柟鍑哄敭鐨凙ir800鍜孉ir801寮鍙戞澘涓婄殑鎸囩ず鐏紩鑴氫负pio.P0_28锛屽叾浠栧紑鍙戞澘涓婄殑鎸囩ず鐏紩鑴氫负pio.P1_1 @@ -47,7 +52,6 @@ wdt.setup(pio.P0_30, pio.P0_31) --netLed.setup(true,pio.P1_1) --缃戠粶鎸囩ず鐏姛鑳芥ā鍧椾腑锛岄粯璁ら厤缃簡鍚勭宸ヤ綔鐘舵佷笅鎸囩ず鐏殑闂儊瑙勫緥锛屽弬鑰僴etLed.lua涓璴edBlinkTime閰嶇疆鐨勯粯璁ゅ --濡傛灉榛樿鍊兼弧瓒充笉浜嗛渶姹傦紝姝ゅ璋冪敤netLed.updateBlinkTime鍘婚厤缃棯鐑佹椂闀 - --鍔犺浇閿欒鏃ュ織绠$悊鍔熻兘妯″潡銆愬己鐑堝缓璁墦寮姝ゅ姛鑳姐 --濡備笅2琛屼唬鐮侊紝鍙槸绠鍗曠殑婕旂ず濡備綍浣跨敤errDump鍔熻兘锛岃鎯呭弬鑰僥rrDump鐨刟pi require "errDump" @@ -58,7 +62,6 @@ errDump.request("udp://ota.airm2m.com:9072") --PRODUCT_KEY = "v32xEAKsGTIEQxtqgwCldp5aPlcnPs3K" --require "update" --update.request() - --鍔犺浇GPS鍔熻兘娴嬭瘯妯″潡 --鍚姩绯荤粺妗嗘灦 sys.init(0, 0) diff --git a/script_LuaTask/demo/crypto/testCrypto.lua b/script_LuaTask/demo/crypto/testCrypto.lua index 3cdd57d..3ceda5e 100644 --- a/script_LuaTask/demo/crypto/testCrypto.lua +++ b/script_LuaTask/demo/crypto/testCrypto.lua @@ -100,8 +100,8 @@ end -- @usage sha256Test() local function sha256Test() local originStr = "sdfdsfdsfdsffdsfdsfsdfs1234" - if crypto.sha256 then - log.info("testCrypto.sha256",crypto.sha256(originStr):toHex()) + if tonumber(string.match(rtos.get_version(),"Luat_V(%d+)_"))>=34 then + log.info("testCrypto.sha256",crypto.sha256(originStr)) end end @@ -132,6 +132,9 @@ local function crcTest() log.info("testCrypto.crc16_XMODEM",string.format("%04X",crypto.crc16("XMODEM",originStr))) log.info("testCrypto.crc16_DNP",string.format("%04X",crypto.crc16("DNP",originStr))) end + if tonumber(string.match(rtos.get_version(),"Luat_V(%d+)_"))>=34 then + log.info("testCrypto.USER-DEFINED",string.format("%04X",crypto.crc16("USER-DEFINED",originStr,0x8005,0x0000,0x0000,0,0))) + end log.info("testCrypto.crc16_modbus",string.format("%04X",crypto.crc16_modbus(originStr,slen(originStr)))) log.info("testCrypto.crc32",string.format("%08X",crypto.crc32(originStr,slen(originStr)))) @@ -333,6 +336,38 @@ local function aesTest() end end +--鍙傝冿細http://www.kjson.com/encrypt/enc/ +local function desTest() + --aes.encrypt鍜宎es.decrypt鎺ュ彛娴嬭瘯(V0020鐗堟湰鍚庣殑lod鎵嶆敮鎸佹鍔熻兘) + if tonumber(string.match(rtos.get_version(),"Luat_V(%d+)_"))>=34 then + local originStr = "123456789" + --鍔犲瘑妯″紡锛欵CB锛涘~鍏呮柟寮忥細ZeroPadding锛涘瘑閽ワ細12345678 + local encodeStr = crypto.des_encrypt("ECB","ZERO",originStr,"12345678") + print(originStr,"DES ECB ZeroPadding encrypt",string.toHex(encodeStr)) + log.info("DES ECB ZeroPadding decrypt",crypto.des_decrypt("ECB","ZERO",encodeStr,"12345678")) + + originStr = "123456789" + --鍔犲瘑妯″紡锛欵CB锛涘~鍏呮柟寮忥細Pkcs5Padding锛涘瘑閽ワ細12345678 + encodeStr = crypto.des_encrypt("ECB","PKCS5",originStr,"12345678") + print(originStr,"DES ECB Pkcs5Padding encrypt",string.toHex(encodeStr)) + log.info("DES ECB Pkcs5Padding decrypt",crypto.des_decrypt("ECB","PKCS5",encodeStr,"12345678")) + + originStr = "123456789" + --鍔犲瘑妯″紡锛欵CB锛涘~鍏呮柟寮忥細Pkcs7Padding锛涘瘑閽ワ細12345678 + encodeStr = crypto.des_encrypt("ECB","PKCS7",originStr,"12345678") + print(originStr,"DES ECB Pkcs7Padding encrypt",string.toHex(encodeStr)) + log.info("DES ECB Pkcs7Padding decrypt",crypto.des_decrypt("ECB","PKCS7",encodeStr,"12345678")) + + originStr = ("31323334353637383900000000000000"):fromHex() + --鍔犲瘑妯″紡锛欵CB锛涘~鍏呮柟寮忥細NONE锛涘瘑閽ワ細12345678 + encodeStr = crypto.des_encrypt("ECB","NONE",originStr,"12345678") + print(originStr,"DES ECB NonePadding encrypt",string.toHex(encodeStr)) + log.info("DES ECB NonePadding decrypt",string.toHex(crypto.des_decrypt("ECB","NONE",encodeStr,"12345678"))) + + + end +end + --- 绠楁硶娴嬭瘯鍏ュ彛 -- @return 鏃 -- @usage test() @@ -342,9 +377,10 @@ local function test() md5Test() hmacSha1Test() sha1Test() - --sha256Test() + sha256Test() crcTest() aesTest() + desTest() flowMd5Test() hmacSha256Test() --xxtea 闇瑕乴od鎵撳紑鏀寔 diff --git a/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua b/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua index fe0238d..440e16e 100644 --- a/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua +++ b/script_LuaTask/demo/mqtt/sync/sendInterruptRecv/testMqtt.lua @@ -10,6 +10,8 @@ module(..., package.seeall) -- 杩欓噷璇峰~鍐欎慨鏀逛负鑷繁鐨処P鍜岀鍙 local host, port = "lbsmqtt.airm2m.com", 1884 +socket.setSendMode(1) + -- 娴嬭瘯MQTT鐨勪换鍔′唬鐮 sys.taskInit(function() while true do diff --git a/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua index 486398b..41101fa 100644 --- a/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua +++ b/script_LuaTask/demo/mqtt/sync/sendWaitRecv/mqttTask.lua @@ -14,6 +14,8 @@ require"mqttInMsg" local ready = false +socket.setSendMode(1) + --- MQTT杩炴帴鏄惁澶勪簬婵娲荤姸鎬 -- @return 婵娲荤姸鎬佽繑鍥瀟rue锛岄潪婵娲荤姸鎬佽繑鍥瀎alse -- @usage mqttTask.isReady() diff --git a/script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua b/script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua index bfe88fd..9414999 100644 --- a/script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua +++ b/script_LuaTask/demo/socket/async/asyncSocket/testSocket.lua @@ -10,10 +10,11 @@ module(..., package.seeall) -- 姝ゅ鐨処P鍜岀鍙h濉笂浣犺嚜宸辩殑socket鏈嶅姟鍣ㄥ拰绔彛 local ip, port, c = "180.97.80.55", "12415" +socket.setSendMode(1) + -- 寮傛鎺ュ彛婕旂ず浠g爜 local asyncClient sys.taskInit(function() - local recv_cnt, send_cnt = 0, 0 while true do while not socket.isReady() do sys.wait(1000) end asyncClient = socket.tcp() diff --git a/script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua b/script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua index d11184d..4f932ae 100644 --- a/script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua +++ b/script_LuaTask/demo/socket/async/asyncSocketCallback/testSocket.lua @@ -10,10 +10,11 @@ module(..., package.seeall) -- 姝ゅ鐨処P鍜岀鍙h濉笂浣犺嚜宸辩殑socket鏈嶅姟鍣ㄥ拰绔彛 local ip, port, c = "180.97.80.55", "12415" +socket.setSendMode(1) + -- 寮傛鎺ュ彛婕旂ず浠g爜 local asyncClient sys.taskInit(function() - local recv_cnt, send_cnt = 0, 0 while true do while not socket.isReady() do sys.wait(1000) end asyncClient = socket.tcp() diff --git a/script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua b/script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua index 32911e8..e77c896 100644 --- a/script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua +++ b/script_LuaTask/demo/socket/sync/sendInterruptRecv/testSocket.lua @@ -9,6 +9,9 @@ module(..., package.seeall) -- 姝ゅ鐨処P鍜岀鍙h濉笂浣犺嚜宸辩殑socket鏈嶅姟鍣ㄥ拰绔彛 local ip, port = "180.97.80.55",12415 + +socket.setSendMode(1) + -- tcp test sys.taskInit(function() local r, s, p diff --git a/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua index 8a255f5..37daf3a 100644 --- a/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua +++ b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnection/socketTask.lua @@ -27,6 +27,8 @@ function isReady() return ready end +socket.setSendMode(1) + --鍚姩socket瀹㈡埛绔换鍔 sys.taskInit( function() diff --git a/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua index 602f03e..479efd9 100644 --- a/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua +++ b/script_LuaTask/demo/socket/sync/sendWaitRecv/longConnectionTransparent/socketTask.lua @@ -28,6 +28,8 @@ function isReady() return ready end +socket.setSendMode(1) + --鍚姩socket瀹㈡埛绔换鍔 sys.taskInit( function() diff --git a/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua index f16170f..2fa451a 100644 --- a/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua +++ b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnection/socketTask.lua @@ -9,6 +9,8 @@ module(...,package.seeall) require"socket" +socket.setSendMode(1) + --鍚姩socket瀹㈡埛绔换鍔 sys.taskInit( function() diff --git a/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua index 68f4705..6a479c4 100644 --- a/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua +++ b/script_LuaTask/demo/socket/sync/sendWaitRecv/shortConnectionFlymode/socketTask.lua @@ -9,6 +9,8 @@ module(...,package.seeall) require"socket" +socket.setSendMode(1) + --鍚姩socket瀹㈡埛绔换鍔 sys.taskInit( function() diff --git a/script_LuaTask/demo/ui/mono_std_spi_st7571.lua b/script_LuaTask/demo/ui/mono_std_spi_st7571.lua new file mode 100644 index 0000000..0ac8e68 --- /dev/null +++ b/script_LuaTask/demo/ui/mono_std_spi_st7571.lua @@ -0,0 +1,105 @@ +--- 妯″潡鍔熻兘锛歋T 7567椹卞姩鑺墖LCD鍛戒护閰嶇疆 +-- @author openLuat +-- @module ui.mono_std_spi_st7567 +-- @license MIT +-- @copyright openLuat +-- @release 2018.03.27 + +--[[ +娉ㄦ剰锛歞isp搴撶洰鍓嶆敮鎸両2C鎺ュ彛鍜孲PI鎺ュ彛鐨勫睆锛屾鏂囦欢鐨勯厤缃紝纭欢涓婁娇鐢ㄧ殑鏄爣鍑嗙殑SPI寮曡剼锛屼笉鏄疞CD涓撶敤鐨凷PI寮曡剼 +纭欢杩炵嚎鍥惧涓嬶細 +Air妯″潡 LCD +GND--鍦 +SPI_CS--鐗囬 +SPI_CLK--鏃堕挓 +SPI_DO--鏁版嵁 +SPI_DI--鏁版嵁/鍛戒护閫夋嫨 +VDDIO--鐢垫簮 +UART1_CTS--澶嶄綅 +娉ㄦ剰锛欰ir202鏃╂湡鐨勫紑鍙戞澘锛孶ART1鐨凜TS鍜孯TS鐨勪笣鍗板弽浜 +]] + +module(...,package.seeall) + +--[[ +鍑芥暟鍚嶏細init +鍔熻兘 锛氬垵濮嬪寲LCD鍙傛暟 +鍙傛暟 锛氭棤 +杩斿洖鍊硷細鏃 +]] +local function init() + local para = + { + width = 128, --鍒嗚鲸鐜囧搴︼紝128鍍忕礌锛涚敤鎴锋牴鎹睆鐨勫弬鏁拌嚜琛屼慨鏀 + height = 96, --鍒嗚鲸鐜囬珮搴︼紝96鍍忕礌锛涚敤鎴锋牴鎹睆鐨勫弬鏁拌嚜琛屼慨鏀 + bpp = 1, --浣嶆繁搴︼紝1琛ㄧず鍗曡壊銆傚崟鑹插睆灏辫缃负1锛屼笉鍙慨鏀 + bus = disp.BUS_SPI, --led浣嶆爣鍑哠PI鎺ュ彛锛屼笉鍙慨鏀 + hwfillcolor = 0xffff, --濉厖鑹诧紝榛戣壊 + yoffset = 0, + pinrst = pio.P0_3, --reset锛屽浣嶅紩鑴 + pinrs = pio.P0_12, --rs锛屽懡浠/鏁版嵁閫夋嫨寮曡剼 + --鍒濆鍖栧懡浠 + initcmd = + { + ----[[ + 0xAE,--Display OFF + 0x38,--MODE SET + 0x7c,--棰戠巼 70Hz 卤20% ,fficiency Level 4 + 0x48,--Set Display Duty + 0x60,-- + 0xA0,-- ADC select, ADC=1 =>reverse direction + 0xC8,-- SHL select, SHL=1 => reverse direction + 0x44,--Set initial COM0 register + 0x00,-- + 0x40,--Set initial display line register + 0x00,-- + 0xAB,-- OSC. ON + 0x66,--渚涚數鐩稿叧 + 0x26,--鐢靛帇涔嬬被鐨 + 0x81,-- Set Reference Voltage + 0x32,--EV + 0x55,--Set LCD Bias + 0x93,-- Set FRC and PWM mode (4FRC & 15PWM) + 0x2c,-- Power Control, VC: ON VR: OFF VF: OFF + 0x000100c8, --寤舵椂200ms + 0x2e,-- Power Control, VC: ON VR: ON VF: OFF + 0x000100c8, --寤舵椂200ms + 0x2F,-- Power Control, VC: ON VR: ON VF: ON + 0x0001000f, --寤舵椂10ms + 0xAF, + --]] + + }, + --]] + --浼戠湢鍛戒护 + sleepcmd = { + 0xAE, + }, + --鍞ら啋鍛戒护 + wakecmd = { + 0xAF, + } + } + disp.init(para) + disp.clear() + disp.update() +end + +require"pins" +local rs = pins.setup(pio.P0_12,0) +disp.update = function () + local pic = disp.getframe() + rs(0) + spi.send(spi.SPI_1,string.char(0xb0,0x10))--璁剧疆璧峰椤典笌鍒 + rs(1) + for i=1,pic:len() do--鍙戞暟鎹 + local data = pic:sub(i,i) + spi.send(spi.SPI_1,data) + spi.send(spi.SPI_1,data) + end + rs(0) +end + +--鎺у埗SPI寮曡剼鐨勭數鍘嬪煙 +pmd.ldoset(6,pmd.LDO_VMMC) +init() diff --git a/script_LuaTask/doc/lib/index.html b/script_LuaTask/doc/lib/index.html index f801023..23f868f 100644 --- a/script_LuaTask/doc/lib/index.html +++ b/script_LuaTask/doc/lib/index.html @@ -31,6 +31,7 @@

script_LuaTask lib

Modules