From c22fae771f39b3d3722bcf6490df0501a46d89eb Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Sat, 2 Nov 2019 10:49:38 +0100 Subject: [PATCH] Update Read service group details Add missing param --- FIWARE IoT Agent.postman_collection.json | 114 ++++++++--------------- 1 file changed, 37 insertions(+), 77 deletions(-) diff --git a/FIWARE IoT Agent.postman_collection.json b/FIWARE IoT Agent.postman_collection.json index 3881893..ac3e45e 100644 --- a/FIWARE IoT Agent.postman_collection.json +++ b/FIWARE IoT Agent.postman_collection.json @@ -1,24 +1,19 @@ { "info": { - "_postman_id": "4b0fd35b-47e3-4ebb-b8c8-170ca4d82d74", + "_postman_id": "6b14053b-d153-4984-a955-6d4036dd3078", "name": "FIWARE IoT Agent", - "description": "This tutorial introduces the concept of an **IoT Agent** and wires up the dummy [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) IoT devices created in the\n[previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors) so that measurements can be read \nand commands can be sent using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) requests sent to the [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/).\n\nThe `docker-compose` files for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Historic-Context/icon/GitHub-Mark-32px.png) [FIWARE 202: Provisioning an IoT Agent](https://github.com/Fiware/tutorials.IoT-Agent)\n\n# What is an IoT Agent?\n\n> \"In every operation there is an above the line and a below the line.\n> Above the line is what you do by the book. Below the line is how you\n> do the job.\"\n>\n> — John le Carré (A Perfect Spy)\n\nAn IoT Agent is a component that lets a group of devices send their data to and be managed from a Context Broker\nusing their own native protocols. IoT Agents should also be able to deal with security aspects of the Fiware \nplatform (authentication and authorization of the channel) and provide other common services to the device programmer.\n\nThe Orion Context Broker exclusively uses [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) requests for all\nof its interactions. Each IoT Agent provides a **North Port** [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\ninterface which is used for context broker interactions and all interactions beneath this port occur using the **native protocol**\nof the attached devices. \n\nIn effect, this brings a standard interface to all IoT interactions at the context information management level. \nEach group of IoT devices are able to use their own propriatory protocols and disparate transport mechanisms under\nthe hood whilst the associated IoT Agent offers a facade pattern to handle this complexity.\n\nIoT Agents already exist or are in development for many common transports and protocols. Examples include the following: \n\n* [IoTAgent-JSON](http://fiware-iotagent-json.readthedocs.io/en/latest/) (HTTP/MQTT transport) - a bridge between an HTTP/MQTT+JSON based protocol and NGSI\n* [IoTAgent-LWM2M](http://fiware-iotagent-lwm2m.readthedocs.io/en/latest) (CoaP transport) - a bridge between the Lightweight M2M protocol and NGSI\n* [IoTAgent-UL](http://fiware-iotagent-ul.readthedocs.io/en/latest) (HTTP/MQTT transport) - a bridge between the UltraLight2.0 protocol and NGSI \n* [IoTagent-LoraWAN](http://fiware-lorawan.readthedocs.io/en/latest) (CoaP transport) - a bridge between the LoraWAN protocol and NGSI\n\n## Southbound Traffic (Commands)\n\nHTTP requests generated by the from the Context Broker and passed downwards towards an IoT device (via\nan IoT agent) are known as southbound traffic. Southbound traffic consists of **commands** made to \nactuator devices which alter the state of the real world by their actions. \n\nFor example to switch on a real-life UltraLight 2.0 **Smart Lamp** the following interactions would occur:\n\n1. An request is sent to the **Context broker** to invoke the `on` command of the **Smart Lamp** via NGSI\n2. The **Context Broker** finds the entity within the context and notes that the context provision for this \n attribute has been delegated to the IoT Agent\n3. The **Context broker** sends an NGSI request to the North Port of the **IoT Agent** to invoke the command\n4. The **IoT Agent** receives this Southbound request and converts it to UltraLight 2.0 syntax and passes it on to the **Smart Lamp** \n5. The **Smart Lamp** switches on the lamp and returns the result of the command to the **IoT Agent** in UltraLight 2.0 syntax\n6. The **IoT Agent** receives this Northbound request, interprets it and passes the result of the interaction into\n the context by making an NGSI request to the **Context Broker**.\n6. The **Context Broker** receives this Northbound request and updates the context with the result of the command.\n\n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/command-swimlane.png)\n\n* Requests between **User** and **Context Broker** use NGSI\n* Requests between **Context Broker** and **IoT Agent** use NGSI\n* Requests between **IoT Agent** and **IoT Device** use native protocols\n* Requests between **IoT Device** and **IoT Agent** use native protocols\n* Requests between **IoT Agent** and **Context Broker** use NGSI\n\n\n## Northbound Traffic (Measurements)\n\nRequests generated from an IoT device and passed back upwards towards the Context Broker (via an \nIoT agent) are known as northbound traffic. Northbound traffic consists of **measurements** made\nby sensor devices and relays the state of the real world into the context data of the system.\n\nFor example for a real-life **Motion Sensor** to send a count measurement the following interactions would occur:\n\n1. A **Motion Sensor** makes a measurement and passes the result to the **IoT Agent**\n2. The **IoT Agent** receives this Northbound request, converts the result from UltraLight syntax\n and passes the result of the interaction into the context by making an NGSI request to the **Context Broker**.\n3. The **Context Broker** receives this Northbound request and updates the context with the result of the measurement. \n\n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/measurement-swimlane.png)\n\n* Requests between **Iot-Device** and **IoT-Agent** use native protocols\n* Requests between **Iot-Agent** and **Context-Broker** use NGSI\n\n> **Note** Other more complex interactions are also possible, but this overview is sufficient to understand the basic\n> principles of an IoT Agent.\n\n## Common Functionality\n\nAs can be seen from the previous sections, although each IoT Agent will be unique since they interpret different\nprotocols, there will a large degree of similarity between IoT agents. \n\n* Offering a standard location to listen to device updates\n* Offering a standard location to listen to context data updates\n* Holding a list of devices and mapping context data attributes to device syntax\n* Security Authorization\n\nThis base functionality has been abstracted out into a common [IoT Agent framework library](https://fiware-iotagent-node-lib.readthedocs.org)\n\n#### Device Monitor\n\nFor the purpose of this tutorial, a series of dummy IoT devices have been created, which will be attached to the context broker.\nThe state of each device can be seen on the UltraLight device monitor web-page found at: `http://localhost:3000/device/monitor`\n\n![FIWARE Monitor](https://fiware.github.io/tutorials.IoT-Agent/img/device-monitor.png)\n\n# Architecture\n\nThis application builds on the components created in [previous tutorials](https://github.com/Fiware/tutorials.Subscriptions/). It\nwill make use of two FIWARE components - the [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) and the [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/). Usage of the Orion Context Broker is sufficient for an application to qualify as *“Powered by FIWARE”*.\nBoth the Orion Context Broker and the IoT Agent rely on open source [MongoDB](https://www.mongodb.com/) technology to keep persistence of the information they hold. We will also be using the dummy IoT devices created in the [previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors/) \n\n\nTherefore the overall architecture will consist of the following elements:\n\n* The FIWARE [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) which will receive requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\n* The FIWARE [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/) which will receive southbound requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) and convert them to [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) commands for the devices\n* The underlying [MongoDB](https://www.mongodb.com/) database :\n + Used by the **Orion Context Broker** to hold context data information such as data entities, subscriptions and registrations\n + Used by the **IoT Agent** to hold device information such as device URLs and Keys\n* The **Context Provider NGSI** proxy is not used in this tutorial. It does the following:\n + receive requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\n + makes requests to publicly available data sources using their own APIs in a proprietory format \n + returns context data back to the Orion Context Broker in [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) format.\n* The **Stock Management Frontend** is not used in this tutorial will it does the following:\n + Display store information\n + Show which products can be bought at each store\n + Allow users to \"buy\" products and reduce the stock count.\n* A webserver acting as set of [dummy IoT devices]](https://github.com/Fiware/tutorials.IoT-Sensors) using the [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) protocol running over HTTP.\n\nSince all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports. \n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/architecture.png)\n\nThe necessary configuration information for wiring up the IoT devices and the IoT Agent can be seen in the services section of the associated `docker-compose.yml` file:\n\n## Dummy IoT Devices Configuration\n\n```yaml\n context-provider:\n image: fiware/cp-web-app:latest\n hostname: context-provider\n container_name: context-provider\n networks:\n - default\n expose:\n - \"3000\"\n - \"3001\"\n ports:\n - \"3000:3000\"\n - \"3001:3001\"\n environment:\n - \"DEBUG=tutorial:*\"\n - \"PORT=3000\"\n - \"IOTA_HTTP_HOST=iot-agent\"\n - \"IOTA_HTTP_PORT=7896\"\n - \"DUMMY_DEVICES_PORT=3001\"\n - \"DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov\"\n```\n\nThe `context-provider` container is listening on two ports: \n\n* Port `3000` is exposed so we can see the web-page displaying the Dummy IoT devices.\n* Port `3001` is exposed purely for tutorial access - so that cUrl or Postman can make UltraLight commands\n without being part of the same network.\n\n\nThe `context-provider` container is driven by environment variables as shown:\n\n| Key |Value|Description|\n|-----|-----|-----------|\n|DEBUG|`tutorial:*`| Debug flag used for logging |\n|PORT|`3000`|Port used by web-app which displays the dummy device data |\n|IOTA_HTTP_HOST|`iot-agent`| The host name of the IoT Agent for UltraLight 2.0 - see below | \n|IOTA_HTTP_PORT|`7896` | The port that the IoT Agent for UltraLight 2.0 will be listening on. `7896` is a common default for UltraLight over HTTP |\n|DUMMY_DEVICES_PORT|`3001`|Port used by the dummy IoT devices to receive commands |\n|DUMMY_DEVICES_API_KEY|`4jggokgpepnvsb2uv4s40d59ov`| Random security key used for UltraLight interactions - used to ensure the integrity of interactions between the devices and the IoT Agent |\n\nThe other `context-provider` container configuration values described in the YAML file are not used in this tutorial.\n\n## IoT Agent for UltraLight 2.0 Configuration\n\nThe [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/) can be instantiated within a Docker container. An offical Docker image is available from [Docker Hub](https://hub.docker.com/r/fiware/iotagent-ul/) tagged `fiware/iotagent-ul`. The \nnecessary configuration can be seen below:\n\n```yaml\n iot-agent:\n image: fiware/iotagent-ul:latest\n hostname: iot-agent\n container_name: iot-agent\n depends_on:\n - context-db\n - orion\n networks:\n - default\n expose:\n - \"4041\"\n - \"7896\"\n ports:\n - \"4041:4041\"\n - \"7896:7896\"\n environment:\n - \"IOTA_CB_HOST=orion\"\n - \"IOTA_CB_PORT=1026\"\n - \"IOTA_NORTH_PORT=4041\"\n - \"IOTA_REGISTRY_TYPE=mongodb\"\n - \"IOTA_LOG_LEVEL=DEBUG\"\n - \"IOTA_TIMESTAMP=true\"\n - \"IOTA_MONGO_HOST=context-db\"\n - \"IOTA_MONGO_PORT=27017\"\n - \"IOTA_MONGO_DB=iotagentul\"\n - \"IOTA_HTTP_PORT=7896\"\n - \"IOTA_PROVIDER_URL=http://iot-agent:4041\"\n```\n\nThe `iot-agent` container relies on the precence of the Orion Context Broker and uses a MongoDB database to hold device information such as device URLs and Keys. The container is listening on two ports: \n\n* Port `7896` is exposed to receive Ultralight measurements over HTTP from the Dummy IoT devices\n* Port `4041` is exposed purely for tutorial access - so that cUrl or Postman can make provisioning commands\n without being part of the same network.\n\n\nThe `iot-agent` container is driven by environment variables as shown:\n\n| Key |Value|Description|\n|-----|-----|-----------|\n|IOTA_CB_HOST|`orion`| Hostname of the context broker to update context |\n|IOTA_CB_PORT|`1026`| Port that context broker listens on to update context |\n|IOTA_NORTH_PORT|`4041` | Port used for Configuring the IoT Agent and receiving context updates from the context broker |\n|IOTA_REGISTRY_TYPE|`mongodb`| Whether to hold IoT device info in memory or in a database |\n|IOTA_LOG_LEVEL|`DEBUG`|The log level of the IoT Agent |\n|IOTA_TIMESTAMP|`true`| Whether to supply timestamp information with each measurement received from attached devices |\n|IOTA_MONGO_HOST|`context-db`| The host name of mongoDB - used for holding device information |\n|IOTA_MONGO_PORT|`27017`| The port mongoDB is listening on |\n|IOTA_MONGO_DB|`iotagentul`| The name of the database used in mongoDB |\n|IOTA_HTTP_PORT|`7896`| The port where the IoT Agent listens for IoT device traffic over HTTP |\n|IOTA_PROVIDER_URL|`http://iot-agent:4041`| URL passed to the Context Broker when commands are registered, used as a forwarding URL location when the Context Broker issues a command to a device | ", + "description": "This tutorial introduces the concept of an **IoT Agent** and wires up the dummy [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) IoT devices created in the\n[previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors) so that measurements can be read \nand commands can be sent using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) requests sent to the [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/).\n\nThe `docker-compose` files for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Historic-Context/icon/GitHub-Mark-32px.png) [FIWARE 202: Provisioning an IoT Agent](https://github.com/Fiware/tutorials.IoT-Agent)\n\n# What is an IoT Agent?\n\n> \"In every operation there is an above the line and a below the line.\n> Above the line is what you do by the book. Below the line is how you\n> do the job.\"\n>\n> — John le Carré (A Perfect Spy)\n\nAn IoT Agent is a component that lets a group of devices send their data to and be managed from a Context Broker\nusing their own native protocols. IoT Agents should also be able to deal with security aspects of the Fiware \nplatform (authentication and authorization of the channel) and provide other common services to the device programmer.\n\nThe Orion Context Broker exclusively uses [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) requests for all\nof its interactions. Each IoT Agent provides a **North Port** [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\ninterface which is used for context broker interactions and all interactions beneath this port occur using the **native protocol**\nof the attached devices. \n\nIn effect, this brings a standard interface to all IoT interactions at the context information management level. \nEach group of IoT devices are able to use their own propriatory protocols and disparate transport mechanisms under\nthe hood whilst the associated IoT Agent offers a facade pattern to handle this complexity.\n\nIoT Agents already exist or are in development for many common transports and protocols. Examples include the following: \n\n* [IoTAgent-JSON](http://fiware-iotagent-json.readthedocs.io/en/latest/) (HTTP/MQTT transport) - a bridge between an HTTP/MQTT+JSON based protocol and NGSI\n* [IoTAgent-LWM2M](http://fiware-iotagent-lwm2m.readthedocs.io/en/latest) (CoaP transport) - a bridge between the Lightweight M2M protocol and NGSI\n* [IoTAgent-UL](http://fiware-iotagent-ul.readthedocs.io/en/latest) (HTTP/MQTT transport) - a bridge between the UltraLight2.0 protocol and NGSI \n* [IoTagent-LoraWAN](http://fiware-lorawan.readthedocs.io/en/latest) (CoaP transport) - a bridge between the LoraWAN protocol and NGSI\n\n## Southbound Traffic (Commands)\n\nHTTP requests generated by the from the Context Broker and passed downwards towards an IoT device (via\nan IoT agent) are known as southbound traffic. Southbound traffic consists of **commands** made to \nactuator devices which alter the state of the real world by their actions. \n\nFor example to switch on a real-life UltraLight 2.0 **Smart Lamp** the following interactions would occur:\n\n1. An request is sent to the **Context broker** to invoke the `on` command of the **Smart Lamp** via NGSI\n2. The **Context Broker** finds the entity within the context and notes that the context provision for this \n attribute has been delegated to the IoT Agent\n3. The **Context broker** sends an NGSI request to the North Port of the **IoT Agent** to invoke the command\n4. The **IoT Agent** receives this Southbound request and converts it to UltraLight 2.0 syntax and passes it on to the **Smart Lamp** \n5. The **Smart Lamp** switches on the lamp and returns the result of the command to the **IoT Agent** in UltraLight 2.0 syntax\n6. The **IoT Agent** receives this Northbound request, interprets it and passes the result of the interaction into\n the context by making an NGSI request to the **Context Broker**.\n6. The **Context Broker** receives this Northbound request and updates the context with the result of the command.\n\n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/command-swimlane.png)\n\n* Requests between **User** and **Context Broker** use NGSI\n* Requests between **Context Broker** and **IoT Agent** use NGSI\n* Requests between **IoT Agent** and **IoT Device** use native protocols\n* Requests between **IoT Device** and **IoT Agent** use native protocols\n* Requests between **IoT Agent** and **Context Broker** use NGSI\n\n\n## Northbound Traffic (Measurements)\n\nRequests generated from an IoT device and passed back upwards towards the Context Broker (via an \nIoT agent) are known as northbound traffic. Northbound traffic consists of **measurements** made\nby sensor devices and relays the state of the real world into the context data of the system.\n\nFor example for a real-life **Motion Sensor** to send a count measurement the following interactions would occur:\n\n1. A **Motion Sensor** makes a measurement and passes the result to the **IoT Agent**\n2. The **IoT Agent** receives this Northbound request, converts the result from UltraLight syntax\n and passes the result of the interaction into the context by making an NGSI request to the **Context Broker**.\n3. The **Context Broker** receives this Northbound request and updates the context with the result of the measurement. \n\n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/measurement-swimlane.png)\n\n* Requests between **Iot-Device** and **IoT-Agent** use native protocols\n* Requests between **Iot-Agent** and **Context-Broker** use NGSI\n\n> **Note** Other more complex interactions are also possible, but this overview is sufficient to understand the basic\n> principles of an IoT Agent.\n\n## Common Functionality\n\nAs can be seen from the previous sections, although each IoT Agent will be unique since they interpret different\nprotocols, there will a large degree of similarity between IoT agents. \n\n* Offering a standard location to listen to device updates\n* Offering a standard location to listen to context data updates\n* Holding a list of devices and mapping context data attributes to device syntax\n* Security Authorization\n\nThis base functionality has been abstracted out into a common [IoT Agent framework library](https://fiware-iotagent-node-lib.readthedocs.org)\n\n#### Device Monitor\n\nFor the purpose of this tutorial, a series of dummy IoT devices have been created, which will be attached to the context broker.\nThe state of each device can be seen on the UltraLight device monitor web-page found at: `http://localhost:3000/device/monitor`\n\n![FIWARE Monitor](https://fiware.github.io/tutorials.IoT-Agent/img/device-monitor.png)\n\n# Architecture\n\nThis application builds on the components created in [previous tutorials](https://github.com/Fiware/tutorials.Subscriptions/). It\nwill make use of two FIWARE components - the [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) and the [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/). Usage of the Orion Context Broker is sufficient for an application to qualify as *“Powered by FIWARE”*.\nBoth the Orion Context Broker and the IoT Agent rely on open source [MongoDB](https://www.mongodb.com/) technology to keep persistence of the information they hold. We will also be using the dummy IoT devices created in the [previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors/) \n\n\nTherefore the overall architecture will consist of the following elements:\n\n* The FIWARE [Orion Context Broker](https://fiware-orion.readthedocs.io/en/latest/) which will receive requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\n* The FIWARE [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/) which will receive southbound requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) and convert them to [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) commands for the devices\n* The underlying [MongoDB](https://www.mongodb.com/) database :\n + Used by the **Orion Context Broker** to hold context data information such as data entities, subscriptions and registrations\n + Used by the **IoT Agent** to hold device information such as device URLs and Keys\n* The **Context Provider NGSI** proxy is not used in this tutorial. It does the following:\n + receive requests using [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2)\n + makes requests to publicly available data sources using their own APIs in a proprietory format \n + returns context data back to the Orion Context Broker in [NGSI](https://fiware.github.io/specifications/OpenAPI/ngsiv2) format.\n* The **Stock Management Frontend** is not used in this tutorial will it does the following:\n + Display store information\n + Show which products can be bought at each store\n + Allow users to \"buy\" products and reduce the stock count.\n* A webserver acting as set of [dummy IoT devices]](https://github.com/Fiware/tutorials.IoT-Sensors) using the [UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual) protocol running over HTTP.\n\nSince all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports. \n\n![](https://fiware.github.io/tutorials.IoT-Agent/img/architecture.png)\n\nThe necessary configuration information for wiring up the IoT devices and the IoT Agent can be seen in the services section of the associated `docker-compose.yml` file:\n\n## Dummy IoT Devices Configuration\n\n```yaml\n context-provider:\n image: fiware/cp-web-app:latest\n hostname: context-provider\n container_name: context-provider\n networks:\n - default\n expose:\n - \"3000\"\n - \"3001\"\n ports:\n - \"3000:3000\"\n - \"3001:3001\"\n environment:\n - \"DEBUG=proxy:*\"\n - \"PORT=3000\"\n - \"IOTA_HTTP_HOST=iot-agent\"\n - \"IOTA_HTTP_PORT=7896\"\n - \"DUMMY_DEVICES_PORT=3001\"\n - \"DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov\"\n```\n\nThe `context-provider` container is listening on two ports: \n\n* Port `3000` is exposed so we can see the web-page displaying the Dummy IoT devices.\n* Port `3001` is exposed purely for tutorial access - so that cUrl or Postman can make UltraLight commands\n without being part of the same network.\n\n\nThe `context-provider` container is driven by environment variables as shown:\n\n| Key |Value|Description|\n|-----|-----|-----------|\n|DEBUG|`proxy:*`| Debug flag used for logging |\n|PORT|`3000`|Port used by web-app which displays the dummy device data |\n|IOTA_HTTP_HOST|`iot-agent`| The host name of the IoT Agent for UltraLight 2.0 - see below | \n|IOTA_HTTP_PORT|`7896` | The port that the IoT Agent for UltraLight 2.0 will be listening on. `7896` is a common default for UltraLight over HTTP |\n|DUMMY_DEVICES_PORT|`3001`|Port used by the dummy IoT devices to receive commands |\n|DUMMY_DEVICES_API_KEY|`4jggokgpepnvsb2uv4s40d59ov`| Random security key used for UltraLight interactions - used to ensure the integrity of interactions between the devices and the IoT Agent |\n\nThe other `context-provider` container configuration values described in the YAML file are not used in this tutorial.\n\n## IoT Agent for UltraLight 2.0 Configuration\n\nThe [IoT Agent for UltraLight 2.0](http://fiware-iotagent-ul.readthedocs.io/en/latest/) can be instantiated within a Docker container. An offical Docker image is available from [Docker Hub](https://hub.docker.com/r/fiware/iotagent-ul/) tagged `fiware/iotagent-ul`. The \nnecessary configuration can be seen below:\n\n```yaml\n iot-agent:\n image: fiware/iotagent-ul:latest\n hostname: iot-agent\n container_name: iot-agent\n depends_on:\n - context-db\n - orion\n networks:\n - default\n expose:\n - \"4041\"\n - \"7896\"\n ports:\n - \"4041:4041\"\n - \"7896:7896\"\n environment:\n - \"IOTA_CB_HOST=orion\"\n - \"IOTA_CB_PORT=1026\"\n - \"IOTA_NORTH_PORT=4041\"\n - \"IOTA_REGISTRY_TYPE=mongodb\"\n - \"IOTA_LOG_LEVEL=DEBUG\"\n - \"IOTA_TIMESTAMP=true\"\n - \"IOTA_MONGO_HOST=context-db\"\n - \"IOTA_MONGO_PORT=27017\"\n - \"IOTA_MONGO_DB=iotagentul\"\n - \"IOTA_HTTP_PORT=7896\"\n - \"IOTA_PROVIDER_URL=http://iot-agent:4041\"\n```\n\nThe `iot-agent` container relies on the precence of the Orion Context Broker and uses a MongoDB database to hold device information such as device URLs and Keys. The container is listening on two ports: \n\n* Port `7896` is exposed to receive Ultralight measurements over HTTP from the Dummy IoT devices\n* Port `4041` is exposed purely for tutorial access - so that cUrl or Postman can make provisioning commands\n without being part of the same network.\n\n\nThe `iot-agent` container is driven by environment variables as shown:\n\n| Key |Value|Description|\n|-----|-----|-----------|\n|IOTA_CB_HOST|`orion`| Hostname of the context broker to update context |\n|IOTA_CB_PORT|`1026`| Port that context broker listens on to update context |\n|IOTA_NORTH_PORT|`4041` | Port used for Configuring the IoT Agent and receiving context updates from the context broker |\n|IOTA_REGISTRY_TYPE|`mongodb`| Whether to hold IoT device info in memory or in a database |\n|IOTA_LOG_LEVEL|`DEBUG`|The log level of the IoT Agent |\n|IOTA_TIMESTAMP|`true`| Whether to supply timestamp information with each measurement received from attached devices |\n|IOTA_MONGO_HOST|`context-db`| The host name of mongoDB - used for holding device information |\n|IOTA_MONGO_PORT|`27017`| The port mongoDB is listening on |\n|IOTA_MONGO_DB|`iotagentul`| The name of the database used in mongoDB |\n|IOTA_HTTP_PORT|`7896`| The port where the IoT Agent listens for IoT device traffic over HTTP |\n|IOTA_PROVIDER_URL|`http://iot-agent:4041`| URL passed to the Context Broker when commands are registered, used as a forwarding URL location when the Context Broker issues a command to a device | ", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Connecting IoT Devices", - "description": "The IoT Agent acts as a middleware between the IoT devices and the context broker. It therefore\nneeds to be able to create context data entities with unique ids. Once a service has been provisioned\nand an unknown device makes a measurement the IoT Agent add this to the context using the supplied\n`` (unless the device is recognized and can be mapped to a known id.\n\nThere is no guarantee that every supplied IoT device `` will always be unique, therefore \nall provisioning requests to the IoT Agent require two mandatory headers:\n\n* `fiware-service` header is defined so that entities for a given service can be held in a separate mongoDB database.\n* `fiware-servicepath` can be used to differenciate between arrays of devices. \n\nFor example within a smart city application you would expect different `fiware-service` headers for different\ndepartments (e.g. parks, transport, refuse collection etc.) and each `fiware-servicepath` would refer to specific park \nand so on. This would mean that data and devices for each service can be identified and separated as needed, but the\ndata would not be siloed - for example data from a **Smart Bin** within a park can be combined with the **GPS Unit** \nof a refuse truck to alter the route of the truck in an efficient manner. \n\nThe **Smart Bin** and **GPS Unit** are likely to come from different manufacturers and it cannot be \nguaranteed that that there is no overlap within ``s used. The use of the `fiware-service` and\n`fiware-servicepath` headers can ensure that this is always the case, and allows the context broker to identify\nthe original source of the context data.\n", "item": [ { "name": "IoT Agent - Obtain Version Information", "request": { "method": "GET", "header": [], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{iot-agent}}/iot/about", "protocol": "http", @@ -91,7 +86,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"devices\": [\n {\n \"device_id\": \"motion001\",\n \"entity_name\": \"urn:ngsi-ld:Motion:001\",\n \"entity_type\": \"Motion\",\n \"timezone\": \"Europe/Berlin\",\n \"attributes\": [\n { \"object_id\": \"c\", \"name\":\"count\", \"type\":\"Integer\"}\n ],\n \"static_attributes\": [\n {\"name\":\"refStore\", \"type\": \"Relationship\",\"value\": \"urn:ngsi-ld:Store:001\"}\n ]\n }\n ]\n}\n" + "raw": "{\n \"devices\": [\n {\n \"device_id\": \"motion001\",\n \"entity_name\": \"urn:ngsd-ld:Motion:001\",\n \"entity_type\": \"Motion\",\n \"timezone\": \"Europe/Berlin\",\n \"attributes\": [\n { \"object_id\": \"c\", \"name\":\"count\", \"type\":\"Integer\"}\n ],\n \"static_attributes\": [\n {\"name\":\"refStore\", \"type\": \"Relationship\",\"value\": \"urn:ngsi-ld:Store:001\"}\n ]\n }\n ]\n}\n" }, "url": { "raw": "http://{{iot-agent}}/iot/devices", @@ -104,7 +99,7 @@ "devices" ] }, - "description": "It is common good practice to use URNs following the NGSI-LD [specification](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.01.01_60/gs_CIM009v010101p.pdf) when creating entities. Furthermore it is easier to understand\nmeaningful names when defining data attributes. These mappings can be defined by provisioning a device individually.\n\nThree types of meaasurement attributes can be provisioned:\n\n* `attributes` are active readings from the device\n* `lazy` attributes are only sent on request - The IoT Agent will inform the device to return the measurement\n* `static_attributes` are as the name suggests static data about the device (such as relationships) passed on \n to the context broker.\n\n>**Note**: in the case where individual `id`s are not required, or aggregated data is sufficient \n> the `attributes` can be defined within the provisioning service rather than individually.\n\nIn the request we are assiociating the device `motion001` with the URN `urn:ngsi-ld:Motion:001`\nand mapping the device reading `c` with the context attribute `count` (which is defined as an `Integer`)\nA `refStore` is defined as a `static_attribute`, placing the device within **Store** `urn:ngsi-ld:Store:001`" + "description": "It is common good practice to use URNs following the NGSI-LD [draft recommendation](https://docbox.etsi.org/ISG/CIM/Open/ISG_CIM_NGSI-LD_API_Draft_for_public_review.pdf) when creating entities. Furthermore it is easier to understand\nmeaningful names when defining data attributes. These mappings can be defined by provisioning a device individually.\n\nThree types of meaasurement attributes can be provisioned:\n\n* `attributes` are active readings from the device\n* `lazy` attributes are only sent on request - The IoT Agent will inform the device to return the measurement\n* `static_attributes` are as the name suggests static data about the device (such as relationships) passed on \n to the context broker.\n\n>**Note**: in the case where individual `id`s are not required, or aggregated data is sufficient \n> the `attributes` can be defined within the provisioning service rather than individually.\n\nIn the request we are assiociating the device `motion001` with the URN `urn:ngsd-ld:Motion:001`\nand mapping the device reading `c` with the context attribute `count` (which is defined as an `Integer`)\nA `refStore` is defined as a `static_attribute`, placing the device within **Store** `urn:ngsi-ld:Store:001`" }, "response": [] }, @@ -162,12 +157,8 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Motion:001", + "raw": "http://{{orion}}/v2/entities/urn:ngsd-ld:Motion:001", "protocol": "http", "host": [ "{{orion}}" @@ -175,10 +166,10 @@ "path": [ "v2", "entities", - "urn:ngsi-ld:Motion:001" + "urn:ngsd-ld:Motion:001" ] }, - "description": "This example returns the data for the `Motion` entity with the `id=urn:ngsi-ld:Motion:001` within the context data.\n\nThe response shows that the device with `id=motion001` has been successfully identifed by the IoT Agent and mapped to the\nentity `id=urn:ngsi-ld:Motion:001`. This new entity has been created within the context data. The `c` \nattribute from the dummy device measurement request has been mapped to the more meaningful `count` attribute\nwithin the context. As you will notice, a `TimeInstant` attribute has been added to both the entity and the\nmeta data of the attribute - this represents the last time the entity and attribute have been updated, and is\nautomatically added to each new entity because the `IOTA_TIMESTAMP` environment variable was set when the\nIoT Agent was started up. The `refStore` attribute comes from the `static_attributes` set when the device was provisioned." + "description": "This example returns the data for the `Motion` entity with the `id=urn:ngsd-ld:Motion:001` within the context data.\n\nThe response shows that the device with `id=motion001` has been successfully identifed by the IoT Agent and mapped to the\nentity `id=urn:ngsd-ld:Motion:001`. This new entity has been created within the context data. The `c` \nattribute from the dummy device measurement request has been mapped to the more meaningful `count` attribute\nwithin the context. As you will notice, a `TimeInstant` attribute has been added to both the entity and the\nmeta data of the attribute - this represents the last time the entity and attribute have been updated, and is\nautomatically added to each new entity because the `IOTA_TIMESTAMP` environment variable was set when the\nIoT Agent was started up. The `refStore` attribute comes from the `static_attributes` set when the device was provisioned." }, "response": [] }, @@ -270,10 +261,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Bell:001?options=keyValues", "protocol": "http", @@ -384,10 +371,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{iot-agent}}/iot/devices", "protocol": "http", @@ -404,6 +387,7 @@ "response": [] } ], + "description": "The IoT Agent acts as a middleware between the IoT devices and the context broker. It therefore\nneeds to be able to create context data entities with unique ids. Once a service has been provisioned\nand an unknown device makes a measurement the IoT Agent add this to the context using the supplied\n`` (unless the device is recognized and can be mapped to a known id.\n\nThere is no guarantee that every supplied IoT device `` will always be unique, therefore \nall provisioning requests to the IoT Agent require two mandatory headers:\n\n* `fiware-service` header is defined so that entities for a given service can be held in a separate mongoDB database.\n* `fiware-servicepath` can be used to differenciate between arrays of devices. \n\nFor example within a smart city application you would expect different `fiware-service` headers for different\ndepartments (e.g. parks, transport, refuse collection etc.) and each `fiware-servicepath` would refer to specific park \nand so on. This would mean that data and devices for each service can be identified and separated as needed, but the\ndata would not be siloed - for example data from a **Smart Bin** within a park can be combined with the **GPS Unit** \nof a refuse truck to alter the route of the truck in an efficient manner. \n\nThe **Smart Bin** and **GPS Unit** are likely to come from different manufacturers and it cannot be \nguaranteed that that there is no overlap within ``s used. The use of the `fiware-service` and\n`fiware-servicepath` headers can ensure that this is always the case, and allows the context broker to identify\nthe original source of the context data.\n", "event": [ { "listen": "prerequest", @@ -429,11 +413,9 @@ }, { "name": "Enabling Context Broker Commands", - "description": "Having connected up the IoT Agent to the IoT devices, we now need to inform the Orion Context Broker that the commands\nare available. In other words we need to register the IoT Agent as a [Context Provider](https://github.com/Fiware/tutorials.Context-Providers/) for the command attributes.\n\nOnce the commands have been registered it will be possible to ring the **Bell**, open and close the **Smart Door** and\nswitch the **Smart Lamp** on and off by sending requests to the Orion Context Broker, rather than sending UltraLight 2.0\nrequests directly t the IoT devices as we did in the [previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors)", "item": [ { "name": "Bell Commands", - "description": "The **Bell** entity has been mapped to `id=\"urn:ngsi-ld:Bell:001\"` with an entity `type=\"Bell\"`", "item": [ { "name": "Register Bell Commands", @@ -458,7 +440,7 @@ "raw": "{\n \"description\": \"Bell Commands\",\n \"dataProvided\": {\n \"entities\": [\n {\n \"id\": \"urn:ngsi-ld:Bell:001\", \"type\": \"Bell\"\n }\n ],\n \"attrs\": [\"ring\"]\n },\n \"provider\": {\n \"http\": {\"url\": \"http://orion:1026/v1\"},\n \"legacyForwarding\": true\n }\n}" }, "url": { - "raw": "http://{{orion}}/v2/registrations", + "raw": "http://{{orion}}/v2/registrations?", "protocol": "http", "host": [ "{{orion}}" @@ -509,13 +491,12 @@ "raw": "{\n \"ring\": {\n \"type\" : \"command\",\n \"value\" : \"\"\n }\n}" }, "url": { - "raw": "http://{{orion}}//v2/entities/urn:ngsi-ld:Bell:001/attrs", + "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Bell:001/attrs", "protocol": "http", "host": [ "{{orion}}" ], "path": [ - "", "v2", "entities", "urn:ngsi-ld:Bell:001", @@ -540,10 +521,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"ring\": {\n \t\"type\" : \"command\",\n \t\"value\" : \"\"\n\t}\n}" - }, "url": { "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Bell:001?options=keyValues", "protocol": "http", @@ -567,6 +544,7 @@ "response": [] } ], + "description": "The **Bell** entity has been mapped to `id=\"urn:ngsi-ld:Bell:001\"` with an entity `type=\"Bell\"`", "event": [ { "listen": "prerequest", @@ -593,7 +571,6 @@ }, { "name": "Smart Door Commands", - "description": "The **Smart Door** entity has been mapped to `id=\"urn:ngsi-ld:Door:001\"` with an entity `type=\"Door\"`", "item": [ { "name": "Register Smart Door Commands", @@ -618,7 +595,7 @@ "raw": "{\n \"description\": \"Door Commands\",\n \"dataProvided\": {\n \"entities\": [\n {\n \"id\": \"urn:ngsi-ld:Door:001\", \"type\": \"Door\"\n }\n ],\n \"attrs\": [ \"lock\", \"unlock\", \"open\", \"close\"]\n },\n \"provider\": {\n \"http\": {\"url\": \"http://orion:1026/v1\"},\n \"legacyForwarding\": true\n }\n}" }, "url": { - "raw": "http://{{orion}}/v2/registrations", + "raw": "http://{{orion}}/v2/registrations?", "protocol": "http", "host": [ "{{orion}}" @@ -699,10 +676,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Door:001?options=keyValues", "protocol": "http", @@ -726,6 +699,7 @@ "response": [] } ], + "description": "The **Smart Door** entity has been mapped to `id=\"urn:ngsi-ld:Door:001\"` with an entity `type=\"Door\"`", "event": [ { "listen": "prerequest", @@ -752,7 +726,6 @@ }, { "name": "Smart Lamp", - "description": "The **Smart Lamp** entity has been mapped to `id=\"urn:ngsi-ld:Lamp:001\"` with an entity `type=\"Lamp\"`", "item": [ { "name": "Register Smart Lamp Commands", @@ -777,7 +750,7 @@ "raw": "{\n \"description\": \"Lamp Commands\",\n \"dataProvided\": {\n \"entities\": [\n {\n \"id\": \"urn:ngsi-ld:Lamp:001\",\"type\": \"Lamp\"\n }\n ],\n \"attrs\": [ \"on\", \"off\" ]\n },\n \"provider\": {\n \"http\": {\"url\": \"http://orion:1026/v1\"},\n \"legacyForwarding\": true\n }\n}" }, "url": { - "raw": "http://{{orion}}/v2/registrations", + "raw": "http://{{orion}}/v2/registrations?", "protocol": "http", "host": [ "{{orion}}" @@ -858,10 +831,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{orion}}/v2/entities/urn:ngsi-ld:Lamp:001?options=keyValues", "protocol": "http", @@ -885,6 +854,7 @@ "response": [] } ], + "description": "The **Smart Lamp** entity has been mapped to `id=\"urn:ngsi-ld:Lamp:001\"` with an entity `type=\"Lamp\"`", "event": [ { "listen": "prerequest", @@ -923,10 +893,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{orion}}/v2/entities/", "protocol": "http", @@ -944,6 +910,7 @@ "response": [] } ], + "description": "Having connected up the IoT Agent to the IoT devices, we now need to inform the Orion Context Broker that the commands\nare available. In other words we need to register the IoT Agent as a [Context Provider](https://github.com/Fiware/tutorials.Context-Providers/) for the command attributes.\n\nOnce the commands have been registered it will be possible to ring the **Bell**, open and close the **Smart Door** and\nswitch the **Smart Lamp** on and off by sending requests to the Orion Context Broker, rather than sending UltraLight 2.0\nrequests directly t the IoT devices as we did in the [previous tutorial](https://github.com/Fiware/tutorials.IoT-Sensors)", "event": [ { "listen": "prerequest", @@ -969,7 +936,6 @@ }, { "name": "Service Group CRUD Actions", - "description": "The **CRUD** operations for a service group map on to the expected HTTP verbs under the `/iot/services` endpoint\n\n* **Create** - HTTP POST\n* **Read** - HTTP GET\n* **Update** - HTTP PUT\n* **Delete** - HTTP DELETE\n\nUse the `resource` and `apikey` parameters to uniquely identify a service group.", "item": [ { "name": "Create a Service Group", @@ -1020,14 +986,16 @@ { "key": "fiware-servicepath", "value": "/" + }, + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/x-www-form-urlencoded", + "type": "text" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "http://{{iot-agent}}/iot/services", + "raw": "http://{{iot-agent}}/iot/services?resource=/iot/d", "protocol": "http", "host": [ "{{iot-agent}}" @@ -1035,6 +1003,12 @@ "path": [ "iot", "services" + ], + "query": [ + { + "key": "resource", + "value": "/iot/d" + } ] }, "description": "This example obtains the full details of a provisioned services with a given `resource` path.\n\nThe response includes all the defaults associated with the service group such as the `entity_type` and any default commands or attribute mappings.\n\nService group details can be read by making a GET request to the `/iot/services` endpoint and providing a `resource` parameter." @@ -1055,10 +1029,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{iot-agent}}/iot/services", "protocol": "http", @@ -1167,6 +1137,7 @@ "response": [] } ], + "description": "The **CRUD** operations for a service group map on to the expected HTTP verbs under the `/iot/services` endpoint\n\n* **Create** - HTTP POST\n* **Read** - HTTP GET\n* **Update** - HTTP PUT\n* **Delete** - HTTP DELETE\n\nUse the `resource` and `apikey` parameters to uniquely identify a service group.", "event": [ { "listen": "prerequest", @@ -1192,7 +1163,6 @@ }, { "name": "Device CRUD Actions", - "description": "The **CRUD** operations for an individual device map on to the expected HTTP verbs under the `/iot/devices` endpoint\n\n* **Create** - HTTP POST\n* **Read** - HTTP GET\n* **Update** - HTTP PUT\n* **Delete** - HTTP DELETE\n\nUse the `` to uniquely identify a device.", "item": [ { "name": "Create a Provisioned Device", @@ -1245,10 +1215,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{iot-agent}}/iot/devices/bell002", "protocol": "http", @@ -1279,10 +1245,6 @@ "value": "/" } ], - "body": { - "mode": "raw", - "raw": "" - }, "url": { "raw": "http://{{iot-agent}}/iot/devices", "protocol": "http", @@ -1371,6 +1333,7 @@ "response": [] } ], + "description": "The **CRUD** operations for an individual device map on to the expected HTTP verbs under the `/iot/devices` endpoint\n\n* **Create** - HTTP POST\n* **Read** - HTTP GET\n* **Update** - HTTP PUT\n* **Delete** - HTTP DELETE\n\nUse the `` to uniquely identify a device.", "event": [ { "listen": "prerequest", @@ -1419,25 +1382,22 @@ ], "variable": [ { - "id": "01ab6efb-524a-435e-87c4-bdc48b4fb2a0", + "id": "43cd94b2-d9fd-4f8c-9f16-79ade8321dc0", "key": "iot-agent", "value": "localhost:4041", - "type": "string", - "description": "" + "type": "string" }, { - "id": "cd18d255-1559-41db-9159-49b8704198bd", + "id": "00792a5f-dfd2-41af-a236-4c43e4e28442", "key": "orion", "value": "localhost:1026", - "type": "string", - "description": "" + "type": "string" }, { - "id": "3e916b1c-b56c-421c-bc0e-ebb3dd37d4e3", + "id": "5abfc42e-cb82-47d3-a0e1-b59d44d5b118", "key": "ultralight", "value": "localhost:3001", - "type": "string", - "description": "" + "type": "string" } ] } \ No newline at end of file