Browse Source

update: 去除无用的local前缀

chenxuuu 3 năm trước cách đây
mục cha
commit
840fce9313
66 tập tin đã thay đổi với 139 bổ sung139 xóa
  1. 2 2
      demo/adc/Air101/main.lua
  2. 2 2
      demo/adc/Air105/main.lua
  3. 2 2
      demo/adc/Air302/main.lua
  4. 1 1
      demo/airkiss/Air640w/main.lua
  5. 3 3
      demo/aliyun/Air302/main.lua
  6. 4 4
      demo/aliyun_autoreg/Air302/main.lua
  7. 4 4
      demo/aliyun_autoreg/Air640w/main.lua
  8. 3 3
      demo/camera/Air105/capture/main.lua
  9. 3 3
      demo/camera/Air105/capture_usb/main.lua
  10. 2 2
      demo/camera/Air105/scanner/main.lua
  11. 2 2
      demo/camera/Air105/synthesis/main.lua
  12. 1 1
      demo/coremark/main.lua
  13. 1 1
      demo/dbg/Air640w/main.lua
  14. 1 1
      demo/disp/Air640w/main.lua
  15. 1 1
      demo/echo/Air302/main.lua
  16. 1 1
      demo/hello_world/main.lua
  17. 3 3
      demo/http/Air640w/main.lua
  18. 1 1
      demo/http_download/Air302/main.lua
  19. 1 1
      demo/i2c/main.lua
  20. 1 1
      demo/ir/main.lua
  21. 1 1
      demo/json/main.lua
  22. 1 1
      demo/keyboard/Air105/main.lua
  23. 1 1
      demo/libcoap/Air302/main.lua
  24. 3 3
      demo/lvgl/Air101/button/main.lua
  25. 4 4
      demo/lvgl/Air101/touch/gt911.lua
  26. 1 1
      demo/lvgl/Air101/touch/main.lua
  27. 1 1
      demo/lvgl/win32/lvgl_demo/anim/main.lua
  28. 1 1
      demo/lvgl/win32/lvgl_demo/printer/main.lua
  29. 1 1
      demo/lvgl/win32/lvgl_demo/printer/printer.lua
  30. 1 1
      demo/lvgl/win32/lvgl_demo/screen_transitions/main.lua
  31. 1 1
      demo/lvgl/win32/lvgl_demo/slider_pregress/main.lua
  32. 1 1
      demo/lvgl/win32/lvgl_demo/switch_widget/main.lua
  33. 1 1
      demo/lvgl/win32/lvgl_load_font/main.lua
  34. 1 1
      demo/lvgl/win32/lwip_mqtt_test/main.lua
  35. 1 1
      demo/lvgl/win32/mqttcore_leak_test/main.lua
  36. 1 1
      demo/main.lua
  37. 1 1
      demo/meminfo/main.lua
  38. 4 4
      demo/modbus_relay2/Air640w/main.lua
  39. 1 1
      demo/modbus_rtu/main.lua
  40. 1 1
      demo/nimble/Air103/main.lua
  41. 4 4
      demo/nimble/nimble_led/main.lua
  42. 1 1
      demo/ntp/Air640w/main.lua
  43. 1 1
      demo/nvm/main.lua
  44. 3 3
      demo/ota/Air302/main.lua
  45. 3 3
      demo/ota/Air640w/main.lua
  46. 1 1
      demo/pwm/Air640w/main.lua
  47. 38 38
      demo/ril_8266/mqtt.lua
  48. 1 1
      demo/sdcard/Air640w/main.lua
  49. 1 1
      demo/sfud/Air101/main.lua
  50. 1 1
      demo/sfud/Air105/main.lua
  51. 1 1
      demo/sht20/main.lua
  52. 1 1
      demo/sht30/main.lua
  53. 1 1
      demo/socket/Air302/udp/main.lua
  54. 1 1
      demo/socket/Air640w/socket/main.lua
  55. 1 1
      demo/socket/Air640w/socket2/main.lua
  56. 1 1
      demo/socket/Air640w/udp/main.lua
  57. 1 1
      demo/socket/Air640w/udp_coap/main.lua
  58. 1 1
      demo/spi/main.lua
  59. 1 1
      demo/statem/Air101/main.lua
  60. 3 3
      demo/tlink_udp_ds18b20/Air302/main.lua
  61. 1 1
      demo/u8g2/Air640w/main.lua
  62. 1 1
      demo/uart/main.lua
  63. 1 1
      demo/usb_uart/main.lua
  64. 1 1
      demo/wifi/Air640w/main.lua
  65. 1 1
      demo/wifi_scan/Air640w/main.lua
  66. 1 1
      demo/ws2812/main.lua

