Просмотр исходного кода

Merge branch 'master' of https://gitee.com/openLuat/LuatOS

wjq 8 месяцев назад
Родитель
Сommit
6b221ba686
95 измененных файлов с 0 добавлено и 8294 удалено
  1. 0 126
      module/Air780EHV/DEMO/CC/main.lua
  2. 0 407
      module/Air780EHV/DEMO/JT808/main.lua
  3. 0 66
      module/Air780EHV/DEMO/SPI/main.lua
  4. 0 26
      module/Air780EHV/DEMO/SPI/rc522_test.lua
  5. 0 47
      module/Air780EHV/DEMO/SPI/readme.md
  6. 0 122
      module/Air780EHV/DEMO/WebSocket/WebSocket-UART透传/main.lua
  7. 0 83
      module/Air780EHV/DEMO/WebSocket/WebSocket加密通讯/main.lua
  8. 0 24
      module/Air780EHV/DEMO/adc/main.lua
  9. 0 83
      module/Air780EHV/DEMO/adc/testAdc.lua
  10. 0 96
      module/Air780EHV/DEMO/airlbs/main.lua
  11. 0 81
      module/Air780EHV/DEMO/airtalk/airaudio.lua
  12. 0 60
      module/Air780EHV/DEMO/airtalk/main.lua
  13. 0 128
      module/Air780EHV/DEMO/airtalk/talk.lua
  14. 0 25
      module/Air780EHV/DEMO/apn/main.lua
  15. BIN
      module/Air780EHV/DEMO/audio/1.mp3
  16. 0 204
      module/Air780EHV/DEMO/audio/main.lua
  17. 0 52
      module/Air780EHV/DEMO/bit/main.lua
  18. 0 114
      module/Air780EHV/DEMO/bit64/main.lua
  19. BIN
      module/Air780EHV/DEMO/crypto/logo.jpg
  20. 0 242
      module/Air780EHV/DEMO/crypto/main.lua
  21. 0 62
      module/Air780EHV/DEMO/errDump/main.lua
  22. 0 101
      module/Air780EHV/DEMO/fota2/main.lua
  23. 0 133
      module/Air780EHV/DEMO/fs/main.lua
  24. 0 105
      module/Air780EHV/DEMO/fskv/main.lua
  25. 0 92
      module/Air780EHV/DEMO/ftp/main.lua
  26. 0 21
      module/Air780EHV/DEMO/helloworld/main.lua
  27. 0 30
      module/Air780EHV/DEMO/hmeta/main.lua
  28. 0 3
      module/Air780EHV/DEMO/http/luatos_uploadFile.txt
  29. 0 306
      module/Air780EHV/DEMO/http/main.lua
  30. 0 37
      module/Air780EHV/DEMO/i2c/aht10_test.lua
  31. 0 82
      module/Air780EHV/DEMO/i2c/main.lua
  32. 0 48
      module/Air780EHV/DEMO/i2c/readme.md
  33. 0 218
      module/Air780EHV/DEMO/iconv/main.lua
  34. 0 83
      module/Air780EHV/DEMO/iotcloud/aliyun/示例1 一型一密(免预注册,但需要是企业版实例平台)方式连接云平台/main.lua
  35. 0 82
      module/Air780EHV/DEMO/iotcloud/aliyun/示例2 一型一密(预注册)方式连接云平台/main.lua
  36. 0 82
      module/Air780EHV/DEMO/iotcloud/aliyun/示例3 一机一密方式连接云平台/main.lua
  37. 0 70
      module/Air780EHV/DEMO/iotcloud/baiduiot/main.lua
  38. 0 88
      module/Air780EHV/DEMO/iotcloud/huaweiiot/main.lua
  39. 0 157
      module/Air780EHV/DEMO/iotcloud/onenet/main.lua
  40. 0 79
      module/Air780EHV/DEMO/iotcloud/tencentiot/main.lua
  41. 0 132
      module/Air780EHV/DEMO/iotcloud/tlink/main.lua
  42. 0 70
      module/Air780EHV/DEMO/iotcloud/tuyaiot/示例1 一机一密/main.lua
  43. 0 81
      module/Air780EHV/DEMO/json/main.lua
  44. 0 26
      module/Air780EHV/DEMO/lbsLoc2/main.lua
  45. 0 103
      module/Air780EHV/DEMO/lcd/lcd_test.lua
  46. 0 74
      module/Air780EHV/DEMO/lcd/main.lua
  47. BIN
      module/Air780EHV/DEMO/lcd/picture.jpg
  48. 0 47
      module/Air780EHV/DEMO/lcd/readme.md
  49. 0 64
      module/Air780EHV/DEMO/log/main.lua
  50. 0 41
      module/Air780EHV/DEMO/miniz/main.lua
  51. 0 122
      module/Air780EHV/DEMO/mobile/main.lua
  52. 0 155
      module/Air780EHV/DEMO/modbus/ascii/master_ascii/main.lua
  53. 0 70
      module/Air780EHV/DEMO/modbus/ascii/slave_ascii/main.lua
  54. 0 154
      module/Air780EHV/DEMO/modbus/rtu/master_rtu/main.lua
  55. 0 70
      module/Air780EHV/DEMO/modbus/rtu/slave_rtu/main.lua
  56. 0 59
      module/Air780EHV/DEMO/modbus/tcp/master_tcp/lan.lua
  57. 0 161
      module/Air780EHV/DEMO/modbus/tcp/master_tcp/main.lua
  58. 0 60
      module/Air780EHV/DEMO/modbus/tcp/slave_tcp/lan.lua
  59. 0 69
      module/Air780EHV/DEMO/modbus/tcp/slave_tcp/main.lua
  60. BIN
      module/Air780EHV/DEMO/modbus/test_core/LuatOS-SoC_V2007_Air780EPM_TEMP_20250610_150400.soc
  61. 0 30
      module/Air780EHV/DEMO/mqtt/main.lua
  62. 0 226
      module/Air780EHV/DEMO/mqtt/multilink_mqtt.lua
  63. 0 177
      module/Air780EHV/DEMO/mqtt/single_mqtt.lua
  64. 0 123
      module/Air780EHV/DEMO/ntp/main.lua
  65. 0 124
      module/Air780EHV/DEMO/os/main.lua
  66. 0 49
      module/Air780EHV/DEMO/pack/main.lua
  67. 0 72
      module/Air780EHV/DEMO/protobuf/main.lua
  68. 0 7
      module/Air780EHV/DEMO/protobuf/person.pb
  69. 0 6
      module/Air780EHV/DEMO/protobuf/person.pbtxt
  70. 0 29
      module/Air780EHV/DEMO/pwm/breathing_led.lua
  71. 0 69
      module/Air780EHV/DEMO/pwm/main.lua
  72. 0 26
      module/Air780EHV/DEMO/pwm/pwm_output.lua
  73. 0 32
      module/Air780EHV/DEMO/pwm/readme.md
  74. 0 222
      module/Air780EHV/DEMO/record/main.lua
  75. 0 87
      module/Air780EHV/DEMO/sms/main.lua
  76. 0 113
      module/Air780EHV/DEMO/string/main.lua
  77. 0 134
      module/Air780EHV/DEMO/tcp/TCP-UART/main.lua
  78. 0 139
      module/Air780EHV/DEMO/tcp/TCP单向认证/main.lua
  79. 0 134
      module/Air780EHV/DEMO/tcp/TCP断链续连/main.lua
  80. 0 51
      module/Air780EHV/DEMO/timer/main.lua
  81. 0 155
      module/Air780EHV/DEMO/tts/main.lua
  82. 0 63
      module/Air780EHV/DEMO/tts/qianzw.txt
  83. 0 155
      module/Air780EHV/DEMO/u8g2/main.lua
  84. 0 51
      module/Air780EHV/DEMO/uart/uart/main.lua
  85. 0 49
      module/Air780EHV/DEMO/uart/uart_rs485/main.lua
  86. 0 77
      module/Air780EHV/DEMO/uart/uart_two/main.lua
  87. 0 61
      module/Air780EHV/DEMO/uart/uart_vir/main.lua
  88. 0 123
      module/Air780EHV/DEMO/udp/main.lua
  89. 0 33
      module/Air780EHV/DEMO/wdt/示例一 程序正常运行/main.lua
  90. 0 42
      module/Air780EHV/DEMO/wdt/示例二 添加死循环模拟故障场景/main.lua
  91. 0 30
      module/Air780EHV/DEMO/wlan/wifiscan/main.lua
  92. 0 72
      module/Air780EHV/DEMO/zbuff/main.lua
  93. 0 109
      module/Air780EHV/README.md
  94. 0 1
      module/Air780EHV/core.md
  95. 0 0
      module/Air780EHV/project/.keep

+ 0 - 126
module/Air780EHV/DEMO/CC/main.lua

