Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Fix: processing configurations subscriptions in NGSIv2 (#563)
Fix: check access to active attribute of device before use it (#576)
Remove: obsolete Thinking Things plugin (#573)
Remove: NGSI-v1 specific behaviours (#533)
5 changes: 1 addition & 4 deletions lib/commonBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ function guessType(attribute, device) {
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGES_NEXT_RELEASE entry is needed. Something like this:

- Remove: NGSI-v1 specific behaviours

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fd29166


if (attribute === constants.TIMESTAMP_ATTRIBUTE) {
if (iotAgentLib.configModule.isCurrentNgsi()) {
return constants.TIMESTAMP_TYPE_NGSI2;
}
return constants.TIMESTAMP_TYPE;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If TIMESTAMP_TYPE constant is not used in any place, we could remove it from the source file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c904dfb

return constants.TIMESTAMP_TYPE_NGSI2;
}
return constants.DEFAULT_ATTRIBUTE_TYPE;
}
Expand Down
1 change: 0 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module.exports = {
HTTP_COMMANDS_PATH: '/commands',

TIMESTAMP_ATTRIBUTE: 'TimeInstant',
TIMESTAMP_TYPE: 'ISO8601',
TIMESTAMP_TYPE_NGSI2: 'DateTime',

DEFAULT_ATTRIBUTE_TYPE: 'string',
Expand Down
34 changes: 6 additions & 28 deletions lib/iotaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,10 @@ function manageConfiguration(apiKey, deviceId, device, objMessage, sendFunction,
callback(error);
}

function extractAttributes(results, callback) {
if (iotAgentLib.configModule.isCurrentNgsi()) {
callback(null, results);
} else if (
results.contextResponses &&
results.contextResponses[0] &&
results.contextResponses[0].contextElement.attributes
) {
callback(null, results.contextResponses[0].contextElement.attributes);
} else {
callback("Couldn't find any information in Context Broker response: " + JSON.stringify(results));
}
}

if (objMessage.type === 'configuration') {
async.waterfall(
[
apply(iotAgentLib.query, device.name, device.type, '', objMessage.fields, device),
extractAttributes,
apply(sendFunction, apiKey, deviceId)
],
handleSendConfigurationError
Expand Down Expand Up @@ -138,22 +123,15 @@ function createConfigurationNotification(results) {
const configurations = {};
const now = new Date();

if (iotAgentLib.configModule.isCurrentNgsi()) {
// If it is the result of a subscription, results is an array
if (Array.isArray(results)){
for (let i = 0; i < results.length; i++) {
configurations[results[i].name] = results[i].value;
}
}
else {
for (var att in results) {
configurations[att] = results[att].value;
}
}
} else {
// If it is the result of a subscription, results is an array
if (Array.isArray(results)) {
for (let i = 0; i < results.length; i++) {
configurations[results[i].name] = results[i].value;
}
} else {
for (var att in results) {
configurations[att] = results[att].value;
}
}

configurations.dt = dateFormat(now, constants.DATE_FORMAT);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"body-parser": "1.18.3",
"dateformat": "3.0.3",
"express": "~4.16.4",
"iotagent-node-lib": "git://github.com/telefonicaid/iotagent-node-lib.git#master",
"iotagent-node-lib": "git://github.com/jason-fox/iotagent-node-lib.git#feature/ngsi-v1",
"logops": "2.1.0",
"mqtt": "3.0.0",
"request": "2.88.0",
Expand Down