2
votes

I'm a Fiware user and i deployed an orion context broker GE , cepheus GE and an iotagent-ul instances in different VMs on cloud. I have registered a device in the iot agent specifying a command attribute in the register request and its corresponding entity was created in the context broker on the registration process. Now when i register a device with its attributes and the command attribute with its name and type , the device is registered on the iot agent and its entity is also created in the context broker . But the strange thing that happens is that the command attribute is only translated into its special attributes which are the commandName_info and commandName_status but the command attribute itself is not shown among them in the registration result in the iot agent logs .In addition, when i do an update operation on the command attribute in the Orion context broker , the attribute is not recognized and the update fails as the command attribute is missing in the entitiy itself . And the registration process is as follows:

  • this is the registration request that i send :

(curl -v -H 'content-type: application/json' -H 'fiware-service: ourservicename' -H 'fiware-servicepath: /ourservicpath' -X POST 'http://iotagentULaddress:8080/iot/devices' -d @- ) << EOF

{
"`devices`": [
    {
        "device_id": "controller12",
        "entity_name": "labcontroller12",
        "entity_type": "Controller",
        "isPattern" :"false",
        "protocol": "IoTA-UL",
        "timezone": "Egypt/Cairo",
        "endpoint": "http://iotagentULaddress:8080",
        "attributes": [
        {
            "object_id": "n",
            "name": "number",
            "type": "string"
        }],
        "commands": [{
            "name": "play",
            "type": "string"
        }]
    }]
}
EOF

And this is the registration result in the iot agent's logs showing the registered entity and how it is created in the context broker:

time=2017-03-06T18:10:56.335Z | lvl=DEBUG | corr=dee16709-4b99-4336-b23a-722878a8b628 | trans=dee16709-4b99-4336-b23a-722878a8b628 | op=IoTAgentNGSI.ContextServer | srv=n/a | subsrv=n/a | msg=Successfully subscribed to the following topics:
["/+/+/attrs/+","/+/+/attrs","/+/+/cmdexe"]
 | comp=IoTAgent
{"op":"IOTAUL.Executable","time":"2017-03-06T18:10:56.427Z","lvl":"INFO","msg":"Ultralight 2.0 IoT Agent started"}
time=2017-03-06T18:12:14.459Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.GenericMiddlewares | srv=hi | subsrv=/hi | msg=Request for path [/iot/devices] from [217.172.12.190:8080] | comp=IoTAgent
time=2017-03-06T18:12:14.460Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.GenericMiddlewares | srv=hi | subsrv=/hi | msg=Body:

{
    "devices": [
        {
            "device_id": "controller12",
            "entity_name": "labcontroller12",
            "entity_type": "Controller",
            "isPattern": "false",
            "protocol": "IoTA-UL",
            "timezone": "Egypt/Cairo",
            "endpoint": "http://217.172.12.190:8080",
            "attributes": [
                {
                    "object_id": "n",
                    "name": "number",
                    "type": "string"
                }
            ],
            "commands": [
                {
                    "object_id": "s",
                    "name": "play",
                    "type": "string"
                }
            ]
        }
    ]
}

 | comp=IoTAgent
