【发布时间】:2018-01-09 08:21:44
【问题描述】:
我正在尝试将 Orion CB 用作 IoT 代理的 Contex 提供程序,我在其中注册了仅具有惰性属性的设备。
在 IoT 代理上,我需要处理 updateContext 请求,因此我为这些请求做了一个处理程序,如下所示:
iotAgentLib.setDataUpdateHandler(updateContextHandler);
而在 updateContextHandler 函数中我只有一条指令:
console.log(attributes);
为了查看我要更新的所有值是否都已正确接收。
现在,如果我对设备表示的实体的属性之一进行更新:
curl -i -X POST \
-H "fiware-service:service1" \
-H "fiware-servicepath:/subservice1" \
-H "X-Auth-Token:wNRwDwqYlLoLD8U9sFkTAEE6PfYMbQ" \
-H "Content-Type:application/json" \
-d \
'{
"contextElements": [
{
"id": "ncc_estimate",
"attributes": [
{
"name": "arrival",
"type": "string",
"value": "some_value"
}
]
}
],
"updateAction": "UPDATE"
} ' \
'http://{orion_address}/v1/updateContext'
我在 IoT 代理输出控制台上看到的是:
time=2018-01-09T08:14:59.539Z | lvl=DEBUG | corr=2f4fdb0c-f515-11e7-86b2-0242ac110003 | trans=6ac5c35d-d7bf-419c-8f64-bc843b991d47 | op=IoTAgentNGSI.GenericMiddlewares | srv=service1 | subsrv=/subservice1 | msg=Body:
{
"contextElements": [
{
"type": "nccestimate",
"isPattern": "false",
"id": "ncc_estimate",
"attributes": [
{
"name": "arrival",
"type": "string",
"value": ""
}
]
}
],
"updateAction": "UPDATE"
}
你可以看到 value 字段是空的,我也可以从 UpdateHandler 函数中的 console.log() 输出中看到:
[ { name: 'arrival', type: 'string', value: '' } ]
似乎 Orion 在将其发送到 IoT 代理之前删除了该值。可能是什么问题呢?我做错了什么吗?
编辑:
这是对调用的响应:/v1/registry/contextEntities/ncc_estimate
{"contextRegistrationResponses":[
{"contextRegistration":
{"entities":[
{
"type":"nccestimate",
"isPattern":"false",
"id":"ncc_estimate"
}
],
"attributes":[
{
"name":"transport_type",
"type":"string",
"isDomain":"false"
},
{
"name":"arrival",
"type":"string",
"isDomain":"false"
}
],
"providingApplication":"http://192.168.199.151:4044"}
}
]}
编辑2:
这是 Orion 在执行前面描述的 updateContext 操作时向 iot 代理发送的内容:
POST //updateContext HTTP/1.1
User-Agent: orion/1.10.0-next libcurl/7.19.7
Host: 192.168.199.151:4044
fiware-service: service1
Fiware-ServicePath: /subservice1
X-Auth-Token: M62UkJc7yKX5aQwaHrsODfIrV4Ou85
Accept: application/json
Content-length: 169
Content-type: application/json; charset=utf-8
Fiware-Correlator: 42561e9a-f615-11e7-8610-0242ac110003
{"contextElements":[{"type":"nccestimate","isPattern":"false","id":"ncc_estimate","attributes":[{"name":"arrival","type":"string","value":""}]}],"updateAction":"UPDATE"}
如您所见,该属性的“值”字段为空。 我正在使用 Orion 1.10.0 版和 iot 代理节点库 2.5.1 版。
【问题讨论】:
-
惰性属性基于 IOTA 在配置时在 CB 创建的注册。这将是一个非常有用的信息,可以找出可能发生的事情。请检查与设备关联的 CB 注册(请参阅fiware-orion.readthedocs.io/en/master/user/walkthrough_apiv1/… 了解如何在 CB 发现现有注册)并编辑您的问题帖子以包含它。谢谢!
-
我已经添加了您要求的内容,希望对您有所帮助。谢谢。
-
注册好像没问题,它包含了lazy属性。让我们检查 Orion 实际发送的内容,以丢弃 IOTA 日志系统中的错误。为此,只需在配置设备后停止 IOTA,它们会在同一端口(如
nc或netcat)启动侦听器进程。然后,更新 CB 的属性并检查您在侦听器进程中获得的内容。请编辑包含该信息的问题帖子。 -
此外,如果您在问题帖子中添加有关正在使用的 IOTA 和 Orion 版本的信息,那就太好了。
-
我已经添加了您要求的内容。如您所见,没有任何值从 Orion 发送到 IoT 代理。
标签: fiware fiware-orion