From a4c3f3c7f1b86c1b138a23cf3a0b778f30b07789 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 27 Jan 2025 11:10:19 +0100 Subject: [PATCH 01/17] copy old jexlctxt into typeInformation --- lib/services/ngsi/entities-NGSI-v2.js | 2 ++ lib/services/ngsi/ngsiService.js | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 9f8a6e19c..5751add29 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -652,6 +652,8 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } } + //Add jexlctxt to typeInformation + typeInformation.oldCtxt = jexlctxt; } // end for (let measures of originMeasures) let url = '/v2/op/update'; if (originTypeInformation.useCBflowControl) { diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 3f2619f55..8b66a283a 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -69,15 +69,30 @@ function init() { * @param {String} token User token to identify against the PEP Proxies (optional). */ function sendUpdateValue(entityName, attributes, typeInformation, token, callback) { - // check config about store last measure const newCallback = statsRegistry.withStats('updateEntityRequestsOk', 'updateEntityRequestsError', callback); + const additionalCallback = (data, next) => { + logger.debug(context, 'aditionalCallback data %j typeInformation %j', data, typeInformation); + next(null, data); + }; + const wrappedNewCallback = (err, result) => { + if (err) { + return newCallback(err); + } + additionalCallback(result, (additionalErr, modifiedResult) => { + if (additionalErr) { + return newCallback(additionalErr); + } + newCallback(null, modifiedResult || result); + }); + }; + // check config about store last measure if (typeInformation.storeLastMeasure) { logger.debug(context, 'StoreLastMeasure for %j', typeInformation); deviceService.storeLastMeasure(attributes, typeInformation, function () { - return entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, newCallback); + return entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, wrappedNewCallback); }); } else { - entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, newCallback); + entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, wrappedNewCallback); } } From 20a7c4b4b444f3939d1de210a1ce24903a144607 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Mon, 27 Jan 2025 11:26:54 +0100 Subject: [PATCH 02/17] fix originTypeInformation --- lib/services/ngsi/entities-NGSI-v2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 5751add29..4bfd3de86 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -653,7 +653,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } //Add jexlctxt to typeInformation - typeInformation.oldCtxt = jexlctxt; + originTypeInformation.oldCtxt = jexlctxt; } // end for (let measures of originMeasures) let url = '/v2/op/update'; if (originTypeInformation.useCBflowControl) { From 0ca2ec6f905828a71093471b7979cf410ee25254 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 28 Jan 2025 16:32:05 +0100 Subject: [PATCH 03/17] store previous ctxt --- lib/services/devices/deviceRegistryMemory.js | 10 +++++++--- lib/services/devices/deviceRegistryMongoDB.js | 10 +++++++--- lib/services/devices/deviceService.js | 6 +++--- lib/services/ngsi/entities-NGSI-v2.js | 2 +- lib/services/ngsi/ngsiService.js | 17 ++++++++++++++--- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/lib/services/devices/deviceRegistryMemory.js b/lib/services/devices/deviceRegistryMemory.js index 3a81aec49..b75ee0c11 100644 --- a/lib/services/devices/deviceRegistryMemory.js +++ b/lib/services/devices/deviceRegistryMemory.js @@ -210,7 +210,7 @@ function getDevicesByAttribute(name, value, service, subservice, callback) { } } -function storeLastMeasure(measure, typeInformation, callback) { +function storeDeviceField(fieldName, fieldValue, typeInformation, callback) { if ( typeInformation && typeInformation.id && @@ -226,7 +226,11 @@ function storeLastMeasure(measure, typeInformation, callback) { function (error, data) { if (!error) { if (data) { - data.lastMeasure = measure; + if (fieldName === 'lastMeasure') { + data.lastMeasure = measure; + } else { + data[fieldName] = fieldValue; + } } if (callback) { callback(null, data); @@ -243,7 +247,7 @@ function storeLastMeasure(measure, typeInformation, callback) { exports.getDevicesByAttribute = getDevicesByAttribute; exports.store = storeDevice; -exports.storeLastMeasure = storeLastMeasure; +exports.storeDeviceField = storeDeviceField; exports.update = update; exports.remove = removeDevice; exports.list = listDevices; diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index a77241f44..3d3307a53 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -397,7 +397,7 @@ function getDevicesByAttribute(name, value, service, subservice, callback) { }); } -function storeLastMeasure(measure, typeInformation, callback) { +function storeDeviceField(fieldName, fieldValue, typeInformation, callback) { if ( typeInformation && typeInformation.id && @@ -414,7 +414,11 @@ function storeLastMeasure(measure, typeInformation, callback) { if (error) { callback(error); } else { - data.lastMeasure = { timestamp: new Date().toISOString(), measure }; + if (fieldName === 'lastMeasure') { + data.lastMeasure = { timestamp: new Date().toISOString(), fieldValue }; + } else { + data[fieldName] = fieldValue; + } /* eslint-disable-next-line new-cap */ const deviceObj = new Device.model(data); deviceObj.isNew = false; @@ -441,7 +445,7 @@ function storeLastMeasure(measure, typeInformation, callback) { exports.getDevicesByAttribute = alarmsInt(constants.MONGO_ALARM, getDevicesByAttribute); exports.store = alarmsInt(constants.MONGO_ALARM, storeDevice); -exports.storeLastMeasure = alarmsInt(constants.MONGO_ALARM, storeLastMeasure); +exports.storeDeviceField = alarmsInt(constants.MONGO_ALARM, storeDeviceField); exports.update = alarmsInt(constants.MONGO_ALARM, update); exports.remove = alarmsInt(constants.MONGO_ALARM, removeDevice); exports.list = alarmsInt(constants.MONGO_ALARM, listDevices); diff --git a/lib/services/devices/deviceService.js b/lib/services/devices/deviceService.js index 457b91e4f..be09cf5a6 100644 --- a/lib/services/devices/deviceService.js +++ b/lib/services/devices/deviceService.js @@ -717,8 +717,8 @@ function retrieveDevice(deviceId, apiKey, callback) { } } -function storeLastMeasure(measure, typeInformation, callback) { - config.getRegistry().storeLastMeasure(measure, typeInformation, callback); +function storeDeviceField(fieldName, fieldValue, typeInformation, callback) { + config.getRegistry().storeDeviceField(fieldName, fieldValue, typeInformation, callback); } exports.listDevices = intoTrans(context, checkRegistry)(listDevices); @@ -737,5 +737,5 @@ exports.retrieveDevice = intoTrans(context, checkRegistry)(retrieveDevice); exports.mergeDeviceWithConfiguration = mergeDeviceWithConfiguration; exports.findOrCreate = findOrCreate; exports.findConfigurationGroup = findConfigurationGroup; -exports.storeLastMeasure = storeLastMeasure; +exports.storeDeviceField = storeDeviceField; exports.init = init; diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index 4bfd3de86..eca7cd1ef 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -653,7 +653,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } //Add jexlctxt to typeInformation - originTypeInformation.oldCtxt = jexlctxt; + originTypeInformation['oldctxt'] = jexlctxt; } // end for (let measures of originMeasures) let url = '/v2/op/update'; if (originTypeInformation.useCBflowControl) { diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 8b66a283a..4300120cf 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -71,8 +71,19 @@ function init() { function sendUpdateValue(entityName, attributes, typeInformation, token, callback) { const newCallback = statsRegistry.withStats('updateEntityRequestsOk', 'updateEntityRequestsError', callback); const additionalCallback = (data, next) => { - logger.debug(context, 'aditionalCallback data %j typeInformation %j', data, typeInformation); - next(null, data); + if (typeInformation.oldctxt) { + logger.debug( + context, + 'aditionalCallback data %j typeInformation.oldctxt %j', + data, + typeInformation.oldctxt + ); + deviceService.storeDeviceField('oldctxt', typeInformation.oldctxt, typeInformation, function () { + next(null, data); + }); + } else { + next(null, data); + } }; const wrappedNewCallback = (err, result) => { if (err) { @@ -88,7 +99,7 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac // check config about store last measure if (typeInformation.storeLastMeasure) { logger.debug(context, 'StoreLastMeasure for %j', typeInformation); - deviceService.storeLastMeasure(attributes, typeInformation, function () { + deviceService.storeDeviceField('lastMeasure', attributes, typeInformation, function () { return entityHandler.sendUpdateValue(entityName, attributes, typeInformation, token, wrappedNewCallback); }); } else { From c195a694743d5cf6203e241242a3d46847c62117 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 28 Jan 2025 17:00:56 +0100 Subject: [PATCH 04/17] rename oldcxt to oldCtxt --- lib/model/Device.js | 3 ++- lib/services/ngsi/entities-NGSI-v2.js | 6 +++++- lib/services/ngsi/ngsiService.js | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/model/Device.js b/lib/model/Device.js index 6f7d44920..07b8342e9 100644 --- a/lib/model/Device.js +++ b/lib/model/Device.js @@ -56,7 +56,8 @@ const Device = new Schema({ payloadType: String, useCBflowControl: Boolean, storeLastMeasure: Boolean, - lastMeasure: Object + lastMeasure: Object, + oldCtxt: Object }); function load() { diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index eca7cd1ef..d5397c55d 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -347,6 +347,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, //metadata static attributes jexlctxt = reduceMetadataAttrToPlainObject(typeInformation.staticAttributes, jexlctxt); + //recover oldctxt + if (typeInformation.oldCtxt) { + jexlctxt.oldCtxt = typeInformation.oldCtxt; + } logger.debug( context, 'sendUpdateValueNgsi2 loop with: entityName=%s, measures=%j, typeInformation=%j, initial jexlContext=%j, timestamp=%j', @@ -653,7 +657,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } //Add jexlctxt to typeInformation - originTypeInformation['oldctxt'] = jexlctxt; + originTypeInformation['oldCtxt'] = jexlctxt; } // end for (let measures of originMeasures) let url = '/v2/op/update'; if (originTypeInformation.useCBflowControl) { diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 4300120cf..8ded51406 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -71,14 +71,14 @@ function init() { function sendUpdateValue(entityName, attributes, typeInformation, token, callback) { const newCallback = statsRegistry.withStats('updateEntityRequestsOk', 'updateEntityRequestsError', callback); const additionalCallback = (data, next) => { - if (typeInformation.oldctxt) { + if (typeInformation.oldCtxt) { logger.debug( context, - 'aditionalCallback data %j typeInformation.oldctxt %j', + 'aditionalCallback data %j typeInformation.oldCtxt %j', data, - typeInformation.oldctxt + typeInformation.oldCtxt ); - deviceService.storeDeviceField('oldctxt', typeInformation.oldctxt, typeInformation, function () { + deviceService.storeDeviceField('oldCtxt', typeInformation.oldCtxt, typeInformation, function () { next(null, data); }); } else { From b0ea7d66ab713f5c4aaebb850d9387b15c76ca87 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 28 Jan 2025 17:18:46 +0100 Subject: [PATCH 05/17] fix measure key --- lib/services/devices/deviceRegistryMongoDB.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/devices/deviceRegistryMongoDB.js b/lib/services/devices/deviceRegistryMongoDB.js index 3d3307a53..0edb73ac7 100644 --- a/lib/services/devices/deviceRegistryMongoDB.js +++ b/lib/services/devices/deviceRegistryMongoDB.js @@ -415,7 +415,7 @@ function storeDeviceField(fieldName, fieldValue, typeInformation, callback) { callback(error); } else { if (fieldName === 'lastMeasure') { - data.lastMeasure = { timestamp: new Date().toISOString(), fieldValue }; + data.lastMeasure = { timestamp: new Date().toISOString(), measure: fieldValue }; } else { data[fieldName] = fieldValue; } From 87615229a076f1d1a00710a7ac24b237ecb599d6 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 28 Jan 2025 17:31:42 +0100 Subject: [PATCH 06/17] store jexlctxt without oldCtxt --- lib/services/ngsi/entities-NGSI-v2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/services/ngsi/entities-NGSI-v2.js b/lib/services/ngsi/entities-NGSI-v2.js index d5397c55d..e180e607a 100644 --- a/lib/services/ngsi/entities-NGSI-v2.js +++ b/lib/services/ngsi/entities-NGSI-v2.js @@ -656,8 +656,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, } } } - //Add jexlctxt to typeInformation - originTypeInformation['oldCtxt'] = jexlctxt; + //Add jexlctxt to typeInformation without oldCtxt + const oldCJexlctxt = { ...jexlctxt }; + delete oldCJexlctxt.oldCtxt; + originTypeInformation['oldCtxt'] = oldCJexlctxt; } // end for (let measures of originMeasures) let url = '/v2/op/update'; if (originTypeInformation.useCBflowControl) { From 1c3489b15081a92f096a88869860fd30e7ee1070 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 28 Jan 2025 17:43:20 +0100 Subject: [PATCH 07/17] fix lint --- lib/services/devices/deviceRegistryMemory.js | 2 +- lib/services/ngsi/ngsiService.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/devices/deviceRegistryMemory.js b/lib/services/devices/deviceRegistryMemory.js index b75ee0c11..93f94f034 100644 --- a/lib/services/devices/deviceRegistryMemory.js +++ b/lib/services/devices/deviceRegistryMemory.js @@ -227,7 +227,7 @@ function storeDeviceField(fieldName, fieldValue, typeInformation, callback) { if (!error) { if (data) { if (fieldName === 'lastMeasure') { - data.lastMeasure = measure; + data.lastMeasure = { timestamp: new Date().toISOString(), measure: fieldValue }; } else { data[fieldName] = fieldValue; } diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 8ded51406..bbbc7b093 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -87,11 +87,11 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac }; const wrappedNewCallback = (err, result) => { if (err) { - return newCallback(err); + newCallback(err); } additionalCallback(result, (additionalErr, modifiedResult) => { if (additionalErr) { - return newCallback(additionalErr); + newCallback(additionalErr); } newCallback(null, modifiedResult || result); }); From 50a32018c7a4a01bfe0b2cd0b36be22d689f6d96 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 08:41:34 +0100 Subject: [PATCH 08/17] fix return callback when error --- lib/services/ngsi/ngsiService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index bbbc7b093..8ded51406 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -87,11 +87,11 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac }; const wrappedNewCallback = (err, result) => { if (err) { - newCallback(err); + return newCallback(err); } additionalCallback(result, (additionalErr, modifiedResult) => { if (additionalErr) { - newCallback(additionalErr); + return newCallback(additionalErr); } newCallback(null, modifiedResult || result); }); From c21496e751520a02755f1ce4052f574ba1e7b7dc Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 09:09:47 +0100 Subject: [PATCH 09/17] fix return callback when error --- lib/services/ngsi/ngsiService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 8ded51406..69aedb7d8 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -93,7 +93,7 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac if (additionalErr) { return newCallback(additionalErr); } - newCallback(null, modifiedResult || result); + return newCallback(null, modifiedResult || result); }); }; // check config about store last measure From eda40963678bfdfcb150ef0fe47448419af8145f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:00:38 +0100 Subject: [PATCH 10/17] fix linter --- lib/services/ngsi/ngsiService.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index 69aedb7d8..fb5e6f6fd 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -87,14 +87,15 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac }; const wrappedNewCallback = (err, result) => { if (err) { - return newCallback(err); + newCallback(err); + } else { + additionalCallback(result, (additionalErr, modifiedResult) => { + if (additionalErr) { + newCallback(additionalErr); + } + newCallback(null, modifiedResult || result); + }); } - additionalCallback(result, (additionalErr, modifiedResult) => { - if (additionalErr) { - return newCallback(additionalErr); - } - return newCallback(null, modifiedResult || result); - }); }; // check config about store last measure if (typeInformation.storeLastMeasure) { From 9418cf92daa4d0b237686bb1ade32c309216f14f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:07:28 +0100 Subject: [PATCH 11/17] update api --- doc/api.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/api.md b/doc/api.md index f5115c2be..ada28fb00 100644 --- a/doc/api.md +++ b/doc/api.md @@ -623,6 +623,7 @@ expression. In all cases the following data is available to all expressions: - `service`: device service (`Fiware-Service`) - `subservice`: device subservice (`Fiware-ServicePath`) - `staticAttributes`: static attributes defined in the device or config group +- `oldCtxt`: previous jexl context (related to last processed measure) Additionally, for attribute expressions (`expression`, `entity_name`), `entityNameExp` and metadata expressions (`expression`) the following is available in the **context** used to evalute: @@ -1998,10 +1999,11 @@ the API resource fields and the same fields in the database model. | `internal_attributes` | ✓ | `array` | | List of internal attributes with free format for specific IoT Agent configuration. | | `explicitAttrs` | ✓ | `boolean` | ✓ | Field to support selective ignore of measures so that IOTA doesn’t progress. See details in [specific section](#explicitly-defined-attributes-explicitattrs) | | `ngsiVersion` | ✓ | `string` | | string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | -| `payloadType` | ✓ | `string` | | optional string value used to switch between **IoTAgent**, **NGSI-v2** and **NGSI-LD** measure payloads types. Possible values are: `iotagent`, `ngsiv2` or `ngsild`. The default is `iotagent`. | -| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. See more info [in this section](admin.md#storelastmeasure). False by default. | -| `lastMeasure` | ✓ | `object` | | last measure stored on device when `storeLastMeasure` is enabled. See more info [in this section](admin.md#storelastmeasure). This field can be cleared using `{}` in a device update request. In that case, `lastMeasure` is removed from device (until a next measure is received and `lastMesuare` gets created again). | -| `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default. | +| `payloadType` | ✓ | `string` | | optional string value used to switch between **IoTAgent**, **NGSI-v2** and **NGSI-LD** measure payloads types. Possible values are: `iotagent`, `ngsiv2` or `ngsild`. The default is `iotagent`. | +| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. Usefull just for debuging purpose. See more info [in this section](admin.md#storelastmeasure). False by default. | +| `lastMeasure` | ✓ | `object` | | last measure stored on device when `storeLastMeasure` is enabled. See more info [in this section](admin.md#storelastmeasure). This field can be cleared using `{}` in a device update request. In that case, `lastMeasure` is removed from device (until a next measure is received and `lastMesuare` gets created again). | +| `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default. | + ### Device operations #### Retrieve devices /iot/devices `GET /iot/devices` From b736b36432c0cac05dc1c5df0d149b3988f50ab3 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:12:39 +0100 Subject: [PATCH 12/17] fix typo --- doc/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api.md b/doc/api.md index ada28fb00..9382f4d6a 100644 --- a/doc/api.md +++ b/doc/api.md @@ -2000,7 +2000,7 @@ the API resource fields and the same fields in the database model. | `explicitAttrs` | ✓ | `boolean` | ✓ | Field to support selective ignore of measures so that IOTA doesn’t progress. See details in [specific section](#explicitly-defined-attributes-explicitattrs) | | `ngsiVersion` | ✓ | `string` | | string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | | `payloadType` | ✓ | `string` | | optional string value used to switch between **IoTAgent**, **NGSI-v2** and **NGSI-LD** measure payloads types. Possible values are: `iotagent`, `ngsiv2` or `ngsild`. The default is `iotagent`. | -| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. Usefull just for debuging purpose. See more info [in this section](admin.md#storelastmeasure). False by default. | +| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. Usefull just for debugging purpose. See more info [in this section](admin.md#storelastmeasure). False by default. | | `lastMeasure` | ✓ | `object` | | last measure stored on device when `storeLastMeasure` is enabled. See more info [in this section](admin.md#storelastmeasure). This field can be cleared using `{}` in a device update request. In that case, `lastMeasure` is removed from device (until a next measure is received and `lastMesuare` gets created again). | | `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default. | From e78b5edef577cf1ef7d867214a3d74c99de90612 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:14:31 +0100 Subject: [PATCH 13/17] update CNR --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index b5c1f8c7f..f1471b860 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,4 @@ +- Add: store (and recover) previous jexlctxt and make aviailable in current jexlctxt (#1690) - Fix: set polling and transport for autoprovisioned devices - Add: option to force to use CB flow control with new API field useCBflowControl at group and device device level (#1420) - Add: useCBflowControl config setting (IOTA_CB_FLOW_CONTROL env var) to set CB flow control behaviour at instance level (#1420) From ad8152d6d3c7644a5ff6390111e6ccfbda4ec585 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:23:36 +0100 Subject: [PATCH 14/17] fix jexl to uppercase --- doc/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api.md b/doc/api.md index 9382f4d6a..0423022df 100644 --- a/doc/api.md +++ b/doc/api.md @@ -623,7 +623,7 @@ expression. In all cases the following data is available to all expressions: - `service`: device service (`Fiware-Service`) - `subservice`: device subservice (`Fiware-ServicePath`) - `staticAttributes`: static attributes defined in the device or config group -- `oldCtxt`: previous jexl context (related to last processed measure) +- `oldCtxt`: previous JEXL context (related to last processed measure) Additionally, for attribute expressions (`expression`, `entity_name`), `entityNameExp` and metadata expressions (`expression`) the following is available in the **context** used to evalute: From b73decacac1fca4056910dc6a2e67732cb12552f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 10:26:18 +0100 Subject: [PATCH 15/17] fix wording --- doc/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api.md b/doc/api.md index 0423022df..c836f29c8 100644 --- a/doc/api.md +++ b/doc/api.md @@ -2000,7 +2000,7 @@ the API resource fields and the same fields in the database model. | `explicitAttrs` | ✓ | `boolean` | ✓ | Field to support selective ignore of measures so that IOTA doesn’t progress. See details in [specific section](#explicitly-defined-attributes-explicitattrs) | | `ngsiVersion` | ✓ | `string` | | string value used in mixed mode to switch between **NGSI-v2** and **NGSI-LD** payloads. The default is `v2`. When not running in mixed mode, this field is ignored. | | `payloadType` | ✓ | `string` | | optional string value used to switch between **IoTAgent**, **NGSI-v2** and **NGSI-LD** measure payloads types. Possible values are: `iotagent`, `ngsiv2` or `ngsild`. The default is `iotagent`. | -| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. Usefull just for debugging purpose. See more info [in this section](admin.md#storelastmeasure). False by default. | +| `storeLastMeasure` | ✓ | `boolean` | | Store in device last measure received. Useful just for debugging purpose. See more info [in this section](admin.md#storelastmeasure). False by default. | | `lastMeasure` | ✓ | `object` | | last measure stored on device when `storeLastMeasure` is enabled. See more info [in this section](admin.md#storelastmeasure). This field can be cleared using `{}` in a device update request. In that case, `lastMeasure` is removed from device (until a next measure is received and `lastMesuare` gets created again). | | `useCBflowControl` | ✓ | `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default. | From 3e9aae2a5cd2dd97c8500dc59e7311425dd2f941 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Wed, 29 Jan 2025 15:43:02 +0100 Subject: [PATCH 16/17] clean debug log --- lib/services/ngsi/ngsiService.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/services/ngsi/ngsiService.js b/lib/services/ngsi/ngsiService.js index fb5e6f6fd..28b34c518 100644 --- a/lib/services/ngsi/ngsiService.js +++ b/lib/services/ngsi/ngsiService.js @@ -72,12 +72,7 @@ function sendUpdateValue(entityName, attributes, typeInformation, token, callbac const newCallback = statsRegistry.withStats('updateEntityRequestsOk', 'updateEntityRequestsError', callback); const additionalCallback = (data, next) => { if (typeInformation.oldCtxt) { - logger.debug( - context, - 'aditionalCallback data %j typeInformation.oldCtxt %j', - data, - typeInformation.oldCtxt - ); + logger.debug(context, 'StoreOldCtxt %j', typeInformation.oldCtxt); deviceService.storeDeviceField('oldCtxt', typeInformation.oldCtxt, typeInformation, function () { next(null, data); }); From 3ca642ca455bd973ece632dcdd040601f9001346 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 30 Jan 2025 16:01:33 +0100 Subject: [PATCH 17/17] 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 f1471b860..c4c51bcdd 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,4 +1,4 @@ -- Add: store (and recover) previous jexlctxt and make aviailable in current jexlctxt (#1690) +- Add: store (and recover) previous jexlctxt and make available in current jexlctxt (#1690) - Fix: set polling and transport for autoprovisioned devices - Add: option to force to use CB flow control with new API field useCBflowControl at group and device device level (#1420) - Add: useCBflowControl config setting (IOTA_CB_FLOW_CONTROL env var) to set CB flow control behaviour at instance level (#1420)