@@ -67,7 +67,7 @@ For the purpose of this tutorial we will amend code from the existing Ultralight
6767XML format. A direct comparison of the two IoT Agents can be seen below:
6868
6969| IoT Agent for Ultralight | New IoT Agent for XML | Protocol's Area of Concern |
70- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -------------------------- |
70+ | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------- |
7171| Sample Measure ` c\|1 ` | Sample Measure ` <measure device="lamp002" key="xxx"> ` <br />  ; ` <c value="1"/> ` <br />` </measure> ` | Message Payload |
7272| Sample Command ` Robot1@turn\|left=30 ` | Sample Command ` <turn device="Robot1"> ` <br />  ; ` <left>30</left> ` <br />` </turn> ` | Message Payload |
7373| Content Type is ` text/plain ` | Content Type is ` application/xml ` | Message Payload |
@@ -84,15 +84,15 @@ custom payload which will need to be adapted to ensure that the XML devices can
8484
8585It should be noted that, depending on your use case, it also may be necessary to create an additional middleware for
8686communications purposes. In this example the _ devices_ are capable of sending measures and listening and responding to
87- commands directly on two separate comms channels. A different paradigm is used within the
87+ commands directly on two separate communication channels. A different paradigm is used within the
8888[ LoRaWAN] ( https://fiware-lorawan.readthedocs.io ) and [ OPC-UA] ( https://iotagent-opcua.readthedocs.io ) IoT Agents where an
8989HTTP middleware responds to the IoT Agent, and it is then responsible for converting the communications to the
9090lower-level CoAP transport used by the devices.
9191
9292## The teaching goal of this tutorial
9393
9494The aim of this tutorial is to improve developer understanding of how to create their own custom IoT Agents, a series of
95- simple modificiations has been made to the code of the Ultralight IoT Agent demonstrating how to make changes. The
95+ simple modifications has been made to the code of the Ultralight IoT Agent demonstrating how to make changes. The
9696tutorial consists of a walkthrough of the relevant code and a series of HTTP requests to connect the new IoT Agent. The
9797code can be found within the current
9898[ GitHub Repository] ( https://github.com/FIWARE/tutorials.Custom-IoT-Agent/tree/master/iot-agent )
@@ -130,7 +130,7 @@ information they hold. We will also be using the dummy IoT devices created in th
130130[ previous tutorial] ( https://github.com/FIWARE/tutorials.IoT-Sensors/ ) , however they have been already been adapted to
131131respond to the custom XML messaging format.
132132
133- Therefore the overall architecture will consist of the following elements:
133+ Therefore, the overall architecture will consist of the following elements:
134134
135135- The FIWARE [ Orion Context Broker] ( https://fiware-orion.readthedocs.io/en/latest/ ) which will receive requests using
136136 [ NGSI-v2] ( https://fiware.github.io/specifications/OpenAPI/ngsiv2 )
@@ -179,14 +179,14 @@ tutorial:
179179
180180The ` tutorial` container is listening on two ports:
181181
182- - Port `3000` is exposed so we can see the web page displaying the Dummy IoT devices.
182+ - Port `3000` is exposed therefore we can see the web page displaying the Dummy IoT devices.
183183- Port `3001` is exposed purely for tutorial access - so that cUrl or Postman can make JSON commands without being
184184 part of the same network.
185185
186186The `tutorial` container is driven by environment variables as shown :
187187
188188| Key | Value | Description |
189- | ----------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
189+ |-------------------------| ------------------------------| ------------------------------------------------------------------------------------------------------------------------------------ |
190190| DEBUG | `tutorial:*` | Debug flag used for logging |
191191| WEB_APP_PORT | `3000` | Port used by web-app which displays the dummy device data |
192192| IOTA_HTTP_HOST | `iot-agent` | The hostname of the IoT Agent for JSON - see below |
@@ -205,7 +205,7 @@ The code for the custom XML IoT Agent can be found within the
205205tutorial. It is a copy of the 1.12.0 version of the IoT Agent for Ultralight, lightly modified as described below. The
206206associated [Dockerfile](https://github.com/FIWARE/tutorials.Custom-IoT-Agent/blob/master/iot-agent/Dockerfile) merely
207207copies the code into an appropriate location within a Docker container running Node.js. This allows the component to be
208- instansiated using a `docker-compose.yaml` file. The necessary configuration can be seen below :
208+ instantiated using a `docker-compose.yaml` file. The necessary configuration can be seen below :
209209
210210` ` ` yaml
211211iot-agent:
@@ -236,13 +236,13 @@ iot-agent:
236236 - IOTA_AUTOCAST=true
237237 - IOTA_MONGO_HOST=mongo-db
238238 - IOTA_MONGO_PORT=27017
239- - IOTA_MONGO_DB=iotagentjson
239+ - IOTA_MONGO_DB=iotagentxml
240240 - IOTA_HTTP_PORT=7896
241241 - IOTA_PROVIDER_URL=http://iot-agent:4041
242242 - IOTA_DEFAULT_RESOURCE=/iot/xml
243243` ` `
244244
245- The `iot-agent` container relies on the precence of the Orion Context Broker and uses a MongoDB database to hold device
245+ The `iot-agent` container relies on the presence of the Orion Context Broker and uses a MongoDB database to hold device
246246information such as device URLs and Keys. The container is listening on two ports :
247247
248248- Port `7896` is exposed to receive JSON measurements over HTTP from the Dummy IoT devices
@@ -252,7 +252,7 @@ information such as device URLs and Keys. The container is listening on two port
252252The `iot-agent` container is driven by environment variables as shown :
253253
254254| Key | Value | Description |
255- | --------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
255+ |-----------------------| -------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------- |
256256| IOTA_CB_HOST | `orion` | Hostname of the context broker to update context |
257257| IOTA_CB_PORT | `1026` | Port that context broker listens on to update context |
258258| IOTA_NORTH_PORT | `4041` | Port used for Configuring the IoT Agent and receiving context updates from the context broker |
@@ -266,7 +266,7 @@ The `iot-agent` container is driven by environment variables as shown:
266266| IOTA_MONGO_DB | `iotagentjson` | The name of the database used in mongoDB |
267267| IOTA_HTTP_PORT | `7896` | The port where the IoT Agent listens for IoT device traffic over HTTP |
268268| 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 |
269- | IOTA_DEFAULT_RESOURCE | `/iot/xml` | The default path the IoT Agent uses listenening for custom XML measures. |
269+ | IOTA_DEFAULT_RESOURCE | `/iot/xml` | The default path the IoT Agent uses listening for custom XML measures. |
270270
271271# Prerequisites
272272
@@ -362,7 +362,7 @@ The response will look similar to the following:
362362}
363363` ` `
364364
365- This is standard functionality coming directly from the IoT Agent Node.js library and does not involve an code changes.
365+ This is standard functionality coming directly from the IoT Agent Node.js library and does not involve a code changes.
366366
367367# ## Provisioning a Service Group
368368
@@ -414,7 +414,7 @@ Where the `<measure>` holds the relevant device ID and API key.
414414
415415This syntax differs from the Ultralight IoT Agent where the device ID and API key are sent as URL parameters.
416416
417- The relevant changes can be found in the `HTTPBindings.js` file where an XML parser is instanciated .
417+ The relevant changes can be found in the `HTTPBindings.js` file where an XML parser is instantiated .
418418
419419```javascript
420420const xmlBodyParser = require('express-xml-bodyparser');
@@ -474,7 +474,7 @@ not hold sufficient information.
474474
475475It is common good practice to use URNs following the NGSI-LD
476476[ specification] ( https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.01.01_60/gs_CIM009v010101p.pdf ) when creating
477- entities. Furthermore it is easier to understand meaningful names when defining data attributes. These mappings can be
477+ entities. Furthermore, it is easier to understand meaningful names when defining data attributes. These mappings can be
478478defined by provisioning a device individually.
479479
480480Three types of measurement attributes can be provisioned:
@@ -660,10 +660,10 @@ Agent the provisioning of commands fulfills the following implied contract:
660660 the device (or alternatively to a middleware responsible for the device).
661661
662662The first two items - listening to context changes from the context broker follow the well-defined NGSI syntax and
663- therefore are common to all IoT Agents. However the third item - what to do to prepare the message for ongoing
663+ therefore are common to all IoT Agents. However, the third item - what to do to prepare the message for ongoing
664664consumption will vary according to the protocol which is being abstracted out.
665665
666- Before we wire-up the context broker, we can test that a command can be send to a device by making a REST request
666+ Before we wire-up the context broker, we can test that a command can be sent to a device by making a REST request
667667directly to the IoT Agent's North Port using the ` /v2/op/update ` endpoint. It is this endpoint that will eventually be
668668invoked by the context broker once we have connected it up. To test the configuration you can run the command directly
669669as shown:
@@ -747,7 +747,7 @@ function createCommandPayload(device, command, attributes) {
747747
748748This is an amendment from the Ultralight protocol where the ` @` and ` | ` symbol is generated for Ultralight devices.
749749
750- However creating a payload is only half the job, it must be sent to the device and understood, so communications must be
750+ However, creating a payload is only half the job, it must be sent to the device and understood, so communications must be
751751completed using a well-defined communications handshake. So after generating the payload the ` sendXMLCommandHTTP ()`
752752method of ` HTTPBindings .js ` sends the message and passes the response to the ` result ()` method in ` xmlParser .js ` to
753753interprets the command response from the device.
@@ -765,14 +765,14 @@ function result(payload) {
765765}
766766` ` `
767767
768- Finally the success or failure of the command is updated into the context broker using common code from the IoT Agent
768+ Finally, the success or failure of the command is updated into the context broker using common code from the IoT Agent
769769node library.
770770
771771As is typical for IoT Agents, creation of payloads and the handshake of communications has been split into two separate
772- concerns for ease of maintenance. Therefore since in our case only the payload has changed, it is only the XML payload
772+ concerns for ease of maintenance. Therefore, since in our case only the payload has changed, it is only the XML payload
773773side of the code that needs modification to fulfil our custom use case.
774774
775- The result of the actutator command can be read in the context broker using standard NGSI commands.
775+ The result of the actuator command can be read in the context broker using standard NGSI commands.
776776
777777#### 8️⃣ Request:
778778
0 commit comments