iotagent-node-lib 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +134 -0
- package/.github/ISSUE_TEMPLATE/config.yml +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
- package/.github/advanced-issue-labeler.yml +30 -0
- package/.github/workflows/issue-labeler.yml +43 -0
- package/README.md +10 -11
- package/doc/README.md +16 -0
- package/doc/admin.md +565 -0
- package/doc/api.md +32 -85
- package/doc/deprecated.md +16 -10
- package/doc/{architecture.md → devel/architecture.md} +3 -3
- package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
- package/doc/devel/development.md +1879 -0
- package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
- package/doc/index.md +3 -5
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/docker/Mosquitto/README.md +1 -0
- package/lib/commonConfig.js +0 -5
- package/lib/fiware-iotagent-lib.js +1 -1
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/model/Device.js +0 -1
- package/lib/model/Group.js +0 -1
- package/lib/model/dbConn.js +1 -7
- package/lib/plugins/jexlParser.js +1 -1
- package/lib/request-shim.js +2 -2
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/common/genericMiddleware.js +1 -1
- package/lib/services/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMemory.js +2 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +32 -19
- package/lib/services/devices/deviceService.js +44 -43
- package/lib/services/devices/devices-NGSI-LD.js +14 -2
- package/lib/services/devices/devices-NGSI-mixed.js +0 -2
- package/lib/services/devices/devices-NGSI-v2.js +23 -104
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +3 -3
- package/lib/services/ngsi/entities-NGSI-v2.js +28 -19
- package/lib/services/northBound/deviceProvisioningServer.js +14 -8
- package/lib/templates/createDevice.json +0 -4
- package/lib/templates/createDeviceLax.json +0 -4
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +11 -0
- package/mkdocs.yml +6 -11
- package/package.json +3 -3
- package/scripts/legacy_expression_tool/README.md +280 -0
- package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
- package/scripts/legacy_expression_tool/requirements.txt +3 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +0 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -15
- package/test/unit/mongodb/mongodb-registry-test.js +1 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
- package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -10
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +2 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +144 -85
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +20 -53
- package/test/unit/ngsiv2/general/https-support-test.js +2 -6
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +8 -24
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +146 -65
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +11 -20
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +1 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +3 -5
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +13 -156
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +9 -13
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -10
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -8
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/doc/config-basic-example.js +0 -20
- package/doc/development.md +0 -285
- package/doc/howto.md +0 -645
- package/doc/installationguide.md +0 -370
- package/doc/operations.md +0 -127
- package/doc/usermanual.md +0 -900
- package/lib/plugins/bidirectionalData.js +0 -356
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -599
- /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
- /package/doc/{echo.js → devel/echo.js} +0 -0
- /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
package/doc/api.md
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
- [Measurement persistence options](#measurement-persistence-options)
|
|
20
20
|
- [Autoprovision configuration (autoprovision)](#autoprovision-configuration-autoprovision)
|
|
21
21
|
- [Explicitly defined attributes (explicitAttrs)](#explicitly-defined-attributes-explicitattrs)
|
|
22
|
-
- [
|
|
23
|
-
- [Differences between `autoprovision`, `explicitAttrs` and `appendMode`](#differences-between-autoprovision-explicitattrs-and-appendmode)
|
|
22
|
+
- [Differences between `autoprovision`, `explicitAttrs`](#differences-between-autoprovision-explicitattrs)
|
|
24
23
|
- [Expression language support](#expression-language-support)
|
|
25
24
|
- [Examples of JEXL expressions](#examples-of-jexl-expressions)
|
|
26
25
|
- [Available functions](#available-functions)
|
|
@@ -31,7 +30,6 @@
|
|
|
31
30
|
- [Multientity measurement transformation support (`object_id`)](#multientity-measurement-transformation-support-object_id)
|
|
32
31
|
- [Timestamp Compression](#timestamp-compression)
|
|
33
32
|
- [Timestamp Processing](#timestamp-processing)
|
|
34
|
-
- [Bidirectionality plugin (bidirectional)](#bidirectionality-plugin-bidirectional)
|
|
35
33
|
- [Overriding global Context Broker host](#overriding-global-context-broker-host)
|
|
36
34
|
- [Multitenancy, FIWARE Service and FIWARE ServicePath](#multitenancy-fiware-service-and-fiware-servicepath)
|
|
37
35
|
- [Secured access to the Context Broker](#secured-access-to-the-context-broker)
|
|
@@ -58,7 +56,7 @@
|
|
|
58
56
|
- [Miscellaneous API](#miscellaneous-api)
|
|
59
57
|
- [Log operations](#log-operations)
|
|
60
58
|
- [Modify Loglevel `PUT /admin/log`](#modify-loglevel-put-adminlog)
|
|
61
|
-
- [Retrieve log level `
|
|
59
|
+
- [Retrieve log level `GET /admin/log`](#retrieve-log-level-get-adminlog)
|
|
62
60
|
- [About operations](#about-operations)
|
|
63
61
|
- [List IoTA Information `GET /iot/about`](#list-iota-information-get-iotabout)
|
|
64
62
|
|
|
@@ -141,6 +139,16 @@ subservice mapping, security information and attribute configuration can be spec
|
|
|
141
139
|
relaying on the config group configuration. The specific parameters that can be configured for a given device are
|
|
142
140
|
described in the [Device datamodel](#device-datamodel) section.
|
|
143
141
|
|
|
142
|
+
If devices are not pre-registered, they will be automatically created when a measure arrives to the IoT Agent - this
|
|
143
|
+
process is known as autoprovisioning. The IoT Agent will create an empty device with the group `apiKey` and `type` - the
|
|
144
|
+
associated document created in database doesn't include config group parameters (in particular, `timestamp`,
|
|
145
|
+
`explicitAttrs`, `active` or `attributes`, `static` and `lazy` attributes and commands). The IoT Agent will also create
|
|
146
|
+
the entity in the Context Broker if it does not exist yet.
|
|
147
|
+
|
|
148
|
+
This behavior allows that autoprovisioned parameters can freely established modifying the device information after
|
|
149
|
+
creation using the provisioning API. However, note that if a device (autoprovisioned or not) doesn't have these
|
|
150
|
+
parameters defined at device level in database, the parameters are inherit from config group parameters.
|
|
151
|
+
|
|
144
152
|
## Entity attributes
|
|
145
153
|
|
|
146
154
|
In the config group/device model there are four list of attributes with different purpose to configure how the
|
|
@@ -175,22 +183,21 @@ All of them have the same syntax, a list of objects with the following attribute
|
|
|
175
183
|
- **type** (mandatory): name of the type of the attribute in the target entity.
|
|
176
184
|
- **metadata** (optional): additional static metadata for the attribute in the target entity. (e.g. `unitCode`)
|
|
177
185
|
|
|
178
|
-
Some
|
|
186
|
+
Some advanced features also allow the use of the following optional fields:
|
|
179
187
|
|
|
180
188
|
- **expression**: indicates that the value of the target attribute will not be the plain value or the measurement, but
|
|
181
189
|
an expression based on a combination of the reported values. See the
|
|
182
190
|
[Expression Language definition](#expression-language-support) for details
|
|
183
|
-
- **skipValue**: indicates that if the result of applying `expression` to a measure is equal to the value of
|
|
184
|
-
the attribute corresponding to the measure is not sent to CB.
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
- **skipValue**: indicates that if the result of applying `expression` to a measure is equal to the value of
|
|
192
|
+
`skipValue` then the attribute corresponding to the measure is not sent to CB. In other words, this field **is not
|
|
193
|
+
an expression**, it is a value that is compared with the result of applying `expression` to a measure. By default if
|
|
194
|
+
`skipValue` is not defined then is considered as `null` (i.e. if the result of apply `expression` results in `null`
|
|
195
|
+
then corresponding attribute is not sent to CB). It is only used if `expression` is provided (otherwise is ignored).
|
|
187
196
|
- **entity_name**: the presence of this attribute indicates that the value will not be stored in the original device
|
|
188
197
|
entity but in a new entity with an ID given by this attribute. The type of this additional entity can be configured
|
|
189
198
|
with the `entity_type` attribute. If no type is configured, the device entity type is used instead. Entity names can
|
|
190
199
|
be defined as expressions, using the [Expression Language definition](#expression-language-support).
|
|
191
200
|
- **entity_type**: configures the type of an alternative entity.
|
|
192
|
-
- **reverse**: add bidirectionality expressions to the attribute. See the **bidirectionality** transformation plugin
|
|
193
|
-
in the [Data Mapping Plugins section](development.md#bidirectionality-plugin-bidirectional) for details.
|
|
194
201
|
|
|
195
202
|
Additionally for commands (which are attributes of type `command`) the following fields are optional:
|
|
196
203
|
|
|
@@ -360,15 +367,13 @@ used should be taken from those defined by
|
|
|
360
367
|
|
|
361
368
|
## Measurement persistence options
|
|
362
369
|
|
|
363
|
-
There are
|
|
370
|
+
There are 2 different options to configure how the IoTAgent stores the measures received from the devices, depending on
|
|
364
371
|
the following parameters:
|
|
365
372
|
|
|
366
373
|
- `autoprovision`: If the device is not provisioned, the IoTAgent will create a new device and entity for it.
|
|
367
374
|
- `explicitAttrs`: If the measure element (object_id) is not defined in the mappings of the device or config group
|
|
368
375
|
provision, the measure is stored in the Context Broker by adding a new attribute to the entity with the same name of
|
|
369
376
|
the undefined measure element.
|
|
370
|
-
- `appendMode`: It configures the request to the Context Broker to update the entity every time a new measure arrives.
|
|
371
|
-
It have implications depending if the entity is already created or not in the Context Broker.
|
|
372
377
|
|
|
373
378
|
### Autoprovision configuration (autoprovision)
|
|
374
379
|
|
|
@@ -376,7 +381,8 @@ By default, when a measure arrives to the IoTAgent, if the `device_id` does not
|
|
|
376
381
|
IoTA creates a new device and a new entity according to the config group. Defining the field `autoprovision` to `false`
|
|
377
382
|
when provisioning the config group, the IoTA to reject the measure at the southbound, allowing only to persist the data
|
|
378
383
|
to devices that are already provisioned. It makes no sense to use this field in device provisioning since it is intended
|
|
379
|
-
to avoid provisioning devices (and for it to be effective, it would have to be provisional).
|
|
384
|
+
to avoid provisioning devices (and for it to be effective, it would have to be provisional). Further information can be
|
|
385
|
+
found in section [Devices](#devices)
|
|
380
386
|
|
|
381
387
|
### Explicitly defined attributes (explicitAttrs)
|
|
382
388
|
|
|
@@ -440,15 +446,7 @@ depending on the JEXL expression evaluation:
|
|
|
440
446
|
- If it evaluates to an array just measures defined in the array (identified by their attribute names, not by their
|
|
441
447
|
object_id) will be will be propagated to NGSI interface (as in case 3)
|
|
442
448
|
|
|
443
|
-
###
|
|
444
|
-
|
|
445
|
-
This is a flag that can be enabled by activating the parameter `appendMode` in the configuration file or by using the
|
|
446
|
-
`IOTA_APPEND_MODE` environment variable (more info
|
|
447
|
-
[here](https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/installationguide.md)). If this flag is
|
|
448
|
-
activated, the update requests to the Context Broker will be performed always with APPEND type, instead of the default
|
|
449
|
-
UPDATE. This have implications in the use of attributes with Context Providers, so this flag should be used with care.
|
|
450
|
-
|
|
451
|
-
### Differences between `autoprovision`, `explicitAttrs` and `appendMode`
|
|
449
|
+
### Differences between `autoprovision`, `explicitAttrs`
|
|
452
450
|
|
|
453
451
|
Since those configuration parameters are quite similar, this section is intended to clarify the relation between them.
|
|
454
452
|
|
|
@@ -460,16 +458,6 @@ related to the **southbound**.
|
|
|
460
458
|
What `explicitAttrs` does is to filter from the southbound the parameters that are not explicitly defined in the device
|
|
461
459
|
provision or config group. That also would avoid propagating the measures to the Context Broker.
|
|
462
460
|
|
|
463
|
-
The default way the agent updates the information into the Context Broker is by using an update request. If
|
|
464
|
-
`appendMode=true`, the IoTA will use an append request instead of an update one. This means it will store the attributes
|
|
465
|
-
even if they are not present in the entity. This seems the same functionality that the one provided by `autoprovision`,
|
|
466
|
-
but it is a different concept since the scope of this config is to setup how the IoT interacts with the context broker,
|
|
467
|
-
this is something related to the **northbound**.
|
|
468
|
-
|
|
469
|
-
Note that, even creating a config group with `autoprovision=true` and `explicitAttrs=true`, if you do not provision
|
|
470
|
-
previously the entity in the Context Broker (having all attributes to be updated), it would fail if `appendMode=false`.
|
|
471
|
-
For further information check the issue [#1301](https://github.com/telefonicaid/iotagent-node-lib/issues/1301).
|
|
472
|
-
|
|
473
461
|
## Expression language support
|
|
474
462
|
|
|
475
463
|
The IoTAgent Library provides an expression language for measurement transformation and other purposes. This expression
|
|
@@ -495,6 +483,9 @@ expression. In all cases the following data is available to all expressions:
|
|
|
495
483
|
- `subservice`: device subservice
|
|
496
484
|
- `staticAttributes`: static attributes defined in the device or config group
|
|
497
485
|
|
|
486
|
+
Additionally, for attribute expressions (`expression`, `entity_name`) and `entityNameExp` measures are avaiable in the
|
|
487
|
+
**context** used to evaluate them.
|
|
488
|
+
|
|
498
489
|
### Examples of JEXL expressions
|
|
499
490
|
|
|
500
491
|
The following table shows expressions and their expected outcomes taking into account the following measures at
|
|
@@ -683,6 +674,10 @@ will check which ones contain expressions whose variables are present in the rec
|
|
|
683
674
|
whose variables are covered, their expressions will be executed with the received values, and their values updated in
|
|
684
675
|
the Context Broker.
|
|
685
676
|
|
|
677
|
+
If as a result of apply expression `undefined` or `null` value is obtained then any of them will not progress to entity
|
|
678
|
+
attribute. Have into acount that some numeric operations results (like nonexistent \* 2) are a kind of null with a
|
|
679
|
+
number type but NaN value, which will also not progress to entity attribute.
|
|
680
|
+
|
|
686
681
|
E.g.: if a device with the following provisioning information is created in the IoT Agent:
|
|
687
682
|
|
|
688
683
|
```json
|
|
@@ -760,7 +755,7 @@ following to CB:
|
|
|
760
755
|
|
|
761
756
|
### Multientity measurement transformation support (`object_id`)
|
|
762
757
|
|
|
763
|
-
To allow support for measurement transformation in combination with multi entity
|
|
758
|
+
To allow support for measurement transformation in combination with multi entity feature, where the same attribute is
|
|
764
759
|
generated for different entities out of different incoming attribute values (i.e. `object_id`), we introduced support
|
|
765
760
|
for `object_id` in the expression context.
|
|
766
761
|
|
|
@@ -854,58 +849,10 @@ it in queries (and viceversa, receive the extended one in queries and return it
|
|
|
854
849
|
|
|
855
850
|
## Timestamp Processing
|
|
856
851
|
|
|
857
|
-
The IOTA processes the entity attributes looking for a `TimeInstant` attribute. If one is found, for NGSI v2,
|
|
852
|
+
The IOTA processes the entity attributes looking for a `TimeInstant` attribute. If one is found, for NGSI v2, then it
|
|
858
853
|
adds a `TimeInstant` attribute as metadata for every other attribute in the same request. With NGSI-LD, the Standard
|
|
859
854
|
`observedAt` property-of-a-property is used instead.
|
|
860
855
|
|
|
861
|
-
## Bidirectionality plugin (bidirectional)
|
|
862
|
-
|
|
863
|
-
This plugin allows the devices with composite values an expression to update the original values in the devices when the
|
|
864
|
-
composite expressions are updated in the Context Broker. This behavior is achieved through the use of subscriptions.
|
|
865
|
-
|
|
866
|
-
IoTAs using this plugins should also define a notification handler to handle incoming values. This handler will be
|
|
867
|
-
intercepted by the plugin, so the mapped values are included in the updated notification.
|
|
868
|
-
|
|
869
|
-
When a device is provisioned with bidirectional attributes, the IoTAgent subscribes to changes in that attribute. When a
|
|
870
|
-
change notification for that attribute arrives to the IoTA, it applies the transformation defined in the device
|
|
871
|
-
provisioning payload to the notification, and calls the underlying notification handler with the transformed entity
|
|
872
|
-
including the `value` along with any `metadata`, and in the case of an NGSI-LD bidirectional attribute a `datasetId` if
|
|
873
|
-
provided.
|
|
874
|
-
|
|
875
|
-
The following `attributes` section shows an example of the plugin configuration (using `IOTA_AUTOCAST=false` to avoid
|
|
876
|
-
translation from geo:point to geo:json)
|
|
877
|
-
|
|
878
|
-
```json
|
|
879
|
-
"attributes": [
|
|
880
|
-
{
|
|
881
|
-
"name":"location",
|
|
882
|
-
"type":"geo:point",
|
|
883
|
-
"expression": "latitude, longitude",
|
|
884
|
-
"reverse": [
|
|
885
|
-
{
|
|
886
|
-
"object_id":"longitude",
|
|
887
|
-
"type": "Number",
|
|
888
|
-
"expression": "location | split(', ')[0] | parsefloat()"
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
"object_id":"latitude",
|
|
892
|
-
"type": "Number",
|
|
893
|
-
"expression": "location | split(', ')[1] | parsefloat()"
|
|
894
|
-
}
|
|
895
|
-
]
|
|
896
|
-
}
|
|
897
|
-
],
|
|
898
|
-
```
|
|
899
|
-
|
|
900
|
-
For each attribute that would have bidirectionality, a new field `reverse` must be configured. This field will contain
|
|
901
|
-
an array of fields that will be created based on the notifications content. The expression notification can contain any
|
|
902
|
-
attribute of the same entity as the bidirectional attribute; declaring them in the expressions will add them to the
|
|
903
|
-
subscription payload.
|
|
904
|
-
|
|
905
|
-
For each attribute in the `reverse` array, an expression must be defined to calculate its value based on the
|
|
906
|
-
notification attributes. This value will be passed to the underlying protocol with the `object_id` name. Details about
|
|
907
|
-
how the value is then progressed to the device are protocol-specific.
|
|
908
|
-
|
|
909
856
|
## Overriding global Context Broker host
|
|
910
857
|
|
|
911
858
|
**cbHost**: Context Broker host URL. This option can be used to override the global CB configuration for specific types
|
|
@@ -1666,7 +1613,7 @@ _**Response code**_
|
|
|
1666
1613
|
- `200` `OK` if successful.
|
|
1667
1614
|
- `500` `SERVER ERROR` if there was any error not contemplated above.
|
|
1668
1615
|
|
|
1669
|
-
#### Retrieve log level `
|
|
1616
|
+
#### Retrieve log level `GET /admin/log`
|
|
1670
1617
|
|
|
1671
1618
|
_**Response code**_
|
|
1672
1619
|
|
package/doc/deprecated.md
CHANGED
|
@@ -21,7 +21,10 @@ A list of deprecated features and the version in which they were deprecated foll
|
|
|
21
21
|
- Support to NGSI-LD v1.3 in iotagent-node-lib 2.25.0 (finally removed in 2.26.0)
|
|
22
22
|
- Support groups (provision) statically defined by configuration
|
|
23
23
|
- Support to in-memory registry (i.e.`deviceRegistry.type=memory`)
|
|
24
|
+
- eventType configuration (finally removed in 3.0.0)
|
|
24
25
|
- Support to legacy expressions (finally removed in 3.2.0)
|
|
26
|
+
- Bidirectinal pluging (finally removed in 3.4.0)
|
|
27
|
+
- appendMode configuration (`IOTA_APPEND_MODE` env var) (finally removed in 3.4.0)
|
|
25
28
|
|
|
26
29
|
The use of Node.js v14 is highly recommended.
|
|
27
30
|
|
|
@@ -41,13 +44,16 @@ information in the case you want to use old versions:
|
|
|
41
44
|
|
|
42
45
|
The following table provides information about the last iotagent-node-lib version supporting currently removed features:
|
|
43
46
|
|
|
44
|
-
| **Removed feature**
|
|
45
|
-
|
|
|
46
|
-
| NGSI v1 API
|
|
47
|
-
| Support to Node.js v4
|
|
48
|
-
| Support to Node.js v6
|
|
49
|
-
| Support to Node.js v8
|
|
50
|
-
| Support to Node.js v10
|
|
51
|
-
| Support to Node.js v12
|
|
52
|
-
| Support to NGSI-LD 1.3
|
|
53
|
-
|
|
|
47
|
+
| **Removed feature** | **Last iotagent-node-lib version supporting feature** | **That version release date** |
|
|
48
|
+
| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------- |
|
|
49
|
+
| NGSI v1 API | 2.17.0 | August 30th, 2021 |
|
|
50
|
+
| Support to Node.js v4 | 2.8.1 | December 19th, 2018 |
|
|
51
|
+
| Support to Node.js v6 | 2.9.0 | May 22nd, 2019 |
|
|
52
|
+
| Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
|
|
53
|
+
| Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
|
|
54
|
+
| Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
|
|
55
|
+
| Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |
|
|
56
|
+
| eventType configuration | 2.26.0 | March 15th, 2023 |
|
|
57
|
+
| Support to Legacy Expressions | 3.1.0 | April 25th, 2023 |
|
|
58
|
+
| bidirectional plugin | 3.3.0 | August 24th, 2023 |
|
|
59
|
+
| appendMode configuration (`IOTA_APPEND_MODE` env var) | 3.3.0 | August 24th, 2023 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Architecture
|
|
2
2
|
|
|
3
|
-
The following section defines the
|
|
3
|
+
The following section defines the architecture and message flow which is common to all IoT Agents which use the library.
|
|
4
4
|
|
|
5
5
|
### Device to NGSI Mapping
|
|
6
6
|
|
|
@@ -32,7 +32,7 @@ basis preprovisioning the devices). Device measures can have three different beh
|
|
|
32
32
|
The following sequence diagram shows the different NGSI interactions an IoT Agent makes with the Context Broker,
|
|
33
33
|
explained in the following subsections (using the example of a OMA Lightweight M2M device).
|
|
34
34
|
|
|
35
|
-

|
|
36
36
|
|
|
37
37
|
Be aware that the IoT Agents are only required to support NGSI10 operations `updateContext` and `queryContext` in their
|
|
38
38
|
standard formats (currently in JSON format; XML deprecated) but will not answer to NGSI9 operations (or NGSI convenience
|
|
@@ -254,7 +254,7 @@ the concrete IoT Agent implementations will be to map between the native device
|
|
|
254
254
|
The following figure offers a graphical example of how a COAP IoT Agent work, ordered from the registration of the
|
|
255
255
|
device to a command update to the device.
|
|
256
256
|
|
|
257
|
-

|
|
258
258
|
|
|
259
259
|
### The `TimeInstant` element
|
|
260
260
|
|
|
@@ -4,21 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
Before we get started, here are a few things we expect from you (and that you should expect from others):
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
- Be kind and thoughtful in your conversations around this project. We all come from different backgrounds and
|
|
8
|
+
projects, which means we likely have different perspectives on "how open source is done." Try to listen to others
|
|
9
|
+
rather than convince them that your way is correct.
|
|
10
|
+
- Please ensure that your contribution passes all tests. If there are test failures, you will need to address them
|
|
11
|
+
before we can merge your contribution.
|
|
12
|
+
- When adding content, please consider if it is widely valuable. Please don't add references or links to things you or
|
|
13
|
+
your employer have created as others will do so if they appreciate it.
|
|
14
|
+
- When reporting a vulnerability on the software, please, put in contact with IoT Agent Node Lib repository
|
|
15
|
+
maintainers in order to discuss it in a private way.
|
|
16
16
|
|
|
17
17
|
## How to contribute
|
|
18
18
|
|
|
19
|
-
If you'd like to contribute, start by searching through the
|
|
20
|
-
[
|
|
21
|
-
|
|
19
|
+
If you'd like to contribute, start by searching through the
|
|
20
|
+
[issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
|
|
21
|
+
[pull requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) to see whether someone else has raised a
|
|
22
|
+
similar idea or question.
|
|
22
23
|
|
|
23
24
|
If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following:
|
|
24
25
|
|
|
@@ -28,36 +29,43 @@ If you don't see your idea listed, and you think it fits into the goals of this
|
|
|
28
29
|
|
|
29
30
|
### Pull Request protocol
|
|
30
31
|
|
|
31
|
-
As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest)) contributions
|
|
33
|
+
are done using a pull request (PR). The detailed "protocol" used in such PR is described below:
|
|
34
|
+
|
|
35
|
+
- Direct commits to master branch (even single-line modifications) are not allowed. Every modification has to come as
|
|
36
|
+
a PR
|
|
37
|
+
- In case the PR is implementing/fixing a numbered issue, the issue number has to be referenced in the body of the PR
|
|
38
|
+
at creation time
|
|
39
|
+
- Anybody is welcome to provide comments to the PR (either direct comments or using the review feature offered by
|
|
40
|
+
GitHub)
|
|
41
|
+
- Use _code line comments_ instead of _general comments_, for traceability reasons (see comments lifecycle below)
|
|
42
|
+
- Comments lifecycle
|
|
43
|
+
- Comment is created, initiating a _comment thread_
|
|
44
|
+
- New comments can be added as responses to the original one, starting a discussion
|
|
45
|
+
- After discussion, the comment thread ends in one of the following ways:
|
|
46
|
+
- `Fixed in <commit hash>` in case the discussion involves a fix in the PR branch (which commit hash is
|
|
47
|
+
included as reference)
|
|
48
|
+
- `NTC`, if finally nothing needs to be done (NTC = Nothing To Change)
|
|
49
|
+
- PR can be merged when the following conditions are met:
|
|
50
|
+
- All comment threads are closed
|
|
51
|
+
- All the participants in the discussion have provided a `LGTM` general comment (LGTM = Looks good to me)
|
|
52
|
+
- Self-merging is not allowed (except in rare and justified circumstances)
|
|
49
53
|
|
|
50
54
|
Some additional remarks to take into account when contributing with new PRs:
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
- PR must include not only code contributions, but their corresponding pieces of documentation (new or modifications
|
|
57
|
+
to existing one) and tests
|
|
58
|
+
- PR modifications must pass full regression based on existing test (unit, functional, memory, e2e) in addition to
|
|
59
|
+
whichever new test added due to the new functionality
|
|
60
|
+
- PR should be of an appropriated size that makes review achievable. Too large PRs could be closed with a "please,
|
|
61
|
+
redo the work in smaller pieces" without any further discussing
|
|
55
62
|
|
|
56
63
|
## Community
|
|
57
64
|
|
|
58
65
|
Discussions about the Open Source Guides take place on this repository's
|
|
59
|
-
[Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
|
|
60
|
-
sections. Anybody is welcome to join these
|
|
66
|
+
[Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
|
|
67
|
+
[Pull Requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) sections. Anybody is welcome to join these
|
|
68
|
+
conversations.
|
|
61
69
|
|
|
62
70
|
Wherever possible, do not take these conversations to private channels, including contacting the maintainers directly.
|
|
63
71
|
|