Skip to content

Commit 1bcd64b

Browse files
committed
sample documentation update
1 parent 995a362 commit 1bcd64b

File tree

12 files changed

+556
-2958
lines changed

12 files changed

+556
-2958
lines changed

documents/FAQ.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you are just getting started make sure you [install this sdk](https://github.
1818

1919
### How do I enable logging?
2020

21-
To enable logging in the samples, you will need to set the following system properties when running the samples:
21+
<!-- To enable logging in the samples, you will need to set the following system properties when running the samples:
2222
2323
```sh
2424
-Daws.crt.debugnative=true
@@ -36,7 +36,7 @@ For example, to run `BasicPubSub` with logging you could use the following:
3636
3737
```sh
3838
mvn compile exec:java -pl samples/BasicPubSub -Daws.crt.debugnative=true -Daws.crt.log.level=Debug -Daws.crt.log.destionation=Stdout -Dexec.mainClass=pubsub.PubSub -Dexec.args='--endpoint <endpoint> --cert <path to cert> --key <path to key> --ca_file <path to ca file>'
39-
```
39+
``` -->
4040

4141
You can also enable [CloudWatch logging](https://docs.aws.amazon.com/iot/latest/developerguide/cloud-watch-logs.html) for IoT which will provide you with additional information that is not available on the client side sdk.
4242

@@ -90,11 +90,11 @@ Here is an example launch.json file to run the pubsub sample
9090
"configurations": [
9191
{
9292
"type": "java",
93-
"name": "PubSub",
93+
"name": "x509",
9494
"request": "launch",
95-
"mainClass": "pubsub.PubSub",
96-
"projectName": "BasicPubSub",
97-
"args": "--endpoint <account-number>-ats.iot.<region>.amazonaws.com --ca_file <path to root-CA> --cert <path to cert> --key <path to key> --client-id test-client",
95+
"mainClass": "mqtt5x509.Mqtt5X509",
96+
"projectName": "Mqtt5X509",
97+
"args": "--endpoint <account-number>-ats.iot.<region>.amazonaws.com --cert <path to cert> --key <path to key> --client-id test-client",
9898
"console": "externalTerminal"
9999
}
100100
]

documents/MQTT5_Userguide.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
* [Websocket Connection with Cognito Authentication Method](#websocket-connection-with-cognito-authentication-method)
1919
+ [Adding an HTTP Proxy](#adding-an-http-proxy)
2020
+ [How to create a MQTT5 client](#how-to-create-a-mqtt5-client)
21+
* [Lifecycle Management](#lifecycle-management)
2122
+ [How to Start and Stop](#how-to-start-and-stop)
22-
+ [How to Publish](#how-to-publish)
23-
+ [How to Subscribe and Unsubscribe](#how-to-subscribe-and-unsubscribe)
23+
+ [Client Operations](#client-operations)
24+
+ [How to Publish](#how-to-publish)
25+
+ [How to Subscribe and Unsubscribe](#how-to-subscribe-and-unsubscribe)
2426
+ [MQTT5 Best Practices](#mqtt5-best-practices)
2527

2628
# Introduction
@@ -351,6 +353,8 @@ SDK Proxy support also includes support for basic authentication and TLS-to-prox
351353
352354
Once a MQTT5 client builder has been created, it is ready to make a [MQTT5 client](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5Client.html). Something important to note is that once a MQTT5 client is built and finalized, the resulting MQTT5 client cannot have its settings modified! Further, modifications to the MQTT5 client builder will not change the settings of already created the MQTT5 clients. Before building a MQTT5 client from a MQTT5 client builder, make sure to have everything fully setup.
353355
356+
### Lifecycle Management
357+
354358
For almost every MQTT5 client, it is extremely important to setup [LifecycleEvents](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5ClientOptions.LifecycleEvents.html) callbacks. [LifecycleEvents](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5ClientOptions.LifecycleEvents.html) are invoked when the MQTT5 client connects, fails to connect, disconnects, and is stopped. Without these callbacks setup, it will be incredibly hard to determine the state of the MQTT5 client. To setup [LifecycleEvents](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5ClientOptions.LifecycleEvents.html) callbacks, see the following code:
355359
356360
~~~ java
@@ -482,7 +486,9 @@ client.stop(disconnectBuilder.build());
482486
client.close();
483487
~~~
484488
485-
## How to Publish
489+
## Client Operations
490+
491+
### Publish
486492
487493
The [publish](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5Client.html#publish(software.amazon.awssdk.crt.mqtt5.packets.PublishPacket)) operation takes a description of the PUBLISH packet you wish to send and returns a promise containing a [PublishResult](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/PublishResult.html). The returned [PublishResult](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/PublishResult.html) will contain different data depending on the QoS used in the publish.
488494
@@ -518,7 +524,7 @@ PublishResult result = published.get(60, TimeUnit.SECONDS);
518524
519525
Note that publishes made while a MQTT5 client is disconnected and offline will be put into a queue. Once reconnected, the MQTT5 client will send any publishes made while disconnected and offline automatically.
520526
521-
## How to Subscribe and Unsubscribe
527+
### Subscribe and Unsubscribe
522528
523529
The [subscribe](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/Mqtt5Client.html#subscribe(software.amazon.awssdk.crt.mqtt5.packets.SubscribePacket)) operation takes a description of the [SubscribePacket](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/packets/SubscribePacket.html) you wish to send and returns a promise that resolves successfully with the corresponding [SubAckPacket](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/packets/SubAckPacket.html) returned by the broker; the promise is rejected with an error if anything goes wrong before the [SubAckPacket](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/packets/SubAckPacket.html) is received.
524530
You should always check the reason codes of a [SubAckPacket](https://awslabs.github.io/aws-crt-java/software/amazon/awssdk/crt/mqtt5/packets/SubAckPacket.html) completion to determine if the subscribe operation actually succeeded.

0 commit comments

Comments
 (0)