Google IoT核心连接状态 [英] Google iot core connection status

查看:130
本文介绍了Google IoT核心连接状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Google IOT核心与猫鼬os一起使用.我想将设备连接状态更新为Firestore.但是我找不到像设备断开连接或重新连接时(例如,设备是否脱机)向pub/sub报告mqtt连接状态的事件.

I am using Google IOT core with mongoose os. I wanted to update device connection status to firestore. But i am unable to find event which reports mqtt connection status to pub/sub like when device disconnects or reconnect i.e if device is offline or not.

我在这个问题上困扰了好几天.任何帮助将不胜感激

I am stuck on this problem for days.Any help will be appreciated

推荐答案

更新

@devunwired在此回复中提到 现在可以监视Stackdriver日志中的断开事件.您必须至少在IoT核心版>注册表> [您的注册表]>编辑注册表>选择信息"日志级别>项目中单击启用的INFO级别登录项目.

As @devunwired mentioned in this response it is now possible to monitor Stackdriver logs for disconnect events. You must have at a minimum enabled INFO level logging on your project in IoT Core > Registries > [your registry] > Edit Registry > Select "Info" log level > Click save.

原始回复

您可以查看一些在设备配置元数据中跟踪的值,这些值可用于了解设备上次在线的时间:

There are a few values you can look at that are tracked in device configuration metadata that you could use to know when a device last was online:

  1. 上次配置发送时间-您的设备连接时随时发送/ 配置发布
  2. 上次事件时间-上次从设备发送事件的时间
  3. 上次状态时间-上次从设备发送状态的时间
  4. 上次心跳时间-上次发送MQTT心跳的时间
  1. Last Configuration Send time - sent anytime your device connects / configuration is posted
  2. Last Event Time - Last time an event was sent from the device
  3. Last State Time - Last time state was sent from the device
  4. Last Heartbeat time - Last time MQTT heartbeat was sent

要开始使用,请

To get you started, here is an example using API explorer that you can fill-in with your project ID, region, registry, and device to query for a specific device's metadata.

对于1 ... 3,您可以通过设备管理器和发布数据来控制它们.如果您的设备在"ping期间"发送了MQTT_PINGREQ消息而没有其他消息被发送,则MQTT心跳将被更新.

For 1...3 you have control over these through device manager and by publishing data. MQTT heartbeat is updated if your device sends an MQTT_PINGREQ message during the "ping period" without other messages getting sent.

无论如何,您都可以使用这些更新时间值中的任何一个来查看设备上次上线/运行的时间.您可以在注册表中列出设备后查询设备的状态,并可以定期更新Firebase RTDB(如果要使用这种方式进行报告)(例如,使用AppEngine TaskQueue).请注意,您也可以从 Google云控制台中获取这些最后连接"的值.

At any rate, you could use any of these update time values to see the last time a device was online / functioning. You could query the states of your devices after listing the devices in a registry and could update a Firebase RTDB periodically if that's how you want to report (e.g. using AppEngine TaskQueue). Note that you also just can get these "last connected" values from the Google Cloud Console.

之前曾说过,但是我们没有断开连接的事件,只有配置确认,通常是连接事件.如果要在设备和设备管理器之间共享状态,请使用状态消息.

It was said before but we don't have an event for disconnect, just configuration ack, which generally is the connection event. If you want to share state between a device and the device manager, use state messages.

这篇关于Google IoT核心连接状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