Skip to content

Commit 5dcb430

Browse files
authored
Merge pull request #2408 from reubenmiller/docs-enforce-te2mqtt-v1-format
docs: enforce/normalize v1 format on all te2mqtt code blocks
2 parents d07775a + 696d0c9 commit 5dcb430

26 files changed

+127
-127
lines changed

docs/src/contribute/design/mqtt-topic-design.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Having a fixed **identifier** group in the topic structure makes it easier for o
1616

1717
A client can subscribe to all measurements for the main device by subscribing to a single topic.
1818

19-
```sh te2mqtt formats="v1"
19+
```sh te2mqtt formats=v1
2020
tedge mqtt sub 'te/device/main///m/+'
2121
```
2222

2323
Alternatively, if a client wants to subscribe to all measurements regardless of the **identifier** then it can also can be done using a single subscription, as demonstrated by the following example:
2424

25-
```sh te2mqtt formats="v1"
25+
```sh te2mqtt formats=v1
2626
tedge mqtt sub 'te/+/+/+/+/m/+'
2727
```
2828

@@ -119,7 +119,7 @@ graph LR
119119

120120
The equipment, which is a conveyor belt called "belt01", is located in factory "factory01", in the "hallA" building, in the "packaging" area. The conveyor belt can be registered as a child-device by publishing the following message.
121121

122-
```sh te2mqtt formats="v1"
122+
```sh te2mqtt formats=v1
123123
tedge mqtt pub -r 'te/factory01/hallA/packaging/belt001' '{
124124
"@type": "child-device",
125125
"name": "belt001",
@@ -139,15 +139,15 @@ The registration message will associate the telemetry data or commands published
139139

140140
For example, an event can be published to the `belt01` equipment using the following message.
141141

142-
```sh te2mqtt formats="v1"
142+
```sh te2mqtt formats=v1
143143
tedge mqtt pub 'te/factory01/hallA/packaging/belt001/e/running_status' '{
144144
"text": "Belt started"
145145
}'
146146
```
147147

148148
Since the topic schema encodes additional location information about the equipment, other MQTT clients can subscribe to telemetry data coming from all equipment located in the same area using a single MQTT subscription.
149149

150-
```sh te2mqtt formats="v1"
150+
```sh te2mqtt formats=v1
151151
tedge mqtt pub 'te/factory01/hallA/packaging/+/e/+'
152152
```
153153

@@ -156,15 +156,15 @@ When applying your own semantics to the **identifier**, you can leave any segmen
156156

157157
For example, if it does not make sense to have the factory and building in the **identifier**, then they can be removed and the equipment can be registered using:
158158

159-
```sh te2mqtt formats="v1"
159+
```sh te2mqtt formats=v1
160160
tedge mqtt pub -r 'te/packaging/belt001' '{
161161
"@type": "child-device"
162162
}'
163163
```
164164

165165
Publishing an event requires just leaving the last two segments of the **identifier** blank (whilst keeping the slashes `/` in place).
166166

167-
```sh te2mqtt formats="v1"
167+
```sh te2mqtt formats=v1
168168
tedge mqtt pub 'te/packaging/belt001///e/running_status' '{
169169
"text": "Belt started"
170170
}'

docs/src/contribute/writing-documentation/markdown-components.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ The following shows how to document how to publish a single MQTT message.
210210
**Markdown**
211211

212212
````markdown title="Markdown"
213-
```sh te2mqtt
213+
```sh te2mqtt formats=v1
214214
tedge mqtt pub te/device/main///m/ '{"temperature": 21.3}'
215215
```
216216
````
217217

218218
**Output**
219219

220-
```sh te2mqtt
220+
```sh te2mqtt formats=v1
221221
tedge mqtt pub te/device/main///m/ '{"temperature": 21.3}'
222222
```
223223

@@ -296,14 +296,14 @@ tedge mqtt pub te/device/child01///a/temp_hi_hi '{"text": "Temperature Hi Hi", "
296296
### Example: Subscribe to MQTT messages
297297

298298
````markdown title="Markdown"
299-
```sh te2mqtt
299+
```sh te2mqtt formats=v1
300300
tedge mqtt sub 'te/#'
301301
```
302302
````
303303

304304
**Output**
305305

