|  | 
|  | 1 | +# Sample Applications for the AWS IoT Device SDK v2 for Python | 
|  | 2 | +This directory contains sample applications for [aws-iot-device-sdk-python-v2](../README.md). | 
|  | 3 | + | 
|  | 4 | +### Table of Contents | 
|  | 5 | +* [Samples](#samples) | 
|  | 6 | +    * [MQTT5 Client Samples](#mqtt5-client-samples) | 
|  | 7 | +    * [Service Client Samples](#service-client-samples) | 
|  | 8 | +    * [Greengrass Samples](#greengrass-samples) | 
|  | 9 | +* [Instructions](#instructions) | 
|  | 10 | +* [Sample Help](#sample-help) | 
|  | 11 | +* [Enable Logging](#enable-logging) | 
|  | 12 | + | 
|  | 13 | + | 
|  | 14 | +## Samples | 
|  | 15 | +### MQTT5 Client Samples | 
|  | 16 | +##### MQTT5 is the recommended MQTT Client. Additional infomration and usage instructions can be found in the [MQTT5 User Guide](../documents/MQTT5_Userguide.md). The samples below will create an MQTT5 client, connect using the selected method, subscribe to a topic, publish to the topic, and then disconnect. | 
|  | 17 | +| MQTT5 Client Sample | Description | | 
|  | 18 | +|--------|-------------| | 
|  | 19 | +| [X509-based mutual TLS](./mqtt/mqtt5_x509.md) | Demonstrates connecting to AWS IoT Core using X.509 certificates and private keys. | 
|  | 20 | +| [Websockets with Sigv4 authentication](./mqtt/mqtt5_aws_websocket.md) | Shows how to authenticate over websockets using AWS Signature Version 4 credentials. | | 
|  | 21 | +| [AWS Custom Authorizer Lambda Function](./mqtt/mqtt5_custom_auth.md) | Examples of connecting with a signed and unsigned Lambda-backed custom authorizer. | 
|  | 22 | +| [PKCS11](./mqtt/mqtt5_pkcs11_connect.md) | Demonstrates connecting using a hardware security module (HSM) or smartcard with PKCS#11. | | 
|  | 23 | +| [Other Connection Methods](../documents/MQTT5_Userguide.md#how-to-create-an-mqtt5-client-based-on-desired-connection-method) | More connection methods are available for review in the MQTT5 Userguide | 
|  | 24 | + | 
|  | 25 | +### Service Client Samples | 
|  | 26 | +##### AWS offers a number of IoT related services using MQTT. The samples below demonstrate how to use the service clients provided by the SDK to interact with those services. | 
|  | 27 | +| Service Client Sample | Description | | 
|  | 28 | +|--------|-------------| | 
|  | 29 | +| [Shadow](./service_clients//shadow.md) | Manage and sync device state using the IoT Device Shadow service. | | 
|  | 30 | +| [Jobs](./service_clients//jobs.md) | Receive and execute remote operations sent from the Jobs service. | | 
|  | 31 | +| [Basic Fleet Provisioning](./service_clients//fleet_provisioning_basic.md) | Provision a device using the Fleet Provisioning template. | | 
|  | 32 | +| [CSR Fleet Provisioning](./service_clients//fleet_provisioning_csr.md) | Demonstrates CSR-based device certificate provisioning. | | 
|  | 33 | + | 
|  | 34 | + | 
|  | 35 | +### Greengrass Samples | 
|  | 36 | +##### Samples that interact with [AWS Greengrass](https://aws.amazon.com/greengrass/). | 
|  | 37 | +| Greengrass Sample | Description | | 
|  | 38 | +|--------|-------------| | 
|  | 39 | +| [Greengrass Discovery](./greengrass//basic_discovery.md) | Discover and connect to a local Greengrass core. | | 
|  | 40 | +| [Greengrass IPC](./greengrass//ipc_greengrass.md) | Demonstrates Inter-Process Communication (IPC) with Greengrass components. | | 
|  | 41 | + | 
|  | 42 | +### Instructions | 
|  | 43 | + | 
|  | 44 | +First, install `aws-iot-device-sdk-python-v2`. Installation instructions for the SDK are [Provided Here](../README.md#Installation). | 
|  | 45 | + | 
|  | 46 | +Each sample's README contains prerequisites, arguments, and detailed instructions. For example, the [MQTT5 X509 Sample README](./mqtt/mqtt5_x509.md) is `mqtt5_x509.md` and the sample can be run with the following command: | 
|  | 47 | + | 
|  | 48 | +``` sh | 
|  | 49 | +# For Windows: replace 'python3' with 'python' and '/' with '\' | 
|  | 50 | +python3 mqtt5_x509.py --endpoint <endpoint> --cert <path to certificate> --key <path to private key> | 
|  | 51 | +``` | 
|  | 52 | + | 
|  | 53 | +### Sample Help | 
|  | 54 | + | 
|  | 55 | +All samples will show their options and arguments by passing in `--help`. For example: | 
|  | 56 | +``` sh | 
|  | 57 | +# For Windows: replace 'python3' with 'python' and '/' with '\' | 
|  | 58 | +python3 mqtt5_x509.py --help | 
|  | 59 | +``` | 
|  | 60 | + | 
|  | 61 | +will result in the following print output: | 
|  | 62 | +``` | 
|  | 63 | +MQTT5 X509 Sample (mTLS) | 
|  | 64 | +
 | 
|  | 65 | +options: | 
|  | 66 | +  -h, --help    show this help message and exit | 
|  | 67 | +
 | 
|  | 68 | +required arguments: | 
|  | 69 | +  --endpoint    IoT endpoint hostname (default: None) | 
|  | 70 | +  --cert        Path to the certificate file to use during mTLS connection establishment (default: None) | 
|  | 71 | +  --key         Path to the private key file to use during mTLS connection establishment (default: None) | 
|  | 72 | +
 | 
|  | 73 | +optional arguments: | 
|  | 74 | +  --client_id   Client ID (default: mqtt5-sample-5873a450) | 
|  | 75 | +  --topic       Topic (default: test/topic) | 
|  | 76 | +  --message     Message payload (default: Hello from mqtt5 sample) | 
|  | 77 | +  --count       Messages to publish (0 = infinite) (default: 5) | 
|  | 78 | +``` | 
|  | 79 | + | 
|  | 80 | +The sample will not run without the required arguments and will notify you of missing arguments. | 
|  | 81 | + | 
|  | 82 | +### Enable Logging | 
|  | 83 | + | 
|  | 84 | +Instructions to enable logging are available in the [FAQ](../documents/FAQ.md) under [How do I enable logging](../documents/FAQ.md#how-do-i-enable-logging). | 
0 commit comments