Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transports field for protocol #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
}
}
}
}