问题描述
我将 IoT 代理与 Ultralight 直接运行一起使用(而不是作为 dockerized 组件)。我可以注册在 Orion Context broker 中映射的新设备。但是,我在注册需要配置数据中的命令的执行器时遇到问题。我使用:
curl -iX POST \
'http://MYIP:4061/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"devices": [
{
"device_id": "lamp003","entity_name": "urn:ngsi-ld:Lamp:003","entity_type": "Lamp","protocol": "PDI-IoTA-UltraLight","transport": "MQTT","commands": [
{"name": "on","type": "command"},{"name": "off","type": "command"}
]}
]
}
作为回应,我很震惊:
op=IoTAgentNGSI.DeviceProvisioning |从=n/a | srv=n/a | subsrv=n/a | msg=由于以下错误,设备配置失败:| comp=IoTAgent 连接到上下文代理的请求错误: {"code":"400","reasonPhrase":"Bad Request","details":"missing isDomain 注册属性值"}
我尝试将 "isDomain": "false" 添加到命令表的元素中,但没有成功。它以前可以工作,而且 official guide 上提供了类似的解决方案。
解决方法
isDomain
部分 已弃用 NGSI-v1 语法。它未用于 NGSI-v2 或 NGSI-LD
我认为您可能将 IoT 代理作为 NGSI-v1 运行。您需要在 contextBroker.ngsiVersion
中设置 config.js
或设置以下 Env variable in Docker 或 Docker-compose。
IOTA_CB_NGSI_VERSION=v2
config.js
{
host: '192.168.56.101',port: '1026',ngsiVersion: 'v2'
}