Quellcode durchsuchen

update: script/libs 整个拍扁,取消目录结构

Wendal Chen vor 3 Jahren
Ursprung
Commit
24082be4a4
71 geänderte Dateien mit 145 neuen und 1045 gelöschten Zeilen
  1. 1 1
      script/README.md
  2. 0 0
      script/corelib/sys.lua
  3. 0 0
      script/corelib/sysplus.lua
  4. 0 32
      script/libs/README.md
  5. 0 0
      script/libs/ads1115.lua
  6. 0 27
      script/libs/ads1115/README.md
  7. 0 12
      script/libs/ads1115/meta.json
  8. 0 0
      script/libs/adxl34x.lua
  9. 0 27
      script/libs/adxl34x/README.md
  10. 0 12
      script/libs/adxl34x/meta.json
  11. 0 0
      script/libs/aht10.lua
  12. 0 27
      script/libs/aht10/README.md
  13. 0 12
      script/libs/aht10/meta.json
  14. 0 0
      script/libs/bh1750.lua
  15. 0 27
      script/libs/bh1750/README.md
  16. 0 12
      script/libs/bh1750/meta.json
  17. 0 0
      script/libs/bmx.lua
  18. 0 38
      script/libs/bmx/README.md
  19. 0 12
      script/libs/bmx/meta.json
  20. 0 8
      script/libs/core/package.json
  21. 0 0
      script/libs/ds3231.lua
  22. 0 33
      script/libs/ds3231/README.md
  23. 0 12
      script/libs/ds3231/meta.json
  24. 0 0
      script/libs/gt911.lua
  25. 0 34
      script/libs/gt911/README.md
  26. 0 12
      script/libs/gt911/meta.json
  27. 0 0
      script/libs/l3g4200d.lua
  28. 0 27
      script/libs/l3g4200d/README.md
  29. 0 12
      script/libs/l3g4200d/meta.json
  30. 0 0
      script/libs/lbsLoc.lua
  31. 0 57
      script/libs/lbsLoc/README.md
  32. 0 12
      script/libs/lbsLoc/meta.json
  33. 144 0
      script/libs/libnet.lua
  34. 0 0
      script/libs/lis2dh12.lua
  35. 0 27
      script/libs/lis2dh12/README.md
  36. 0 12
      script/libs/lis2dh12/meta.json
  37. 0 0
      script/libs/lm75.lua
  38. 0 29
      script/libs/lm75/README.md
  39. 0 12
      script/libs/lm75/meta.json
  40. 0 0
      script/libs/mcp2515.lua
  41. 0 42
      script/libs/mcp2515/README.md
  42. 0 12
      script/libs/mcp2515/meta.json
  43. 0 0
      script/libs/mpu6xxx.lua
  44. 0 31
      script/libs/mpu6xxx/README.md
  45. 0 12
      script/libs/mpu6xxx/meta.json
  46. 0 0
      script/libs/pac9685.lua
  47. 0 0
      script/libs/pcf8574.lua
  48. 0 29
      script/libs/pcf8574/README.md
  49. 0 12
      script/libs/pcf8574/meta.json
  50. 0 0
      script/libs/qmc5883l.lua
  51. 0 27
      script/libs/qmc5883l/README.md
  52. 0 12
      script/libs/qmc5883l/meta.json
  53. 0 0
      script/libs/rc522.lua
  54. 0 31
      script/libs/rc522/README.md
  55. 0 12
      script/libs/rc522/meta.json
  56. 0 0
      script/libs/si24r1.lua
  57. 0 39
      script/libs/si24r1/README.md
  58. 0 12
      script/libs/si24r1/meta.json
  59. 0 0
      script/libs/tcs3472.lua
  60. 0 32
      script/libs/tcs3472/README.md
  61. 0 12
      script/libs/tcs3472/meta.json
  62. 0 0
      script/libs/tm1637.lua
  63. 0 27
      script/libs/tm1637/README.md
  64. 0 12
      script/libs/tm1637/meta.json
  65. 0 0
      script/libs/tsl2561.lua
  66. 0 27
      script/libs/tsl2561/README.md
  67. 0 12
      script/libs/tsl2561/meta.json
  68. 0 93
      script/libs/update_inline_libs.lua
  69. 0 0
      script/libs/xmodem.lua
  70. 0 21
      script/libs/xmodem/README.md
  71. 0 12
      script/libs/xmodem/meta.json

+ 1 - 1
script/README.md

