telefonicaid / fiware-IoTAgent-Cplusplus

IoTAgent development framework for C++
GNU Affero General Public License v3.0
11 stars 57 forks source link

Protocol when you add a Decive #254

Open anthony-pietro opened 8 years ago

anthony-pietro commented 8 years ago

Hello, I am trying to use your fiware-IoTAgent-Cplusplus. I installed everything but even if I follow the documentation, I have a problem when I execute this :

curl -X POST http://127.0.0.1:8080/iot/devices \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: service2" \ -H "Fiware-ServicePath: /srvpath2" \ -d ' { "devices": [ { "device_id": "dev_1", "entity_name": "entity_1", "entity_type": "thing", "timezone": "America/Santiago", "commands": [ { "name": "ping", "type": "command", "value": "device_id@ping|%s"} ], "attributes": [ { "object_id": "source_data", "name": "attr_name", "type": "int" } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value" } ] } ] }'

{"reason":"The request is not well formed","details":"Missing required property: protocol [/devices[0]]"}

And when I add a protocol I have this

{"reason":"There are conflicts, protocol is not correct","details":" [ protocol: PDI-IoTA-MQTT-UltraLight]"}

My problem is I can’t find any information about protocols in your doc that’s why I am asking.

Thanks -Anthony

agonlucas commented 8 years ago

Hello Anthony, First, I must explain that “protocol” field is added in order to use IoT Agent manager (This agent “deploys” services or devices in individual agents). Anyway, I think you use API agent (no manager). If you check out configuration file (/usr/local/iot/config) (you can send me and I search for an explanation) you can see, for every “resource” a field named “FileName” (that is the loaded module). MqttService -> PDI-IoTA-MQTT-UltraLight UL20Service -> PDI-IoTA-UltraLight

Anyway, if you send me configuration file I try help you.

Agustin.

anthony-pietro commented 8 years ago

My configuration file (/etc/iot/config.json) looks like this :

{ "ngsi_url": { "cbroker": "http://127.0.0.1:1026", "updateContext": "/NGSI10/updateContext", "registerContext": "/NGSI9/registerContext", "queryContext": "/NGSI10/queryContext" }, "dir_log": "/tmp/", "timezones": "/etc/iot/date_time_zonespec.csv", "storage": { "host": "127.0.0.1", "type": "mongodb", "port": "27017", "dbname": "iot" }, "resources": [ { "resource": "/iot/mqtt", "options": { "ConfigFile": "/etc/iot/MqttService.xml", "FileName": "MqttService" } } ] }

I tried to launch the manager (I will have to use it at some point) but the service doesn't start : Starting iotagent manager...pidfile not found

But when I do a status

IoTAgent manager status... dead but pid file exists

But one problem at a time I guess.

Thank you for the help.

agonlucas commented 8 years ago

Hello, We will focus in first problem (Dont worry for manager, at this moment). We think about following options: 1- Service (service2 /srvpath2) is created in other protocol or resource. When you create a service and subservice (Fiware-Service and Fiware-ServicePath headers) you need a "resource" field. You can use GET /services (with Fiware-Service and Fiware-ServicePath in your request) in order to check the resource assigned to service and /srvpath2. If this resource is not "/iot/mqtt" (protocol loaded) you get this error. Solution: create service2 and /srvpath2 with "resource" "iot/mqtt". (View API to create a service). 2- MQTT service or module does not start. We remind you to follow documentation in order to install mosquitto.

anthony-pietro commented 8 years ago

Thank you it worked.

If you have an idea for the manager not starting up I will gladly hear it.

agonlucas commented 8 years ago

About manager, We need the command line you use to start it and config.json for IoTA Manager. We see the configuration file for IoT Agent (with MQTT) has not defined any manager. Anyway, We will start knowing the command line and config.json for IoTA Manager.