Skip to content

Commit

Permalink
Merge pull request #764 from telefonicaid/fgalan-patch-1
Browse files Browse the repository at this point in the history
FIX improve documentation
  • Loading branch information
mapedraza authored Oct 6, 2023
2 parents 18d3568 + 21e0121 commit a6f2572
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions docs/usermanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,23 @@ In this case, sending a single measure, there is possible to send other kinds of
`application/octet-stream`, not just `application/json`. In case of using `application/octet-stream`, data will be
treated as binary data, saved in the attribute maped as hex string. I.E:

For a measure sent to `/iot/json/attrs/attrHex` with value `hello` the resulting attribute value persisten in the context
broker will be:
For a measure sent to `POST /iot/json/attrs/attrHex` with content-type: application/octet-stream and binary value

```
hello
```

then the resulting attribute sent to ContextBroker:

```json
{
...
"attrHex":"68656c6c6f"
...
...
"attrHex": {
"value": "68656c6c6f"
"type": "<the one used at provisiong time for attrHex attribute>"
}
}
```

where every group of 2 character (I.E, the first group, `68`) corresponds to a single ASCII character or byte received in
Note that every group of 2 character (I.E, the first group, `68`) corresponds to a single ASCII character or byte received in
the payload (in this case, the value `0x68` corresponds to `h` in ASCII). You can use one of the multiple tools available
online like [this one](https://string-functions.com/string-hex.aspx)

Expand Down Expand Up @@ -311,6 +316,30 @@ attribute IDs `h` and `t`, then humidity measures are reported this way:
$ mosquitto_pub -t /json/ABCDEF/id_sen1/attrs/h -m 70 -h <mosquitto_broker> -p <mosquitto_port> -u <user> -P <password>
```

In the single measure case, when the published data is not a valid JSON, it is interpreted as binary content. For instance,
if the following is published to `/json/ABCDEF/id_sen1/attrs/attrHex` topic:

```
hello
```

then the resulting attribute sent to ContextBroker:

{
...
"attrHex": {
"value": "68656c6c6f"
"type": "<the one used at provisiong time for attrHex attribute>"
}
}

Note that every group of 2 character (I.E, the first group, `68`) corresponds to a single ASCII character or byte received in
the payload (in this case, the value `0x68` corresponds to `h` in ASCII). You can use one of the multiple tools available
online like [this one](https://string-functions.com/string-hex.aspx).

Note this works differently that in HTTP transport. In HTTP the JSON vs. binary decission is based on `application/octed-stream` `content-type` header.
Given that in MQTT we don't have anything equivalent to HTTP headers, we apply the heuristics of checking for JSON format.

#### Configuration retrieval

The protocol offers a mechanism for the devices to retrieve its configuration (or any other value it needs from those
Expand Down

0 comments on commit a6f2572

Please sign in to comment.