@@ -5,8 +5,8 @@
 |目录名称|目录内容|着重点|典型示例|
 |--------|-------|----|---------|
 |[libs](libs)|外部库合集|外设驱动或控制|将外设驱动做成标准化的库|[ADS1115](libs/peripheral/ADS1115)|
-|[demo](../demo) |内置库的实例|单一库API用法|[GPIO控制](../demo/gpio)|
 |[turnkey](turnkey)|准项目级方案|真实项目的演示|[扫码枪turnkey](turnkey/scanner_air105/)|
+|[corelib](corelib)|核心库|系统核心库|已内置在固件内|基本固件,不做修改|
 
 ## demo 简述
 

+ 0 - 0
script/libs/core/sys.lua → script/corelib/sys.lua


+ 0 - 0
script/libs/core/sysplus.lua → script/corelib/sysplus.lua


+ 0 - 32
script/libs/README.md

@@ -1,32 +0,0 @@
-# LuatOS包仓库
-
-## 介绍
-
-存放和管理LuatOS的库文件, 包含纯C/纯Lua/Lua-C混合的各种库文件
-
-## 包管理要求
-
-1. 语法正确. 请尽量兼容air和soc固件
-2. 包含package.json, 添加基本的描述信息
-
-## 如何提交新的库或修改
-
-1. 欢迎使用pull request提交
-2. 若使用git有困难, 也欢迎通过邮件方式提交到 wendal@openluat.com
-3. 提交到本库的代码, 自动应用MIT协议, 请留意代码来源, 确保合法合规
-
-## Ask for help
-
-1. wiki站 wiki.luatos.com
-2. Q_Q群 1061642968
-
-## 库列表
-
-本列表不定期更新
-
-|名称|状态|用途|依赖|备注|
-|----|----|---|----|----|
-|[核心库](core/)|已发布|核心脚本|无|已内置|
-|[ads1115](ads1115/)|已发布|模数转换器|i2c||
-|[adxl34x](adxl34x/)|已发布|3轴加速度计|i2c||
-

+ 0 - 0
script/libs/ads1115/ads1115.lua → script/libs/ads1115.lua


+ 0 - 27
script/libs/ads1115/README.md

