Open DiEVeXx opened 5 years ago
As you can see in https://fiware-iotagent-lwm2m.readthedocs.io/en/latest/deviceProvisioning/, you should use fiware-service
in the headers of your requests in lowercase. So instead of Factory
, please use factory
.
Also confirm the name of the entity in the Context Broker. In my tests, instead of robot1
is Robot:robot1
.
Hi, after the changes I'm having new problems.
I just deleted all my DB and deleted my service provisioning.
I just changed the fiware-service to factory
and removed the line in the dynamic device provisioning "entity_name": "robot1",
to make the system concatenate the entity_type:device_id
for the id.
Orion returns in retrieve entities:
[
{
"id": "Robot:robot1",
"type": "Robot",
"Battery": {
"type": "number",
"value": " ",
"metadata": {}
},
"Position_info": {
"type": "commandResult",
"value": " ",
"metadata": {}
},
"Position_status": {
"type": "commandStatus",
"value": "UNKNOWN",
"metadata": {}
},
"Message": {
"type": "string",
"value": "First robot here",
"metadata": {}
},
"Position": {
"type": "string",
"value": "[0, 0]",
"metadata": {}
}
}
]
First question: Why is IoTAgent uploading lazy attributes to Orion? So now, my queryContext request for a lazy attribute is this:
curl -X POST \
http://192.168.1.32:1026/v1/queryContext \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 00efb112-2917-404a-8fc1-da6de93716a5' \
-H 'cache-control: no-cache' \
-H 'fiware-service: factory' \
-H 'fiware-servicepath: /robots' \
-d '{
"entities": [
{
"type": "Robot",
"isPattern": "false",
"id": "Robot:robot1"
}
],
"attributes": [
"Message"
]
}'
it returns:
{
"contextResponses": [
{
"contextElement": {
"type": "Robot",
"isPattern": "false",
"id": "Robot:robot1",
"attributes": [
{
"name": "Message",
"type": "string",
"value": "First robot here"
}
]
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
But when I try to update the lazy 'Message' value using:
curl -X POST \
http://192.168.1.32:1026/v1/updatecontext \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 1ccc1d90-9172-4a85-93aa-5a2893a4fb61' \
-H 'cache-control: no-cache' \
-H 'fiware-service: factory' \
-H 'fiware-servicepath: /robots' \
-d '{
"contextElements": [
{
"type": "Robot",
"isPattern": "false",
"id": "Robot:robot1",
"attributes": [
{
"name": "Message",
"type": "string",
"value": "SOS!"
}
]
}
],
"updateAction": "UPDATE"
}'
I get:
{
"errorCode": {
"code": "404",
"reasonPhrase": "No context element found",
"details": "error forwarding update"
}
}
this is the log:
iotagent_1 | time=2019-02-08T08:08:49.250Z | lvl=DEBUG | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=7e0537ee-3c70-4692-bef3-a3d673bdb436 | op=IoTAgentNGSI.GenericMiddlewares | srv=factory | subsrv=/robots | msg=Request for path [//updateContext] from [iotagent:4041] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.250Z | lvl=DEBUG | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=7e0537ee-3c70-4692-bef3-a3d673bdb436 | op=IoTAgentNGSI.GenericMiddlewares | srv=factory | subsrv=/robots | msg=Body:
iotagent_1 | {
iotagent_1 | "contextElements": [
iotagent_1 | {
iotagent_1 | "type": "Robot",
iotagent_1 | "isPattern": "false",
iotagent_1 | "id": "Robot:robot1",
iotagent_1 | "attributes": [
iotagent_1 | {
iotagent_1 | "name": "Message",
iotagent_1 | "type": "string",
iotagent_1 | "value": "SOS!"
iotagent_1 | }
iotagent_1 | ]
iotagent_1 | }
iotagent_1 | ],
iotagent_1 | "updateAction": "UPDATE"
iotagent_1 | }
iotagent_1 | | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.251Z | lvl=DEBUG | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=7e0537ee-3c70-4692-bef3-a3d673bdb436 | op=IoTAgentNGSI.ContextServer | srv=factory | subsrv=/robots | msg=Handling update from [iotagent:4041] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.251Z | lvl=DEBUG | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=7e0537ee-3c70-4692-bef3-a3d673bdb436 | op=IoTAgentNGSI.ContextServer | srv=factory | subsrv=/robots | msg=[object Object] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.251Z | lvl=DEBUG | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=7e0537ee-3c70-4692-bef3-a3d673bdb436 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=factory | subsrv=/robots | msg=Looking for device with name [Robot:robot1]. | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.255Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["service","subservice","type"] with queryObj {"service":"factory","subservice":"/robots","type":"Robot"} | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.256Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["service","subservice","type"]] not found: [{"service":"factory","subservice":"/robots","type":"Robot"}] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.257Z | lvl=ERROR | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.Alarms | srv=n/a | subsrv=n/a | msg=Raising [MONGO-ALARM]: {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group","code":404} | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.257Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=deviceData: {"lazy":[{"name":"Message","type":"string","object_id":"Message"}],"active":[{"name":"Battery","type":"number","object_id":"Battery"}],"commands":[{"name":"Position","type":"location","object_id":"Position"}],"staticAttributes":[],"subscriptions":[],"_id":"5c5d373b99391b001423dff5","creationDate":"2019-02-08T08:00:59.203Z","id":"robot1","type":"Robot","name":"Robot:robot1","service":"factory","subservice":"/robots","registrationId":"5c5d373be5fdde598ad1b046","internalId":null,"internalAttributes":{"lwm2mResourceMapping":{"Battery":{"objectType":7392,"objectInstance":0,"objectResource":1},"Message":{"objectType":7392,"objectInstance":0,"objectResource":2},"Position":{"objectType":7392,"objectInstance":0,"objectResource":3}}}} | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.257Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=deviceData2: {"lazy":[{"name":"Message","type":"string","object_id":"Message"}],"active":[{"name":"Battery","type":"number","object_id":"Battery"}],"commands":[{"name":"Position","type":"location","object_id":"Position"}],"staticAttributes":[],"subscriptions":[],"_id":"5c5d373b99391b001423dff5","creationDate":"2019-02-08T08:00:59.203Z","id":"robot1","type":"Robot","name":"Robot:robot1","service":"factory","subservice":"/robots","registrationId":"5c5d373be5fdde598ad1b046","internalId":null,"internalAttributes":[{"lwm2mResourceMapping":{"Battery":{"objectType":7392,"objectInstance":0,"objectResource":1},"Message":{"objectType":7392,"objectInstance":0,"objectResource":2},"Position":{"objectType":7392,"objectInstance":0,"objectResource":3}}}]} | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.257Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IOTAgent.NGSIHandlers | srv=n/a | subsrv=n/a | msg=Handling device data update from the north port for device [Robot:robot1] of type [Robot] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.258Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IOTAgent.NGSIHandlers | srv=n/a | subsrv=n/a | msg=New attributes;
iotagent_1 | [object Object] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.258Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Looking for device with name [Robot:robot1]. | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.260Z | lvl=ERROR | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.Alarms | srv=n/a | subsrv=n/a | msg=Releasing [MONGO-ALARM] | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.260Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=n/a | subsrv=n/a | msg=Looking for device with name [Robot:robot1]. | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.262Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Selecting ID from the stored device data | comp=IoTAgent
iotagent_1 | time=2019-02-08T08:08:49.262Z | lvl=DEBUG | corr=31f6217e-704c-48ce-a59a-47a1ff244ee4 | trans=31f6217e-704c-48ce-a59a-47a1ff244ee4 | op=LWM2MLib.DeviceManagement | srv=n/a | subsrv=n/a | msg=Writting a new value [SOS!] on resource /7392/0/2 in device [2] | comp=IoTAgent
orion_1 | time=Friday 08 Feb 08:08:54 2019.246Z | lvl=ERROR | corr=c3caf7e0-2b78-11e9-a143-0242ac130004 | trans=1549612847-482-00000000028 | from=192.168.1.32 | srv=factory | subsrv=/robots | comp=Orion | op=postUpdateContext.cpp[190]:updateForward | msg=Runtime Error (error 'Timeout was reached' forwarding 'Update' to providing application)
Thank you in advance.
I'm trying to follow Robot's example: https://fiware-iotagent-lwm2m.readthedocs.io/en/latest/deviceProvisioning/
Using dynamic provisioning in the latest stable version of Fiware/Orion. Virtual Device data: (following this: https://github.com/telefonicaid/lwm2m-node-lib)
Here I show the Dockerfile:
Here I show the config.js file:
retrieve devices provisioning returns:
retrieve entities v2:
returns me:
Well, now i cant access to lazy values or modify them
returns:
Server log when i try to get a lazy value :
I could also show the log when I try to modify the value of the 'Message' lazy attribute. but this issue seems long enough.
It works flawless using this docker images: iotagent: hopu/lwm2m-iotagent:observe-and-read orion: fiware/orion:2.0.0