|
1 |
| -## AWS IoT SDK for C++ v2 |
| 1 | +# AWS IoT SDK for C++ v2 |
2 | 2 |
|
3 |
| -Next generation AWS IoT Client SDK for C++ using the AWS Common Runtime |
| 3 | +Next generation AWS IoT Client SDK for C++. |
4 | 4 |
|
5 |
| -## License |
| 5 | +This project is in **DEVELOPER PREVIEW** while we gather feedback on |
| 6 | +interfaces and use cases. Please file issues and feature requests. |
| 7 | +Expect breaking API changes as we incorporate feedback. |
| 8 | +Until this project is promoted to General Availability, we advise you use the |
| 9 | +[previous SDK](https://github.com/aws/aws-iot-device-sdk-cpp) |
| 10 | +for a stable development environment. |
6 | 11 |
|
7 |
| -This library is licensed under the Apache 2.0 License. |
| 12 | +This SDK is built on the AWS Common Runtime, a collection of libraries |
| 13 | +([1](https://github.com/awslabs/aws-c-common), |
| 14 | +[2](https://github.com/awslabs/aws-c-io), |
| 15 | +[3](https://github.com/awslabs/aws-c-mqtt), ...) written in C to be |
| 16 | +cross-platform, high-performance, secure, and reliable. The libraries are bound |
| 17 | +to C++ by the [aws-crt-cpp](https://github.com/awslabs/aws-crt-cpp) package. |
| 18 | + |
| 19 | +Integration with AWS IoT Services such as |
| 20 | +[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) |
| 21 | +and [Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) |
| 22 | +is provided by code that been generated from a model of the service. |
| 23 | + |
| 24 | +# Installation |
| 25 | +## Minimum Requirements |
| 26 | +* C++ 11 or higher |
| 27 | +* CMake 3.1+ |
| 28 | +* Clang 3.9+ or GCC 4.4+ or MSVC 2015+ |
| 29 | + |
| 30 | +## Build from source |
| 31 | +``` |
| 32 | +git clone --branch v0.1.0 https://github.com/awslabs/aws-crt-cpp.git |
| 33 | +git clone https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git |
| 34 | +mkdir aws-crt-cpp-build |
| 35 | +cd aws-crt-cpp-build |
| 36 | +cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DCMAKE_PREFIX_PATH="<path to where you install>" -DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp |
| 37 | +<invoke build command make, msbuild, ninja etc....> install |
| 38 | +cd .. |
| 39 | +mkdir aws-iot-device-sdk-cpp-v2 |
| 40 | +cd aws-iot-device-sdk-cpp-v2 |
| 41 | +cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DCMAKE_PREFIX_PATH="<path to where you install>" -DBUILD_SHARED_LIBS=ON ../aws-iot-device-sdk-cpp-v2 |
| 42 | +<invoke build command make, msbuild, ninja etc....> install |
| 43 | +
|
| 44 | +``` |
| 45 | + |
| 46 | +# Samples |
| 47 | + |
| 48 | +## Shadow |
| 49 | + |
| 50 | +This sample uses the AWS IoT |
| 51 | +[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) |
| 52 | +Service to keep a property in |
| 53 | +sync between device and server. Imagine a light whose color may be changed |
| 54 | +through an app, or set by a local user. |
| 55 | + |
| 56 | +Once connected, type a value in the terminal and press Enter to update |
| 57 | +the property's "reported" value. The sample also responds when the "desired" |
| 58 | +value changes on the server. To observe this, edit the Shadow document in |
| 59 | +the AWS Console and set a new "desired" value. |
| 60 | + |
| 61 | +On startup, the sample requests the shadow document to learn the property's |
| 62 | +initial state. The sample also subscribes to "delta" events from the server, |
| 63 | +which are sent when a property's "desired" value differs from its "reported" |
| 64 | +value. When the sample learns of a new desired value, that value is changed |
| 65 | +on the device and an update is sent to the server with the new "reported" |
| 66 | +value. |
| 67 | + |
| 68 | +Source: `samples/shadow/shadow_sync` |
| 69 | + |
| 70 | +Your Thing's |
| 71 | +[Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) |
| 72 | +must provide privileges for this sample to connect, subscribe, publish, |
| 73 | +and receive. |
| 74 | + |
| 75 | +<details> |
| 76 | +<summary>(see sample policy)</summary> |
| 77 | +<pre> |
| 78 | +{ |
| 79 | + "Version": "2012-10-17", |
| 80 | + "Statement": [ |
| 81 | + { |
| 82 | + "Effect": "Allow", |
| 83 | + "Action": [ |
| 84 | + "iot:Publish" |
| 85 | + ], |
| 86 | + "Resource": [ |
| 87 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get", |
| 88 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update" |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "Effect": "Allow", |
| 93 | + "Action": [ |
| 94 | + "iot:Receive" |
| 95 | + ], |
| 96 | + "Resource": [ |
| 97 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get/accepted", |
| 98 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get/rejected", |
| 99 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/accepted", |
| 100 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/rejected", |
| 101 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/delta" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "Effect": "Allow", |
| 106 | + "Action": [ |
| 107 | + "iot:Subscribe" |
| 108 | + ], |
| 109 | + "Resource": [ |
| 110 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/get/accepted", |
| 111 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/get/rejected", |
| 112 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/accepted", |
| 113 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/rejected", |
| 114 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/delta" |
| 115 | + ] |
| 116 | + }, |
| 117 | + { |
| 118 | + "Effect": "Allow", |
| 119 | + "Action": "iot:Connect", |
| 120 | + "Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id" |
| 121 | + } |
| 122 | + ] |
| 123 | +} |
| 124 | +</pre> |
| 125 | +</details> |
| 126 | + |
| 127 | +## Jobs |
| 128 | + |
| 129 | +This sample uses the AWS IoT |
| 130 | +[Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) |
| 131 | +Service to describe jobs to execute. |
| 132 | + |
| 133 | +This sample requires you to create jobs for your device to execute. See |
| 134 | +[instructions here](https://docs.aws.amazon.com/iot/latest/developerguide/create-manage-jobs.html). |
| 135 | + |
| 136 | +On startup, the sample describes a job that is pending execution. |
| 137 | + |
| 138 | +Source: `samples/jobs/describe_job_execution` |
| 139 | + |
| 140 | +Your Thing's |
| 141 | +[Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) |
| 142 | +must provide privileges for this sample to connect, subscribe, publish, |
| 143 | +and receive. |
| 144 | +<details> |
| 145 | +<summary>(see sample policy)</summary> |
| 146 | +<pre> |
| 147 | +{ |
| 148 | + "Version": "2012-10-17", |
| 149 | + "Statement": [ |
| 150 | + { |
| 151 | + "Effect": "Allow", |
| 152 | + "Action": [ |
| 153 | + "iot:Publish" |
| 154 | + ], |
| 155 | + "Resource": [ |
| 156 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next", |
| 157 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update" |
| 158 | + ] |
| 159 | + }, |
| 160 | + { |
| 161 | + "Effect": "Allow", |
| 162 | + "Action": [ |
| 163 | + "iot:Receive" |
| 164 | + ], |
| 165 | + "Resource": [ |
| 166 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/notify-next", |
| 167 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next/accepted", |
| 168 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/start-next/rejected", |
| 169 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update/accepted", |
| 170 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/jobs/*/update/rejected" |
| 171 | + ] |
| 172 | + }, |
| 173 | + { |
| 174 | + "Effect": "Allow", |
| 175 | + "Action": [ |
| 176 | + "iot:Subscribe" |
| 177 | + ], |
| 178 | + "Resource": [ |
| 179 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/notify-next", |
| 180 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/start-next/accepted", |
| 181 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/start-next/rejected", |
| 182 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/*/update/accepted", |
| 183 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/jobs/*/update/rejected" |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "Effect": "Allow", |
| 188 | + "Action": "iot:Connect", |
| 189 | + "Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id" |
| 190 | + } |
| 191 | + ] |
| 192 | +} |
| 193 | +</pre> |
| 194 | +</details> |
| 195 | + |
| 196 | +# License |
| 197 | + |
| 198 | +This library is licensed under the Apache 2.0 License. |
0 commit comments