]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blobdiff - example/iot-gateway/iot-gateway.js
Updated TI Linux Sensor To Cloud to the latest TI 15.4-Stack v2.4, now with CC13x2...
[apps/tidep0084.git] / example / iot-gateway / iot-gateway.js
index 2b9a26f5e04842149f828b1ce12672338f715dcb..40f8c2b686007be4e441b6589c01dabc3c67fa44 100755 (executable)
@@ -100,7 +100,6 @@ function Gateway() {
         * Network Information Message Type to the Cloud
         */
        var gotNwkUpdate = false;
-       var gotDevArray = false;
 
        /* This functions checks every second to see if we've got the
         * network and device information we need and also checks if we are
@@ -109,7 +108,7 @@ function Gateway() {
         * then clear the interval so the function won't repeat.
         */
        var intervalID = setInterval( function() {
-               if (cloudAdapter.connected && gotNwkUpdate && gotDevArray){
+               if (cloudAdapter.connected && gotNwkUpdate){
                        var nwkInfo = formatNwkInfoMsg(appClient.nwkInfo, appClient.connectedDeviceList);
                        cloudAdapter.cloudAdapter_sendNetworkInfoMsg(nwkInfo);
                        if (isAws){
@@ -128,11 +127,9 @@ function Gateway() {
                appClient.appC_setPermitJoin(data);
        });
 
-       /* Allows the Cloud to sent toggleLED messages to devices in the wireless network */
+       /* Allows the Cloud to sent actuation messages to devices in the wireless network */
        cloudAdapter.on('deviceActuation', function (data) {
-               console.log("deviceActuation");
-               console.log(data);
-               appClient.appC_sendToggle(data);
+               appClient.appC_sendDeviceActuation(data);
        });
 
        /* rcvd send config req */
@@ -141,18 +138,6 @@ function Gateway() {
                appClient.appC_sendConfig(data);
        });
 
-       /* rcvd send toggle req */
-       cloudAdapter.on('sendToggle', function (data) {
-               /* send toggle request */
-               appClient.appC_sendToggle(data);
-       });
-
-       /* rcvd getDevArray Req */
-       cloudAdapter.on('getDevArrayReq', function (data) {
-               /* process the request */
-               appClient.appC_getDeviceArray();
-       });
-
        /* rcvd getNwkInfoReq */
        cloudAdapter.on('getNwkInfoReq', function (data) {
                /* process the request */
@@ -178,16 +163,10 @@ function Gateway() {
        });
 
        /* Send Network Information Message to Cloud Adapter */
-       appClient.on('nwkUpdate', function () {
+       appClient.on('nwkInfo', function () {
                gotNwkUpdate = true;
                var nwkInfo = formatNwkInfoMsg(appClient.nwkInfo, appClient.connectedDeviceList);
-               cloudAdapter.cloudAdapter_sendNetworkInfoMsg(nwkInfo);
-       });
-
-       /* Send Network Information Message to Cloud Adapter */
-       appClient.on('getdevArrayRsp', function () {
-               gotDevArray = true;
-               var nwkInfo = formatNwkInfoMsg(appClient.nwkInfo, appClient.connectedDeviceList);
+               console.log("nwkInfo:", nwkInfo);
                cloudAdapter.cloudAdapter_sendNetworkInfoMsg(nwkInfo);
        });
 
@@ -197,6 +176,11 @@ function Gateway() {
         */
        function formatNwkInfoMsg(nwkInfo, conDevs) {
                var devices = [];
+               if (nwkInfo == null || conDevs == null)
+               {
+                       console.log("formatNwkInfoMsg: invalid parameters");
+                       return null;
+               }       
                var nwkAddress = '0x' + nwkInfo.panCoord.extAddress.toString(16);
                for(i = 0; i < conDevs.length; i++) {
                        var short_addr = '0x' + conDevs[i].shortAddress.toString(16);
@@ -250,5 +234,4 @@ function Gateway() {
 }
 
 /* create gateway */
-var gateway = new Gateway();
-
+var gateway = new Gateway();
\ No newline at end of file