Syntax update to support different versions of Node
authorJason Reeder <jreeder@ti.com>
Fri, 16 Dec 2016 19:20:16 +0000 (13:20 -0600)
committerJason Reeder <jreeder@ti.com>
Fri, 16 Dec 2016 19:20:16 +0000 (13:20 -0600)
Some of the community distributions of Linux on the
BeagleBone Black include an older version of Node than the
Linux Processor SDK. It was found that the original syntax
for the AWS Thing Shadow update used in this package did
not work with the older version of Node.

This commit changes the syntax so that the demo will run on
both the TI Linux Processor SDK version of Node as well as
the BeagleBoard community version of Node.

Signed-off-by: Jason Reeder <jreeder@ti.com>
example/iot-gateway/cloudAdapter/awsCloudAdapter.js
prebuilt/iot-gateway/cloudAdapter/awsCloudAdapter.js

index ff7e4edc3e0938e6437fdbc670fd878f81e4dfc9..4bdd0858b7820250eebcb9143c9762c88807c547 100644 (file)
@@ -164,19 +164,18 @@ function AwsCloudAdapter() {
                }
                nwkInfo.devices = devices.slice();
 
-               var reported = nwkInfo;
                var nwkInfoThing = 'ti_iot_' + nwkInfo.ext_addr + '_network';
                /* If the network thing isn't registered yet, then register it before sending the update */
                if (awsCloudAdapterInstance.registered[nwkInfoThing] != 1) {
                        thingShadows.register(nwkInfoThing, { ignoreDeltas : false, persistentSubscribe : false });
                        /* Amazon requires a delay between Thing registration and its first update */
                        setTimeout (function() {
-                               thingShadows['update'](nwkInfoThing, { state : { reported }});
+                               thingShadows['update'](nwkInfoThing, { state : { reported : nwkInfo }});
                        }, 5000);
                        awsCloudAdapterInstance.registered[nwkInfoThing] = 1;
                }
                else {
-                       thingShadows['update'](nwkInfoThing, { state : { reported }});
+                       thingShadows['update'](nwkInfoThing, { state : { reported : nwkInfo }});
                }
        }
 
@@ -186,20 +185,19 @@ function AwsCloudAdapter() {
                }
                
                var devInfoThing = 'ti_iot_' + nwkExtAddr + '_' + devInfo.ext_addr;
-               var reported = devInfo;
                /* If the device thing ins't registered yet, then register it before sending the update */
                if (awsCloudAdapterInstance.registered[devInfoThing] != 1) {
                        thingShadows.register(devInfoThing, { ignoreDeltas : false, persistentSubscribe : false });
                        /* Amazon requires a delay between Thing registration and its first update */
                        setTimeout (function() {
                                /* Set desired to null in order to remove any toggleLED requests */
-                               thingShadows['update'](devInfoThing, { state : { desired: null, reported }});
+                               thingShadows['update'](devInfoThing, { state : { desired : null, reported : devInfo }});
                        }, 5000);
                        awsCloudAdapterInstance.registered[devInfoThing] = 1;
                }       
                else {
                        /* Set desired to null in order to remove any toggleLED requests */
-                       thingShadows['update'](devInfoThing, { state : { desired: null, reported }});
+                       thingShadows['update'](devInfoThing, { state : { desired : null, reported : devInfo }});
                }
        }
 }
index ff7e4edc3e0938e6437fdbc670fd878f81e4dfc9..4bdd0858b7820250eebcb9143c9762c88807c547 100644 (file)
@@ -164,19 +164,18 @@ function AwsCloudAdapter() {
                }
                nwkInfo.devices = devices.slice();
 
-               var reported = nwkInfo;
                var nwkInfoThing = 'ti_iot_' + nwkInfo.ext_addr + '_network';
                /* If the network thing isn't registered yet, then register it before sending the update */
                if (awsCloudAdapterInstance.registered[nwkInfoThing] != 1) {
                        thingShadows.register(nwkInfoThing, { ignoreDeltas : false, persistentSubscribe : false });
                        /* Amazon requires a delay between Thing registration and its first update */
                        setTimeout (function() {
-                               thingShadows['update'](nwkInfoThing, { state : { reported }});
+                               thingShadows['update'](nwkInfoThing, { state : { reported : nwkInfo }});
                        }, 5000);
                        awsCloudAdapterInstance.registered[nwkInfoThing] = 1;
                }
                else {
-                       thingShadows['update'](nwkInfoThing, { state : { reported }});
+                       thingShadows['update'](nwkInfoThing, { state : { reported : nwkInfo }});
                }
        }
 
@@ -186,20 +185,19 @@ function AwsCloudAdapter() {
                }
                
                var devInfoThing = 'ti_iot_' + nwkExtAddr + '_' + devInfo.ext_addr;
-               var reported = devInfo;
                /* If the device thing ins't registered yet, then register it before sending the update */
                if (awsCloudAdapterInstance.registered[devInfoThing] != 1) {
                        thingShadows.register(devInfoThing, { ignoreDeltas : false, persistentSubscribe : false });
                        /* Amazon requires a delay between Thing registration and its first update */
                        setTimeout (function() {
                                /* Set desired to null in order to remove any toggleLED requests */
-                               thingShadows['update'](devInfoThing, { state : { desired: null, reported }});
+                               thingShadows['update'](devInfoThing, { state : { desired : null, reported : devInfo }});
                        }, 5000);
                        awsCloudAdapterInstance.registered[devInfoThing] = 1;
                }       
                else {
                        /* Set desired to null in order to remove any toggleLED requests */
-                       thingShadows['update'](devInfoThing, { state : { desired: null, reported }});
+                       thingShadows['update'](devInfoThing, { state : { desired : null, reported : devInfo }});
                }
        }
 }