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

Lazy and Command Attributes not appearing in CB #184

Closed Ngombo closed 5 years ago

Ngombo commented 5 years ago

I tried to implement the example in https://fiware-iotagent-lwm2m.readthedocs.io/en/latest/deviceProvisioning/index.html but, I am not being able to interact with both Lazy and Command attributes from the Broker. I tried with Orion V1 and V2 querying both from Postman and .sh files and the error code below remains.

{
"errorCode": {
    "code": "404",
    "reasonPhrase": "No context element found"
}

}

The readings work just perfectly. Hence, I can see the updated active attributes values in Broker when running a series of SET > in the LwM2M client.js.

Both Fiware GEs (Agent and Broker) are running in the same VMWare Workstation/Fiware Instance.

Following I have the main configurations I am using and can share more details if needed. Any help will be more than welcome!


1) docker-compose.yml

version: '2'
services:
 mongodb:
    image: fiware/tutorials.tourguide-app.restaurant-data:20161011
    hostname: mongodb
    container_name: mongodb
    ports:
      - "27017:27017"
    expose:
    - '27017'
    command: --smallfiles
    logging:
       options:
         max-size: 50m
 orionunified:
    image: fiware/orion:2.1.0
    hostname: orionunified
    container_name: orionunified
    links:
    - mongodb
    expose:
    - '1026'
    ports:
    - 9014:1026
    command: -dbhost mongodb
    logging:
       options:
         max-size: 50m
 idaslwm2m:
    image: telefonicaiot/lightweightm2m-iotagent:latest
    hostname: idaslwm2m
    container_name: idaslwm2m
    restart: on-failure
    links:
    - orionunified
    - mongodb:mongo
    expose:
    - '5684'
    - '4041'
    ports:
    - 9008:4041
    - 9009:5684
    volumes:
    - ./configurations/IdasLWM2M/config.js:/opt/iota-lwm2m/config.js
    logging:
       options:
         max-size: 50m

2) ./configurations/IdasLWM2M/config.js:/opt/iota-lwm2m/config.js EQUALS to lightweightm2m-iotagent/config.js

var config = {};
config.lwm2m = {
    logLevel: 'DEBUG',
    port: 5684,
    defaultType: 'Robot',
    ipProtocol: 'udp4',
    serverProtocol: 'udp4',

    delayedObservationTimeout: 50,
    formats: [
        {
            name: 'application-vnd-oma-lwm2m/text',
            value: 1541
        },
        {
            name: 'application-vnd-oma-lwm2m/tlv',
            value: 1542
        },
        {
            name: 'application-vnd-oma-lwm2m/json',
            value: 1543
        },
        {
            name: 'application-vnd-oma-lwm2m/opaque',
            value: 1544
        }
    ],
    writeFormat: 'application-vnd-oma-lwm2m/text',
    types: [ ]
};

config.ngsi = {
    logLevel: 'DEBUG',
    contextBroker: {
        host: 'orionunified',
        port: '1026'
    },
    server: {
        port: 4041
    },
    deviceRegistry: {
        //type: 'memory'
        type: 'mongodb'
    },
    mongodb: {
        host: 'mongo',
        port: '27017',
        db: 'iotagentlm2m'
        //replicaSet: ''
    },
    types: { },
    service: 'factory',
    subservice: '/robots',
    providerUrl: 'http://idaslwm2m:4041',
    deviceRegistrationDuration: 'P1Y',
    defaultType: 'Robot'
};

module.exports = config;

3) Device created in Agent

{
    "count": 1,
    "devices": [
        {
            "device_id": "robot1",
            "service": "factory",
            "service_path": "/robots",
            "entity_name": "Robot:robot1",
            "entity_type": "Robot",
            "attributes": [
                {
                    "object_id": "Battery",
                    "name": "Battery",
                    "type": "number"
                }
            ],
            "lazy": [
                {
                    "object_id": "Message",
                    "name": "Message",
                    "type": "string"
                }
            ],
            "commands": [
                {
                    "object_id": "Position",
                    "name": "Position",
                    "type": "location"
                }
            ],
            "static_attributes": [],
            "internal_attributes": {
                "lwm2mResourceMapping": {
                    "Battery": {
                        "objectType": 7392,
                        "objectInstance": 0,
                        "objectResource": 1
                    },
                    "Message": {
                        "objectType": 7392,
                        "objectInstance": 0,
                        "objectResource": 2
                    },
                    "Position": {
                        "objectType": 7392,
                        "objectInstance": 0,
                        "objectResource": 3
                    }
                }
            }
        }
    ]
}

4) Entity created in the Broker, with an updated Active attribute reading

{
    "contextResponses": [
        {
            "contextElement": {
                "type": "Robot",
                "isPattern": "false",
                "id": "Robot:robot1",
                "attributes": [
                    {
                        "name": "Battery",
                        "type": "number",
                        "value": "1200"
                    },
                    {
                        "name": "Position_info",
                        "type": "commandResult",
                        "value": " "
                    },
                    {
                        "name": "Position_status",
                        "type": "commandStatus",
                        "value": "UNKNOWN"
                    }
                ]
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}

* P.S Related to the what I think "not answered" issue in https://stackoverflow.com/questions/34004222/fiware-iotagent-cant-send-command-to-a-device,

fgalan commented 5 years ago

StackOverflow is the way to go. Great!

This issue is somehow redundant and I think it should be closed.

Ngombo commented 5 years ago

Hi Fermín and thanks for the reply.

Indeed, I saw some issues related to it but I am afraid the question was not answered. So, I openned another one. Maybe I am wrong and this issue is somehow redundant. Can you share with me the link where the issue has been overcome, please?

Best regards,

fgalan commented 5 years ago

What I mean with "the issue is redundant" is that given the question has been already posted in StackOverflow, it should be answered there. The issue is a "duplicated" and can be closed.

I hope to have clarified.

Ngombo commented 5 years ago

Hmm, closed by the Stackoverflow moderator, you mean?

I really think it is not redundant but maybe it is rather related to a previous issue that was not necessarily overcome, neither.

Does it mean that maybe you guys from Telefónica/Fiware could answer to the issue directly from stackoverflow?

I am really sorry for insisting on the same points. In the end it is just a normal research interaction.

Regards,

fgalan commented 5 years ago

See https://github.com/telefonicaid/lightweightm2m-iotagent/issues/183#issuecomment-472476538