【发布时间】:2021-01-03 00:37:22
【问题描述】:
我想使用 listDevices 将我的所有设备都放在注册表下。 Google NodeJS Core IOT API spec
我得到了一个数组,它似乎包含一个元数据 obj/json 文档,但它是空的。
---
- credentials: []
metadata: {}
id: device001
name: ''
numId: '3038801391636994'
config:
lastConfigAckTime:
state:
lastConfigSendTime:
blocked: false
lastStateTime:
logLevel: LOG_LEVEL_UNSPECIFIED
gatewayConfig:
- credentials: []
metadata: {}
id: device002
name: ''
numId: '2991873732633082'
config:
lastConfigAckTime:
state:
lastConfigSendTime:
blocked: false
lastStateTime:
logLevel: LOG_LEVEL_UNSPECIFIED
gatewayConfig:
如果我运行 getDevice,我确实会得到预期的元数据,但这需要对每个设备发出请求,这会变得太慢并且会占用资源。错误还是设计?
const [response] = await iotClient.getDevice({name: devicePath});
实际显示元数据
Found device: device002 {
credentials: [
{
expirationTime: [Object],
publicKey: [Object],
credential: 'publicKey'
}
],
metadata: {
hasGPS: 'true',
model: 'Pyton_v1',
hasSolar: 'true',
netType: 'WIFI'
},
id: 'device002'
}
【问题讨论】:
-
您的数据似乎已在 YAML 中列出,并显示了一组看似设备的内容。所以你已经完成了任务......你已经在注册表下检索了设备。我们似乎看到“元数据”字段为空。您对存在与 device001 或 device002 关联的元数据有多大把握?
-
@Kolban 我更新了我的问题以包含 getDevices(registry) 中列出的设备之一的 getDevice(deviceid) 打印输出。在那里。但也许它的意思是空的?我正在尝试查找模型类型为“Python_v1”的设备。 API Doc提到元数据没有被索引等等,但我可以在客户端过滤它。
标签: google-cloud-platform google-cloud-iot