Files
fastbee/sdk/air724/wumeimqtt/WeiMeiApp.lua
DuXingJie 50d548ec9a 第一次提交合宙mqtt对接物美
代码结构:
WeiMeiComAuth.lua 用于认证
WeiMeiComInteraction.lua 用户交互
WeiMeiApp.lua 应用采集
WuMeiTest.lua 结合合宙mqtt 调用上面函数 完成功能
开发调试环境:vscode 仿真代码
功能:
1.简单认证,加密认证
2.设备信息上传
3.监控主题订阅 监控数据回应
4.属性定时上传
验证完成
1.简单加密
2.设备信息上传
3.监控上传
4.属性定时上传
2022-08-07 00:55:20 +08:00

82 lines
1.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--- 模块功能物美MQTT应用
-- @author 杜兴杰
-- @module 物美MQTT应用
-- @license MIT
-- @copyright 杜兴杰
-- @release 2022.8.5
module(..., package.seeall)
local VERSION = "0.1"
local m_strUserId = "1"
local m_strLongitude = "0"
local m_strLatitude = "0"
local m_nTemperature = 25
local m_nVoltval = 4.0
--模块温度返回回调函数
--@temp温度srting类型如果要对该值进行运算可以使用带float的固件将该值转为number
local function getTemperatureCb(temp)
m_nTemperature = temp
end
--- ADC读取测试
-- @return 无
-- @usage read()
local function read0()
--ADC0接口用来读取电压
local ADC_ID = 0
local adcval,voltval = adc.read(ADC_ID)
log.info("testAdc0.read",adcval,(voltval-(voltval%3))/3,voltval)
-- 输出计算得出的原始电压值
m_nVoltval = voltval/3 * 3127 / 1000
log.info("testAdc0.Vbat", m_nVoltval)
end
--2秒循环查询模块温度
--sys.timerLoopStart(misc.getTemperature,1000,getTemperatureCb)
--sys.timerLoopStart(read0,1000)
-- 开启对应的adc通道
--adc.open(0)
function FunctionData()
local jsonStr = ""
end
function PropertyData()
local jsonData = {{
id= "temperature",
value= m_nTemperature ,
remark="温度信息"
},{
id= "Voltage",
value= m_nVoltval,
remark="电压信息"
}}
local jsonStr = json.encode(jsonData)
return jsonStr
end
function InformationData()
local jsonData = {
rssi = net.getRssi(),
firmwareVersion = VERSION,
status = 3 ,
userId = m_strUserId ,
longitude = m_strLongitude ,
latitude = m_strLatitude,
summary = {
name= "device",
chip = "air724",
author = "duxingjie",
version=0.1,
create = "2022-08-06"
}
}
local jsonStr = json.encode(jsonData)
return jsonStr
end