306-
```sh te2mqtt
306+
```sh te2mqtt formats=v1
307307
tedge mqtt sub 'te/#'
308308
```
309309

@@ -312,14 +312,14 @@ tedge mqtt sub 'te/#'
312312
Any additional arguments will be automatically preserved when translating the commands. Though the `mqtt` tab will not display this information it is just meant to represent the MQTT message and does not know anything about the terminal/console.
313313

314314
````markdown title="Markdown"
315-
```sh te2mqtt
315+
```sh te2mqtt formats=v1
316316
tedge mqtt sub 'te/#' > logged.tedge.messages.txt
317317
```
318318
````
319319

320320
**Output**
321321

322-
```sh te2mqtt
322+
```sh te2mqtt formats=v1
323323
tedge mqtt sub 'te/#' > logged.tedge.messages.txt
324324
```
325325

docs/src/operate/c8y/child_device_config_management_agent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ to the URL: `http://{tedge-ip}:8000/tedge/file-transfer/{child-id}/c8y-configura
7575

7676
Once the upload is complete, the agent should notify thin-edge about the upload by sending the following MQTT message:
7777

78-
```sh te2mqtt
78+
```sh te2mqtt formats=v1
7979
tedge mqtt pub 'tedge/{child-d}/commands/res/config_snapshot' '{"type": "c8y-configuration-plugin", "path": "/child/local/fs/path"}'
8080
```
8181

@@ -107,7 +107,7 @@ The `url` value is what the child device agent must use to upload the requested
107107

108108
On receipt of the request, the agent must send an "executing" MQTT status message as follows:
109109

110-
```sh te2mqtt
110+
```sh te2mqtt formats=v1
111111
tedge mqtt pub tedge/{child-d}/commands/res/config_snapshot '{
112112
"status": "executing",
113113
"type": "{config-type}",

docs/src/operate/c8y/retrieve_jwt_token_from_cumulocity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Follow the below steps in order to retrieve the token from the Cumulocity cloud
1717

1818
1. Subscribe to token topic
1919

20-
```sh te2mqtt
20+
```sh te2mqtt formats=v1
2121
tedge mqtt sub c8y/s/dat --no-topic
2222
```
2323

2424
2. Publish an empty message on `c8y/s/uat` topic
2525

26-
```sh te2mqtt
26+
```sh te2mqtt formats=v1
2727
tedge mqtt pub c8y/s/uat ''
2828
```
2929

docs/src/operate/configuration/child-device-config-management.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Follow these steps to bootstrap the child device:
188188

189189
**Example**
190190

191-
```sh te2mqtt
191+
```sh te2mqtt formats=legacy
192192
tedge mqtt pub "tedge/child1/commands/res/config_snapshot" '{"path": "", "type":"c8y-configuration-plugin"}'
193193
```
194194

@@ -202,7 +202,7 @@ Following these steps, a configuration file from the child-device will be reques
202202

203203
1. Subscribe to config snapshot requests via MQTT
204204

205-
```sh te2mqtt
205+
```sh te2mqtt formats=legacy
206206
tedge mqtt sub "tedge/{child-id}/commands/req/config_snapshot"
207207
```
208208

@@ -249,7 +249,7 @@ Following these steps, a configuration file from the child-device will be reques
249249

250250
**Example**
251251

252-
```sh te2mqtt
252+
```sh te2mqtt formats=legacy
253253
tedge mqtt pub "tedge/child1/commands/res/config_snapshot" '{"status": "executing", "path": "/home/pi/config/config1", "type": "config1"}'
254254
```
255255

@@ -289,7 +289,7 @@ Following these steps, a configuration file from the child-device will be reques
289289

290290
**Example**
291291

292-
```sh te2mqtt
292+
```sh te2mqtt formats=legacy
293293
tedge mqtt pub "tedge/child1/commands/res/config_snapshot" '{"status": "successful", "path": "/home/pi/config/config1", "type": "config1"}'
294294
```
295295

@@ -301,7 +301,7 @@ Performing config update is an 8-step process:
301301

302302
**Example**
303303

304-
```sh te2mqtt
304+
```sh te2mqtt formats=legacy
305305
tedge mqtt sub "tedge/child1/commands/req/config_update"
306306
```
307307

@@ -352,7 +352,7 @@ Performing config update is an 8-step process:
352352

