Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix service and subservice to 'n/a' when apikey from measure is not found (needs iota-node-lib => 2.18) (#587)
- Remove: NGSI-v1 specific behaviours (iotagent-lib#966)
5 changes: 1 addition & 4 deletions lib/commonBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,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