【问题标题】:How to get active device list from Google Cloud IoT core如何从 Google Cloud IoT 核心获取活动设备列表
【发布时间】:2019-10-23 05:22:45
【问题描述】:

我在 Firebase/Firestore 项目中使用 Google 的 cloud-iot-core。我的 iot 核心注册表中有设备,我想使用命令或使用 iot 核心库(Java/Python)从 iot 核心获取活动设备。我想在 android 应用程序以及 Firebase/Firestore 中显示/更新活动设备。我怎样才能做到这一点??

【问题讨论】:

    标签: firebase google-cloud-platform google-cloud-firestore iot


    【解决方案1】:

    Google Cloud IoT 公开了一个 REST 接口,可用于询问设备的状态。具体来说,有一个名为 projects.locations.registries.devices.list 的 API,可用于返回所有设备的列表。

    https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries.devices/list

    使用此 API,您可以返回设备对象列表:

    https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries.devices#Device

    其中包含每个设备的标识以及lastHeartbeatTime 等字段。在您最初的问题中,您没有定义 active 的含义,因为它与设备相关,所以我假设它是 lastHeartbeatTime 或 lastEventTime。

    【讨论】:

    • 我正在使用 MQTT 连接到云物联网核心,我想要当前连接/活动或实时的设备。
    • 这种方法的问题是这些字段在我得到的响应中是空的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 2015-12-08
    相关资源
    最近更新 更多