我在使用 IDAS Iotagent 时遇到问题。使用 MQTT Ultralight 代理,根据我注册设备的方式,当代理收到读取时,iotagent 服务崩溃,并且上下文代理中的相关实体未更新。
正确的行为是下一个。如果创建一个服务:
curl -X POST 172.21.0.23:8090/iot/services \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: red_entrada _1" \
-H "Fiware-ServicePath: /Prueba" \
-d '{
"services": [
{
"apikey": "pass_1",
"cbroker": "http://172.21.0.23:1026",
"entity_type": "disp_entrada_1",
"resource": "/iot/mqtt"
}]}'
...和一个设备,为每个属性建立传入属性和名称:
curl -X POST 172.21.0.23:8090/iot/devices \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: red_entrada _1" \
-H "Fiware-ServicePath: /Prueba" \
-d '{
"devices":[
{
"device_id": "AC_2",
"entity_name":"disp_entrada_1:AC_2",
"protocol":"PDI-IoTA-MQTT-UltraLight",
"entity_type": "disp_entrada_1",
"timezone": "Europe/Madrid",
"attributes": [
{
"object_id": "LUX",
"name": "LUX_1",
"type": "string"
},
{
"object_id": "LUM",
"name": "LUM_1",
"type": "string" },
{
"object_id": "HUMB",
"name": "HUMB_1",
"type": "string"
},
{
"object_id": "TCB",
"name": "TCB_1",
"type": "string"
},
{
"object_id": "IN_TEMP",
"name": "IN_TEMP_1",
"type": "string" },
{
"object_id": "BAT",
"name": "BAT_1",
"type": "string"
}
]}]}'
因此,上下文代理中会创建一个新实体,并且当读数到达代理时,该实体就会更新:
{
"_id" : {
"id" : "disp_entrada_1:AC_2",
"type" : "disp_entrada_1",
"servicePath" : "/Prueba"
},
"attrNames" : [
"TimeInstant",
"LUX_1",
"LUM_1",
"HUMB_1",
"TCB_1",
"IN_TEMP_1",
"BAT_1"
],
"attrs" : {
"TimeInstant" : {
"value" : "2016-03-14T08:11:49.810465Z",
"type" : "ISO8601",
"creDate" : 1457943015,
"modDate" : 1457943109
},
"LUX_1" : {
"value" : "464.000",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.687585Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
},
"LUM_1" : {
"value" : "2.694",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.718131Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
},
"HUMB_1" : {
"value" : "38.7",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.748719Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
},
"TCB_1" : {
"value" : "21.31",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.779327Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
},
"IN_TEMP_1" : {
"value" : "21.00",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.810465Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
},
"BAT_1" : {
"value" : "97",
"type" : "string",
"md" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2016-03-14T08:11:49.230590Z"
}
],
"creDate" : 1457943103,
"modDate" : 1457943109
}
},
"creDate" : 1457943015,
"modDate" : 1457943109
}
当我注册一个新设备并使用与“object_id”相同的值(传入 MQTT 数据的属性名称)作为属性名称时,就会出现问题。当然,在这种情况下,无需注册设备)。例如:
curl -X POST 172.21.0.23:8090/iot/devices \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: red_entrada_2" \
-H "Fiware-ServicePath: /Prueba" \
-d '{
"devices":[
{
"device_id": "AC_2",
"entity_name":"disp_entrada_1:AC_2",
"protocol":"PDI-IoTA-MQTT-UltraLight",
"entity_type": "disp_entrada_1",
"timezone": "Europe/Madrid",
"attributes": [
{
"object_id": "LUX",
"name": "LUX",
"type": "string"
},
{
"object_id": "LUM",
"name": "LUM",
"type": "string"
},
{
"object_id": "HUMB",
"name": "HUMB",
"type": "string"
},
{
"object_id": "TCB",
"name": "TCB",
"type": "string"
},
{
"object_id": "IN_TEMP",
"name": "IN_TEMP",
"type": "string"
},
{
"object_id": "BAT",
"name": "BAT",
"type": "string"
}
]}] }'
在这种情况下,也会在上下文代理中创建一个新实体,但当读数到达时,该实体不会更新,并且 IoTAgent 服务崩溃。实体状态:
{
"_id" : {
"id" : " disp_entrada_1:AC_2",
"type" : " disp_entrada_1",
"servicePath" : "/Prueba"
},
"attrNames" : [
"TimeInstant"
],
"attrs" : {
"TimeInstant" : {
"type" : "ISO8601",
"creDate" : 1457948167,
"modDate" : 1457948167,
"value" : "2016-03-14T09:36:07.432814Z"
}
},
"creDate" : 1457948167,
"modDate" : 1457948167
}
我看不出这种行为有任何逻辑。如果我没有事先注册设备,则将自动创建实体,并且属性将以“object_id”字段的值作为名称(这就是我在第二个示例中尝试执行的操作)。
¿可能是由于代理或管理器安装出现问题吗?
最佳答案
实际上这是一个错误,当您将要翻译的参数“t”关联为相同的(“t”)时,会导致无限循环。
最好的解决方案是不要要求任何翻译,然后它将保留为原始版本(“t”)。
在接下来的版本中,该错误将被修复。
感谢您使用 IDAS,对于我们迟到的回复深表歉意!
关于固件-IDAS : Issue with registered device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35989887/