+ 2 - 2
demo/adc/Air101/main.lua

@@ -6,7 +6,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 if wdt then
@@ -38,7 +38,7 @@ sys.taskInit(function()
         adc.close(11)
         sys.wait(500)
     end
-    
+
 end)
 
 

+ 2 - 2
demo/adc/Air105/main.lua

@@ -6,7 +6,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 if wdt then
@@ -26,7 +26,7 @@ sys.taskInit(function()
         adc.close(1)
         sys.wait(500)
     end
-    
+
 end)
 
 

+ 2 - 2
demo/adc/Air302/main.lua

@@ -4,7 +4,7 @@ PROJECT = "adcdemo"
 VERSION = "1.0.0"
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 -- 网络灯 GPIO19, NETLED脚
 local NETLED = gpio.setup(19, 0)     -- 初始化GPIO19, 并设置为低电平
@@ -33,7 +33,7 @@ sys.taskInit(function()
         adc.close(1)
         adc.close(2)
     end
-    
+
 end)
 
 

+ 1 - 1
demo/airkiss/Air640w/main.lua

@@ -3,7 +3,7 @@ PROJECT = "airkissdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 sys.subscribe("WLAN_READY", function ()
     print("!!! wlan ready event !!!")

+ 3 - 3
demo/aliyun/Air302/main.lua

