index 2b9a26f5e04842149f828b1ce12672338f715dcb..40f8c2b686007be4e441b6589c01dabc3c67fa44 100755 (executable)
* 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
* 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){
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 */
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 */
});
/* 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);
});
*/
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);
}
/* create gateway */
-var gateway = new Gateway();
-
+var gateway = new Gateway();
\ No newline at end of file