Skip to content

Commit 1639b0f

Browse files
committed
Format README
1 parent c98bc29 commit 1639b0f

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,20 @@ tutorial:
161161
networks:
162162
- default
163163
expose:
164-
- "3000"
165-
- "3001"
164+
- '3000'
165+
- '3001'
166166
ports:
167-
- "3000:3000"
168-
- "3001:3001"
167+
- '3000:3000'
168+
- '3001:3001'
169169
environment:
170-
- "DEBUG=tutorial:*"
171-
- "PORT=3000"
172-
- "IOTA_HTTP_HOST=iot-agent"
173-
- "IOTA_HTTP_PORT=7896"
174-
- "DUMMY_DEVICES_PORT=3001"
175-
- "DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov"
176-
- "DUMMY_DEVICES_TRANSPORT=HTTP"
177-
- "DUMMY_DEVICES_PAYLOAD=XML"
170+
- 'DEBUG=tutorial:*'
171+
- 'PORT=3000'
172+
- 'IOTA_HTTP_HOST=iot-agent'
173+
- 'IOTA_HTTP_PORT=7896'
174+
- 'DUMMY_DEVICES_PORT=3001'
175+
- 'DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov'
176+
- 'DUMMY_DEVICES_TRANSPORT=HTTP'
177+
- 'DUMMY_DEVICES_PAYLOAD=XML'
178178
```
179179
180180
The `tutorial` container is listening on two ports:
@@ -220,11 +220,11 @@ iot-agent:
220220
networks:
221221
- default
222222
expose:
223-
- "4041"
224-
- "7896"
223+
- '4041'
224+
- '7896'
225225
ports:
226-
- "4041:4041"
227-
- "7896:7896"
226+
- '4041:4041'
227+
- '7896:7896'
228228
environment:
229229
- IOTA_CB_HOST=orion
230230
- IOTA_CB_PORT=1026
@@ -416,7 +416,7 @@ This syntax differs from the Ultralight IoT Agent where the device ID and API ke
416416
The relevant changes can be found in the `HTTPBindings.js` file where an XML parser is instanciated.
417417
418418
```javascript
419-
const xmlBodyParser = require("express-xml-bodyparser");
419+
const xmlBodyParser = require('express-xml-bodyparser');
420420
```
421421

422422
```javascript
@@ -437,24 +437,24 @@ function checkMandatoryParams(queryPayload) {
437437
var notFoundParams = [],
438438
error;
439439

440-
req.apiKey = req.body["measure"]["$"]["key"];
441-
req.deviceId = req.body["measure"]["$"]["device"];
440+
req.apiKey = req.body['measure']['$']['key'];
441+
req.deviceId = req.body['measure']['$']['device'];
442442

443443
if (!req.apiKey) {
444-
notFoundParams.push("API Key");
444+
notFoundParams.push('API Key');
445445
}
446446

447447
if (!req.deviceId) {
448-
notFoundParams.push("Device Id");
448+
notFoundParams.push('Device Id');
449449
}
450450

451451
// CHeck if retrievingParam
452-
if (queryPayload && !req.query.d && req.query.getCmd !== "1") {
453-
notFoundParams.push("Payload");
452+
if (queryPayload && !req.query.d && req.query.getCmd !== '1') {
453+
notFoundParams.push('Payload');
454454
}
455455

456-
if (req.method === "POST" && !req.is("application/xml")) {
457-
error = new errors.UnsupportedType("application/xml");
456+
if (req.method === 'POST' && !req.is('application/xml')) {
457+
error = new errors.UnsupportedType('application/xml');
458458
}
459459

460460
if (notFoundParams.length !== 0) {
@@ -547,11 +547,11 @@ The next step is to parse the payload extract the attributes. This can be found
547547
```javascript
548548
function parse(payload) {
549549
let result = [];
550-
const keys = Object.keys(payload["measure"]);
550+
const keys = Object.keys(payload['measure']);
551551
for (let i = 0; i < keys.length; i++) {
552-
if (keys[i] !== "$") {
552+
if (keys[i] !== '$') {
553553
let obj = {};
554-
obj[keys[i]] = payload["measure"][keys[i]]["$"].value;
554+
obj[keys[i]] = payload['measure'][keys[i]]['$'].value;
555555
result.push(obj);
556556
}
557557
}
@@ -730,16 +730,16 @@ unique to our custom XML messaging protocol and is generated in `createCommandPa
730730
731731
```javascript
732732
function createCommandPayload(device, command, attributes) {
733-
if (typeof attributes === "object") {
734-
let payload = "<" + command + ' device="' + device.id + '">';
733+
if (typeof attributes === 'object') {
734+
let payload = '<' + command + ' device="' + device.id + '">';
735735

736736
Object.keys(attributes).forEach(function (key, value) {
737-
payload = payload + "<" + key + ">" + value + "</" + key + ">";
737+
payload = payload + '<' + key + '>' + value + '</' + key + '>';
738738
});
739-
payload = payload + "</" + command + ">";
739+
payload = payload + '</' + command + '>';
740740
return payload;
741741
} else {
742-
return "<" + command + ' device="' + device.id + '"/>';
742+
return '<' + command + ' device="' + device.id + '"/>';
743743
}
744744
}
745745
```
@@ -753,7 +753,7 @@ interprets the command response from the device.
753753
754754
```javascript
755755
function result(payload) {
756-
const xmlToJson = require("xml-parser");
756+
const xmlToJson = require('xml-parser');
757757
const data = xmlToJson(payload);
758758
const result = {};
759759
result.deviceId = data.root.attributes.device;

0 commit comments

Comments
 (0)