|
1 | | -## AWS IoT SDK for Node.js v2 |
| 1 | +# AWS IoT SDK for Javascript v2 |
2 | 2 |
|
3 | | -Next generation AWS IoT Client SDK for Node.js using the AWS Common Runtime |
| 3 | +Next generation AWS IoT Client SDK for Javascript. |
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-js) |
| 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), |
| 16 | +[4](https://github.com/awslabs/aws-c-http), |
| 17 | +[5](https://github.com/awslabs/aws-c-cal) ...) written in C to be |
| 18 | +cross-platform, high-performance, secure, and reliable. The libraries are bound |
| 19 | +to JS by the [awscrt](https://github.com/awslabs/aws-crt-nodejs) package. |
| 20 | + |
| 21 | +The aws-crt package can be installed via npm |
| 22 | +``` |
| 23 | +npm install aws-crt |
| 24 | +``` |
| 25 | + |
| 26 | +Integration with AWS IoT Services such as |
| 27 | +[Device Shadow](https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html) |
| 28 | +and [Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html) |
| 29 | +is provided by code that been generated from a model of the service. |
| 30 | + |
| 31 | +# Installation |
| 32 | +## Minimum Requirements |
| 33 | +* Node 10.x+ |
| 34 | + |
| 35 | +## Install from npm |
| 36 | +``` |
| 37 | +npm install aws-iot-device-sdk-v2 |
| 38 | +``` |
| 39 | + |
| 40 | +## Build from source |
| 41 | +``` |
| 42 | +npm install |
| 43 | +``` |
| 44 | + |
| 45 | +# Samples |
| 46 | + |
| 47 | +## node/pub_sub |
| 48 | +This sample uses the |
| 49 | +[Message Broker](https://docs.aws.amazon.com/iot/latest/developerguide/iot-message-broker.html) |
| 50 | +for AWS IoT to send and receive messages |
| 51 | +through an MQTT connection. On startup, the device connects to the server, |
| 52 | +subscribes to a topic, and begins publishing messages to that topic. |
| 53 | +The device should receive those same messages back from the message broker, |
| 54 | +since it is subscribed to that same topic. |
| 55 | +Status updates are continually printed to the console. |
| 56 | + |
| 57 | +Source: `samples/node/pub_sub` |
| 58 | + |
| 59 | +Run the sample like this: |
| 60 | +``` |
| 61 | +npm install |
| 62 | +node dist/index.js --endpoint <endpoint> --root-ca <file> --cert <file> --key <file> |
| 63 | +``` |
| 64 | + |
| 65 | +Your Thing's |
| 66 | +[Policy](https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html) |
| 67 | +must provide privileges for this sample to connect, subscribe, publish, |
| 68 | +and receive. |
| 69 | +<details> |
| 70 | +<summary>(see sample policy)</summary> |
| 71 | +<pre> |
| 72 | +{ |
| 73 | + "Version": "2012-10-17", |
| 74 | + "Statement": [ |
| 75 | + { |
| 76 | + "Effect": "Allow", |
| 77 | + "Action": [ |
| 78 | + "iot:Publish", |
| 79 | + "iot:Receive" |
| 80 | + ], |
| 81 | + "Resource": [ |
| 82 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topic/samples/test" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "Effect": "Allow", |
| 87 | + "Action": [ |
| 88 | + "iot:Subscribe" |
| 89 | + ], |
| 90 | + "Resource": [ |
| 91 | + "arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/samples/test" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "Effect": "Allow", |
| 96 | + "Action": [ |
| 97 | + "iot:Connect" |
| 98 | + ], |
| 99 | + "Resource": [ |
| 100 | + "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id" |
| 101 | + ] |
| 102 | + } |
| 103 | + ] |
| 104 | +} |
| 105 | +</pre> |
| 106 | +</details> |
| 107 | + |
| 108 | +## node/basic_discovery |
| 109 | + |
| 110 | +This sample intended for use directly with the |
| 111 | +[Getting Started with AWS IoT Greengrass](https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-gs.html) guide. |
| 112 | + |
| 113 | +# License |
| 114 | + |
| 115 | +This library is licensed under the Apache 2.0 License. |
0 commit comments