From 494aed91ae65123020e2a8c9d2931b925dd0d71e Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 21 May 2024 16:19:06 +0200 Subject: [PATCH 1/9] send to CB using multimeasures --- lib/bindings/HTTPBindings.js | 6 +++--- lib/commonBindings.js | 36 ++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/bindings/HTTPBindings.js b/lib/bindings/HTTPBindings.js index dbb99537..fe8a0d73 100644 --- a/lib/bindings/HTTPBindings.js +++ b/lib/bindings/HTTPBindings.js @@ -214,7 +214,7 @@ function returnCommands(req, res, next) { } function handleIncomingMeasure(req, res, next) { - let updates = []; + let update = []; context = fillService(context, { service: 'n/a', subservice: 'n/a' }); // prettier-ignore config.getLogger().debug(context, 'Processing multiple HTTP measures for device %s with apiKey %j', @@ -223,10 +223,10 @@ function handleIncomingMeasure(req, res, next) { function processHTTPWithDevice(device) { context = fillService(context, device); if (req.ulPayload) { - updates = req.ulPayload.reduce(commonBindings.processMeasureGroup.bind(null, device, req.apiKey), []); + update = [req.ulPayload].reduce(commonBindings.processMeasureGroup.bind(null, device, req.apiKey), []); } - async.series(updates, function (error) { + async.series(update, function (error) { if (error) { next(error); // prettier-ignore diff --git a/lib/commonBindings.js b/lib/commonBindings.js index 23fffa28..63e887cd 100644 --- a/lib/commonBindings.js +++ b/lib/commonBindings.js @@ -128,32 +128,36 @@ function manageConfigurationRequest(apiKey, deviceId, device, objMessage) { /* eslint-disable-next-line no-unused-vars */ function processMeasureGroup(device, apikey, previous, current, index) { - const values = []; - if (current.command) { + if (current[0] && current[0].command) { previous.push( iotAgentLib.setCommandResult.bind( null, device.name, config.getConfig().iota.defaultResource, apikey, - current.command, - current.value, + current[0].command, + current[0].value, constants.COMMAND_STATUS_COMPLETED, device ) ); } else { - for (const k in current) { - if (current.hasOwnProperty(k)) { - values.push({ - name: k, - type: guessType(k, device), - value: current[k] - }); + const val = []; + for (let curr of current) { + const values = []; + for (const k in curr) { + if (curr.hasOwnProperty(k)) { + values.push({ + name: k, + type: guessType(k, device), + value: curr[k] + }); + } } + val.push(values); } - - previous.push(iotAgentLib.update.bind(null, device.name, device.type, '', values, device)); + config.getLogger().debug(context, 'VAL %j', val); + previous.push(iotAgentLib.update.bind(null, device.name, device.type, '', val, device)); } return previous; @@ -168,7 +172,7 @@ function processMeasureGroup(device, apikey, previous, current, index) { * @param {String} messageStr UL payload parsed to string. */ function multipleMeasures(apiKey, device, messageStr) { - let updates = []; + let update = []; let parsedMessage; context = fillService(context, device); config.getLogger().debug(context, 'Processing multiple measures for device %s with apiKey %s', device.id, apiKey); @@ -181,9 +185,9 @@ function multipleMeasures(apiKey, device, messageStr) { return; } config.getLogger().debug(context, 'stringMessage: %s parsedMessage: %s', messageStr, parsedMessage); - updates = parsedMessage.reduce(processMeasureGroup.bind(null, device, apiKey), []); + update = [parsedMessage].reduce(processMeasureGroup.bind(null, device, apiKey), []); - async.series(updates, function (error) { + async.series(update, function (error) { if (error) { config.getLogger().error( context, From 85a0eee50a48cccb54c8563a1f8caf821ba4ab2f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 21 May 2024 16:38:38 +0200 Subject: [PATCH 2/9] update httpBinding test --- .../ngsiv2/contextRequests/multimeasure.json | 21 + .../ngsiv2/contextRequests/multimeasure2.json | 29 + .../ngsiv2/contextRequests/multimeasure3.json | 499 ++++++++++++++++++ test/unit/ngsiv2/httpBindings-test.js | 54 +- 4 files changed, 555 insertions(+), 48 deletions(-) create mode 100644 test/unit/ngsiv2/contextRequests/multimeasure.json create mode 100644 test/unit/ngsiv2/contextRequests/multimeasure2.json create mode 100644 test/unit/ngsiv2/contextRequests/multimeasure3.json diff --git a/test/unit/ngsiv2/contextRequests/multimeasure.json b/test/unit/ngsiv2/contextRequests/multimeasure.json new file mode 100644 index 00000000..3802eafb --- /dev/null +++ b/test/unit/ngsiv2/contextRequests/multimeasure.json @@ -0,0 +1,21 @@ +{ + "actionType": "append", + "entities": [ + { + "id": "Second UL Device", + "type": "AnMQTTDevice", + "temperature": { + "type": "celsius", + "value": 23 + } + }, + { + "id": "Second UL Device", + "type": "AnMQTTDevice", + "humidity": { + "type": "degrees", + "value": 98 + } + } + ] +} diff --git a/test/unit/ngsiv2/contextRequests/multimeasure2.json b/test/unit/ngsiv2/contextRequests/multimeasure2.json new file mode 100644 index 00000000..55c8bb70 --- /dev/null +++ b/test/unit/ngsiv2/contextRequests/multimeasure2.json @@ -0,0 +1,29 @@ +{ + "actionType": "append", + "entities": [ + { + "id": "Second UL Device", + "type": "AnMQTTDevice", + "temperature": { + "type": "celsius", + "value": 23 + }, + "humidity": { + "type": "degrees", + "value": 98 + } + }, + { + "id": "Second UL Device", + "type": "AnMQTTDevice", + "temperature": { + "type": "celsius", + "value": 16 + }, + "humidity": { + "type": "degrees", + "value": 34 + } + } + ] +} diff --git a/test/unit/ngsiv2/contextRequests/multimeasure3.json b/test/unit/ngsiv2/contextRequests/multimeasure3.json new file mode 100644 index 00000000..2667a40b --- /dev/null +++ b/test/unit/ngsiv2/contextRequests/multimeasure3.json @@ -0,0 +1,499 @@ +{ + "actionType": "append", + "entities": [ + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "temperature:ambient": { + "type": "float", + "value": 24.4, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "hum": { + "type": "Text", + "value": 58, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "aco": { + "type": "Text", + "value": 0.1, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "apa": { + "type": "Text", + "value": 0.38, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "ao3": { + "type": "Text", + "value": 121, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "no2": { + "type": "Text", + "value": 115, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "pla": { + "type": "Text", + "value": 43.4551, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "plo": { + "type": "Text", + "value": -3.83381, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "poa": { + "type": "Text", + "value": 28, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "spi": { + "type": "Text", + "value": 0, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "dia": { + "type": "Text", + "value": 0, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "mit": { + "type": "Text", + "value": 1492, + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + }, + { + "id": "urn:x-iot:smartsantander:u7jcfa:fixed:t311", + "type": "repeater:illuminance", + "att_name": { + "type": "string", + "value": "value", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "coords": { + "type": "string", + "value": "WGS84", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "pos": { + "type": "Text", + "value": "43.4630608,-3.8345434", + "metadata": { + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + }, + "TimeInstant": { + "type": "DateTime", + "value": "2024-05-21T16:33:16.657+02:00" + } + } + ] +} diff --git a/test/unit/ngsiv2/httpBindings-test.js b/test/unit/ngsiv2/httpBindings-test.js index 6bdc3b79..056dd7a3 100644 --- a/test/unit/ngsiv2/httpBindings-test.js +++ b/test/unit/ngsiv2/httpBindings-test.js @@ -391,19 +391,7 @@ describe('HTTP Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/singleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondSingleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure.json')) .reply(204); }); @@ -440,19 +428,7 @@ describe('HTTP Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multipleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondMultipleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure2.json')) .reply(204); }); @@ -650,28 +626,10 @@ describe('HTTP Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - // Note: The expected body payload is not set explicitly since this mock will be used to - // intercept requests from the IOTA to the CB for each one of the different observations. - // Therefore, instead of introducing 13 different mocks, we have decided to have a single one - // and just check the structure of the payload programmatically. - .post('/v2/entities?options=upsert', function (body) { - let i = 0; - let attributes = 0; - - for (const attribute in body) { - // checks that all attributes has metadata - if (body.hasOwnProperty(attribute)) { - attributes++; - for (const metadata in body[attribute].metadata) { - if (body[attribute].metadata.hasOwnProperty(metadata)) { - i++; - } - } - } - } - return i === attributes - 1 - 2; - }) - .times(13) + .post( + '/v2/op/update' + //utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure3.json') + ) .reply(204); config.iota.timestamp = true; // forces to add timestamp att and metadata with timeinstant to all attributes From c74bdc5e1301719de776af82e2c21d52f0e06be2 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 21 May 2024 17:19:30 +0200 Subject: [PATCH 3/9] update tests --- test/unit/ngsiv2/amqpBinding-test.js | 28 ++-------------------------- test/unit/ngsiv2/mqttBinding-test.js | 28 ++-------------------------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/test/unit/ngsiv2/amqpBinding-test.js b/test/unit/ngsiv2/amqpBinding-test.js index ae43f19a..b4a7746a 100644 --- a/test/unit/ngsiv2/amqpBinding-test.js +++ b/test/unit/ngsiv2/amqpBinding-test.js @@ -218,19 +218,7 @@ describe('AMQP Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/singleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondSingleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure.json')) .reply(204); }); @@ -248,19 +236,7 @@ describe('AMQP Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multipleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondMultipleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure2.json')) .reply(204); }); diff --git a/test/unit/ngsiv2/mqttBinding-test.js b/test/unit/ngsiv2/mqttBinding-test.js index 1876bb58..47c4d778 100644 --- a/test/unit/ngsiv2/mqttBinding-test.js +++ b/test/unit/ngsiv2/mqttBinding-test.js @@ -289,19 +289,7 @@ describe('MQTT Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/singleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondSingleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure.json')) .reply(204); }); @@ -329,19 +317,7 @@ describe('MQTT Transport binding: measures', function () { contextBrokerMock .matchHeader('fiware-service', 'smartgondor') .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multipleMeasure.json') - ) - .reply(204); - - contextBrokerMock - .matchHeader('fiware-service', 'smartgondor') - .matchHeader('fiware-servicepath', '/gardens') - .post( - '/v2/entities?options=upsert', - utils.readExampleFile('./test/unit/ngsiv2/contextRequests/secondMultipleMeasure.json') - ) + .post('/v2/op/update', utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure2.json')) .reply(204); }); From 7a3cd10316fed59e1afda7ccd26fb2255197bf16 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 21 May 2024 17:21:13 +0200 Subject: [PATCH 4/9] remove log --- lib/commonBindings.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/commonBindings.js b/lib/commonBindings.js index 63e887cd..2f8d9ea1 100644 --- a/lib/commonBindings.js +++ b/lib/commonBindings.js @@ -156,7 +156,6 @@ function processMeasureGroup(device, apikey, previous, current, index) { } val.push(values); } - config.getLogger().debug(context, 'VAL %j', val); previous.push(iotAgentLib.update.bind(null, device.name, device.type, '', val, device)); } From 830dc50e7ce8ea1d3c139dd1e7f95534db39f127 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 22 May 2024 08:33:22 +0200 Subject: [PATCH 5/9] Update usermanual.md --- docs/usermanual.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/usermanual.md b/docs/usermanual.md index 0cb8de8a..e7f335fa 100644 --- a/docs/usermanual.md +++ b/docs/usermanual.md @@ -30,15 +30,14 @@ t|15|k|abc In this example, two attributes, one named "t" with value "15" and another named "k" with value "abc" are transmitted. Values in Ultralight 2.0 are not typed (everything is treated as a string). -Multiple groups of measures can be combined into a single request, using the `#` character. In that case, a different +Multiple groups of measures can be combined into a single request (but just for HTTP/POST or MQTT), using the `#` character. In that case, a different NGSI request will be generated for each group of measures. E.g.: ```text gps|1.2/3.4#t|10 ``` -This will generate two NGSI requests for the same entity, one for each one of the values. Each one of those requests can -contain any number of attributes. +This will generate two elements in the NGSI batch update request (POST /v2/op/update) for the same entity, one for each one of the measures. Each one of those elements can contain any number of attributes. Measure groups can additionally have an optional timestamp, with the following syntax: From 8e9f3c36e003c75d6a6f7a102b813e2ff09600bd Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 22 May 2024 08:35:41 +0200 Subject: [PATCH 6/9] update CNR --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index b05eacdd..f3e5c58f 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ +- Fix: allow send multiple measures to CB in a batch (POTS /v2/op/update) instead of using multiples single request (iotagent-json#825) - Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (iota-json#827) From d62dc2b1eac46b15dab5af003119fc2d08f184f4 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 23 May 2024 08:04:30 +0200 Subject: [PATCH 7/9] Update CHANGES_NEXT_RELEASE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- CHANGES_NEXT_RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index f3e5c58f..19cce0b9 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,2 +1,2 @@ -- Fix: allow send multiple measures to CB in a batch (POTS /v2/op/update) instead of using multiples single request (iotagent-json#825) +- Fix: allow send multiple measures to CB in a batch (POST /v2/op/update) and sorted by TimeInstant when possible, instead of using multiples single request (iotagent-json#825, iotagent-node-lib#1612) - Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (iota-json#827) From 357667ea6222e3fd7d4732d1f5d09d4f58402e47 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 23 May 2024 12:52:55 +0200 Subject: [PATCH 8/9] Update httpBindings-test.js --- test/unit/ngsiv2/httpBindings-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/ngsiv2/httpBindings-test.js b/test/unit/ngsiv2/httpBindings-test.js index 056dd7a3..6a56f826 100644 --- a/test/unit/ngsiv2/httpBindings-test.js +++ b/test/unit/ngsiv2/httpBindings-test.js @@ -628,7 +628,6 @@ describe('HTTP Transport binding: measures', function () { .matchHeader('fiware-servicepath', '/gardens') .post( '/v2/op/update' - //utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure3.json') ) .reply(204); From 83ba4445002e2af5343f0f8fc3a3e1f4a91de3b7 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 23 May 2024 13:04:05 +0200 Subject: [PATCH 9/9] Update httpBindings-test.js --- test/unit/ngsiv2/httpBindings-test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unit/ngsiv2/httpBindings-test.js b/test/unit/ngsiv2/httpBindings-test.js index 6a56f826..0e49590d 100644 --- a/test/unit/ngsiv2/httpBindings-test.js +++ b/test/unit/ngsiv2/httpBindings-test.js @@ -628,6 +628,8 @@ describe('HTTP Transport binding: measures', function () { .matchHeader('fiware-servicepath', '/gardens') .post( '/v2/op/update' + // FIXME: Mock about current timestamp + //utils.readExampleFile('./test/unit/ngsiv2/contextRequests/multimeasure3.json') ) .reply(204);