Skip to content

Commit

Permalink
Merge pull request #1607 from telefonicaid/task/allow_send_update_cb_…
Browse files Browse the repository at this point in the history
…batch_for_multimeasures

allow to send to CB batch update for multimeasures (and sort them by TimeInstant)
  • Loading branch information
fgalan authored May 21, 2024
2 parents eae5ae0 + 6d8642b commit f7b914c
Show file tree
Hide file tree
Showing 6 changed files with 956 additions and 352 deletions.
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (telefonicaid/iotagent-json#827)
- Fix: allow send multiple measures to CB in a batch (POST /v2/op/update) and sorted by TimeInstant when possible, instead of using multiples single request (iotagent-json#825, #1612)
- Fix: default express limit to 1Mb instead default 100Kb and allow change it throught a conf env var 'IOTA_EXPRESS_LIMIT' (iotagent-json#827)
122 changes: 122 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [Measurement transformation order](#measurement-transformation-order)
- [Multientity measurement transformation support (`object_id`)](#multientity-measurement-transformation-support-object_id)
- [Timestamp Processing](#timestamp-processing)
- [Multimeasure support](#multimeasure-support)
- [Overriding global Context Broker host](#overriding-global-context-broker-host)
- [Multitenancy, FIWARE Service and FIWARE ServicePath](#multitenancy-fiware-service-and-fiware-servicepath)
- [Secured access to the Context Broker](#secured-access-to-the-context-broker)
Expand Down Expand Up @@ -1051,6 +1052,127 @@ Some additional considerations to take into account:
measure of after a mapping, as described in the previous bullet) then it is refused (so a failover to server
timestamp will take place).

## Multimeasure support

A device could receive several measures at the same time.

For example:

```json
[
{
"vol": 0
},
{
"vol": 1
},
{
"vol": 2
}
]
```

In this case a batch update (`POST /v2/op/update`) to CB will be generated with the following NGSI v2 payload:

```json
{
"actionType": "append",
"entities": [
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 0
}
},
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 1
}
},
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 1
}
}
]
}
```

Moreover if a multimeasure contains TimeInstant attribute, then CB update is sorted by attribute TimeInstant:

For example:

```json
[
{
"vol": 0,
"TimeInstant": "2024-04-10T10:15:00Z"
},
{
"vol": 1,
"TimeInstant": "2024-04-10T10:10:00Z"
},
{
"vol": 2,
"TimeInstant": "2024-04-10T10:05:00Z"
}
]
```

In this case a batch update (`POST /v2/op/update`) to CB will be generated with the following NGSI v2 payload:

```json
{
"actionType": "append",
"entities": [
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 2
},
"TimeInstant": {
"type": "DateTime",
"value": "2024-04-10T10:05:00Z"
}
},
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 1
},
"TimeInstant": {
"type": "DateTime",
"value": "2024-04-10T10:10:00Z"
}
},
{
"id": "ws",
"type": "WeatherStation",
"vol": {
"type": "Number",
"value": 0
},
"TimeInstant": {
"type": "DateTime",
"value": "2024-04-10T10:15:00Z"
}
}
]
}
```

## Overriding global Context Broker host

**cbHost**: Context Broker host URL. This option can be used to override the global CB configuration for specific types
Expand Down
Loading

0 comments on commit f7b914c

Please sign in to comment.