Skip to content

Commit

Permalink
Added transports field to protocol in order to list supported transpo…
Browse files Browse the repository at this point in the history
…rt protocols of iot agent
  • Loading branch information
Cerfoglg authored and chicco785 committed Jun 11, 2019
1 parent 8a0edd8 commit 4c17103
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Whenever a new IoT Agent wants to register itself into the IoTAgent Manager, it
the following path: ``, indicating the following information:
* *protocol*: Name of the protocol served by the IoTAgent.
* *description*: Textual description for its display in portals.
* *transports*: List of transport protocols supported by the IoT Agent.
* *iotagent*: URL address where requests for this IoT Agent will be redirected.
* *resource*: Unique string used to identify different IoT Agents for the same protocol.
* *services*: List of device Configurations available in the IoT Agent. The IoTA Manager saves a cache for all the
Expand All @@ -139,6 +140,7 @@ IoT Agent:
{
"protocol": "GENERIC_PROTOCOL",
"description": "A generic protocol",
"transports": ["HTTP", "MQTP"],
"iotagent": "http://smartGondor.com/iot",
"resource": "/iot/d",
"services": [
Expand Down Expand Up @@ -174,6 +176,7 @@ response from the server:
{
"protocol" : "PDI-IoTA-UltraLight",
"description" : "UL2",
"transports" : ["HTTP", "MQTP"],
"endpoints" : [
{ "endpoint" : "http://127.0.0.1:8080/iot",
"identifier" : "idcl1:8080",
Expand Down
1 change: 1 addition & 0 deletions lib/model/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var Configuration = new Schema({
service: String,
protocol: String,
description: String,
transports: Array,
subservice: String,
cbHost: String,
timezone: String,
Expand Down
3 changes: 2 additions & 1 deletion lib/model/Protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var Protocol = new Schema({
iotagent: String,
resource: String,
protocol: String,
description: String
description: String,
transports: Array
});

function load(db) {
Expand Down
3 changes: 2 additions & 1 deletion lib/services/configurationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function createGetWithFields(fields) {
};
}

function save(protocol, description, iotagent, resource, configuration, oldConfiguration, callback) {
function save(protocol, description, transports, iotagent, resource, configuration, oldConfiguration, callback) {
var configurationObj = oldConfiguration || new Configuration.model(),
attributeList = [
'name',
Expand All @@ -123,6 +123,7 @@ function save(protocol, description, iotagent, resource, configuration, oldConfi

configurationObj.protocol = protocol;
configurationObj.description = description;
configurationObj.transports = transports;
configurationObj.iotagent = iotagent;
configurationObj.resource = resource;

Expand Down
1 change: 1 addition & 0 deletions lib/services/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function translateToApi(configurations) {
'resource',
'iotagent',
'description',
'transports',
'protocol',
'internalAttributes',
'attributes',
Expand Down
7 changes: 5 additions & 2 deletions lib/services/protocolData.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ var Protocol = require('../model/Protocol'),
op: 'IoTAManager.ProtocolAPI'
};

function processConfiguration(protocol, description, iotagent, resource, configuration, callback) {
function processConfiguration(protocol, description, transports, iotagent, resource, configuration, callback) {
configurations.get(configuration.apikey, resource, protocol, function(error, oldConfiguration) {
if (error) {
callback(error);
} else if (oldConfiguration.services.length === 0) {
configurations.save(
protocol,
description,
transports,
iotagent,
resource,
configuration,
Expand All @@ -52,6 +53,7 @@ function processConfiguration(protocol, description, iotagent, resource, configu
configurations.save(
protocol,
description,
transports,
iotagent,
resource,
configuration,
Expand Down Expand Up @@ -129,7 +131,7 @@ function save(newProtocol, callback) {
callback(error);
} else {
var protocolObj = protocol || new Protocol.model(),
attributeList = ['iotagent', 'resource', 'protocol', 'description'],
attributeList = ['iotagent', 'resource', 'protocol', 'description', 'transports'],
actions = [];

for (var i = 0; i < attributeList.length; i++) {
Expand All @@ -149,6 +151,7 @@ function save(newProtocol, callback) {
processConfiguration,
newProtocol.protocol,
newProtocol.description,
newProtocol.transports,
newProtocol.iotagent,
newProtocol.resource)));
}
Expand Down
7 changes: 6 additions & 1 deletion lib/templates/protocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"type": "string",
"required": true
},
"transports": {
"description": "The transport protocols supported by the IoT Agent",
"type": "array",
"required": false
},
"iotagent": {
"description": "URL Where the IoTAgent is listening",
"type": "string",
Expand Down Expand Up @@ -74,4 +79,4 @@
}
}
}
}
}

0 comments on commit 4c17103

Please sign in to comment.