telefonicaid / lightweightm2m-iotagent

IoT Agent accepting COAP requests. Designed to be a bridge between the OMA Lightweight M2M protocol and the NGSI interface.
https://fiware-iotagent-lwm2m.rtfd.io/
GNU Affero General Public License v3.0
24 stars 30 forks source link

Active attributes are not correctly observed #112

Open dcalvoalonso opened 6 years ago

dcalvoalonso commented 6 years ago

We have been doing some integration tests with real devices and the agent is not able to observe active attributes.

I think that this problem is related to https://github.com/telefonicaid/lwm2m-node-lib/issues/110 and https://github.com/telefonicaid/lwm2m-node-lib/pull/111.

dcalvoalonso commented 6 years ago

@fgalan Can you tell us something about this issue? Are you guys supporting https://github.com/telefonicaid/lwm2m-node-lib? @FRDavid @jgato

fgalan commented 6 years ago

Not at the present moment... but of course we will be more than happy to review any PR fixing this issue :)

dcalvoalonso commented 6 years ago

If I am not wrong, there is an open PR to solve https://github.com/telefonicaid/lwm2m-node-lib/issues/110: https://github.com/telefonicaid/lwm2m-node-lib/pull/111

fgalan commented 6 years ago

Thanks for pointing it out! I didn't remember that PR (maybe because if was casted before I start looking to IOTAs stuff :)

So you mean that PR telefonicaid/lwm2m-node-lib#111 solves both issues telefonicaid/lwm2m-node-lib#110 and the present one (#112) isn't it?

fgalan commented 6 years ago

(Btw, I have provided feedback on PR telefonicaid/lwm2m-node-lib#111 . As soon as the comment put there gets addressed -very minor- it will be merged)

fgalan commented 6 years ago

@dcalvoalonso now that PR https://github.com/telefonicaid/lwm2m-node-lib/pull/111 has been merged (and consecuently https://github.com/telefonicaid/lwm2m-node-lib/issues/110 has been closed), should the present issue be closed?

dcalvoalonso commented 6 years ago

Thanks @fgalan. I will do some tests and let you know if it is working now.

letavia commented 5 years ago

What is the status of this? I tried but still CB does not read the active attributes sent by the client (device).

fgalan commented 5 years ago

@letavia could you provide more detail on the test you are doing so that information can be used to reproduce and debug the issue, please?

letavia commented 5 years ago

I followed the instructions for device provisioning.

Here is my device configuration:

fiware-service: factory 
fiware-servicepath: /robots

payload:

{
  "devices": [
      {
        "device_id": "robot1",
        "entity_type": "Robot",
        "entity_name": "robot01",
        "attributes": [
          {
            "name": "Battery",
            "type": "number"
          }
        ],
        "lazy": [
          {
            "name": "Message",
            "type": "string"
          }
        ],
        "commands": [
          {
            "name": "Position",
            "type": "location"
          }
        ],
      "internal_attributes": {
        "lwm2mResourceMapping": {
          "Battery" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 1
          },
          "Message" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 2
          },
          "Position" : {
            "objectType": 7392,
            "objectInstance": 0,
            "objectResource": 3
          }
        }
      }
    }
  ]
}

Then I ran iotagent-lwm2m-client.js with all the suggested commands.

I checked the result in context broker:

http://orion:1026/v2/entities/robot01

{
"id": "robot01",
"type": "Robot",
"Battery": {
  "type": "number",
  "value": " ",
  "metadata": {}
},
"Position_info": {
  "type": "commandResult",
  "value": " ",
  "metadata": {}
},
"Position_status": {
  "type": "commandStatus",
  "value": "UNKNOWN",
  "metadata": {}
},
"TimeInstant": {
  "type": "DateTime",
  "value": "2019-04-24T01:48:14.00Z",
  "metadata": {}
},
"Message": {
  "type": "string",
  "value": "First robot here",
  "metadata": {}
},
"Position": {
  "type": "string",
  "value": "[0, 0]",
  "metadata": {}
}
}

The value for Battery attribute was not updated.

LWM2M Client also showed only lazy and command attributes were read.

LWM2M-Client>
Value read:
--------------------------------
-> ObjectType: 7392
-> ObjectId: 0
-> ResourceId: 2
-> Read Value: First robot here
LWM2M-Client>
Value read:
--------------------------------
-> ObjectType: 7392
-> ObjectId: 0
-> ResourceId: 3
-> Read Value: [0, 0]

Whereas the "attributes" is correctly mapped to "active" in IoT Agent database:

{ "_id" : ObjectId("5cbfc05f1c422f001159da73"), "lazy" : [ { "name" : "Message", "type" : "string", "object_id" : "Message" } ], "active" : [ { "name" : "Battery", "type" : "number", "object_id" : "Battery" } ], "commands" : [ { "name" : "Position", "type" : "location", "object_id" : "Position" } ], "subscriptions" : [ ], "creationDate" : ISODate("2019-04-24T01:48:15.351Z"), "id" : "robot1", "type" : "Robot", "name" : "robot01", "service" : "factory", "subservice" : "/robots", "registrationId" : "5cbfc05e75c52beb3d046835", "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 } } }, "__v" : 0 }

Let me know if you need more info.

letavia commented 5 years ago

any advice on this issue?