@@ -1,27 +0,0 @@
-# ADS1115 驱动
-
-超小型 16位 精密 模数转换器 ADC 开发板模块
-
-## 用法示例
-
-```lua
-
-local ads1115 = require "ads1115"
-i2cid = 0 -- 根据实际设备选择
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    ads1115.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local ads1115_data = ads1115.get_val()
-        log.info("ads1115_get_val", ads1115_data)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=ADS1115

+ 0 - 12
script/libs/ads1115/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/ads1115",
-    "tags" : ["ads1115"],
-    "version" : "1.0.0",
-    "title" : "ADS1115数模转换的驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "ads1115.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/adxl34x/adxl34x.lua → script/libs/adxl34x.lua


+ 0 - 27
script/libs/adxl34x/README.md

@@ -1,27 +0,0 @@
-# ADXL34X 驱动
-
-3轴 加速度计 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local adxl34x = require "adxl34x"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    adxl34x.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local adxl34x_data = adxl34x.get_data()
-        log.info("adxl34x_data", "adxl34x_data.x"..(adxl34x_data.x),"adxl34x_data.y"..(adxl34x_data.y),"adxl34x_data.z"..(adxl34x_data.z))
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=ADXL34

+ 0 - 12
script/libs/adxl34x/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/adxl34x",
-    "tags" : ["adxl34x"],
-    "version" : "1.0.0",
-    "title" : "ADXL34X 3轴加速度计驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "adxl34x.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/aht10/aht10.lua → script/libs/aht10.lua


+ 0 - 27
script/libs/aht10/README.md

@@ -1,27 +0,0 @@
-# AHT10 驱动
-
-温湿度传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local aht10 = require "aht10"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    aht10.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local aht10_data = aht10.get_data()
-        log.info("aht10_data", "aht10_data.RH:"..(aht10_data.RH*100).."%","aht10_data.T"..(aht10_data.T).."℃")
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=AHT10

+ 0 - 12
script/libs/aht10/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/aht10",
-    "tags" : ["aht10"],
-    "version" : "1.0.0",
-    "title" : "AHT10 温湿度传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "aht10.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/bh1750/bh1750.lua → script/libs/bh1750.lua


+ 0 - 27
script/libs/bh1750/README.md

@@ -1,27 +0,0 @@
-# BH1750 驱动
-
-数字型光强度传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local bh1750 = require "bh1750"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    bh1750.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local bh1750_data = bh1750.read_light()
-        log.info("bh1750_read_light", bh1750_data)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=BH1750

+ 0 - 12
script/libs/bh1750/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/bh1750",
-    "tags" : ["bh1750"],
-    "version" : "1.0.0",
-    "title" : "BH1750 数字型光强度传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "bh1750.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/bmx/bmx.lua → script/libs/bmx.lua


+ 0 - 38
script/libs/bmx/README.md

@@ -1,38 +0,0 @@
-# BMX 驱动
-
-气压传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local bmx = require "bmx"
-i2cid = 0
-i2c_speed = i2c.SLOW
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    bmx.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local bmx_data = bmx.get_data()
-        if bmx_data.temp then
-            log.info("bmx_data_data.temp:"..(bmx_data.temp).."°C")
-        end
-        if bmx_data.press then
-            log.info("bmx_data_data.press:"..(bmx_data.press).."hPa")
-        end
-        if bmx_data.high then
-            log.info("bmx_data_data.high:"..(bmx_data.high).."m")
-        end
-        if bmx_data.hum then
-            log.info("bmx_data_data.hum:"..(bmx_data.hum).."%")
-        end
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=BMX

+ 0 - 12
script/libs/bmx/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/bmx",
-    "tags" : ["bmp180","bmp280","bme280","bme680"],
-    "version" : "1.0.0",
-    "title" : "BMX 气压传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "bmx.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 8
script/libs/core/package.json

@@ -1,8 +0,0 @@
-{
-    "type" : "lua",
-    "enterpoint" : "sys.lua",
-    "compatibility" : {
-        "soc" : true
-    },
-    "dependency" : []
-}

+ 0 - 0
script/libs/ds3231/ds3231.lua → script/libs/ds3231.lua


+ 0 - 33
script/libs/ds3231/README.md

@@ -1,33 +0,0 @@
-# DS3231 驱动
-
-实时时钟传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local ds3231 = require "ds3231"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    ds3231.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        log.info("ds3231.get_temperature", ds3231.get_temperature())
-        local time = ds3231.read_time()
-        log.info("ds3231.read_time",time.tm_year,time.tm_mon,time.tm_mday,time.tm_hour,time.tm_min,time.tm_sec)
-        sys.wait(5000)
-        local set_time = {tm_year=2021,tm_mon=3,tm_mday=0,tm_wday=0,tm_hour=0,tm_min=0,tm_sec=0}
-        ds3231.set_time(set_time)
-        time = ds3231.read_time()
-        log.info("ds3231_read_time",time.tm_year,time.tm_mon,time.tm_mday,time.tm_hour,time.tm_min,time.tm_sec)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=DS3231

+ 0 - 12
script/libs/ds3231/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/ds3231",
-    "tags" : ["ds3231"],
-    "version" : "1.0.0",
-    "title" : "DS3231 实时时钟传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "ds3231.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/gt911/gt911.lua → script/libs/gt911.lua


+ 0 - 34
script/libs/gt911/README.md

@@ -1,34 +0,0 @@
-# GT911 驱动
-
-电容触摸驱动 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local gt911 = require "gt911"
-
-local i2cid = 0
-local gt911_res = pin.PA07
-local gt911_int = pin.PA00
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    gt911.init(i2cid,gt911_res,gt911_int)
-    while 1 do
-        sys.wait(1000)
-    end
-end)
-
-local function gt911CallBack(press_sta,i,x,y)
-    print(press_sta,i,x,y)
-end
-
-sys.subscribe("GT911",gt911CallBack)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=GT911

+ 0 - 12
script/libs/gt911/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/gt911",
-    "tags" : ["gt911"],
-    "version" : "1.0.0",
-    "title" : "GT911 电容触摸驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "gt911.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/l3g4200d/l3g4200d.lua → script/libs/l3g4200d.lua


+ 0 - 27
script/libs/l3g4200d/README.md

@@ -1,27 +0,0 @@
-# L3G4200D 驱动
-
-3轴 加速度计 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local l3g4200d = require "l3g4200d"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    l3g4200d.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-    local l3g4200d_data = l3g4200d.get_data()
-    log.info("l3g4200d_data", l3g4200d_data.x,l3g4200d_data.y,l3g4200d_data.z)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=L3G4200D

+ 0 - 12
script/libs/l3g4200d/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/l3g4200d",
-    "tags" : ["l3g4200d"],
-    "version" : "1.0.0",
-    "title" : "L3G4200D 3轴加速度计驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "l3g4200d.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/lbsLoc/lbsLoc.lua → script/libs/lbsLoc.lua


+ 0 - 57
script/libs/lbsLoc/README.md

@@ -1,57 +0,0 @@
-# lbsLoc 发送基站定位请求
-
-air780E lbsLoc 发送基站定位请求
-
-## 用法示例
-
-```lua
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "lbslocdemo"
-VERSION = "1.0.0"
-PRODUCT_KEY = "VmhtOb81EgZau6YyuuZJzwF6oUNGCbXi"
-log.info("main", PROJECT, VERSION)
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-local lbsLoc = require("lbsLoc")                          
-local function reqLbsLoc()
-    lbsLoc.request(getLocCb)
-end
---[[
-功能  :获取基站对应的经纬度后的回调函数
-参数  :
-		result:number类型,0表示成功,1表示网络环境尚未就绪,2表示连接服务器失败,3表示发送数据失败,4表示接收服务器应答超时,5表示服务器返回查询失败;为0时,后面的5个参数才有意义
-		lat:string类型,纬度,整数部分3位,小数部分7位,例如031.2425864
-		lng:string类型,经度,整数部分3位,小数部分7位,例如121.4736522
-        addr:目前无意义
-        time:string类型或者nil,服务器返回的时间,6个字节,年月日时分秒,需要转为十六进制读取
-            第一个字节:年减去2000,例如2017年,则为0x11
-            第二个字节:月,例如7月则为0x07,12月则为0x0C
-            第三个字节:日,例如11日则为0x0B
-            第四个字节:时,例如18时则为0x12
-            第五个字节:分,例如59分则为0x3B
-            第六个字节:秒,例如48秒则为0x30
-        locType:numble类型或者nil,定位类型,0表示基站定位成功,255表示WIFI定位成功
-返回值:无
-]]
-function getLocCb(result, lat, lng, addr, time, locType)
-    log.info("testLbsLoc.getLocCb", result, lat, lng)
-    -- 获取经纬度成功
-    if result == 0 then
-        log.info("服务器返回的时间", time:toHex())
-        log.info("定位类型,基站定位成功返回0", locType)
-    end
-    sys.timerStart(reqLbsLoc,20000)
-end
-
-reqLbsLoc()
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!
-```
-
-
-
-

+ 0 - 12
script/libs/lbsLoc/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/lbsLoc",
-    "tags" : ["lbsLoc"],
-    "version" : "1.0.0",
-    "title" : "lbsLoc 发送基站定位请求",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "lbsLoc.lua",
-    "dependency" : ["mobile"]
-}

+ 144 - 0
script/libs/libnet.lua

@@ -0,0 +1,144 @@
+local libnet = {}
+
+--- 阻塞等待网卡的网络连接上,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.linkup一致
+-- @return 失败或者超时返回false 成功返回true
+function libnet.waitLink(taskName, timeout, ...)
+	local is_err, result = socket.linkup(...)
+	if is_err then
+		return false
+	end
+	if not result then
+		result = sys_wait(taskName, socket.LINK, timeout)
+	else
+		return true
+	end
+	if type(result) == 'table' and result[2] == 0 then
+		return true
+	else
+		return false
+	end
+end
+
+--- 阻塞等待IP或者域名连接上,如果加密连接还要等握手完成,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.connect一致
+-- @return 失败或者超时返回false 成功返回true
+function libnet.connect(taskName,timeout, ... )
+	local is_err, result = socket.connect(...)
+	if is_err then
+		return false
+	end
+	if not result then
+		result = sys_wait(taskName, socket.ON_LINE, timeout)
+	else
+		return true
+	end
+	if type(result) == 'table' and result[2] == 0 then
+		return true
+	else
+		return false
+	end
+end
+
+--- 阻塞等待客户端连接上,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.listen一致
+-- @return 失败或者超时返回false 成功返回true
+function libnet.listen(taskName,timeout, ... )
+	local is_err, result = socket.listen(...)
+	if is_err then
+		return false
+	end
+	if not result then
+		result = sys_wait(taskName, socket.ON_LINE, timeout)
+	else
+		return true
+	end
+	if type(result) == 'table' and result[2] == 0 then
+		return true
+	else
+		return false
+	end
+end
+
+--- 阻塞等待数据发送完成,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.tx一致
+-- @return 
+-- @boolean 失败或者超时返回false,缓冲区满了或者成功返回true
+-- @boolean 缓存区是否满了
+function libnet.tx(taskName,timeout, ...)
+	local is_err, is_full, result = socket.tx(...)
+	if is_err then
+		return false, is_full
+	end
+	if is_full then
+		return true, true
+	end
+	if not result then
+		result = sys_wait(taskName, socket.TX_OK, timeout)
+	else
+		return true, is_full
+	end
+	if type(result) == 'table' and result[2] == 0 then
+		return true, false
+	else
+		return false, is_full
+	end
+end
+
+--- 阻塞等待新的网络事件或者特定事件,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.wait一致
+-- @return 
+-- @boolean 网络异常返回false,其他返回true
+-- @table or boolean 超时返回false,有新的数据到返回true,被其他事件退出的,返回接收到的事件
+function libnet.wait(taskName,timeout, netc)
+	local is_err, result = socket.wait(netc)
+	if is_err then
+		return false,false
+	end
+	if not result then
+		result = sys_wait(taskName, socket.EVENT, timeout)
+	else
+		return true,true
+	end
+	if type(result) == 'table' then
+		if result[2] == 0 then
+			return true, true
+		else
+			return false, false
+		end
+	else
+		return true, false
+	end
+end
+
+--- 阻塞等待网络断开连接,只能用于任务函数中
+-- @string 任务标志
+-- @int 超时时间,如果==0或者空,则没有超时一致等待
+-- @... 其他参数和socket.close一致
+-- @return 无
+function libnet.close(taskName,timeout, netc)
+	local is_err, result = socket.discon(netc)
+	if is_err then
+		socket.close(netc)
+		return
+	end
+	if not result then
+		result = sys_wait(taskName, socket.CLOSED, timeout)
+	else
+		socket.close(netc)
+		return
+	end
+	socket.close(netc)
+end
+
+return libnet

+ 0 - 0
script/libs/lis2dh12/lis2dh12.lua → script/libs/lis2dh12.lua


+ 0 - 27
script/libs/lis2dh12/README.md

@@ -1,27 +0,0 @@
-# LIS2DH12 驱动
-
-3轴 加速度计 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local lis2dh12 = require "lis2dh12"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    lis2dh12.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local lis2dh12_data = lis2dh12.get_data()
-        log.info("lis2dh12_data", "lis2dh12_data.x"..(lis2dh12_data.x),"lis2dh12_data.y"..(lis2dh12_data.y),"lis2dh12_data.z"..(lis2dh12_data.z),"lis2dh12_data.temp"..(lis2dh12_data.temp))
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=LIS2DH12

+ 0 - 12
script/libs/lis2dh12/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/lis2dh12",
-    "tags" : ["lis2dh12"],
-    "version" : "1.0.0",
-    "title" : "LIS2DH12 3轴加速度计驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "lis2dh12.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/lm75/lm75.lua → script/libs/lm75.lua


+ 0 - 29
script/libs/lm75/README.md

@@ -1,29 +0,0 @@
-# LM75 驱动
-
-温度传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local lm75 = require "lm75"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    lm75.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local lm75_data = lm75.get_data()
-        if lm75_data then
-            log.info("lm75_data", lm75_data.."℃")
-        end
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=LM75

+ 0 - 12
script/libs/lm75/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/lm75",
-    "tags" : ["lm75"],
-    "version" : "1.0.0",
-    "title" : "LM75 温度传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "lm75.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/mcp2515/mcp2515.lua → script/libs/mcp2515.lua


+ 0 - 42
script/libs/mcp2515/README.md

@@ -1,42 +0,0 @@
-# mcp2515 SP转CAN
-
-CAN总线模块. 请务必确认硬件ok, 某宝上的CAN总线模块质量堪忧.
-
-## 用法示例
-
-```lua
-
-local mcp2515 = require "mcp2515"
-
--- mcp2515    mcu
--- csk      spi_sck
--- si       spi_mosi
--- so       spi_miso
--- cs       spi_cs
--- int      gpio
-
-sys.subscribe("mcp2515", function(len,buff,config)
-    print("mcp2515", len,buff:byte(1,len))
-    for k, v in pairs(config) do
-        print(k,v)
-    end
-end)
-
-sys.taskInit(function()
-    local mcp2515_spi= 0
-    local mcp2515_cs= pin.PB04
-    local mcp2515_int= pin.PB01
-    spi_mcp2515 = spi.setup(mcp2515_spi,nil,0,0,8,10*1000*1000,spi.MSB,1,0)
-    mcp2515.init(mcp2515_spi,mcp2515_cs,mcp2515_int,mcp2515.CAN_500Kbps)
-
-    mcp2515.send_buffer({id = 0x7FF,ide = false,rtr = false},0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07)--标准帧,数据帧
-    mcp2515.send_buffer({id = 0x1FFFFFE6,ide = true,rtr = false},0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07)--扩展帧,数据帧
-    mcp2515.send_buffer({id = 0x7FF,ide = false,rtr = true},0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07)--标准帧,远程帧
-    mcp2515.send_buffer({id = 0x1FFFFFE6,ide = true,rtr = true},0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07)--扩展帧,远程帧
-
-end)
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=mcp2515

