- Basic Pub-Sub
- Basic Connect
- Mqtt5 Pub-Sub
- Mqtt5 Shared Subscription
- Websocket Connect
- PKCS#11 Connect
- x509 Credentials Provider Connect
- Windows Certificate MQTT Connect
- Custom Authorizer Connect
- Cognito Connect
- Secure Tunnel
- Secure Tunnel Notification
- Shadow
- Jobs
- Fleet provisioning
- Greengrass discovery
- Greengrass IPC
- Device Defender
- Cycle Pub-Sub
Firstly, build and install aws-iot-devices-sdk-cpp-v2 with following instructions from Installation.
Change directory into one of the samples. Under the directory of the sample you wish to build, run the following commands:
cmake -B build -S . -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DCMAKE_BUILD_TYPE="<Release|RelWithDebInfo|Debug>" .
cmake --build build --config "<Release|RelWithDebInfo|Debug>"
For CMake versions that do not support the -B
command, go to the directory of the sample you wish to build and run the following commands:
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DCMAKE_BUILD_TYPE="<Release|RelWithDebInfo|Debug>" ..
cmake --build . --config "<Release|RelWithDebInfo|Debug>"
Change directory to the aws-iot-device-sdk-cpp-v2/samples
directory and then run the following commands:
cmake -B build -S . -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DCMAKE_BUILD_TYPE="<Release|RelWithDebInfo|Debug>" .
cmake --build build --config "<Release|RelWithDebInfo|Debug>"
This will compile all the samples at once and place the executables under the build
directory relative to their file path. To view the commands for a given sample, run the compiled program and pass --help
. For example, with the PubSub sample:
./build/pub_sub/basic_pub_sub/basic-pub-sub --help
This will compile all of the samples at once. You can then find the samples in the aws-iot-device-sdk-cpp-v2/samples/build
folder. For example, the PubSub sample will be located at aws-iot-device-sdk-cpp-v2/samples/build/pubsub/basic_pubsub
.
For CMake versions that do not support the -B
command, go to the aws-iot-device-sdk-cpp-v2/samples
directory and run the following commands:
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DCMAKE_BUILD_TYPE="<Release|RelWithDebInfo|Debug>" ..
cmake --build . --config "<Release|RelWithDebInfo|Debug>"
-
-DCMAKE_PREFIX_PATH
needs to be set to the path aws-iot-device-sdk-cpp-v2 installed at. Since Installation takessdk-cpp-workspace
as an example, this file uses that example too. -
-DCMAKE_BUILD_TYPE
and--config
needs to match theCMAKE_BUILD_TYPE
when aws-iot-device-sdk-cpp-v2 built.--config
is only REQUIRED for multi-configuration build tools.
All samples will show their options by passing in --help
. For example:
./build/basic-pub-sub --help
Which will result in output showing all of the options that can be passed in at the command line, along with descriptions of what each does and whether or not they are optional or not.
To enable logging in the samples, you can pass in --verbosity
, and optionally --log_file
, to the sample:
./build/basic-pub-sub --verbosity "Trace" --log_file "log.txt"
--verbosity
: The level of logging shown. Can beTrace
,Debug
,Info
,Warn
,Error
,Fatal
orNone
. Logging will not occur if this is not passed in withNone
or greater logging level.--log_file
: The filepath to store the logs at. This is optional, and if undefined the logs will be printed tostdout
instead.