Skip to content

Commit

Permalink
Merge pull request #467 from telefonicaid/test-ngsiv1-removal
Browse files Browse the repository at this point in the history
NGSIv1 removal
  • Loading branch information
mapedraza authored Sep 15, 2021
2 parents f488133 + 0554f1e commit 9e4bc27
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 33 deletions.
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) (#508)
- 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 @@ -57,10 +57,7 @@ function guessType(attribute, device) {
}

if (attribute === constants.TIMESTAMP_ATTRIBUTE) {
if (iotAgentLib.configModule.isCurrentNgsi()) {
return constants.TIMESTAMP_TYPE_NGSI2;
}
return constants.TIMESTAMP_TYPE;
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 @@ -33,7 +33,6 @@ module.exports = {
DATE_FORMAT: "yyyymmdd'T'HHMMss'Z'",

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

HTTP_MEASURE_PATH: '/iot/d',
Expand Down
34 changes: 6 additions & 28 deletions lib/iotaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,25 +299,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.attributes, device),
extractAttributes,
apply(sendFunction, apiKey, deviceId)
],
handleSendConfigurationError
Expand Down Expand Up @@ -358,22 +343,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

0 comments on commit 9e4bc27

Please sign in to comment.