353353
**Example**
354354

355-
```sh te2mqtt
355+
```sh te2mqtt formats=legacy
356356
tedge mqtt pub "tedge/child1/commands/res/config_update" '{"status": "executing", "path": "/home/pi/config/config1", "type": "config1"}'
357357
```
358358

@@ -398,7 +398,7 @@ Performing config update is an 8-step process:
398398

399399
**Example**
400400

401-
```sh te2mqtt
401+
```sh te2mqtt formats=legacy
402402
tedge mqtt pub "tedge/child1/commands/res/config_update" '{"status": "successful", "path": "/home/pi/config/config1", "type": "config1"}'
403403
```
404404

@@ -415,7 +415,7 @@ Performing config update is an 8-step process:
415415

416416
**Example**
417417

418-
```sh te2mqtt
418+
```sh te2mqtt formats=legacy
419419
tedge mqtt pub "tedge/child1/commands/res/config_update" '{"status": "failed", "reason": "Download failed", "path": "/home/pi/config/config1", "type": "config1"}'
420420
```
421421

docs/src/operate/monitoring/enable_tedge_watchdog_using_systemd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ One can observe the message exchange between the `service` and the `watchdog`
8484
by subscribing to the following topics:
8585

8686

87-
```sh te2mqtt
87+
```sh te2mqtt formats=v1
8888
tedge mqtt sub 'te/+/+/+/+/status/health'
8989
```
9090

91-
```sh te2mqtt
91+
```sh te2mqtt formats=v1
9292
tedge mqtt sub 'te/+/+/+/+/cmd/health/check'
9393
```
9494

docs/src/operate/telemetry/pub_sub.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ Command [`tedge mqtt pub`](../../references/cli/tedge-mqtt.md) can be used to pu
1414

1515
Example:
1616

17-
```sh te2mqtt formats="v1"
17+
```sh te2mqtt formats=v1
1818
tedge mqtt pub 'te/device/main///m/env_sensor' '{"temperature": 21.3}'
1919
```
2020

2121
Messages can also be published with a different Quality of Service (QoS).
2222

23-
```sh te2mqtt formats="v1"
23+
```sh te2mqtt formats=v1
2424
tedge mqtt pub 'te/device/main///m/env_sensor' '{"temperature": 21.3}' --qos 2
2525
```
2626

2727
MQTT messages can also be published using the retained option which means that the message will be received by new MQTT clients connecting to the broker after the message was published.
2828

2929
Below shows an example of publishing a retained MQTT message:
3030

31-
```sh te2mqtt formats="v1"
31+
```sh te2mqtt formats=v1
3232
tedge mqtt pub --retain --qos 1 te/device/main///a/high_temperature '{
3333
"text": "Temperature is critical",
3434
"severity": "critical"
@@ -44,25 +44,25 @@ By default the mqtt message will be published with retain flag set to false.
4444

4545
Command [`tedge mqtt sub`](../../references/cli/tedge-mqtt.md) can be used to ease debugging of of MQTT communication on local bridge. You can subscribe to topic of your choosing:
4646

47-
```sh te2mqtt
47+
```sh te2mqtt formats=v1
4848
tedge mqtt sub te/errors
4949
```
5050

5151
Or you can subscribe to any topic on the server using wildcard (`#`) topic:
5252

53-
```sh te2mqtt
53+
```sh te2mqtt formats=v1
5454
tedge mqtt sub '#'
5555
```
5656

5757
Now using a different console/shell, publish the following measurement so that the previous subscription will receive it:
5858

59-
```sh te2mqtt formats="v1"
59+
```sh te2mqtt formats=v1
6060
tedge mqtt pub --retain --qos 1 te/device/main///m/env_sensor '{"temperature": 21.3}'
6161
```
6262

6363
All messages from sub command are printed to `stdout` and can be captured to a file if you need to:
6464

65-
```sh te2mqtt
65+
```sh te2mqtt formats=v1
6666
tedge mqtt sub '#' > filename.mqtt
6767
```
6868

docs/src/operate/troubleshooting/monitor_tedge_health.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ and this will be retained until the service is restarted.
4545

4646
E.g. the mapper being killed:
4747

48-
```sh te2mqtt
48+
```sh te2mqtt formats=v1
4949
tedge mqtt sub 'te/+/+/+/+/status/health'
5050
```
5151

