我想使用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,我确实会得到预期的元数据,但这需要每个设备都有一个请求,这会变得太慢,并占用大量资源。Bug还是设计?
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'
}发布于 2021-01-11 16:03:59
我已经用设备列表功能做了一些尝试,我认为这是一个设计。
如果运行"gcloud iot devices list" command,您只会得到字段id和num_id,这两个字段也会填充到输出数组中。
我尝试使用其他客户端库,得到了相同的结果,所以它看起来是这样设计的,但NodeJS库为每个设备检索额外的字段。
发布于 2021-04-21 19:38:04
在listDevices接口的fieldMask参数中定义。请查看此处的示例代码:
https://cloud.google.com/iot/docs/how-tos/devices?authuser=1#getting_device_details
https://stackoverflow.com/questions/65545576
复制相似问题