time=2017-03-06T18:12:14.463Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceProvisioning | srv=hi | subsrv=/hi | msg=Handling device provisioning request. | comp=IoTAgent
time=2017-03-06T18:12:14.464Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Looking for entity params undefined | comp=IoTAgent
Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
time=2017-03-06T18:12:14.473Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Device group for fields [undefined] not found: [{"undefined":"Controller"}] | comp=IoTAgent
time=2017-03-06T18:12:14.473Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.BidirectionalPlugin | srv=hi | subsrv=/hi | msg=Extracting attribute list | comp=IoTAgent
time=2017-03-06T18:12:14.473Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.BidirectionalPlugin | srv=hi | subsrv=/hi | msg=Sending bidirectionality subscriptions for device [controller12] | comp=IoTAgent
time=2017-03-06T18:12:14.474Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Looking for bindings for the function [deviceProvisioningHandler] and protocol [null] | comp=IoTAgent
time=2017-03-06T18:12:14.474Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Binding found for function [deviceProvisioningHandler] and protocol [null] | comp=IoTAgent
time=2017-03-06T18:12:14.475Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=hi | subsrv=/hi | msg=Looking for entity with id [controller12]. | comp=IoTAgent
time=2017-03-06T18:12:14.476Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=hi | subsrv=/hi | msg=Entity [controller12] not found. | comp=IoTAgent
time=2017-03-06T18:12:14.477Z | lvl=ERROR | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.Alarms | srv=hi | subsrv=/hi | msg=Raising [MONGO-ALARM]: undefined | comp=IoTAgent
time=2017-03-06T18:12:14.477Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Looking for entity params undefined | comp=IoTAgent
time=2017-03-06T18:12:14.478Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=hi | subsrv=/hi | msg=Device group for fields [undefined] not found: [{"undefined":"Controller"}] | comp=IoTAgent
time=2017-03-06T18:12:14.479Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Registering device into NGSI Service:
{
    "id": "controller12",
    "type": "Controller",
    "name": "labcontroller12",
    "service": "hi",
    "subservice": "/hi",
    "active": [
        {
            "object_id": "n",
            "name": "number",
            "type": "string"
        }
    ],
    "staticAttributes": [],
    "lazy": null,
    "commands": [
        {
            "object_id": "s",
            "name": "play",
            "type": "string"
        }
    ],
    "timezone": "Egypt/Cairo",
    "endpoint": "http://217.172.12.190:8080",
    "protocol": "IoTA-UL",
    "transport": "HTTP",
    "internalId": null,
    "subscriptions": [],
    "polling": false
} | comp=IoTAgent
time=2017-03-06T18:12:14.480Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Sending device registrations to Context Broker at [http://147.27.60.58:1026/NGSI9/registerContext] | comp=IoTAgent
time=2017-03-06T18:12:14.480Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Using the following request:

{
    "url": "http://147.27.60.58:1026/NGSI9/registerContext",
    "method": "POST",
    "json": {
        "contextRegistrations": [
            {
                "entities": [
                    {
                        "type": "Controller",
                        "isPattern": "false",
                        "id": "labcontroller12"
                    }
                ],
                "attributes": [
                    {
                        "name": "play",
                        "type": "string",
                        "isDomain": "false"
                    }
                ],
                "providingApplication": "http://localhost:4061"
            }
        ],
        "duration": "P1Y"
    },
    "headers": {
        "fiware-service": "hi",
        "fiware-servicepath": "/hi"
    }
}

 | comp=IoTAgent
time=2017-03-06T18:12:14.701Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Registration success. | comp=IoTAgent
time=2017-03-06T18:12:14.702Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Creating initial entity in the Context Broker:
 {
    "url": "http://147.27.60.58:1026/v1/updateContext",
    "method": "POST",
    "json": {
        "contextElements": [
            {
                "type": "Controller",
                "isPattern": "false",
                "id": "labcontroller12",
                "attributes": [
                    {
                        "name": "number",
                        "type": "string",
                        "value": " "
                    },
                    {
                        "name": "play_status",
                        "type": "commandStatus",
                        "value": "UNKNOWN"
                    },
                    {
                        "name": "play_info",
                        "type": "commandResult",
                        "value": " "
                    },
                    {
                        "name": "TimeInstant",
                        "type": "ISO8601",
                        "value": " "
                    }
                ]
            }
        ],
        "updateAction": "APPEND"
    },
    "headers": {
        "fiware-service": "hi",
        "fiware-servicepath": "/hi",
        "fiware-correlator": "2d54c696-7c62-454a-bdf2-5fb289f53e28"
    }
} | comp=IoTAgent
time=2017-03-06T18:12:14.915Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceService | srv=hi | subsrv=/hi | msg=Initial entity created successfully. | comp=IoTAgent
time=2017-03-06T18:12:14.920Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=hi | subsrv=/hi | msg=Storing device with id [controller12] and type [Controller] | comp=IoTAgent
time=2017-03-06T18:12:14.930Z | lvl=ERROR | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.Alarms | srv=hi | subsrv=/hi | msg=Releasing [MONGO-ALARM] | comp=IoTAgent
time=2017-03-06T18:12:14.931Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DeviceProvisioning | srv=hi | subsrv=/hi | msg=Device provisioning request succeeded | comp=IoTAgent
time=2017-03-06T18:12:14.933Z | lvl=DEBUG | corr=2d54c696-7c62-454a-bdf2-5fb289f53e28 | trans=2d54c696-7c62-454a-bdf2-5fb289f53e28 | op=IoTAgentNGSI.DomainControl | srv=hi | subsrv=/hi | msg=response-time: 486 | comp=IoTAgent

It's now clear that the command attribute is not created but only its special attributes that describe the command state itself but there's no command to be updated . So , Is my registration request composed correctly to suit the iotagen-ul instance especially for its interpretation for the command ? and how could i verify the registration correctness ? and i just want to know where the problem could lie exactly . and thanks so much.

1

1 Answers

0
votes

As you can see in the logs, the command you have to query is created as a Context Provider registration (the request to the following url "http://147.27.60.58:1026/NGSI9/registerContext"). Command attributes are not registered as NGSI attributes, but defined as attributes provided by another Context Provider (the IoTAgent in this case). That's why there is no mention of the command attribute in the request that creates the initial entity: it's the expected behavior.