Skip to content

Commit 97b0b46

Browse files
committed
Release of version 1.0.13
1 parent aaec88d commit 97b0b46

File tree

13 files changed

+797
-222
lines changed

13 files changed

+797
-222
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.0.13](https://github.com/aws/aws-iot-device-sdk-js/releases/tag/v1.0.13) (July 11, 2016)
2+
3+
Bugfixes/Improvements
4+
- Addressed pull request[#83](https://github.com/aws/aws-iot-device-sdk-js/pull/83) Credits given to [Torsph](https://github.com/Torsph)
5+
- Updated lifecycle events browser demo to read from DynamoDB table of connected clients if available
6+
- Addresses pull request [#60](https://github.com/aws/aws-iot-device-sdk-js/pull/60)
7+
- Fixes for GitHub issues [#66](https://github.com/aws/aws-iot-device-sdk-js/issues/66), [#61](https://github.com/aws/aws-iot-device-sdk-js/issues/61), [#53](https://github.com/aws/aws-iot-device-sdk-js/issues/53), [#48](https://github.com/aws/aws-iot-device-sdk-js/issues/48), and [#44](https://github.com/aws/aws-iot-device-sdk-js/issues/44).
8+
19
## [1.0.12](https://github.com/aws/aws-iot-device-sdk-js/releases/tag/v1.0.12) (April 19, 2016)
210

311
Features

README.md

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,12 @@ thingShadows.on('connect', function() {
130130
// After connecting to the AWS IoT platform, register interest in the
131131
// Thing Shadow named 'RGBLedLamp'.
132132
//
133-
thingShadows.register( 'RGBLedLamp' );
134-
//
135-
// 5 seconds after registering, update the Thing Shadow named
133+
thingShadows.register( 'RGBLedLamp', function() {
134+
135+
// Once registration is complete, update the Thing Shadow named
136136
// 'RGBLedLamp' with the latest device state and save the clientToken
137137
// so that we can correlate it with status or timeout events.
138138
//
139-
// Note that the delay is not required for subsequent updates; only
140-
// the first update after a Thing Shadow registration using default
141-
// parameters requires a delay. See API documentation for the update
142-
// method for more details.
143-
//
144-
setTimeout( function() {
145-
//
146139
// Thing shadow state
147140
//
148141
var rgbLedLampState = {"state":{"desired":{"red":rval,"green":gval,"blue":bval}}};
@@ -160,7 +153,6 @@ thingShadows.on('connect', function() {
160153
{
161154
console.log('update shadow failed, operation still in progress');
162155
}
163-
}, 5000 );
164156
});
165157

166158
thingShadows.on('status',
@@ -246,7 +238,9 @@ All certificates and keys must be in PEM format.
246238
247239
`options` also contains arguments specific to mqtt. See [the mqtt client documentation]
248240
(https://github.com/mqttjs/MQTT.js/blob/master/README.md#client) for details
249-
of these arguments.
241+
of these arguments. Note, AWS IoT doesn't support retained messages; setting `retain` flag to
242+
'true' for message publishing, including Last Will and Testament messages, will result in
243+
connection termination. For AWS IoT protocol specifics, please visit [here](http://docs.aws.amazon.com/iot/latest/developerguide/protocols.html).
250244
251245
Supports all events emitted by the [mqtt.Client()](https://github.com/mqttjs/MQTT.js/blob/master/README.md#client) class.
252246
@@ -333,7 +327,7 @@ from each operation.
333327
334328
-------------------------------------------------------
335329
<a name="register"></a>
336-
### awsIot.thingShadow#register(thingName, [options] )
330+
### awsIot.thingShadow#register(thingName, [options], [callback] )
337331
338332
Register interest in the Thing Shadow named `thingName`. The thingShadow class will
339333
subscribe to any applicable topics, and will fire events for the Thing Shadow
@@ -364,6 +358,8 @@ AWS IoT maintains version numbers for each shadow, and will reject operations wh
364358
contain the incorrect version; in applications where multiple clients update the same
365359
shadow, clients can use versioning to avoid overwriting each other's changes.
366360
361+
If the `callback` parameter is provided, it will be invoked after registration is complete (i.e., when subscription ACKs have been received for all shadow topics). Applications should wait until shadow registration is complete before performing update/get/delete operations.
362+
367363
-------------------------------------------------------
368364
<a name="unregister"></a>
369365
### awsIot.thingShadow#unregister(thingName)
@@ -447,7 +443,7 @@ connection used to access Thing Shadows.
447443
448444
-------------------------------------------------------
449445
<a name="unsubscribe"></a>
450-
### awsIot.thingShadow#unsubscribe(topic, [options], [callback])
446+
### awsIot.thingShadow#unsubscribe(topic, [callback])
451447
452448
Identical to the [mqtt.Client#unsubscribe()](https://github.com/mqttjs/MQTT.js/blob/master/README.md#unsubscribe)
453449
method, with the restriction that the topic may not represent a Thing Shadow.
@@ -811,6 +807,8 @@ This SDK includes a utility script called `scripts/browserize.sh`. This script
811807
812808
This command will create a browser bundle in `browser/aws-iot-sdk-browser-bundle.js`. The browser bundle makes both the `aws-sdk` and `aws-iot-device-sdk` modules available so that you can `require` them from your browserified application bundle.
813809
810+
**IMPORTANT:** The `scripts/browserize.sh` script requires npm version 3. You can check which version of npm you have installed with `npm -v`.
811+
814812
#### Creating Application Bundles
815813
You can also use the `scripts/browserize.sh` script to browserify your own applications and use them with the AWS SDK browser bundle. For example, to prepare the [temperature-monitor](#temperature-monitor-browser-example) browser example application for use, run this command in the SDK's top-level directory:
816814
@@ -864,6 +862,7 @@ This SDK includes a browser application which demonstrates the functionality of
864862
865863
1. Open `examples/browser/lifecycle/index.html` in your web browser. After connecting to AWS IoT, it should display 'connected clients'.
866864
1. Start programs which connect to AWS IoT (e.g., [the example programs in this package](#programs)). Make sure that these programs are connecting to the same AWS region that your Cognito Identity Pool was created in. The browser application will display a green box containing the client ID of each client which connects; when the client disconnects, the box will disappear.
865+
1. If a DynamoDB table named `LifecycleEvents` exists in your account and has a primary key named `clientId`, the lifecycle event browser monitor browser application will display the client ID contained in each row. By updating this table using an [AWS IoT rule](http://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html) triggered by [lifecycle events](http://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html), you can maintain a persistent list of all of the currently connected clients within your account.
867866
868867
<a name="mqtt-explorer-browser-example"></a>
869868
### MQTT Explorer Browser Example Application
@@ -880,8 +879,54 @@ This SDK includes a browser application which implements a simple interactive MQ
880879
881880
1. Open `examples/browser/mqtt-explorer/index.html` in your web browser. After connecting to AWS IoT, it should display input fields allowing you to subscribe or publish to a topic. By subscribing to '#', for example, you will be able to monitor all traffic within your AWS account as allowed by the policy associated with the unauthenticated role of your Cognito Identity Pool.
882881
883-
### Optimizations
884-
If you're writing a browser application based on the examples in this SDK, you might consider creating a smaller version of the AWS SDK for JavaScript using [the AWS SDK for JavaScript Custom Builder](https://sdk.amazonaws.com/builder/js/). This tool allows you to create a version containing only the pieces of the SDK that you need (e.g., Cognito Identity), helping to reduce the size of the SDK bundle. There are also tools available for reducing the size of JavaScript application bundles (e.g. [UglifyJS](https://github.com/mishoo/UglifyJS2)), but the `browserize.sh` script does not yet make use of them; bundle optimizations are left up to the user.
882+
### Reducing Browser Bundle Size
883+
After your application development is complete, you will probably want to reduce the size of the browser bundle. There are a couple of easy techniques to do this, and by combining both of them you can create much smaller browser bundles.
884+
885+
#### Eliminate unused features from the AWS SDK
886+
887+
1. The [AWS SDK for JavaScript](https://github.com/aws/aws-sdk-js) allows you to install only the features you use in your application. In order to use this feature when preparing a browser bundle, first you'll need to remove any existing bundle that you've already created:
888+
889+
```sh
890+
rm browser/aws-iot-sdk-browser-bundle.js
891+
```
892+
893+
2. Define the AWS features your application uses as a comma-separated list in the `AWS_SERVICES` environment variable. For example, the [MQTT Explorer example](#mqtt-explorer-browser-example) uses only AWS Cognito Identity, so to create a bundle containing only this feature, do:
894+
895+
```sh
896+
export AWS_SERVICES=cognitoidentity
897+
```
898+
For a list of the AWS SDK feature names, refer to the [_features subdirectory_ of the AWS SDK for JavaScript](https://github.com/aws/aws-sdk-js/tree/master/features). As another example, if your application uses Cognito Identity, DynamoDB, S3, and SQS, you would do:
899+
900+
```sh
901+
export AWS_SERVICES=cognitoidentity,dynamodb,s3,sqs
902+
```
903+
904+
3. Create the browser app and bundle, e.g. for the [MQTT Explorer example](#mqtt-explorer-browser-example), do:
905+
906+
```sh
907+
npm run-script browserize examples/browser/mqtt-explorer/index.js
908+
```
909+
910+
#### Uglify the bundle source
911+
912+
[Uglify](https://www.npmjs.com/package/uglify) is an npm utility for minimizing the size of JavaScript source files. To use it, first install it as a global npm package:
913+
914+
```sh
915+
npm install -g uglify
916+
```
917+
918+
Once installed, you can use it to reduce the bundle size:
919+
920+
```sh
921+
uglify -s ./browser/aws-iot-sdk-browser-bundle.js -o ./browser/aws-iot-sdk-browser-bundle-min.js
922+
```
923+
After you've created the minimized bundle, you'll need to make sure that your application loads this version rather than the non-minimized version, e.g:
924+
925+
```html
926+
<script src="aws-iot-sdk-browser-bundle-min.js"></script>
927+
```
928+
#### Optimization results
929+
By using both of the above techniques for the [MQTT Explorer example](#mqtt-explorer-browser-example), the bundle size can be reduced from 2.4MB to 615KB.
885930
886931
<a name="troubleshooting"></a>
887932
## Troubleshooting
@@ -900,6 +945,7 @@ specify a client ID, the example programs will generate random client IDs,
900945
but if you are using a [JSON configuration file](#configurationFile), you'll
901946
need to explictly specify client IDs for both programs using the '-i' command
902947
line option.
948+
* _Invalid NPM Version_: To run the browserize.sh script which prepares the browser example applications, you'll need to use npm version 3. This is because browserize.sh expects package dependencies to be handled using the npm version 3 strategy, which is [different than the strategy used in npm version 2](https://docs.npmjs.com/how-npm-works/npm3). If you're having trouble running the browser application examples, make sure that you're using npm version 3. You can check your npm version with `npm -v`.
903949
904950
<a name="unittests"></a>
905951
## Unit Tests

0 commit comments

Comments
 (0)