+ 0 - 12
script/libs/mcp2515/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/mcp2515",
-    "tags" : ["mcp2515", "sit2512", "can"],
-    "version" : "1.0.0",
-    "title" : "SPI转CAN驱动,兼容mcp2515/sit2515",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "mcp2515.lua",
-    "dependency" : ["spi"]
-}

+ 0 - 0
script/libs/mpu6xxx/mpu6xxx.lua → script/libs/mpu6xxx.lua


+ 0 - 31
script/libs/mpu6xxx/README.md

@@ -1,31 +0,0 @@
-# MPU6XXX 驱动
-
-加速度计 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local mpu6xxx = require "mpu6xxx"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    mpu6xxx.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        sys.wait(100)
-        local temp = mpu6xxx.get_temp()--获取温度
-        log.info("6050temp", temp)
-        local accel = mpu6xxx.get_accel()--获取加速度
-        log.info("6050accel", "accel.x",accel.x,"accel.y",accel.y,"accel.z",accel.z)
-        local gyro = mpu6xxx.get_gyro()--获取陀螺仪
-        log.info("6050gyro", "gyro.x",gyro.x,"gyro.y",gyro.y,"gyro.z",gyro.z)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=MPU6XXX

+ 0 - 12
script/libs/mpu6xxx/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/mpu6xxx",
-    "tags" : ["mpu6500","mpu6050","mpu9250","icm2068g","icm20608d"],
-    "version" : "1.0.0",
-    "title" : "MPU6XXX 加速度计驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "mpu6xxx.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/pac9685.lua