@@ -1,126 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "ccdemo"
-VERSION = "1.0.0"
-log.style(1)
---[[]
-运行环境:Air780EHV核心板+AirAUDIO_1000配件板
-最后修改时间:2025-6-17
-使用了如下IO口:
-[3, "MIC+", " PIN3脚, 用于麦克风正极"],
-[4, "MIC-", " PIN4脚, 用于麦克风负极"],
-[5, "spk+", " PIN5脚, 用于喇叭正极"],
-[6, "spk-", " PIN6脚, 用于喇叭负极"],
-[20, "AudioPA_EN", " PIN20脚, 用于PA使能脚"],
-3.3V
-GND
-执行逻辑为:
-设置i2s和音频参数,读取文件qianzw.txt里面的内容,然后播放出来
-]]
-
--- sys库是标配
-sys = require("sys")
-
-local up1 = zbuff.create(6400,0)
-local up2 = zbuff.create(6400,0)
-local down1 = zbuff.create(6400,0)
-local down2 = zbuff.create(6400,0)
-local cnt = 0
-
-local function record(is_dl, point)
-    if is_dl then
-        log.info("下行数据,位于缓存", point+1, "缓存1数据量", down1:used(), "缓存2数据量", down2:used())
-    else
-        log.info("上行数据,位于缓存", point+1, "缓存1数据量", up1:used(), "缓存2数据量", up2:used())
-    end
-	log.info("通话质量", cc.quality())
-    -- 可以在初始化串口后,通过uart.tx来发送走对应的zbuff即可
-end
-
-sys.subscribe("CC_IND", function(state)
-    log.info("cc状态", state)
-    if state == "READY" then
-        sys.publish("CC_READY")
-    elseif state == "INCOMINGCALL" then
-		cnt = cnt + 1
-		if cnt > 1 then
-			cc.accept(0)
-		end
-    elseif state == "HANGUP_CALL_DONE" or state == "MAKE_CALL_FAILED" or state == "DISCONNECTED" then
-		audio.pm(0,audio.STANDBY)
-		-- audio.pm(0,audio.SHUTDOWN)	--低功耗可以选择SHUTDOWN或者POWEROFF,如果codec无法断电用SHUTDOWN
-	end
-end)
-
-
-
-sys.taskInit(function()
-    cc.on("record", record)
-    cc.record(true, up1, up2, down1, down2)
-    local multimedia_id = 0
- local i2c_id = 0 -- i2c_id 0
-
-    local pa_pin = gpio.AUDIOPA_EN -- 喇叭pa功放脚
-    local power_pin = 20 -- es8311电源脚
-
-    local i2s_id = 0 -- i2s_id 0
-    local i2s_mode = 0 -- i2s模式 0 主机 1 从机
-    local i2s_sample_rate = 16000 -- 采样率
-    local i2s_bits_per_sample = 16 -- 数据位数
-    local i2s_channel_format = i2s.MONO_R -- 声道, 0 左声道, 1 右声道, 2 立体声
-    local i2s_communication_format = i2s.MODE_LSB -- 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
-    local i2s_channel_bits = 16 -- 声道的BCLK数量
-
-    local multimedia_id = 0 -- 音频通道 0
-    local pa_on_level = 1 -- PA打开电平 1 高电平 0 低电平
-    local power_delay = 3 -- 在DAC启动前插入的冗余时间,单位100ms
-    local pa_delay = 100 -- 在DAC启动后,延迟多长时间打开PA,单位1ms
-    local power_on_level = 1 -- 电源控制IO的电平,默认拉高
-    local power_time_delay = 100 -- 音频播放完毕时,PA与DAC关闭的时间间隔,单位1ms
-
-    local voice_vol = 70 -- 喇叭音量
-    local mic_vol = 80 -- 麦克风音量
-    gpio.setup(power_pin, 1, gpio.PULLUP)
-    gpio.setup(pa_pin, 1, gpio.PULLUP)
-
-    sys.wait(200)
-
-
-    i2c.setup(i2c_id, i2c.FAST) -- 设置i2c
-    i2s.setup(i2s_id, i2s_mode, i2s_sample_rate, i2s_bits_per_sample, i2s_channel_format, i2s_communication_format,
-        i2s_channel_bits) -- 设置i2s
-
-    audio.config(multimedia_id, pa_pin, pa_on_level, power_delay, pa_delay, power_pin, power_on_level, power_time_delay)
-    audio.setBus(multimedia_id, audio.BUS_I2S, {
-        chip = "es8311",
-        i2cid = i2c_id,
-        i2sid = i2s_id,
-    }) -- 通道0的硬件输出通道设置为I2S
-
-    audio.vol(multimedia_id, voice_vol)
-    audio.micVol(multimedia_id, mic_vol)
-
-    cc.init(multimedia_id)
-	audio.pm(0,audio.STANDBY)
-    sys.waitUntil("CC_READY")
-    log.info("一切就绪,5S后准备打电话")
-    sys.wait(5000)   
-    -- cc.dial(0,"12345678910) --拨打电话
-
-
-
-end)
-
--- sys.taskInit(function()
---     while 1 do
---         -- 打印内存状态, 调试用
---         sys.wait(1000)
---         log.info("lua", rtos.meminfo())
---         log.info("sys", rtos.meminfo("sys"))
---     end
--- end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 407
module/Air780EHV/DEMO/JT808/main.lua

@@ -1,407 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "JT808"
-VERSION = "2.0.0"
-
---[[
-本demo演示使用string.pack与unpack函数,实现JT808 终端注册协议数据生成与解析
-]]
-
---加载sys库
-sys = require("sys")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-local netLed = require("netLed")
---GPIO27配置为输出,用作网络指示灯
-local LEDA= gpio.setup(27, 0, gpio.PULLUP)
-
--- 自定义位运算函数
-local bit = {}
-
---终端消息ID
-T_COMMON_RSP = 0x0001
-T_REGISTER = 0x0100
-
-function bit.bxor(a, b)
-    return a ~ b  -- 按位异或
-end
-
---十六进制转二进制
-local function hexToBinary(hexStr)
-    local binaryData = {}
-    for i = 1, #hexStr, 2 do
-        local byte = tonumber(hexStr:sub(i, i+1), 16) -- 每两个字符转换为一个字节
-        table.insert(binaryData, string.char(byte))
-    end
-    return table.concat(binaryData) -- 拼接成二进制字符串
-end
---字符串转字节数组
-local function stringToBytes(hexStr)
-    local bytes = {}
-    for i = 1, #hexStr, 2 do
-        local byteStr = hexStr:sub(i, i+1)
-        local byte = tonumber(byteStr, 16)
-        table.insert(bytes, byte)
-    end
-    return bytes
-end
---BCD编码
-local function encodeBcdNum(d, n)
-    if d:len() < n then
-        return (string.rep('0', n - d:len()) .. d):fromHex()
-    else
-        return (d:sub(1, n)):fromHex()
-    end
-end
---计算异或校验(十六进制字符串)
-local function calculateXor(data)
-    local sum = 0
-     for i = 1, #data, 2 do
-        local byte = tonumber(data:sub(i, i+1), 16)
-
-        -- 检查是否转换成功
-        if not byte then
-           error(string.format("Invalid hex character: '%s' at position %d", byteStr, i))
-        end
-
-        -- 打印当前字节的值(十六进制和十进制)
-        --print(string.format("当前字节: %s (十进制: %d)", byteStr, byte))
-
-        if not byte then
-            error("Invalid hex character in input string!")
-        end
-        sum = bit.bxor(sum, byte)
-        -- 打印异或后的中间结果
-        --print(string.format("异或后 sum = %d (十六进制: 0x%X)", sum, sum))
-    end
-    return sum
-end
---
-local function calCrc(hexStr)
-
-    -- 解析hexStr转换为十六进制字符数组
-    local byteArray = HexOutput(hexStr)
-
-    -- 计算 CRC
-    local crc = calculateXor(byteArray)
-    log.info("CRCxor:",crc)
-
-    -- 返回 CRC 值
-    return crc
-end
-
---将时间转换为BCD格式
-function timeToBCD()
-    local t = os.date("*t")
-    
-    -- 转换为BCD格式
-    local year = string.format("%02d", t.year % 100)
-    local month = string.format("%02d", t.month)
-    local day = string.format("%02d", t.day)
-    local hour = string.format("%02d", t.hour)
-    local min = string.format("%02d", t.min)
-    local sec = string.format("%02d", t.sec)
-    
-    -- 组合BCD格式字符串
-    local bcdTime = year .. month .. day .. hour .. min .. sec
-    
-    return bcdTime
-end
-
-
---构建通用应答
-function cmnRsp(svrSeq, svrId, result)
-    return string.pack('>HHb', svrSeq, svrId, result)   
-    -- >表示使用大端字节序;  
-    -- HH 表示两个 16 位无符号整数(svrSeq 和 svrId); 
-    -- b 表示一个 8 位有符号整数(result)
-end
---构建设备注册
-function register(ProvinceId,CityId,ManufactureId,TerminalModule,TerminalId,CarColor,CarId)
-    local termMd = TerminalModule..string.rep(string.char(0), 16 - (TerminalModule):len())..string.rep(string.char(0), 4)
-    --log.info("HexDataByteLength:",#termMd)
-    --log.info("HexData is:       ",termMd)
-    return string.pack('>HHc5c20c7Bc11',ProvinceId,CityId,ManufactureId,termMd,TerminalId:fromHex(),CarColor,CarId)
-end
---构建位置信息汇报
-function locRpt(alarm, status, lat, lng, alt, spd, course, tm, extInfo)
-    -- 使用 '>iiiiHHH' 格式打包数据
-    return string.pack('>iiiiHHH', alarm, status, lat, lng, alt, spd, course)..tm:fromHex().. extInfo
-end
-
-function HexOutput(data)
-    log.info("HexDataByteLength:",#data)
-    local hex = ""
-    for i = 1, #data do
-        hex = hex.. string.format("%02x", string.byte(data, i))
-    end
-    log.info("HexData is:       ",hex)
-    return hex
-end
---封装一个完整的JT808终端注册数据帧
-function encodeReg(phoneNo,tSendSeq)
-    --消息体
-    local msgBody = register(12,123,'10001','GT808','00000000000002',0,'41048063212')
-    --消息头
-    local msgHead =string.pack('>HH',T_REGISTER,msgBody:len())..encodeBcdNum(phoneNo,12)..tSendSeq
-    local curSeq = tSendSeq
-    tSendSeq = (tSendSeq == 0xFFFF) and 0 or (tSendSeq + 1)
-    --校验码
-    HexOutput(msgHead .. msgBody)
-    local frame = msgHead .. msgBody
-    log.info("encodeReg Frame length is:       ",#frame)
-    local crc = calCrc(frame)
-    
-    --转义
-    local s = msgHead .. msgBody .. string.char(crc)
-    s = s:gsub('\125', '\125\1') -- 7D -> 7D 01
-    s = s:gsub('\126', '\125\2') -- 7E -> 7D 02
-    return string.char(0x7E) .. s .. string.char(0x7E), curSeq
-
-end
-
-function decodeCmnRsp(s)
-
-    log.info("hereNow.",s)
-    --local start, tail, msg = s:find('^(7E[^7E]+7E)$')
-    --local decPacket, msgAttr = {}
--- 检查是否以 7E 开头和结尾
-    if not s:match("^7E") or not s:match("7E$") then
-        log.warn("prot.decode", "packet does not start or end with 7E")
-        return nil
-    end
-
-    -- 匹配以 7E 开头和结尾的数据包
-    local start, tail, msg = s:find('^(7E.+7E)$')  -- 改为允许中间部分包含 7E
-    log.info("start:", start)
-    log.info("tail:", tail)
-    log.info("msg:", msg)
-
-    if not msg then
-        -- 如果未匹配到
-        log.warn('prot.decode', 'wait packet complete')
-        return nil
-    end
-    
-    --反转义
-    msg = msg:gsub('\125\2', '\126') -- 7D 02 -> 7E
-    msg = msg:gsub('\125\1', '\125') -- 7D 01 -> 7D
-
-    log.info("msg:", msg,msg:len())
-
-    if msg:len() < 13 then
-        log.error('prot.decode', 'packet len is too short')
-        return s:sub(tail + 1, -1), nil
-    end
-
-    local hexArray = stringToBytes(msg)
-
-    local dataHexStr = msg:sub(3, -5)
-    log.info("消息体和其字节长度:", dataHexStr,dataHexStr:len())
-
-    local crcVal = calculateXor(dataHexStr)
-    print("XOR校验值:", crcVal)
-
-    if  crcVal ~= hexArray[#hexArray-1] then
-        log.error('prot.decode', 'crc value error!')
-        return s:sub(tail + 1, -1), nil
-    else
-        log.info("XOR:校验通过")
-    end
-
-    ----------------------------解析消息id
-    msgdata = msg:sub(3, 6)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    msgId = string.unpack(">H", binaryData)
-
-    -- 输出结果
-    log.info("消息id十六进制:", string.format("0x%04X", msgId))
-
-    ----------------------------解析应答结果
-    msgdata = msg:sub(7, 8)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    result = string.unpack(">B", binaryData)
-
-    -- 输出结果
-    log.info("结果十六进制:", string.format("0x%02X", result))
-
-    ----------------------------解析鉴权码
-    msgdata = msg:sub(9, 10)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    result = string.unpack(">B", binaryData)
-
-    -- 输出结果
-    log.info("鉴权码十六进制:", string.format("0x%02X", result))
-
-    ----------------------------解析电话号码
-    msgdata = msg:sub(11, 22)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    local b1, b2, b3, b4, b5, b6 = string.unpack(">BBBBBB", binaryData)
-
-    -- 格式化输出为 6 字节的十六进制字符串
-    local TerminalPhoneNo = string.format("0x%02X%02X%02X%02X%02X%02X", b1, b2, b3, b4, b5, b6)
-
-    -- 输出电话号码
-    log.info("电话号码十六进制:", TerminalPhoneNo)
-
-    ----------------------------解析标头流水号
-    msgdata = msg:sub(23, 26)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    local ManualMsgNum = string.unpack(">H", binaryData)
-
-    -- 输出结果
-    log.info("标头流水号十六进制:", string.format("0x%04X", ManualMsgNum))
-
-    ----------------------------解析标尾流水号
-    msgdata = msg:sub(23, 26)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    -- 解析二进制数据
-    local MsgNum = string.unpack(">H", binaryData)
-
-    -- 输出结果
-    log.info("标尾流水号十六进制:", string.format("0x%04X", MsgNum))
-
-    ----------------------------解析鉴权码
-    msgdata = msg:sub(33, 50)
-
-    -- 转换为二进制数据
-    local binaryData = hexToBinary(msgdata)
-
-    local b1, b2, b3, b4, b5, b6, b7, b8, b9 = string.unpack(">BBBBBBBBB", binaryData)
-
-    -- 格式化输出为 6 字节的十六进制字符串
-    local JianquanCode = string.format("0x%02X%02X%02X%02X%02X%02X%02X%02X%02X", b1, b2, b3, b4, b5, b6, b7, b8, b9)
-
-    -- 输出结果
-    log.info("鉴权码十六进制:", JianquanCode)
-end
-
---新建任务,每休眠2000ms继续一次
-sys.taskInit(function()
-    
-    --实验1:构建立通用应答数据帧,协议可参考JT808协议8.1与8.2
-    --输入参数:
-    --应答流水号为123,
-    --应答 ID为456,
-    --结果为1,
-    local data = cmnRsp(123, 456, 1)
-    HexOutput(data)  --HexDataByteLength:5,HexData is:007b01c801  007b为123,01c8为456,1为1
-
-    --实验2:构建终端注册数据帧,协议可参考JT808协议8.5
-    --输入参数:
-    --12,                   --省域 ID  WORD
-    --123,                  --市县域 ID  WORD
-    --'10001',              --制造商 ID  BYTE[5]
-    --'GT808'               --终端型号 BYTE[20]
-    --'00000000000002',     --终端 ID BYTE[7]
-    --0,                    --车牌颜色  BYTE
-    --'41048063212')        --车辆标识  STRING  VIN或车牌号均为固定长度,这里假设字符串长度为11
-    local data = register(12,123,'10001','GT808','00000000000002',0,'41048063212')
-    HexOutput(data)--[HexDataByteLength:]	48,[HexData is:       ]	
-
-    --输出解析:
-    --000c,对应12,                   --省域 ID  WORD
-    --007b,对应123,                  --市县域 ID  WORD
-    --3130303031,对应'10001',              --制造商 ID  BYTE[5]
-    --4754383038,对应'GT808'               --终端型号 BYTE[20],不足字节补0
-    --0000000000
-    --0000000000
-    --0000000000
-    --00000000000002 对应'00000000000002',     --终端 ID BYTE[7]
-    --000,                    --车牌颜色  BYTE
-    --3431303438303633323132,对应'41048063212')        --车辆标识  STRING 
-
- 
-    --实验3:构建位置信息汇报数据帧,协议可参考JT808协议8.18
-    --输入参数:
-    --0, 报警标志 DWORD
-    --1, 状态位 DWORD
-    --12345678, 纬度 DWORD
-    --87654321, 经度 DWORD
-    --100, 高程 WORD
-    --60, 速度 WORD
-    --180, 方向 WORD
-    --os.time(), 时间 BCD[6]  YY-MM-DD-hh-mm-ss(GMT+8 时间,本标准中之后涉及的时间均采用此时区)
-    --"extra"
-
-    local time = timeToBCD();
-    log.info("CurrentTime:       ",time)
-
-    local data = locRpt(0, 1, 12345678, 87654321, 100, 60, 180, time, "extra")
-    HexOutput(data)--[HexDataByteLength:]	33,[HexData is:       ]	000000000000000100bc614e05397fb10064003c00b42411241232046578747261
-    --输出解析:
-    --00000000,对应 0, 报警标志 DWORD,4字节
-    --00000001,对应 1, 状态位 DWORD
-    --00bc614e,对应 12345678, 纬度 DWORD
-    --05397fb1, 对应 87654321, 经度 DWORD
-    --0064,对应 100, 高程 WORD
-    --003c,对应60, 速度 WORD
-    --00b4,对应180, 方向 WORD
-    --241124123204,对应时间 BCD[6]  24-11-24-12-32-04
-    --6578747261,对应"extra"
-
-    --实验4:封闭一个完整的JT808注册数据帧
-    --输入参数:
-    --'018068821447',手机号不足 12位,则在前补充数字,大陆手机号补充数字 0
-    --'101',消息流水号
-    local data = encodeReg('018068821447','101')
-    HexOutput(data) --[HexDataByteLength:]	64
-                    --[HexData is:       ]	7e01000030018068821447313031000c007b3130303031475438303800000000000000000000000000000000000000000002003431303438303633323132627e
-
-    --输出解析:
-    --7e,标识位固定为0x7e
-    --0100,消息 ID
-    --0030,消息体属性
-    --018068821447,手机号
-    --313031,消息流水号
-    --000c007b3130303031475438303800000000000000000000000000000000000000000002003431303438303633323132,注册消息体
-    --62,校验
-    --7e,标识位固定为0x7e
-
-    --实验5:解析JT808终端注册应答数据帧
-    local hexStr = '7E8100000C0404571031660030003000736875616E67776569E07E'
-    decodeCmnRsp(hexStr)
-end)
--- 这里演示4G模块上网后,会自动点亮网络灯,方便用户判断模块是否正常开机
-sys.taskInit(function()
-    while true do
-        sys.wait(6000)
-                if mobile.status() == 1 then
-                        gpio.set(27, 1)  
-                else
-                        gpio.set(27, 0) 
-                        mobile.reset()
-        end
-    end
-end)
--- 用户代码已结束---------------------------------------------
--- 运行lua task,只能调用一次,而且必须写在末尾
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 66
module/Air780EHV/DEMO/SPI/main.lua

@@ -1,66 +0,0 @@
---[[
-必须定义PROJECT和VERSION变量,Luatools工具会用到这两个变量,远程升级功能也会用到这两个变量
-PROJECT:项目名,ascii string类型
-        可以随便定义,只要不使用,就行
-VERSION:项目版本号,ascii string类型
-        如果使用合宙iot.openluat.com进行远程升级,必须按照"XXX.YYY.ZZZ"三段格式定义:
-            X、Y、Z各表示1位数字,三个X表示的数字可以相同,也可以不同,同理三个Y和三个Z表示的数字也是可以相同,可以不同
-            因为历史原因,YYY这三位数字必须存在,但是没有任何用处,可以一直写为000
-        如果不使用合宙iot.openluat.com进行远程升级,根据自己项目的需求,自定义格式即可
-
-本demo演示的功能为:
-使用Air780EGH开发板通过spi接口驱动RC522传感器读取ic数据卡数据
-]]
-PROJECT = "spi_demo"
-VERSION = "001.000.000"
-
-
--- 在日志中打印项目名和项目版本号
-log.info("main", PROJECT, VERSION)
-
-
-
-
--- 如果内核固件支持wdt看门狗功能,此处对看门狗进行初始化和定时喂狗处理
--- 如果脚本程序死循环卡死,就会无法及时喂狗,最终会自动重启
-if wdt then
-    --配置喂狗超时时间为9秒钟
-    wdt.init(9000)
-    --启动一个循环定时器,每隔3秒钟喂一次狗
-    sys.timerLoopStart(wdt.feed, 3000)
-end
-
-
--- 如果内核固件支持errDump功能,此处进行配置,【强烈建议打开此处的注释】
--- 因为此功能模块可以记录并且上传脚本在运行过程中出现的语法错误或者其他自定义的错误信息,可以初步分析一些设备运行异常的问题
--- 以下代码是最基本的用法,更复杂的用法可以详细阅读API说明文档
--- 启动errDump日志存储并且上传功能,600秒上传一次
--- if errDump then
---     errDump.config(true, 600)
--- end
-
-
--- 使用LuatOS开发的任何一个项目,都强烈建议使用远程升级FOTA功能
--- 可以使用合宙的iot.openluat.com平台进行远程升级
--- 也可以使用客户自己搭建的平台进行远程升级
--- 远程升级的详细用法,可以参考fota的demo进行使用
-
-
--- 启动一个循环定时器
--- 每隔3秒钟打印一次总内存,实时的已使用内存,历史最高的已使用内存情况
--- 方便分析内存使用是否有异常
-sys.timerLoopStart(function()
-    log.info("mem.lua", rtos.meminfo())
-    log.info("mem.sys", rtos.meminfo("sys"))
- end, 3000)
-
-
- -- 加载spi测试模块
- --引入rc522测试demo
- require "rc522_test"
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后不要加任何语句!!!!!因为添加的任何语句都不会被执行

+ 0 - 26
module/Air780EHV/DEMO/SPI/rc522_test.lua

@@ -1,26 +0,0 @@
---[[
-本demo演示的功能为:
-使用Air780EGH开发板通过spi接口驱动RC522传感器读取ic数据卡数据
-通过spi0通道
-cs片选脚接gpio8
-rst接gpio16
-]]
-
-local rc522 = require "rc522"  --引入rc522驱动模块
-function rc522_test()
-    spi_rc522 = spi.setup(0,8,0,0,8,10*1000*1000,spi.MSB,1,0)  --初始化spi接口
-    rc522.init(0,8,16)   --初始化rc522相关接口
-    wdata = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} --测试写入数据
-    while 1 do
-        -- rc522.write_datablock(7,wdata) --测试ic卡写入
-        for i=0,63 do
-            local a,b = rc522.read_datablock(i) --测试ic卡读取
-            if a then
-                print("read",i,b:toHex())  --打印读取的数据
-            end
-            sys.wait(50)
-        end
-        sys.wait(500)
-    end
-end
-sys.taskInit(rc522_test)

+ 0 - 47
module/Air780EHV/DEMO/SPI/readme.md

@@ -1,47 +0,0 @@
-
-## 演示功能概述
-
-使用 Air780EHV 核心板通过 spi 接口驱动 RC522 传感器读取 ic 数据卡数据。
-
-## 演示硬件环境
-
-1、Air780EHV核心板一块
-
-2、TYPE-C USB数据线一根
-
-3、Air780EHV核心板和数据线的硬件接线方式为
-
-- Air780EHV核心板通过TYPE-C USB口供电;(核心板USB旁边的开关拨到on一端)
-
-- TYPE-C USB数据线直接插到核心板的TYPE-C USB座子,另外一端连接电脑USB口;
-
-4、rc522 模块一块
-
-
-5、核心板和rc500模块连接方式
-
-| RC522引脚   | Air780EGH引脚  |说明               |
-|------------|----------------|-------------------|
-| SDA        | SPL.CS         | 片选信号           |
-| SCK        | SPL.CLK        | SPI 时钟信号       |
-| MOSI       | SPL.MOSI       | 主设备输出从设备输入 |
-| MISO       | SPL.MISO       | 主设备输入从设备输出 |
-| RST        | GPIO16         | 复位信号(可自定义)|
-| GND        | GND            | 地线               |
-| 3.3V       | 3.3V           | 电源(3.3V)       |
-
-## 演示软件环境
-
-1、Luatools下载调试工具
-
-2、[Air780EHV V2007版本固件](https://docs.openluat.com/air780ehv/luatos/firmware/version/)(测试使用V2007 固件)
-
-## 演示核心步骤
-
-1、搭建好演示硬件环境
-
-2、通过Luatools将demo与固件烧录到核心板中
-
-3、烧录成功后,自动开机运行
-
-4、卡片放到读卡区域后可以正常读取卡片信息。

+ 0 - 122
module/Air780EHV/DEMO/WebSocket/WebSocket-UART透传/main.lua

@@ -1,122 +0,0 @@
-
-PROJECT = "airtun"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
--- _G.sysplus = require("sysplus")
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-----------------------------------------
--- 报错信息自动上报到平台,默认是iot.openluat.com
--- 支持自定义, 详细配置请查阅API手册
--- 开启后会上报开机原因, 这需要消耗流量,请留意
-if errDump then
-    errDump.config(true, 600)
-end
-----------------------------------------
-local tx_buff = zbuff.create(1024)      -- 发送至WebSocket服务器的数据
-local uart_rx_buff = zbuff.create(1024)     -- 串口接收到的数据
-local uartid = 1 -- 根据实际设备选取不同的uartid
-Sbuf = 0
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
-local wsc = nil
-
-sys.taskInit(function()
-
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-
-    -- 这是个测试服务, 当发送的是json,且action=echo,就会回显所发送的内容
-    -- 加密TCP链接 wss 表示加密
-    wsc = websocket.create(nil, "wss://echo.airtun.air32.cn/ws/echo")
-    -- 这是另外一个测试服务, 能响应websocket的二进制帧
-    -- wsc = websocket.create(nil, "ws://echo.airtun.air32.cn/ws/echo2")
-    -- 以上两个测试服务是Java写的, 源码在 https://gitee.com/openLuat/luatos-airtun/tree/master/server/src/main/java/com/luatos/airtun/ws
-
-    if wsc.headers then
-        wsc:headers({Auth="Basic ABCDEGG"})
-    end
-    wsc:autoreconn(true, 3000) -- 自动重连机制
-    wsc:on(function(wsc, event, data, fin, optcode)
-        --[[
-            event的值有:
-            conack 连接服务器成功,已经收到websocket协议头部信息,通信已建立
-            recv   收到服务器下发的信息, data, payload 不为nil
-            sent   send函数发送的消息,服务器在TCP协议层已确认收到
-            disconnect 服务器连接已断开
-
-            其中 sent/disconnect 事件在 2023.04.01 新增
-        ]]
-        -- data 当事件为recv是有接收到的数据
-        -- fin 是否为最后一个数据包, 0代表还有数据, 1代表是最后一个数据包
-        -- optcode, 0 - 中间数据包, 1 - 文本数据包, 2 - 二进制数据包
-        -- 因为lua并不区分文本和二进制数据, 所以optcode通常可以无视
-        -- 若数据不多, 小于1400字节, 那么fid通常也是1, 同样可以忽略
-        log.info("wsc", event, data, fin, optcode)
-        -- 显示二进制数据
-        -- log.info("wsc", event, data and data:toHex() or "", fin, optcode)
-        if event == "conack" then -- 连接websocket服务后, 会有这个事件
-            log.info("WebSocket connect succeed!")
-            sys.publish("wsc_conack")
-        end
-    end)
-    wsc:connect()
-    sys.waitUntil("wsc_conack")
-    while true do
-        uart.on(uartid, "receive", function(id, len)
-            while true do
-                local len = uart.rx(id, uart_rx_buff)   -- 接收串口收到的数据,并赋值到uart_rx_buff
-                if len <= 0 then    -- 接收到的字节长度为0 则退出
-                    break
-                else
-                    uart_rx_buff:seek(0)
-                    uart_rx_buff_data = uart_rx_buff:read(len)
-                    Sbuf = len
-                    log.info("UART接收的数据包",uart_rx_buff_data)
-                    break
-                end
-            end
-        end)
-
-        if Sbuf > 0 then
-            log.info("发送到服务器数据,长度",Sbuf)
-            log.info("UART发送到服务器的数据包 ",uart_rx_buff_data)
-            log.info("UART发送到服务器的数据包类型 ",type(uart_rx_buff_data))
-            if uart_rx_buff_data == '"echo"' then               -- 连接收到串口发送的"echo" ,会进行数据发送
-                log.info("UART透传成功 进行数据发送")
-                wsc:send(json.encode({action="echo", msg=os.date()})) ---发送数据
-            end
-        end
-        Sbuf = 0
-        uart_rx_buff:del()                      -- 清除串口buff的数据长度
-        sys.wait(1000) 
-    end
-
-    wsc:close()
-    wsc = nil
-
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 83
module/Air780EHV/DEMO/WebSocket/WebSocket加密通讯/main.lua

@@ -1,83 +0,0 @@
-
-PROJECT = "airtun"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
--- _G.sysplus = require("sysplus")
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-----------------------------------------
--- 报错信息自动上报到平台,默认是iot.openluat.com
--- 支持自定义, 详细配置请查阅API手册
--- 开启后会上报开机原因, 这需要消耗流量,请留意
-if errDump then
-    errDump.config(true, 600)
-end
-----------------------------------------
-
-local wsc = nil
-
-sys.taskInit(function()
-
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-
-    -- 这是个测试服务, 当发送的是json,且action=echo,就会回显所发送的内容
-    -- 加密TCP链接 wss 表示加密
-    wsc = websocket.create(nil, "wss://echo.airtun.air32.cn/ws/echo")
-    -- 这是另外一个测试服务, 能响应websocket的二进制帧
-    -- wsc = websocket.create(nil, "ws://echo.airtun.air32.cn/ws/echo2")
-    -- 以上两个测试服务是Java写的, 源码在 https://gitee.com/openLuat/luatos-airtun/tree/master/server/src/main/java/com/luatos/airtun/ws
-
-    if wsc.headers then
-        wsc:headers({Auth="Basic ABCDEGG"})
-    end
-    wsc:autoreconn(true, 3000) -- 自动重连机制
-    wsc:on(function(wsc, event, data, fin, optcode)
-        --[[
-            event的值有:
-            conack 连接服务器成功,已经收到websocket协议头部信息,通信已建立
-            recv   收到服务器下发的信息, data, payload 不为nil
-            sent   send函数发送的消息,服务器在TCP协议层已确认收到
-            disconnect 服务器连接已断开
-
-            其中 sent/disconnect 事件在 2023.04.01 新增
-        ]]
-        -- data 当事件为recv是有接收到的数据
-        -- fin 是否为最后一个数据包, 0代表还有数据, 1代表是最后一个数据包
-        -- optcode, 0 - 中间数据包, 1 - 文本数据包, 2 - 二进制数据包
-        -- 因为lua并不区分文本和二进制数据, 所以optcode通常可以无视
-        -- 若数据不多, 小于1400字节, 那么fid通常也是1, 同样可以忽略
-        log.info("wsc", event, data, fin, optcode)
-        -- 显示二进制数据
-        -- log.info("wsc", event, data and data:toHex() or "", fin, optcode)
-        if event == "conack" then -- 连接websocket服务后, 会有这个事件
-            log.info("WebSocket connect succeed!")
-            sys.publish("wsc_conack")
-        end
-    end)
-    wsc:connect()
-    -- 等待conack是可选的
-    sys.waitUntil("wsc_conack")
-    --local stat = wsc:ready()
-    -- 定期发业务ping也是可选的, 但为了保存连接, 也为了继续持有wsc对象, 这里周期性发数据
-    while true do
-        wsc:send((json.encode({action="echo", msg=os.date()})))
-        sys.wait(15000)
-        -- 发送二进制帧, 2023.06.21 之后编译的固件支持
-        -- wsc:send(string.char(0xA5, 0x5A, 0xAA, 0xF2), 1, 1)
-    end
-    wsc:close()
-    wsc = nil
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 24
module/Air780EHV/DEMO/adc/main.lua

@@ -1,24 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "adcdemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 一定要添加sys.lua !!!!
-sys = require("sys")
-
--- 添加硬狗防止程序卡死
-if wdt then
-    wdt.init(9000) -- 初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000) -- 3s喂一次狗
-end
-
-local testAdc = require "testAdc"
-sys.taskInit(testAdc.dotest)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 83
module/Air780EHV/DEMO/adc/testAdc.lua

@@ -1,83 +0,0 @@
-
---[[
-1. Air101,Air103 模块上的ADC0脚-PA1, 0~2.4v,不要超过范围使用!!!
-2. Air101,Air103模块上的ADC1脚-PA4, 0~2.4v,不要超过范围使用!!!
-3. Air103 模块上的ADC2脚-PA2, 0~2.4v,不要超过范围使用!!! 
-4. Air103 模块上的ADC3脚-PA3, 0~2.4v,不要超过范围使用!!! 
-5. Air101,Air103 adc.CH_CPU 为内部温度 ,adc.CH_VBAT为VBAT
-6. Air105 adc参考电压是1.88V,所有通道一致,
-7. Air105内部分压没有隔离措施,在开启内部分压后,量程有所变化,具体看寄存器手册,1~5分压后能测到3.6,6通道能接近5V,但是不能直接测5V,可以测4.2V 0通道是始终开启无法关闭分压。
-8. Air780E内部ADC接口为12bits 外部直流分压为0-3.4V
-9. Air780E内部具有2个ADC接口,ADC0 -- AIO3 ADC1 -- AIO4 
-10. 特殊通道, CPU内部温度Temp -- adc.CH_CPU 主供电脚电压 VBAT -- adc.CH_VBAT
-11. 设置分压(adc.setRange)要在adc.open之前设置,否则无效!!
-]]
-
-local testAdc = {}
-
-function adc_pin()
-    --Air780EHV开发板ADC编号
-    -- 默认不开启分压,范围是0-1.1v精度高
-    -- 开启分压后,外部输入最大不可超过3.3V
-    -- 设置分压要在adc.open之前设置,否则无效!!
-    -- adc.setRange(adc.ADC_RANGE_MAX)
-    return 0,1,255,255,adc.CH_CPU ,adc.CH_VBAT
-end
-local adc_pin_0,adc_pin_1,adc_pin_2,adc_pin_3,adc_pin_temp,adc_pin_vbat=adc_pin()
-
-
-function testAdc.dotest()
-    if adc_pin_0 and adc_pin_0 ~= 255 then adc.open(adc_pin_0) end
-    if adc_pin_1 and adc_pin_1 ~= 255 then adc.open(adc_pin_1) end
-    if adc_pin_2 and adc_pin_2 ~= 255 then adc.open(adc_pin_2) end
-    if adc_pin_3 and adc_pin_3 ~= 255 then adc.open(adc_pin_3) end
-    if adc_pin_temp and adc_pin_temp ~= 255 then adc.open(adc_pin_temp) end
-    if adc_pin_vbat and adc_pin_vbat ~= 255 then adc.open(adc_pin_vbat) end
-
-    if adc_pin_0 and adc_pin_0 ~= 255 and mcu and mcu.ticks then
-        sys.wait(1000)
-        log.info("开始读取ADC")
-        local ms_start = mcu.ticks()
-        for i = 1, 100, 1 do
-            adc.get(adc_pin_0)
-        end
-        local ms_end = mcu.ticks()
-        log.info("结束读取ADC")
-        log.info("adc", "读取耗时", "100次", ms_end - ms_start, "ms", "单次", (ms_end - ms_start) // 100, "ms")
-    end
-
-    -- 下面是循环打印, 接地不打印0也是正常现象
-    -- ADC的精度都不会太高, 若需要高精度ADC, 建议额外添加adc芯片
-    while true do
-        if adc_pin_0 and adc_pin_0 ~= 255 then
-            log.debug("adc", "adc" .. tostring(adc_pin_0), adc.get(adc_pin_0)) -- 若adc.get报nil, 改成adc.read
-        end
-        if adc_pin_1 and adc_pin_1 ~= 255 then
-            log.debug("adc", "adc" .. tostring(adc_pin_1), adc.get(adc_pin_1))
-        end
-        if adc_pin_2 and adc_pin_2 ~= 255 then
-            log.debug("adc", "adc" .. tostring(adc_pin_2), adc.get(adc_pin_2))
-        end
-        if adc_pin_3 and adc_pin_3 ~= 255 then
-            log.debug("adc", "adc" .. tostring(adc_pin_3), adc.get(adc_pin_3))
-        end
-        if adc_pin_temp and adc_pin_temp ~= 255 then
-            log.debug("adc", "CPU TEMP", adc.get(adc_pin_temp))
-        end
-        if adc_pin_vbat and adc_pin_vbat ~= 255 then
-            log.debug("adc", "VBAT", adc.get(adc_pin_vbat))
-        end
-        sys.wait(1000)
-    end
-
-    -- 若不再读取, 可关掉adc, 降低功耗, 非必须
-    if adc_pin_0 and adc_pin_0 ~= 255 then adc.close(adc_pin_0) end
-    if adc_pin_1 and adc_pin_1 ~= 255 then adc.close(adc_pin_1) end
-    if adc_pin_2 and adc_pin_2 ~= 255 then adc.close(adc_pin_2) end
-    if adc_pin_3 and adc_pin_3 ~= 255 then adc.close(adc_pin_3) end
-    if adc_pin_temp and adc_pin_temp ~= 255 then adc.close(adc_pin_temp) end
-    if adc_pin_vbat and adc_pin_vbat ~= 255 then adc.close(adc_pin_vbat) end
-
-end
-
-return testAdc

+ 0 - 96
module/Air780EHV/DEMO/airlbs/main.lua

@@ -1,96 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "paid_lbs"
-VERSION = "1.0.0"
-
--- 使用合宙iot平台时需要这个参数
-PRODUCT_KEY = "xxx" -- 到 iot.openluat.com 创建项目,获取正确的项目id
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-sysplus = require("sysplus")
-libnet = require "libnet"
-
-log.info("main", PROJECT, VERSION)
-
-if wdt then
-    -- 添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(20000) -- 初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000) -- 3s喂一次狗
-end
-
-local airlbs = require "airlbs"
-
-local timeout = 60 -- 扫描基站/wifi 做 基站/wifi定位 的超时时间,最小5S,最大60S
-
--- 此为收费服务,需自行联系销售申请
-local airlbs_project_id = ""
-local airlbs_project_key = ""
-
--- --多基站定位
--- sys.taskInit(function()
---     sys.waitUntil("IP_READY") -- 等待底层上报联网成功
---     socket.sntp() -- 进行NTP授时,放置部分联通卡没有基站授时
---     sys.waitUntil("NTP_UPDATE", 1000)
---     while 1 do
---         if airlbs_project_id and airlbs_project_key then
---             local result, data = airlbs.request({
---                 project_id = airlbs_project_id,
---                 project_key = airlbs_project_key,
---                 timeout = timeout * 1000 -- 实际的超时时间(单位:ms)
---             })
---             if result then
---                 log.info("airlbs多基站定位返回的经纬度数据为", json.encode(data))
---             end
---         else
---             log.warn("请检查project_id和project_key")
---         end
---         sys.wait(20000)
---     end
-
--- end)
-
--- wifi/基站混合定位
-sys.taskInit(function()
-    sys.waitUntil("IP_READY")
-    -- 如需wifi定位,需要硬件以及固件支持wifi扫描功能
-    local wifi_info = nil
-    if wlan then
-        sys.wait(3000) -- 网络可用后等待一段时间才再调用wifi扫描功能,否则可能无法获取wifi信息
-        wlan.init()
-        wlan.scan()
-        sys.waitUntil("WLAN_SCAN_DONE", timeout * 1000)
-        wifi_info = wlan.scanResult()
-        log.info("scan", "wifi_info", #wifi_info)
-    end
-
-    socket.sntp()
-    sys.waitUntil("NTP_UPDATE", 1000)
-
-    while 1 do
-        local result, data = airlbs.request({
-            project_id = airlbs_project_id,
-            project_key = airlbs_project_key,
-            wifi_info = wifi_info,
-            timeout = timeout * 1000
-        })
-        if result then
-            local data_str = json.encode(data)
-            log.info("airlbs多基站定位返回的经纬度数据为", data_str)
-            -- 解析经纬度
-            local lat = data_str:match("\"lat\":([0-9.-]+)")
-            log.info("airlbs", "lat", lat)
-            local lng = data_str:match("\"lng\":([0-9.-]+)")
-            log.info("airlbs", "lng", lng)
-        else
-            log.warn("请检查project_id和project_key")
-        end
-        sys.wait(20000) -- 循环20S一次wifi定位
-    end
-
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!
-

+ 0 - 81
module/Air780EHV/DEMO/airtalk/airaudio.lua

@@ -1,81 +0,0 @@
---[[
-@module  airaudio
-@summary 初始化codec测试功能模块
-@version 001.000.000
-@date    2025.07.11
-@author  李源龙
-@usage
-使用Air780EHV核心板外接AirAudio_1000,初始化配置:
-Air780EHM            AirAudio_1000
-GND(任意)            GND
-VDD_EXT              VCC
-19/GPIO22            PA_EN
-5/SPK+               SPK+
-4/SPK-               SPK-
-]]
-local airaudio = {}
-
-local i2c_id = 0            -- i2c_id 0
-
-
-local pa_pin = gpio.AUDIOPA_EN -- 喇叭pa功放脚
-local power_pin = 20 -- es8311电源脚
-
-
-local i2s_id = 0            -- i2s_id 0
-local i2s_mode = 0          -- i2s模式 0 主机 1 从机
-local i2s_sample_rate = 16000   -- 采样率
-local i2s_bits_per_sample = 16  -- 数据位数
-local i2s_channel_format = i2s.MONO_R   -- 声道, 0 左声道, 1 右声道, 2 立体声
-local i2s_communication_format = i2s.MODE_LSB   -- 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
-local i2s_channel_bits = 16     -- 声道的BCLK数量
-
-local multimedia_id = 0         -- 音频通道 0
-local pa_on_level = 1           -- PA打开电平 1 高电平 0 低电平
-local power_delay = 3           -- 在DAC启动前插入的冗余时间,单位100ms
-local pa_delay = 100            -- 在DAC启动后,延迟多长时间打开PA,单位1ms
-local power_on_level = 1        -- 电源控制IO的电平,默认拉高
-local power_time_delay = 600    -- 音频播放完毕时,PA与DAC关闭的时间间隔,单位1ms
-local taskName = "task_tts"
-
-local play_string = "降功耗,找合宙"
-local voice_vol = 60        -- 喇叭音量
-local mic_vol = 80          -- 麦克风音量
-
-function audio_setup()
-    sys.wait(100)
-
-    i2c.setup(i2c_id,i2c.FAST)
-    i2s.setup(i2s_id, i2s_mode, i2s_sample_rate, i2s_bits_per_sample, i2s_channel_format, i2s_communication_format,i2s_channel_bits)
-
-    audio.config(multimedia_id, pa_pin, pa_on_level, power_delay, pa_delay, power_pin, power_on_level, power_time_delay)
-    audio.setBus(multimedia_id, audio.BUS_I2S,{chip = "es8311",i2cid = i2c_id , i2sid = i2s_id, voltage = audio.VOLTAGE_1800})	--通道0的硬件输出通道设置为I2S
-
-    audio.vol(multimedia_id, voice_vol)
-    audio.micVol(multimedia_id, mic_vol)
-
-end
-
-local function audio_callback(id, event)
-    local succ,stop,file_cnt = audio.getError(0)
-    if not succ then
-        if stop then
-            log.info("用户停止播放")
-        else
-            log.info("第", file_cnt, "个文件解码失败")
-        end
-    end
-    sysplus.sendMsg(taskName, MSG_PD)
-end
-
-
-function airaudio.init()
-    sys.wait(100)
-    gpio.setup(power_pin, 1, gpio.PULLUP)   -- 打开音频编解码供电
-    gpio.setup(pa_pin, 1, gpio.PULLUP)      -- pa供电
-    audio_setup()
-    audio.on(0, audio_callback)
-end
-
-
-return airaudio

+ 0 - 60
module/Air780EHV/DEMO/airtalk/main.lua

@@ -1,60 +0,0 @@
-
---[[
-@module  main
-@summary LuatOS用户应用脚本文件入口,总体调度应用逻辑
-@version 001.000.000
-@date    2025.07.11
-@author  李源龙
-@usage
-本demo演示的功能为:
-使用Air780EHV核心板外接AirAudio_1000,通过airtalk库,通过MQTT实现对讲功能,对讲网页地址:https://airtalk.openluat.com/
-]]
-
---[[
-必须定义PROJECT和VERSION变量,Luatools工具会用到这两个变量,远程升级功能也会用到这两个变量
-PROJECT:项目名,ascii string类型
-        可以随便定义,只要不使用,就行
-VERSION:项目版本号,ascii string类型
-        如果使用合宙iot.openluat.com进行远程升级,必须按照"XXX.YYY.ZZZ"三段格式定义:
-            X、Y、Z各表示1位数字,三个X表示的数字可以相同,也可以不同,同理三个Y和三个Z表示的数字也是可以相同,可以不同
-            因为历史原因,YYY这三位数字必须存在,但是没有任何用处,可以一直写为000
-        如果不使用合宙iot.openluat.com进行远程升级,根据自己项目的需求,自定义格式即可
-]]
-PROJECT = "airtalk"
-VERSION = "001.000.000"
-
--- 如果内核固件支持errDump功能,此处进行配置,【强烈建议打开此处的注释】
--- 因为此功能模块可以记录并且上传脚本在运行过程中出现的语法错误或者其他自定义的错误信息,可以初步分析一些设备运行异常的问题
--- 以下代码是最基本的用法,更复杂的用法可以详细阅读API说明文档
--- 启动errDump日志存储并且上传功能,600秒上传一次
--- if errDump then
---     errDump.config(true, 600)
--- end
-
-
--- 使用LuatOS开发的任何一个项目,都强烈建议使用远程升级FOTA功能
--- 可以使用合宙的iot.openluat.com平台进行远程升级
--- 也可以使用客户自己搭建的平台进行远程升级
--- 远程升级的详细用法,可以参考fota的demo进行使用
-
-
--- 启动一个循环定时器
--- 每隔3秒钟打印一次总内存,实时的已使用内存,历史最高的已使用内存情况
--- 方便分析内存使用是否有异常
--- sys.timerLoopStart(function()
---     log.info("mem.lua", rtos.meminfo())
---     log.info("mem.sys", rtos.meminfo("sys"))
--- end, 3000)
-
-talk=require "talk"
-
---运行talk.run(),启动talk
-sys.taskInit(function()
-    log.info("start")
-    talk.run()
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 128
module/Air780EHV/DEMO/airtalk/talk.lua

@@ -1,128 +0,0 @@
---[[
-@module  talk
-@summary airtalk测试功能模块
-@version 001.000.000
-@date    2025.07.11
-@author  李源龙
-@usage
-使用Air780EHV核心板外接AirAudio_1000,连接MQTT服务器,订阅对应的主题和平台进行对讲功能,还支持使用powerkey按键进行对讲功能:
-Air780EHM            AirAudio_1000
-GND(任意)            GND
-VDD_EXT              VCC
-19/GPIO22            PA_EN
-5/SPK+               SPK+
-4/SPK-               SPK-
-]]
-local talk = {}
-
-local run_state = false
-local airaudio  = require "airaudio"
-local input_key = false
-
-
--- 初始化fskv
---speech_topic是topic,自己设定,需要和平台的topic一致,mqtt_host是mqtt服务器地址,mqtt_port是mqtt服务器端口,
---mqtt_isssl是是否使用ssl连接,client_id是mqtt客户端id,user_name是mqtt用户名,password是mqtt密码
-local speech_topic = "12345678910"
-local mqtt_host = "lbsmqtt.openluat.com"
-local mqtt_port = 1886
-local mqtt_isssl = false
-local client_id = nil
-local user_name = "mqtt_hz_test_1"
-local password = "Ck8WpNCp"
-local mqttc = nil
-local message = ""
-local event = ""
-local talk_state = ""
-
-local function airtalk_event_cb(event, param)
-    log.info("talk event", event, param)
-    event  = event
-end
-
-
--- MQTT回调函数
-local function mqtt_cb(mqtt_client, event, data, payload)
-    log.info("mqtt", "event", event, mqtt_client, data, payload)
-    -- 连接成功时订阅主题
-end
-
-
---初始化airtalk,连接MQTT
-local function init_talk()
-    log.info("init_call")
-    --初始化codec
-    airaudio.init() 
-    client_id = mobile.imei()
-
-    mqttc = mqtt.create(nil, mqtt_host, mqtt_port, mqtt_isssl, {rxSize = 4096})
-    airtalk.config(airtalk.PROTOCOL_DEMO_MQTT_8K, mqttc, 200) -- 缓冲至少200ms播放
-    airtalk.on(airtalk_event_cb)
-    airtalk.start(client_id, speech_topic)
-
-    mqttc:auth(client_id,user_name,password) -- client_id必填,其余选填
-    mqttc:keepalive(240) -- 默认值240s
-    mqttc:autoreconn(true, 3000) -- 自动重连机制
-    mqttc:debug(false)
-    mqttc:on(mqtt_cb)
-
-    -- mqttc自动处理重连, 除非自行关闭
-    mqttc:connect()
-
-end
-
--- 重新初始化对讲函数
-local function reinit_talk()
-    log.info("talk", "重新初始化对讲")
-    
-    -- 安全停止对讲
-    if airtalk and airtalk.stop then
-        airtalk.stop()
-    end
-    if mqttc then
-        mqttc:close()
-    end
-    
-    -- 重新初始化对讲
-    sys.taskInit(init_talk)
-end
-
---初始化airtalk
-function talk.run()
-    log.info("talk.run")
-    -- lcd.setFont(lcd.font_opposansm12_chinese)
-    run_state = true
-    init_talk()
-    speech_topic = fskv.get("talk_channel")
-    log.info("get  speech_topic",speech_topic)
-end
-
---停止语音采集
-local function stop_talk()
-    talk_state = "语音停止采集"
-    airtalk.uplink(false)
-    log.info("STATE", talk_state)
-end
-
---开启语音采集
-local function start_talk()
-    talk_state = "语音采集上传中"
-    airtalk.uplink(true)
-    log.info("STATE", talk_state)
-end
-
---设置防抖
-gpio.debounce(gpio.PWR_KEY,1000)
-gpio.setup(gpio.PWR_KEY,function(val)
-    if val == 1 then
-        log.info("talk", "暂停",val)
-        stop_talk()
-    else
-        log.info("talk2", "录音上传",val)
-        start_talk()
-
-    end
-end,gpio.PULLUP)
-
-
-return talk

+ 0 - 25
module/Air780EHV/DEMO/apn/main.lua

@@ -1,25 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "setApnDemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 一定要添加sys.lua !!!!
-sys = require("sys")
-
-mobile.apn(0,1,"name","user","password",nil,3) -- 专网卡设置的demo,name,user,password联系卡商获取
-
-local function main_task()
-    while true do
-        sys.wait(2000)
-        local apn = mobile.apn(0,1,"","","",nil,0) --获取APN,第三个参数不填就是获取APN
-        log.info("main  apn", apn)
-    end 
-end
-
-sys.taskInit(main_task)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

BIN
module/Air780EHV/DEMO/audio/1.mp3


+ 0 - 204
module/Air780EHV/DEMO/audio/main.lua

@@ -1,204 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "audio"
-VERSION = "1.0.0"
-
---[[]
-运行环境:Air780EHV核心板+AirAUDIO_1000配件板
-最后修改时间:2025-6-17
-使用了如下IO口:
-[5, "spk+", " PIN5脚, 用于喇叭正极"],
-[6, "spk-", " PIN6脚, 用于喇叭负极"],
-[20, "AudioPA_EN", " PIN20脚, 用于PA使能脚"],
-3.3V
-GND
-SD卡的使用IO口:
-[83, "SPI0CS", " PIN83脚, 用于SD卡片选脚"],
-[84, "SPI0MISO," PIN84脚, 用于SD卡数据脚"],
-[85, "SPI0MOSI", " PIN85脚, 用于SD卡数据脚"],
-[86, "SPI0CLK", " PIN86脚, 用于SD卡时钟脚"],
-[24, "VDD_EXT", " PIN24脚, 用于给SD卡供电脚"],
-GND
-执行逻辑为:
-设置i2s和音频参数,写了四种操作方式
-1、播放脚本区的文件
-2、挂载SD卡,通过HTTP下载到SD卡,播放SD卡中的文件
-3、通过HTTP下载到文件区,播放文件区中的文件
-4、通过HTTP下载到内存里面,播放内存中的文件
-]]
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-
---目前代码里面提供了4种播放方式,对应mode的值,默认是1
---1:播放脚本区的文件
---2:挂载SD卡,通过HTTP下载到SD卡,播放SD卡中的文件
---3:通过HTTP下载到文件区,播放文件区中的文件
---4:通过HTTP下载到内存里面,播放内存中的文件
-local mode = 1
-local i2c_id = 0 -- i2c_id 0
-
-local pa_pin = gpio.AUDIOPA_EN -- 喇叭pa功放脚
-local power_pin = 20 -- es8311电源脚
-
-local i2s_id = 0 -- i2s_id 0
-local i2s_mode = 0 -- i2s模式 0 主机 1 从机
-local i2s_sample_rate = 16000 -- 采样率
-local i2s_bits_per_sample = 16 -- 数据位数
-local i2s_channel_format = i2s.MONO_R -- 声道, 0 左声道, 1 右声道, 2 立体声
-local i2s_communication_format = i2s.MODE_LSB -- 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
-local i2s_channel_bits = 16 -- 声道的BCLK数量
-
-local multimedia_id = 0 -- 音频通道 0
-local pa_on_level = 1 -- PA打开电平 1 高电平 0 低电平
-local power_delay = 3 -- 在DAC启动前插入的冗余时间,单位100ms
-local pa_delay = 100 -- 在DAC启动后,延迟多长时间打开PA,单位1ms
-local power_on_level = 1 -- 电源控制IO的电平,默认拉高
-local power_time_delay = 100 -- 音频播放完毕时,PA与DAC关闭的时间间隔,单位1ms
-
-local voice_vol = 50 -- 喇叭音量
-local mic_vol = 80 -- 麦克风音量
-
-gpio.setup(power_pin, 1, gpio.PULLUP) -- 设置ES83111电源脚
-gpio.setup(pa_pin, 1, gpio.PULLUP) -- 设置功放PA脚
-
-function audio_setup()
-    log.info("audio_setup")
-    sys.wait(200)
-
-    i2c.setup(i2c_id, i2c.FAST)
-    i2s.setup(
-        i2s_id,
-        i2s_mode,
-        i2s_sample_rate,
-        i2s_bits_per_sample,
-        i2s_channel_format,
-        i2s_communication_format,
-        i2s_channel_bits
-    )
-
-    audio.config(multimedia_id, pa_pin, pa_on_level, power_delay, pa_delay, power_pin, power_on_level, power_time_delay)
-    audio.setBus(
-        multimedia_id,
-        audio.BUS_I2S,
-        {
-            chip = "es8311",
-            i2cid = i2c_id,
-            i2sid = i2s_id
-        }
-    ) -- 通道0的硬件输出通道设置为I2S
-    audio.vol(multimedia_id, voice_vol)
-    audio.micVol(multimedia_id, mic_vol)
-    sys.publish("AUDIO_READY")
-end
-
--- 配置好audio外设
-sys.taskInit(audio_setup)
-
-local taskName = "task_audio"
-
-local MSG_MD = "moreData" -- 播放缓存有空余
-local MSG_PD = "playDone" -- 播放完成所有数据
-
-audio.on(0,function(id, event)
-        -- 使用play来播放文件时只有播放完成回调
-        local succ, stop, file_cnt = audio.getError(0)
-        if not succ then
-            if stop then
-                log.info("用户停止播放")
-            else
-                log.info("第", file_cnt, "个文件解码失败")
-            end
-        end
-        sysplus.sendMsg(taskName, MSG_PD)
-    end
-)
-
-local function audio_task()
-    local result
-    sys.waitUntil("AUDIO_READY")
-    result = sys.waitUntil("IP_READY", 15000)
-    if result then
-        if mode == 1 then
-        elseif mode == 2 then
-            --以下内容为SD卡挂载的方式,如果有需要用到SD卡可以打开下面的挂载流程
-            -- -- 此为spi方式
-            local spi_id, pin_cs = 0, 8
-            -- 仅SPI方式需要自行初始化spi, sdio不需要
-            spi.setup(spi_id, nil, 0, 0, pin_cs, 400 * 1000)
-            gpio.setup(pin_cs, 1)
-            fatfs.mount(fatfs.SPI, "/sd", spi_id, pin_cs, 24 * 1000 * 1000)
-            local code, headers, body =
-                http.request("GET", "http://airtest.openluat.com:2900/download/1.mp3", nil, nil, {dst = "/sd/1.mp3"}).wait()
-            --存到sd卡里面
-            log.info("下载完成", code, headers, body)
-        elseif mode == 3 then
-            local code, headers, body =
-                http.request("GET", "http://airtest.openluat.com:2900/download/1.mp3", nil, nil, {dst = "/1.mp3"}).wait()
-            --存到本地文件区,适用于多次播放
-            log.info("下载完成", code, headers, body)
-        elseif mode == 4 then
-            local code, headers, body =
-                http.request("GET", "http://airtest.openluat.com:2900/download/1.mp3", nil, nil, {dst = "/ram/1.mp3"}).wait()
-            --存到内存里面,适用于下载播放一次,然后不需要再次播放或者不重启的时候可以继续播放,重启后需要重新下载
-            log.info("下载完成", code, headers, body)
-        end
-    end
-
-    while true do
-        log.info("开始播放")
-        if result then
-            if mode == 1 then
-                result = audio.play(0, "/luadb/1.mp3") -- 播放本地脚本区文件
-            elseif mode == 2 then
-                result = audio.play(0, "/sd/1.mp3") -- 播放sd卡里面文件
-            elseif mode == 3 then
-                result = audio.play(0, "/1.mp3") --播放HTTP下载的文件
-            elseif mode == 4 then
-                result = audio.play(0, "/ram/1.mp3") --播放HTTP下载到内存的文件
-            end
-        end
-        if result then
-            --等待音频通道的回调消息,或者切换歌曲的消息
-            while true do
-                msg = sysplus.waitMsg(taskName, nil)
-                if type(msg) == "table" then
-                    if msg[1] == MSG_PD then
-                        log.info("播放结束")
-                        break
-                    end
-                else
-                    log.error(type(msg), msg)
-                end
-            end
-        else
-            log.debug("解码失败!")
-            sys.wait(1000)
-        end
-        if not audio.isEnd(0) then
-            log.info("手动关闭")
-            audio.playStop(0)
-        end
-        if audio.pm then
-            audio.pm(0, audio.STANDBY) --PM模式 待机模式,PA断电,codec待机状态,系统不能进低功耗状态,如果PA不可控,codec进入静音模式
-        end
-        -- audio.pm(0,audio.SHUTDOWN)	--低功耗可以选择SHUTDOWN或者POWEROFF,如果codec无法断电用SHUTDOWN
-        log.info("mem", "sys", rtos.meminfo("sys"))
-        log.info("mem", "lua", rtos.meminfo("lua"))
-        sys.wait(1000)
-    end
-end
-
-sys.timerLoopStart(
-    function()
-        log.info("mem.lua", rtos.meminfo())
-        log.info("mem.sys", rtos.meminfo("sys"))
-    end,
-    3000
-)
-
-sysplus.taskInitEx(audio_task, taskName)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 52
module/Air780EHV/DEMO/bit/main.lua

@@ -1,52 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "bit64_test"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-
-
-local function log_bit()
-        log.info("按位取反,输出-6",bit.bnot(5))
-        log.info("与,--输出1",bit.band(1,1))
-        log.info("或,--输出3",bit.bor(1,2))
-        log.info("异或结果为4",bit.bxor(2,3,5))
-        log.info("逻辑左移,“100”,输出为4",bit.lshift(1,2))
-
-        log.info("逻辑右移,“001”,输出为1",bit.rshift(4,2))
-        log.info("算数右移,左边添加的数与符号有关,输出为0",bit.arshift(2,2))
-        log.info("参数是位数,作用是1向左移动两位,打印出4",bit.bit(2))
-        log.info("测试位数是否被置1",bit.isset(5,0))--第一个参数是是测试数字,第二个是测试位置.从右向左数0到7.是1返回true,否则返回false,该返回true
-        log.info("测试位数是否被置1",bit.isset(5,1))--打印false
-        log.info("测试位数是否被置1",bit.isset(5,2))--打印true
-        log.info("测试位数是否被置1",bit.isset(5,3))--返回返回false
-        log.info("测试位数是否被置0",bit.isclear(5,0))----与上面的相反
-        log.info("测试位数是否被置0",bit.isclear(5,1))
-        log.info("测试位数是否被置0",bit.isclear(5,2))
-        log.info("测试位数是否被置0",bit.isclear(5,3))
-        log.info("把0的第0,1,2,3位值为1",bit.set(0,0,1,2,3))--在相应的位数置1,打印15
-        log.info("把5的第0,2位置为0",bit.clear(5,0,2))--在相应的位置置0,打印0
-end
-
-sys.taskInit(log_bit)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 114
module/Air780EHV/DEMO/bit64/main.lua

@@ -1,114 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "bit64_test"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-
-local data,b64,b32,a,b
-
-if bit64 then
-	log.style(1)
-	log.info("bit64 演示")
-	data = 12345678
-	b64 = bit64.to64(data)
-	b32 = bit64.to32(b64)
-	log.info("i32", b32, mcu.x32(b32))
-	data = -12345678
-	b64 = bit64.to64(data)
-	b32 = bit64.to32(b64)
-	log.info("i32", b32, mcu.x32(b32))
-	data = 12.34234
-	b64 = bit64.to64(data)
-	b32 = bit64.to32(b64)
-	log.info("f32", data, b32)
-	data = -12.34234
-	b64 = bit64.to64(data)
-	b32 = bit64.to32(b64)
-	log.info("f32", data, b32)
-
-
-	a = bit64.to64(87654321)
-	b = bit64.to64(12345678)
-	log.info("87654321+12345678=", bit64.show(bit64.plus(a,b)))
-	log.info("87654321-12345678=", bit64.show(bit64.minus(a,b)))
-	log.info("87654321*12345678=", bit64.show(bit64.multi(a,b)))
-	log.info("87654321/12345678=", bit64.show(bit64.pide(a,b)))
-
-	a = bit64.to64(87654321)
-	b = 1234567
-	log.info("87654321+1234567=", bit64.show(bit64.plus(a,b)))
-	log.info("87654321-1234567=", bit64.show(bit64.minus(a,b)))
-	log.info("87654321*1234567=", bit64.show(bit64.multi(a,b)))
-	log.info("87654321/1234567=", bit64.show(bit64.pide(a,b)))
-
-
-	a = bit64.to64(87654.326)
-	b = bit64.to64(12345)
-	log.info("87654.326+12345=", 87654.326 + 12345)
-	log.info("87654.326+12345=", bit64.show(bit64.plus(a,b)))
-	log.info("87654.326-12345=", bit64.show(bit64.minus(a,b)))
-	log.info("87654.326*12345=", bit64.show(bit64.multi(a,b)))
-	log.info("87654.326/12345=", bit64.show(bit64.pide(a,b)))
-
-	a = bit64.to64(87654.32)
-	b = bit64.to64(12345.67)
-	log.info("float", "87654.32+12345.67=", 87654.32 + 12345.67)
-	log.info("double","87654.32+12345.67=", bit64.show(bit64.plus(a,b)))
-	log.info("double to float","87654.32+12345.67=", bit64.to32(bit64.plus(a,b)))
-	log.info("87654.32-12345.67=", bit64.show(bit64.minus(a,b)))
-	log.info("87654.32*12345.67=", bit64.show(bit64.multi(a,b)))
-	log.info("87654.32/12345.67=", bit64.show(bit64.pide(a,b)))
-	log.info("double to int64", "87654.32/12345.67=", bit64.show(bit64.pide(a,b,nil,true)))
-
-	a = bit64.to64(0xc0000000)
-	b = 2
-	a = bit64.shift(a,8,true)
-	log.info("0xc0000000 << 8 =", bit64.show(a, 16))
-	log.info("0xc000000000+2=", bit64.show(bit64.plus(a,b), 16))
-	log.info("0xc000000000-2=", bit64.show(bit64.minus(a,b), 16))
-	log.info("0xc000000000*2=", bit64.show(bit64.multi(a,b), 16))
-	log.info("0xc000000000/2=", bit64.show(bit64.pide(a,b), 16))
-	log.style(0)
-
-	if bit64.strtoll then
-		local data = bit64.strtoll("864040064024194", 10)
-		log.info("data", data:toHex())
-		log.info("data", bit64.show(data))
-	end
-end
-
-local function sys_run_time()
-	local tick64, per = mcu.tick64(true)
-	local per_cnt = per * 1000000
-	while true do
-		tick64, per = mcu.tick64(true)
-		log.info("work time","当前时间", bit64.to32(bit64.pide(tick64,per_cnt)))
-		sys.wait(1000)
-	end
-end
-
-if mcu.tick64 then
-	sys.taskInit(sys_run_time)
-end
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

BIN
module/Air780EHV/DEMO/crypto/logo.jpg


+ 0 - 242
module/Air780EHV/DEMO/crypto/main.lua

@@ -1,242 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "cryptodemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-sys.taskInit(function()
-
-    sys.wait(1000)
-
-    -- MD5,输出结果已经hex编码
-    log.info("md5", crypto.md5("abc"))
-    log.info("hmac_md5", crypto.hmac_md5("abc", "1234567890"))
-
-    -- SHA1,输出结果已经hex编码
-    log.info("sha1", crypto.sha1("abc"))
-    log.info("hmac_sha1", crypto.hmac_sha1("abc", "1234567890"))
-
-    -- SHA256,输出结果已经hex编码
-    log.info("sha256", crypto.sha256("abc"))
-    log.info("hmac_sha256", crypto.hmac_sha256("abc", "1234567890"))
-
-    -- SHA512,输出结果已经hex编码
-    log.info("sha512", crypto.sha512("abc"))
-    log.info("hmac_sha512", crypto.hmac_sha512("abc", "1234567890"))
-
-	local data_encrypt = crypto.cipher_encrypt("AES-128-ECB", "ZERO", "023001", "HZBIT@WLW/YSBKEY")
-	log.info("AES", "aes-128-ecb", data_encrypt:toHex())
-	local data_decrypt = crypto.cipher_decrypt("AES-128-ECB", "ZERO", data_encrypt, "HZBIT@WLW/YSBKEY")
-	log.info("AES", "aes-128-ecb", data_decrypt)
-
-    -- AES加密, 未经Hex编码. AES-128-ECB 算法,待加密字符串如果超过32字节会报错,待查. by wendal 20200812
-    local data_encrypt = crypto.cipher_encrypt("AES-128-ECB", "PKCS7", "12345678901234 > 123456", "1234567890123456")
-    local data2_encrypt = crypto.cipher_encrypt("AES-128-CBC", "PKCS7", "12345678901234 > 123456", "1234567890123456", "1234567890666666")
-    log.info("AES", "aes-128-ecb", data_encrypt:toHex())
-    log.info("AES", "aes-128-cbc", data2_encrypt:toHex())
-
-    -- AES解密, 未经Hex编码
-    local data_decrypt = crypto.cipher_decrypt("AES-128-ECB", "PKCS7", data_encrypt, "1234567890123456")
-    local data2_decrypt = crypto.cipher_decrypt("AES-128-CBC", "PKCS7", data2_encrypt, "1234567890123456", "1234567890666666")
-    log.info("AES", "aes-128-ecb", data_decrypt)
-    log.info("AES", "aes-128-cbc", data2_decrypt)
-    log.info("mem", rtos.meminfo("sys"))
-
-    -- DES-ECB 加解密
-    local data1 = crypto.cipher_encrypt("DES-ECB", "PKCS7", "abcdefg", "12345678")
-    if data1 then -- DES-ECB 在某些平台不支持的
-        log.info("des", data1:toHex())
-        local data2 = crypto.cipher_decrypt("DES-ECB", "PKCS7", data1, "12345678")
-        log.info("des", data2)
-    else
-        log.info("des", "当前固件不支持DES/3DES")
-    end
-
-    -- 3DES-ECB 加解密
-    local data1 = crypto.cipher_encrypt("DES-EDE3-ECB", "PKCS7", "abcdefg!!--ZZSS", "123456781234567812345678")
-    if data1 then -- DES-ECB 在某些平台不支持的
-        log.info("3des", data1:toHex())
-        local data2 = crypto.cipher_decrypt("DES-EDE3-ECB", "PKCS7", data1, "123456781234567812345678")
-        log.info("3des", data2)
-    else
-        log.info("3des", "当前固件不支持DES/3DES")
-    end
-
-
-    -- 打印所有支持的cipher
-    if crypto.cipher_list then
-        log.info("cipher", "list", json.encode(crypto.cipher_list()))
-    else
-        log.info("cipher", "当前固件不支持crypto.cipher_list")
-    end
-    -- 打印所有支持的cipher suites
-    if crypto.cipher_suites then
-        log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    else
-        log.info("cipher", "当前固件不支持crypto.cipher_suites")
-    end
-
-    ---------------------------------------
-    log.info("随机数测试")
-    for i=1, 10 do
-        sys.wait(100)
-        log.info("crypto", "真随机数",string.unpack("I",crypto.trng(4)))
-        -- log.info("crypto", "伪随机数",math.random()) -- 输出的是浮点数,不推荐
-        -- log.info("crypto", "伪随机数",math.random(1, 65525)) -- 不推荐
-    end
-
-    -- totp的密钥
-    log.info("totp的密钥")
-    local secret = "VK54ZXPO74ISEM2E"
-    --写死时间戳用来测试
-    local ts = 1646796576
-    --生成十分钟的动态码验证下
-    for i=1,600,30 do
-        local r = crypto.totp(secret,ts+i)
-        local time = os.date("*t",ts+i + 8*3600)--东八区
-        log.info("totp", string.format("%06d" ,r),time.hour,time.min,time.sec)
-    end
-
-    -- 文件测试
-    log.info("文件hash值测试")
-    if crypto.md_file then
-        log.info("md5", crypto.md_file("MD5", "/luadb/logo.jpg"))
-        log.info("sha1", crypto.md_file("SHA1", "/luadb/logo.jpg"))
-        log.info("sha256", crypto.md_file("SHA256", "/luadb/logo.jpg"))
-        
-        log.info("hmac_md5", crypto.md_file("MD5", "/luadb/logo.jpg", "123456"))
-        log.info("hmac_sha1", crypto.md_file("SHA1", "/luadb/logo.jpg", "123456"))
-        log.info("hmac_sha256", crypto.md_file("SHA256", "/luadb/logo.jpg", "123456"))
-    else
-        log.info("文件hash值测试", "当前固件不支持crypto.md_file")
-    end
-
-    if crypto.checksum then
-        log.info("checksum", "OK", string.char(crypto.checksum("OK")):toHex())
-        log.info("checksum", "357E", string.char(crypto.checksum("357E", 1)):toHex())
-    else
-        log.info("checksum", "当前固件不支持crypto.checksum")
-    end
-
-    -- 流式hash测试
-    log.info("流式hash测试")
-    if crypto.hash_init then
-        -- MD5
-        local md5_obj = crypto.hash_init("MD5")
-        crypto.hash_update(md5_obj, "1234567890")
-        crypto.hash_update(md5_obj, "1234567890")
-        crypto.hash_update(md5_obj, "1234567890")
-        crypto.hash_update(md5_obj, "1234567890")
-        local md5_result = crypto.hash_finish(md5_obj)
-        log.info("md5_stream", md5_result)
-        log.info("md5", crypto.md5("1234567890123456789012345678901234567890"))
-
-        -- HMAC_MD5
-        local hmac_md5_obj = crypto.hash_init("MD5", "1234567890")
-        crypto.hash_update(hmac_md5_obj, "1234567890")
-        crypto.hash_update(hmac_md5_obj, "1234567890")
-        crypto.hash_update(hmac_md5_obj, "1234567890")
-        crypto.hash_update(hmac_md5_obj, "1234567890")
-        local hmac_md5_result = crypto.hash_finish(hmac_md5_obj)
-        log.info("hmac_md5_stream", hmac_md5_result)
-        log.info("hmac_md5", crypto.hmac_md5("1234567890123456789012345678901234567890", "1234567890"))
-
-        -- SHA1
-        local sha1_obj = crypto.hash_init("SHA1")
-        crypto.hash_update(sha1_obj, "1234567890")
-        crypto.hash_update(sha1_obj, "1234567890")
-        crypto.hash_update(sha1_obj, "1234567890")
-        crypto.hash_update(sha1_obj, "1234567890")
-        local sha1_result = crypto.hash_finish(sha1_obj)
-        log.info("sha1_stream", sha1_result)
-        log.info("sha1", crypto.sha1("1234567890123456789012345678901234567890"))
-
-        -- HMAC_SHA1
-        local hmac_sha1_obj = crypto.hash_init("SHA1", "1234567890")
-        crypto.hash_update(hmac_sha1_obj, "1234567890")
-        crypto.hash_update(hmac_sha1_obj, "1234567890")
-        crypto.hash_update(hmac_sha1_obj, "1234567890")
-        crypto.hash_update(hmac_sha1_obj, "1234567890")
-        local hmac_sha1_result = crypto.hash_finish(hmac_sha1_obj)
-        log.info("hmac_sha1_stream", hmac_sha1_result)
-        log.info("hmac_sha1", crypto.hmac_sha1("1234567890123456789012345678901234567890", "1234567890"))
-
-        -- SHA256
-        local sha256_obj = crypto.hash_init("SHA256")
-        crypto.hash_update(sha256_obj, "1234567890")
-        crypto.hash_update(sha256_obj, "1234567890")
-        crypto.hash_update(sha256_obj, "1234567890")
-        crypto.hash_update(sha256_obj, "1234567890")
-        local sha256_result = crypto.hash_finish(sha256_obj)
-        log.info("sha256_stream", sha256_result)
-        log.info("sha256", crypto.sha256("1234567890123456789012345678901234567890"))
-
-        -- HMAC_SHA256
-        local hmac_sha256_obj = crypto.hash_init("SHA256", "1234567890")
-        crypto.hash_update(hmac_sha256_obj, "1234567890")
-        crypto.hash_update(hmac_sha256_obj, "1234567890")
-        crypto.hash_update(hmac_sha256_obj, "1234567890")
-        crypto.hash_update(hmac_sha256_obj, "1234567890")
-        local hmac_sha256_result = crypto.hash_finish(hmac_sha256_obj)
-        log.info("hmac_sha256_stream", hmac_sha256_result)
-        log.info("hmac_sha256", crypto.hmac_sha256("1234567890123456789012345678901234567890", "1234567890"))
-
-        -- SHA512
-        local sha512_obj = crypto.hash_init("SHA512")
-        if sha512_obj then
-            crypto.hash_update(sha512_obj, "1234567890")
-            crypto.hash_update(sha512_obj, "1234567890")
-            crypto.hash_update(sha512_obj, "1234567890")
-            crypto.hash_update(sha512_obj, "1234567890")
-            local sha512_result = crypto.hash_finish(sha512_obj)
-            log.info("sha512_stream", sha512_result)
-            log.info("sha512", crypto.sha512("1234567890123456789012345678901234567890"))
-        end
-
-        -- HMAC_SHA512
-        local hmac_sha512_obj = crypto.hash_init("SHA512", "1234567890")
-        if hmac_sha512_obj then
-            crypto.hash_update(hmac_sha512_obj, "1234567890")
-            crypto.hash_update(hmac_sha512_obj, "1234567890")
-            crypto.hash_update(hmac_sha512_obj, "1234567890")
-            crypto.hash_update(hmac_sha512_obj, "1234567890")
-            local hmac_sha512_result = crypto.hash_finish(hmac_sha512_obj)
-            log.info("hmac_sha512_stream", hmac_sha512_result)
-            log.info("hmac_sha512", crypto.hmac_sha512("1234567890123456789012345678901234567890", "1234567890"))
-        end
-    else
-        log.info("crypto", "当前固件不支持crypto.hash_init")
-    end
-
-    log.info("crc7测试")
-    if crypto.crc7 then
-        local result = crypto.crc7(string.char(0xAA), 0xE5, 0x00)
-        log.info("crc7测试", result, string.format("%02X", result))
-    else
-        log.info("crypto", "当前固件不支持crypto.crc7")
-    end
-
-    log.info("crypto", "ALL Done")
-    sys.wait(100000)
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 62
module/Air780EHV/DEMO/errDump/main.lua

@@ -1,62 +0,0 @@
-PROJECT = "errdump_test"
-VERSION = "1.0"
-PRODUCT_KEY = "s1uUnY6KA06ifIjcutm5oNbG3MZf5aUv" --换成自己的
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-log.style(1)
-
---下面演示自动发送
--- errDump.config(true, 600, "user_id")	-- 默认是关闭,用这个可以额外添加用户标识,比如用户自定义的ID之类
-
--- local function test_user_log()
--- 	while true do
--- 		sys.wait(15000)
--- 		errDump.record("测试一下用户的记录功能")
--- 	end
--- end
-
--- local function test_error_log()
--- 	sys.wait(60000)
--- 	-- lllllllllog.record("测试一下用户的记录功能") --默认写错代码死机
--- end
-
-
-
--- 下面演示手动获取信息
-errDump.config(true, 0)
-local function test_user_log()
-	local buff = zbuff.create(4096)
-	local new_flag = errDump.dump(buff, errDump.TYPE_SYS)		-- 开机手动读取一次异常日志
-	if buff:used() > 0 then
-		log.info(buff:toStr(0, buff:used()))	-- 打印出异常日志
-	end
-	new_flag = errDump.dump(buff, errDump.TYPE_SYS)
-	if not new_flag then
-		log.info("没有新数据了,删除系统错误日志")
-		errDump.dump(nil, errDump.TYPE_SYS, true)
-	end
-	while true do
-		sys.wait(15000)
-		errDump.record("测试一下用户的记录功能")
-		local new_flag = errDump.dump(buff, errDump.TYPE_USR)
-		if new_flag then
-			log.info("errBuff", buff:toStr(0, buff:used()))
-		end
-		new_flag = errDump.dump(buff, errDump.TYPE_USR)
-		if not new_flag then
-			log.info("没有新数据了,删除用户错误日志")
-			errDump.dump(nil, errDump.TYPE_USR, true)
-		end
-
-	end
-end
-
-local function test_error_log()
-	sys.wait(60000)
-	lllllllllog.record("测试一下用户的记录功能") --默认写错代码死机
-end
-
-sys.taskInit(test_user_log)
-sys.taskInit(test_error_log)
-sys.run()

+ 0 - 101
module/Air780EHV/DEMO/fota2/main.lua

@@ -1,101 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "fotademo"
--- iot限制,只能上传xxx.yyy.zzz格式的三位数的版本号,但实际上现在只用了XXX和ZZZ,中间yyy暂未使用
--- 需要注意的是,因为yyy不生效,所以111.222.333版本和111.444.333版本,对iot平台来说都一样,所以建议中间那一位永远写000
-VERSION = "001.000.000"
-
--- 使用合宙iot平台时需要这个参数
-PRODUCT_KEY = "123" -- 到 iot.openluat.com 创建项目,获取正确的项目id
-
-sys = require "sys"
-libfota2 = require "libfota2"
-
--- 联网函数, 可自行删减
-sys.taskInit(function()
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    log.info("4G网络链接成功")
-    sys.publish("net_ready")
-end)
-
--- 循环打印版本号, 方便看版本号变化, 非必须
-sys.taskInit(function()
-    while 1 do
-        sys.wait(5000)
-        log.info("降功耗 找合宙")
-        -- log.info("fota", "脚本版本号", VERSION)
-        log.info("fota", "脚本版本号", VERSION, "core版本号", rtos.version())
-    end
-end)
-
--- 升级结果的回调函数
--- 功能:获取fota的回调函数
--- 参数:
--- result:number类型
---   0表示成功
---   1表示连接失败
---   2表示url错误
---   3表示服务器断开
---   4表示接收报文错误
---   5表示使用iot平台VERSION需要使用 xxx.yyy.zzz形式
-local function fota_cb(ret)
-    log.info("fota", ret)
-    if ret == 0 then
-        log.info("升级包下载成功,重启模块")
-        rtos.reboot()
-    elseif ret == 1 then
-        log.info("连接失败", "请检查url拼写或服务器配置(是否为内网)")
-    elseif ret == 2 then
-        log.info("url错误", "检查url拼写")
-    elseif ret == 3 then
-        log.info("服务器断开", "检查服务器白名单配置")
-    elseif ret == 4 then
-        log.info("接收报文错误", "检查模块固件或升级包内文件是否正常")
-    elseif ret == 5 then
-        log.info("版本号书写错误", "iot平台版本号需要使用xxx.yyy.zzz形式")
-    else
-        log.info("不是上面几种情况 ret为", ret)
-    end
-end
-
-local ota_opts = {}
-
--- 使用合宙iot平台进行升级,不需要管下面这段代码
--- 使用第三方服务器时打开下面这段代码
---[[local ota_opts = {
-    url = "", 
-    -- 合宙IOT平台的默认升级URL, 不填就是这个默认值
-    -- 如果是自建的OTA服务器, 则需要填写正确的URL, 例如 http://192.168.1.5:8000/update
-    -- 如果自建OTA服务器,且url包含全部参数,不需要额外添加参数, 请在url前面添加 ### 
-    -- 如果不加###,则默认会上传如下参数
-    -- 1. opts.version string 版本号, 默认是 BSP版本号.x.z格式
-    -- 2. opts.timeout int 请求超时时间, 默认300000毫秒,单位毫秒
-    -- 3. opts.project_key string 合宙IOT平台的项目key, 默认取全局变量PRODUCT_KEY. 自建服务器不用填
-    -- 4. opts.imei string 设备识别码, 默认取IMEI(Cat.1模块)或WLAN MAC地址(wifi模块)或MCU唯一ID
-    -- 5. opts.firmware_name string 底层版本号
-    -- 请求的版本号, 合宙IOT有一套版本号体系,不传就是合宙规则, 自建服务器的话当然是自行约定版本号了
-    version = ""
-    -- 其他更多参数, 请查阅libfota2的文档 https://wiki.luatos.com/api/libs/libfota2.html
-}]]--
-sys.taskInit(function()
-    -- 这个判断是提醒要设置PRODUCT_KEY的,实际生产请删除
-    if "123" == _G.PRODUCT_KEY and not ota_opts.url then
-        while 1 do
-            sys.wait(1000)
-            log.info("fota", "请修改正确的PRODUCT_KEY")
-        end
-    end
-    -- 等待网络就行后开始检查升级
-    sys.waitUntil("net_ready")
-    log.info("开始检查升级")
-    sys.wait(500)
-    libfota2.request(fota_cb, ota_opts)
-end)
--- 演示定时自动升级, 每隔4小时自动检查一次
-sys.timerLoopStart(libfota2.request, 4 * 3600000, fota_cb, ota_opts)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 133
module/Air780EHV/DEMO/fs/main.lua

@@ -1,133 +0,0 @@
--- main.lua文件
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "fs_demo"
-VERSION = "1.0.0"
-
-log.info("---------------------文件创建---------------")  
-local ret, errio = io.mkdir("/data/")
-if ret then       
-       log.info("文件夹创建成功")  
-   else    
-       log.error("文件夹创建失败")  
-end
---[[
--- 方法1:使用io.open创建空文件(如果文件已存在,则覆盖)  
-local fd = io.open("/newfile.txt", "w")  
-if fd then
-  -- 文件已成功创建(或覆盖),此时文件为空    
-  fd:close()   
-    log.info("文件创建成功(空文件)")  
-else  
-   log.error("文件创建失败")  
-end  
-]]
--- 方法2:通过写入内容创建文件  
-
-log.info("---------------------文件创建---------------")  
-
-local content = "这是文件的内容"  
-local fd = io.open("/data/newfile_with_content.txt", "w")  
-if fd then    
-fd:write(content)   
-fd:close()    
-    log.info("文件创建成功并写入内容")  
-else    
-    log.error("文件创建失败")  
-end
-
-
-log.info("-------------------文件追加---------------")  
--- 打开文件以追加模式  
-local fd = io.open("/data/newfile_with_content.txt", "rb")  
-if fd then    -- 写入内容   
- local data_old = fd:read("*a")  
- log.info("文件创建初始内容:",data_old)  
- -- 关闭文件   
- fd:close() 
- local fd1 = io.open("/data/newfile_with_content.txt", "a")  
- fd1:write("我是追加的内容\n")    
- -- 关闭文件   
- fd1:close() 
- local fd2 = io.open("/data/newfile_with_content.txt", "rb") 
- local data_new = fd2:read("*a")  
- log.info("文件追加之后的内容:",data_new)  
- -- 关闭文件   
- fd2:close() 
-end
-
-
-log.info("----------------命名文件---------------")  
--- 重命名文件  
-local success, err = os.rename("/data/newfile_with_content.txt", "/data/newname.txt")  
-if success then    
-log.info("文件重命名成功")  
-else   
- log.error("文件重命名失败:" .. err)  
-end
-
-log.info("----------------文件拷贝---------------")  
----文件拷贝
--- 读取源文件内容  
-local fd_src = io.open("/data/newname.txt", "rb")  
-if fd_src then   
-    local content = fd_src:read("*a")  
-    fd_src:close()  
-    -- 写入目标文件  
-   local fd_dest = io.open("/data/destination.txt", "wb")   
-    if fd_dest then       
-       fd_dest:write(content)       
-       fd_dest:close()       
-       log.info("文件拷贝成功")   
-   else       
-       log.error("无法打开目标文件")  
-   end  
-else   
-  log.error("无法打开源文件")  
-end
-
-log.info("----------------移动文件---------------")  
-local ret, errio = io.mkdir("/destination/")
-if ret then       
-       log.info("文件夹创建成功")  
-   else    
-       log.error("文件夹创建失败")  
-end
--- 移动文件:重命名(适用于同一文件系统)  
-local success, err = os.rename("/data/newname.txt", "/destination/source.txt")  
-if success then   
-   log.info("文件移动成功(重命名)")  
-else   
- log.error("文件移动失败(重命名):" .. err)  
-end  
-
--- 获取文件大小  
-local size = io.fileSize("/data/newname.txt")  
-if size then   
- log.info("文件大小:" .. size .. " 字节")  
-else   
- log.error("无法获取文件大小")  
-end
-
-
--- 列出目录下的文件  
-
-local ret, data = io.lsdir("/data/",10,0)  
-if ret then
-   log.info("fs", "lsdir", json.encode(data))
- else
-   log.info("fs", "lsdir", "fail", ret, data)
- end
-
--- 删除文件  
-local success, err = os.remove("/destination/source.txt")  
-if success then   
-   log.info("文件删除成功")  
-else   
-   log.error("文件删除失败:" .. err)  
-end
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 105
module/Air780EHV/DEMO/fskv/main.lua

@@ -1,105 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "fskvdemo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
-
-sys.taskInit(function()
-    sys.wait(1000) -- 免得日志刷没了, 生产环境不需要
-
-    -- 检查一下当前固件是否支持fskv
-    if not fskv then
-        while true do
-            log.info("fskv", "this demo need fskv")
-            sys.wait(1000)
-        end
-    end
-
-    -- 初始化kv数据库
-    fskv.init()
-    log.info("fskv", "init complete")
-    -- 先放入一堆值
-    local bootime = fskv.get("boottime")
-    if bootime == nil or type(bootime) ~= "number" then
-        bootime = 0
-    else
-        bootime = bootime + 1
-    end
-    fskv.set("boottime", bootime)
-
-    fskv.set("my_bool", true)
-    fskv.set("my_int", 123)
-    fskv.set("my_number", 1.23)
-    fskv.set("my_str", "luatos")
-    fskv.set("my_table", {name="wendal",age=18})
-    
-    fskv.set("my_str_int", "123")
-    fskv.set("1", "123") -- 单字节key
-    --fskv.set("my_nil", nil) -- 会提示失败,不支持空值
-
-
-    log.info("fskv", "boottime",      type(fskv.get("boottime")),    fskv.get("boottime"))
-    log.info("fskv", "my_bool",      type(fskv.get("my_bool")),    fskv.get("my_bool"))
-    log.info("fskv", "my_int",       type(fskv.get("my_int")),     fskv.get("my_int"))
-    log.info("fskv", "my_number",    type(fskv.get("my_number")),  fskv.get("my_number"))
-    log.info("fskv", "my_str",       type(fskv.get("my_str")),     fskv.get("my_str"))
-    log.info("fskv", "my_table",     type(fskv.get("my_table")),   json.encode(fskv.get("my_table")))
-    log.info("fskv", "my_str_int",     type(fskv.get("my_str_int")),   fskv.get("my_str_int"))
-    log.info("fskv", "1 byte key",     type(fskv.get("1")),   json.encode(fskv.get("1")))
-
-    -- 删除测试
-    fskv.del("my_bool")
-    local t = fskv.get("my_bool")
-    log.info("fskv", "my_bool",      type(t),    t)
-
-    -- 查询kv数据库状态
-    -- local used, total,kv_count = fskv.stat()
-    -- log.info("fdb", "kv", used,total,kv_count)
-
-    -- fskv.clr()
-    -- local used, total,kv_count = fskv.stat()
-    -- log.info("fdb", "kv", used,total,kv_count)
-    
-
-    -- 压力测试
-    -- local start = mcu.ticks()
-    -- local count = 1000
-    -- for i=1,count do
-    --     -- sys.wait(10)
-    --     -- count = count - 1
-    --     -- fskv.set("BENT1", "--" .. os.date() .. "--")
-    --     -- fskv.set("BENT2", "--" .. os.date() .. "--")
-    --     -- fskv.set("BENT3", "--" .. os.date() .. "--")
-    --     -- fskv.set("BENT4", "--" .. os.date() .. "--")
-    --     fskv.get("my_bool")
-    -- end
-    -- log.info("fskv", mcu.ticks() - start)
-
-    if fskv.sett then
-        -- 设置数据, 字符串,数值,table,布尔值,均可
-        -- 但不可以是nil, function, userdata, task
-        log.info("fdb", fskv.sett("mytable", "wendal", "goodgoodstudy"))
-        log.info("fdb", fskv.sett("mytable", "upgrade", true))
-        log.info("fdb", fskv.sett("mytable", "timer", 1))
-        log.info("fdb", fskv.sett("mytable", "bigd", {name="wendal",age=123}))
-        
-        -- 下列语句将打印出4个元素的table
-        log.info("fdb", fskv.get("mytable"), json.encode(fskv.get("mytable")))
-        -- 注意: 如果key不存在, 或者原本的值不是table类型,将会完全覆盖
-        -- 例如下列写法,最终获取到的是table,而非第一行的字符串
-        log.info("fdb", fskv.set("mykv", "123"))
-        log.info("fdb", fskv.sett("mykv", "age", "123")) -- 保存的将是 {age:"123"}
-
-        -- 删除测试
-        log.info("fdb", fskv.set("mytable", {age=18, name="wendal"}))
-        log.info("fdb", fskv.sett("mytable", "name", nil))
-        log.info("fdb", fskv.get("mytable"), json.encode(fskv.get("mytable")))
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 92
module/Air780EHV/DEMO/ftp/main.lua

@@ -1,92 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "ftpdemo"
-VERSION = "1.0.0"
-
---[[
-本demo需要ftp库, 大部分能联网的设备都具有这个库
-ftp也是内置库, 无需require
-]]
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用ftp库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-sys.taskInit(function()
-    -----------------------------
-    -- 统一联网函数, 可自行删减
-    ----------------------------
-    if wlan and wlan.connect then
-        -- wifi 联网, ESP32系列均支持
-        local ssid = "luatos1234"
-        local password = "12341234"
-        log.info("wifi", ssid, password)
-        -- TODO 改成esptouch配网
-        -- LED = gpio.setup(12, 0, gpio.PULLUP)
-        wlan.init()
-        wlan.setMode(wlan.STATION)
-        wlan.connect(ssid, password, 1)
-        local result, data = sys.waitUntil("IP_READY", 30000)
-        log.info("wlan", "IP_READY", result, data)
-        device_id = wlan.getMac()
-        -- TODO 获取mac地址作为device_id
-    elseif mobile then
-        -- Air780E/Air600E系列
-        --mobile.simid(2)
-        -- LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-        sys.waitUntil("IP_READY", 30000)
-    end
-
-    -- -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件
-    -- if crypto.cipher_suites then
-    --     log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    -- end
-    while true do
-        sys.wait(1000)
-        log.info("ftp 启动")
-        print(ftp.login(nil,"121.43.224.154",21,"ftp_user","3QujbiMG").wait())
-    
-        print(ftp.command("NOOP").wait())
-        print(ftp.command("SYST").wait())
-
-        print(ftp.command("TYPE I").wait())
-        print(ftp.command("PWD").wait())
-        print(ftp.command("MKD QWER").wait())
-        print(ftp.command("CWD /QWER").wait())
-
-        print(ftp.command("CDUP").wait())
-        print(ftp.command("RMD QWER").wait())
-
-        print(ftp.command("LIST").wait())
-
-        -- io.writeFile("/1222.txt", "23noianfdiasfhnpqw39fhawe;fuibnnpw3fheaios;fna;osfhisao;fadsfl")
-        -- print(ftp.push("/1222.txt","/12222.txt").wait())
-        
-        print(ftp.pull("/122224.txt","/122224.txt").wait())
-
-        local f = io.open("/122224.txt", "r")
-        if f then
-            local data = f:read("*a")
-            f:close()
-            log.info("fs", "writed data", data)
-        else
-            log.info("fs", "open file for read failed")
-        end
-
-        print(ftp.command("DELE /12222.txt").wait())
-        print(ftp.push("/122224.txt","/12222.txt").wait())
-        print(ftp.close().wait())
-        log.info("meminfo", rtos.meminfo("sys"))
-        sys.wait(15000)
-    end
-
-
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 21
module/Air780EHV/DEMO/helloworld/main.lua

@@ -1,21 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "helloworld"
-VERSION = "1.0.0"
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
--- log.info("main", "hello world")
-
--- print(_VERSION)
-
-sys.timerLoopStart(function()
-    print("hello world")
-end, 3000)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 30
module/Air780EHV/DEMO/hmeta/main.lua

@@ -1,30 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "hmetademo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
-sys.taskInit(function()
-    while hmeta do
-        -- hmeta识别底层模组类型的
-        -- 不同的模组可以使用相同的bsp,但根据封装的不同,根据内部数据仍可识别出具体模块
-        log.info("hmeta", hmeta.model(), hmeta.hwver and hmeta.hwver())
-        log.info("bsp",   rtos.bsp())
-        sys.wait(3000)
-    end
-    log.info("这个bsp不支持hmeta库哦")
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 3
module/Air780EHV/DEMO/http/luatos_uploadFile.txt

@@ -1,3 +0,0 @@
-测试文本   adcc1234x衣二三
-	84as1c188
--*accxxx6-4

+ 0 - 306
module/Air780EHV/DEMO/http/main.lua

@@ -1,306 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "httpdemo"
-VERSION = "1.0.0"
-
---[[
-本demo需要http库, 大部分能联网的设备都具有这个库
-http也是内置库, 无需require
-
-1. 如需上传大文件,请使用 httpplus 库, 对应demo/httpplus
-2. 
-]]
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用http库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
-sys.taskInit(function()
-    -----------------------------
-    -- 统一联网函数, 可自行删减
-    ----------------------------
-    if wlan and wlan.connect then
-        -- wifi 联网, ESP32系列均支持
-        local ssid = "luatos1234"
-        local password = "12341234"
-        log.info("wifi", ssid, password)
-        -- TODO 改成esptouch配网
-        -- LED = gpio.setup(12, 0, gpio.PULLUP)
-        wlan.init()
-        wlan.setMode(wlan.STATION)
-        wlan.connect(ssid, password, 1)
-        local result, data = sys.waitUntil("IP_READY", 30000)
-        log.info("wlan", "IP_READY", result, data)
-        device_id = wlan.getMac()
-    elseif mobile then
-        -- Air780E/Air600E系列
-        --mobile.simid(2)
-        -- LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-        log.info("ipv6", mobile.ipv6(true))
-        sys.waitUntil("IP_READY", 30000)
-    elseif http then
-        sys.waitUntil("IP_READY")
-    else
-        while 1 do
-            sys.wait(1000)
-            log.info("http", "当前固件未包含http库")
-        end
-    end
-    log.info("已联网")
-    sys.publish("net_ready")
-end)
-
-function demo_http_get()
-    -- 最普通的Http GET请求
-    local code, headers, body = http.request("GET", "https://www.air32.cn/").wait()
-    log.info("http.get", code, headers, body)
-    local code, headers, body = http.request("GET", "https://mirrors6.tuna.tsinghua.edu.cn/", nil, nil, {ipv6=true}).wait()
-    log.info("http.get", code, headers, body)
-    sys.wait(100)
-    local code, headers, body = http.request("GET", "https://www.luatos.com/").wait()
-    log.info("http.get", code, headers, body)
-
-    -- 按需打印
-    -- code 响应值, 若大于等于 100 为服务器响应, 小于的均为错误代码
-    -- headers是个table, 一般作为调试数据存在
-    -- body是字符串. 注意lua的字符串是带长度的byte[]/char*, 是可以包含不可见字符的
-    -- log.info("http", code, json.encode(headers or {}), #body > 512 and #body or body)
-end
-
-function demo_http_post_json()
-    -- POST request 演示
-    local req_headers = {}
-    req_headers["Content-Type"] = "application/json"
-    local body = json.encode({name="LuatOS"})
-    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
-            req_headers,
-            body -- POST请求所需要的body, string, zbuff, file均可
-    ).wait()
-    log.info("http.post", code, headers, body)
-end
-
-function demo_http_post_form()
-    -- POST request 演示
-    local req_headers = {}
-    req_headers["Content-Type"] = "application/x-www-form-urlencoded"
-    local params = {
-        ABC = "123",
-        DEF = 345
-    }
-    local body = ""
-    for k, v in pairs(params) do
-        body = body .. tostring(k) .. "=" .. tostring(v):urlEncode() .. "&"
-    end
-    local code, headers, body = http.request("POST","http://echohttp.wendal.cn/post", 
-            req_headers,
-            body -- POST请求所需要的body, string, zbuff, file均可
-    ).wait()
-    log.info("http.post.form", code, headers, body)
-end
-
--- local function http_download_callback(content_len,body_len,userdata)
---     print("http_download_callback",content_len,body_len,userdata)
--- end
-
--- local http_userdata = "123456789"
-
-function demo_http_download()
-
-    -- POST and download, task内的同步操作
-    local opts = {}                 -- 额外的配置项
-    opts["dst"] = "/data.bin"       -- 下载路径,可选
-    opts["timeout"] = 30000         -- 超时时长,单位ms,可选
-    -- opts["adapter"] = socket.ETH0  -- 使用哪个网卡,可选
-    -- opts["callback"] = http_download_callback
-    -- opts["userdata"] = http_userdata
-
-    for k, v in pairs(opts) do
-        print("opts",k,v)
-    end
-    
-    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date",
-            {}, -- 请求所添加的 headers, 可以是nil
-            "", 
-            opts
-    ).wait()
-    log.info("http.post", code, headers, body) -- 只返回code和headers
-
-    -- local f = io.open("/data.bin", "rb")
-    -- if f then
-    --     local data = f:read("*a")
-    --     log.info("fs", "data", data, data:toHex())
-    -- end
-    
-    -- GET request, 开个task让它自行执行去吧, 不管执行结果了
-    sys.taskInit(http.request("GET","http://site0.cn/api/httptest/simple/time").wait)
-end
-
-function demo_http_post_file()
-        -- -- POST multipart/form-data模式 上传文件---手动拼接
-        local boundary = "----WebKitFormBoundary"..os.time()
-        local req_headers = {
-            ["Content-Type"] = "multipart/form-data; boundary="..boundary,
-        }
-        local body = "--"..boundary.."\r\n"..
-                     "Content-Disposition: form-data; name=\"uploadFile\"; filename=\"luatos_uploadFile_TEST01.txt\""..
-                     "\r\nContent-Type: text/plain\r\n\r\n"..
-                     "1111http_测试一二三四654zacc\r\n"..
-                     "--"..boundary
-
-        log.info("headers: ", "\r\n"..json.encode(req_headers))
-        log.info("body: ", "\r\n"..body)
-        local code, headers, body = http.request("POST","http://airtest.openluat.com:2900/uploadFileToStatic",
-                req_headers,
-                body -- POST请求所需要的body, string, zbuff, file均可
-        ).wait()
-        log.info("http.post", code, headers, body)
-
-        -- 也可用postMultipartFormData(url, params) 上传文件
-        postMultipartFormData(
-            "http://airtest.openluat.com:2900/uploadFileToStatic",
-            {
-                -- texts = 
-                -- {
-                --     ["imei"] = "862991234567890",
-                --     ["time"] = "20180802180345"
-                -- },
-                
-                files =
-                {
-                    ["uploadFile"] = "/luadb/luatos_uploadFile.txt",
-                }
-            }
-        )
-end
-
-
-local function demo_http_get_gzip()
-    -- 这里用 和风天气 的API做演示
-    -- 这个API的响应, 总会gzip压缩过, 需要配合miniz库进行解压
-    local code, headers, body = http.request("GET", "https://devapi.qweather.com/v7/weather/now?location=101010100&key=0e8c72015e2b4a1dbff1688ad54053de").wait()
-    log.info("http.gzip", code)
-    if code == 200 then
-        local re = miniz.uncompress(body:sub(11), 0)
-        log.info("和风天气", re)
-        if re then
-            local jdata = json.decode(re)
-            log.info("jdata", jdata)
-            if jdata then
-                log.info("和风天气", jdata.code)
-                if jdata.now then
-                    log.info("和风天气", "天气", jdata.now.text)
-                    log.info("和风天气", "温度", jdata.now.temp)
-                end
-            end
-        end
-    end
-end
-
-sys.taskInit(function()
-    sys.wait(100)
-    -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件
-    -- if crypto.cipher_suites then
-    --     log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    -- end
-
-    -------------------------------------
-    -------- HTTP 演示代码 --------------
-    -------------------------------------
-    sys.waitUntil("net_ready") -- 等联网
-
-    while 1 do
-        -- 演示GET请求
-        demo_http_get()
-        -- 表单提交
-        -- demo_http_post_form()
-        -- POST一个json字符串
-        -- demo_http_post_json()
-        -- 上传文件, mulitform形式
-        -- demo_http_post_file()
-        -- 文件下载
-        -- demo_http_download()
-        -- gzip压缩的响应, 以和风天气为例
-        -- demo_http_get_gzip()
-
-        sys.wait(1000)
-        -- 打印一下内存状态
-        log.info("sys", rtos.meminfo("sys"))
-        log.info("lua", rtos.meminfo("lua"))
-        sys.wait(600000)
-    end
-end)
-
----- MultipartForm上传文件
--- url string 请求URL地址
--- req_headers table 请求头
--- params table 需要传输的数据参数
-function postMultipartFormData(url, params)
-    local boundary = "----WebKitFormBoundary"..os.time()
-    local req_headers = {
-        ["Content-Type"] = "multipart/form-data; boundary="..boundary,
-    }
-    local body = {}
-
-    -- 解析拼接 body
-    for k,v in pairs(params) do
-        if k=="texts" then
-            local bodyText = ""
-            for kk,vv in pairs(v) do
-                print(kk,vv)
-                bodyText = bodyText.."--"..boundary.."\r\nContent-Disposition: form-data; name=\""..kk.."\"\r\n\r\n"..vv.."\r\n"
-            end
-            table.insert(body, bodyText)
-        elseif k=="files" then
-            local contentType =
-            {
-                txt = "text/plain",             -- 文本
-                jpg = "image/jpeg",             -- JPG 格式图片
-                jpeg = "image/jpeg",            -- JPEG 格式图片
-                png = "image/png",              -- PNG 格式图片   
-                gif = "image/gif",              -- GIF 格式图片
-                html = "image/html",            -- HTML
-                json = "application/json"       -- JSON
-            }
-            
-            for kk,vv in pairs(v) do
-                if type(vv) == "table" then
-                    for i=1, #vv do
-                        print(kk,vv[i])
-                        table.insert(body, "--"..boundary.."\r\nContent-Disposition: form-data; name=\""..kk.."\"; filename=\""..vv[i]:match("[^%/]+%w$").."\"\r\nContent-Type: "..contentType[vv[i]:match("%.(%w+)$")].."\r\n\r\n")
-                        table.insert(body, io.readFile(vv[i]))
-                        table.insert(body, "\r\n")
-                    end
-                else
-                    print(kk,vv)
-                    table.insert(body, "--"..boundary.."\r\nContent-Disposition: form-data; name=\""..kk.."\"; filename=\""..vv:match("[^%/]+%w$").."\"\r\nContent-Type: "..contentType[vv:match("%.(%w+)$")].."\r\n\r\n")
-                    table.insert(body, io.readFile(vv))
-                    table.insert(body, "\r\n")
-                end
-            end
-        end
-    end 
-    table.insert(body, "--"..boundary.."--\r\n")
-    body = table.concat(body)
-    log.info("headers: ", "\r\n" .. json.encode(req_headers), type(body))
-    log.info("body: " .. body:len() .. "\r\n" .. body)
-    local code, headers, body = http.request("POST",url,
-            req_headers,
-            body
-    ).wait()   
-    log.info("http.post", code, headers, body)
-end
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 37
module/Air780EHV/DEMO/i2c/aht10_test.lua

@@ -1,37 +0,0 @@
---[[
-@module  aht10_test
-@summary aht10_test测试功能模块
-@version 1.0
-@date    2025.07.01
-@author  yc
-@usage
-使用Air780EHV核心板 配合 aht10 传感器 演示i2c通信功能.
-]]
-
-
-
-local aht10 = require "aht10"
-
-function aht10_test_func()
---电平设置为3.3v
-pm.ioVol(pm.IOVOL_ALL_GPIO, 3300)
---设置gpio2输出,给camera_sda、camera_scl引脚提供上拉
-gpio.setup(2, 1)
-
-i2cid = 1
-i2c_speed = i2c.FAST
-
-i2c.setup(i2cid,i2c_speed)
---初始化,传入i2c_id
-aht10.init(i2cid)
-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(2000)
-
-end
-
-end
---创建并且启动一个task
---运行这个task的主函数aht10_test_func
-sys.taskInit(aht10_test_func)

+ 0 - 82
module/Air780EHV/DEMO/i2c/main.lua

@@ -1,82 +0,0 @@
---[[
-@module  main
-@summary LuatOS用户应用脚本文件入口,总体调度应用逻辑
-@version 1.0
-@date    2025.07.07
-@author yc
-@usage
-本demo演示的功能为:
-使用Air780EHV核心板 配合 aht10 传感器 演示i2c通信功能.
-]]
--- 接线
---[[
-SHT20 --- 模块
-SDA   -   I2C_SDA
-SCL   -   I2C_SCL
-VCC   -   VDDIO
-GND   -   GND
-]]
-
---[[
-必须定义PROJECT和VERSION变量,Luatools工具会用到这两个变量,远程升级功能也会用到这两个变量
-PROJECT:项目名,ascii string类型
-        可以随便定义,只要不使用,就行
-VERSION:项目版本号,ascii string类型
-        如果使用合宙iot.openluat.com进行远程升级,必须按照"XXX.YYY.ZZZ"三段格式定义:
-            X、Y、Z各表示1位数字,三个X表示的数字可以相同,也可以不同,同理三个Y和三个Z表示的数字也是可以相同,可以不同
-            因为历史原因,YYY这三位数字必须存在,但是没有任何用处,可以一直写为000
-        如果不使用合宙iot.openluat.com进行远程升级,根据自己项目的需求,自定义格式即可
-]]
-PROJECT = "aht10demo"
-VERSION = "001.000.000"
-
--- 在日志中打印项目名和项目版本号
-log.info("main", PROJECT, VERSION)
-
-
-
--- sys库是标配
-sys = require("sys")
-
-
--- 添加硬狗防止程序卡死
-if wdt then
-    wdt.init(9000) -- 初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000) -- 3s喂一次狗
-end
-
--- 如果内核固件支持errDump功能,此处进行配置,【强烈建议打开此处的注释】
--- 因为此功能模块可以记录并且上传脚本在运行过程中出现的语法错误或者其他自定义的错误信息,可以初步分析一些设备运行异常的问题
--- 以下代码是最基本的用法,更复杂的用法可以详细阅读API说明文档
--- 启动errDump日志存储并且上传功能,600秒上传一次
--- if errDump then
---     errDump.config(true, 600)
--- end
-
-
--- 使用LuatOS开发的任何一个项目,都强烈建议使用远程升级FOTA功能
--- 可以使用合宙的iot.openluat.com平台进行远程升级
--- 也可以使用客户自己搭建的平台进行远程升级
--- 远程升级的详细用法,可以参考fota的demo进行使用
-
-
--- 启动一个循环定时器
--- 每隔3秒钟打印一次总内存,实时的已使用内存,历史最高的已使用内存情况
--- 方便分析内存使用是否有异常
--- sys.timerLoopStart(function()
---     log.info("mem.lua", rtos.meminfo())
---     log.info("mem.sys", rtos.meminfo("sys"))
--- end, 3000)
-
-
---加载lcd测试应用模块
-require "aht10_test"
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!
-
-
-

+ 0 - 48
module/Air780EHV/DEMO/i2c/readme.md

@@ -1,48 +0,0 @@
-
-## 演示功能概述
-
-本例程将使用 I2C 协议读取传感器数据并打印出来温湿度数值。
-
-## 演示硬件环境
-
-1、Air780EHV核心板一块
-
-2、TYPE-C USB数据线一根
-
-3、Air780EHV核心板和数据线的硬件接线方式为
-
-- Air780EHV核心板通过TYPE-C USB口供电;(核心板USB旁边的开关拨到on一端)
-
-- TYPE-C USB数据线直接插到核心板的TYPE-C USB座子,另外一端连接电脑USB口;
-
-4、aht10 温湿度传感器一个
-
-[购买连接](https://item.taobao.com/item.htm?abbucket=15&detail_redpacket_pop=true&id=891645785252&ltk2=1751939170154m7bqoeqwmea8pnqgf2eih&ns=1&priceTId=2147825717519391446893951e12fd&query=aht10&spm=a21n57.1.hoverItem.11&utparam=%7B%22aplus_abtest%22%3A%223f8c6c40d54be7cad7b986e73347904b%22%7D&xxc=taobaoSearch)
-
-5、核心板和温湿度传感器连接方式
-
-
-| aht10 引脚 | Air780EHV 引脚 | 功能             |
-|-------------|----------------|------------------|
-| GND         | GND            | 地               |
-| VDD         | 3.3V           | 逻辑电源         |
-| SCL         | I2C1_SCL        | 时钟信号 (SPI)   |
-| SDA         | I2C1_SDA        | 数据输入 (SPI)   |
-
-
-
-## 演示软件环境
-
-1、Luatools下载调试工具
-
-2、[Air780EHV V2007版本固件](https://docs.openluat.com/air780ehv/luatos/firmware/version/)(测试使用V2007 固件)
-
-## 演示核心步骤
-
-1、搭建好演示硬件环境
-
-2、通过Luatools将demo与固件烧录到核心板中
-
-3、烧录成功后,自动开机运行
-
-4、终端循环打印获取的温湿度信息。

+ 0 - 218
module/Air780EHV/DEMO/iconv/main.lua

@@ -1,218 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "my_test"
-VERSION = "1.2"
-PRODUCT_KEY = "s1uUnY6KA06ifIjcutm5oNbG3MZf5aUv" -- 换成自己的
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-
---- unicode小端编码 转化为 gb2312编码
--- @string ucs2s unicode小端编码数据
--- @return string data,gb2312编码数据
--- @usage local data = common.ucs2ToGb2312(ucs2s)
-function ucs2ToGb2312(ucs2s)
-    local cd = iconv.open("gb2312", "ucs2")
-    return cd:iconv(ucs2s)
-end
-
---- gb2312编码 转化为 unicode小端编码
--- @string gb2312s gb2312编码数据
--- @return string data,unicode小端编码数据
--- @usage local data = common.gb2312ToUcs2(gb2312s)
-function gb2312ToUcs2(gb2312s)
-    local cd = iconv.open("ucs2", "gb2312")
-    return cd:iconv(gb2312s)
-end
-
---- unicode大端编码 转化为 gb2312编码
--- @string ucs2s unicode大端编码数据
--- @return string data,gb2312编码数据
--- @usage data = common.ucs2beToGb2312(ucs2s)
-function ucs2beToGb2312(ucs2s)
-    local cd = iconv.open("gb2312", "ucs2be")
-    return cd:iconv(ucs2s)
-end
-
---- gb2312编码 转化为 unicode大端编码
--- @string gb2312s gb2312编码数据
--- @return string data,unicode大端编码数据
--- @usage local data = common.gb2312ToUcs2be(gb2312s)
-function gb2312ToUcs2be(gb2312s)
-    local cd = iconv.open("ucs2be", "gb2312")
-    return cd:iconv(gb2312s)
-end
-
---- unicode小端编码 转化为 utf8编码
--- @string ucs2s unicode小端编码数据
--- @return string data,utf8编码数据
--- @usage data = common.ucs2ToUtf8(ucs2s)
-function ucs2ToUtf8(ucs2s)
-    local cd = iconv.open("utf8", "ucs2")
-    return cd:iconv(ucs2s)
-end
-
---- utf8编码 转化为 unicode小端编码
--- @string utf8s utf8编码数据
--- @return string data,unicode小端编码数据
--- @usage local data = common.utf8ToUcs2(utf8s)
-function utf8ToUcs2(utf8s)
-    local cd = iconv.open("ucs2", "utf8")
-    return cd:iconv(utf8s)
-end
-
---- unicode大端编码 转化为 utf8编码
--- @string ucs2s unicode大端编码数据
--- @return string data,utf8编码数据
--- @usage data = common.ucs2beToUtf8(ucs2s)
-function ucs2beToUtf8(ucs2s)
-    local cd = iconv.open("utf8", "ucs2be")
-    return cd:iconv(ucs2s)
-end
-
---- utf8编码 转化为 unicode大端编码
--- @string utf8s utf8编码数据
--- @return string data,unicode大端编码数据
--- @usage local data = common.utf8ToUcs2be(utf8s)
-function utf8ToUcs2be(utf8s)
-    local cd = iconv.open("ucs2be", "utf8")
-    return cd:iconv(utf8s)
-end
-
---- utf8编码 转化为 gb2312编码
--- @string utf8s utf8编码数据
--- @return string data,gb2312编码数据
--- @usage local data = common.utf8ToGb2312(utf8s)
-function utf8ToGb2312(utf8s)
-    local cd = iconv.open("ucs2", "utf8")
-    local ucs2s = cd:iconv(utf8s)
-    cd = iconv.open("gb2312", "ucs2")
-    return cd:iconv(ucs2s)
-end
-
---- gb2312编码 转化为 utf8编码
--- @string gb2312s gb2312编码数据
--- @return string data,utf8编码数据
--- @usage local data = common.gb2312ToUtf8(gb2312s)
-function gb2312ToUtf8(gb2312s)
-    local cd = iconv.open("ucs2", "gb2312")
-    local ucs2s = cd:iconv(gb2312s)
-    cd = iconv.open("utf8", "ucs2")
-    return cd:iconv(ucs2s)
-end
-
---------------------------------------------------------------------------------------------------------
---[[
-函数名:ucs2ToGb2312
-功能  :unicode小端编码 转化为 gb2312编码,并打印出gb2312编码数据
-参数  :
-        ucs2s:unicode小端编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testucs2ToGb2312(ucs2s)
-    print("ucs2ToGb2312")
-    local gb2312num = ucs2ToGb2312(ucs2s)--调用的是common.ucs2ToGb2312,返回的是编码所对应的字符串
-    --print("gb2312  code:",gb2312num)
-    print("gb2312  code:",string.toHex(gb2312num))
-end
-
---[[
-函数名:gb2312ToUcs2
-功能  :gb2312编码 转化为 unicode十六进制小端编码数据并打印
-参数  :
-        gb2312s:gb2312编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testgb2312ToUcs2(gb2312s)
-    print("gb2312ToUcs2")
-    local ucs2num = gb2312ToUcs2(gb2312s)
-    print("unicode little-endian code:" .. string.toHex(ucs2num)) -- 要将二进制转换为十六进制,否则无法输出
-end
-
---[[
-函数名:ucs2beToGb2312
-功能  :unicode大端编码 转化为 gb2312编码,并打印出gb2312编码数据,
-大端编码数据是与小端编码数据位置调换
-参数  :
-        ucs2s:unicode大端编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testucs2beToGb2312(ucs2s)
-    print("ucs2beToGb2312")
-    local gb2312num = ucs2beToGb2312(ucs2s) -- 转化后的数据直接变成字符可以直接输出
-    print("gb2312 code :" .. string.toHex(gb2312num))
-end
-
---[[
-函数名:gb2312ToUcs2be
-功能  :gb2312编码 转化为 unicode大端编码,并打印出unicode大端编码
-参数  :
-        gb2312s:gb2312编码数据,注意输入参数的字节数
-返回值:unicode大端编码数据
-]]
-function testgb2312ToUcs2be(gb2312s)
-    print("gb2312ToUcs2be")
-    local ucs2benum = gb2312ToUcs2be(gb2312s)
-    print("unicode big-endian code :" .. string.toHex(ucs2benum))
-end
-
---[[
-函数名:ucs2ToUtf8
-功能  :unicode小端编码 转化为 utf8编码,并打印出utf8十六进制编码数据
-参数  :
-        ucs2s:unicode小端编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testucs2ToUtf8(ucs2s)
-    print("ucs2ToUtf8")
-    local utf8num = ucs2ToUtf8(ucs2s)
-    print("utf8  code:" .. string.toHex(utf8num))
-
-end
-
---[[
-函数名:utf8ToGb2312
-功能  :utf8编码 转化为 gb2312编码,并打印出gb2312编码数据
-参数  :
-        utf8s:utf8编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testutf8ToGb2312(utf8s)
-    print("utf8ToGb2312")
-    local gb2312num = utf8ToGb2312(utf8s)
-    print("gb2312 code:" .. string.toHex(gb2312num))
-
-end
-
---[[
-函数名:gb2312ToUtf8
-功能  :gb2312编码 转化为 utf8编码,并打印出utf8编码数据
-参数  :
-        gb2312s:gb2312s编码数据,注意输入参数的字节数
-返回值:
-]]
-local function testgb2312ToUtf8(gb2312s)
-    print("gb2312ToUtf8")
-    local utf8s = gb2312ToUtf8(gb2312s)
-    print("utf8s code:" .. utf8s)
-
-end
-
-
-
-sys.taskInit(function()
-    while 1 do
-        sys.wait(1000)
-        testucs2ToGb2312(string.fromHex("1162")) -- "1162"是"我"字的ucs2编码,这里调用了string.fromHex将参数转化为二进制,也就是两个字节。
-        testgb2312ToUcs2(string.fromHex("CED2")) -- "CED2"是"我"字的gb2312编码
-        testucs2beToGb2312(string.fromHex("6211")) -- "6211"是"我"字的ucs2be编码
-        testgb2312ToUcs2be(string.fromHex("CED2"))
-        testucs2ToUtf8(string.fromHex("1162"))
-        testutf8ToGb2312(string.fromHex("E68891")) -- "E68891"是"我"字的utf8编码
-        testgb2312ToUtf8(string.fromHex("CED2"))
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 83
module/Air780EHV/DEMO/iotcloud/aliyun/示例1 一型一密(免预注册,但需要是企业版实例平台)方式连接云平台/main.lua

@@ -1,83 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "aliyun_yxym_myzc"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        device_id = mobile.imei()
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    --------    以下接入方式根据自己需要修改,相关参数修改为自己的    ---------
-
-    -- 阿里云  
-    -- 动态注册(免预注册)(一型一密)(仅企业版支持)
-    iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",product_secret = "xxx"}) -- 企业版公共实例
-    -- 动态注册(预注册)(一型一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",product_secret = "xxx"})                     -- 旧版公共实例
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",product_secret = "xxx"}) -- 新版公共实例
-    -- 密钥校验 (预注册)(一机一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",device_secret = "xxx"})                    -- 旧版公共实例
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",device_secret = "xxx"})-- 新版公共实例
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc:subscribe("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/get") -- 订阅主题,用于下发消息
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-    end
-end)
-
--- 每隔2秒发布一次qos为1的消息到云平台
-sys.taskInit(function()
-    while 1 do
-        sys.wait(2000)
-        if iotcloudc then
-            iotcloudc:publish("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/update", "hello world", 1) -- 上传数据
-        end
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 82
module/Air780EHV/DEMO/iotcloud/aliyun/示例2 一型一密(预注册)方式连接云平台/main.lua

@@ -1,82 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "aliyun_yxym_yzc"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        device_id = mobile.imei()
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    --------    以下接入方式根据自己需要修改,相关参数修改为自己的    ---------
-
-    -- 阿里云  
-    -- 动态注册(免预注册)(一型一密)(仅企业版支持)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",product_secret = "xxx"}) -- 企业版公共实例
-    -- 动态注册(预注册)(一型一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",product_secret = "xxx"})                     -- 旧版公共实例
-    iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",product_secret = "xxx"}) -- 新版公共实例
-    -- 密钥校验 (预注册)(一机一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",device_secret = "xxx"})                    -- 旧版公共实例
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",device_secret = "xxx"})-- 新版公共实例
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc:subscribe("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/get") -- 订阅主题,用于下发消息
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-    end
-end)
-
--- 每隔2秒发布一次qos为1的消息到云平台
-sys.taskInit(function()
-    while 1 do
-        sys.wait(2000)
-        if iotcloudc then
-            iotcloudc:publish("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/update", "hello world", 1) -- 上传数据
-        end
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 82
module/Air780EHV/DEMO/iotcloud/aliyun/示例3 一机一密方式连接云平台/main.lua

@@ -1,82 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "aliyun_yjym_yzc"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        device_id = mobile.imei()
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    --------    以下接入方式根据自己需要修改,相关参数修改为自己的    ---------
-
-    -- 阿里云  
-    -- 动态注册(免预注册)(一型一密)(仅企业版支持)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",product_secret = "xxx"}) -- 企业版公共实例
-    -- 动态注册(预注册)(一型一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",product_secret = "xxx"})                     -- 旧版公共实例
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",product_secret = "xxx"}) -- 新版公共实例
-    -- 密钥校验 (预注册)(一机一密)
-    -- iotcloudc = iotcloud.new(iotcloud.ALIYUN,{product_id = "xxx",device_name = "xxx",device_secret = "xxx"})                    -- 旧版公共实例
-    iotcloudc = iotcloud.new(iotcloud.ALIYUN,{instance_id = "xxx",product_id = "xxx",device_name = "xxx",device_secret = "xxx"})-- 新版公共实例
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc:subscribe("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/get") -- 订阅主题,用于下发消息
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-    end
-end)
-
--- 每隔2秒发布一次qos为1的消息到云平台
-sys.taskInit(function()
-    while 1 do
-        sys.wait(2000)
-        if iotcloudc then
-            iotcloudc:publish("/"..iotcloudc.product_id.."/"..iotcloudc.device_name.."/user/update", "hello world", 1) -- 上传数据
-        end
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 70
module/Air780EHV/DEMO/iotcloud/baiduiot/main.lua

@@ -1,70 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "iotclouddemo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    -- 百度云
-    -- 密钥认证(手动注册)
-    -- iotcloudc = iotcloud.new(iotcloud.BAIDU,{produt_id = "aakyhyw",device_name = "869329069169988",device_secret = "IzNIWqXdGRPEoUlS"})
-    -- 证书认证(自动注册)
-    iotcloudc = iotcloud.new(iotcloud.BAIDU,{produt_id = "aakyhyw",device_name = "869329069169988"},{tls={server_cert=io.readFile("/luadb/GlobalSign.cer"),client_cert=io.readFile("/luadb/client_cert.txt"),client_key=io.readFile("/luadb/client_private_key.txt")}})
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc:subscribe("$iot/869329069169988/user/fortest") -- 可以自由订阅主题等
-
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        if payload == "open" then
-            log.info("main", "收到云平台下发的指令")
-            LED(1)
-        elseif payload == "close" then
-            LED(0)
-        end
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-        print("iotcloud","DISCONNECT", "云平台连接断开")
-    end
-end)
-
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 88
module/Air780EHV/DEMO/iotcloud/huaweiiot/main.lua

@@ -1,88 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "iotclouddemo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        -- LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    -- -- 华为云
-    -- -- 动态注册(免预注册)
-    -- iotcloudc = iotcloud.new(iotcloud.HUAWEI,{produt_id = "670c7b2dfc8d5a4ea71c6a79",
-    --                                             project_id = "c086a58ebd714bfcb1a0fea2f0edde36",
-    --                                             endpoint = "9098a2ff3c.st1",
-    --                                             iam_username="hao",
-    --                                             iam_password="Wsh1322764769",
-    --                                             iam_domain="hao15738882476"})
-    -- 密钥校验 (预注册)
-    iotcloudc = iotcloud.new(iotcloud.HUAWEI,{produt_id = "670c7b2dfc8d5a4ea71c6a79",endpoint = "5341624af8.st1",device_name = "869329069169988",device_secret = "XXX"})
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        -- iotcloudc:subscribe("/huawei/down/869329069169988") -- 可以自由定阅主题等
-        -- iotcloudc:subscribe("$oc/devices/869329069169988/user/869329069169988")
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        -- local test_value = json.decode(payload).content.switch
-        -- print("test value:", test_value)
-
-        -- if test_value == 1 then
-        --     LED(1)
-        -- elseif test_value == 0 then
-        --     LED(0)
-        -- end
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-        print("iotcloud","DISCONNECT", "云平台连接断开")
-    end
-end)
-
--- -- 每隔2秒发布一次qos为1的消息到云平台
--- sys.taskInit(function()
---     while 1 do
---         sys.wait(2000)
---         if iotcloudc then
---             iotcloudc:publish("$oc/devices/869329069169988/user/869329069169988", "hello world!", 1) -- 上传数据
---         end
---     end
--- end)
-
-
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 157
module/Air780EHV/DEMO/iotcloud/onenet/main.lua

@@ -1,157 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "oneNET_demo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-lbsLoc2 = require("lbsLoc2")
-local iotcloud = require("iotcloud")
-mobile.simid(2, true)
-
-local produt_id = "4qM5N1Sa4T"
-local userid = "226691"
-local userkey = "pk1M3FKXBvvmjF8If/xDfSFFmr96NZCEg00sxlLBMjjh9vOD5hpIs42rmAYnMh5b3m9B1+0rmYdqzUyoQVrxow=="
-local device_name = mobile.imei()
-local send_data_time = 5 * 60 * 1000 -- 定时发送数据的时间,单位ms
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    --------    以下接入方式根据自己需要修改,相关参数修改为自己的    ---------
-
-    -- ONENET云
-    -- 动态注册
-    iotcloudc = iotcloud.new(iotcloud.ONENET, {
-        device_name = device_name,
-        produt_id = produt_id,
-        userid = userid,
-        userkey = userkey
-    })
-    -- 一型一密
-    -- iotcloudc = iotcloud.new(iotcloud.ONENET,{produt_id = "xxx",product_secret = "xxx"})
-    -- 一机一密
-    -- iotcloudc = iotcloud.new(iotcloud.ONENET,{produt_id = "xxx",device_name = "xxx",device_secret = "xxx"})
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-
-end)
-
--- 发布和订阅的主题
-
-local oneNET_sub = "$sys/" .. produt_id .. "/" .. device_name .. "/thing/property/post/reply"
-
-local oneNET_pub = "$sys/" .. produt_id .. "/" .. device_name .. "/thing/property/post"
-
-local function oneNET_send_data()
-    log.info("oneNET 链接成功,准备开始发送数据")
-    while 1 do
-        -- 没有mobile库就没有基站定位
-        mobile.reqCellInfo(15)
-        -- 由于基站定位需要等待扫描周围基站,推荐扫描时间为15S
-        sys.waitUntil("CELL_INFO_UPDATE", 15000)
-        local lat, lng, t = lbsLoc2.request(5000)
-        log.info("lbsLoc2", lat, lng, (json.encode(t or {})))
-        -- 如果没扫描到基站则给lat和lng赋值为0
-        if lat and lng then
-            log.info("扫描到了,有位置信息")
-        else
-            lat = "0"
-            lng = "0"
-        end
-        -- 读取CPU温度, 单位为0.001摄氏度, 是内部温度, 非环境温度
-        adc.open(adc.CH_CPU)
-        local cpu_temp = adc.get(adc.CH_CPU)
-        adc.close(adc.CH_CPU)
-        local gpio_pin = 6 -- GPIO编号
-        local gpio_state = gpio.get(gpio_pin)
-        local send_data = {
-            id = "123",
-            verson = VERSION,
-            params = {
-                gpio_state = {
-                    value = gpio_state
-                },
-                cpu_temp = {
-                    value = cpu_temp / 1000
-                },
-                lbs_lat = {
-                    value = tonumber(lat)
-                },
-                lbs_lng = {
-                    value = tonumber(lng)
-                    -- value = lng
-                }
-            }
-        }
-        local send_data = json.encode(send_data)
-        log.info("发送的数据为", send_data)
-        -- 正式发布数据
-        iotcloudc:publish(oneNET_pub, send_data)
-        -- 循环发送数据的定时时间
-        sys.wait(send_data_time)
-    end
-
-end
-
-local con = 0
---oneNET断开后的处理函数,
-local function oneNET_DISCONNECT()
-    log.info("云平台断开了,隔一分钟重连一次,如果10次都没有连上则重启设备")
-    while con < 10 do
-        sys.wait(60*1000)
-        log.info("oneNET reconnection",con)
-        iotcloudc:connect()
-    end
-    pm.reboot()
-end
-sys.subscribe("iotcloud", function(cloudc, event, data, payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        log.info("iotcloud", "CONNECT", "oneNET平台连接成功")
-        iotcloudc:subscribe({
-            [oneNET_sub] = 1
-        }) -- 订阅服务器下发数据的主题
-        -- 链接成功,启动一个task专门用来定时发消息
-        sys.taskInit(oneNET_send_data)
-
-    elseif event == iotcloud.RECEIVE then
-        log.info("收到服务器下发的数据")
-        log.info("iotcloud", "topic", data, "payload", payload)
-
-        -- 用户处理代码
-        if payload then
-            payload = json.decode(payload)
-            if payload["code"] == 200 then
-                log.info("服务器收到了刚刚上传的数据", payload["msg"])
-            else
-                log.info("服务器接收数据有误", "错误码为", payload["code"], "错误信息为",
-                    payload["msg"])
-            end
-        end
-
-    elseif event == iotcloud.SEND then
-        log.info("发送数据成功")
-
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-       sys.taskInit(oneNET_DISCONNECT)
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 79
module/Air780EHV/DEMO/iotcloud/tencentiot/main.lua

@@ -1,79 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "iotclouddemo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    if mobile then
-        LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    -- -- 腾讯云
-    -- -- 动态注册
-    -- iotcloudc = iotcloud.new(iotcloud.TENCENT,{produt_id = "ZAJCHA24SH" ,product_secret = "vGGwnSkyM4eD5ddbNrQoGJox"})
-    -- -- 密钥校验
-    iotcloudc = iotcloud.new(iotcloud.TENCENT,{produt_id = "ZAJCHA24SH",device_name = "869329069169988",device_secret = "xNWcxDX0qzSM74oFteehvw=="})
-
-    if iotcloudc then
-        iotcloudc:connect()
-    end
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc:subscribe("$thing/down/property/ZAJCHA24SH/869329069169988") -- 可以自由定阅主题等
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        local test_value = json.decode(payload).params.switch
-        print("test value:", test_value)
-
-        if test_value == 1 then
-            LED(1)
-        elseif test_value == 0 then
-            LED(0)
-        end
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-        print("iotcloud","DISCONNECT", "云平台连接断开")
-    end
-end)
-
--- 每隔2秒发布一次qos为1的消息到云平台
-sys.taskInit(function()
-    while 1 do
-        sys.wait(2000)
-        if iotcloudc then
-            iotcloudc:publish("$thing/up/property/ZAJCHA24SH/869329069169988", "hello world!", 1) -- 上传数据
-        end
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 132
module/Air780EHV/DEMO/iotcloud/tlink/main.lua

@@ -1,132 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "IOTCLOUD_TLINK"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- TLINK平台设备序列号
-local serialNumber = "XXXXXXXXXXXXXX"
--- TLINK平台登录账号
-local username = "XXXXXXXXXXXXXX"
--- TLINK平台登录密码
-local password = "XXXXXXXXXXXXXX"
-
--- TLINK平台添加的传感器ID
-local sensorsId = "XXXXXXXXXXXXXX"
-
--- TLINK平台添加的传感器对应的TOPIC,iotcloud库会自动为设备订阅通配主题,用户只需判断报文是否来自该传感器的TOPIC即可
-local tlinkSubTopic = serialNumber .. "/" .. sensorsId
-
--- 是否使用自动重连
-local autoReconnect = false
-local connectConfig = {
-    keepalive = 60 -- mqtt心跳设置为60秒
-}
-
--- 手动重连定时器ID
-local reconnectTimerId
-
-if autoReconnect then
-    connectConfig.autoreconn = 3000 -- 云平台断开3秒后自动重连
-end
-
--- TLINK平台switch类型传感器回传报文
-local function switchSensorPub(cloudc, switch)
-    local tmp = {
-        sensorDatas = {{
-            sensorsId = sensorsId,
-            switcher = switch
-        }}
-    }
-    local payload = json.encode(tmp)
-    log.info("回传的报文", payload)
-    cloudc:publish(serialNumber, payload)
-end
-
--- 将gpio27设置为输出模式,低电平,gpio27在开发板上控制的是蓝灯
-local ledCtrl = gpio.setup(27, 0)
-
--- 订阅来自iotcloud库发布的消息主题
-sys.subscribe("iotcloud", function(cloudc, event, data, payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台连上了
-        if not autoReconnect then
-            if reconnectTimerId and sys.timerIsActive(reconnectTimerId) then
-                sys.timerStop(reconnectTimerId)
-            end
-        end
-        log.info("TLINK 云平台连接成功")
-        -- cloudc:subscribe("test") -- 可以自由订阅主题,详情可参考TLINK开发文档
-    elseif event == iotcloud.RECEIVE then
-        log.info("TLINK 发布消息", "topic", data, "payload", payload)
-        -- 判断主题是否来自sensorsId的报文
-        if data == tlinkSubTopic then
-            -- json解析
-            local userPayload, result, err = json.decode(payload)
-            -- 防止异常的措施,防止json解析失败代码运行异常
-            if result == 1 and userPayload and type(userPayload) == "table" then
-                if userPayload.sensorDatas and userPayload.sensorDatas[1] then
-                    local switch = userPayload.sensorDatas[1].switcher
-                    -- 如果开关状态等于1,则打开蓝灯,否则关闭蓝灯
-                    if switch == 1 then
-                        ledCtrl(1)
-                    else
-                        ledCtrl(0)
-                    end
-                    -- 回传报文
-                    switchSensorPub(cloudc, switch)
-                end
-            end
-        end
-    elseif event == iotcloud.OTA then
-        -- 用户处理代码
-        -- TLINK 不会有这条消息上报,可忽略
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-        log.info("云平台连接断开")
-        if not autoReconnect then
-            if reconnectTimerId and sys.timerIsActive(reconnectTimerId) then
-                sys.timerStop(reconnectTimerId)
-            end
-            reconnectTimerId = sys.timerStart(function()
-                cloudc:connect()
-            end, 3000)
-        end
-    end
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local result
-    while true do
-        log.info("等待联网")
-        result = sys.waitUntil("IP_READY", 30000)
-        if result then
-            break
-        end
-    end
-    log.info("联网成功")
-
-    -- 创建TLINK云平台实例,在iotcloud TLINK平台中,device_name对应mqtt三元组的clientId,product_id对应mqtt三元组的username,product_secret对应mqtt三元组的password
-    iotcloudc = iotcloud.new(iotcloud.TLINK, {
-        device_name = serialNumber,
-        produt_id = username,
-        product_secret = password
-    }, connectConfig)
-    -- 创建成功,则连接,创建失败,就结束程序
-    if iotcloudc then
-        iotcloudc:connect()
-    else
-        log.error("iotcloud", "创建失败, 请检查参数")
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 70
module/Air780EHV/DEMO/iotcloud/tuyaiot/示例1 一机一密/main.lua

@@ -1,70 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "iotclouddemo"
-VERSION = "1.0.0"
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-local iotcloud = require("iotcloud")
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    -----------------------------
-    if mobile then
-        device_id = mobile.imei()
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-
-    --------    以下接入方式根据自己需要修改,相关参数修改为自己的    ---------
-
-    -- -- 涂鸦云 
-    iotcloudc = iotcloud.new(iotcloud.TUYA,{device_name = "xxx",device_secret = "xxx"})
-
-    if iotcloudc then
-        iotcloudc:connect()
-    else
-        log.error("iotcloud", "创建失败, 请检查参数")
-    end
-    
-end)
-
-sys.subscribe("iotcloud", function(cloudc,event,data,payload)
-    -- 注意,此处不是协程内,复杂操作发消息给协程内进行处理
-    if event == iotcloud.CONNECT then -- 云平台联上了
-        print("iotcloud","CONNECT", "云平台连接成功")
-        iotcloudc : subscribe("tylink/${deviceId}/thing/property/set") -- 订阅信息
-        iotcloudc : publish("tylink/${deviceId}/thing/property/report" , '{"data":{"device_status":"999"}}' , 1) -- 上报信息
-    elseif event == iotcloud.RECEIVE then
-        print("iotcloud","topic", data, "payload", payload)
-        -- 用户处理代码
-    elseif event ==  iotcloud.OTA then
-        if data then
-            rtos.reboot()
-        end
-    elseif event == iotcloud.DISCONNECT then -- 云平台断开了
-        -- 用户处理代码
-    end
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 81
module/Air780EHV/DEMO/json/main.lua

@@ -1,81 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "jsondemo"
-VERSION = "1.0.0"
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-log.info("main", PROJECT, VERSION)
-
--- json库支持将 table 转为 字符串, 或者反过来, 字符串 转 table
--- 若转换失败, 会返回nil值, 强烈建议在使用时添加额外的判断
-sys.taskInit(function()
-    while 1 do
-        sys.wait(1000)
-        -- table 转为 字符串
-        local t = {abc=123, def="123", ttt=true}
-        local jdata = json.encode(t)
-        log.info("json", jdata)  									--日志输出:{"ttt":true,"def":"123","abc":123}
-
-        -- 字符串转table
-        local str = "{\"abc\":1234545}" -- 字符串可以来源于任何地方,网络,文本,用户输入,都可以
-        local t = json.decode(str)
-        if t then
-			-- 若解码成功,t不为nil
-			log.info("json", "decode", t.abc) 						--日志输出:decode	1234545
-		else
-			-- 若解码失败,t为nil
-			log.info("json", "decode failed")
-		end
-
-        -- lua中的table是 数组和hashmap的混合体
-        -- 这对json来说会有一些困扰, 尤其是空的table
-        local t = {abc={}}
-        -- 假设从业务上需要输出 {"abc":[]}
-        -- 实际会输出 {"abc": {}} , 空table是优先输出 hashmap (即字典模式)形式, 而非数组形式,Lua语言中数组优先级低于hashmap优先级
-        log.info("json", "encode", json.encode(t)) 					--日志输出:encode	{"abc":{}}
-        -- 混合场景, json场景应避免使用
-        t.abc.def = "123"
-        t.abc[1] = 345
-        -- 输出的内容是 {"abc":{"1":345,"def":"123"}}
-        log.info("json", "encode2", json.encode(t))  				--日志输出:encode2	{"abc":{"1":345,"def":"123"}}
-
-        -- 浮点数演示
-        log.info("json", json.encode({abc=1234.300}))  				--日志输出:{"abc":1234.300}
-        -- 限制小数点到1位
-        log.info("json", json.encode({abc=1234.300}, "1f")) 		--日志输出:{"abc":1234.3}
-
- 
-        local tmp = "ABC\r\nDEF\r\n"
-        local tmp2 = json.encode({str=tmp}) --在JSON中,\r\n 被保留为字符串的一部分
-        log.info("json", tmp2)                                    	--日志输出:{"str":"ABC\r\nDEF\r\n"}
-        local tmp3 = json.decode(tmp2)								
-        log.info("json", "tmp3", tmp3.str, tmp3.str == tmp)			--日志输出:tmp3	ABC
-																		--DEF
-																		--		true  注:true前存在一个TAB长度(这个TAB原因未知,但不影响使用)
-        -- break
-
-        log.info("json.null", json.encode({name=json.null}))		--日志输出:{}  为空对象
-        log.info("json.null", json.decode("{\"abc\":null}").abc == json.null)  	--日志输出:false    在 Lua 中,nil 是一种特殊类型,用于表示“无值”或“未定义”。它与任何其他值(包括自定义的 json.null)都不相等
-        log.info("json.null", json.decode("{\"abc\":null}").abc == nil)			 --日志输出:false
-
-    end
-end)
-
-
--- 这里演示4G模块上网后,会自动点亮网络灯,方便用户判断模块是否正常开机
-sys.taskInit(function()
-    while true do
-        sys.wait(6000)
-                if mobile.status() == 1 then
-                        gpio.set(27, 1)  
-                else
-                        gpio.set(27, 0) 
-                        mobile.reset()
-        end
-    end
-end)
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 26
module/Air780EHV/DEMO/lbsLoc2/main.lua

@@ -1,26 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "lbsLoc2demo"
-VERSION = "1.0.0"
-
-local lbsLoc2 = require("lbsLoc2")
-
-sys.taskInit(function()
-    sys.waitUntil("IP_READY", 30000)
-    -- mobile.reqCellInfo(60)
-    -- sys.wait(1000)
-    while mobile do -- 没有mobile库就没有基站定位
-        mobile.reqCellInfo(15)--进行基站扫描
-        sys.waitUntil("CELL_INFO_UPDATE", 3000)--等到扫描成功,超时时间3S
-        local lat, lng, t = lbsLoc2.request(5000)--仅需要基站定位给出的经纬度
-        --local lat, lng, t = lbsLoc2.request(5000,nil,nil,true)--需要经纬度和当前时间
-        --(时间格式{"year":2024,"min":56,"month":11,"day":12,"sec":44,"hour":14})
-        log.info("lbsLoc2", lat, lng, (json.encode(t or {})))
-        sys.wait(60000)
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 103
module/Air780EHV/DEMO/lcd/lcd_test.lua

@@ -1,103 +0,0 @@
---[[
-@module  lcd_test
-@summary lcd_test测试功能模块
-@version 1.0
-@date    2025.07.01
-@author  yc
-@usage
-使用Air780EHV核心板 配合 ST7796 LCD 显示屏幕演示基本的显示功能.
-]]
-
-
--- 根据不同的BSP返回不同的值
--- spi_id,pin_reset,pin_dc,pin_cs,bl
-local function lcd_pin()
-    local rtos_bsp = rtos.bsp()
-    if string.find(rtos_bsp, "780EHV") then
-        return lcd.HWID_0, 36, 0xff, 0xff, 25
-    else
-        log.info("main", "没找到合适的cat.1芯片", rtos_bsp)
-        return
-    end
-end
-
-
-function lcd_test_func()
-
-    local spi_id, pin_reset, pin_dc, pin_cs, bl = lcd_pin()
-    if spi_id ~= lcd.HWID_0 then
-        spi_lcd = spi.deviceSetup(spi_id, pin_cs, 0, 0, 8, 20 * 1000 * 1000, spi.MSB, 1, 0)
-        port = "device"
-    else
-        port = spi_id
-    end
-
-    lcd.init("st7796", {
-    port = port,
-    pin_dc = pin_dc,
-    pin_pwr = bl,
-    pin_rst = pin_reset,
-    direction = 0,
-
-    w = 320,
-    h = 480,
-    xoffset = 0,
-    yoffset = 0,
-    sleepcmd = 0x10,
-    wakecmd = 0x11,
-    })
-
-
-    -- 开启缓冲区, 刷屏速度回加快, 但也消耗2倍屏幕分辨率的内存
-    -- lcd.setupBuff()          -- 使用lua内存
-    lcd.setupBuff(nil, true) -- 使用sys内存, 只需要选一种
-    lcd.autoFlush(false)
-
-    while 1 do
-        lcd.clear()
-        log.info("图片显示")
-        -- API 文档 https://wiki.luatos.com/api/lcd.html
-        if lcd.showImage then
-            -- 注意, jpg需要是常规格式, 不能是渐进式JPG
-            -- 如果无法解码, 可以用画图工具另存为,新文件就能解码了
-            lcd.showImage(0, 0, "/luadb/picture.jpg")
-            sys.wait(100)
-        end
-        lcd.flush()
-        sys.wait(3000)
-        --lcd清屏
-        lcd.clear()
-
-        -- 画线
-        log.info("lcd.drawLine", lcd.drawLine(100, 240, 240, 240, 0x001F))
-        lcd.flush()
-        sys.wait(3000)
-        --lcd清屏
-        lcd.clear()
-
-        -- 画框
-        log.info("lcd.drawRectangle", lcd.drawRectangle(100, 240, 240, 70, 0xF800))
-        lcd.flush()
-        sys.wait(3000)
-        --lcd清屏
-        lcd.clear()
-
-        -- 画圆
-        log.info("lcd.drawCircle", lcd.drawCircle(150, 240, 100, 0x0CE0))
-        lcd.flush()
-        sys.wait(3000)
-        --lcd清屏
-        lcd.clear()
-
-        lcd.setFont(lcd.font_opposansm32)
-        lcd.drawStr(60,240,"hello hezhou") --显示字符
-        lcd.flush()
-        sys.wait(3000)
-        --lcd清屏
-        lcd.clear()
-
-    end
-end
---创建并且启动一个task
---运行这个task的主函数lcd_test_func
-sys.taskInit(lcd_test_func)

+ 0 - 74
module/Air780EHV/DEMO/lcd/main.lua

@@ -1,74 +0,0 @@
---[[
-@module  main
-@summary LuatOS用户应用脚本文件入口,总体调度应用逻辑
-@version 1.0
-@date    2025.07.07
-@author yc
-@usage
-本demo演示的功能为:
-使用Air780EHV核心板 配合 ST7796 LCD 显示屏幕演示基本的显示功能.
-]]
-
---[[
-必须定义PROJECT和VERSION变量,Luatools工具会用到这两个变量,远程升级功能也会用到这两个变量
-PROJECT:项目名,ascii string类型
-        可以随便定义,只要不使用,就行
-VERSION:项目版本号,ascii string类型
-        如果使用合宙iot.openluat.com进行远程升级,必须按照"XXX.YYY.ZZZ"三段格式定义:
-            X、Y、Z各表示1位数字,三个X表示的数字可以相同,也可以不同,同理三个Y和三个Z表示的数字也是可以相同,可以不同
-            因为历史原因,YYY这三位数字必须存在,但是没有任何用处,可以一直写为000
-        如果不使用合宙iot.openluat.com进行远程升级,根据自己项目的需求,自定义格式即可
-]]
-PROJECT = "lcddemo"
-VERSION = "001.000.000"
-
--- 在日志中打印项目名和项目版本号
-log.info("main", PROJECT, VERSION)
-
-
-
--- sys库是标配
-sys = require("sys")
-
-
--- 添加硬狗防止程序卡死
-if wdt then
-    wdt.init(9000) -- 初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000) -- 3s喂一次狗
-end
-
--- 如果内核固件支持errDump功能,此处进行配置,【强烈建议打开此处的注释】
--- 因为此功能模块可以记录并且上传脚本在运行过程中出现的语法错误或者其他自定义的错误信息,可以初步分析一些设备运行异常的问题
--- 以下代码是最基本的用法,更复杂的用法可以详细阅读API说明文档
--- 启动errDump日志存储并且上传功能,600秒上传一次
--- if errDump then
---     errDump.config(true, 600)
--- end
-
-
--- 使用LuatOS开发的任何一个项目,都强烈建议使用远程升级FOTA功能
--- 可以使用合宙的iot.openluat.com平台进行远程升级
--- 也可以使用客户自己搭建的平台进行远程升级
--- 远程升级的详细用法,可以参考fota的demo进行使用
-
-
--- 启动一个循环定时器
--- 每隔3秒钟打印一次总内存,实时的已使用内存,历史最高的已使用内存情况
--- 方便分析内存使用是否有异常
--- sys.timerLoopStart(function()
---     log.info("mem.lua", rtos.meminfo())
---     log.info("mem.sys", rtos.meminfo("sys"))
--- end, 3000)
-
-
---加载lcd测试应用模块
-require "lcd_test"
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!
-
-
-

BIN
module/Air780EHV/DEMO/lcd/picture.jpg


+ 0 - 47
module/Air780EHV/DEMO/lcd/readme.md

@@ -1,47 +0,0 @@
-
-## 演示功能概述
-
-本文演示如何在 Air780EHV 核心板上实现 LCD 屏幕显示图片、字符和画线,框,圆的功能。
-
-## 演示硬件环境
-
-1、Air780EHV核心板一块
-
-2、TYPE-C USB数据线一根
-
-3、Air780EHV核心板和数据线的硬件接线方式为
-
-- Air780EHV核心板通过TYPE-C USB口供电;(核心板USB旁边的开关拨到on一端)
-
-- TYPE-C USB数据线直接插到核心板的TYPE-C USB座子,另外一端连接电脑USB口;
-
-4、ST7796 LCD 屏幕 一块
-
-5、核心板和ST7796 LCD 屏幕连接方式
-
-| ST7796 引脚 | Air780EHV 引脚 | 功能             |
-|-------------|----------------|------------------|
-| GND         | GND            | 地               |
-| VDD         | 3.3V           | 逻辑电源         |
-| SCL         | LCD_CLK        | 时钟信号 (SPI)   |
-| SDA         | LCD_SDA        | 数据输入 (SPI)   |
-| RES         | LCD_RES        | 复位控制         |
-| RS          | LCD_RS         | 数据/命令选择    |
-| CS          | LCD_CS         | 片选信号 (SPI)   |
-
-
-## 演示软件环境
-
-1、Luatools下载调试工具
-
-2、[Air780EHV V2007版本固件](https://docs.openluat.com/air780ehv/luatos/firmware/version/)(测试使用V2007 固件)
-
-## 演示核心步骤
-
-1、搭建好演示硬件环境
-
-2、通过Luatools将demo与固件烧录到核心板中
-
-3、烧录成功后,自动开机运行
-
-4、ST7796 LCD 屏幕显示的内容每间隔3秒切换一次。

+ 0 - 64
module/Air780EHV/DEMO/log/main.lua

@@ -1,64 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "LOG"
-VERSION = "2.0.0"
-
---[[
-本demo演示 string字符串的基本操作
-1. lua的字符串是带长度, 这意味着, 它不依赖0x00作为结束字符串, 可以包含任意数据
-2. lua的字符串是不可变的, 就不能直接修改字符串的一个字符, 修改字符会返回一个新的字符串
-]]
-
--- sys库是标配
-_G.sys = require("sys")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-local netLed = require("netLed")
---GPIO18配置为输出,默认输出低电平,可通过setGpio18Fnc(0或者1)设置输出电平
-local LEDA= gpio.setup(27, 0, gpio.PULLUP)
-
-sys.taskInit(function ()
-    sys.wait(1000) -- 免得看不到日志
-    local tmp
-
-	--实验1:输出四个等级的日志,日志等级排序从低到高为 debug < info < warn < error
-	log.debug(PROJECT, "debug message")
-	log.info(PROJECT, "info message")
-	log.warn(PROJECT, "warn message")
-	log.error(PROJECT, "error message")
-	
-	
-	--实验2:输出INFO及更高级别日志,即debug日志不输出
-	log.setLevel("INFO")
-	print(log.getLevel())
-
-	-- 这条debug级别的日志不会输出
-	log.debug(PROJECT, "debug message")
-	log.info(PROJECT, "info message")
-	log.warn(PROJECT, "warn message")
-	log.error(PROJECT, "error message")
-	
-	--实验3:通过日志输出变量内容
-	local myInteger = 42
-    log.info("Integer", myInteger)
-end)
--- 这里演示4G模块上网后,会自动点亮网络灯,方便用户判断模块是否正常开机
-sys.taskInit(function()
-    while true do
-        sys.wait(6000)
-                if mobile.status() == 1 then
-                        gpio.set(27, 1)  
-                else
-                        gpio.set(27, 0) 
-                        mobile.reset()
-        end
-    end
-end)
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 41
module/Air780EHV/DEMO/miniz/main.lua

@@ -1,41 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "minizdemo"
-VERSION = "1.0.0"
-
-sys = require("sys")
-
---添加硬狗防止程序卡死
-if wdt then
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-sys.taskInit(function()
-    sys.wait(1000)
-    -- 压缩过的字符串, 为了方便演示, 这里用了base64编码
-    -- 大部分MCU设备的内存都比较小, miniz.compress 通常在服务器端完成,这里就不演示了
-    -- miniz能解压标准zlib数据流
-    local b64str = "eAEFQIGNwyAMXOUm+E2+OzjhCCiOjYyhyvbVR7K7IR0l+iau8G82eIW5jXVoPzF5pse/B8FaPXLiWTNxEMsKI+WmIR0l+iayEY2i2V4UbqqPh5bwimyEuY11aD8xeaYHxAquvom6VDFUXqQjG1Fek6efCFfCK0b0LUnQMjiCxhUT05GNL75dFUWCSMcjN3EE5c4Wvq42/36R41fa"
-    local str = b64str:fromBase64()
-
-    local dstr = miniz.uncompress(str)
-    -- 压缩过的数据长度 156
-    -- 解压后的数据长度,即原始数据的长度 235
-    log.info("miniz", "compressed", #str, "uncompressed", #dstr)
-
-    -- 演示压缩解压
-    local ostr = "abcd12345"
-    -- 压缩字符串
-    local zstr = miniz.compress(ostr)
-    log.info("压缩后的字符串:",zstr:toHex())
-    -- 解压字符串
-    local lstr = miniz.uncompress(zstr)
-    log.info("miniz","compress zstr",#zstr,"uncompress lstr data",lstr)
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 122
module/Air780EHV/DEMO/mobile/main.lua

@@ -1,122 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "mobiledemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-
--- 对于双卡的设备, 可以设置为自动选sim卡
--- 但是, 这样SIM1所在管脚就强制复用为SIM功能, 不可以再复用为GPIO
--- mobile.simid(2)
-mobile.simid(2,true)--优先用SIM0
-
-
-sys.taskInit(function()
-
-	log.info("status", mobile.status())
-    local band = zbuff.create(40)
-    local band1 = zbuff.create(40)
-    mobile.getBand(band)
-    log.info("当前使用的band:")
-    for i=0,band:used()-1 do
-        log.info("band", band[i])
-    end
-    band1[0] = 38
-    band1[1] = 39
-    band1[2] = 40
-    mobile.setBand(band1, 3)    --改成使用38,39,40
-    band1:clear()
-    mobile.getBand(band1)
-    log.info("修改后使用的band:")
-    for i=0,band1:used()-1 do
-        log.info("band", band1[i])
-    end
-    mobile.setBand(band, band:used())    --改回原先使用的band,也可以下载的时候选择清除fs
-
-    mobile.getBand(band1)
-    log.info("修改回默认使用的band:")
-    for i=0,band1:used()-1 do
-        log.info("band", band1[i])
-    end
-	-- mobile.vsimInit()
-	-- mobile.flymode(nil,true)
-	-- mobile.vsimOnOff(true)
-	-- mobile.flymode(nil,false)
-    -- mobile.apn(0,2,"") -- 使用默认APN激活CID2
-    -- mobile.rtime(3) -- 在无数据交互时,RRC 3秒后自动释放
-    -- 下面是配置自动搜索小区间隔,和轮询搜索冲突,开启1个就可以了
-    -- mobile.setAuto(10000,30000, 5) -- SIM暂时脱离后自动恢复,30秒搜索一次周围小区信息
-	log.info("status", mobile.status())
-    sys.wait(2000)
-    while 1 do
-        log.info("imei", mobile.imei())
-        log.info("imsi", mobile.imsi())
-        local sn = mobile.sn()
-        if sn then
-            log.info("sn",   sn:toHex())
-        end
-		log.info("status", mobile.status())
-        
-
-        log.info("iccid", mobile.iccid())
-        log.info("csq", mobile.csq()) -- 4G模块的CSQ并不能完全代表强度
-        log.info("rssi", mobile.rssi()) -- 需要综合rssi/rsrq/rsrp/snr一起判断
-        log.info("rsrq", mobile.rsrq())
-        log.info("rsrp", mobile.rsrp())
-        log.info("snr", mobile.snr())
-        log.info("simid", mobile.simid()) -- 这里是获取当前SIM卡槽
-        log.info("apn", mobile.apn(0,1))
-        log.info("ip", socket.localIP())
-		log.info("lua", rtos.meminfo())
-        -- sys内存
-        log.info("sys", rtos.meminfo("sys"))
-        sys.wait(15000)
-    end
-end)
-
--- 基站数据的查询
-
--- 订阅式, 模块本身会周期性查询基站信息,但通常不包含临近小区
-sys.subscribe("CELL_INFO_UPDATE", function()
-    log.info("cell", json.encode(mobile.getCellInfo()))
-end)
-
--- 轮询式, 包含临近小区信息,这是手动搜索,和上面的自动搜索冲突,开启一个就行
-sys.taskInit(function()
-    sys.wait(5000)
-	mobile.config(mobile.CONF_SIM_WC_MODE, 2)
-    while 1 do
-        mobile.reqCellInfo(10)
-        sys.wait(11000)
-        log.info("cell", json.encode(mobile.getCellInfo()))
-		mobile.config(mobile.CONF_SIM_WC_MODE, 2)
-    end
-end)
-
--- 获取sim卡的状态
-
-sys.subscribe("SIM_IND", function(status, value)
-    log.info("sim status", status)
-    if status == 'GET_NUMBER' then
-        log.info("number", mobile.number(0))
-    end
-	if status == "SIM_WC" then
-        log.info("sim", "write counter", value)
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 155
module/Air780EHV/DEMO/modbus/ascii/master_ascii/main.lua

@@ -1,155 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_master_ascii"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-
---初始化通讯串口
-local uartid = 1        -- 根据实际设备选取不同的uartid
-local uart485Pin = 24   -- 用于控制485接收和发送的使能引脚
-gpio.setup(1, 1)        --打开电源(开发板485供电脚是gpio1,用开发板测试需要开机初始化拉高gpio1)
-uart.setup(uartid, 115200, 8, 1, uart.NONE, uart.LSB, 1024, uart485Pin, 0, 2000)
-
-
--- 创建主站设备,ASCII模式
--- 设置通讯间隔时间,主站将按每隔 设置时间 的频率向从站问询数据(默认100ms),当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- 设置通讯超时时间和消息发送超时重发次数,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送,默认1)
--- 设置断线重连时间间隔,当从站与主站断连后,主站将在设置时间内重新连接从站(默认5000ms)
-mb_ascii = modbus.create_master(modbus.MODBUS_ASCII, uartid,3000,2000,1,5000)
-
-
--- 为主站添加从站,从站ID为1,可使用modbus.add_slave(master_handler, slave_id)接口添加多个从站,最多可以添加247个
-mb_slave1 = modbus.add_slave(mb_ascii, 1)
--- -- 为主站添加从站,从站ID为2
--- mb_slave2 = modbus.add_slave(mb_ascii, 2)
-
-
--- 为从站1创建数据存储区,并创建通讯消息,默认为自动loop模式
-slave1_msg1_buf = zbuff.create(1)
-mb_slave1_msg1 = modbus.create_msg(mb_ascii, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf)
-slave1_msg1_buf:clear()
-
--- -- 为从站1创建数据存储区,并创建通讯消息,如需要使用手动模式,须在这里设置为手动模式
--- slave1_msg1_buf = zbuff.create(1)
--- mb_slave1_msg1 = modbus.create_msg(mb_ascii, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf,1,modbus.EXEC)
--- slave1_msg1_buf:clear()
-
--- -- 为从站2创建数据存储区,并创建通讯消息,如设置多个从站,需要给每个从站创建数据储存区
--- slave2_msg1_buf = zbuff.create(1)
--- mb_slave2_msg1 = modbus.create_msg(mb_ascii, mb_slave2, modbus.REGISTERS,  modbus.READ, 0, 10, slave2_msg1_buf)
--- slave2_msg1_buf:clear()
-
-
--- 启动Modubs设备
-modbus.master_start(mb_ascii)
-
-
--- -- 设置通讯间隔时间,设置后主站将按每隔 设置时间 的频率向从站问询数据,当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- modbus.set_comm_interval_time(mb_ascii, 3000)
-
-
--- -- 设置通讯超时时间,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送)
--- modbus.set_comm_timeout(mb_ascii, 2000)
-
-
--- -- 设置消息发送失败、超时重发次数,如果主站在设置超时时间内未接收到数据,将按设置次数问询数据
--- modbus.set_comm_resend_count(mb_ascii,2)
-
-
--- -- 设置消息通讯周期,搭配modbus.create_master/modbus.set_comm_interval_time(mb_rtu, 3000)设置通讯时间使用,若设置通讯周期为2次,将在2倍的通讯时间后向从站问询数据
--- modbus.set_msg_comm_period(mb_slave1_msg1, 2)
-
-
--- 获取所有从站状态,如果所有从站状态为正常,返回true,其他情况返回false,将在每隔5秒的时间获取所有从站状态,并在日志中打印状态(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_all_slave_state(mb_ascii)
-    log.info("modbus", status)
-end, 5000)
-
-
--- 获取从站1的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_slave_state(mb_slave1)
-    log.info("modbus1", status)
-end, 5000)
-
--- -- 获取从站2的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
--- sys.timerLoopStart(function()
---     local status = modbus.get_slave_state(mb_slave2)
---     log.info("modbus2", status)
--- end, 5000)
-
-
--- -- 每隔5秒执行一次mb_slave1_msg1消息,使用modbus.exec(master_handler, msg_handler)接口须先在modbus.set_msg_comm_period(msg_handler, comm_period)接口中设置为手动模式;成功返回true,其他情况返回false
--- sys.timerLoopStart(function()
---     local status=modbus.exec(mb_ascii, mb_slave1_msg1)
---     log.info("msg",status)
--- end,5000)
-
-
--- -- 测试删除一个从站对象,并删除与之相关的通讯消息句柄。需在主站停止时(modbus.master_stop)执行该操作,否则无效。
--- -- 将在3分钟后删除从站1(主站已关闭),删除与之相关的通讯消息句柄,并在5秒后重启主站,可以观察从站是否删除成功。
--- sys.timerStart(function()
---     local status = modbus.remove_slave(mb_ascii, mb_slave1)
---     log.info("modbus", "slave1 remove after 3 minutes")
---     log.info("remove", status)
-    
--- -- 移除从站后,5秒后重新启动Modbus主站
---     sys.timerStart(function()
---         modbus.master_start(mb_ascii)
---         log.info("modbus", "Modbus master restarted after slave removal")
---     end, 5000)
--- end, 180000) 
-
-
--- 获取从站1的状态,每1秒获取一次数据并转换为JSON
-sys.timerLoopStart(function()
-    -- 检查从站状态
-    local status = modbus.get_slave_state(mb_slave1)
-    if status == 0 then  -- 0表示正常
-        -- 读取缓冲区数据
-        slave1_msg1_buf:seek(0)  -- 重置指针到起始位置
-        
-        -- 读取4个寄存器的值(每个寄存器2字节)
-        local reg1 = slave1_msg1_buf:readU16()
-        local reg2 = slave1_msg1_buf:readU16()
-        local reg3 = slave1_msg1_buf:readU16()
-        local reg4 = slave1_msg1_buf:readU16()
-        
-        -- 创建数据表
-        local data = {
-            addr = 1,  -- 从站地址
-            fun = 3,   -- 功能码03
-            reg1 = reg1 / 10,  -- 假设原始数据需要除以10得到实际值
-            reg2 = reg2 / 10,
-            reg3 = reg3 / 10,
-            reg4 = reg4 / 10,
-            timestamp = os.time()  -- 添加时间戳
-        }
-        
-        -- 转换为JSON
-        local json_str = json.encode(data)
-        log.info("Modbus数据转JSON:", json_str)
-
-    else
-        log.warn("从站1状态异常:", status)
-    end
-end, 1000)
-
-
-
--- -- 将在主站开启2分钟后停止modbus主站
--- sys.timerStart(function()
---     modbus.master_stop(mb_ascii)
---     log.info("modbus", "Modbus stopped after 2 minutes")
--- end, 120000) 
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 70
module/Air780EHV/DEMO/modbus/ascii/slave_ascii/main.lua

@@ -1,70 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_slave_ascii"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
---初始化通讯串口
-local uartid = 1        -- 根据实际设备选取不同的uartid
-local uart485Pin = 24   -- 用于控制485接收和发送的使能引脚
-gpio.setup(1, 1)        --打开电源(开发板485供电脚是gpio1,用开发板测试需要开机初始化拉高gpio1)
-uart.setup(uartid, 9600, 8, 1, uart.NONE, uart.LSB, 1024, uart485Pin, 0, 2000)
-
-
--- 创建从站设备,此demo用作测试ASCII。
-local slave_id = 1
-mb_ascii_s = modbus.create_slave(modbus.MODBUS_ASCII, slave_id, uartid)
-
-
--- 添加一块寄存器内存区
-registers = zbuff.create(1)
-modbus.add_block(mb_ascii_s, modbus.REGISTERS, 0, 32, registers)
-registers:clear()
-
--- 创建线圈数据区
-ciols = zbuff.create(1)
-modbus.add_block(mb_ascii_s, modbus.CIOLS, 0, 32, ciols)
-ciols:clear()
-
-
--- 启动modbus从站
-modbus.slave_start(mb_ascii_s)
-
-
-local counter = 0
--- 修改和读取modbus值
-function modify_data()
-    counter = counter + 1  
-    -- 写入寄存器数据 (16位无符号整数)
-    registers:seek(0)
-    for i=0,31 do
-        registers:writeU16((counter + i) % 65536)  -- 写入递增数字,限制在0-65535
-    end  
-    -- 写入线圈数据 (1位布尔值)
-    ciols:seek(0)
-    for i=0,31 do
-        ciols:writeU8((counter + i) % 2)  -- 交替写入0和1
-    end
-  
-    -- 读取并打印部分数据用于调试
-    registers:seek(0)
-    ciols:seek(0)
-    log.info("registers:", registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16())
-    log.info("ciols    :", ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8())
-end
-sys.timerLoopStart(modify_data,1000)
-
--- -- 测试停止modbus从站,将在从站启动两分钟后关闭
--- sys.timerStart(function()
---     modbus.slave_stop(mb_ascii_s)
---     log.info("Modbus", "2分钟时间到,停止Modbus从站")
--- end, 2 * 60 * 1000)  -- 2分钟(单位:毫秒)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 154
module/Air780EHV/DEMO/modbus/rtu/master_rtu/main.lua

@@ -1,154 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_master_rtu"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-
---初始化通讯串口
-local uartid = 1        -- 根据实际设备选取不同的uartid
-local uart485Pin = 24   -- 用于控制485接收和发送的使能引脚
-gpio.setup(1, 1)        --打开电源(开发板485供电脚是gpio1,用开发板测试需要开机初始化拉高gpio1)
-uart.setup(uartid, 115200, 8, 1, uart.NONE, uart.LSB, 1024, uart485Pin, 0, 2000)
-
-
--- 创建主站设备,RTU模式
--- 设置通讯间隔时间,主站将按每隔 设置时间 的频率向从站问询数据(默认100ms),当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- 设置通讯超时时间和消息发送超时重发次数,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送,默认1)
--- 设置断线重连时间间隔,当从站与主站断连后,主站将在设置时间内重新连接从站(默认5000ms)
-mb_rtu = modbus.create_master(modbus.MODBUS_RTU, uartid,3000,2000,1,5000)
-
--- 为主站添加从站,从站ID为1,可使用modbus.add_slave(master_handler, slave_id)接口添加多个从站,最多可以添加247个
-mb_slave1 = modbus.add_slave(mb_rtu, 1)
--- -- 为主站添加从站,从站ID为2
--- mb_slave2 = modbus.add_slave(mb_rtu, 2)
-
-
--- 为从站1创建数据存储区,并创建通讯消息,默认为自动loop模式
-slave1_msg1_buf = zbuff.create(1)
-mb_slave1_msg1 = modbus.create_msg(mb_rtu, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf)
-slave1_msg1_buf:clear()
-
--- -- 为从站1创建数据存储区,并创建通讯消息,如需要使用手动模式,须在这里设置为手动模式
--- slave1_msg1_buf = zbuff.create(1)
--- mb_slave1_msg1 = modbus.create_msg(mb_rtu, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf,1,modbus.EXEC)
--- slave1_msg1_buf:clear()
-
--- -- 为从站2创建数据存储区,并创建通讯消息,如设置多个从站,需要给每个从站创建数据储存区
--- slave2_msg1_buf = zbuff.create(1)
--- mb_slave2_msg1 = modbus.create_msg(mb_rtu, mb_slave2, modbus.REGISTERS,  modbus.READ, 0, 10, slave2_msg1_buf)
--- slave2_msg1_buf:clear()
-
-
--- 启动Modubs设备
-modbus.master_start(mb_rtu)
-
-
--- -- 设置通讯间隔时间,设置后主站将按每隔 设置时间 的频率向从站问询数据,当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- modbus.set_comm_interval_time(mb_rtu, 3000)
-
-
--- -- 设置通讯超时时间,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送)
--- modbus.set_comm_timeout(mb_rtu, 2000)
-
-
--- -- 设置消息发送失败、超时重发次数,如果主站在设置超时时间内未接收到数据,将按设置次数问询数据
--- modbus.set_comm_resend_count(mb_rtu,2)
-
-
--- -- 设置消息通讯周期,搭配modbus.create_master/modbus.set_comm_interval_time(mb_rtu, 3000)设置通讯时间使用,若设置通讯周期为2次,将在2倍的通讯时间后向从站问询数据
--- modbus.set_msg_comm_period(mb_slave1_msg1, 2)
-
-
--- 获取所有从站状态,如果所有从站状态为正常,返回true,其他情况返回false,将在每隔5秒的时间获取所有从站状态,并在日志中打印状态(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_all_slave_state(mb_rtu)
-    log.info("modbus", status)
-end, 5000)
-
-
--- 获取从站1的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_slave_state(mb_slave1)
-    log.info("modbus1", status)
-end, 5000)
-
--- -- 获取从站2的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
--- sys.timerLoopStart(function()
---     local status = modbus.get_slave_state(mb_slave2)
---     log.info("modbus2", status)
--- end, 5000)
-
-
--- -- 每隔5秒执行一次mb_slave1_msg1消息,使用modbus.exec(master_handler, msg_handler)接口须先在modbus.set_msg_comm_period(msg_handler, comm_period)接口中设置为手动模式;成功返回true,其他情况返回false
--- sys.timerLoopStart(function()
---     local status=modbus.exec(mb_rtu, mb_slave1_msg1)
---     log.info("msg",status)
--- end,5000)
-
-
--- -- 测试删除一个从站对象,并删除与之相关的通讯消息句柄。需在主站停止时(modbus.master_stop)执行该操作,否则无效。
--- -- 将在3分钟后删除从站1(主站已关闭),删除与之相关的通讯消息句柄,并在5秒后重启主站,可以观察从站是否删除成功。
--- sys.timerStart(function()
---     local status = modbus.remove_slave(mb_rtu, mb_slave1)
---     log.info("modbus", "slave1 remove after 3 minutes")
---     log.info("remove", status)
-    
--- -- 移除从站后,5秒后重新启动Modbus主站
---     sys.timerStart(function()
---         modbus.master_start(mb_rtu)
---         log.info("modbus", "Modbus master restarted after slave removal")
---     end, 5000)
--- end, 180000) 
-
-
--- 获取从站1的状态,每1秒获取一次数据并转换为JSON
-sys.timerLoopStart(function()
-    -- 检查从站状态
-    local status = modbus.get_slave_state(mb_slave1)
-    if status == 0 then  -- 0表示正常
-        -- 读取缓冲区数据
-        slave1_msg1_buf:seek(0)  -- 重置指针到起始位置
-        
-        -- 读取4个寄存器的值(每个寄存器2字节)
-        local reg1 = slave1_msg1_buf:readU16()
-        local reg2 = slave1_msg1_buf:readU16()
-        local reg3 = slave1_msg1_buf:readU16()
-        local reg4 = slave1_msg1_buf:readU16()
-        
-        -- 创建数据表
-        local data = {
-            addr = 1,  -- 从站地址
-            fun = 3,   -- 功能码03
-            reg1 = reg1 / 10,  -- 假设原始数据需要除以10得到实际值
-            reg2 = reg2 / 10,
-            reg3 = reg3 / 10,
-            reg4 = reg4 / 10,
-            timestamp = os.time()  -- 添加时间戳
-        }
-        
-        -- 转换为JSON
-        local json_str = json.encode(data)
-        log.info("Modbus数据转JSON:", json_str)
-
-    else
-        log.warn("从站1状态异常:", status)
-    end
-end, 1000)
-
-
-
--- -- 将在主站开启2分钟后停止modbus主站
--- sys.timerStart(function()
---     modbus.master_stop(mb_rtu)
---     log.info("modbus", "Modbus stopped after 2 minutes")
--- end, 120000) 
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 70
module/Air780EHV/DEMO/modbus/rtu/slave_rtu/main.lua

@@ -1,70 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_slave_rtu"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
---初始化通讯串口
-local uartid = 1        -- 根据实际设备选取不同的uartid
-local uart485Pin = 24   -- 用于控制485接收和发送的使能引脚
-gpio.setup(1, 1)        --打开电源(开发板485供电脚是gpio1,用开发板测试需要开机初始化拉高gpio1)
-uart.setup(uartid, 115200, 8, 1, uart.NONE, uart.LSB, 1024, uart485Pin, 0, 2000)
-
-
--- 创建从站设备,此demo仅用作测试RTU。
-local slave_id = 1
-mb_rtu_s = modbus.create_slave(modbus.MODBUS_RTU, slave_id, uartid)
-
-
--- 添加一块寄存器内存区
-registers = zbuff.create(1)
-modbus.add_block(mb_rtu_s, modbus.REGISTERS, 0, 32, registers)
-registers:clear()
-
--- 创建线圈数据区
-ciols = zbuff.create(1)
-modbus.add_block(mb_rtu_s, modbus.CIOLS, 0, 32, ciols)
-ciols:clear()
-
-
--- 启动modbus从站
-modbus.slave_start(mb_rtu_s)
-
-
-local counter = 0
--- 修改和读取modbus值
-function modify_data()
-    counter = counter + 1  
-    -- 写入寄存器数据 (16位无符号整数)
-    registers:seek(0)
-    for i=0,31 do
-        registers:writeU16((counter + i) % 65536)  -- 写入递增数字,限制在0-65535
-    end  
-    -- 写入线圈数据 (1位布尔值)
-    ciols:seek(0)
-    for i=0,31 do
-        ciols:writeU8((counter + i) % 2)  -- 交替写入0和1
-    end
-  
-    -- 读取并打印部分数据用于调试
-    registers:seek(0)
-    ciols:seek(0)
-    log.info("registers:", registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16())
-    log.info("ciols    :", ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8())
-end
-sys.timerLoopStart(modify_data,1000)
-
--- -- 测试停止modbus从站,将在从站启动两分钟后关闭
--- sys.timerStart(function()
---     modbus.slave_stop(mb_rtu_s)
---     log.info("Modbus", "2分钟时间到,停止Modbus从站")
--- end, 2 * 60 * 1000)  -- 2分钟(单位:毫秒)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 59
module/Air780EHV/DEMO/modbus/tcp/master_tcp/lan.lua

@@ -1,59 +0,0 @@
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-sysplus = require("sysplus")
-
-dhcps = require "dhcpsrv"
-dnsproxy = require "dnsproxy"
-
-sys.taskInit(function ()
-    -- sys.wait(3000)
-    local result = spi.setup(
-        0,--串口id
-        nil,
-        0,--CPHA
-        0,--CPOL
-        8,--数据宽度
-        25600000--,--频率
-        -- spi.MSB,--高低位顺序    可选,默认高位在前
-        -- spi.master,--主模式     可选,默认主
-        -- spi.full--全双工       可选,默认全双工
-    )
-    log.info("main", "open",result)
-    if result ~= 0 then--返回值为0,表示打开成功
-        log.info("main", "spi open error",result)
-        return
-    end
-
-    netdrv.setup(socket.LWIP_ETH, netdrv.CH390, {spiid=0,cs=8})
-    sys.wait(3000)
-    local ipv4,mark, gw = netdrv.ipv4(socket.LWIP_ETH, "192.168.4.1", "255.255.255.0", "192.168.4.1")
-    log.info("ipv4", ipv4,mark, gw)
-    while netdrv.link(socket.LWIP_ETH) ~= true do
-        sys.wait(100)
-    end
-    dhcps.create({adapter=socket.LWIP_ETH})
-
-
-    -- dnsproxy.setup(socket.LWIP_ETH, socket.LWIP_GP)
-    -- netdrv.napt(socket.LWIP_GP)
-
-
-    dnsproxy.setup(socket.LWIP_ETH, socket.LWIP_ETH)
-    netdrv.napt(socket.LWIP_ETH)
-
-    -- netdrv.dhcp(socket.LWIP_ETH, true)
-end)
-
-
-sys.taskInit(function()
-    -- sys.waitUntil("IP_READY")
-    while 1 do
-        sys.wait(300000)
-        -- log.info("http", http.request("GET", "http://httpbin.air32.cn/bytes/4096", nil, nil, {adapter=socket.LWIP_ETH}).wait())
-        log.info("lua", rtos.meminfo())
-        log.info("sys", rtos.meminfo("sys"))
-        -- log.info("psram", rtos.meminfo("psram"))
-    end
-end)
-
-

+ 0 - 161
module/Air780EHV/DEMO/modbus/tcp/master_tcp/main.lua

@@ -1,161 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_master_tcp"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-
---初始化网络
-log.info("ch390", "打开LDO供电")
-gpio.setup(20, 1)  --打开lan供电
-
-mcu.hardfault(0) -- 死机后停机,一般用于调试状态
-require "lan"
-
-
--- 创建主站设备,TCP模式
--- 设置连接方式为socket.LWIP_ETH
--- 设置通讯间隔时间,主站将按每隔 设置时间 的频率向从站问询数据(默认100ms),当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- 设置通讯超时时间和消息发送超时重发次数,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送,默认1)
--- 设置断线重连时间间隔,当从站与主站断连后,主站将在设置时间内重新连接从站(默认5000ms)
-mb_tcp = modbus.create_master(modbus.MODBUS_TCP, socket.LWIP_ETH,3000,1,5000)
-
-
--- 为主站添加从站,从站ID为1,ip地址为 192.168.0.104,端口号为 6000,最多可添加247个从站
-mb_slave1 = modbus.add_slave(mb_tcp, 1, "192.168.4.100", 6000)
--- 为主站添加从站,从站ID为2,ip地址为 192.168.0.104,端口号为 6001
--- mb_slave2 = modbus.add_slave(mb_tcp, 2, "192.168.4.100", 6001)
-
-
--- 为从站1创建数据存储区,并创建通讯消息,默认为自动loop模式
-slave1_msg1_buf = zbuff.create(1)
-mb_slave1_msg1 = modbus.create_msg(mb_tcp, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf)
-slave1_msg1_buf:clear()
-
--- -- 为从站1创建数据存储区,并创建通讯消息,如需要使用手动模式,须在这里设置为手动模式
--- slave1_msg1_buf = zbuff.create(1)
--- mb_slave1_msg1 = modbus.create_msg(mb_tcp, mb_slave1, modbus.REGISTERS, modbus.READ, 0, 10, slave1_msg1_buf,1,modbus.EXEC)
--- slave1_msg1_buf:clear()
-
--- 为从站2创建数据存储区,并创建通讯消息
--- slave2_msg1_buf = zbuff.create(1)
--- mb_slave2_msg1 = modbus.create_msg(mb_tcp, mb_slave2, modbus.REGISTERS, modbus.WRITE, 0, 10, slave2_msg1_buf)
--- slave2_msg1_buf:clear()
-
-
--- 启动Modubs设备
-modbus.master_start(mb_tcp)
-log.info("start modbus master")
-
--- -- 设置通讯间隔时间,设置后主站将按每隔 设置时间 的频率向从站问询数据,当添加了多个从站后,主站向每个从站问询的时间间隔将叠加
--- modbus.set_comm_interval_time(mb_tcp,3000)
-
-
--- -- 设置通讯超时时间,当主站未在 设置的时间 内接收到从站数据,将向从站再次发送问询(问询次数按设置的 消息超时重发次数 发送)
--- modbus.set_comm_timeout(mb_tcp, 3000)
-
-
--- -- 设置消息发送失败、超时重发次数,如果主站在设置超时时间内未接收到数据,将按设置次数问询数据
--- modbus.set_comm_resend_count(mb_tcp,1)
-
-
--- 设置断线重连时间间隔,若从站与主站断连,主站将在设置时间内重新连接从站
--- modbus.set_comm_reconnection_time(mb_tcp, 5000)
-
-
--- -- 设置消息通讯周期,搭配modbus.create_master/modbus.set_comm_interval_time(mb_tcp,3000)设置通讯时间使用,若设置通讯周期为2次,将在2倍的通讯时间后向从站问询数据
--- modbus.set_msg_comm_period(mb_slave1_msg1, 2)
-
-
--- 获取所有从站状态,如果所有从站状态为正常,返回true,其他情况返回false,将在每隔5秒的时间获取所有从站状态,并在日志中打印状态(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_all_slave_state(mb_tcp)
-    log.info("modbus", status)
-end, 5000)
-
-
--- 获取从站1的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
-sys.timerLoopStart(function()
-    local status = modbus.get_slave_state(mb_slave1)
-    log.info("modbus1", status)
-end, 5000)
-
--- -- 获取从站2的状态,每隔5秒获取从站状态并在日志打印出来(仅方便调试使用,量产时可删除)
--- sys.timerLoopStart(function()
---     local status = modbus.get_slave_state(mb_slave2)
---     log.info("modbus2", status)
--- end, 5000)
-
-
--- -- 每隔5秒执行一次 mb_slave1_msg1 消息,使用modbus.exec(master_handler, msg_handler)接口须先在modbus.set_msg_comm_period(msg_handler, comm_period)接口中设置为手动模式;成功返回true,其他情况返回false
--- sys.timerLoopStart(function()
---     local status=modbus.exec(mb_tcp, mb_slave1_msg1)
---     log.info("msg",status)
--- end,5000)
-
-
--- -- 测试删除一个从站对象,并删除与之相关的通讯消息句柄。需在主站停止时(modbus.master_stop)执行该操作,否则无效。
--- -- 将在3分钟后删除从站2(主站已关闭),删除与之相关的通讯消息句柄,并在5秒后重启主站,可以观察从站是否删除成功。
--- sys.timerStart(function()
---     local status = modbus.remove_slave(mb_tcp, mb_slave2)
---     log.info("modbus", "slave2 remove after 3 minutes")
---     log.info("remove", status)
-    
---     -- 移除从站后,5秒后重新启动Modbus主站
---     sys.timerStart(function()
---         modbus.master_start(mb_tcp)
---         log.info("modbus", "Modbus master restarted after slave removal")
---     end, 5000)
--- end, 180000) 
-
-
--- 获取从站1的状态,每1秒获取一次数据并转换为JSON
-sys.timerLoopStart(function()
-    -- 检查从站状态
-    local status = modbus.get_slave_state(mb_slave1)
-    if status == 0 then  -- 0表示正常
-        -- 读取缓冲区数据
-        slave1_msg1_buf:seek(0)  -- 重置指针到起始位置
-        
-        -- 读取4个寄存器的值(每个寄存器2字节)
-        local reg1 = slave1_msg1_buf:readU16()
-        local reg2 = slave1_msg1_buf:readU16()
-        local reg3 = slave1_msg1_buf:readU16()
-        local reg4 = slave1_msg1_buf:readU16()
-        
-        -- 创建数据表
-        local data = {
-            addr = 1,  -- 从站地址
-            fun = 3,   -- 功能码03
-            reg1 = reg1 / 10,  -- 假设原始数据需要除以10得到实际值
-            reg2 = reg2 / 10,
-            reg3 = reg3 / 10,
-            reg4 = reg4 / 10,
-            timestamp = os.time()  -- 添加时间戳
-        }
-        
-        -- 转换为JSON
-        local json_str = json.encode(data)
-        log.info("Modbus数据转JSON:", json_str)
-
-    else
-        log.warn("从站1状态异常:", status)
-    end
-end, 1000)
-
-
-
--- -- 将在主站开启2分钟后停止modbus主站
--- sys.timerStart(function()
---     modbus.master_stop(mb_tcp)
---     log.info("modbus", "Modbus stopped after 2 minutes")
--- end, 120000) 
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 60
module/Air780EHV/DEMO/modbus/tcp/slave_tcp/lan.lua

@@ -1,60 +0,0 @@
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-sysplus = require("sysplus")
-
-dhcps = require "dhcpsrv"
-dnsproxy = require "dnsproxy"
-
-sys.taskInit(function ()
-    -- sys.wait(3000)
-    local result = spi.setup(
-        0,--串口id
-        nil,
-        0,--CPHA
-        0,--CPOL
-        8,--数据宽度
-        25600000--,--频率
-        -- spi.MSB,--高低位顺序    可选,默认高位在前
-        -- spi.master,--主模式     可选,默认主
-        -- spi.full--全双工       可选,默认全双工
-    )
-    log.info("main", "open",result)
-    if result ~= 0 then--返回值为0,表示打开成功
-        log.info("main", "spi open error",result)
-        return
-    end
-
-    netdrv.setup(socket.LWIP_ETH, netdrv.CH390, {spiid=0,cs=8})
-    sys.wait(3000)
-    local ipv4,mark, gw = netdrv.ipv4(socket.LWIP_ETH, "192.168.4.1", "255.255.255.0", "192.168.4.1")
-    log.info("ipv4", ipv4,mark, gw)
-    while netdrv.link(socket.LWIP_ETH) ~= true do
-        sys.wait(100)
-    end
-    dhcps.create({adapter=socket.LWIP_ETH})
-
-
-    -- dnsproxy.setup(socket.LWIP_ETH, socket.LWIP_GP)
-    -- netdrv.napt(socket.LWIP_GP)
-
-
-    dnsproxy.setup(socket.LWIP_ETH, socket.LWIP_ETH)
-    netdrv.napt(socket.LWIP_ETH)
-
-    -- netdrv.dhcp(socket.LWIP_ETH, true)
-end)
-
-
-sys.taskInit(function()
-    sys.waitUntil("IP_READY")
-    while 1 do
-        sys.wait(300000)
-        -- log.info("http", http.request("GET", "http://httpbin.air32.cn/bytes/4096", nil, nil, {adapter=socket.LWIP_ETH}).wait())
-        log.info("lua", rtos.meminfo())
-        log.info("sys", rtos.meminfo("sys"))
-        -- log.info("psram", rtos.meminfo("psram"))
-    end
-end)
-
-

+ 0 - 69
module/Air780EHV/DEMO/modbus/tcp/slave_tcp/main.lua

@@ -1,69 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "modbus_slave_tcp"
-VERSION = "1.0.0"
-log.style(1)
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-
-log.info("ch390", "打开LDO供电")
-gpio.setup(20, 1)  --打开lan供电
-require "lan"
-
--- 创建从站设备,可选择RTU、ASCII、TCP,此demo仅用作测试TCP。设置该从站端口号为6000,网卡适配器序列号为socket.LWIP_ETH。
-local slave_id = 1
-mb_tcp_s = modbus.create_slave(modbus.MODBUS_TCP, slave_id, 6000, socket.LWIP_ETH)
-
-
--- 创建寄存器数据区
-registers = zbuff.create(1)
-modbus.add_block(mb_tcp_s, modbus.REGISTERS, 0, 32, registers)
-registers:clear()
--- 创建线圈数据区
-ciols = zbuff.create(1)
-modbus.add_block(mb_tcp_s, modbus.CIOLS, 0, 32, ciols)
-ciols:clear()
-
-
--- 启动modbus从站
-modbus.slave_start(mb_tcp_s)
-log.info("start modbus slave")
-
-
-local counter = 0
--- 修改和读取modbus值
-function modify_data()
-    counter = counter + 1
-    -- 写入寄存器数据 (16位无符号整数)
-    registers:seek(0)
-    for i=0,31 do
-        registers:writeU16((counter + i) % 65536)  -- 写入递增数字,限制在0-65535
-    end
-    -- 写入线圈数据 (1位布尔值)
-    ciols:seek(0)
-    for i=0,31 do
-        ciols:writeU8((counter + i) % 2)  -- 交替写入0和1
-    end
-    
-    -- 读取并打印部分数据用于调试
-    registers:seek(0)
-    ciols:seek(0)
-    log.info("registers:", registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16(), registers:readU16())
-    log.info("ciols    :", ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8(), ciols:readU8())
-end
-sys.timerLoopStart(modify_data,1000)
-
-
--- -- 测试停止modbus从站,从站将在开启两分钟后关闭
--- sys.timerStart(function()
---     modbus.slave_stop(mb_rtu_s)
---     log.info("Modbus", "2分钟时间到,停止Modbus从站")
--- end, 120000)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

BIN
module/Air780EHV/DEMO/modbus/test_core/LuatOS-SoC_V2007_Air780EPM_TEMP_20250610_150400.soc


+ 0 - 30
module/Air780EHV/DEMO/mqtt/main.lua

@@ -1,30 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "mqttdemo"
-VERSION = "1.0.0"
-
---[[
-本demo需要mqtt库, 大部分能联网的设备都具有这个库
-mqtt也是内置库, 无需require
-]]
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-require "single_mqtt"       -- MQTT单链接
-
--- require "multilink_mqtt"    -- MQTT多链接
-
--- require "ssl_mqtt"             -- MQTTS SSL链接
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 226
module/Air780EHV/DEMO/mqtt/multilink_mqtt.lua

@@ -1,226 +0,0 @@
--- 自动低功耗, 轻休眠模式
--- Air780E、Air780EP支持uart唤醒和网络数据下发唤醒, 但需要断开USB,或者pm.power(pm.USB, false) 但这样也看不到日志了
--- pm.request(pm.LIGHT)
-
---根据自己的服务器修改以下参数
-local mqtt_host = "lbsmqtt.airm2m.com"
-local mqtt_port = 1884
-local mqtt_isssl = false
-local client1_id = "abc"
-local client2_id = "abc2"
-local user_name = "user"
-local password = "password"
-local device_id = mobile.imei()
-
-local mqttc1 = nil
-local pub_topic_client = "/luatos/pub/client1/"
-local sub_topic_client = "/luatos/sub/client1/"
--- local pub_topic2_client = "/luatos/2"
--- local pub_topic3_client = "/luatos/3"
-
-
-local mqttc2 = nil
-local pub_topic_client2 = "/luatos/pub/client2/"
-local sub_topic_client2 = "/luatos/sub/client2/"
--- local pub_topic2_client2 = "/luatos/2"
--- local pub_topic3_client2 = "/luatos/3"
--- 统一联网函数
-sys.taskInit(function()
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready")
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    
-    local ret= sys.waitUntil("net_ready")
-    -- 下面的是mqtt的参数均可自行修改
-    pub_topic_client = pub_topic_client .. device_id
-    sub_topic_client = sub_topic_client .. device_id
-
-    -- 打印一下上报(pub)和下发(sub)的topic名称
-    -- 上报: 设备 ---> 服务器
-    -- 下发: 设备 <--- 服务器
-    -- 可使用mqtt.x等客户端进行调试
-    log.info("mqtt", "pub", pub_topic_client)
-    log.info("mqtt", "sub", sub_topic_client)
-
-    -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件
-    -- if crypto.cipher_suites then
-    --     log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    -- end
-    if mqtt == nil then
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp未适配mqtt库, 请查证")
-        end
-    end
-
-    -------------------------------------
-    -------- MQTT 演示代码 --------------
-    -------------------------------------
-
-    mqttc1 = mqtt.create(nil, mqtt_host, mqtt_port, mqtt_isssl)
-
-    mqttc1:auth(client1_id,user_name,password) -- client_id必填,其余选填
-    -- mqttc1:keepalive(240) -- 默认值240s
-    mqttc1:autoreconn(true, 3000) -- 自动重连机制
-
-    mqttc1:on(function(mqtt_client, event, data, payload)
-        -- 用户自定义代码
-        log.info("mqtt", "event", event, mqtt_client, data, payload)
-        if event == "conack" then
-            -- 联上了
-            sys.publish("mqtt_conack")
-            mqtt_client:subscribe(sub_topic_client)--单主题订阅
-            -- mqtt_client:subscribe({[topic1]=1,[topic2]=1,[topic3]=1})--多主题订阅
-        elseif event == "recv" then
-            log.info("mqtt", "downlink", "topic", data, "payload", payload)
-            sys.publish("mqtt_payload", data, payload)
-        elseif event == "sent" then
-            -- log.info("mqtt", "sent", "pkgid", data)
-        -- elseif event == "disconnect" then
-            -- 非自动重连时,按需重启mqttc
-            -- mqtt_client:connect()
-        end
-    end)
-
-    -- mqttc自动处理重连, 除非自行关闭
-    mqttc1:connect()
-	sys.waitUntil("mqtt_conack")
-    while true do
-        -- 演示等待其他task发送过来的上报信息
-        local ret, topic, data, qos = sys.waitUntil("mqtt_pub", 300000)
-        if ret then
-            -- 提供关闭本while循环的途径, 不需要可以注释掉
-            if topic == "close" then break end
-            mqttc1:publish(topic, data, qos)
-        end
-        -- 如果没有其他task上报, 可以写个空等待
-        --sys.wait(60000000)
-    end
-    mqttc1:close()
-    mqttc1 = nil
-end)
-
--- 这里演示在另一个task里上报数据, 会定时上报数据,不需要就注释掉
-sys.taskInit(function()
-    sys.wait(3000)
-	local data = "123,"
-	local qos = 1 -- QOS0不带puback, QOS1是带puback的
-    while true do
-        sys.wait(3000)
-        if mqttc1 and mqttc1:ready() then
-            local pkgid = mqttc1:publish(pub_topic_client, data .. os.date(), qos)
-            -- local pkgid = mqttc1:publish(topic2, data, qos)
-            -- local pkgid = mqttc1:publish(topic3, data, qos)
-        end
-    end
-end)
-
-
--- mqtt多链接示例
-sys.taskInit(function()
-    -- 等待联网
-    local ret= sys.waitUntil("net_ready")
-    -- 下面的是mqtt的参数均可自行修改
-    client2_id = device_id.."2"
-    pub_topic_client2 = pub_topic_client2 .. device_id
-    sub_topic_client2 = sub_topic_client2 .. device_id
-
-    -- 打印一下上报(pub)和下发(sub)的topic名称
-    -- 上报: 设备 ---> 服务器
-    -- 下发: 设备 <--- 服务器
-    -- 可使用mqtt.x等客户端进行调试
-    log.info("mqtt", "pub", pub_topic_client2)
-    log.info("mqtt", "sub", sub_topic_client2)
-
-    -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件
-    -- if crypto.cipher_suites then
-    --     log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    -- end
-    if mqtt == nil then
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp未适配mqtt库, 请查证")
-        end
-    end
-
-    -------------------------------------
-    -------- MQTT 演示代码 --------------
-    -------------------------------------
-
-    mqttc2 = mqtt.create(nil, mqtt_host, mqtt_port, mqtt_isssl)
-
-    mqttc2:auth(client2_id,user_name,password) -- client_id必填,其余选填
-    -- mqttc2:keepalive(240) -- 默认值240s
-    mqttc2:autoreconn(true, 3000) -- 自动重连机制
-
-    mqttc2:on(function(mqtt_client, event, data, payload)
-        -- 用户自定义代码
-        log.info("mqtt", "event", event, mqtt_client, data, payload)
-        if event == "conack" then
-            -- 联上了
-            sys.publish("mqtt_conack")
-            mqtt_client:subscribe(sub_topic_client2)--单主题订阅
-            -- mqtt_client:subscribe({[topic1]=1,[topic2]=1,[topic3]=1})--多主题订阅
-        elseif event == "recv" then
-            log.info("mqtt", "downlink", "topic", data, "payload", payload)
-            sys.publish("mqtt_payload", data, payload)
-        elseif event == "sent" then
-            log.info("mqtt", "sent", "pkgid", data)
-        elseif event == "disconnect" then
-            -- 非自动重连时,按需重启mqttc
-            mqtt_client:connect()
-        end
-    end)
-
-    -- mqttc自动处理重连, 除非自行关闭
-    mqttc2:connect()
-	sys.waitUntil("mqtt_conack")
-    while true do
-        -- 演示等待其他task发送过来的上报信息
-        local ret, topic, data, qos = sys.waitUntil("mqtt_pub", 300000)
-        if ret then
-            -- 提供关闭本while循环的途径, 不需要可以注释掉
-            if topic == "close" then break end
-            mqttc2:publish(topic, data, qos)
-        end
-        -- 如果没有其他task上报, 可以写个空等待
-        --sys.wait(60000000)
-    end
-    mqttc2:close()
-    mqttc2 = nil
-end)
-
-
--- 这里演示在另一个task里上报数据, 会定时上报数据,不需要就注释掉
-sys.taskInit(function()
-    sys.wait(3000)
-	local data = "123,"
-	local qos = 1 -- QOS0不带puback, QOS1是带puback的
-    while true do
-        sys.wait(3000)
-        if mqttc2 and mqttc2:ready() then
-            local pkgid = mqttc2:publish(pub_topic_client2, data .. os.date(), qos)
-            -- local pkgid = mqttc2:publish(topic2, data, qos)
-            -- local pkgid = mqttc2:publish(topic3, data, qos)
-        end
-    end
-end)
-
-
-sys.taskInit(function ()
-    while true do
-        sys.wait(3000)
-        log.info("lua", rtos.meminfo())
-        log.info("sys", rtos.meminfo("sys"))
-    end
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 177
module/Air780EHV/DEMO/mqtt/single_mqtt.lua

@@ -1,177 +0,0 @@
--- 自动低功耗, 轻休眠模式
--- Air780E支持uart唤醒和网络数据下发唤醒, 但需要断开USB,或者pm.power(pm.USB, false) 但这样也看不到日志了
--- pm.request(pm.LIGHT)
-
---根据自己的服务器修改以下参数
-local mqtt_host = "lbsmqtt.airm2m.com"
-local mqtt_port = 1884
-local mqtt_isssl = false
-local client_id = "abc"
-local user_name = "user"
-local password = "password"
-
-local pub_topic = "/luatos/pub/" .. (mcu.unique_id():toHex())
-local sub_topic = "/luatos/sub/" .. (mcu.unique_id():toHex())
--- local topic2 = "/luatos/2"
--- local topic3 = "/luatos/3"
-
-local mqttc = nil
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    -----------------------------
-    -- 统一联网函数, 可自行删减
-    ----------------------------
-    if wlan and wlan.connect then
-        -- wifi 联网, ESP32系列均支持
-        local ssid = "luatos1234"
-        local password = "12341234"
-        log.info("wifi", ssid, password)
-        -- TODO 改成自动配网
-        -- LED = gpio.setup(12, 0, gpio.PULLUP)
-        wlan.init()
-        wlan.setMode(wlan.STATION) -- 默认也是这个模式,不调用也可以
-        device_id = wlan.getMac()
-        wlan.connect(ssid, password, 1)
-    elseif mobile then
-        -- Air780E/Air600E系列
-        --mobile.simid(2) -- 自动切换SIM卡
-        -- LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-    elseif w5500 then
-        -- w5500 以太网, 当前仅Air105支持
-        w5500.init(spi.HSPI_0, 24000000, pin.PC14, pin.PC01, pin.PC00)
-        w5500.config() --默认是DHCP模式
-        w5500.bind(socket.ETH0)
-        -- LED = gpio.setup(62, 0, gpio.PULLUP)
-    elseif socket or mqtt then
-        -- 适配的socket库也OK
-        -- 没有其他操作, 单纯给个注释说明
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-    -- 下面的是mqtt的参数均可自行修改
-    client_id = device_id
-    pub_topic = "/luatos/pub/" .. device_id
-    sub_topic = "/luatos/sub/" .. device_id
-
-    -- 打印一下上报(pub)和下发(sub)的topic名称
-    -- 上报: 设备 ---> 服务器
-    -- 下发: 设备 <--- 服务器
-    -- 可使用mqtt.x等客户端进行调试
-    log.info("mqtt", "pub", pub_topic)
-    log.info("mqtt", "sub", sub_topic)
-
-    -- 打印一下支持的加密套件, 通常来说, 固件已包含常见的99%的加密套件
-    -- if crypto.cipher_suites then
-    --     log.info("cipher", "suites", json.encode(crypto.cipher_suites()))
-    -- end
-    if mqtt == nil then
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp未适配mqtt库, 请查证")
-        end
-    end
-
-    -------------------------------------
-    -------- MQTT 演示代码 --------------
-    -------------------------------------
-
-    mqttc = mqtt.create(nil, mqtt_host, mqtt_port, mqtt_isssl)
-
-    mqttc:auth(client_id,user_name,password) -- client_id必填,其余选填
-    -- mqttc:keepalive(240) -- 默认值240s
-    mqttc:autoreconn(true, 3000) -- 自动重连机制
-
-    mqttc:on(function(mqtt_client, event, data, payload)
-        -- 用户自定义代码
-        log.info("mqtt", "event", event, mqtt_client, data, payload)
-        if event == "conack" then
-            -- 联上了
-            sys.publish("mqtt_conack")
-            mqtt_client:subscribe(sub_topic)--单主题订阅
-            -- mqtt_client:subscribe({[topic1]=1,[topic2]=1,[topic3]=1})--多主题订阅
-        elseif event == "recv" then
-            log.info("mqtt", "downlink", "topic", data, "payload", payload)
-            sys.publish("mqtt_payload", data, payload)
-        elseif event == "sent" then
-            -- log.info("mqtt", "sent", "pkgid", data)
-        -- elseif event == "disconnect" then
-            -- 非自动重连时,按需重启mqttc
-            -- mqtt_client:connect()
-        end
-    end)
-
-    -- mqttc自动处理重连, 除非自行关闭
-    mqttc:connect()
-	sys.waitUntil("mqtt_conack")
-    while true do
-        -- 演示等待其他task发送过来的上报信息
-        local ret, topic, data, qos = sys.waitUntil("mqtt_pub", 300000)
-        if ret then
-            -- 提供关闭本while循环的途径, 不需要可以注释掉
-            if topic == "close" then break end
-            mqttc:publish(topic, data, qos)
-        end
-        -- 如果没有其他task上报, 可以写个空等待
-        --sys.wait(60000000)
-    end
-    mqttc:close()
-    mqttc = nil
-end)
-
--- 这里演示在另一个task里上报数据, 会定时上报数据,不需要就注释掉
-sys.taskInit(function()
-    sys.wait(3000)
-	local data = "123,"
-	local qos = 1 -- QOS0不带puback, QOS1是带puback的
-    while true do
-        sys.wait(3000)
-        if mqttc and mqttc:ready() then
-            local pkgid = mqttc:publish(pub_topic, data .. os.date(), qos)
-            -- local pkgid = mqttc:publish(topic2, data, qos)
-            -- local pkgid = mqttc:publish(topic3, data, qos)
-        end
-    end
-end)
-
--- 以下是演示与uart结合, 简单的mqtt-uart透传实现,不需要就注释掉
-local uart_id = 1
-uart.setup(uart_id, 9600)
-uart.on(uart_id, "receive", function(id, len)
-    local data = ""
-    while 1 do
-        local tmp = uart.read(uart_id)
-        if not tmp or #tmp == 0 then
-            break
-        end
-        data = data .. tmp
-    end
-    log.info("uart", "uart收到数据长度", #data)
-    sys.publish("mqtt_pub", pub_topic, data)
-end)
-sys.subscribe("mqtt_payload", function(topic, payload)
-    log.info("uart", "uart发送数据长度", #payload)
-    uart.write(1, payload)
-end)
-
-sys.taskInit(function ()
-    while true do
-        sys.wait(3000)
-        log.info("lua", rtos.meminfo())
-        log.info("sys", rtos.meminfo("sys"))
-    end
-end)

+ 0 - 123
module/Air780EHV/DEMO/ntp/main.lua

@@ -1,123 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "sntpdemo"
-VERSION = "1.0.0"
-
---[[
-本demo需要mqtt库, 大部分能联网的设备都具有这个库
-mqtt也是内置库, 无需require
-]]
-
--- sys库是标配
-_G.sys = require("sys")
---[[特别注意, 使用mqtt库需要下列语句]]
-_G.sysplus = require("sysplus")
-
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
--- 统一联网函数
-sys.taskInit(function()
-    local device_id = mcu.unique_id():toHex()
-    -----------------------------
-    -- 统一联网函数, 可自行删减
-    ----------------------------
-    if wlan and wlan.connect then
-        -- wifi 联网, ESP32系列均支持
-        local ssid = "luatos1234"
-        local password = "12341234"
-        log.info("wifi", ssid, password)
-        -- TODO 改成自动配网
-        -- LED = gpio.setup(12, 0, gpio.PULLUP)
-        wlan.init()
-        wlan.setMode(wlan.STATION) -- 默认也是这个模式,不调用也可以
-        device_id = wlan.getMac()
-        wlan.connect(ssid, password, 1)
-    elseif mobile then
-        -- Air780E/Air600E系列
-        --mobile.simid(2) -- 自动切换SIM卡
-        -- LED = gpio.setup(27, 0, gpio.PULLUP)
-        device_id = mobile.imei()
-    elseif w5500 then
-        -- w5500 以太网, 当前仅Air105支持
-        w5500.init(spi.HSPI_0, 24000000, pin.PC14, pin.PC01, pin.PC00)
-        w5500.config() --默认是DHCP模式
-        w5500.bind(socket.ETH0)
-        -- LED = gpio.setup(62, 0, gpio.PULLUP)
-    elseif socket then
-        -- 适配的socket库也OK
-        -- 没有其他操作, 单纯给个注释说明
-    else
-        -- 其他不认识的bsp, 循环提示一下吧
-        while 1 do
-            sys.wait(1000)
-            log.info("bsp", "本bsp可能未适配网络层, 请查证")
-        end
-    end
-    -- 默认都等到联网成功
-    sys.waitUntil("IP_READY")
-    sys.publish("net_ready", device_id)
-end)
-
-sys.taskInit(function()
-    -- 等待联网
-    local ret, device_id = sys.waitUntil("net_ready")
-    sys.wait(1000)
-    -- 对于Cat.1模块, 移动/电信卡, 通常会下发基站时间,  那么sntp就不是必要的, 而联通卡通常不会下发, 就需要sntp了
-    -- 对应ESP32系列模块, 固件默认也会执行sntp, 所以手动调用sntp也是可选的
-    -- sntp内置了几个常用的ntp服务器, 也支持自选服务器
-    while 1 do
-        -- 使用内置的ntp服务器地址, 包括阿里ntp
-        log.info("开始执行SNTP")
-        socket.sntp()
-        -- 自定义ntp地址
-        -- socket.sntp("ntp.aliyun.com")
-        -- socket.sntp({"baidu.com", "abc.com", "ntp.air32.cn"})
-        -- 通常只需要几百毫秒就能成功
-        local ret = sys.waitUntil("NTP_UPDATE", 5000)
-        if ret then
-            -- 以下是获取/打印时间的演示,注意时区问题
-            log.info("sntp", "时间同步成功", "本地时间", os.date())
-            log.info("sntp", "时间同步成功", "UTC时间", os.date("!%c"))
-            log.info("sntp", "时间同步成功", "RTC时钟(UTC时间)", json.encode(rtc.get()))
-            -- os.time(rtc.get()) 需要 2023.07.21 之后的版本, 因为月份的命名差异mon/month
-            -- log.info("sntp", "时间同步成功", "utc时间戳", os.time(rtc.get()))
-            log.info("sntp", "时间同步成功", "本地时间戳", os.time())
-            local t = os.date("*t")
-            log.info("sntp", "时间同步成功", "本地时间os.date() json格式", json.encode(t))
-            log.info("sntp", "时间同步成功", "本地时间os.date(os.time())", os.time(t))
-            -- log.info("sntp", "时间同步成功", "本地时间", os.time())
-            -- 正常使用, 一小时一次, 已经足够了, 甚至1天一次也可以
-            -- sys.wait(3600000) 
-            -- 这里为了演示, 用5秒一次
-            sys.wait(5000)
-        else
-            log.info("sntp", "时间同步失败")
-            sys.wait(60000) -- 1分钟后重试
-        end
-
-        -- 时间戳, 精确到毫秒. 2023.11.15 新增
-        -- 注意, 至少成功完成2次sntp,该时间戳才比较准确
-        -- 如果仅完成了一次sntp, 时间戳比标准时间会慢一个网络延时的时长(10~500ms)不等
-        if socket.ntptm then
-            local tm = socket.ntptm()
-            log.info("tm数据", json.encode(tm))
-            log.info("时间戳", string.format("%u.%03d", tm.tsec, tm.tms))
-            sys.wait(5000)
-        end
-    end
-end)
-
-sys.subscribe("NTP_ERROR", function()
-    log.info("socket", "sntp error")
-    -- socket.sntp()
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 124
module/Air780EHV/DEMO/os/main.lua

@@ -1,124 +0,0 @@
-
-PROJECT = "os_test"
-VERSION = "1.0.0"
-local function test_os_remove()
-    log.info("os.remove", "测试开始")
-    -- 先创建一个测试文件
-    local testFile = "/test_remove.txt"
-    local f = io.open(testFile, "w")
-    if f then
-        f:write("test content")
-        f:close()
-        log.info("os.remove", "测试文件创建成功")
-    else
-        log.error("os.remove", "无法创建测试文件")
-        return
-    end
-
-    -- 测试删除文件
-    local result, err = os.remove(testFile)
-    if result then
-        log.info("os.remove", "文件删除成功")
-    else
-        log.error("os.remove", "文件删除失败", err)
-    end
-
-    -- 测试删除不存在的文件
-    result, err = os.remove("/nonexistent.txt")
-    if not result then
-        log.info("os.remove", "删除不存在文件返回预期结果", err)
-    end
-end
-
--- 测试 os.rename() 文件重命名功能
-local function test_os_rename()
-    log.info("os.rename", "测试开始")
-    -- 创建源文件
-    local srcFile = "/test_rename_src.txt"
-    local f = io.open(srcFile, "w")
-    if f then
-        f:write("test content")
-        f:close()
-        log.info("os.rename", "源文件创建成功")
-    else
-        log.error("os.rename", "无法创建源文件")
-        return
-    end
-
-    -- 目标文件路径
-    local dstFile = "/test_rename_dst.txt"
-
-    -- 测试重命名
-    local result, err = os.rename(srcFile, dstFile)
-    if result then
-        log.info("os.rename", "文件重命名成功")
-
-        -- 验证新文件是否存在
-        if io.open(dstFile, "r") then
-            log.info("os.rename", "验证新文件存在")
-            os.remove(dstFile)
-        end
-    else
-        log.error("os.rename", "文件重命名失败", err)
-        os.remove(srcFile)
-    end
-
-    -- 测试重命名不存在的文件
-    result, err = os.rename("/nonexistent_src.txt", "/nonexistent_dst.txt")
-    if not result then
-        log.info("os.rename", "重命名不存在文件返回预期结果", err)
-    end
-end
-
--- 测试 os.date() 和 os.time() 功能
-local function test_os_date_time()
-    log.info("os.date/time", "测试开始")
-
-    -- 获取当前时间戳
-    local currentTimestamp = os.time()
-    log.info("os.time", "当前时间戳", currentTimestamp)
-
-    -- 测试 os.date() 各种格式
-    log.info("os.date", "默认格式本地时间", os.date())
-    log.info("os.date", "默认格式UTC时间", os.date("!%c"))
-    log.info("os.date", "自定义格式本地时间", os.date("%Y-%m-%d %H:%M:%S"))
-    log.info("os.date", "自定义格式UTC时间", os.date("!%Y-%m-%d %H:%M:%S"))
-
-    -- 测试特定时间
-    local testTime = {year=2000, mon=1, day=1, hour=0, min=0, sec=0}
-    local testTimestamp = os.time(testTime)
-    log.info("os.time", "2000-01-01 00:00:00 时间戳", testTimestamp)
-    log.info("os.date", "格式化特定时间", os.date("!%Y-%m-%d %H:%M:%S", testTimestamp))
-
-    -- 测试获取时间表
-    local localTimeTable = os.date("*t")
-    log.info("os.date", "本地时间表", json.encode(localTimeTable))
-    local utcTimeTable = os.date("!*t")
-    log.info("os.date", "UTC时间表", json.encode(utcTimeTable))
-
-    -- 测试 os.difftime()
-    local time1 = os.time()
-    sys.wait(1000) -- 等待1秒
-    local time2 = os.time()
-    local diff = os.difftime(time2, time1)
-    log.info("os.difftime", "时间差(应该约等于1)", diff)
-end
-
--- 主测试函数
-local function test_all()
-    log.info("OS接口测试", "===== 开始测试 =====")
-    test_os_remove()
-    test_os_rename()
-    test_os_date_time()
-    log.info("OS接口测试", "===== 测试完成 =====")
-end
-
--- 启动测试
-sys.taskInit(function()
-    sys.wait(1000) -- 等待系统初始化
-    test_all()
-end)
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 49
module/Air780EHV/DEMO/pack/main.lua

@@ -1,49 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "pack"
-VERSION = "2.0.0"
-
---[[
-本demo演示 string字符串的基本操作
-1. lua的字符串是带长度, 这意味着, 它不依赖0x00作为结束字符串, 可以包含任意数据
-2. lua的字符串是不可变的, 就不能直接修改字符串的一个字符, 修改字符会返回一个新的字符串
-]]
-
--- sys库是标配
-_G.sys = require("sys")
-sysplus = require("sysplus")
-
--- Air780E的AT固件默认会为开机键防抖, 导致部分用户刷机很麻烦
-if rtos.bsp() == "EC618" and pm and pm.PWK_MODE then
-    pm.power(pm.PWK_MODE, false)
-end
-
-sys.taskInit(function ()
-    sys.wait(1000) -- 免得看不到日志
-    local tmp
-
-	--实验1:以小端方式编码
-	local data = string.pack("<I", 0xAABBCCDD)      --‘<’表示以小端方式编码,'I'表示,unsigned int , 4字节
-	log.info("pack:", 	string.format("%02X", data:byte(1)), 	--输出小端编码后的数据
-						string.format("%02X", data:byte(2)), 
-						string.format("%02X", data:byte(3)), 
-						string.format("%02X", data:byte(4)))
-	
-	--实验2:以大端方式编码
-	local data = string.pack(">I", 0xAABBCCDD)
-	log.info("pack:", 	string.format("%02X", data:byte(1)),   --输出大端编码后的数据
-						string.format("%02X", data:byte(2)), 
-						string.format("%02X", data:byte(3)), 
-						string.format("%02X", data:byte(4)))
-						
-	--实验3:对上面已经完成的大端编码,再次进行解包为每个字节					
-	local byte1,byte2,byte3,byte4 = string.unpack(">BBBB", data)  --将32位数据拆成4个8位字节数据
-    --log.info("Unpack", byte1,byte2,byte3,byte4)		
-	log.info("Unpack:", string.format("%02X", byte1),   --以十六进制形式输出拆解后的4个字节数据
-						string.format("%02X", byte2), 
-						string.format("%02X", byte3), 
-						string.format("%02X", byte4))
-end)
--- 这里演示4G模块上网后,会自动点亮网络灯,方便用户判断模块是否正常开机
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 72
module/Air780EHV/DEMO/protobuf/main.lua

@@ -1,72 +0,0 @@
---- 模块功能:Google ProtoBuffs 编解码
--- @module pb
--- @author wendal
--- @release 2022.9.8
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "pbdemo"
-VERSION = "1.0.1"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
---添加硬狗防止程序卡死
-if wdt then
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-sys.taskInit(function()
-    sys.wait(500)
-    -- 如果没有这个库, 就云编译一份吧: https://wiki.luatos.com/develop/compile/Cloud_compilation.html
-    if not protobuf then
-        log.info("protobuf", "this demo need protobuf lib")
-        return
-    end
-    -- 加载 pb 文件, 这个是从pbtxt 转换得到的
-    -- 下载资源到模块时不需要下载pbtxt
-    -- 转换命令: protoc.exe -operson.pb person.pbtxt
-    -- protoc.exe 下载地址: https://github.com/protocolbuffers/protobuf/releases
-    local pb_file = "/luadb/person.pb"
-    
-    if io.exists(pb_file) then
-        protobuf.load(io.readFile(pb_file))
-        sys.publish("pb_file_exists")
-    else
-        log.info("protobuf","Failed to load file")
-    end
-
-    local tb = {
-        name = "wendal",
-        id = 123,
-        email = "abc@qq.com"
-    }
-    while 1 do
-        sys.waitUntil("pb_file_exists")
-        sys.wait(1000)
-        -- 用 protobuf 编码数据
-        local pbdata = protobuf.encode("Person", tb)
-        if pbdata then
-            -- 打印数据长度. 编码后的数据含不可见字符, toHex是方便显示
-            log.info("protobuf", "encode",  #pbdata, (pbdata:toHex()))
-        end
-        -- 用 json 编码数据, 用于对比大小
-        local jdata = json.encode(tb)
-        if jdata then
-            log.info("json", #jdata, jdata)
-        end
-        -- 可见 protobuffs 比 json 节省很多空间
-
-        -- 后续是演示解码
-        local re = protobuf.decode("Person", pbdata)
-        if re then
-            -- 打印数据, 因为table不能直接显示, 这里转成json来显示
-            log.info("protobuf", "decode", json.encode(re))
-        end
-    end
-end)
-
--- 主循环, 必须加
-sys.run()

+ 0 - 7
module/Air780EHV/DEMO/protobuf/person.pb

@@ -1,7 +0,0 @@
-
-R
-person.pbtxt"B
-Person
-name (	Rname
-id (Rid
-email (	Remail

+ 0 - 6
module/Air780EHV/DEMO/protobuf/person.pbtxt

@@ -1,6 +0,0 @@
-syntax = "proto2";
-message Person {
-  optional string name = 1;
-  optional int32 id = 2;
-  optional string email = 3;
-}

+ 0 - 29
module/Air780EHV/DEMO/pwm/breathing_led.lua

@@ -1,29 +0,0 @@
---[[
-@module  breathing_led
-@summary PWM呼吸灯效果模块
-@version 1.0
-@date    2025.07.08
-@author  王世豪
-@usage
-使用Air780EHV核心板的GPIO引脚输出PWM波形,演示呼吸灯效果。
-]]
-
-local PWM_ID = 0
-local function breathing_led()
-    log.info("pwm", "ch", PWM_ID)
-    while 1 do
-        -- 仿呼吸灯效果
-        log.info("pwm", ">>>>>")
-        for i = 10, 1, -1 do 
-            pwm.open(PWM_ID, 1000, i*9) -- 频率1000hz, 占空比从 90% 递减到 9%
-            sys.wait(100 + i*10) 
-        end
-        for i = 10, 1, -1 do 
-            pwm.open(PWM_ID, 1000, 100 - i*9) -- 频率1000hz, 占空比从 10% 递增到 91%
-            sys.wait(100 + i*10)
-        end
-        sys.wait(2000)
-    end
-end
-
-sys.taskInit(breathing_led)

+ 0 - 69
module/Air780EHV/DEMO/pwm/main.lua

@@ -1,69 +0,0 @@
---[[
-@module  main
-@summary LuatOS用户应用脚本文件入口,总体调度应用逻辑
-@version 1.0
-@date    2025.07.08
-@author  王世豪
-@usage
-本demo演示的核心功能为:
-1. 加载pwm输出模块,控制GPIO引脚输出PWM波形
-2. 加载呼吸灯效果模块,控制GPIO引脚输出呼吸灯效果
-
-更多说明参考本目录下的readme.md文件
-]]
-
---[[
-必须定义PROJECT和VERSION变量,Luatools工具会用到这两个变量,远程升级功能也会用到这两个变量
-PROJECT:项目名,ascii string类型
-        可以随便定义,只要不使用,就行
-VERSION:项目版本号,ascii string类型
-        如果使用合宙iot.openluat.com进行远程升级,必须按照"XXX.YYY.ZZZ"三段格式定义:
-            X、Y、Z各表示1位数字,三个X表示的数字可以相同,也可以不同,同理三个Y和三个Z表示的数字也是可以相同,可以不同
-            因为历史原因,YYY这三位数字必须存在,但是没有任何用处,可以一直写为000
-        如果不使用合宙iot.openluat.com进行远程升级,根据自己项目的需求,自定义格式即可
-]]
-PROJECT = "pwm"
-VERSION = "001.000.000"
-
-log.info("main", "project name is ", PROJECT, "version is ", VERSION)
-
--- 如果内核固件支持wdt看门狗功能,此处对看门狗进行初始化和定时喂狗处理
--- 如果脚本程序死循环卡死,就会无法及时喂狗,最终会自动重启
-if wdt then
-    --配置喂狗超时时间为9秒钟
-    wdt.init(9000)
-    --启动一个循环定时器,每隔3秒钟喂一次狗
-    sys.timerLoopStart(wdt.feed, 3000)
-end
-
--- 如果内核固件支持errDump功能,此处进行配置,【强烈建议打开此处的注释】
--- 因为此功能模块可以记录并且上传脚本在运行过程中出现的语法错误或者其他自定义的错误信息,可以初步分析一些设备运行异常的问题
--- 以下代码是最基本的用法,更复杂的用法可以详细阅读API说明文档
--- 启动errDump日志存储并且上传功能,600秒上传一次
--- if errDump then
---     errDump.config(true, 600)
--- end
-
--- 使用LuatOS开发的任何一个项目,都强烈建议使用远程升级FOTA功能
--- 可以使用合宙的iot.openluat.com平台进行远程升级
--- 也可以使用客户自己搭建的平台进行远程升级
--- 远程升级的详细用法,可以参考fota的demo进行使用
-
--- 启动一个循环定时器
--- 每隔3秒钟打印一次总内存,实时的已使用内存,历史最高的已使用内存情况
--- 方便分析内存使用是否有异常
--- sys.timerLoopStart(function()
---     log.info("mem.lua", rtos.meminfo())
---     log.info("mem.sys", rtos.meminfo("sys"))
--- end, 3000)
-
--- 加载pwm输出模块
-require "pwm_output"
-
--- -- 加载呼吸灯效果模块
--- require "breathing_led"
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 26
module/Air780EHV/DEMO/pwm/pwm_output.lua

@@ -1,26 +0,0 @@
---[[
-@module  pwm_output
-@summary PWM输出模块
-@version 1.0
-@date    2025.07.08
-@author  王世豪
-@usage
-使用Air780EHV核心板的GPIO引脚输出PWM波形,演示不同占空比的PWM波形输出效果。
-]]
-
-local PWM_ID = 0
-local function pwm_output()
-    while true do
-        -- 开启pwm通道0,设置脉冲频率为1kHz,分频精度为1000,占空比为10/1000=1% 持续输出
-        pwm.open(PWM_ID, 1000, 10, 0, 1000) -- 小灯微微发光
-        sys.wait(1000)
-        -- 开启pwm通道0,设置脉冲频率为1kHz,分频精度为1000,占空比为500/1000=50% 持续输出
-        pwm.open(PWM_ID, 1000, 500, 0, 1000) -- 小灯中等亮度
-        sys.wait(1000)
-        -- 开启pwm通道0,设置脉冲频率为1kHz,分频精度为1000,占空比为1000/1000=100% 持续输出
-        pwm.open(PWM_ID, 1000, 1000, 0, 1000) -- 小灯很高亮度
-        sys.wait(1000)
-    end
-end
-
-sys.taskInit(pwm_output)

+ 0 - 32
module/Air780EHV/DEMO/pwm/readme.md

@@ -1,32 +0,0 @@
-
-## 演示功能概述
-
-将使用Air780EHV核心板,演示PWM控制GPIO引脚输出PWM波形,以及控制GPIO引脚输出呼吸灯效果。
-
-## 演示硬件环境
-
-1、Air780EHV核心板一块
-
-2、TYPE-C USB数据线一根
-
-3、Air780EHV核心板和数据线的硬件接线方式为
-
-- Air780EHV核心板通过TYPE-C USB口供电;(核心板USB旁边的开关拨到on一端)
-
-- TYPE-C USB数据线直接插到核心板的TYPE-C USB座子,另外一端连接电脑USB口;
-
-## 演示软件环境
-
-1、Luatools下载调试工具
-
-2、[Air780EHV V2008版本固件](https://docs.openluat.com/air780ehv/luatos/firmware/version/)(测试使用V2008 1号固件)
-
-## 演示核心步骤
-
-1、搭建好演示硬件环境
-
-2、通过Luatools将demo与固件烧录到核心板中
-
-3、烧录成功后,自动开机运行
-
-4、接下来通过示波器查看波形,使用发光二极管演示呼吸灯效果。

+ 0 - 222
module/Air780EHV/DEMO/record/main.lua

@@ -1,222 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "record"
-VERSION = "1.0.0"
-
---[[]
-运行环境:Air780EHV核心板+AirAUDIO_1000配件板
-最后修改时间:2025-6-17
-使用了如下IO口:
-[3, "MIC+", " PIN3脚, 用于麦克风正极"],
-[4, "MIC-", " PIN4脚, 用于麦克风负极"],
-[5, "spk+", " PIN5脚, 用于喇叭正极"],
-[6, "spk-", " PIN6脚, 用于喇叭负极"],
-[20, "AudioPA_EN", " PIN20脚, 用于PA使能脚"],
-3.3V
-GND
-执行逻辑为:
-设置i2s和音频参数,提供了两种录音方式,录音到文件区或者录音到内存,然后播放,然后
-]]
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
---代码提供了2种方式录音,对应recordmode的值
---1:直接录音到文件
---2:录音到内存,然后保存到文件
-local recordmode = 1
---代码提供了2种方式对录音文件做处理
---1:发送到服务器
---2:发送到串口
-local recordhandle = 1
-local taskName = "task_audio"
-
-local MSG_MD = "moreData" -- 播放缓存有空余
-local MSG_PD = "playDone" -- 播放完成所有数据
-
--- amr数据存放buffer,尽可能地给大一些
-amr_buff = zbuff.create(20 * 1024)
--- 创建一个amr的encoder
-encoder = nil
-pcm_buff0 = zbuff.create(16000)
-pcm_buff1 = zbuff.create(16000)
-audio.on(0,function(id, event, point)
-        -- 使用play来播放文件时只有播放完成回调
-        if event == audio.RECORD_DATA then -- 录音数据
-            if point == 0 then
-                log.info("buff", point, pcm_buff0:used())
-                codec.encode(encoder, pcm_buff0, amr_buff)
-            else
-                log.info("buff", point, pcm_buff1:used())
-                codec.encode(encoder, pcm_buff1, amr_buff)
-            end
-        elseif event == audio.RECORD_DONE then -- 录音完成
-            sys.publish("AUDIO_RECORD_DONE")
-        else
-            local succ, stop, file_cnt = audio.getError(0)
-            if not succ then
-                if stop then
-                    log.info("用户停止播放")
-                else
-                    log.info("第", file_cnt, "个文件解码失败")
-                end
-            end
-            -- log.info("播放完成一个音频")
-            sysplus.sendMsg(taskName, MSG_PD)
-        end
-    end
-)
-
----- MultipartForm上传文件
--- url string 请求URL地址
--- filename string 上传服务器的文件名
--- filePath string 待上传文件的路径
-local function postMultipartFormData(url, filename, filePath)
-    local boundary = "----WebKitFormBoundary" .. os.time()
-    local req_headers = {
-        ["Content-Type"] = "multipart/form-data; boundary=" .. boundary
-    }
-    local body = {}
-    table.insert(
-        body,
-        "--" .. boundary .. '\r\nContent-Disposition: form-data; name="file"; filename="' .. filename .. '"\r\n\r\n'
-    )
-    table.insert(body, io.readFile(filePath))
-    table.insert(body, "\r\n")
-    table.insert(body, "--" .. boundary .. "--\r\n")
-    body = table.concat(body)
-    log.info("headers: ", "\r\n" .. json.encode(req_headers), type(body))
-    log.info("body: " .. body:len() .. "\r\n" .. body)
-    local code, headers, body = http.request("POST", url, req_headers, body).wait()
-    log.info("http.post", code, headers, body)
-end
-
-function audio_setup()
-    local i2c_id = 0 -- i2c_id 0
-
-    local pa_pin = gpio.AUDIOPA_EN -- 喇叭pa功放脚
-    local power_pin = 20 -- es8311电源脚
-
-    local i2s_id = 0 -- i2s_id 0
-    local i2s_mode = 0 -- i2s模式 0 主机 1 从机
-    local i2s_sample_rate = 16000 -- 采样率
-    local i2s_bits_per_sample = 16 -- 数据位数
-    local i2s_channel_format = i2s.MONO_R -- 声道, 0 左声道, 1 右声道, 2 立体声
-    local i2s_communication_format = i2s.MODE_LSB -- 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
-    local i2s_channel_bits = 16 -- 声道的BCLK数量
-
-    local multimedia_id = 0 -- 音频通道 0
-    local pa_on_level = 1 -- PA打开电平 1 高电平 0 低电平
-    local power_delay = 3 -- 在DAC启动前插入的冗余时间,单位100ms
-    local pa_delay = 100 -- 在DAC启动后,延迟多长时间打开PA,单位1ms
-    local power_on_level = 1 -- 电源控制IO的电平,默认拉高
-    local power_time_delay = 100 -- 音频播放完毕时,PA与DAC关闭的时间间隔,单位1ms
-
-    local voice_vol = 80 -- 喇叭音量
-    local mic_vol = 80 -- 麦克风音量
-
-    gpio.setup(power_pin, 1, gpio.PULLUP) -- 设置ES83111电源脚
-    gpio.setup(pa_pin, 1, gpio.PULLUP) -- 设置功放PA脚
-
-    sys.wait(200)
-
-    i2c.setup(i2c_id, i2c.FAST) -- 设置i2c
-    i2s.setup(
-        i2s_id,
-        i2s_mode,
-        i2s_sample_rate,
-        i2s_bits_per_sample,
-        i2s_channel_format,
-        i2s_communication_format,
-        i2s_channel_bits
-    ) -- 设置i2s
-
-    audio.config(multimedia_id, pa_pin, pa_on_level, power_delay, pa_delay, power_pin, power_on_level, power_time_delay)
-    audio.setBus(
-        multimedia_id,
-        audio.BUS_I2S,
-        {
-            chip = "es8311",
-            i2cid = i2c_id,
-            i2sid = i2s_id
-        }
-    ) -- 通道0的硬件输出通道设置为I2S
-
-    audio.vol(multimedia_id, voice_vol)
-    audio.micVol(multimedia_id, mic_vol)
-    sys.publish("AUDIO_READY")
-end
-
--- 配置好audio外设
-sys.taskInit(audio_setup)
-
-local function audio_task()
-    sys.waitUntil("AUDIO_READY")
-    sys.wait(5000)
-    local result
-
-    -- 下面为录音demo,根据适配情况选择性开启
-    local recordPath = "/record.amr"
-    if recordmode == 1 then
-        -- -- 直接录音到文件
-        err = audio.record(0, audio.AMR, 5, 7, recordPath)
-        sys.waitUntil("AUDIO_RECORD_DONE")
-        log.info("record", "录音结束")
-    elseif recordmode == 2 then
-        -- 录音到内存自行编码
-        encoder = codec.create(codec.AMR, false, 7)
-        log.info("encoder", encoder)
-        log.info("开始录音")
-        err = audio.record(0, audio.AMR, 5, 7, nil, nil, pcm_buff0, pcm_buff1)
-        sys.waitUntil("AUDIO_RECORD_DONE")
-        log.info("record", "录音结束")
-        os.remove(recordPath)
-        io.writeFile(recordPath, "#!AMR\n")
-        io.writeFile(recordPath, amr_buff:query(), "a+b")
-    end
-
-    result = audio.play(0, {recordPath})
-    if result then
-        -- 等待音频通道的回调消息,或者切换歌曲的消息
-        while true do
-            msg = sysplus.waitMsg(taskName, nil)
-            if type(msg) == "table" then
-                if msg[1] == MSG_PD then
-                    log.info("播放结束")
-                    break
-                end
-            else
-                log.error(type(msg), msg)
-            end
-        end
-    else
-        log.debug("解码失败!")
-        sys.wait(1000)
-    end
-
-    -- 下面的演示是将音频文件发送到服务器上,如有需要,可以将下面代码注释打开,这里的url是合宙的文件上传测试服务器,上传的文件到http://tools.openluat.com/tools/device-upload-test查看
-    if recordhandle == 1 then
-        local timeTable = os.date("*t", os.time())
-        local nowTime =
-            string.format(
-            "%4d%02d%02d_%02d%02d%02d",
-            timeTable.year,
-            timeTable.month,
-            timeTable.day,
-            timeTable.hour,
-            timeTable.min,
-            timeTable.sec
-        )
-        local filename = mobile.imei() .. "_" .. nowTime .. ".amr"
-        postMultipartFormData("http://tools.openluat.com/api/site/device_upload_file", filename, recordPath)
-    elseif recordhandle == 2 then
-        -- 该方法为从串口1,把录音数据传给串口1
-        uart.setup(1, 115200) -- 开启串口1
-        uart.write(1, io.readFile(recordPath)) -- 向串口发送录音文件
-    end
-end
-
-sysplus.taskInitEx(audio_task, taskName)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 87
module/Air780EHV/DEMO/sms/main.lua

@@ -1,87 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "smsdemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-require "sysplus" -- http库需要这个sysplus
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-log.info("main", "sms demo")
-
--- 辅助发送http请求, 因为http库需要在task里运行
-function http_post(url, headers, body)
-    sys.taskInit(function()
-        local code, headers, body = http.request("POST", url, headers, body).wait()
-        log.info("resp", code)
-    end)
-end
-
-function sms_handler(num, txt)
-    -- num 手机号码
-    -- txt 文本内容
-    log.info("sms", num, txt, txt:toHex())
-
-    -- http演示1, 发json
-    local body = json.encode({phone=num, txt=txt})
-    local headers = {}
-    headers["Content-Type"] = "application/json"
-    log.info("json", body)
-    http_post("http://www.luatos.com/api/sms/blackhole", headers, body)
-    -- http演示2, 发表单的
-    headers = {}
-    headers["Content-Type"] = "application/x-www-form-urlencoded"
-    local body = string.format("phone=%s&txt=%s", num:urlEncode(), txt:urlEncode())
-    log.info("params", body)
-    http_post("http://www.luatos.com/api/sms/blackhole", headers, body)
-    -- http演示3, 不需要headers,直接发
-    http_post("http://www.luatos.com/api/sms/blackhole", nil, num .. "," .. txt)
-    -- 如需发送到钉钉, 参考 demo/dingding
-    -- 如需发送到飞书, 参考 demo/feishu
-end
-
---------------------------------------------------------------------
--- 接收短信, 支持多种方式, 选一种就可以了
--- 1. 设置回调函数
---sms.setNewSmsCb(sms_handler)
--- 2. 订阅系统消息
---sys.subscribe("SMS_INC", sms_handler)
--- 3. 在task里等着
-sys.taskInit(function()
-    while 1 do
-        local ret, num, txt = sys.waitUntil("SMS_INC", 300000)
-        if num then
-            -- 方案1, 交给自定义函数处理
-            sms_handler(num, txt)
-            -- 方案2, 因为这里是task内, 可以直接调用http.request
-            -- local body = json.encode({phone=num, txt=txt})
-            -- local headers = {}
-            -- headers["Content-Type"] = "application/json"
-            -- log.info("json", body)
-            -- local code, headers, body = http.request("POST", "http://www.luatos.com/api/sms/blackhole", headers, body).wait()
-            -- log.info("resp", code)
-        end
-    end
-end)
-
--------------------------------------------------------------------
--- 发送短信, 直接调用sms.send就行, 是不是task无所谓
-sys.taskInit(function()
-    sys.wait(10000)
-    -- 中移动卡查短信
-    -- sms.send("+8610086", "301")
-    -- 联通卡查话费
-     sms.send("10010", "101")
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 113
module/Air780EHV/DEMO/string/main.lua

@@ -1,113 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "strtest"
-VERSION = "2.0.0"
-
---[[
-本demo演示 string字符串的基本操作
-1. lua的字符串是带长度, 这意味着, 它不依赖0x00作为结束字符串, 可以包含任意数据
-2. lua的字符串是不可变的, 就不能直接修改字符串的一个字符, 修改字符会返回一个新的字符串
-]]
-
--- sys库是标配
-_G.sys = require("sys")
-
-sys.taskInit(function ()
-    sys.wait(1000) -- 免得看不到日志
-    local tmp
-
-    ----------------------------------------------
-    --================================================
-    -- 字符串的声明和生成
-    --================================================
-
-    -- 常量声明
-    local str = "123455" 
-    log.info("str", str)														--日志输出:123455
-
-    -- 合成式
-    str = string.char(0x31, 0x32, 0x33, 0x34)  --0x31为字符 1的ASCII码
-    log.info("str", str)           												--日志输出:1234                   
-    -- lua的字符串可以包含任意数据, 包括 0x00
-    str = string.char(0x12, 0x00, 0xF1, 0x3A)
-    log.info("str", str:toHex()) -- 注意, 这里用toHex(), 因为包含了不可见字符   --日志输出:1200F13A	8(其中8为输出字符串长度)
-    -- 使用转义字符
-    str = "\x00\x12ABC"			 -- 字符串中的\x表示十六进制转义序列								
-    log.info("str", str:toHex()) -- 注意, 这里用toHex(), 因为包含了不可见字符   --日志输出:0012414243	10 (其中41,42,43分别分字符 ABC的ASCII值的十六进制形式,10为输出字符串长度)
-    str = "ABC\r\n\t"
-    log.info("str", str:toHex()) -- 注意, 这里用toHex(), 因为包含了不可见字符   --日志输出:4142430D0A09	12(其中0D为\r回车键值的ASCII值的十六进制形式,
-	                                                                            --0A为\n换行键值的ASCII值的十六进制形式,\t 是一个转义字符,表示一个水平制表符(Tab))
-
-
-
-    -- 解析生成
-    str = string.fromHex("AABB00EE")											
-    log.info("str", str:toHex())												--日志输出:AABB00EE	8
-    str = string.fromHex("393837363433")       --将字符串转换为十六进制形式
-    log.info("str", #str, str)												    --日志输出:6	987643(其中6为输出字符长度,987643为输出字符串)
-
-    -- 连接字符串, 操作符 ".."
-    str = "123" .. "," .. "ABC"  --将3段字符串连接起来
-    log.info("str", #str, str)												    --日志输出:7	123,ABC(其中7为输出字符长度,123,ABC为连接后的字符串)
-
-
-    -- 格式化生成
-    str = string.format("%s,%d,%f", "123", 45678, 1.5)		--格式化输出,	%s为字符串输出,%d为十进制输出,%f为浮点形式输出			
-    log.info("str", #str, str)													--日志输出:18	123,45678,1.500000
-
-
-    --================================================
-    -- 字符串的解析与处理
-    --================================================
-    -- 获取长度
-    str = "1234567"
-    log.info("str", #str)														--日志输出:7为字符串长度
-    -- 获取字符串的HEX字符串显示
-    log.info("str", str:toHex())												--日志输出:31323334353637	14(用字符格式输出十六进制)
-
-    -- 获取指定位置的值, 注意lua的下标是1开始的
-    str = "123ddss"
-    log.info("str[1]", str:byte(1))                                             --日志输出:49	 (字符1,对应十进制ASCII值)
-    log.info("str[4]", str:byte(4))												--日志输出: 100	 (字符d,对应十进制ASCII值)
-    log.info("str[1]", string.byte(str, 1))										--日志输出:49   (str位置1的字符,也是数字1)
-    log.info("str[4]", string.byte(str, 4))										--日志输出: 100	 (str位置4的字符,也是数字d)
-
-    -- 按字符串分割
-    str = "12,2,3,4,5"
-    tmp = str:split(",")
-    log.info("str.split", #tmp, tmp[1], tmp[3])									--日志输出:5	12	3
-    tmp = string.split(str, ",") -- 与前面的等价
-    log.info("str.split", #tmp, tmp[1], tmp[3])                                 --日志输出:5	12	3
-    str = "/tmp//def/1234/"
-    tmp = str:split("/")
-    log.info("str.split", #tmp, json.encode(tmp))								--日志输出:3	["tmp","def","1234"]
-
-    -- 2023.04.11新增的, 可以保留空的分割片段
-	--在 Lua 中,str:split("/", true) 语句表示将字符串 str 按照字符 "/" 进行分割,并且 true 参数通常用于表示保留空字符串(这取决于具体的 split 函数实现,因为 Lua 标准库中没有内置的 split 函数)。根据你的描述,输出结果是 6 ["","tmp","","def","1234",""]。这是因为:
-    --假设 str 是 "/tmp//def/1234/",在这种情况下,字符串以 "/" 开头和结尾,并且有连续的 "/"。
-    --split 函数将字符串分割成多个部分,每个 "/" 都会作为一个分割符。
-    --因为 true 参数表示保留空字符串,所以在分割过程中,连续的 "/" 和开头、结尾的 "/" 都会导致空字符串被保留。
-
-    tmp = str:split("/", true) 
-    log.info("str.split", #tmp, json.encode(tmp))								--日志输出:6	["","tmp","","def","1234",""]
-
-    -- 更多资料
-    -- https://wiki.luatos.com/develop/hex_string.html
-    -- https://wiki.luatos.com/_static/lua53doc/manual.html#3.4
-end)
--- 这里演示4G模块上网后,会自动点亮网络灯,方便用户判断模块是否正常开机
-sys.taskInit(function()
-    while true do
-        sys.wait(6000)
-                if mobile.status() == 1 then
-                        gpio.set(27, 1)  
-                else
-                        gpio.set(27, 0) 
-                        mobile.reset()
-        end
-    end
-end)
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 134
module/Air780EHV/DEMO/tcp/TCP-UART/main.lua

@@ -1,134 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_tcp"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-_G.sysplus = require("sysplus")
-local taskName = "TCP_TASK"             -- sysplus库用到的任务名称,也作为任务id
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-local uartid = 1 -- 根据实际设备选取不同的uartid
-local uart_rx_buff = zbuff.create(1024)     -- 串口接收到的数据
-local libnet = require "libnet"         -- libnet库,支持tcp、udp协议所用的同步阻塞接口
-local ip = "112.125.89.8"               -- 连接tcp服务器的ip地址
-local port = 46244                 -- 连接tcp服务器的端口
-local netCB = nil                       -- socket服务的回调函数
-local connect_state = false             -- 连接状态 true:已连接   false:未连接
-local protocol = false                  -- 通讯协议 true:UDP协议  false:TCP协议
-local ssl = false                       -- 加密传输 true:加密     false:不加密
-local tx_buff = zbuff.create(1024)      -- 发送至tcp服务器的数据
-local rx_buff = zbuff.create(1024)      -- 从tcp服务器接收到的数据
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-function TCP_TASK()
-    -- 打印一下连接的目标ip和端口号
-    log.info("connect ip: ", ip, "port:", port)
-
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-    netCB = socket.create(nil, taskName)     -- 创建socket对象
-    socket.debug(netCB, true)                -- 打开调试日志
-    socket.config(netCB, nil, protocol, ssl)      -- 此配置为TCP连接,无SSL加密
-
-    -- 串口和TCP服务器的交互逻辑
-    while true do
-        -- 连接服务器,返回是否连接成功
-        result = libnet.connect(taskName, 15000, netCB, ip, port)
-
-        -- 收取数据会触发回调, 这里的"receive" 是固定值不要修改。
-        uart.on(uartid, "receive", function(id, len)
-            while true do
-                local len = uart.rx(id, uart_rx_buff)   -- 接收串口收到的数据,并赋值到uart_rx_buff
-                if len <= 0 then    -- 接收到的字节长度为0 则退出
-                    break
-                end
-                -- 如果已经在线了,则发送socket.EVENT消息来打断任务里的阻塞等待状态,让任务循环继续
-                if connect_state then
-                    sys_send(taskName, socket.EVENT, 0)
-                end
-            end
-        end)
-
-        -- 如果连接成功,则改变连接状态参数,并且随便发一条数据到服务器,看服务器能不能收到
-        if result then
-            connect_state = true
-            libnet.tx(taskName, 0, netCB, "TCP  CONNECT")
-        end
-
-        -- 连接上服务器后,等待处理接收服务器下行至模块的数据 和 发送串口的数据到服务器
-        while result do
-            succ, param, _, _ = socket.rx(netCB, rx_buff)   -- 接收数据
-            if not succ then
-                log.info("服务器断开了", succ, param, ip, port)
-                break
-            end
-
-            if rx_buff:used() > 0 then
-                log.info("收到服务器数据,长度", rx_buff:used())
-
-                uart.tx(uartid, rx_buff)    -- 从服务器收到的数据转发 从串口输出
-                rx_buff:del()
-            end
-
-            tx_buff:copy(nil, uart_rx_buff)         -- 将串口数据赋值给tcp待发送数据的buff中
-            uart_rx_buff:del()                      -- 清除串口buff的数据长度
-            if tx_buff:used() > 0 then
-                log.info("发送到服务器数据,长度", tx_buff:used())
-                local result = libnet.tx(taskName, 0, netCB, tx_buff)   -- 发送数据
-                if not result then
-                    log.info("发送失败了", result, param)
-                    break
-                end
-            end
-            tx_buff:del()
-
-            -- 如果zbuff对象长度超出,需要重新分配下空间
-            if uart_rx_buff:len() > 1024 then
-                uart_rx_buff:resize(1024)
-            end
-            if tx_buff:len() > 1024 then
-                tx_buff:resize(1024)
-            end
-            if rx_buff:len() > 1024 then
-                rx_buff:resize(1024)
-            end
-            log.info(rtos.meminfo("sys"))   -- 打印系统内存
-
-            -- 阻塞等待新的消息到来,比如服务器下发,串口接收到数据
-            result, param = libnet.wait(taskName, 15000, netCB)
-            if not result then
-                log.info("服务器断开了", result, param)
-                break
-            end
-        end
-
-        -- 服务器断开后的行动,由于while true的影响,所以会再次重新执行进行 重新连接。
-        connect_state = false
-        libnet.close(taskName, 5000, netCB)
-        tx_buff:clear(0)
-        rx_buff:clear(0)
-        sys.wait(1000)
-    end
-
-end
-
--- libnet库依赖于sysplus,所以只能通过sysplus.taskInitEx创建的任务函数中运行
-sysplus.taskInitEx(TCP_TASK, taskName, netCB)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 139
module/Air780EHV/DEMO/tcp/TCP单向认证/main.lua

@@ -1,139 +0,0 @@
--- main.lua文件
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_tcp"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-_G.sysplus = require("sysplus")
-local taskName = "TCP_TASK"             -- sysplus库用到的任务名称,也作为任务id
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-local uartid = 1 -- 根据实际设备选取不同的uartid
-local uart_rx_buff = zbuff.create(1024)     -- 串口接收到的数据
-
-local libnet = require "libnet"         -- libnet库,支持tcp、udp协议所用的同步阻塞接口
-local ip = "112.125.89.8"               -- 连接tcp服务器的ip地址
-local port = 46428            -- 连接tcp服务器的端口
-local netCB = nil                       -- socket服务的回调函数
-local connect_state = false             -- 连接状态 true:已连接   false:未连接
-local protocol = false                  -- 通讯协议 true:UDP协议  false:TCP协议
-local ssl = true                     -- 加密传输 true:加密     false:不加密
-local tx_buff = zbuff.create(1024)      -- 发送至tcp服务器的数据
-local rx_buff = zbuff.create(1024)      -- 从tcp服务器接收到的数据
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
-function TCP_TASK()
-    -- 打印一下连接的目标ip和端口号
-    log.info("connect ip: ", ip, "port:", port)
-
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-    netCB = socket.create(nil, taskName)     -- 创建socket对象
-    socket.debug(netCB, true)                -- 打开调试日志
-    socket.config(netCB, nil, protocol, ssl)      -- 此配置为TCP连接,无SSL加密
-
-    -- 串口和TCP服务器的交互逻辑
-    while true do
-        -- 连接服务器,返回是否连接成功
-        result = libnet.connect(taskName, 15000, netCB, ip, port)
-
-        -- 收取数据会触发回调, 这里的"receive" 是固定值不要修改。
-        uart.on(uartid, "receive", function(id, len)
-            while true do
-                local len = uart.rx(id, uart_rx_buff)   -- 接收串口收到的数据,并赋值到uart_rx_buff
-                if len <= 0 then    -- 接收到的字节长度为0 则退出
-                    break
-                end
-                -- 如果已经在线了,则发送socket.EVENT消息来打断任务里的阻塞等待状态,让任务循环继续
-                if connect_state then
-                    sys_send(taskName, socket.EVENT, 0)
-                end
-            end
-        end)
-
-        -- 如果连接成功,则改变连接状态参数,并且随便发一条数据到服务器,看服务器能不能收到
-        if result then
-            connect_state = true
-            libnet.tx(taskName, 0, netCB, "TCP  CONNECT")
-        end
-
-        -- 连接上服务器后,等待处理接收服务器下行至模块的数据 和 发送串口的数据到服务器
-        while result do
-            succ, param, _, _ = socket.rx(netCB, rx_buff)   -- 接收数据
-            if not succ then
-                log.info("服务器断开了", succ, param, ip, port)
-                break
-            end
-
-            if rx_buff:used() > 0 then
-                log.info("收到服务器数据,长度", rx_buff:used())
-
-                uart.tx(uartid, rx_buff)    -- 从服务器收到的数据转发 从串口输出
-                rx_buff:del()
-            end
-
-            tx_buff:copy(nil, uart_rx_buff)         -- 将串口数据赋值给tcp待发送数据的buff中
-            uart_rx_buff:del()                      -- 清除串口buff的数据长度
-            if tx_buff:used() > 0 then
-                log.info("发送到服务器数据,长度", tx_buff:used())
-                local result = libnet.tx(taskName, 0, netCB, tx_buff)   -- 发送数据
-                if not result then
-                    log.info("发送失败了", result, param)
-                    break
-                end
-            end
-            tx_buff:del()
-
-            -- 如果zbuff对象长度超出,需要重新分配下空间
-            if uart_rx_buff:len() > 1024 then
-                uart_rx_buff:resize(1024)
-            end
-            if tx_buff:len() > 1024 then
-                tx_buff:resize(1024)
-            end
-            if rx_buff:len() > 1024 then
-                rx_buff:resize(1024)
-            end
-            log.info(rtos.meminfo("sys"))   -- 打印系统内存
-
-            -- 阻塞等待新的消息到来,比如服务器下发,串口接收到数据
-            result, param = libnet.wait(taskName, 15000, netCB)
-            if not result then
-                log.info("服务器断开了", result, param)
-                break
-            end
-        end
-
-        -- 服务器断开后的行动,由于while true的影响,所以会再次重新执行进行 重新连接。
-        connect_state = false
-        libnet.close(taskName, 5000, netCB)
-        tx_buff:clear(0)
-        rx_buff:clear(0)
-        sys.wait(1000)
-    end
-
-end
-
--- libnet库依赖于sysplus,所以只能通过sysplus.taskInitEx创建的任务函数中运行
-sysplus.taskInitEx(TCP_TASK, taskName, netCB)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 134
module/Air780EHV/DEMO/tcp/TCP断链续连/main.lua

@@ -1,134 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_tcp"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-_G.sysplus = require("sysplus")
-local taskName = "TCP_TASK"             -- sysplus库用到的任务名称,也作为任务id
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-local uartid = 1 -- 根据实际设备选取不同的uartid
-local uart_rx_buff = zbuff.create(1024)     -- 串口接收到的数据
-local libnet = require "libnet"         -- libnet库,支持tcp、udp协议所用的同步阻塞接口
-local ip = "112.125.89.8"               -- 连接tcp服务器的ip地址
-local port = 46244                 -- 连接tcp服务器的端口
-local netCB = nil                       -- socket服务的回调函数
-local connect_state = false             -- 连接状态 true:已连接   false:未连接
-local protocol = false                  -- 通讯协议 true:UDP协议  false:TCP协议
-local ssl = false                       -- 加密传输 true:加密     false:不加密
-local tx_buff = zbuff.create(1024)      -- 发送至tcp服务器的数据
-local rx_buff = zbuff.create(1024)      -- 从tcp服务器接收到的数据
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-function TCP_TASK()
-    -- 打印一下连接的目标ip和端口号
-    log.info("connect ip: ", ip, "port:", port)
-
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-    netCB = socket.create(nil, taskName)     -- 创建socket对象
-    socket.debug(netCB, true)                -- 打开调试日志
-    socket.config(netCB, nil, protocol, ssl)      -- 此配置为TCP连接,无SSL加密
-
-    -- 串口和TCP服务器的交互逻辑
-    while true do
-        -- 连接服务器,返回是否连接成功
-        result = libnet.connect(taskName, 15000, netCB, ip, port)
-
-        -- 收取数据会触发回调, 这里的"receive" 是固定值不要修改。
-        uart.on(uartid, "receive", function(id, len)
-            while true do
-                local len = uart.rx(id, uart_rx_buff)   -- 接收串口收到的数据,并赋值到uart_rx_buff
-                if len <= 0 then    -- 接收到的字节长度为0 则退出
-                    break
-                end
-                -- 如果已经在线了,则发送socket.EVENT消息来打断任务里的阻塞等待状态,让任务循环继续
-                if connect_state then
-                    sys_send(taskName, socket.EVENT, 0)
-                end
-            end
-        end)
-
-        -- 如果连接成功,则改变连接状态参数,并且随便发一条数据到服务器,看服务器能不能收到
-        if result then
-            connect_state = true
-            libnet.tx(taskName, 0, netCB, "TCP  CONNECT")
-        end
-
-        -- 连接上服务器后,等待处理接收服务器下行至模块的数据 和 发送串口的数据到服务器
-        while result do
-            succ, param, _, _ = socket.rx(netCB, rx_buff)   -- 接收数据
-            if not succ then
-                log.info("服务器断开了", succ, param, ip, port)
-                break
-            end
-
-            if rx_buff:used() > 0 then
-                log.info("收到服务器数据,长度", rx_buff:used())
-
-                uart.tx(uartid, rx_buff)    -- 从服务器收到的数据转发 从串口输出
-                rx_buff:del()
-            end
-
-            tx_buff:copy(nil, uart_rx_buff)         -- 将串口数据赋值给tcp待发送数据的buff中
-            uart_rx_buff:del()                      -- 清除串口buff的数据长度
-            if tx_buff:used() > 0 then
-                log.info("发送到服务器数据,长度", tx_buff:used())
-                local result = libnet.tx(taskName, 0, netCB, tx_buff)   -- 发送数据
-                if not result then
-                    log.info("发送失败了", result, param)
-                    break
-                end
-            end
-            tx_buff:del()
-
-            -- 如果zbuff对象长度超出,需要重新分配下空间
-            if uart_rx_buff:len() > 1024 then
-                uart_rx_buff:resize(1024)
-            end
-            if tx_buff:len() > 1024 then
-                tx_buff:resize(1024)
-            end
-            if rx_buff:len() > 1024 then
-                rx_buff:resize(1024)
-            end
-            log.info(rtos.meminfo("sys"))   -- 打印系统内存
-
-            -- 阻塞等待新的消息到来,比如服务器下发,串口接收到数据
-            result, param = libnet.wait(taskName, 15000, netCB)
-            if not result then
-                log.info("服务器断开了", result, param)
-                break
-            end
-        end
-
-        -- 服务器断开后的行动,由于while true的影响,所以会再次重新执行进行 重新连接。
-        connect_state = false
-        libnet.close(taskName, 5000, netCB)
-        tx_buff:clear(0)
-        rx_buff:clear(0)
-        sys.wait(1000)
-    end
-
-end
-
--- libnet库依赖于sysplus,所以只能通过sysplus.taskInitEx创建的任务函数中运行
-sysplus.taskInitEx(TCP_TASK, taskName, netCB)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 51
module/Air780EHV/DEMO/timer/main.lua

@@ -1,51 +0,0 @@
-
--- main.lua文件
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "timer_demo"
-VERSION = "1.0.0"
-
-sys = require("sys")
--- 定义一个单次触发的定时器回调函数  
-local function oneShotCallback(message)  
-    log.info("One-shot timer triggered: " .. message)  
-end  
--- 定义一个周期性触发的定时器回调函数  
-local function periodicCallback(count)  
-    log.info("Periodic timer triggered (Count: " .. count .. ")")  
-end  
--- 定义一个周期性触发的定时器回调函数  
-local function periodicCallback1(count)  
-    log.info("Periodic timer triggered1 (Count: " .. count .. ")")  
-end  
-
--- 初始化计数器,用于周期性定时器  
-local periodicCount = 0  
-  
--- 启动一个单次触发的定时器,延迟3秒后触发  
-local oneShotTimerId = sys.timerStart(oneShotCallback, 3000, 0, "Hello from one-shot timer!")  
-  
--- 启动一个周期性触发的定时器,每2秒触发一次  
-
-sys.timerStart(periodicCallback,7000,"first")
-sys.timerStart(periodicCallback,6000,"second")
-sys.timerStart(periodicCallback,5000,"third")
-
-local periodicTimerId2 = sys.timerLoopStart(function()  
-    periodicCount = periodicCount + 1  
-    periodicCallback1(periodicCount)  
-end, 2000)  
-
-    -- 停止所有定时器(仅作为测试,实际应用中应根据需要停止)  
-
-    sys.timerStart(function()
-        sys.timerStop(periodicTimerId2)
-        log.info("stop 2s loop timer periodicCallback1")
-    end,5000)
-
-    sys.timerStart(function()
-        sys.timerStopAll(periodicCallback)  
-        log.info("stop periodicCallback loop timer ")
-    end,4000)
-
-
-sys.run()-- sys.run()-此后不要在添加其他函数

+ 0 - 155
module/Air780EHV/DEMO/tts/main.lua

@@ -1,155 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "testtts"
-VERSION = "1.0.0"
-
---[[]
-运行环境:Air780EHV核心板+AirAUDIO_1000配件板
-最后修改时间:2025-6-17
-使用了如下IO口:
-[5, "spk+", " PIN5脚, 用于喇叭正极"],
-[6, "spk-", " PIN6脚, 用于喇叭负极"],
-[20, "AudioPA_EN", " PIN20脚, 用于PA使能脚"],
-3.3V
-GND
-执行逻辑为:
-设置i2s和音频参数,读取文件qianzw.txt里面的内容,然后播放出来
-]]
-
--- sysplus库是可选的,可以用sys库代替
--- sys库是标配
-_G.sys = require("sys")
-_G.sysplus = require("sysplus")
-
-
-local i2c_id = 0 -- i2c_id 0
-
-local pa_pin = gpio.AUDIOPA_EN -- 喇叭pa功放脚
-local power_pin = 20 -- es8311电源脚
-
-local i2s_id = 0 -- i2s_id 0
-local i2s_mode = 0 -- i2s模式 0 主机 1 从机
-local i2s_sample_rate = 16000 -- 采样率
-local i2s_bits_per_sample = 16 -- 数据位数
-local i2s_channel_format = i2s.MONO_R -- 声道, 0 左声道, 1 右声道, 2 立体声
-local i2s_communication_format = i2s.MODE_LSB -- 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
-local i2s_channel_bits = 16 -- 声道的BCLK数量
-
-local multimedia_id = 0 -- 音频通道 0
-local pa_on_level = 1 -- PA打开电平 1 高电平 0 低电平
-local power_delay = 3 -- 在DAC启动前插入的冗余时间,单位100ms
-local pa_delay = 100 -- 在DAC启动后,延迟多长时间打开PA,单位1ms
-local power_on_level = 1 -- 电源控制IO的电平,默认拉高
-local power_time_delay = 100 -- 音频播放完毕时,PA与DAC关闭的时间间隔,单位1ms
-
-local voice_vol = 50 -- 喇叭音量
-local mic_vol = 80 -- 麦克风音量
-
-gpio.setup(power_pin, 1, gpio.PULLUP)   -- 设置ES83111电源脚
-gpio.setup(pa_pin, 1, gpio.PULLUP)      -- 设置功放PA脚
-
-function audio_setup()
-    log.info("audio_setup")
-    sys.wait(200)
-
-    i2c.setup(i2c_id, i2c.FAST)
-    i2s.setup(i2s_id, i2s_mode, i2s_sample_rate, i2s_bits_per_sample, i2s_channel_format, i2s_communication_format,
-        i2s_channel_bits)
-
-    audio.config(multimedia_id, pa_pin, pa_on_level, power_delay, pa_delay, power_pin, power_on_level, power_time_delay)
-    audio.setBus(multimedia_id, audio.BUS_I2S, {
-        chip = "es8311",
-        i2cid = i2c_id,
-        i2sid = i2s_id
-    }) -- 通道0的硬件输出通道设置为I2S
-
-    audio.vol(multimedia_id, voice_vol)
-    audio.micVol(multimedia_id, mic_vol)
-    sys.publish("AUDIO_READY")
-end
-
--- 配置好audio外设
-sys.taskInit(audio_setup)
-
-local taskName = "task_audio"
-
-local MSG_MD = "moreData" -- 播放缓存有空余
-local MSG_PD = "playDone" -- 播放完成所有数据
-
-audio.on(0, function(id, event)
-    -- 使用play来播放文件时只有播放完成回调
-    local succ, stop, file_cnt = audio.getError(0)
-    if not succ then
-        if stop then
-            log.info("用户停止播放")
-        else
-            log.info("第", file_cnt, "个文件解码失败")
-        end
-    end
-    sysplus.sendMsg(taskName, MSG_PD)
-end)
-
-local function audio_task()
-    local result
-    sys.waitUntil("AUDIO_READY")
-
-    -- 本例子是按行播放 "千字文", 文本来源自wiki百科
-    local fd = nil
-    local line = nil
-    while true do
-        log.info("开始播放")
-        line = nil
-        if not fd then
-            fd = io.open("/luadb/qianzw.txt")
-        end
-        if fd then
-            line = fd:read("*l")
-            if line == nil then
-                fd:close()
-                fd = nil
-            end
-        end
-        if line == nil then --如果没有找到千字文,播放以下文本
-            line =
-                "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十"
-        end
-        line = line:trim()
-        log.info("播放内容", line)
-        result = audio.tts(0, line)
-        if result then
-            -- 等待音频通道的回调消息,或者切换歌曲的消息
-            while true do
-                msg = sysplus.waitMsg(taskName, nil)
-                if type(msg) == 'table' then
-                    if msg[1] == MSG_PD then
-                        log.info("播放结束")
-                        break
-                    end
-                else
-                    log.error(type(msg), msg)
-                end
-            end
-        else
-            log.debug("解码失败!")
-            sys.wait(1000)
-        end
-        if not audio.isEnd(0) then
-            log.info("手动关闭")
-            audio.playStop(0)
-        end
-        if audio.pm then
-            audio.pm(0, audio.STANDBY)
-        end
-        -- audio.pm(0,audio.SHUTDOWN)	--低功耗可以选择SHUTDOWN或者POWEROFF,如果codec无法断电用SHUTDOWN
-        log.info("mem", "sys", rtos.meminfo("sys"))
-        log.info("mem", "lua", rtos.meminfo("lua"))
-        sys.wait(1000)
-    end
-    sysplus.taskDel(taskName)
-end
-
-sysplus.taskInitEx(audio_task, taskName)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 63
module/Air780EHV/DEMO/tts/qianzw.txt

@@ -1,63 +0,0 @@
-天地玄黄,宇宙洪荒.日月盈昃,辰宿列张.
-寒来暑往,秋收冬藏.闰余成岁,律吕调阳.
-云腾致雨,露结为霜.金生丽水,玉出昆冈.
-剑号巨阙,珠称夜光.果珍李柰,菜重芥姜.
-海咸河淡,鳞潜羽翔.龙师火帝,鸟官人皇.
-始制文字,乃服衣裳.推位让国,有虞陶唐.
-吊民伐罪,周发殷汤.坐朝问道,垂拱平章.
-爱育黎首,臣伏戎羌.遐迩一体,率宾归王.
-鸣凤在竹,白驹食场.化被草木,赖及万方.
-盖此身发,四大五常.恭惟鞠养,岂敢毁伤.
-女慕贞洁,男效才良.知过必改,得能莫忘.
-罔谈彼短,靡恃己长.信使可覆,器欲难量.
-墨悲丝染,诗赞羔羊.景行维贤,克念作圣.
-德建名立,形端表正.空谷传声,虚堂习听.
-祸因恶积,福缘善庆.尺璧非宝,寸阴是竞.
-资父事君,曰严与敬.孝当竭力,忠则尽命.
-临深履薄,夙兴温凊.似兰斯馨,如松之盛.
-川流不息,渊澄取映.容止若思,言辞安定.
-笃初诚美,慎终宜令.荣业所基,籍甚无竟.
-学优登仕,摄职从政.存以甘棠,去而益咏.
-乐殊贵贱,礼别尊卑.上和下睦,夫唱妇随.
-外受傅训,入奉母仪.诸姑伯叔,犹子比儿.
-孔怀兄弟,同气连枝.交友投分,切磨箴规.
-仁慈隐恻,造次弗离.节义廉退,颠沛匪亏.
-性静情逸,心动神疲.守真志满,逐物意移.
-坚持雅操,好爵自縻.都邑华夏,东西二京.
-背邙面洛,浮渭据泾.宫殿盘郁,楼观飞惊.
-图写禽兽,画彩仙灵.丙舍旁启,甲帐对楹.
-肆筵设席,鼓瑟吹笙.升阶纳陛,弁转疑星.
-右通广内,左达承明.既集坟典,亦聚群英.
-杜稿钟隶,漆书壁经.府罗将相,路侠槐卿.
-户封八县,家给千兵.高冠陪辇,驱毂振缨.
-世禄侈富,车驾肥轻.策功茂实,勒碑刻铭.
-磻溪伊尹,佐时阿衡.奄宅曲阜,微旦孰营.
-桓公匡合,济弱扶倾.绮回汉惠,说感武丁.
-俊乂密勿,多士实宁.晋楚更霸,赵魏困横.
-假途灭虢,践土会盟.何遵约法,韩弊烦刑.
-起翦颇牧,用军最精.宣威沙漠,驰誉丹青.
-九州禹迹,百郡秦并.岳宗泰岱,禅主云亭.
-雁门紫塞,鸡田赤城.昆池碣石,钜野洞庭.
-旷远绵邈,岩岫杳冥.治本于农,务兹稼穑.
-俶载南亩,我艺黍稷.税熟贡新,劝赏黜陟.
-孟轲敦素,史鱼秉直.庶几中庸,劳谦谨敕.
-聆音察理,鉴貌辨色.贻厥嘉猷,勉其祗植.
-省躬讥诫,宠增抗极.殆辱近耻,林皋幸即.
-两疏见机,解组谁逼.索居闲处,沉默寂寥.
-求古寻论,散虑逍遥.欣奏累遣,戚谢欢招.
-渠荷的历,园莽抽条.枇杷晚翠,梧桐蚤凋.
-陈根委翳,落叶飘摇.游鹍独运,凌摩绛霄.
-耽读玩市,寓目囊箱.易輶攸畏,属耳垣墙.
-具膳餐饭,适口充肠.饱饫烹宰,饥厌糟糠.
-亲戚故旧,老少异粮.妾御绩纺,侍巾帷房.
-纨扇圆絜,银烛炜煌.昼眠夕寐,蓝笋象床.
-弦歌酒宴,接杯举觞.矫手顿足,悦豫且康.
-嫡后嗣续,祭祀烝尝.稽颡再拜,悚惧恐惶.
-笺牒简要,顾答审详.骸垢想浴,执热愿凉.
-驴骡犊特,骇跃超骧.诛斩贼盗,捕获叛亡.
-布射僚丸,嵇琴阮啸.恬笔伦纸,钧巧任钓.
-释纷利俗,并皆佳妙.毛施淑姿,工颦妍笑.
-年矢每催,曦晖朗曜.璇玑悬斡,晦魄环照.
-指薪修祜,永绥吉劭.矩步引领,俯仰廊庙.
-束带矜庄,徘徊瞻眺.孤陋寡闻,愚蒙等诮.
-谓语助者,焉哉乎也.

+ 0 - 155
module/Air780EHV/DEMO/u8g2/main.lua

@@ -1,155 +0,0 @@
---- 模块功能:u8g2demo
--- @module u8g2
--- @author Dozingfiretruck
--- @release 2021.01.25
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "u8g2demo"
-VERSION = "1.0.1"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
---[[接线方式  780EPM开发板----------------------------------SSD1306
-LCD_VCC(LCD那组引脚以sim卡卡槽旁的LCD母排为1的第二个排母孔) ---(VCC)
-I2C1_SCL(CAMERA_SCL)----------------------------------------(SCL)
-I2C1_SDA(CAMERA_SDA)----------------------------------------(SDA)
-GND---------------------------------------------------------(GND)
-]]
-
--- 添加硬狗防止程序卡死
-wdt.init(9000) -- 初始化watchdog设置为9s
-sys.timerLoopStart(wdt.feed, 3000) -- 3s喂一次狗
-
--- gpio.setup(14, nil) -- 关闭GPIO14,防止camera复用关系出问题
--- gpio.setup(15, nil) -- 关闭GPIO15,防止camera复用关系出问题
-
-
-local rtos_bsp = rtos.bsp()
-
--- hw_i2c_id,sw_i2c_scl,sw_i2c_sda,spi_id,spi_res,spi_dc,spi_cs
-function u8g2_pin()
-    if string.find(rtos_bsp, "780EPM") or string.find(rtos_bsp, "718PM") then
-        return 1, 14, 15, 0, 14, 10, 8
-    else
-        log.info("main", "你用的不是780EPM 请更换demo测试")
-        return
-    end
-end
-
-local hw_i2c_id, sw_i2c_scl, sw_i2c_sda, spi_id, spi_res, spi_dc, spi_cs = u8g2_pin()
-
--- 日志TAG, 非必须
-local TAG = "main"
-local chinese =true
--- 主流程
-sys.taskInit(function()
-
-    gpio.setup(2, 1) -- GPIO2打开给camera电源供电
-    gpio.setup(28, 1) -- 1.2版本 GPIO28打开给lcd电源供电
-    gpio.setup(29, 1) -- 1.3硬件版本 GPIO29打开给lcd电源供电
-    sys.wait(2000)
-
-    -- 初始化显示屏
-    log.info(TAG, "init ssd1306")
-
-    -- 初始化硬件i2c的ssd1306
-    log.info("setup SSD1306", u8g2.begin({
-        ic = "ssd1306",
-        direction = 0,
-        mode = "i2c_hw",
-        i2c_id = hw_i2c_id
-    })) -- direction 可选0 90 180 270
-
-    log.info("设置字体模式", u8g2.SetFontMode(1))
-    log.info("清屏", u8g2.ClearBuffer())
-    log.info("设置字体为 oppo字体", u8g2.SetFont(u8g2.font_opposansm8))
-    log.info("在显示屏上展示U8G2+LUATOS", u8g2.DrawUTF8("U8G2+LUATOS", 32, 22))
-
-    if u8g2.font_opposansm12_chinese then
-        u8g2.SetFont(u8g2.font_opposansm12_chinese)
-    elseif u8g2.font_opposansm10_chinese then
-        u8g2.SetFont(u8g2.font_opposansm10_chinese)
-    elseif u8g2.font_sarasa_m12_chinese then
-        u8g2.SetFont(u8g2.font_sarasa_m12_chinese)
-    elseif u8g2.font_sarasa_m10_chinese then
-        u8g2.SetFont(u8g2.font_sarasa_m10_chinese)
-    else
-        print("没有中文字库")
-        chinese = false
-    end
-
-    if chinese then
-    log.info("在显示屏显示中文", u8g2.DrawUTF8("中文测试", 40, 38)) -- 若中文不显示或乱码,代表所刷固件不带这个字号的字体数据, 可自行云编译一份. wiki.luatos.com 有文档.
-        
-    end
-    log.info("将存储器帧缓冲区的内容发送到显示器", u8g2.SendBuffer())
-    sys.wait(2000)
-    u8g2.ClearBuffer()
-    if chinese then
-        u8g2.DrawUTF8("屏幕宽度:" .. u8g2.GetDisplayWidth(), 40, 24)
-        u8g2.DrawUTF8("屏幕高度:" .. u8g2.GetDisplayHeight(), 40, 42)
-    else
-        u8g2.DrawUTF8("width:" .. u8g2.GetDisplayWidth(), 40, 24)
-        u8g2.DrawUTF8("height:" .. u8g2.GetDisplayHeight(), 40, 42)
-    end
-    sys.wait(5000)
-    u8g2.SendBuffer()
-
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("画线测试:", 30, 24)
-    for i = 0, 128, 8 do
-        u8g2.DrawLine(0, 40, i, 40)
-        u8g2.DrawLine(0, 60, i, 60)
-        u8g2.SendBuffer()
-        sys.wait(100)
-    end
-
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("画圆测试:", 30, 24)
-    u8g2.DrawCircle(30, 50, 10, 15)
-    u8g2.DrawDisc(90, 50, 10, 15)
-    u8g2.SendBuffer()
-
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("椭圆测试:", 30, 24)
-    u8g2.DrawEllipse(30, 50, 6, 10, 15)
-    u8g2.DrawFilledEllipse(90, 50, 6, 10, 15)
-    u8g2.SendBuffer()
-
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("方框测试:", 30, 24)
-    u8g2.DrawBox(30, 40, 30, 24)
-    u8g2.DrawFrame(90, 40, 30, 24)
-    u8g2.SendBuffer()
-
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("圆角方框:", 30, 24)
-    u8g2.DrawRBox(30, 40, 30, 24, 8)
-    u8g2.DrawRFrame(90, 40, 30, 24, 8)
-    u8g2.SendBuffer()
-
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawUTF8("三角测试:", 30, 24)
-    u8g2.DrawTriangle(30, 60, 60, 30, 90, 60)
-    u8g2.SendBuffer()
-
-    -- qrcode测试
-    sys.wait(1000)
-    u8g2.ClearBuffer()
-    u8g2.DrawDrcode(4, 4, "https://wiki.luatos.com", 30);
-
-    u8g2.SendBuffer()
-
-    -- sys.wait(1000)
-    log.info("main", "u8g2 demo done")
-end)
-
--- 主循环, 必须加
-sys.run()

+ 0 - 51
module/Air780EHV/DEMO/uart/uart/main.lua

@@ -1,51 +0,0 @@
--- Luatools需要PROJECT和VERSION这两个信息
-PROJECT = "uart"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-log.info("main", "uart demo run......")
-
-local uartid = 1 -- 根据实际设备选取不同的uartid
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
--- 收取数据会触发回调, 这里的"receive" 是固定值
-uart.on(uartid, "receive", function(id, len)
-    local s = ""
-    repeat
-        s = uart.read(id, 128)
-        if #s > 0 then -- #s 是取字符串的长度
-            -- 关于收发hex值,请查阅 https://doc.openluat.com/article/583
-            log.info("uart", "receive", id, #s, s)
-            -- log.info("uart", "receive", id, #s, s:toHex()) --如果传输二进制/十六进制数据, 部分字符不可见, 不代表没收到
-        end
-    until s == ""
-end)
-
-sys.taskInit(function()
-    -- 循环两秒向串口发一次数据
-    while true do
-        sys.wait(2000)
-        uart.write(uartid, "test data.")
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 49
module/Air780EHV/DEMO/uart/uart_rs485/main.lua

@@ -1,49 +0,0 @@
--- Luatools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_RS485"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-log.info("main", "uart demo run......")
-
-local uartid = 1        -- 根据实际设备选取不同的uartid
-local uart485Pin = 25   -- 用于控制485接收和发送的使能引脚
-
-gpio.setup(1, 1)        --打开电源(开发板485供电脚是gpio1,用开发板测试需要开机初始化拉高gpio1)
-
---初始化
-uart.setup(uartid, 9600, 8, 1, uart.NONE, uart.LSB, 1024, uart485Pin, 0, 2000)
-
--- 收取数据会触发回调, 这里的"receive" 是固定值
-uart.on(uartid, "receive", function(id, len)
-    local s = ""
-    repeat
-        s = uart.read(id, 128)
-        if #s > 0 then -- #s 是取字符串的长度
-            -- 关于收发hex值,请查阅 https://doc.openluat.com/article/583
-            log.info("uart", "receive", id, #s, s)
-            -- log.info("uart", "receive", id, #s, s:toHex()) --如果传输二进制/十六进制数据, 部分字符不可见, 不代表没收到
-        end
-    until s == ""
-end)
-
-sys.taskInit(function()
-    -- 循环两秒向串口发一次数据
-    while true do
-        sys.wait(2000)
-        uart.write(uartid, "test data.")
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 77
module/Air780EHV/DEMO/uart/uart_two/main.lua

@@ -1,77 +0,0 @@
--- Luatools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_two"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-log.info("main", "uart_two demo run......")
-
--- 根据实际设备选取不同的uartid
-local uartid1 = 1 -- 第一个串口id
-local uartid2 = 2 -- 第二个串口id
-
--- 初始化第一个串口
-uart.setup(
-    uartid1,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
--- 初始化第一个串口
-uart.setup(
-    uartid2,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
--- 第一个串口接收数据回调函数
--- 收取数据会触发回调, 这里的"receive" 是固定值
-uart.on(uartid1, "receive", function(id, len)
-    local s = ""
-    repeat
-        s = uart.read(id, 128)
-        if #s > 0 then -- #s 是取字符串的长度
-            -- 关于收发hex值,请查阅 https://doc.openluat.com/article/583
-            log.info("uart", "receive", id, #s, s)
-            -- log.info("uart", "receive", id, #s, s:toHex()) --如果传输二进制/十六进制数据, 部分字符不可见, 不代表没收到
-        end
-    until s == ""
-end)
-
--- 第二个串口接收数据回调函数
--- 收取数据会触发回调, 这里的"receive" 是固定值
-uart.on(uartid2, "receive", function(id, len)
-    local s = ""
-    repeat
-        s = uart.read(id, 128)
-        if #s > 0 then -- #s 是取字符串的长度
-            -- 关于收发hex值,请查阅 https://doc.openluat.com/article/583
-            log.info("uart", "receive", id, #s, s)
-            -- log.info("uart", "receive", id, #s, s:toHex()) --如果传输二进制/十六进制数据, 部分字符不可见, 不代表没收到
-        end
-    until s == ""
-end)
-
-sys.taskInit(function()
-    -- 循环两秒分别向两个串口发一次数据
-    while true do
-        sys.wait(2000)
-        uart.write(uartid1, "uart1 test data.")
-        uart.write(uartid2, "uart2 test data.")
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 61
module/Air780EHV/DEMO/uart/uart_vir/main.lua

@@ -1,61 +0,0 @@
--- Luatools需要PROJECT和VERSION这两个信息
-PROJECT = "uart_vir"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-
-log.info("main", "uart demo run......")
-
-local uartid = uart.VUART_0 -- 使用USB虚拟串口,固定id
-
---初始化
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-
--- 收取数据会触发回调, 这里的"receive" 是固定值
-uart.on(uartid, "receive", function(id, len)
-    local s = ""
-    repeat
-        s = uart.read(id, 128)
-        if #s > 0 then -- #s 是取字符串的长度
-            -- 关于收发hex值,请查阅 https://doc.openluat.com/article/583
-            log.info("uart", "receive", id, #s, s)
-            -- log.info("uart", "receive", id, #s, s:toHex()) --如果传输二进制/十六进制数据, 部分字符不可见, 不代表没收到
-        end
-    until s == ""
-end)
-
-sys.taskInit(function()
-    local data =
-    {
-        host = "abcdefg.com",
-        port = "1883",
-        clientID = "c88885",
-        username = "user",
-        password = "123456",
-        ca_self = {ssl=false},
-    }
-    local jsondata = json.encode(data)
-    -- 循环每两秒向串口发一次数据
-    while true do
-        sys.wait(2000)
-        uart.write(uartid, jsondata)
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 123
module/Air780EHV/DEMO/udp/main.lua

@@ -1,123 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "scdemo"
-VERSION = "1.0.0"
-log.info("main", PROJECT, VERSION)
--- 一定要添加sys.lua !!!!
-sys = require("sys")
-_G.sysplus = require("sysplus")
-local taskName = "UDP_TASK"             -- sysplus库用到的任务名称,也作为任务id
-if wdt then
-    --添加硬狗防止程序卡死,在支持的设备上启用这个功能
-    wdt.init(9000)--初始化watchdog设置为9s
-    sys.timerLoopStart(wdt.feed, 3000)--3s喂一次狗
-end
-local uart_rx_buff = zbuff.create(1024)     -- 串口接收到的数据
-----------------------------网络配置---------------------------
-local libnet = require "libnet"         -- libnet库,支持tcp、udp协议所用的同步阻塞接口
-local ip = "112.125.89.8"               -- 连接UDP服务器的ip地址
-local port = 46139                      -- 连接UDP服务器的端口
-local netCB = nil                       -- socket服务的回调函数
-local connect_state = false             -- 连接状态 true:已连接   false:未连接
-local protocol = true                  -- 通讯协议 true:UDP协议  false:TCP协议
-local ssl = false                       -- 加密传输 true:加密     false:不加密
-local tx_buff = zbuff.create(1024)     -- 发送至UDP服务器的数据
-local rx_buff = zbuff.create(1024)     -- 从UDP服务器接收到的数据
---==============================================================
---Uart初始化  
-local uartid = 1 -- 根据实际设备选取不同的uartid
-uart.setup(
-    uartid,--串口id
-    115200,--波特率
-    8,--数据位
-    1--停止位
-)
-function UDP_TASK()
-    -- 打印一下连接的目标ip和端口号
-    log.info("connect ip: ", ip, "port:", port)
-    sys.waitUntil("IP_READY")                -- 等待联网成功
-    netCB = socket.create(nil, taskName)     -- 创建socket对象
-    socket.debug(netCB, true)                -- 打开调试日志
-    socket.config(netCB, nil, protocol, ssl)      -- 此配置为UDP连接,无SSL加密
-    -- 串口和UDP服务器的交互逻辑
-    while true do
-        -- 连接服务器,返回是否连接成功
-        local result = libnet.connect(taskName, 15000, netCB, ip, port)
-        -----查询网络状态
-        local status = mobile.status()    
-        log.info("status", status) 
-        
-        -- 收取数据会触发回调, 这里的"receive" 是固定值不要修改。
-        log.info("connect ip: 等待连接 ",result)
-        uart.on(uartid, "receive", function(id, len)
-            while true do
-                local len = uart.rx(id, uart_rx_buff)   -- 接收串口收到的数据,并赋值到uart_rx_buff
-                if len <= 0 then    -- 接收到的字节长度为0 则退出
-                    break
-                end
-                -- 如果已经在线了,则发送socket.EVENT消息来打断任务里的阻塞等待状态,让任务循环继续
-                if connect_state then
-                    sys_send(taskName, socket.EVENT, 0)
-                end
-            end
-        end)
-        -- 如果连接成功,则改变连接状态参数,并且随便发一条数据到服务器,看服务器能不能收到
-        if result then
-            log.info("connect ip: 连接成功")
-            connect_state = true
-           libnet.tx(taskName, 0, netCB, "UDP CONNECT")
-        end
-        -- 连接上服务器后,等待处理接收服务器下行至模块的数据 和 发送串口的数据到服务器
-        while result do
-            succ, param, _, _ = socket.rx(netCB, rx_buff)   -- 接收数据
-            if not succ then
-                log.info("服务器断开了", succ, param, ip, port)
-                break
-            end
-            if rx_buff:used() > 0 then
-                log.info("收到服务器数据,长度", rx_buff:used())
-               uart.tx(uartid, rx_buff)    -- 从服务器收到的数据转发 从串口输出
-                rx_buff:del()
-            end
-            tx_buff:copy(nil, uart_rx_buff)         -- 将串口数据赋值给UDP待发送数据的buff中
-            uart_rx_buff:del()                      -- 清除串口buff的数据长度
-            if tx_buff:used() > 0 then
-                log.info("发送到服务器数据,长度", tx_buff:used())
-                local result = libnet.tx(taskName, 0, netCB, tx_buff)   -- 发送数据
-                if not result then
-                    log.info("发送失败了", result, param)
-                    break
-                end
-            end
-            tx_buff:del()
-            -- 如果zbuff对象长度超出,需要重新分配下空间
-            if uart_rx_buff:len() > 1024 then
-                uart_rx_buff:resize(1024)
-            end
-            if tx_buff:len() > 1024 then
-                tx_buff:resize(1024)
-            end
-            if rx_buff:len() > 1024 then
-                rx_buff:resize(1024)
-            end
-            log.info(rtos.meminfo("sys"))   -- 打印系统内存
-            -- 阻塞等待新的消息到来,比如服务器下发,串口接收到数据
-            result, param = libnet.wait(taskName, 15000, netCB)
-            if not result then
-                log.info("服务器断开了", result, param)
-                break
-            end
-        end
-        -- 服务器断开后的行动,由于while true的影响,所以会再次重新执行进行 重新连接。
-        connect_state = false
-        libnet.close(taskName, 5000, netCB)
-        tx_buff:clear(0)
-        rx_buff:clear(0)
-        sys.wait(1000)
-    end
-end
--- libnet库依赖于sysplus,所以只能通过sysplus.taskInitEx创建的任务函数中运行
-sysplus.taskInitEx(UDP_TASK, taskName, netCB)
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 33
module/Air780EHV/DEMO/wdt/示例一 程序正常运行/main.lua

@@ -1,33 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "wdtdemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
-sys.taskInit(function()
-    -- 这个demo要求有wdt库
-    -- wdt库的使用,基本上每个demo的头部都有演示
-    -- 模组/芯片的内部硬狗, 能解决绝大多数情况下的死机问题
-    -- 但如果有要求非常高的场景, 依然建议外挂硬件,然后通过gpio/i2c定时喂狗
-    if wdt == nil then
-        while 1 do
-            sys.wait(1000)
-            log.info("wdt", "this demo need wdt lib")
-        end
-    end
-    -- 注意, 大部分芯片/模块是 2 倍超时时间后才会重启
-    -- 以下是常规配置, 9秒超时, 3秒喂一次狗
-    -- 若软件崩溃,死循环,硬件死机,那么 最多 18 秒后,自动复位
-    -- 注意: 软件bug导致业务失败, 并不能通过wdt解决
-    wdt.init(9000)
-    sys.timerLoopStart(wdt.feed, 3000)
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 42
module/Air780EHV/DEMO/wdt/示例二 添加死循环模拟故障场景/main.lua

@@ -1,42 +0,0 @@
-
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "wdtdemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- sys库是标配
-_G.sys = require("sys")
-
-sys.taskInit(function()
-    -- 这个demo要求有wdt库
-    -- wdt库的使用,基本上每个demo的头部都有演示
-    -- 模组/芯片的内部硬狗, 能解决绝大多数情况下的死机问题
-    -- 但如果有要求非常高的场景, 依然建议外挂硬件,然后通过gpio/i2c定时喂狗
-    if wdt == nil then
-        while 1 do
-            sys.wait(1000)
-            log.info("wdt", "this demo need wdt lib")
-        end
-    end
-    -- 注意, 大部分芯片/模块是 2 倍超时时间后才会重启
-    -- 以下是常规配置, 9秒超时, 3秒喂一次狗
-    -- 若软件崩溃,死循环,硬件死机,那么 最多 18 秒后,自动复位
-    -- 注意: 软件bug导致业务失败, 并不能通过wdt解决
-    wdt.init(9000)
-    sys.timerLoopStart(wdt.feed, 3000)
-end)
-
--- 创建一个新的任务来模拟故障场景
-sys.taskInit(function()
-    log.info("fault_task", "Entering infinite loop to simulate fault.")
-    while true do
-        -- 模拟故障场景,真的进入死循环
-    end
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 30
module/Air780EHV/DEMO/wlan/wifiscan/main.lua

@@ -1,30 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "wifidemo"
-VERSION = "1.0.0"
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-require("sysplus")
-
--- wifi扫描成功后, 会有WLAN_SCAN_DONE消息, 读取即可
-sys.subscribe("WLAN_SCAN_DONE", function ()
-    local results = wlan.scanResult()
-    log.info("scan", "results", #results)
-    for k,v in pairs(results) do
-        log.info("scan", v["ssid"], v["rssi"], (v["bssid"]:toHex()))
-    end
-end)
-
-sys.taskInit(function()
-    sys.wait(1000)
-    wlan.init()
-    while 1 do
-        wlan.scan()
-        sys.wait(15000) -- 注意, 尤其是Air780系列, 这个时间只能更长不能短
-    end
-end)
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 72
module/Air780EHV/DEMO/zbuff/main.lua

@@ -1,72 +0,0 @@
--- LuaTools需要PROJECT和VERSION这两个信息
-PROJECT = "zbuffdemo"
-VERSION = "1.0.0"
-
-log.info("main", PROJECT, VERSION)
-
--- 引入必要的库文件(lua编写), 内部库不需要require
-sys = require("sys")
-
-sys.taskInit(function()
-    sys.wait(3000)
-    -- zbuff可以理解为char[], char*, uint8_t*
-    -- 为了与lua更好的融合, zbuff带长度,带指针位置,可动态扩容
-    local buff = zbuff.create(1024)
-    -- 可当成数组直接赋值和取值
-    buff[0] = 0xAE
-    log.info("zbuff", "buff[0]", buff[0])
-
-    -- 以io形式操作
-    
-    -- 写数据write, 操作之后指针会移动,跟文件句柄一样
-    buff:write("123") -- 字符串
-    buff:write(0x12, 0x13, 0x13, 0x33) -- 直接写数值也可以
-    
-    -- 设置指针位置, seek
-    buff:seek(5, zbuff.SEEK_CUR) -- 指针位置+5
-    buff:seek(0)                 -- 绝对地址
-
-    -- 读数据read, 指针也会移动
-    local data = buff:read(3)
-    log.info("zbuff", "data", data)
-
-    -- 清除全部数据,但指针位置不变
-    buff:clear() -- 默认填0
-    buff:clear(0xA5) -- 也可以指定填充的内容
-
-    -- 支持以pack库的形式写入或读取数据
-    buff:seek(0)
-    buff:pack(">IIHA", 0x1234, 0x4567, 0x12,"abcdefg")
-    buff:seek(0)
-    local cnt,a,b,c,s = buff:unpack(">IIHA10")
-
-    -- 也可以直接按类型读写数据
-    local len = buff:writeI8(10)
-    local len = buff:writeU32(1024)
-    local i8data = buff:readI8()
-    local u32data = buff:readU32()
-
-    -- 取出指定区间的数据
-    local fz = buff:toStr(0,5)
-
-    -- 获取其长度
-    log.info("zbuff", "len", buff:len())
-    -- 获取其指针位置
-    log.info("zbuff", "len", buff:used())
-
-    -- 测试writeF32, 注意, EC618系列(Air780E等), V1106会死机, 在V1107修复
-    buff:seek(0, zbuff.SEEK_SET)
-    buff:writeF32(1.2)
-    buff:seek(0, zbuff.SEEK_SET)
-    log.info("buff", "rw", "f32", buff:readF32())
-
-    -- 更多用法请查阅api文档
-
-    log.info("zbuff", "demo done")
-end)
-
-
--- 用户代码已结束---------------------------------------------
--- 结尾总是这一句
-sys.run()
--- sys.run()之后后面不要加任何语句!!!!!

+ 0 - 109
module/Air780EHV/README.md

@@ -1,109 +0,0 @@
-# LuatOS-Air780EHV
-
-## 介绍
-
-本代码库 是 合宙 Air780EHV 模组的代码中心, 包括演示代码demo, 案例代码project等
-
-如需查阅文档, 请访问合宙文档中心的[Air780EHV模块文档中心](https://docs.openluat.com/air780ehv/product/)
-
-## 目录说明
-
-* demo  [演示代码](demo/)
-* project  [案例代码](project/)
-
-## demo使用指南
-
-[**JT808**]:本demo演示使用string.pack与unpack函数,实现JT808 终端注册协议数据生成与解析,适用于车辆定位和监控系统。
-
-[**Websocket**]:本demo演示使用websocket协议,实现LuatOS与Web服务器的通信,适用于实时数据传输和双向通信场景。
-
-[**adc**]:本demo演示LuatOS的ADC功能,用于模拟信号的读取,适用于传感器数据采集等场景。
-
-[**airlbs**]:本demo演示LuatOS的LBS功能,包括多基站定位和WIFI定位,适用于位置服务开发。
-
-[**bit**]:本demo演示LuatOS的bit操作功能,适用于需要进行位级操作的场景。
-
-[**bit64**]:本demo演示LuatOS的64位bit操作功能,适用于需要进行大范围位级操作的场景。
-
-[**camera/spi_cam**]:本demo演示LuatOS的SPI摄像头功能,适用于需要集成摄像头进行图像采集的设备。
-
-[**can**]:本demo演示LuatOS的CAN总线通信功能,适用于汽车电子和工业自动化等场景。
-
-[**crypto**]:本demo演示LuatOS的加密功能,包括哈希、对称加密和非对称加密等,适用于需要进行数据加密和解密的场景。
-
-[**errdump**]:本demo演示LuatOS的错误信息转储功能,适用于设备调试和错误分析。
-
-[**fota2**]:本demo演示LuatOS的FOTA(空中下载)功能,包括固件更新等,适用于设备远程升级和维护。
-
-[**fs**]:本demo演示LuatOS的文件系统功能,包括文件读写等,适用于需要进行文件存储和操作的场景。
-
-[**gpio**]:本demo演示LuatOS的GPIO功能,包括数字输入输出等,适用于需要进行硬件控制的场景。
-
-[**helloworld**]:本demo演示LuatOS的基本运行环境,通过输出“Hello, World!”来验证开发环境是否搭建成功。
-
-[**hmeta**]:本demo演示LuatOS的硬件信息查询功能,适用于获取设备硬件相关信息。
-
-[**http**]:本demo演示LuatOS的HTTP协议功能,包括网页请求和文件下载等,适用于需要进行网络通信的场景。
-
-[**i2c-sht20**]:本demo演示LuatOS的I2C通信功能,通过SHT20温湿度传感器来读取温度和湿度信息。
-
-[**iconv**]:本demo演示LuatOS的字符编码转换功能,适用于需要进行字符编码转换的场景。
-
-[**iotcloud**]:本demo演示LuatOS与物联网云平台的通信,包括设备连接、数据上传和云服务调用等。
-
-[**json**]:本demo演示LuatOS的JSON数据解析和生成功能,适用于需要进行JSON格式数据处理的场景。
-
-[**lbsloc2**]:本demo演示LuatOS的LBS定位功能,适用于需要进行精准位置定位的场景。
-
-[**lcd**]:本demo演示LuatOS的LCD显示功能,适用于需要进行图形界面显示的设备。
-
-[**log**]:本demo演示LuatOS的日志记录功能,适用于需要进行日志记录和分析的场景。
-
-[**lowpower**]:本demo演示LuatOS的低功耗模式功能,适用于需要进行设备功耗优化的场景。
-
-[**miniz**]:本demo演示LuatOS的压缩和解压缩功能,适用于需要进行数据压缩和解压缩的场景。
-
-[**mobile**]:本demo演示LuatOS的移动网络功能,包括蜂窝网络连接、数据传输等,适用于需要进行移动网络通信的场景。
-
-[**mqtt**]:本demo演示LuatOS的MQTT协议功能,适用于物联网场景下的消息发布和订阅。
-
-[**netdrv/ch390**]:本demo演示LuatOS与CH390芯片的网络驱动功能,适用于USB转网口的设备。
-
-[**ntp**]:本demo演示LuatOS的NTP网络时间同步功能,适用于需要进行时间同步的场景。
-
-[**onewire**]:本demo演示LuatOS的1-Wire协议功能,适用于连接单总线设备如DS18B20温度传感器等。
-
-[**openai/deepseek**]:本demo演示LuatOS如何集成OpenAI的DeepSeek服务,适用于需要进行深度学习推理的场景。
-
-[**pack**]:本demo演示LuatOS的数据打包和解包功能,适用于需要进行数据格式转换的场景。
-
-[**protobuf**]:本demo演示LuatOS的protobuf数据解析和生成功能,适用于需要进行protobuf格式数据处理的场景。
-
-[**pwm**]:本demo演示LuatOS的PWM功能,适用于需要进行脉冲宽度调制的场景。
-
-[**sms**]:本demo演示LuatOS的短信收发功能,适用于嵌入式设备需要进行短信通信的场景。
-
-[**spi**]:本demo演示LuatOS的SPI通信功能,适用于需要进行SPI通信的场景。
-
-[**string**]:本demo演示LuatOS的字符串操作功能,包括字符串拼接、分割、查找等,适用于需要进行字符串处理的场景。
-
-[**tcp**]:本demo演示LuatOS的TCP协议功能,适用于需要进行TCP通信的场景。
-
-[**timer**]:本demo演示LuatOS的定时器功能,包括单次定时器和周期定时器,适用于需要定时执行任务的场景。
-
-[**uart**]:本demo演示LuatOS的UART串口通信功能,适用于需要进行串口通信的场景。
-
-[**udp**]:本demo演示LuatOS的UDP协议功能,适用于需要进行UDP通信的场景。
-
-[**wdt**]:本demo演示LuatOS的看门狗定时器功能,适用于需要进行设备监控和自动复位的场景。
-
-[**wlan/wifiscan**]:本demo演示LuatOS的Wi-Fi扫描功能,适用于需要搜索和连接Wi-Fi网络的场景。
-
-## 授权协议
-
-[MIT License](LICENSE)
-
-```lua
-print("感谢您使用LuatOS ^_^")
-print("Thank you for using LuatOS ^_^")
-```

+ 0 - 1
module/Air780EHV/core.md

@@ -1 +0,0 @@
-[Air780EHV固件下载地址](https://docs.openluat.com/air780ehv/luatos/firmware/version/)

+ 0 - 0
module/Air780EHV/project/.keep