问题描述
说我有一个物联网设备,该设备已订阅一个主题,例如topic1。
只要有与设备的Internet连接,通过aws iot test mqtt客户端在上述主题上发布的任何味精都将到达device1。
断开连接后,味精将永远不会到达设备。我认为设备影子可以解决此问题(设备可以从影子中检索最新状态)。但是我很好奇-在重新连接之前先断开连接,设备如何从影子主题中检索味精(增量)?
在JavaScript中,这是通过调用来完成的:
// get initial token
initialGetClientToken = thingShadows.get(thingName); inside thingShadows.register..
// and then by checking the delta value in the status event handler that is automatically invoked by the above get:
thingShadows.on('status',function(thingName,statusType,clientToken,stateObject){..
if (stateObject.state.hasOwnProperty('delta')) {....
// and the following code helps to monitor for any deltas henceforth
thingShadows.on('delta',stateObject) {...
在python中,我们可以使用以下代码来监控增量:
deviceShadowHandler = myAWSIoTMQTTShadowClient.createShadowHandlerWithName(thingName,True)
deviceShadowHandler.shadowRegisterDeltaCallback(customShadowCallback_Delta)
Bu等于在重新连接后立即断开连接并立即获得增量状态(例如JavaScript示例中的initialGetClientToken和状态事件处理程序)是什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)