2
votes

I want to add location information to my entity in the contextBroker using the MQTT IoT Agent. I followed this link to do so https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus/blob/develop/doc/modules.md

My problem is that the attribut "location" was sent as String to the contextBroker not as "coords"

Here is what I sent to the MQTT IoT agent:

int qos = 1;
boolean retain = false;

String topic = "myKey/sensorId/location";
String payload= "12.5/14.5";

this.dataService.publish(topic, position.getBytes(), qos, retain, 2);

I assume that the location attribut in the contextBroker will have the type "coords", something like that:

{
    "name":"position",
    "type":"coords",
    "value":"33.000,-3.234234",
    "metadatas":[
    {
        "name":"location",
        "type":"string",
        "value":"WGS84"
    }]
}

But what I got in the contextBroker is this:

"location" : {
        "value" : "12.5/14.5",
        "type" : "string",
        "md" : [
            {
                "name" : "TimeInstant",
                "type" : "ISO8601",
                "value" : "2015-11-24T16:26:09.530507"
            }
        ],
        "creDate" : 1448382369,
        "modDate" : 1448382369
    }

What have I missed? Thanks in advance for your help!

2

2 Answers

1
votes

I figured it out, I have to register the device in the IoT Agent with the attribut "location" before start using it.

"attributes": [
        {  "object_id":"location",
           "type": "coords",
           "name":"position"
        } ]
1
votes

Exactly, you have the full description in the subsection "Conversion to Location Entity..." at the sections "MQTT" and "Ultralight" here:

https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus/blob/develop/doc/modules.md

Thanks for using FIWARE!