docs/src/operate/troubleshooting/trouble_shooting_monitoring.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sudo systemctl start collectd
2323

2424
## Is collectd publishing MQTT messages?
2525

26-
```sh te2mqtt
26+
```sh te2mqtt formats=v1
2727
tedge mqtt sub 'collectd/#'
2828
```
2929

@@ -47,21 +47,21 @@ sudo systemctl start tedge-mapper-collectd
4747

4848
## Are the collectd metrics published in Thin Edge JSON format?
4949

50-
```sh te2mqtt formats="v1"
50+
```sh te2mqtt formats=v1
5151
tedge mqtt sub 'te/device/main///m/+'
5252
```
5353

5454
## Are the collectd metrics published to Cumulocity IoT?
5555

56-
```sh te2mqtt
56+
```sh te2mqtt formats=v1
5757
tedge mqtt sub 'c8y/#'
5858
```
5959

6060
If not see how to [connect a device to Cumulocity IoT](../../start/connect-c8y.md).
6161

6262
## Are the collectd metrics published to Azure IoT?
6363

64-
```sh te2mqtt
64+
```sh te2mqtt formats=v1
6565
tedge mqtt sub 'az/#'
6666
```
6767

docs/src/references/agent/device-management-api.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ that this device can be sent commands of this type.
6666
These messages are published with the retained flag set. So, a client process, such a mapper, can discover on start
6767
what are __all the capabilities of all the devices__:
6868

69-
```sh te2mqtt formats="v1"
69+
```sh te2mqtt formats=v1
7070
tedge mqtt sub 'te/+/+/+/+/cmd/+'
7171
```
7272

@@ -105,7 +105,7 @@ It is recommended to either use a unique id generator, or add a unix timestamp a
105105
The messages published on these topics represent each the current status of a running command.
106106
So, one can list __all the in-progress commands of any type across all the devices__:
107107

108-
```sh te2mqtt formats="v1"
108+
```sh te2mqtt formats=v1
109109
tedge mqtt sub 'te/+/+/+/+/cmd/+/+'
110110
```
111111

@@ -222,7 +222,7 @@ As an example, let's take software updates on a child device.
222222
When launched on the child device `device/child001//`,
223223
`tedge-agent` notifies that software packages of types: `apt` and `docker` can be updated on this device:
224224

225-
```sh te2mqtt formats="v1"
225+
```sh te2mqtt formats=v1
226226
tedge mqtt pub --retain 'te/device/child001///cmd/software_update' '{
227227
"description": "Install, update and remove software packages",
228228
"types": [
@@ -235,7 +235,7 @@ tedge mqtt pub --retain 'te/device/child001///cmd/software_update' '{
235235
On reception of this message, the Cumulocity mapper notifies Cumulocity of this capability.
236236
On request from a cloud operator, the Cumulocity mapper creates a new command instance, say to update `nodered`:
237237

238-
```sh te2mqtt formats="v1"
238+
```sh te2mqtt formats=v1
239239
tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' '{
240240
"status": "init",
241241
"updateList": [
@@ -255,7 +255,7 @@ tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' '{
255255

256256
The agent, running on `device/child001//`, notifies that it will execute the command:
257257

258-
```sh te2mqtt formats="v1"
258+
```sh te2mqtt formats=v1
259259
tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' '{
260260
"status": "executing",
261261
"updateList": [
@@ -275,7 +275,7 @@ tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' '{
275275

276276
Then the agent proceeds, here installing a specific version of `nodered`, and notifies the mapper when done:
277277

278-
```sh te2mqtt formats="v1"
278+
```sh te2mqtt formats=v1
279279
tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' '{
280280
"status": "successful",
281281
"updateList": [
@@ -297,6 +297,6 @@ The Cumulocity mapper, having subscribed to all software_update commands,
297297
monitors this command instance and notifies Cumulocity of its progress upto completion.
298298
Finally, the Cumulocity mapper clear the command topic:
299299

300-
```sh te2mqtt formats="v1"
300+
```sh te2mqtt formats=v1
301301
tedge mqtt pub --retain 'te/device/child001///cmd/software_update/c8y-123' ''
302302
```

0 commit comments

Comments
 (0)