简体   繁体   中英

What's the right way to create a mosquitto subscription with a device and IoTAgent-UL

I'm currently developing a Fiware based network, in which I have devices that report via HTTP and JSON over MQTT and work fine. The network has increased and now I need to attach some devices that use the UltraLight protocol. Doing so, I encountered some troubles.

I followed (to the best of my knowledge) the official documentation provided by the FIWARE Foundation in different sites (the official github repo, readthedocs, and so on). I tried installing the new agent on the same machine as the JSON agent, and it didn't work -more on that later-. In order to discard any conflicts, I used another VM in which -over Docker this time- I deployed a new instance of Orion CB, Mosquitto CB, mongo and the agent; a new complete stack of Fiware, basically.

After everything was deployed, I created a new service group on the agent via the rest API (POST /iot/devices), gave it an api key and the CB address. In this step I left the resource field empty, because I don´t really know what role does it play in the whole system. The response was 201, as expected. The next step was to provision a device, which I did by POSTing to agent/iot/devices with the attributes I wanted, and the api key mentioned in last paragraph. Once again, the response was 201.

The problem arises when I try to publish a new measurement using mosquitto_pub. The command runs smoothly but the entity in Orion does not get updated. Accessing Orions DB (mongo) I can check that the entity was created successfully but it has an empty value. Moreover, checking the logs yields the following:

mosquitto    | 1559157902: New connection from 10.150.150.173 on port 1883.
mosquitto    | 1559157902: New client connected from 10.150.150.173 as mosqpub|28750-mqtt (p1, c1, k60).
fiware-iot-agent | time=2019-05-29T19:25:02.374Z | lvl=DEBUG | corr=2c8aa6e3-faab-4166-9e20-0b362c165939 | trans=2c8aa6e3-faab-4166-9e20-0b362c165939 | op=IoTAgentNGSI.MongoDBGroupRegister arams ["resource","apikey"] with queryObj {"resource":"/iot/d","apikey":"apikeymia"} | comp=IoTAgent
fiware-iot-agent | time=2019-05-29T19:25:02.381Z | lvl=DEBUG | corr=2c8aa6e3-faab-4166-9e20-0b362c165939 | trans=2c8aa6e3-faab-4166-9e20-0b362c165939 | op=IoTAgentNGSI.MongoDBGroupRegister elds [["resource","apikey"]] not found: [{"resource":"/iot/d","apikey":"apikeymia"}] | comp=IoTAgent
fiware-iot-agent | time=2019-05-29T19:25:02.382Z | lvl=ERROR | corr=2c8aa6e3-faab-4166-9e20-0b362c165939 | trans=2c8aa6e3-faab-4166-9e20-0b362c165939 | op=IOTAUL.Common.Binding | srv=n/a | essing device measures [/apikeymia/motion003/attrs] | comp=IoTAgent
mosquitto    | 1559157902: Client mosqpub|28750-mqtt disconnected.

after each try of publishing a new meassurment.

Any help would be appreciated

In this step I left the resource field empty, because I don´t really know what role does it play in the whole system

Looking to the logs:

[...] queryObj {"resource":"/iot/d","apikey":"apikeymia"} | comp=IoTAgent
[...] not found: [{"resource":"/iot/d","apikey":"apikeymia"}] | comp=IoTAgent

I'd suggest using "/iot/d" instead of empty for the resource field. Maybe that could solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM