iotagent-node-lib 4.5.0 → 4.7.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.
Files changed (124) hide show
  1. package/.github/workflows/ci.yml +0 -1
  2. package/Changelog +12 -0
  3. package/README.md +67 -272
  4. package/config.js +3 -1
  5. package/doc/README.md +1 -1
  6. package/doc/admin.md +40 -18
  7. package/doc/api.md +532 -136
  8. package/doc/deprecated.md +4 -0
  9. package/doc/devel/architecture.md +5 -135
  10. package/doc/devel/development.md +224 -12
  11. package/doc/getting-started.md +114 -53
  12. package/doc/requirements.txt +1 -1
  13. package/doc/roadmap.md +5 -5
  14. package/docker/Mosquitto/Dockerfile +2 -2
  15. package/docker/Mosquitto/README.md +14 -11
  16. package/lib/commonConfig.js +21 -2
  17. package/lib/constants.js +3 -0
  18. package/lib/fiware-iotagent-lib.js +12 -15
  19. package/lib/jexlTranformsMap.js +3 -1
  20. package/lib/model/Command.js +2 -2
  21. package/lib/model/Device.js +7 -3
  22. package/lib/model/Group.js +5 -3
  23. package/lib/model/dbConn.js +53 -115
  24. package/lib/services/commands/commandRegistryMongoDB.js +115 -75
  25. package/lib/services/common/alarmManagement.js +3 -0
  26. package/lib/services/common/iotManagerService.js +3 -1
  27. package/lib/services/devices/deviceRegistryMemory.js +36 -0
  28. package/lib/services/devices/deviceRegistryMongoDB.js +160 -87
  29. package/lib/services/devices/deviceService.js +33 -3
  30. package/lib/services/devices/devices-NGSI-v2.js +6 -1
  31. package/lib/services/groups/groupRegistryMongoDB.js +120 -83
  32. package/lib/services/groups/groupService.js +1 -1
  33. package/lib/services/ngsi/entities-NGSI-LD.js +320 -570
  34. package/lib/services/ngsi/entities-NGSI-v2.js +51 -3
  35. package/lib/services/ngsi/ngsiService.js +34 -1
  36. package/lib/services/northBound/deviceGroupAdministrationServer.js +42 -6
  37. package/lib/services/northBound/deviceProvisioningServer.js +12 -4
  38. package/lib/services/northBound/northboundServer.js +2 -0
  39. package/lib/services/stats/statsRegistry.js +128 -101
  40. package/lib/templates/createDevice.json +0 -24
  41. package/lib/templates/createDeviceLax.json +0 -23
  42. package/lib/templates/deviceGroup.json +1 -25
  43. package/lib/templates/updateDevice.json +12 -24
  44. package/lib/templates/updateDeviceLax.json +12 -23
  45. package/package.json +5 -5
  46. package/scripts/legacy_expression_tool/README.md +0 -1
  47. package/test/functional/README.md +22 -17
  48. package/test/functional/config-test.js +3 -2
  49. package/test/functional/functional-tests-runner.js +9 -4
  50. package/test/functional/functional-tests.js +4 -4
  51. package/test/functional/testCases.js +245 -4
  52. package/test/functional/testUtils.js +2 -2
  53. package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -13
  54. package/test/unit/examples/groupProvisioningRequests/multipleConfigGroupsCreation.json +44 -0
  55. package/test/unit/examples/groupProvisioningRequests/provisionDuplicateConfigGroup.json +35 -0
  56. package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroup.json +36 -0
  57. package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroupAlternate.json +36 -0
  58. package/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json +1 -0
  59. package/test/unit/general/config-multi-core-test.js +1 -2
  60. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -4
  61. package/test/unit/general/deviceService-test.js +106 -3
  62. package/test/unit/general/statistics-service_test.js +1 -74
  63. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +6 -5
  64. package/test/unit/mongodb/mongodb-configGroup-registry-test.js +452 -0
  65. package/test/unit/mongodb/mongodb-connectionoptions-test.js +9 -42
  66. package/test/unit/mongodb/mongodb-group-registry-test.js +34 -33
  67. package/test/unit/mongodb/mongodb-service-registry-test.js +477 -0
  68. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +4 -4
  69. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +22 -22
  70. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +4 -4
  71. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +14 -15
  72. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +23 -23
  73. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +0 -5
  74. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +11 -16
  75. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +23 -28
  76. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +8 -13
  77. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
  78. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +24 -29
  79. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +12 -17
  80. package/test/unit/ngsi-ld/examples/contextRequests/updateContextStaticLinkedAttributes.json +12 -10
  81. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -104
  82. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +1 -2
  83. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +4 -5
  84. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +0 -4
  85. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +8 -5
  86. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +42 -41
  87. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +11 -10
  88. package/test/unit/ngsiv2/general/deviceService-test.js +98 -4
  89. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  90. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +195 -0
  91. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +4 -3
  92. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +6 -5
  93. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +17 -16
  94. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +10 -18
  95. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +21 -20
  96. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +8 -7
  97. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +12 -11
  98. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +3 -2
  99. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +28 -27
  100. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +265 -4
  101. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +12 -11
  102. package/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +1190 -0
  103. package/test/unit/ngsiv2/provisioning/device-registration_test.js +5 -4
  104. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +6 -9
  105. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -1
  106. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +5 -4
  107. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +8 -7
  108. package/test/unit/statsRegistry/openmetrics-test.js +167 -0
  109. package/lib/templates/queryContext.json +0 -25
  110. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +0 -35
  111. package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json +0 -17
  112. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +0 -31
  113. package/test/unit/general/statistics-persistence_test.js +0 -121
  114. package/test/unit/ngsi-ld/examples/contextRequests/createBidirectionalDevice.json +0 -17
  115. package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +0 -12
  116. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
  117. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithDatasetId.json +0 -21
  118. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -17
  119. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -23
  120. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +0 -132
  121. package/test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json +0 -8
  122. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
  123. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -19
  124. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -24
