Skip to content
100 changes: 96 additions & 4 deletions docs/usermanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,18 @@ Some additional remarks regarding polling commands:
MQTT is a machine-to-machine (M2M)/IoT connectivity protocol, focused on a lightweight interaction between peers. MQTT
Copy link
Member

@fgalan fgalan Jan 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to add the following entry to CHANGES_NEXT_RELEASE:

- Add: /api-docs endpoint providing swagger-based documentation

or something similar

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2808c0b

is based on publish-subscribe mechanisms over a hierarchical set of topics defined by the user.

This section specifies the topics and messages allowed when using MQTT as the transport protocol for Ultralight 2.0. All
the topics subscribed by the agent (to send measures, to configuration command retrieval or to get result
of a command) are prefixed with the agent procotol:
This section specifies the topics and messages allowed when using MQTT as the transport protocol for Ultralight 2.0. All
the topics subscribed by the agent (to send measures, to configuration command retrieval or to get result of a command)
are prefixed with the agent procotol:

```text
/ul/<apiKey>/<deviceId>
```

where `<apiKey>` is the API Key assigned to the service and `<deviceId>` is the ID of the device.

All topis published by the agent (to send a comamnd or to send configuration information) to a device are not prefixed
by the protocol, in this case '/ul', just include apikey and deviceid (e.g: `/FF957A98/MydeviceId/cmd` and
by the protocol, in this case '/ul', just include apikey and deviceid (e.g: `/FF957A98/MydeviceId/cmd` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 205 correct All topis => All topics
Line 207 replace '/ul' with backticks /ul to display as monospace

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8f66e1a

`/FF957A98/MyDeviceId/configuration/values` ).

This transport protocol binding is still under development.
Expand Down Expand Up @@ -544,3 +545,94 @@ To ensure consistent Markdown formatting run the following:
# Use git-bash on Windows
npm run prettier:text
```

### Swagger

In order to run Swagger, you need to execute the IoT Agent
(https://github.com/telefonicaid/iotagent-ul/blob/master/docs/installationguide.md#usage) and then you can access to:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing square brackets for link:

[IoT Agent](http://etc.)

Copy link
Author

@fiqare-secmotic fiqare-secmotic Jan 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 29983d1


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to add a sentence about which API is being covered by the swagger documentation. Something like this:

The swagger documentation provided at /api-docs covers the HTTP southbound interface of the agent. The northbound HTTP interface is not covered.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2c34c9a

```
<server_host>:7896/api-docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One doubt...

IOTA exposes two ports: one corresponding to the "southbound interface" (to which the devices send measures and command responses) and another corresponding to the "nourthbound interface" (in which the IOTA provides the provisioning API, i.e. to create a new device, etc.).

Does this /api-docs endpoint work in both ports? Or only in northbound/southbound?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have developed the Swagger documentation only for the HTTP protocol (https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#http-binding), so this version of swagger documentation (1.0.0) works only in southbound.

Copy link
Member

@fgalan fgalan Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Northbound is also HTTP-based...

However, if /api-docs only works in southbound, fine with it. I just want to confirm how it works ;)

Could you confirm?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation has been based on the sending of measurements using exclusively the HTTP protocol, so works in southbound.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2164dc0

```

If you want to test the HTTP Protocol, two importants points:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this point on, is this really needed to have the swagger web working at api-docs/ ? Or do you refer to steps needed to run IOTA-UL in general?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps needed to run IOTA-UL in general

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I'd suggest removing all this part (i.e. from L559). Note that you already include a link to a document that explains how to run IOTA in L553. Repeating a long explanation about it here is a bit out of scope from my point of view.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 2808c0b


- you should know that other services are needed (see
https://github.com/telefonicaid/iotagent-ul/blob/master/docs/installationguide.md#installation):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove URL from text - use a link e.g.

( see [installation](https://github.com/telefonicaid/iotagent-ul/blob/master/docs/installationguide.md#installation) )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8f66e1a


- Mosquitto
- Mongo
- Rabbitmq
- Orion

- you need to Provisioning a Device and Provisioning a Service Group (see this tutorial
https://fiware-tutorials.readthedocs.io/en/latest/iot-agent/index.html#connecting-iot-devices)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove URL from text - use a link e.g.

[tutorial](https://fiware-tutorials.readthedocs.io/en/latest/iot-agent/index.html#connecting-iot-devices)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8f66e1a


For example, you could use this script:

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add bash code highlight

 ```bash

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8f66e1a

//additional services
docker pull ansi/mosquitto
docker pull mongo
docker pull rabbitmq
docker pull fiware/orion

docker run -d --name mosquitto_container -p 1883:1883 -l mosquitto ansi/mosquitto
docker run -d --name mongo_container -p 27017:27017 -l mongodb mongo
docker run -d --name rabbitmq_container -p 5672:5672 -l rabbitmq rabbitmq
docker run -d --name orion_container --link mongo_container:mongo_container -p 1026:1026 fiware/orion -dbhost mongo_container

//clone repo
git clone https://github.com/fiqare-secmotic/iotagent-ul.git
cd iotagent-ul/

//IoT Agent
npm install
bin/iotagent-ul

// Provisioning a Service Group
curl -X POST \
http://localhost:4061/iot/services \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"services": [
{
"apikey": "4jggokgpepnvsb2uv4s40d59ovh",
"cbroker": "http://localhost:1026",
"entity_type": "Thing",
"resource": "/iot/d"
}
]
}'

// Provisioning a Device
curl -X POST \
http://localhost:4061/iot/devices \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"devices": [
{
"device_id": "motion001",
"entity_name": "urn:ngsd-ld:Motion:001",
"entity_type": "Motion",
"protocol": "PDI-IoTA-UltraLight",
"timezone": "Europe/Berlin",
"attributes": [
{ "object_id": "c", "name":"count", "type":"Integer"}
],
"static_attributes": [
{"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}
]
}
]
}
'

//Finally, go to locahost:7896/api-docs
```