Skip to content

Commit

Permalink
Formatting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Aug 22, 2022
1 parent 13e4124 commit e6cf78e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 68 deletions.
4 changes: 2 additions & 2 deletions doc/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ basis preprovisioning the devices). Device measures can have three different beh
The following sequence diagram shows the different NGSI interactions an IoT Agent makes with the Context Broker,
explained in the following subsections (using the example of a OMA Lightweight M2M device).

![General ](./img/ngsiInteractions.png 'NGSI Interactions')
![General ](./img/ngsiInteractions.png "NGSI Interactions")

Be aware that the IoT Agents are only required to support NGSI10 operations `updateContext` and `queryContext` in their
standard formats (currently in JSON format; XML deprecated) but will not answer to NGSI9 operations (or NGSI convenience
Expand Down Expand Up @@ -254,7 +254,7 @@ the concrete IoT Agent implementations will be to map between the native device
The following figure offers a graphical example of how a COAP IoT Agent work, ordered from the registration of the
device to a command update to the device.

![General ](./img/iotAgentLib.png 'Architecture Overview')
![General ](./img/iotAgentLib.png "Architecture Overview")

### The `TimeInstant` element

Expand Down
5 changes: 2 additions & 3 deletions doc/caching-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ received from the database this allows multiple IoT Agent instances to access th
This is the default operation mode with Mongo-DB. Whenever a measure is received, provisioning data is requested from
the database. This may become a bottleneck in high availability systems.


### MongoDB with in-memory Cache

if `memCache.enabled = true` within the config this provides a transient memory-based cache in front of the mongo-DB
Expand All @@ -45,5 +44,5 @@ IoT Agents would potential hold inconsistent provisioning data until the cache h
## Bypassing cache

In some cases consistent provisioning data is more vital than throughput. When creating or updating a provisioned device
or service group adding a `cache` attribute with the value `true` will ensure that the data can be cached, otherwise it is never placed into a
cache and therefore always consistently received from the Mongo-DB instance.
or service group adding a `cache` attribute with the value `true` will ensure that the data can be cached, otherwise it
is never placed into a cache and therefore always consistently received from the Mongo-DB instance.
18 changes: 9 additions & 9 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ custom settings may also be required dependent upon the actual IoT Agent used.

```javascript
config = {
logLevel: 'DEBUG',
logLevel: "DEBUG",
contextBroker: {
host: 'orion',
port: '1026'
host: "orion",
port: "1026",
},
server: {
port: 4041,
host: '0.0.0.0'
host: "0.0.0.0",
},
deviceRegistry: {
type: 'memory'
type: "memory",
},
service: 'openiot',
subservice: '/',
providerUrl: 'http://iot-agent:4041',
defaultType: 'Thing'
service: "openiot",
subservice: "/",
providerUrl: "http://iot-agent:4041",
defaultType: "Thing",
};
```

Expand Down
106 changes: 53 additions & 53 deletions doc/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ folder of your project. Remember to change the Context Broker IP to your local C
Now we can begin with the code of our IoT Agent. The very minimum code we need to start an IoT Agent is the following:

```javascript
var iotAgentLib = require('iotagent-node-lib'),
config = require('./config');
var iotAgentLib = require("iotagent-node-lib"),
config = require("./config");

iotAgentLib.activate(config, function (error) {
if (error) {
console.log('There was an error activating the IOTA');
console.log("There was an error activating the IOTA");
process.exit(1);
}
});
Expand Down Expand Up @@ -112,10 +112,10 @@ In order to add the Express dependency to your project, add the following line t
The require section would end up like this (the standard `http` module is also needed):

```javascript
var iotAgentLib = require('iotagent-node-lib'),
http = require('http'),
express = require('express'),
config = require('./config');
var iotAgentLib = require("iotagent-node-lib"),
http = require("http"),
express = require("express"),
config = require("./config");
```

And install the dependencies as usual with `npm install`. You will have to require both `express` and `http` in your
Expand All @@ -129,16 +129,16 @@ function initSouthbound(callback) {
southboundServer = {
server: null,
app: express(),
router: express.Router()
router: express.Router(),
};

southboundServer.app.set('port', 8080);
southboundServer.app.set('host', '0.0.0.0');
southboundServer.app.set("port", 8080);
southboundServer.app.set("host", "0.0.0.0");

southboundServer.router.get('/iot/d', manageULRequest);
southboundServer.router.get("/iot/d", manageULRequest);
southboundServer.server = http.createServer(southboundServer.app);
southboundServer.app.use('/', southboundServer.router);
southboundServer.server.listen(southboundServer.app.get('port'), southboundServer.app.get('host'), callback);
southboundServer.app.use("/", southboundServer.router);
southboundServer.server.listen(southboundServer.app.get("port"), southboundServer.app.get("host"), callback);
}
```

Expand All @@ -154,18 +154,18 @@ function manageULRequest(req, res, next) {
iotAgentLib.retrieveDevice(req.query.i, req.query.k, function (error, device) {
if (error) {
res.status(404).send({
message: "Couldn't find the device: " + JSON.stringify(error)
message: "Couldn't find the device: " + JSON.stringify(error),
});
} else {
values = parseUl(req.query.d, device);
iotAgentLib.update(device.name, device.type, '', values, device, function (error) {
iotAgentLib.update(device.name, device.type, "", values, device, function (error) {
if (error) {
res.status(500).send({
message: 'Error updating the device'
message: "Error updating the device",
});
} else {
res.status(200).send({
message: 'Device successfully updated'
message: "Device successfully updated",
});
}
});
Expand All @@ -190,17 +190,17 @@ function parseUl(data, device) {
}

function createAttribute(element) {
var pair = element.split('|'),
var pair = element.split("|"),
attribute = {
name: pair[0],
value: pair[1],
type: findType(pair[0])
type: findType(pair[0]),
};

return attribute;
}

return data.split(',').map(createAttribute);
return data.split(",").map(createAttribute);
}
```

Expand All @@ -227,14 +227,14 @@ show the modifications in the `activate()` function:
```javascript
iotAgentLib.activate(config, function (error) {
if (error) {
console.log('There was an error activating the IOTA');
console.log("There was an error activating the IOTA");
process.exit(1);
} else {
initSouthbound(function (error) {
if (error) {
console.log('Could not initialize South bound API due to the following error: %s', error);
console.log("Could not initialize South bound API due to the following error: %s", error);
} else {
console.log('Both APIs started successfully');
console.log("Both APIs started successfully");
}
});
}
Expand Down Expand Up @@ -286,7 +286,7 @@ A HTTP request library will be needed in order to make those calls. To this exte
used. In order to do so, add the following require statement to the initialization code:

```javascript
request = require('request');
request = require("request");
```

and add the `request` dependency to the `package.json` file:
Expand All @@ -303,11 +303,11 @@ and add the `request` dependency to the `package.json` file:
The require section should now look like this:

```javascript
var iotAgentLib = require('iotagent-node-lib'),
http = require('http'),
express = require('express'),
request = require('request'),
config = require('./config');
var iotAgentLib = require("iotagent-node-lib"),
http = require("http"),
express = require("express"),
request = require("request"),
config = require("./config");
```

### Implementation
Expand All @@ -321,11 +321,11 @@ for the context provisioning requests. At this point, we should provide two hand
```javascript
function queryContextHandler(id, type, service, subservice, attributes, callback) {
var options = {
url: 'http://127.0.0.1:9999/iot/d',
method: 'GET',
url: "http://127.0.0.1:9999/iot/d",
method: "GET",
qs: {
q: attributes.join()
}
q: attributes.join(),
},
};

request(options, function (error, response, body) {
Expand All @@ -350,21 +350,21 @@ attributes). Here is the code for the `createResponse()` function:

```javascript
function createResponse(id, type, attributes, body) {
var values = body.split(','),
var values = body.split(","),
responses = [];

for (var i = 0; i < attributes.length; i++) {
responses.push({
name: attributes[i],
type: 'string',
value: values[i]
type: "string",
value: values[i],
});
}

return {
id: id,
type: type,
attributes: responses
attributes: responses,
};
}
```
Expand All @@ -374,11 +374,11 @@ function createResponse(id, type, attributes, body) {
```javascript
function updateContextHandler(id, type, service, subservice, attributes, callback) {
var options = {
url: 'http://127.0.0.1:9999/iot/d',
method: 'GET',
url: "http://127.0.0.1:9999/iot/d",
method: "GET",
qs: {
d: createQueryFromAttributes(attributes)
}
d: createQueryFromAttributes(attributes),
},
};

request(options, function (error, response, body) {
Expand All @@ -388,7 +388,7 @@ function updateContextHandler(id, type, service, subservice, attributes, callbac
callback(null, {
id: id,
type: type,
attributes: attributes
attributes: attributes,
});
}
});
Expand All @@ -406,13 +406,13 @@ representation of the attributes to the UL type expected by the device:

```javascript
function createQueryFromAttributes(attributes) {
var query = '';
var query = "";

for (var i in attributes) {
query += attributes[i].name + '|' + attributes[i].value;
query += attributes[i].name + "|" + attributes[i].value;

if (i != attributes.length - 1) {
query += ',';
query += ",";
}
}

Expand Down Expand Up @@ -555,9 +555,9 @@ variable and afterward the value of the multiCore in the `config.js` file. The r
(the standard `http` module is also needed):

```javascript
var iotAgent = require('../lib/iotagent-implementation'),
iotAgentLib = require('iotagent-node-lib'),
config = require('./config');
var iotAgent = require("../lib/iotagent-implementation"),
iotAgentLib = require("iotagent-node-lib"),
config = require("./config");
```

It is important to mention the purpose of the `iotAgent` variable. It is the proper implementation of the IoT Agent
Expand All @@ -573,9 +573,9 @@ about starting the IoTAgent:
```javascript
iotAgentLib.startServer(config, iotAgent, function (error) {
if (error) {
console.log(context, 'Error starting IoT Agent: [%s] Exiting process', error);
console.log(context, "Error starting IoT Agent: [%s] Exiting process", error);
} else {
console.log(context, 'IoT Agent started');
console.log(context, "IoT Agent started");
}
});
```
Expand All @@ -602,7 +602,7 @@ handlers themselves. Here we can see the definition of the configuration handler

```javascript
function configurationHandler(configuration, callback) {
console.log('\n\n* REGISTERING A NEW CONFIGURATION:\n%s\n\n', JSON.stringify(configuration, null, 4));
console.log("\n\n* REGISTERING A NEW CONFIGURATION:\n%s\n\n", JSON.stringify(configuration, null, 4));
callback(null, configuration);
}
```
Expand All @@ -619,8 +619,8 @@ feature, let's use the provisioning handler to change the value of the type of t

```javascript
function provisioningHandler(device, callback) {
console.log('\n\n* REGISTERING A NEW DEVICE:\n%s\n\n', JSON.stringify(device, null, 4));
device.type = 'CertifiedType';
console.log("\n\n* REGISTERING A NEW DEVICE:\n%s\n\n", JSON.stringify(device, null, 4));
device.type = "CertifiedType";
callback(null, device);
}
```
Expand Down
2 changes: 1 addition & 1 deletion doc/installationguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ used for the same purpose. For instance:

```javascript
{
type: 'mongodb';
type: "mongodb";
}
```

Expand Down

0 comments on commit e6cf78e

Please sign in to comment.