lightweightm2m-iotagent
lightweightm2m-iotagent copied to clipboard
Execute resource without provide value
Hello,
We didn't find a way to execute a resource without provide an attribute value. Maybe someone knows how to carry out this?
We used a query such as the next one:
(curl http://127.0.0.1:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'fiware-service: HOPBeacon' --header 'fiware-servicepath: /hopbeacon' \
-d @- | python -mjson.tool) <<EOF
{
"contextElements": [
{
"type": "HOPBeacon",
"isPattern": "false",
"id": "HOPe0e5cfb1f4df",
"attributes": [
{
"name": "Temperature Reset Min and Max Measured Values",
"type": "String",
"value": ""
}
]
}
],
"updateAction": "UPDATE"
}
EOF
When value field is empty or value field is not present, the next error is raised in the Lightweight-IOTAgent:
time=2016-11-16T17:53:00.330Z | lvl=DEBUG | corr=n/a | trans=n/a | op=LWM2MLib.DeviceManagement | msg=Writting a new value [function (err, v) {
results[index] = v;
callback(err);
}] on resource /3303/0/5605 in device [1]
time=2016-11-16T17:55:25.859Z | lvl=FATAL | corr=n/a | trans=n/a | op=n/a | msg=An unexpected exception has been raised. Ignoring: TypeError: Invalid non-string/buffer chunk
And the query receives the next response:
{
"errorCode": {
"code": "404",
"details": "error forwarding update",
"reasonPhrase": "No context element found"
}
}
This is what happen in our devices in case of specify a dummy value:

And the query receives the next response:
{
"errorCode": {
"code": "404",
"reasonPhrase": "No context element found"
}
}
Not all the available LwM2M Clients are able to manage this extra value.
If there is no way to send an execute command without value, send a dummy value isn't a correct behaviour to execute some resources in LwM2M, most of the executable resources does not receive value, some example of executable resources without value are:
- Reset device (3/0/4)
- Factory reset (3/0/5)
- Registration Update Trigger (1/0/8)
- Reset Min/Max values for some sensor (some IPSO objects)
- ...
We expect to hear about other way to carry out this, but in the meantime we introduced a condition to allow execute commands without specify a value.

and the query result is ok:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "Temperature Reset Min and Max Measured Values",
"type": "String",
"value": ""
}
],
"id": "HOPe0e5cfb1f4df",
"isPattern": "false",
"type": "HOPBeacon"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Tests are passed correctly.
BR, David