+ 0 - 0
script/libs/pcf8574/pcf8574.lua → script/libs/pcf8574.lua


+ 0 - 29
script/libs/pcf8574/README.md

@@ -1,29 +0,0 @@
-# LM75 驱动
-
-IO扩展 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local pcf8574 = require "pcf8574"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    pcf8574.init(i2cid)--初始化,传入i2c_id
-    for i=0,7 do
-        print(pcf8574.pin(i))
-    end
-    pcf8574.pin(0,1)
-    for i=0,7 do
-        print(pcf8574.pin(i))
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=PCF8574

+ 0 - 12
script/libs/pcf8574/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/pcf8574",
-    "tags" : ["pcf8574"],
-    "version" : "1.0.0",
-    "title" : "PCF8574 IO扩展",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "pcf8574.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/qmc5883l/qmc5883l.lua → script/libs/qmc5883l.lua


+ 0 - 27
script/libs/qmc5883l/README.md

@@ -1,27 +0,0 @@
-# QMC5883L 驱动
-
-地磁传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local qmc5883l = require "qmc5883l"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    qmc5883l.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local qmc5883l_data = qmc5883l.get_data()
-        log.info("qmc5883l_data", qmc5883l_data.x,qmc5883l_data.y,qmc5883l_data.z,qmc5883l_data.heading,qmc5883l_data.headingDegrees)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=QMC5883L