@@ -4,7 +4,7 @@ PROJECT = "aliyun_demo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 local mqtt = require "mqtt"
 
 
@@ -81,7 +81,7 @@ sys.taskInit(function()
     -- 阿里云物联网的设备信息
     -- https://help.aliyun.com/document_detail/73742.html?spm=a2c4g.11186623.6.593.11a22cf0rGX1bC
     -- deviceName 可以是imei, 也可以自定义, 填写正确才能连接上
-    local productKey,deviceName,deviceSecret = "a1YFuY6OC1e","azNhIbNNTdsVwY2mhZno","5iRxTePbEMguOuZqltZrJBR0JjWJSdA7" 
+    local productKey,deviceName,deviceSecret = "a1YFuY6OC1e","azNhIbNNTdsVwY2mhZno","5iRxTePbEMguOuZqltZrJBR0JjWJSdA7"
     local host, port, selfid = productKey .. ".iot-as-mqtt.cn-shanghai.aliyuncs.com", 1883, nbiot.imei()
     local mqttClientId = selfid  .. "|securemode=3,signmethod=hmacsha1,timestamp=132323232|"
     local mqttUsername = deviceName .. "&" .. productKey
@@ -100,7 +100,7 @@ sys.taskInit(function()
     log.info("mqtt", "topic_user_get", topic_user_get)
     while true do
         -- 等待联网成功
-        while not socket.isReady() do 
+        while not socket.isReady() do
             log.info("net", "wait for network ready")
             sys.waitUntil("NET_READY", 1000)
         end

+ 4 - 4
demo/aliyun_autoreg/Air302/main.lua

@@ -12,7 +12,7 @@ regproxy服务的源码 https://gitee.com/openLuat/iot-regproxy
 ]]
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 local mqtt = require "mqtt"
 
 
@@ -86,11 +86,11 @@ end
 -- 连接到阿里云物联网的Task
 sys.taskInit(function()
     sys.wait(2000)
-    while not socket.isReady() do 
+    while not socket.isReady() do
         log.info("net", "wait for network ready")
         sys.waitUntil("NET_READY", 1000)
     end
-    
+
     -- 阿里云物联网的设备信息
     -- https://help.aliyun.com/document_detail/73742.html?spm=a2c4g.11186623.6.593.11a22cf0rGX1bC
     -- deviceName 是imei
@@ -152,7 +152,7 @@ sys.taskInit(function()
     log.info("mqtt", "topic_user_get", topic_user_get)
     while true do
         -- 等待联网成功
-        while not socket.isReady() do 
+        while not socket.isReady() do
             log.info("net", "wait for network ready")
             sys.waitUntil("NET_READY", 1000)
         end

+ 4 - 4
demo/aliyun_autoreg/Air640w/main.lua

@@ -12,7 +12,7 @@ regproxy服务的源码 https://gitee.com/openLuat/iot-regproxy
 ]]
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 local mqtt = require "mqtt"
 
 
@@ -62,11 +62,11 @@ end
 -- 连接到阿里云物联网的Task
 sys.taskInit(function()
     sys.wait(2000)
-    while not socket.isReady() do 
+    while not socket.isReady() do
         log.info("net", "wait for network ready")
         sys.waitUntil("NET_READY", 1000)
     end
-    
+
     -- 阿里云物联网的设备信息
     -- https://help.aliyun.com/document_detail/73742.html?spm=a2c4g.11186623.6.593.11a22cf0rGX1bC
     -- deviceName 是imei
@@ -128,7 +128,7 @@ sys.taskInit(function()
     log.info("mqtt", "topic_user_get", topic_user_get)
     while true do
         -- 等待联网成功
-        while not socket.isReady() do 
+        while not socket.isReady() do
             log.info("net", "wait for network ready")
             sys.waitUntil("NET_READY", 1000)
         end

+ 3 - 3
demo/camera/Air105/capture/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "camerademo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 --[[
 -- LCD接法示例, 以Air105开发板的HSPI(SPI5)为例
@@ -120,11 +120,11 @@ sys.taskInit(function()
             --     log.info("fs", #data)
             --     f:close()
             -- end
-        
+
             -- uart.write(uartid, data) --找个能保存数据的串口工具保存成文件就能在电脑上看了, 格式为JPG
         end
     end
-    
+
 end)
 
 -- 用户代码已结束---------------------------------------------

+ 3 - 3
demo/camera/Air105/capture_usb/main.lua

@@ -25,7 +25,7 @@
 PROJECT = "usbcamera"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     wdt.init(15000)--初始化watchdog设置为15s
@@ -80,7 +80,7 @@ camera.on(0, "scanned", function()
 end)
 
 sys.taskInit(function()
-    
+
     while 1 do
             -- 稍微等待一下
             sys.wait(100)
@@ -101,7 +101,7 @@ sys.taskInit(function()
                 uart.write(uart.VUART_0, data)
             end
     end
-    
+
 end)
 
 -- 用户代码已结束---------------------------------------------

+ 2 - 2
demo/camera/Air105/scanner/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "scanner"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 --[[
 -- LCD接法示例, 以Air105开发板的HSPI为例
@@ -84,7 +84,7 @@ usbapp.start(0)
 sys.taskInit(function()
     camera_rst(0)
     local camera_id = camera.init(GC032A_InitReg_Gray)--屏幕输出灰度图像并扫码
-    
+
     log.info("摄像头启动")
     camera.start(camera_id)--开始指定的camera
 end)

+ 2 - 2
demo/camera/Air105/synthesis/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "camerademo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 --[[
 -- LCD接法示例, 以Air105开发板的HSPI为例
@@ -96,7 +96,7 @@ sys.taskInit(function()
     -- local camera_id = camera.init(GC032A_InitReg)--屏幕输出rgb图像
     local camera_id = camera.init(GC032A_InitReg_Gray)--屏幕输出灰度图像并扫码
 
-    
+
     log.info("摄像头启动")
     camera.start(camera_id)--开始指定的camera
     sys.wait(2000)

+ 1 - 1
demo/coremark/main.lua

@@ -6,7 +6,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 --wdt.init(15000)--初始化watchdog设置为15s

+ 1 - 1
demo/dbg/Air640w/main.lua

@@ -24,7 +24,7 @@ enable = 1
 ]]
 dbg.wait()
 
-local sys = require("sys")
+sys = require("sys")
 
 local function call_abc(tag, val, date, time)
     log.info(tag, val, date)

+ 1 - 1
demo/disp/Air640w/main.lua

@@ -3,7 +3,7 @@ PROJECT = "dispdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 -- 日志TAG, 非必须
 local TAG = "main"

+ 1 - 1
demo/echo/Air302/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "echo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 sys.taskInit(function()
     while 1 do

+ 1 - 1
demo/hello_world/main.lua

@@ -4,7 +4,7 @@ PROJECT = "helloworld"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "hello world")
 

+ 3 - 3
demo/http/Air640w/main.lua

@@ -9,7 +9,7 @@ PROJECT = "httpdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 --_G.httpv2 = require("httpv2")
 
 log.info("main", "simple http demo")
@@ -40,7 +40,7 @@ if wlan ~= nil then
     -- 方法3 airkiss配网, 可参考 app/playit/main.lua
 end
 
--- airkiss.auto(27) -- 预留的功能,未完成 
+-- airkiss.auto(27) -- 预留的功能,未完成
 -- //////////////////////////////////////////////////////////////////////////////////////
 
 --- 从这里开始, 代码与具体网络无关
@@ -78,7 +78,7 @@ end)
 sys.taskInit(function()
     -- 等待联网成功
     while true do
-        while not socket.isReady() do 
+        while not socket.isReady() do
             log.info("net", "wait for network ready")
             sys.waitUntil("NET_READY", 1000)
         end

+ 1 - 1
demo/http_download/Air302/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "httpdw"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 sys.taskInit(function()
     while 1 do

+ 1 - 1
demo/i2c/main.lua

@@ -4,7 +4,7 @@ PROJECT = "i2c 24c02 demo"
 VERSION = "1.0.0"
 
 -- sys库是标配
-local sys = require "sys"
+sys = require("sys")
 
 --1010 000x
 --7bit地址,不包含最后一位读写位

+ 1 - 1
demo/ir/main.lua

@@ -4,7 +4,7 @@ PROJECT = "i2c 24c02 demo"
 VERSION = "1.0.0"
 
 -- sys库是标配
-local sys = require "sys"
+sys = require("sys")
 
 
 sys.taskInit(function()

+ 1 - 1
demo/json/main.lua

@@ -3,7 +3,7 @@ PROJECT = "jsondemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "json demo")
 print(json.null)

+ 1 - 1
demo/keyboard/Air105/main.lua

@@ -3,7 +3,7 @@ PROJECT = "keyboarddemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能

+ 1 - 1
demo/libcoap/Air302/main.lua

@@ -4,7 +4,7 @@ PROJECT = "coapdemo"
 VERSION = "1.0.0"
 
 -- sys库是标配
-local sys = require "sys"
+sys = require("sys")
 
 sys.taskInit(function()
     while 1 do

+ 3 - 3
demo/lvgl/Air101/button/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能
@@ -45,8 +45,8 @@ label = lvgl.label_create(btn2, nil)
 lvgl.label_set_text(label, "Toggled")
 end
 
-gpio.setup(pin.PA04, 
-    function(val) 
+gpio.setup(pin.PA04,
+    function(val)
         if val==0 then
             lvgl.indev_point_emulator_update(80,40,1)
         else

+ 4 - 4
demo/lvgl/Air101/touch/gt911.lua

@@ -30,7 +30,7 @@ sys.subscribe("GT911",gt911CallBack)
 
 
 local gt911 = {}
-local sys = require "sys"
+sys = require("sys")
 local i2cid
 
 local function gt911_send(...)
@@ -68,8 +68,8 @@ function gt911.init(gt911_i2c,gt911_res,gt911_int)
     gpio.set(gt911_res, 1)
     sys.wait(10)
 
-    gpio.setup(gt911_int, 
-        function(val) 
+    gpio.setup(gt911_int,
+        function(val)
             local count
             local data = gt911_recv(0x81, 0x4E)
             if data ~=0 then
@@ -92,7 +92,7 @@ function gt911.init(gt911_i2c,gt911_res,gt911_int)
             else
             end
         end,nil,gpio.RISING)
-        
+
     gt911_send(0x80, 0x40, 0x02)
     gt911_send(0x80, 0x40, 0x00)
     local touchic_id = gt911_recv(0x81, 0x40)

+ 1 - 1
demo/lvgl/Air101/touch/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能

+ 1 - 1
demo/lvgl/win32/lvgl_demo/anim/main.lua

@@ -1,4 +1,4 @@
-local sys = require "sys"
+sys = require("sys")
 
 log.info("sys", "from win32")
 

+ 1 - 1
demo/lvgl/win32/lvgl_demo/printer/main.lua

@@ -1,6 +1,6 @@
 
 
-local sys = require "sys"
+sys = require("sys")
 local printer = require "printer"
 
 log.info("sys", "from win32")

+ 1 - 1
demo/lvgl/win32/lvgl_demo/printer/printer.lua

@@ -1,4 +1,4 @@
-local sys = require "sys"
+sys = require("sys")
 local home = require "home"
 local setup = require "setup"
 local loader = require "loader"

+ 1 - 1
demo/lvgl/win32/lvgl_demo/screen_transitions/main.lua

@@ -6,7 +6,7 @@
 @date    2021.07.26
 ]]
 
-local sys = require "sys"
+sys = require("sys")
 local setup = require "setup_scr_screen"
 
 log.info("sys", "from win32")

+ 1 - 1
demo/lvgl/win32/lvgl_demo/slider_pregress/main.lua

@@ -6,7 +6,7 @@
 @date    2021.07.12
 ]]
 
-local sys = require "sys"
+sys = require("sys")
 
 log.info("sys", "from win32")
 

+ 1 - 1
demo/lvgl/win32/lvgl_demo/switch_widget/main.lua

@@ -6,7 +6,7 @@
 @date    2021.07.12
 ]]
 
-local sys = require "sys"
+sys = require("sys")
 
 log.info("sys", "from win32")
 

+ 1 - 1
demo/lvgl/win32/lvgl_load_font/main.lua

@@ -1,4 +1,4 @@
-local sys = require("sys")
+sys = require("sys")
 
 sys.taskInit(function ()
     sys.wait(1000)

+ 1 - 1
demo/lvgl/win32/lwip_mqtt_test/main.lua

@@ -1,6 +1,6 @@
 
 
-local sys = require "sys"
+sys = require("sys")
 
 log.info("sys", "from win32")
 

+ 1 - 1
demo/lvgl/win32/mqttcore_leak_test/main.lua

@@ -2,7 +2,7 @@
     testcase for mqttcore
     检验mqttcore是否存在内存泄漏的问题
 ]]
-local sys = require("sys")
+sys = require("sys")
 
 local packCONNECT = mqttcore.packCONNECT
 local packPUBLISH = mqttcore.packPUBLISH

+ 1 - 1
demo/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能

+ 1 - 1
demo/meminfo/main.lua

@@ -2,7 +2,7 @@
 PROJECT = "memdemo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 sys.taskInit(function()
     local count = 1

+ 4 - 4
demo/modbus_relay2/Air640w/main.lua

@@ -9,7 +9,7 @@ PROJECT = "modbus2relay"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "simple modbus relay demo")
 
@@ -38,7 +38,7 @@ if wlan ~= nil then
     -- 方法3 airkiss配网, 可参考 app/playit/main.lua
 end
 
--- airkiss.auto(27) -- 预留的功能,未完成 
+-- airkiss.auto(27) -- 预留的功能,未完成
 -- //////////////////////////////////////////////////////////////////////////////////////
 
 --- 从这里开始, 代码与具体网络无关
@@ -117,12 +117,12 @@ end
 sys.taskInit(function()
     -- 等待联网成功
     while true do
-        while not socket.isReady() do 
+        while not socket.isReady() do
             log.info("net", "wait for network ready")
             sys.waitUntil("NET_READY", 3000)
         end
         log.info("main", "socket loop")
-        
+
         collectgarbage("collect")
         local s = socket.tcp()
         s:host("modbus.git4.cn") -- 改成服务器ip或者域名

+ 1 - 1
demo/modbus_rtu/main.lua

@@ -2,7 +2,7 @@
 PROJECT = "modbus_rtu"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 sys.taskInit(function()
     uart.on(1, "recv", function(id, len)

+ 1 - 1
demo/nimble/Air103/main.lua

@@ -6,7 +6,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 if wdt then

+ 4 - 4
demo/nimble/nimble_led/main.lua

@@ -7,7 +7,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 一定要添加sys.lua !!!!
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 if wdt then
@@ -101,7 +101,7 @@ if nimble then
             nimble.server_deinit()
         end
     end)
-    
+
     -- 监听GATT服务器的WRITE_CHR事件
     sys.subscribe("BLE_GATT_WRITE_CHR", function(info, data)
         sys.timerStop(bulingbuling)
@@ -117,7 +117,7 @@ if nimble then
         -- led,b,off 对应 6c65642c622c6f6666
         -- led,c,off 对应 6c65642c632c6f6666
         -- display,xxx 对应 646973706C6179xxx, 支持中文
-        
+
         local cmd = data:split(",")
         if cmd[1] and cmds[cmd[1]] then
             cmds[cmd[1]](table.unpack(cmd, 2))
@@ -126,7 +126,7 @@ if nimble then
         end
     end)
 
-    
+
     -- TODO 支持传数据(read)和推送数据(notify)
 
 -- 配合微信小程序 "LuatOS蓝牙调试"

+ 1 - 1
demo/ntp/Air640w/main.lua

@@ -3,7 +3,7 @@ PROJECT = "ntpdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 sys.subscribe("WLAN_READY", function ()
     print("!!! wlan ready event !!!")

+ 1 - 1
demo/nvm/main.lua

@@ -7,7 +7,7 @@ VERSION = "1.0.0"
 ]]
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 require "config"--默认数据文件
 --引用nvm库

+ 3 - 3
demo/ota/Air302/main.lua

@@ -9,14 +9,14 @@ PROJECT_KEY = "01kgGFLlsfAabFuwJosS4surDNWOQCVH"
 
 log.info("version", VERSION) -- 打印版本号,就能知道是否升级成功
 
-local sys = require "sys"
+sys = require("sys")
 
 -- 生成OTA的URL
 -- local iot_url = "http://iot.nutz.cn/api/site/firmware_upgrade"
 local iot_url = "http://iot.openluat.com/api/site/firmware_upgrade"
-local ota_url = string.format("%s?project_key=%s&imei=%s&firmware_name=%s&version=%s", 
+local ota_url = string.format("%s?project_key=%s&imei=%s&firmware_name=%s&version=%s",
                         iot_url,
-                        PROJECT_KEY, 
+                        PROJECT_KEY,
                         nbiot.imei(),
                         PROJECT .. "_" .. rtos.firmware(),
                         VERSION

+ 3 - 3
demo/ota/Air640w/main.lua

@@ -9,15 +9,15 @@ PROJECT_KEY = "5aae50f068d9408c92b0fb5911834029"
 
 log.info("version", VERSION) -- 打印版本号,就能知道是否升级成功
 
-local sys = require "sys"
+sys = require("sys")
 
 wlan.connect("uiot", "1234567890")
 
 -- 生成OTA的URL
 local iot_url = "http://iot.nutz.cn/api/site/firmware_upgrade"
-local ota_url = string.format("%s?project_key=%s&imei=%s&firmware_name=%s&version=%s", 
+local ota_url = string.format("%s?project_key=%s&imei=%s&firmware_name=%s&version=%s",
                         iot_url,
-                        PROJECT_KEY, 
+                        PROJECT_KEY,
                         wlan.getMac(),
                         PROJECT .. "_" .. rtos.firmware(),
                         VERSION

+ 1 - 1
demo/pwm/Air640w/main.lua

@@ -4,7 +4,7 @@ PROJECT = "pwmdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "hello world")
 

+ 38 - 38
demo/ril_8266/mqtt.lua

@@ -12,7 +12,7 @@ local mqtt = {}
 local CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ, PINGRESP, DISCONNECT = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
 local CLIENT_COMMAND_TIMEOUT = 60000
 
-local sys = require "sys"
+sys = require("sys")
 local pack = _G.pack
 local string = _G.string
 local encodeLen = mqttcore.encodeLen
@@ -124,12 +124,12 @@ local packZeroData = mqttcore.packZeroData
 local function unpack(s)
     if #s < 2 then return end
     log.debug("mqtt.unpack", #s, string.toHex(string.sub(s, 1, 50)))
-    
+
     -- read remaining length
     local len = 0
     local multiplier = 1
     local pos = 2
-    
+
     repeat
         if pos > #s then return end
         local digit = string.byte(s, pos)
@@ -137,15 +137,15 @@ local function unpack(s)
         multiplier = multiplier * 128
         pos = pos + 1
     until digit < 128
-    
+
     if #s < len + pos - 1 then return end
-    
+
     local header = string.byte(s, 1)
-    
+
     --local packet = {id = (header - (header % 16)) / 16, dup = ((header % 16) - ((header % 16) % 8)) / 8, qos = bit.band(header, 0x06) / 2, retain = bit.band(header, 0x01)}
     local packet = {id = (header - (header % 16)) >> 4, dup = ((header % 16) - ((header % 16) % 8)) >> 3, qos = (header & 0x06) >> 1, retain = (header & 0x01)}
     local nextpos
-    
+
     if packet.id == CONNACK then
         nextpos, packet.ackFlag, packet.rc = pack.unpack(s, "bb", pos)
     elseif packet.id == PUBLISH then
@@ -161,7 +161,7 @@ local function unpack(s)
             packet.packetId = 0
         end
     end
-    
+
     return packet, pos + len
 end
 
@@ -185,13 +185,13 @@ mqttc.__index = mqttc
 function mqtt.client(clientId, keepAlive, username, password, cleanSession, will, version)
     local o = {}
     local packetId = 1
-    
+
     if will then
         will.flag = 1
     else
         will = {flag = 0, qos = 0, retain = 0, topic = "", payload = ""}
     end
-    
+
     o.clientId = clientId
     o.keepAlive = keepAlive or 300
     o.username = username or ""
@@ -209,9 +209,9 @@ function mqtt.client(clientId, keepAlive, username, password, cleanSession, will
     end
     o.lastOTime = 0
     o.pkgs = {}
-    
+
     setmetatable(o, mqttc)
-    
+
     return o
 end
 
@@ -294,7 +294,7 @@ function mqttc:waitfor(id, timeout, msg, msgNoResume)
             return true, table.remove(self.cache, index)
         end
     end
-    
+
     while true do
         local insertCache = true
         local r, data, param = self:read(timeout, msg, msgNoResume)
@@ -313,7 +313,7 @@ function mqttc:waitfor(id, timeout, msg, msgNoResume)
                 end
                 insertCache = false
             end
-            
+
             if data.id == id then
                 return true, data
             end
@@ -343,29 +343,29 @@ function mqttc:connect(host, port, transport, cert, timeout)
         log.info("mqtt.client:connect", "has connected")
         return false
     end
-    
+
     if self.io then
         self.io:close()
         self.io = nil
     end
-    
+
     if transport and transport ~= "tcp" and transport ~= "tcp_ssl" then
         log.info("mqtt.client:connect", "invalid transport", transport)
         return false
     end
-    
+
     self.io = socket.tcp(transport == "tcp_ssl" or type(cert) == "table", cert)
-    
+
     if not self.io:connect(host, port, timeout) then
         log.info("mqtt.client:connect", "connect host fail")
         return false
     end
-    
+
     if not self:write(packCONNECT(self.clientId, self.keepAlive, self.username, self.password, self.cleanSession, self.will, self.version)) then
         log.info("mqtt.client:connect", "send fail")
         return false
     end
-    
+
     local r, packet = self:waitfor(CONNACK, self.commandTimeout, nil, true)
     -- if not r or packet.rc ~= 0 then
     --     log.info("mqtt.client:connect", "connack error", r and packet.rc or -1)
@@ -375,9 +375,9 @@ function mqttc:connect(host, port, transport, cert, timeout)
         log.info("mqtt.client:connect", "connack error", r and packet.rc or -1)
         return false, packet and packet.rc or -1
     end
-    
+
     self.connected = true
-    
+
     return true
 end
 
@@ -393,30 +393,30 @@ function mqttc:subscribe(topic, qos)
         log.info("mqtt.client:subscribe", "not connected")
         return false
     end
-    
+
     local topics
     if type(topic) == "string" then
         topics = {[topic] = qos and qos or 0}
     else
         topics = topic
     end
-    
+
     if not self:write(packSUBSCRIBE(0, self.getNextPacketId(), topics)) then
         log.info("mqtt.client:subscribe", "send failed")
         return false
     end
-    
+
     local r, packet = self:waitfor(SUBACK, self.commandTimeout, nil, true)
     if not r then
         log.info("mqtt.client:subscribe", "wait ack failed")
         return false
     end
-    
+
     if not (packet.grantedQos and packet.grantedQos~="" and not packet.grantedQos:match(string.char(0x80))) then
         log.info("mqtt.client:subscribe", "suback grant qos error", packet.grantedQos)
         return false
     end
-    
+
     return true
 end
 
@@ -431,24 +431,24 @@ function mqttc:unsubscribe(topic)
         log.info("mqtt.client:unsubscribe", "not connected")
         return false
     end
-    
+
     local topics
     if type(topic) == "string" then
         topics = {topic}
     else
         topics = topic
     end
-    
+
     if not self:write(packUNSUBSCRIBE(0, self.getNextPacketId(), topics)) then
         log.info("mqtt.client:unsubscribe", "send failed")
         return false
     end
-    
+
     if not self:waitfor(UNSUBACK, self.commandTimeout, nil, true) then
         log.info("mqtt.client:unsubscribe", "wait ack failed")
         return false
     end
-    
+
     return true
 end
 
@@ -467,22 +467,22 @@ function mqttc:publish(topic, payload, qos, retain)
         log.info("mqtt.client:publish", "not connected")
         return false
     end
-    
+
     qos = qos or 0
     retain = retain or 0
-    
+
     if not self:write(packPUBLISH(0, qos, retain, qos > 0 and self.getNextPacketId() or 0, topic, payload)) then
         log.info("mqtt.client:publish", "socket send failed")
         return false
     end
-    
+
     if qos == 0 then return true end
-    
+
     if not self:waitfor(qos == 1 and PUBACK or PUBCOMP, self.commandTimeout, nil, true) then
         log.warn("mqtt.client:publish", "wait ack timeout")
         return false
     end
-    
+
     return true
 end
 
@@ -490,7 +490,7 @@ end
 -- @number timeout 接收超时时间,单位毫秒
 -- @string[opt=nil] msg 可选参数,控制socket所在的线程退出recv阻塞状态
 -- @return result 数据接收结果,true表示成功,false表示失败
--- @return data 
+-- @return data
 --                如果result为true,表示服务器发过来的mqtt包
 --
 --                如果result为false,超时失败,data为"timeout"
@@ -513,7 +513,7 @@ function mqttc:receive(timeout, msg)
         log.info("mqtt.client:receive", "not connected")
         return false
     end
-    
+
     return self:waitfor(PUBLISH, timeout, msg)
 end
 

+ 1 - 1
demo/sdcard/Air640w/main.lua

@@ -20,7 +20,7 @@ PROJECT = "tfdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "sdcard demo")
 

+ 1 - 1
demo/sfud/Air101/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 
 log.info("main", PROJECT, VERSION)
 
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 wdt.init(15000)--初始化watchdog设置为15s

+ 1 - 1
demo/sfud/Air105/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 
 log.info("main", PROJECT, VERSION)
 
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 wdt.init(15000)--初始化watchdog设置为15s

+ 1 - 1
demo/sht20/main.lua

@@ -4,7 +4,7 @@ PROJECT = "sht20demo"
 VERSION = "1.0.0"
 
 -- sys库是标配
-local sys = require "sys"
+sys = require("sys")
 
 -- 接线
 --[[

+ 1 - 1
demo/sht30/main.lua

@@ -4,7 +4,7 @@ PROJECT = "sht30demo"
 VERSION = "1.0.0"
 
 -- sys库是标配
-local sys = require "sys"
+sys = require("sys")
 
 -- 接线
 --[[

+ 1 - 1
demo/socket/Air302/udp/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "udpdemo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 -- V0004开始支持设置Band模式, 中移动的卡支持B8
 if nbiot.getBands then log.info("bands", nbiot.getBands()) end

+ 1 - 1
demo/socket/Air640w/socket/main.lua

@@ -3,7 +3,7 @@ PROJECT = "socketdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "socket demo")
 

+ 1 - 1
demo/socket/Air640w/socket2/main.lua

@@ -9,7 +9,7 @@ PROJECT = "socket2demo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 log.info("main", "socket demo, tcp long connect")
 

+ 1 - 1
demo/socket/Air640w/udp/main.lua

@@ -4,7 +4,7 @@ PROJECT = "udpdemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 wlan.connect("uiot", "12345678")
 

+ 1 - 1
demo/socket/Air640w/udp_coap/main.lua

@@ -4,7 +4,7 @@ PROJECT = "udpcoap"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 wlan.connect("uiot", "12345678")
 

+ 1 - 1
demo/spi/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "w25q_spi_demo"
 VERSION = "1.0.1"
 
-local sys = require "sys"
+sys = require("sys")
 
 --spi编号,请按实际情况修改!
 local spiId = 0

+ 1 - 1
demo/statem/Air101/main.lua

@@ -3,7 +3,7 @@
 PROJECT = "statemdemo"
 VERSION = "1.0.0"
 
-local sys = require "sys"
+sys = require("sys")
 
 --添加硬狗防止程序卡死
 wdt.init(15000)--初始化watchdog设置为15s

+ 3 - 3
demo/tlink_udp_ds18b20/Air302/main.lua

@@ -42,7 +42,7 @@ VERSION = "1.0.0"
     - 4.5 点击 "保存协议", 则 "当前协议" 会显示为 "[H:]  [D?]  [TE:0D0A]"
 5. 返回设备列表, 至此, 网页端的配置就完成了
 
-参考文档: 
+参考文档:
     - 创建设备 https://www.tlink.io/help.htm?menu=2
     - UDP 协议 https://www.tlink.io/help.htm?menu=2&page=46
     - 安卓APP  https://www.tlink.io/help.htm?menu=2&page=116
@@ -52,7 +52,7 @@ VERSION = "1.0.0"
     - 由UDP的特性决定, 不能100%保证数据能上报成功
 ]]
 
-local sys = require "sys"
+sys = require("sys")
 
 -----------------------------------------------------------------------------------
 --PM异常唤醒检测  休眠时间最低120S
@@ -178,7 +178,7 @@ function main_task()
             rtos.reboot()
         end
     end
-    -- 要求进入休眠状态,省电. 
+    -- 要求进入休眠状态,省电.
     -- 如修改休眠时长, 务必做到 "同比例"修改pm_wakeup_time_check里面的检测时长
     pm_enter_hib_mode(120)
 end

+ 1 - 1
demo/u8g2/Air640w/main.lua

@@ -3,7 +3,7 @@
 -- @author Dozingfiretruck
 -- @release 2021.01.25
 
-local sys = require("sys")
+sys = require("sys")
 
 --[[ 注意:如需使用u8g2的全中文字库需将 luat_base.h中#define USE_U8G2_WQY12_T_GB2312 打开]]
 

+ 1 - 1
demo/uart/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能

+ 1 - 1
demo/usb_uart/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能

+ 1 - 1
demo/wifi/Air640w/main.lua

@@ -3,7 +3,7 @@ PROJECT = "wifidemo"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 sys.subscribe("WLAN_READY", function ()
     print("!!! wlan ready event !!!")

+ 1 - 1
demo/wifi_scan/Air640w/main.lua

@@ -4,7 +4,7 @@ PROJECT = "wifiscan"
 VERSION = "1.0.0"
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 -- 打印demo信息, 免得下错demo了
 log.info("main", "wifi scan demo")

+ 1 - 1
demo/ws2812/main.lua

@@ -5,7 +5,7 @@ VERSION = "1.0.0"
 log.info("main", PROJECT, VERSION)
 
 -- 引入必要的库文件(lua编写), 内部库不需要require
-local sys = require "sys"
+sys = require("sys")
 
 if wdt then
     --添加硬狗防止程序卡死,在支持的设备上启用这个功能