Skip to content

Commit 4c88442

Browse files
Adjusted the samples README for the raw-pub-sub sample, the shadow sample, and the jobs sample
1 parent d19cef7 commit 4c88442

File tree

1 file changed

+65
-25
lines changed

1 file changed

+65
-25
lines changed

samples/README.md

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ cmake -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DCMAKE_BUILD_
2424
cmake --build . --config "<Release|RelWithDebInfo|Debug>"
2525
```
2626

27+
To view the commands for a given sample, run the compiled program and pass `--help`.
28+
29+
```
30+
./basic-pub-sub --help
31+
```
32+
2733
#### Note
2834

2935
* `-DCMAKE_PREFIX_PATH` needs to be set to the path aws-iot-device-sdk-cpp-v2 installed. Since [Installation](../README.md#Installation) takes sdk-cpp-workspace as an example, here takes that as an example too.
@@ -172,6 +178,16 @@ This is a starting point for using custom
172178
173179
source: `samples/mqtt/raw_pub_sub/main.cpp`
174180
181+
To run the Raw MQTT Pub-Sub sample use the following command:
182+
183+
``` sh
184+
./raw-pub-sub --endpoint <endpoint> --ca_file <path to root CA1>
185+
--cert <path to the certificate> --key <path to the private key>
186+
--topic <topic name> --user_name <user name to send on connect> --password <password to send on connect>
187+
```
188+
189+
This will allow you to run the program. To disconnect and exit the program, enter `exit`.
190+
175191
## Shadow
176192
177193
This sample uses the AWS IoT
@@ -253,6 +269,16 @@ and receive.
253269
</pre>
254270
</details>
255271
272+
To run the Shadow sample use the following command:
273+
274+
``` sh
275+
./shadow-sync --endpoint <endpoint> --ca_file <path to root CA1>
276+
--cert <path to the certificate> --key <path to the private key>
277+
--thing_name <thing name> --shadow_property <shadow property name>
278+
```
279+
280+
This will allow you to run the program and set the shadow property. To disconnect and exit the program, enter `quit`.
281+
256282
## Jobs
257283
258284
This sample uses the AWS IoT
@@ -276,54 +302,68 @@ and receive.
276302
{
277303
"Version": "2012-10-17",
278304
"Statement": [
279-
280305
{
281306
"Effect": "Allow",
282-
"Action": [
283-
"iot:Publish"
284-
],
307+
"Action": "iot:Connect",
285308
"Resource": [
286-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next",
287-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update"
309+
"arn:aws:iot:<b>region</b>:<b>account</b>:client/<b>thingname</b>",
310+
"arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
288311
]
289312
},
290313
{
291314
"Effect": "Allow",
292-
"Action": [
293-
"iot:Receive"
294-
],
315+
"Action": "iot:Publish",
295316
"Resource": [
296-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/notify-next",
297-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next/accepted",
298-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next/rejected",
299-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update/accepted",
300-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update/rejected"
317+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/test/dc/pubtopic",
318+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/events/job/*",
319+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/events/jobExecution/*",
320+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*"
301321
]
302322
},
303323
{
304324
"Effect": "Allow",
305-
"Action": [
306-
"iot:Subscribe"
307-
],
325+
"Action": "iot:Subscribe",
308326
"Resource": [
309-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/notify-next",
310-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/start-next/accepted",
311-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/start-next/rejected",
312-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/*/update/accepted",
313-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/*/update/rejected"
327+
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/test/dc/subtopic",
328+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/events/jobExecution/*",
329+
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/*"
314330
]
315331
},
316332
{
317333
"Effect": "Allow",
318-
"Action": "iot:Connect",
319-
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
334+
"Action": "iot:Receive",
335+
"Resource": [
336+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/test/dc/subtopic",
337+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*"
338+
]
339+
},
340+
{
341+
"Effect": "Allow",
342+
"Action": [
343+
"iot:DescribeJobExecution",
344+
"iot:GetPendingJobExecutions",
345+
"iot:StartNextPendingJobExecution",
346+
"iot:UpdateJobExecution"
347+
],
348+
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>"
320349
}
321-
322350
]
323351
}
324352
</pre>
353+
354+
See the [Basic job policy example](https://docs.aws.amazon.com/iot/latest/developerguide/basic-jobs-example.html) page for another policy example.
325355
</details>
326356

357+
To run the job sample use the following command:
358+
359+
``` sh
360+
./describe-job-execution --endpoint <endpoint> --ca_file <path to root CA1>
361+
--cert <path to the certificate> --key <path to the private key>
362+
--thing_name <thing name> --job_id <the job id>
363+
```
364+
365+
Note that if you get a `Service Error 4 occurred` error, you may have incorrectly input the job id. The job id needs to exactly match the job id in the AWS console.
366+
327367
## Fleet provisioning
328368

329369
This sample uses the AWS IoT

0 commit comments

Comments
 (0)