Skip to content

Commit

Permalink
Addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
albinsuresh committed Oct 5, 2023
1 parent ff0a810 commit db40a8d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
56 changes: 26 additions & 30 deletions docs/src/references/mappers/c8y-mapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,13 @@ c8y/alarm/alarms/create

</div>

### Data
### Twin

The data telemetry type can be used to store additional information about the device/child/service. Such information could included; operation system name/version, communication statistics, device status, or any other information that is not suited to measurements, events or alarms.
The twin data type can be used to store additional information about the device/child/service.
Such information could included: operation system name/version, communication statistics, device status,
or any other information that is not suited to be measurements, events or alarms.

#### Data - Main device
#### Twin - Main device

A device's digital twin model can be updated by publishing to a specific topic.

Expand All @@ -583,7 +585,7 @@ The type part of the topic is used to group the data so it is easier for compone
**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/main///data/device_OS
te/device/main///twin/device_OS
```

```json5 title="Payload"
Expand Down Expand Up @@ -615,35 +617,22 @@ c8y/inventory/managedObjects/update/<main-device-id>
</div>


#### Data - root
#### Twin data - root

Data can be added on the root level by leaving the type value in topic blank but still using a trailing slash.

Some property names are forbidden and will be ignored if they are included in the payload. This is to avoid setting the property values from two different sources.

* `name`
* `type`

Note: The payload should be restricted to the following data types:

* string
* boolean
* number

For complex data types like arrays and objects, these data types should be published to the typed topics.
Data can be added on the root level of the twin by publishing the values directly to the topic with the key used as type.
The payload can be any valid JSON value other than a JSON object.
JSON objects must be published to their typed topics directly.

<div class="code-indent-left">

**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/main///data/
te/device/main///twin/subtype
```

```json5 title="Payload"
{
"subtype": "my-custom-type"
}
"my-custom-type"
```

</div>
Expand All @@ -664,14 +653,21 @@ c8y/inventory/managedObjects/update/<main-device-id>

</div>

Some property names, that are already included in the entity registration messages,
are forbidden and will be ignored if they are included in the payload.
This is to avoid setting the property values from two different sources.

* `name`
* `type`

#### Data - Child Device

<div class="code-indent-left">

**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/child01///data/device_OS
te/device/child01///twin/device_OS
```

```json5 title="Payload"
Expand Down Expand Up @@ -709,7 +705,7 @@ c8y/inventory/managedObjects/update/<main-device-id>:device:child01
**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/main/service/tedge-agent/data/runtime_stats
te/device/main/service/tedge-agent/twin/runtime_stats
```

```json5 title="Payload"
Expand Down Expand Up @@ -748,7 +744,7 @@ c8y/inventory/managedObjects/update/<main-device-id>:device:main:service:tedge-a
**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/child01/service/tedge-agent/data/runtime_stats
te/device/child01/service/tedge-agent/twin/runtime_stats
```

```json5 title="Payload"
Expand Down Expand Up @@ -787,7 +783,7 @@ c8y/inventory/managedObjects/update/<main-device-id>:device:child01:service:tedg
**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/child01/service/tedge-agent/data/runtime_stats
te/device/child01/service/tedge-agent/twin/runtime_stats
```

```json5 title="Payload"
Expand Down Expand Up @@ -815,12 +811,12 @@ c8y/inventory/managedObjects/update/<main-device-id>:device:child01:service:tedg

#### Data - Deleting a root fragment

When deleting the root fragments on the `/data/` topic, the mapper will have to keep track of the previously published value before the delete request is published. All the properties should have their values set to `null` and included in the published.
When deleting the root fragments on the `/twin/` topic, the mapper will have to keep track of the previously published value before the delete request is published. All the properties should have their values set to `null` and included in the published.

For the example mapping, it assumes that the following message was already published before the deletion message was received.

```text title="Topic (retain=true)"
te/device/child01/service/tedge-agent/data/
te/device/child01/service/tedge-agent/twin/
```

```json5 title="Payload"
Expand All @@ -836,7 +832,7 @@ te/device/child01/service/tedge-agent/data/
**Thin Edge (input)**

```text title="Topic (retain=true)"
te/device/child01/service/tedge-agent/data/
te/device/child01/service/tedge-agent/twin/
```

```json5 title="Payload"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/references/mqtt-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ so that it can process them.
|Measurements|`te/<identifier>/m/<measurement-type>`|
|Events|`te/<identifier>/e/<event-type>`|
|Alarms|`te/<identifier>/a/<alarm-type>`|
|Data|`te/<identifier>/data/<data-type>`|
|Twin|`te/<identifier>/twin/<data-type>`|

### Examples: With default device/service topic semantics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Child devices support sending inventory data via c8y topic


Child devices support sending inventory data via tedge topic with type
Execute Command tedge mqtt pub "te/device/${CHILD_SN}///data/device_OS" '{"family":"Debian","version":11,"complex":[1,"2",3],"object":{"foo":"bar"}}'
Execute Command tedge mqtt pub "te/device/${CHILD_SN}///twin/device_OS" '{"family":"Debian","version":11,"complex":[1,"2",3],"object":{"foo":"bar"}}'
Cumulocity.Set Device ${CHILD_SN}
${mo}= Device Should Have Fragments device_OS
Should Be Equal ${mo["device_OS"]["family"]} Debian
Expand All @@ -84,7 +84,8 @@ Child devices support sending inventory data via tedge topic with type


Child devices supports sending inventory data via tedge topic to root fragments
Execute Command tedge mqtt pub "te/device/${CHILD_SN}///data/" '{"subtype":"LinuxDeviceA","type":"ShouldBeIgnored"}'
Execute Command tedge mqtt pub "te/device/${CHILD_SN}///twin/subtype" "LinuxDeviceA"
Execute Command tedge mqtt pub "te/device/${CHILD_SN}///twin/type" "ShouldBeIgnored"
Cumulocity.Set Device ${CHILD_SN}
${mo}= Device Should Have Fragments subtype
Should Be Equal ${mo["subtype"]} LinuxDeviceA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Thin-edge device support sending inventory data via c8y topic


Thin-edge device support sending inventory data via tedge topic
Execute Command tedge mqtt pub "te/device/main///data/device_OS" '{"family":"Debian","version":11,"complex":[1,"2",3],"object":{"foo":"bar"}}'
Execute Command tedge mqtt pub "te/device/main///twin/device_OS" '{"family":"Debian","version":11,"complex":[1,"2",3],"object":{"foo":"bar"}}'
Cumulocity.Set Device ${DEVICE_SN}
${mo}= Device Should Have Fragments device_OS
Should Be Equal ${mo["device_OS"]["family"]} Debian
Expand All @@ -144,7 +144,8 @@ Thin-edge device support sending inventory data via tedge topic


Thin-edge device supports sending inventory data via tedge topic to root fragments
Execute Command tedge mqtt pub "te/device/main///data/" '{"subtype":"LinuxDeviceA","type":"ShouldBeIgnored"}'
Execute Command tedge mqtt pub "te/device/main///twin/subtype" "LinuxDeviceA"
Execute Command tedge mqtt pub "te/device/main///twin/type" "ShouldBeIgnored"
Cumulocity.Set Device ${DEVICE_SN}
${mo}= Device Should Have Fragments subtype
Should Be Equal ${mo["subtype"]} LinuxDeviceA
Expand Down

0 comments on commit db40a8d

Please sign in to comment.