+ 0 - 12
script/libs/qmc5883l/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/qmc5883l",
-    "tags" : ["qmc5883l"],
-    "version" : "1.0.0",
-    "title" : "QMC5883L 地磁传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "qmc5883l.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/rc522/rc522.lua → script/libs/rc522.lua


+ 0 - 31
script/libs/rc522/README.md

@@ -1,31 +0,0 @@
-# RC522 驱动
-
-非接触式读写卡驱动 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local rc522 = require "rc522"
-sys.taskInit(function()
-    spi_rc522 = spi.setup(0,nil,0,0,8,10*1000*1000,spi.MSB,1,1)
-    rc522.init(0,pin.PB04,pin.PB01)
-    wdata = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
-    while 1 do
-        rc522.write_datablock(8,wdata)
-        for i=0,63 do
-            local a,b = rc522.read_datablock(i)
-            if a then
-                print("read",i,b:toHex())
-            end
-        end
-        sys.wait(500)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=ADXL34

+ 0 - 12
script/libs/rc522/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/rc522",
-    "tags" : ["rc522"],
-    "version" : "1.0.0",
-    "title" : "RC522 非接触式读写卡驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "rc522.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/si24r1/si24r1.lua → script/libs/si24r1.lua


+ 0 - 39
script/libs/si24r1/README.md

@@ -1,39 +0,0 @@
-# SI24R1 驱动
-
-无线收发驱动 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local si24r1 = require "si24r1"
-
-sys.taskInit(function()
-    spi_si24r1 = spi.setup(0,nil,0,0,8,10*1000*1000,spi.MSB,1,1)
-    si24r1.init(0,pin.PB04,pin.PB01,pin.PB00)
-    if si24r1.chip_check() then
-        si24r1.set()
-    end
-
-    --发送示例
-    -- si24r1.set_mode( si24r1.MODE_TX );		--发送模式	
-    -- while 1 do
-    --     sys.wait(1000)
-    --     local a = si24r1.txpacket("si24r1test")
-    --     print("a",a)
-    -- end
-
-    --接收示例 
-    si24r1.set_mode( si24r1.MODE_RX );		--接收模式	
-    while 1 do
-        local i,data = si24r1.rxpacket( );		--接收字节
-        print("rxbuf",i,data)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=SI24R1

+ 0 - 12
script/libs/si24r1/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/si24r1",
-    "tags" : ["si24r1"],
-    "version" : "1.0.0",
-    "title" : "SI24R1 无线收发驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "si24r1.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/tcs3472/tcs3472.lua → script/libs/tcs3472.lua


+ 0 - 32
script/libs/tcs3472/README.md

@@ -1,32 +0,0 @@
-# TCS3472 驱动
-
-颜色传感器 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local tcs3472 = require "tcs3472"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    tcs3472.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local rgb_date = tcs3472.get_rgb()
-        log.info("rgb_date.R:",rgb_date.R)
-        log.info("rgb_date.G:",rgb_date.G)
-        log.info("rgb_date.B:",rgb_date.B)
-        log.info("rgb_date.C:",rgb_date.C)
-        local lux_date = tcs3472.get_lux(rgb_date)
-        log.info("lux_date:",lux_date)
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=TCS3472

+ 0 - 12
script/libs/tcs3472/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/tcs3472",
-    "tags" : ["tcs3472"],
-    "version" : "1.0.0",
-    "title" : "TCS3472 颜色传感器",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "tcs3472.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/tm1637/tm1637.lua → script/libs/tm1637.lua


+ 0 - 27
script/libs/tm1637/README.md

@@ -1,27 +0,0 @@
-# ADXL34X 驱动
-
-3轴 加速度计 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local adxl34x = require "adxl34x"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    adxl34x.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local adxl34x_data = adxl34x.get_data()
-        log.info("adxl34x_data", "adxl34x_data.x"..(adxl34x_data.x),"adxl34x_data.y"..(adxl34x_data.y),"adxl34x_data.z"..(adxl34x_data.z))
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=ADXL34

+ 0 - 12
script/libs/tm1637/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/adxl34x",
-    "tags" : ["adxl34x"],
-    "version" : "1.0.0",
-    "title" : "ADXL34X 3轴加速度计驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "adxl34x.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 0
script/libs/tsl2561/tsl2561.lua → script/libs/tsl2561.lua


+ 0 - 27
script/libs/tsl2561/README.md

@@ -1,27 +0,0 @@
-# TSL2561 驱动
-
-光强传感器驱动 I2C 开发板模块
-
-## 用法示例
-
-```lua
-
-local tsl2561 = require "tsl2561"
-i2cid = 0
-i2c_speed = i2c.FAST
-sys.taskInit(function()
-    i2c.setup(i2cid,i2c_speed)
-    tsl2561.init(i2cid)--初始化,传入i2c_id
-    while 1 do
-        local tsl2561_data = tsl2561.get_data()
-        log.info("tsl2561_data", tsl2561_data.."Lux")
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-
-## 购买链接
-
-https://s.taobao.com/search?q=TSL2561

+ 0 - 12
script/libs/tsl2561/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/tsl2561",
-    "tags" : ["tsl2561"],
-    "version" : "1.0.0",
-    "title" : "TSL2561 光强传感器驱动",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "tsl2561.lua",
-    "dependency" : ["i2c"]
-}

+ 0 - 93
script/libs/update_inline_libs.lua

@@ -1,93 +0,0 @@
-
-local function lsdir(path, files, shortname)
-    local exe = io.popen("dir /b " .. (shortname and " " or " /s ") .. path)
-    if exe then
-        for line in exe:lines() do
-            if string.endsWith(line, ".lua") then
-                table.insert(files, line)
-            end
-        end
-        exe:close()
-    end
-end
-
-
-local function oscall(cmd, quite, cwd)
-    if cwd and Base_CWD then
-        lfs.chdir(cwd)
-    end
-    if tool_debug then
-        log.info("cmd", cmd)
-    end
-    local exe = io.popen(cmd)
-    if exe then
-        for line in exe:lines() do
-            if not quite then
-                log.info("cmd", line)
-            end
-        end
-        exe:close()
-    end
-    if cwd and Base_CWD then
-        lfs.chdir(Base_CWD)
-    end
-end
-
-function TLD(buff, T, D)
-    buff:pack("bb", T, D:len())
-    buff:write(D)
-end
-
-local files = {}
-lsdir("core", files, true)
-oscall("mkdir tmp")
-
-local f = io.open("..\\..\\luat\\vfs\\luat_inline_libs.c", "wb")
-
-if not f then
-    os.exit("can't write luat_inline_libs.c")
-end
-
-f:write([[#include "luat_base.h"]])
-f:write("\r\n")
-f:write([[#include "luat_fs.h"]])
-f:write("\r\n")
-f:write([[#include "luat_luadb.h"]])
-f:write("\r\n\r\n")
-
-
-kvs = {}
-for _, value in ipairs(files) do
-    local lf = loadfile("core\\" .. value)
-    local data = string.dump(lf, true)
-    local buff = zbuff.create(256*1024)
-    -- local data = io.readFile("tmp\\" .. value .. "c")
-    buff:write(data)
-    f:write("//------- " .. value .. "\r\n")
-
-    local k = "luat_inline2_" .. value:sub(1, value:len() - 4)
-    print(value, #data, k)
-    table.insert(kvs, {size=#data,ptr=k, name=value})
-
-    f:write("const char ".. k .."[] = {\r\n")
-    local index = 0
-    local max = #data
-    while index < max do
-        if index % 8 == 0 then
-            f:write("\r\n")
-        end
-        f:write(string.format("0x%02X, ", buff[index]))
-        index = index + 1
-    end
-    f:write("};\r\n\r\n")
-end
-
-f:write("const luadb_file_t luat_inline2_libs[] = {\r\n")
-for _, value in ipairs(kvs) do
-    f:write("   {.name=\"" .. value.name .. "\",.size=" .. tostring(value.size) .. ", .ptr=" .. value.ptr .. "},\r\n")
-end
-f:write("   {.name=\"\",.size=0,.ptr=NULL}\r\n")
-f:write("};\r\n\r\n")
-f:close()
-
-os.exit(0)

+ 0 - 0
script/libs/xmodem/xmodem.lua → script/libs/xmodem.lua


+ 0 - 21
script/libs/xmodem/README.md

@@ -1,21 +0,0 @@
-# XMODEM 文件传输协议
-
-XMODEM 文件传输协议
-
-可用于air101/air103的刷机, 或者对其他设备传输文件/刷机
-
-## 用法示例
-
-```lua
-
-local xmodem = require "xmodem"
-sys.taskInit(function()
-    xmodem.send(2,115200,"/luadb/test.bin")
-    while 1 do
-        sys.wait(1000)
-    end
-end)
-
-sys.run()
-```
-

+ 0 - 12
script/libs/xmodem/meta.json

@@ -1,12 +0,0 @@
-{
-    "type" : "lua",
-    "repo" : "luatos/xmodem",
-    "tags" : ["xmodem"],
-    "version" : "1.0.0",
-    "title" : "XMODEM 文件传输协议",
-    "files" : {
-        "." : "*"
-    },
-    "enterpoint" : "xmodem.lua",
-    "dependency" : ["uart"]
-}