Skip to content

Commit d25d80f

Browse files
authored
Merge pull request #1734 from telefonicaid/task/use_cmd_by_subs
allow use commands by simple subscriptions/notifications
2 parents fd0c311 + 667eeaf commit d25d80f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+958
-200
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
- Fix: update device with useCBflowControl
2+
- Add: command modes (new field cmdMode): legacy, notification and advancedNotification (#1732)
13
- Set Nodejs 20 as minimum version in packages.json (effectively removing Nodev16 and Nodev18 from supported versions)

config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ var config = {
7979
defaultType: 'Thing',
8080
expressLimit: '1Mb',
8181
useCBflowControl: false,
82-
storeLastMeasure: false
82+
storeLastMeasure: false,
83+
cmdMode: 'legacy'
8384
};
8485

8586
module.exports = config;

doc/admin.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,17 @@ If this flag is activated, when iotAgent invokes Context Broker will use
452452
[flowControl option](https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/admin/perf_tuning.md#updates-flow-control-mechanism).
453453
This flag is overwritten by `useCBflowControl` flag in group or device. This flag is disabled by default.
454454

455+
#### `cmdMode`
456+
457+
Set command mode for the IoTAgent instance (it can be overriden by the `cmdMode` at group or device level). Possible values are:
458+
459+
* `legacy` (used as default if this setting is not defined): IoTAgent commands will use Context Broker registers
460+
mechanims.
461+
* `notification`: IoTAgent commands will use subscriptions to be notified for Context Broker commands.
462+
* `advancedNotification`: IoTAgent commands will use subscriptions to be notified for Context Broker commands (but in a different way as in `notification` mode)
463+
464+
Have a look to [this document](devel/northboundinteractions.md) for more detail on how this modes work.
465+
455466
### Configuration using environment variables
456467

457468
Some of the configuration parameters can be overriden with environment variables, to ease the use of those parameters
@@ -517,6 +528,7 @@ overrides.
517528
| IOTA_EXPRESS_LIMIT | `expressLimit` |
518529
| IOTA_STORE_LAST_MEASURE | `storeLastMeasure` |
519530
| IOTA_CB_FLOW_CONTROL | `useCBflowControl` |
531+
| IOTA_CMD_MODE | `cmdMode` |
520532

521533
Note:
522534

doc/api.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Special measures and attributes names](#special-measures-and-attributes-names)
1313
- [Device to NGSI Mapping](#device-to-ngsi-mapping)
1414
- [Device autoprovision and entity creation](#device-autoprovision-and-entity-creation)
15+
- [Entity creation when `cmdMode` is `notification`](#entity-creation-when-cmdmode-is-notification)
1516
- [Entity Name expression support](#entity-name-expression-support)
1617
- [Multientity support](#multientity-support)
1718
- [Metadata support](#metadata-support)
@@ -257,9 +258,9 @@ Additionally for commands (which are attributes of type `command`) the following
257258
particular IOTAs documentation for allowed values of this field in each case.
258259
- **contentType**: `content-type` header used when send command by HTTP transport (ignored in other kinds of
259260
transports)
260-
- **headers**: extra customer headers used when send command by HTTP transport (ignored in other kinds of
261-
transports)
262-
Check full detail of these fields in [comand-transformations](https://github.com/telefonicaid/iotagent-json/blob/master/docs/usermanual.md#commands-transformations)
261+
- **headers**: extra customer headers used when send command by HTTP transport (ignored in other kinds of transports)
262+
Check full detail of these fields in
263+
[comand-transformations](https://github.com/telefonicaid/iotagent-json/blob/master/docs/usermanual.md#commands-transformations)
263264

264265
Note that, when information coming from devices, this means measures, are not defined neither in the group, nor in the
265266
device, the IoT agent will store that information into the destination entity using the same attribute name than the
@@ -276,6 +277,31 @@ If for any reason you need the entity at CB before the first measure of the corr
276277
IOTAgent, you can create it in advance using the Context Broker
277278
[NGSI v2 API](https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md).
278279

280+
## Entity creation when `cmdMode` is `notification`
281+
282+
Even when an entity should not be created (see [above section](#device-autoprovision-and-entity-creation)), when the device uses `cmdMode` set to `notification` an entity is created. In particular:
283+
284+
* An entity is created at device provision time
285+
* That entity is created with an attribute corresponding to each commands. The value of that attribute at creation time is `null` (specifying in some way that the command has not been triggered yet). Note that if the attribute doesn't have any command, the entity is not created (even if `cmdMode` is `notification`).
286+
287+
For instance, if device has commands `ping` and `switch` the entity corresponding to that device will be created at provising time with the following attributes:
288+
289+
```
290+
...
291+
{
292+
"ping": {
293+
"type": "command",
294+
"value": null
295+
},
296+
"switch": {
297+
"type": "command",
298+
"value": null
299+
},
300+
}
301+
```
302+
303+
**NOTE:** `command` is the usual type for attributes associated to commands, but the one used at provisioning time (`"command": [ ...]` field) will be actually used.
304+
279305
## Entity Name expression support
280306

281307
By default, the entity name used to persist the device measures in the Context Broker can be defined in the device
@@ -1323,6 +1349,8 @@ as `command` in the [config group](#config-group-datamodel) or in the [device pr
13231349
attributes are created using `command` as attribute type. Also, you can define the protocol you want the commands to be
13241350
sent (HTTP/MQTT) with the `transport` parameter at the provisioning process.
13251351

1352+
**NOTE**: in `advancedNotification` mode the command is not triggered updating an attribute, but creating a command execution entity. However, this mode has not been implemented yet so details are to be clarified.
1353+
13261354
For a given device provisioned with a `ping` command defined, any update on this attribute "ping" at the NGSI entity in
13271355
the Context Broker will send a command to your device. For instance, to send the `ping` command with value
13281356
`Ping request` you could use the following operation in the Context Broker API:
@@ -1784,6 +1812,7 @@ Config group is represented by a JSON object with the following fields:
17841812
| `endpoint` || `string` | | Endpoint where the group of device is going to receive commands, if any. |
17851813
| `storeLastMeasure` || `boolean` | | Store in device last measure received. See more info [in this section](admin.md#storelastmeasure). False by default |
17861814
| `useCBflowControl` || `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default |
1815+
| `cmdMode` || `string` | | Command mode that will use iotagent with CB: **legacy**, **notification** and **advancedNotification**. **Legacy** is based on registers. **notification** based on simplified schema of subscriptions. **Legacy** by default. More information on how the different modes work can be found in [the northbound interactions documents](devel/northboundinteractions.md). |
17871816

17881817
### Config group operations
17891818

@@ -2007,6 +2036,7 @@ the API resource fields and the same fields in the database model.
20072036
| `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. |
20082037
| `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). |
20092038
| `useCBflowControl` || `boolean` | | Use Context Broker flow control. See more info [in this section](admin.md#useCBflowControl). False by default. |
2039+
| `cmdMode` || `string` | | Command mode that will use iotagent with CB: **legacy**, **notification** and **advancedNotification**. **Legacy** is based on registers. **notification** based on simplified schema of subscriptions. **Legacy** by default. More information on how the different modes work can be found in [the northbound interactions documents](devel/northboundinteractions.md). |
20102040

20112041
### Device operations
20122042

0 commit comments

Comments
 (0)