@@ -1,64 +1,92 @@
1
- ## Getting Started
1
+ # Getting Started
2
2
 
3
- Every IoT Agent which uses the library is different, but the concepts for provisioning IoT devices remain the same
4
- regardless of protocol.
3
+ - [Introduction](#introduction)
4
+ - [IoT Agent settings - `config.js`](#iot-agent-settings---configjs)
5
+ - [Provisioning a Config Group](#provisioning-a-config-group)
6
+ - [Provisioning an Individual Device](#provisioning-an-individual-device)
7
+ - [Receiving measures from devices](#receiving-measures-from-devices)
8
+ - [Receiving a measure from a known Device](#receiving-a-measure-from-a-known-device)
9
+ - [Receiving a measure from an anonymous Device](#receiving-a-measure-from-an-anonymous-device)
5
10
 
6
- ### `config.js` - IoT Agent settings
11
+ ## Introduction
12
+
13
+ In this guide we will be using the IoT Agent JSON (which is the reference IoTAgent using the IoTAgent Library) as an
14
+ example to demonstrate how to provision config groups, devices and how to receive measures from devices.
15
+
16
+ Be aware that every IoT Agent which uses the library is different, but the concepts for provisioning IoT devices remain
17
+ the same regardless of protocol.
18
+
19
+ The IoT Agent JSON is a simple IoT Agent which uses JSON payloads to send and receive data. It is a good starting point
20
+ for understanding how an IoT Agent works since it uses JSON payloads to send and receive data.
21
+
22
+ ## IoT Agent settings - `config.js`
7
23
 
8
24
  The `config.js` holds common information about the interactions between the Agent and the Context Broker. Additional
9
- custom settings may also be required dependent upon the actual IoT Agent used.
25
+ custom settings may also be required dependent upon the actual IoT Agent used. The following is an example of a typical
26
+ `config.js` file:
10
27
 
11
28
  ```javascript
12
29
  config = {
13
- logLevel: "DEBUG",
30
+ logLevel: 'DEBUG',
14
31
  contextBroker: {
15
- host: "orion",
16
- port: "1026",
32
+ host: 'orion',
33
+ port: '1026'
17
34
  },
18
35
  server: {
19
36
  port: 4041,
20
- host: "0.0.0.0",
37
+ host: '0.0.0.0'
21
38
  },
22
39
  deviceRegistry: {
23
- type: "memory",
40
+ type: 'mongodb'
41
+ },
42
+ mongodb: {
43
+ host: 'localhost',
44
+ port: '27017',
45
+ db: 'iotagent'
24
46
  },
25
- service: "openiot",
26
- subservice: "/",
27
- providerUrl: "http://iot-agent:4041",
28
- defaultType: "Thing",
47
+ service: 'openiot',
48
+ subservice: '/',
49
+ providerUrl: 'http://iot-agent:4041',
50
+ defaultType: 'Thing'
29
51
  };
30
52
  ```
31
53
 
32
- In this case the context broker is called `orion` and is listening on port `1026`, the IoT Agent can be provisioned by
33
- sending requests to port `4041` which is also the port used to receive NGSI requests. The IoT Agent is holding the
34
- device mappings in memory.
54
+ In this case the context broker hostname is `orion` and is listening on port `1026`, the IoT Agent can be provisioned by
55
+ sending requests to port `4041` which is also the port used to receive NGSI requests. The IoT Agent is using the
56
+ `iotagent` database from a MongoDB instance at `localhost:27017` to store needed information (provisioned groups and
57
+ devices, etc.).
35
58
 
36
59
  The remaining settings help to define the NGSI interactions - the IoT Agent will be using the `fiware-service=openiot`
37
60
  and `fiware-service-path=/`. The default `type`for each created entity is `Thing`, although this can be overridden as
38
61
  shown below. Devices will be registered for a period of one month and the IoT Agent will receive registration callbacks
39
62
  at the URL `http://iot-agent:4041`.
40
63
 
41
- All configuration settings can also updated using Docker environment variables.
64
+ All configuration settings can also updated using Docker environment variables. You can find more information about the
65
+ available configuration parameters and environment variables in the [Administration Guide](admin.md).
42
66
 
43
- ### Provisioning a Service Group
67
+ ## Provisioning a Config Group
44
68
 
45
- Settings which are common to a group of devices can be passed to the IoT Agent using the Service API. The
46
- `fiware-service` and `fiware-service-path` to be used to access the API are defined within the `config.js`. Each service
47
- may override values previously defined in the configuration if necessary.
69
+ Settings which are common to a group of devices can be passed to the IoT Agent using the Config Group API. Each config
70
+ group may override values previously defined in the global configuration if necessary. When using the config group API,
71
+ the `fiware-service` and `fiware-servicepath` headers will define the service and subservice to which the configuration
72
+ will be applied. Additionally, the `apikey` field is used to identify the configuration group. An example of a basic
73
+ config group is shown below:
48
74
 
49
75
  ```bash
50
76
  curl -iX POST \
51
- 'http://localhost:4041/iot/services' \
77
+ 'http://localhost:4041/iot/groups' \
52
78
  -H 'Content-Type: application/json' \
53
79
  -H 'fiware-service: openiot' \
54
80
  -H 'fiware-servicepath: /' \
55
81
  -d '{
56
- "services": [
82
+ "groups": [
57
83
  {
58
84
  "apikey": "4jggokgpepnvsb2uv4s40d59ov",
59
- "cbHost": "http://orion:1026",
60
85
  "entity_type": "Device",
61
- "resource": "/iot/d",
86
+ "resource": "/iot/json",
87
+ "attributes": [
88
+ { "object_id": "t", "name": "temperature", "type": "Number" }
89
+ ]
62
90
  }
63
91
  ]
64
92
  }'
@@ -66,12 +94,18 @@ curl -iX POST \
66
94
 
67
95
  In this case an `apiKey` for identifying devices has been created and all interactions to the path `/iot/d` which
68
96
  present this `apiKey` will be created as entities of `type=Device` rather than using the configuration default of
69
- `type=Thing`. The service group would usual hold additional attribute mappings, commands and common static attributes as
70
- well.
97
+ `type=Thing`.
98
+
99
+ Additionally, the group has defined an attribute mapping for a measurement `t` to be mapped to `temperature` attribute
100
+ when receiving data from devices.
101
+
102
+ The config group would usual hold additional attribute mappings, commands and common static attributes as well.
71
103
 
72
- ### Provisioning an Individual Device
104
+ ## Provisioning an Individual Device
73
105
 
74
- Settings which are specific to an individual device can be passed to the IoT Agent using the Device API
106
+ Settings which are specific to an individual device can be passed to the IoT Agent using the Device API. The
107
+ configuration provided in the Device API will override any settings defined in the Config Group API and the global
108
+ configuration as well. An example of a basic device configuration is shown below:
75
109
 
76
110
  ```bash
77
111
  curl -iX POST \
@@ -86,7 +120,7 @@ curl -iX POST \
86
120
  "entity_name": "urn:ngsi-ld:Motion:001",
87
121
  "entity_type": "Motion",
88
122
  "attributes": [
89
- { "object_id": "c", "name": "count", "type": "Integer" }
123
+ { "object_id": "c", "name": "count", "type": "Number" }
90
124
  ],
91
125
  "static_attributes": [
92
126
  { "name":"refStore", "type": "Relationship", "value": "urn:ngsi-ld:Store:001"}
@@ -97,54 +131,81 @@ curl -iX POST \
97
131
  '
98
132
  ```
99
133
 
100
- This information is combined with the common service group information whenever a request is received at the South port
101
- of the IoT Agent and used to create or update the relevant entity in the Context Broker.
134
+ The device `motion001` has been provisioned to persist data to the Context Broker as an entity of `type=Motion` (instead
135
+ of the default `type=Thing`). The destination entity is identified by the `entity_name` field, which is set to
136
+ `urn:ngsi-ld:Motion:001`. The device has a single attribute mapping for a measurement `c` to be mapped to `count`
137
+ attribute, additionally to one defined in the group mapping (`temperature`). The device also has a static attribute
138
+ `refStore` which is a relationship to the entity `urn:ngsi-ld:Store:001`.
102
139
 
103
- #### Receiving a measure from a known Device
140
+ This information is combined with the common config group information whenever a measurement is received at the IoT
141
+ Agent and used to create or update the relevant entity in the Context Broker.
104
142
 
105
- For example, imagine we are using the Ultralight IoT Agent and the following request is sent to the South port:
143
+ ## Receiving measures from devices
144
+
145
+ In order to see the complete process from provisioning the groups and devices to receiving measures, we will show how a
146
+ device can send a measure to the IoT Agent. In this case, we will use the IoTA JSON as an example, using the HTTP
147
+ transport protocol. To reproduce the measure sending, you can use the following `curl` commands.
148
+
149
+ The device measures are sent to the South port of the IoT Agent which is listening in the port `7896`.
150
+
151
+ ### Receiving a measure from a known Device
152
+
153
+ In this case, the device has been provisioned previously. We will use the `motion001` device defined in the previous
154
+ example. To simulate the device sending a measure, the following request is sent to the South port:
106
155
 
107
156
  ```bash
108
157
  curl -iX POST \
109
- 'http://localhost:7896/iot/d?k=4jggokgpepnvsb2uv4s40d59ov&i=motion001' \
110
- -H 'Content-Type: text/plain' \
111
- -d 'c|1'
158
+ 'http://localhost:7896/iot/json?k=4jggokgpepnvsb2uv4s40d59ov&i=motion001' \
159
+ -H 'Content-Type: application/json' \
160
+ -d '{"t":23,"c":1}'
112
161
  ```
113
162
 
114
- The IoT Agent South port is listening to the path defined in the service group, and the API key is recognized to match.
163
+ The IoT Agent South port is listening to the path defined in the config group, and the API key is recognized to match.
115
164
  Because the `device_id` is also recognized, the provisioned device configuration is used and its settings are combined
116
- with the service group. A mapping has been found to rename the `c` measurement to `count` - the following context entity
117
- is created in the context broker:
165
+ with the config group.
166
+
167
+ Mapping has been found to use the `c` measurement as `count` and the `t` measurement as `temperature` attributes values.
168
+ The following context entity is created in the context broker:
118
169
 
119
170
  ```json
120
171
  {
121
172
  "id": "urn:ngsi-ld:Motion:001",
122
173
  "type": "Motion",
123
- "count": { "value": "1", "type": "Integer" },
174
+ "temperature": { "value": 23, "type": "Number" },
175
+ "count": { "value": 1, "type": "Number" },
124
176
  "refStore": { "value": "urn:ngsi-ld:Store:001", "type": "Relationship" }
125
177
  }
126
178
  ```
127
179
 
128
- #### Receiving a measure from an anonymous Device
180
+ ### Receiving a measure from an anonymous Device
181
+
182
+ When receiving a measure, it is not necessary to have the device provisioned. In this case, the IoT Agent will use the
183
+ config group configuration to create the device and the entity. This process is called "autoprovision" and it is enabled
184
+ by default in provisioned groups (for further information, review the
185
+ [Autoprovision](api.md#autoprovision-configuration-autoprovision) section in the API documentation).
129
186
 
130
- For example, imagine we are using the Ultralight IoT Agent and a request from an anonymous, unprovisioned device is sent
131
- to the South port:
187
+ Take as an example the following request from an anonymous device:
132
188
 
133
189
  ```bash
134
190
  curl -iX POST \
135
- 'http://localhost:7896/iot/d?k=4jggokgpepnvsb2uv4s40d59ov&i=temp001' \
136
- -H 'Content-Type: text/plain' \
137
- -d 't|1'
191
+ 'http://localhost:7896/iot/json?k=4jggokgpepnvsb2uv4s40d59ov&i=dev001' \
192
+ -H 'Content-Type: application/json' \
193
+ -d '{"t":13,"c":4}'
138
194
  ```
139
195
 
140
- The IoT Agent South port is listen to the path defined in the service group, and the API key is recognized to match, so
141
- the Service group configuration will be used. No mappings will be made for the Entity `id` or the attribute names and
142
- the following entity will be created:
196
+ The IoT Agent South port is listen to the path defined in the config group, and the API key is recognized to match, so
197
+ the config group configuration will be used. No device has been provisioned with the `device_id=dev001`, so the IoT
198
+ Agent will only use the config group configuration.
199
+
200
+ A new entity will be created in the Context Broker with the `id` `Device:dev001` and the `type` `Device`. Only the `t`
201
+ measurement will be mapped to the `temperature` attribute, as defined in the config group. The remaining measurements
202
+ will be created as attributes with the same name. The following context entity will be created in the context broker:
143
203
 
144
204
  ```json
145
205
  {
146
- "id": "temp001",
206
+ "id": "Device:dev001",
147
207
  "type": "Device",
148
- "t": { "value": "1", "type": "Number" }
208
+ "temperature": { "value": 13, "type": "Number" },
209
+ "c": { "value": 4, "type": "Number" }
149
210
  }
150
211
  ```
@@ -1,4 +1,4 @@
1
1
  mkdocs==1.2.4
2
2
  Pygments==2.15.0
3
3
  Markdown==3.3.4
4
- jinja2==3.1.4
4
+ jinja2==3.1.5
package/doc/roadmap.md CHANGED
@@ -25,10 +25,7 @@ Disclaimer:
25
25
  The following list of features are planned to be addressed in the short term, and incorporated in a release of the
26
26
  product:
27
27
 
28
- - cgroup literal in configuration groups management API (community)
29
- - Refactor Append Mode & initial entity ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413))
30
- - Native support for NGSI-v2 and LD ingestion ([#1451](https://github.com/telefonicaid/iotagent-node-lib/issues/1451))
31
- - Remove plugins structure (bidirectional plugin) ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413))
28
+ - cgroup literal in configuration groups management API ([#752](https://github.com/telefonicaid/iotagent-node-lib/issues/752))
32
29
  - Add init and improve log traces ([#1452](https://github.com/telefonicaid/iotagent-node-lib/issues/1452))
33
30
  - Remove InMemory registry for Devices and Groups ([#1429](https://github.com/telefonicaid/iotagent-node-lib/issues/1429))
34
31
 
@@ -37,7 +34,6 @@ product:
37
34
  The following list of features are planned to be addressed in the medium term, typically within the subsequent
38
35
  release(s) generated in the next 9 months after the next planned release:
39
36
 
40
- - Allow to add metadata to attributes from measures ([#1453](https://github.com/telefonicaid/iotagent-node-lib/issues/1453))
41
37
  - Cache support ([#1467](https://github.com/telefonicaid/iotagent-node-lib/issues/1467))
42
38
  - MQTT per group advanced configuration (MQTT broker, topics) ([#1454](https://github.com/telefonicaid/iotagent-node-lib/issues/1454))
43
39
  - Subscription based commands ([#1455](https://github.com/telefonicaid/iotagent-node-lib/issues/1455))
@@ -59,6 +55,10 @@ us if you wish to get involved in the implementation or influence the roadmap:
59
55
 
60
56
  The following list contains all features that were in the roadmap and have already been implemented.
61
57
 
58
+ - Allow to add metadata to attributes from measures ([#1453](https://github.com/telefonicaid/iotagent-node-lib/issues/1453)) ([4.6.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/4.0.0))
59
+ - Refactor Append Mode & initial entity ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413)) ([4.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/4.0.0))
60
+ - Native support for NGSI-v2 and LD ingestion ([#1451](https://github.com/telefonicaid/iotagent-node-lib/issues/1451)) ([4.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/4.0.0))
61
+ - Remove plugins structure (bidirectional plugin) ([#1413](https://github.com/telefonicaid/iotagent-node-lib/issues/1413)) ([4.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/4.0.0))
62
62
  - Refactor entities-NGSI-v2.js module ([#1166](https://github.com/telefonicaid/iotagent-node-lib/issues/1166)) ([3.0.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/3.0.0))
63
63
  - Accept JEXL Expressions for entity name in autoprovisioned devices (entityNameExp) ([#1145](https://github.com/telefonicaid/iotagent-node-lib/issues/1145)) ([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
64
64
  - Improve command functionalities (binary data + expression + mapping) ([2.22.0](https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.22.0))
@@ -1,4 +1,4 @@
1
- ARG IMAGE_TAG=12.5-slim
1
+ ARG IMAGE_TAG=12.6-slim
2
2
  FROM debian:${IMAGE_TAG}
3
3
 
4
4
  ARG CLEAN_DEV_TOOLS
@@ -16,7 +16,7 @@ RUN \
16
16
  # Install dependencies
17
17
  apt-get -y install \
18
18
  wget \
19
- mosquitto && \
19
+ mosquitto mosquitto-clients && \
20
20
  cp /etc/mosquitto/mosquitto.conf /etc/mosquitto/mosquitto.conf.orig && \
21
21
  chmod 755 /bin/startMosquitto.sh && \
22
22
  mkdir -p /var/log/mosquitto && \
@@ -1,13 +1,16 @@
1
- Thi directory containts the Dockerfile (and associated files) for a container of [mosquitto MQTT broker](https://mosquitto.org).
2
- This container is provide as a help for users to test with MQTT, but it is just an auxiliary material in this repository.
1
+ Thi directory containts the Dockerfile (and associated files) for a container of
2
+ [mosquitto MQTT broker](https://mosquitto.org). This container is provide as a help for users to test with MQTT, but it
3
+ is just an auxiliary material in this repository.
3
4
 
4
5
  The following releases matches with eclipse-mosquitto version:
5
- - 2.1.0 uses mosquitto-2.0.11 from Debian 12
6
- - 2.0.0 uses mosquitto-2.0.11 from Debian 11
7
- - 1.6.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
8
- - 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
9
- - 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
10
- - 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64 (from Centos7)
11
- - 1.2.0 uses mosquitto-1.6.7-1.el7.x86_64 (from Centos7)
12
- - 1.1.0 uses mosquitto-1.5.8-1.el7.x86_64 (from Centos7)
13
- - 1.0.0 uses mosquitto-1.4.8-1.el7.x86_64 (from Centos7)
6
+
7
+ - 2.2.0 uses mosquitto-2.0.11 from Debian 12
8
+ - 2.1.0 uses mosquitto-2.0.11 from Debian 12
9
+ - 2.0.0 uses mosquitto-2.0.11 from Debian 11
10
+ - 1.6.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
11
+ - 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
12
+ - 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64 (from Centos7)
13
+ - 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64 (from Centos7)
14
+ - 1.2.0 uses mosquitto-1.6.7-1.el7.x86_64 (from Centos7)
15
+ - 1.1.0 uses mosquitto-1.5.8-1.el7.x86_64 (from Centos7)
16
+ - 1.0.0 uses mosquitto-1.4.8-1.el7.x86_64 (from Centos7)
@@ -157,7 +157,9 @@ function processEnvironmentVariables() {
157
157
  'IOTA_FALLBACK_PATH',
158
158
  'IOTA_LD_SUPPORT_NULL',
159
159
  'IOTA_LD_SUPPORT_DATASET_ID',
160
- 'IOTA_EXPRESS_LIMIT'
160
+ 'IOTA_EXPRESS_LIMIT',
161
+ 'IOTA_USE_CB_FLOW_CONTROL',
162
+ 'IOTA_STORE_LAST_MEASURE'
161
163
  ];
162
164
  const iotamVariables = [
163
165
  'IOTA_IOTAM_URL',
@@ -350,6 +352,11 @@ function processEnvironmentVariables() {
350
352
  config.defaultResource = process.env.IOTA_DEFAULT_RESOURCE;
351
353
  }
352
354
 
355
+ // Default transport
356
+ if (process.env.IOTA_DEFAULT_TRANSPORT !== undefined) {
357
+ config.defaultTransport = process.env.IOTA_DEFAULT_TRANSPORT;
358
+ }
359
+
353
360
  // Default explicitAttrs
354
361
  if (process.env.IOTA_EXPLICIT_ATTRS !== undefined) {
355
362
  config.explicitAttrs = process.env.IOTA_EXPLICIT_ATTRS;
@@ -474,6 +481,16 @@ function processEnvironmentVariables() {
474
481
  } else {
475
482
  config.expressLimit = config.expressLimit ? config.expressLimit : '1mb';
476
483
  }
484
+ if (process.env.IOTA_USE_CB_FLOW_CONTROL) {
485
+ config.useCBflowControl = process.env.IOTA_USE_CB_FLOW_CONTROL === 'true';
486
+ } else {
487
+ config.useCBflowControl = config.useCBflowControl === true;
488
+ }
489
+ if (process.env.IOTA_STORE_LAST_MEASURE) {
490
+ config.storeLastMeasure = process.env.IOTA_STORE_LAST_MEASURE === 'true';
491
+ } else {
492
+ config.storeLastMeasure = config.storeLastMeasure === true;
493
+ }
477
494
  }
478
495
 
479
496
  function setConfig(newConfig) {
@@ -503,7 +520,9 @@ function getConfigForTypeInformation() {
503
520
  multiCore: config.multiCore,
504
521
  relaxTemplateValidation: config.relaxTemplateValidation,
505
522
  defaultEntityNameConjunction: config.defaultEntityNameConjunction,
506
- defaultType: config.defaultType
523
+ defaultType: config.defaultType,
524
+ useCBflowControl: config.useCBflowControl,
525
+ storeLastMeasure: config.storeLastMeasure
507
526
  };
508
527
  return conf;
509
528
  }
package/lib/constants.js CHANGED
@@ -88,5 +88,8 @@ module.exports = {
88
88
  ATTRIBUTE_DEFAULT,
89
89
  DATETIME_DEFAULT,
90
90
 
91
+ CONFIGGROUP_TERM: 'groups',
92
+ CONFIGGROUP_API_PATH: '/iot/groups',
93
+
91
94
  getInitialValueForType
92
95
  };
@@ -45,22 +45,19 @@ const context = {
45
45
  op: 'IoTAgentNGSI.Global'
46
46
  };
47
47
 
48
+ /* eslint-disable-next-line no-unused-vars */
48
49
  function activateStatLogs(newConfig, callback) {
49
- if (newConfig.stats && newConfig.stats.interval) {
50
- async.series(
51
- [
52
- apply(statsRegistry.globalLoad, {
53
- deviceCreationRequests: 0,
54
- deviceRemovalRequests: 0,
55
- measureRequests: 0
56
- }),
57
- apply(statsRegistry.addTimerAction, statsRegistry.logStats)
58
- ],
59
- callback
60
- );
61
- } else {
62
- callback();
63
- }
50
+ async.series([
51
+ apply(statsRegistry.globalLoad, {
52
+ deviceCreationRequests: 0,
53
+ deviceRemovalRequests: 0,
54
+ measureRequests: 0,
55
+ raiseAlarm: 0,
56
+ releaseAlarm: 0,
57
+ updateEntityRequestsOk: 0,
58
+ updateEntityRequestsError: 0
59
+ })
60
+ ], callback);
64
61
  }
65
62
 
66
63
  /**
@@ -80,7 +80,9 @@ const map = {
80
80
  localestring: (d, timezone, options) => new Date(d).toLocaleString(timezone, options),
81
81
  now: () => Date.now(),
82
82
  hextostring: (val) =>
83
- new TextDecoder().decode(new Uint8Array(val.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))))
83
+ new TextDecoder().decode(new Uint8Array(val.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)))),
84
+ valuePicker: (val,pick) => Object.entries(val).filter(([, v]) => v === pick).map(([k,]) => k),
85
+ valuePickerMulti: (val,pick) => Object.entries(val).filter(([, v]) => pick.includes(v)).map(([k,]) => k)
84
86
  };
85
87
 
86
88
  exports.map = map;
@@ -34,8 +34,8 @@ const Command = new Schema({
34
34
  creationDate: { type: Date, default: Date.now }
35
35
  });
36
36
 
37
- function load(db) {
38
- module.exports.model = db.model('Command', Command);
37
+ function load() {
38
+ module.exports.model = mongoose.model('Command', Command);
39
39
  module.exports.internalSchema = Command;
40
40
  }
41
41
 
@@ -53,11 +53,15 @@ const Device = new Schema({
53
53
  autoprovision: Boolean,
54
54
  explicitAttrs: Group.ExplicitAttrsType,
55
55
  ngsiVersion: String,
56
- payloadType: String
56
+ payloadType: String,
57
+ useCBflowControl: Boolean,
58
+ storeLastMeasure: Boolean,
59
+ lastMeasure: Object,
60
+ oldCtxt: Object
57
61
  });
58
62
 
59
- function load(db) {
60
- module.exports.model = db.model('Device', Device);
63
+ function load() {
64
+ module.exports.model = mongoose.model('Device', Device);
61
65
  module.exports.internalSchema = Device;
62
66
  }
63
67
 
@@ -65,12 +65,14 @@ const Group = new Schema({
65
65
  defaultEntityNameConjunction: String,
66
66
  ngsiVersion: String,
67
67
  entityNameExp: String,
68
- payloadType: String
68
+ payloadType: String,
69
+ useCBflowControl: Boolean,
70
+ storeLastMeasure: Boolean
69
71
  });
70
72
 
71
- function load(db) {
73
+ function load() {
72
74
  Group.index({ apikey: 1, resource: 1 }, { unique: true });
73
- module.exports.model = db.model('Group', Group);
75
+ module.exports.model = mongoose.model('Group', Group);
74
76
  module.exports.internalSchema = Group;
75
77
  }
76
78