问题描述
我对fiware IoT Agent JSON感兴趣,我试图解决问题。 我想使用this教程来安装IoT Agent JSON。 本教程介绍了IoT执行器连接,要检查连接,我们必须POST到{IoTAgentIP:Port} / v2 / op / update。 当我发布到该端点时,我得到:
<html lang="en">
<head>
<Meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /v2/op/update</pre>
</body>
</html>
我的发布命令是:
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update","entities": [
{
"type": "Alarm","id": "urn:ngsi-ld:Alarm:001","ring" : {
"type": "command","value": ""
}
}
]
}'
和
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update","entities": [
{
"type": "Bell","id": "urn:ngsi-ld:Bell:001","value": ""
}
}
]
}'
我的IoT代理版本为:
{
"libVersion": "2.12.0-next","port": 4041,"baseRoot": "/","version": "1.14.0-next"
}
更新-使用IoTA和Orion的最新版本,我在以下IoTA日志文件中获得了
:time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Creating initial entity in the Context broker:
{
"url": "http://localhost:1026/v1/updateContext","method": "POST","json": {
"contextElements": [
{
"type": "Bell","isPattern": "false","attributes": [
{
"name": "refStore","type": "Relationship","value": "urn:ngsi-ld:Store:001"
},{
"name": "ring_status","type": "commandStatus","value": "UNKNowN"
},{
"name": "ring_info","type": "commandResult","value": " "
},{
"name": "TimeInstant","type": "ISO8601","value": " "
}
]
}
],"updateAction": "APPEND"
},"headers": {
"fiware-service": "openiot","fiware-servicepath": "/","fiware-correlator": "7c9fba8d-9262-4f81-9b4e-f71ab57953ff"
}
} | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=executeWithSecurity | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Bell"} | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Bell"}] | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group for fields: [\"type\"] and values: {\"type\":\"Bell\"}","code":404} in get group device | comp=IoTAgent
time=2020-10-22T20:46:49.097Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Initial entity created successfully. | comp=IoTAgent
解决方法
我设法使其可以与一个服务组(/ iot / d)一起使用。因此,Post附加传感器的请求来自/ iot / d服务组。
我使用docker映像(与docker compose编译,如示例所示)。
我还在docker文件中修改了IOTA_DEFAULT_RESOURCE,以防万一:
IOTA_DEFAULT_RESOURCE=
我使用了最新的IoT Agent JSON 1.15.0和以前的Orion版本2.4.0。