6 mqtt的订阅和发布

demo文件里那个是订阅主题,哪个是发布主题,attachments-2018-11-JgwNnxvW5be0ee07823dc.png

这一句是是什么意思,订阅主题的话是哪一个,event0还是,event1,我想把订阅主题改为 iotserver,怎么改,

发布主题是哪个?

local function pubQos0TestCb(result)
log.info("mqttOutMsg.pubQos0TestCb",result)
if result then sys.timerStart(pubQos0Test,10000) end
end

function pubQos0Test()
insertMsg("/qos0topic","qos0data",0,{cb=pubQos0TestCb})
end

local function pubQos1TestCb(result)
log.info("mqttOutMsg.pubQos1TestCb",result)
if result then sys.timerStart(pubQos1Test,20000) end
end

function pubQos1Test()
insertMsg("/中文qos1topic","中文qos1data",1,{cb=pubQos1TestCb})
end

哪个是发布主题,如何更改,如果我想把,发布主题改为iotsend,要如何更改

请先 登录 后评论

2 个回答

罗耀锋 - 软件工程师
擅长:软件开发

subscribe 订阅
insertMst 是发布

请先 登录 后评论
Jone

若订阅主题改为 iotserver,则mqttClient:subscribe("/iotserver",0)

若发布主题要为 iotsend, 则mqttClient:publish("/iotsend", "要发送的数据", 0),

或者用demo中的框架代码,改为insertMsg("/iotsend","要发送的数据",0,{cb=你自己的回调函数名})


关于mqtt相关函数的使用,参见http://wiki.openluat.com/doc/luatApi/#mqtt

请先 登录 后评论
  • 0 关注
  • 0 收藏,3633 浏览
  • rainmakersk 提出于 2018-11-06 09:39

相似问题