Skip to content

Commit c1d527b

Browse files
authored
Improve FAQ (#837)
* add faq about build external deps * minior format changes * clean up faq * add submodules notes * update error code section * update section title
1 parent 9f97982 commit c1d527b

File tree

3 files changed

+61
-477
lines changed

3 files changed

+61
-477
lines changed

documents/FAQ.md

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
*__Jump To:__*
44
* [Where should I start](#where-should-i-start)
55
* [How do I enable logging](#how-do-i-enable-logging)
6+
* [How do I get more information from an error code?](#how-do-i-get-more-information-from-an-error-code)
67
* [I keep getting AWS_ERROR_MQTT_UNEXPECTED_HANGUP](#i-keep-getting-aws_error_mqtt_unexpected_hangup)
78
* [Dependencies are bad](#dependencies-are-bad)
89
* [Detecting connection loss (tldr use keepAliveTimeSecs and pingTimeoutMs)](#connection-loss)
910
* [How to use a Pre-Built aws-crt-cpp (Most useful for development of this package)](#prebuilt-aws-crt-cpp)
11+
* [How to use USE_EXTERNAL_DEPS_SOURCES to build with external dependencies](#use-external-deps-source)
1012
* [I am experiencing deadlocks](#i-am-experiencing-deadlocks)
11-
* [How do debug in VSCode?](#how-do-debug-in-vscode)
13+
* [How to debug in VSCode?](#how-to-debug-in-vscode)
1214
* [What certificates do I need?](#what-certificates-do-i-need)
1315
* [Where can I find MQTT 311 Samples?](#where-can-i-find-mqtt-311-samples)
1416
* [I still have more questions about this sdk?](#i-still-have-more-questions-about-this-sdk)
1517

1618
### Where should I start?
1719

18-
If you are just getting started make sure you [install this sdk](https://github.com/aws/aws-iot-device-sdk-cpp-v2#installation) and then build and run the [basic PubSub](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/main/samples#basic-mqtt-pub-sub)
20+
If you are just getting started, make sure you [install this SDK](https://github.com/aws/aws-iot-device-sdk-cpp-v2#installation) and then build and run the [X509 PubSub](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/main/samples/mqtt/mqtt5_x509) sample.
1921

2022
### How do I enable logging?
2123

@@ -28,11 +30,23 @@ apiHandle.InitializeLogging(Aws::Crt::LogLevel::Debug, stderr);
2830

2931
**LogLevel**: LogLevel has the following options: `Trace`, `Debug`, `Info`, `Warn`, `Error`, `Fatal`, or `None`. Defaults to `Warn`.
3032

31-
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.
33+
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.
34+
35+
### How do I get more information from an error code?
36+
37+
When you encounter error codes in the SDK, you can use `ErrorDebugString()` to get a human-readable error message:
38+
39+
``` c++
40+
#include <aws/crt/Api.h>
41+
42+
printf("Error occurred: %s\n", ErrorDebugString(LastError()));
43+
```
44+
45+
This function converts error codes into descriptive strings that help identify the specific issue.
3246
3347
### I keep getting AWS_ERROR_MQTT_UNEXPECTED_HANGUP
3448
35-
This could be many different things but it most likely is a policy issue. Start with using a super permissive IAM policy called AWSIOTFullAccess which looks like this:
49+
This could be many different things, but it is most likely a policy issue. Start by using a super permissive IAM policy called AWSIOTFullAccess which looks like this:
3650
3751
``` json
3852
{
@@ -52,8 +66,8 @@ This could be many different things but it most likely is a policy issue. Start
5266
After getting it working make sure to only allow the actions and resources that you need. More info about IoT IAM policies can be found [here](https://docs.aws.amazon.com/iot/latest/developerguide/security_iam_service-with-iam.html).
5367

5468

55-
### Dependencies are bad.
56-
If you get the following Error:
69+
### Dependencies are bad
70+
If you get the following error:
5771
```
5872
CMake Error at CMakeLists.txt:46 (include):
5973
include could not find load file:
@@ -76,20 +90,53 @@ There are 3 mechanisms for detecting connection loss:
7690

7791
### How to use a Pre-Built aws-crt-cpp (Most useful for development of this package) <a name="prebuilt-aws-crt-cpp"></a>
7892

93+
Turning off the `BUILD_DEPS` option allows you to use your own pre-built AWS CRT dependencies instead of the bundled submodules. This is useful when you want to share dependencies across multiple projects (for example, sharing the aws-crt-cpp dependency with aws-sdk-cpp).
94+
7995
``` sh
8096
mkdir aws-iot-device-sdk-cpp-v2-build
8197
cd aws-iot-device-sdk-cpp-v2-build
8298
cmake -DCMAKE_INSTALL_PREFIX="<absolute path sdk-cpp-workspace dir>" -DCMAKE_PREFIX_PATH="<absolute path sdk-cpp-workspace dir>" -DBUILD_DEPS=OFF ../aws-iot-device-sdk-cpp-v2
8399
cmake --build . --target install
84100
```
85101

102+
### How to use USE_EXTERNAL_DEPS_SOURCES to build with external dependencies <a name="use-external-deps-source"></a>
103+
104+
The `USE_EXTERNAL_DEPS_SOURCES` option allows you to use your own external source directories for AWS CRT dependencies instead of the bundled submodules.
105+
**Build Steps:**
106+
1. **Configure build options** - Update your CMakeLists.txt to set the required flags. Set `BUILD_DEPS` to `OFF` and `USE_EXTERNAL_DEPS_SOURCES` to `ON`:
107+
```cmake
108+
option(BUILD_DEPS "Builds aws common runtime dependencies as part of build. Turn off if you want to control your dependency chain." OFF)
109+
option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" ON)
110+
```
111+
112+
2. **Set up CMake module path** - The aws-crt-cpp library requires certain CMake modules that are defined in aws-c-common. Add it to your CMake modules:
113+
```cmake
114+
add_subdirectory(<path-to-aws-c-common>/aws-c-common <binary-dir>/aws-c-common)
115+
list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake")
116+
```
117+
118+
3. **Add required dependencies** - The following three dependencies are required as a minimum. You can also add other source dependencies as needed. Add them using `add_subdirectory` (or higher-level commands that use `add_subdirectory`, like `FetchContent`):
119+
- aws-c-common
120+
- aws-crt-cpp
121+
- aws-c-iot
122+
123+
```cmake
124+
add_subdirectory(<path-to-aws-c-common>/aws-c-common <binary-dir>/aws-c-common)
125+
add_subdirectory(<path-to-aws-crt-cpp>/aws-crt-cpp <binary-dir>/aws-crt-cpp)
126+
add_subdirectory(<path-to-aws-c-iot>/aws-c-iot <binary-dir>/aws-c-iot)
127+
```
128+
**Common Issues:**
129+
- **Missing submodules**: While using `FetchContent` or `ExternalProject_Add`, remember to set `GIT_SUBMODULES_RECURSE` to make sure the library pulls the submodules.
130+
131+
132+
86133
### I am experiencing deadlocks
87134
88135
You MUST NOT perform blocking operations on any callback, or you will cause a deadlock. For example: in the on_publish_received callback, do not send a publish, and then wait for the future to complete within the callback. The Client cannot do work until your callback returns, so the thread will be stuck.
89136
90-
### How do debug in VSCode?
137+
### How to debug in VSCode?
91138
92-
Here is an example launch.json file to run the pubsub sample
139+
Here is an example launch.json file to run the x509 pubsub sample:
93140
``` json
94141
{
95142
// Use IntelliSense to learn about possible attributes.
@@ -98,15 +145,14 @@ Here is an example launch.json file to run the pubsub sample
98145
"version": "0.2.0",
99146
"configurations": [
100147
{
101-
"name": "PubSub",
148+
"name": "X509 PubSub",
102149
"type": "cppdbg",
103150
"request": "launch",
104-
"program": "${workspaceFolder}/samples/pub_sub/basic_pub_sub/build/basic-pub-sub",
151+
"program": "${workspaceFolder}/samples/mqtt/mqtt5_x509/build/mqtt5_x509",
105152
"args": [
106153
"--endpoint", "<account-number>-ats.iot.<region>.amazonaws.com",
107154
"--cert", "<path to cert>",
108-
"--key", "<path to key>",
109-
"--client-id", "test-client"
155+
"--key", "<path to key>"
110156
]
111157
}
112158
]
@@ -127,10 +173,10 @@ Here is an example launch.json file to run the pubsub sample
127173
* You should have generated/downloaded private and public keys that will be used to verify that communications are coming from you
128174
* When using samples you only need the private key and it will look like this: `--key abcde12345-private.pem.key`
129175

130-
### Where can I find MQTT 311 Samples?
131-
The MQTT 311 Samples can be found in the v1.40.0 samples folder [here](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/v1.40.0/samples)
176+
### Where can I find MQTT 3.1.1 Samples?
177+
The MQTT 3.1.1 samples can be found in the v1.40.0 samples folder [here](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/v1.40.0/samples)
132178

133-
### I still have more questions about this sdk?
179+
### I still have more questions about this SDK?
134180

135181
* [Here](https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html) are the AWS IoT Core docs for more details about IoT Core
136182
* [Here](https://docs.aws.amazon.com/greengrass/v2/developerguide/what-is-iot-greengrass.html) are the AWS IoT Greengrass v2 docs for more details about greengrass

0 commit comments

Comments
 (0)