-
Notifications
You must be signed in to change notification settings - Fork 222
README #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
README #6
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,169 @@ | ||
## AWS IoT SDK for Python v2 | ||
# AWS IoT SDK for Python v2 | ||
|
||
Next generation AWS IoT Client SDK for Python using the AWS Common Runtime | ||
Next generation AWS IoT Client SDK for Python. | ||
|
||
## License | ||
This SDK is built on the AWS Common Runtime, a collection of libraries | ||
([1](https://github.com/awslabs/aws-c-common), | ||
[2](https://github.com/awslabs/aws-c-io), | ||
[3](https://github.com/awslabs/aws-c-mqtt), ...) written in C to be | ||
cross-platform, high-performance, secure, and reliable. The libraries are bound | ||
to Python by the [awscrt](https://github.com/awslabs/aws-crt-python) package. | ||
|
||
This library is licensed under the Apache 2.0 License. | ||
Integration with AWS IoT Services such as | ||
[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) | ||
and [Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) | ||
is provided by code that been generated from a model of the service. | ||
|
||
# Installation | ||
## Minimum Requirements | ||
* Python 3.5+ or Python 2.7+ | ||
* CMake 3.1+ | ||
* Clang 3.9+ or GCC 4.4+ or MSVC 2015+ | ||
|
||
## Build from source | ||
``` | ||
git clone https://github.com/awslabs/aws-crt-python.git | ||
git clone https://github.com/awslabs/aws-iot-device-sdk-python-v2.git | ||
pip install ./aws-crt-python | ||
pip install ./aws-iot-device-sdk-python-v2 | ||
``` | ||
|
||
# Samples | ||
|
||
## pubsub | ||
This sample uses the Message Broker for AWS IoT to send and receive messages | ||
through an MQTT connection. On startup, the device connects to the server, | ||
subscribes to a topic, and begins publishing messages to that topic. | ||
The device should receive those same messages back from the message broker, | ||
since it is subscribed to that same topic. | ||
Status updates are continually printed to the console. | ||
|
||
Source: `samples/pubsub.py` | ||
|
||
Run the sample like this: | ||
``` | ||
python pubsub.py --endpoint <endpoint> --root-ca <file> --cert <file> --key <file> | ||
``` | ||
|
||
Your Thing's | ||
[Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) | ||
must provide priveleges for this sample to connect, subscribe, publish, | ||
graebm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
and receive. The Policy document should look something like this: | ||
|
||
<pre> | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Publish", | ||
"iot:Receive" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/samples/test" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Subscribe" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/samples/test" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Connect" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id" | ||
] | ||
} | ||
] | ||
} | ||
</pre> | ||
|
||
## shadow | ||
|
||
This sample uses the AWS IoT Device Shadow Service to keep a property in | ||
sync between device and server. Imagine a light whose color may be changed | ||
through an app, or set by a local user. | ||
|
||
Once connected, type a value in the terminal and press Enter to update | ||
the property's "reported" value. The sample also responds when the "desired" | ||
value changes on the server. To observe this, edit the Shadow document in | ||
the AWS Console and set a new "desired" value. | ||
|
||
On startup, the sample requests the shadow document to learn the property's | ||
initial state. The sample also subscribes to "delta" events from the server, | ||
which are sent when a property's "desired" value differs from its "reported" | ||
value. When the sample learns of a new desired value, that value is changed | ||
on the device and an update is sent to the server with the new "reported" | ||
value. | ||
|
||
Source: `samples/shadow.py` | ||
|
||
Run the sample like this: | ||
``` | ||
python shadow.py --endpoint <endpoint> --root-ca <file> --cert <file> --key <file> --thing-name <name> | ||
``` | ||
|
||
Your Thing's | ||
[Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) | ||
must provide priveleges for this sample to connect, publish, and subscribe. | ||
The Policy document should look something like this: | ||
|
||
<pre> | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Publish" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Receive" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get/accepted", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/get/rejected", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/accepted", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/rejected", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/$aws/things/<b>thingname</b>/shadow/update/delta" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"iot:Subscribe" | ||
], | ||
"Resource": [ | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/get/accepted", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/get/rejected", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/accepted", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/rejected", | ||
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/$aws/things/<b>thingname</b>/shadow/update/delta" | ||
] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": "iot:Connect", | ||
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id" | ||
} | ||
] | ||
} | ||
</pre> | ||
# License | ||
|
||
This library is licensed under the Apache 2.0 License. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.