summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9d1ee87)
raw | patch | inline | side by side (parent: 9d1ee87)
author | Tony Cave <t-cave@ti.com> | |
Fri, 10 Apr 2015 11:11:17 +0000 (11:11 +0000) | ||
committer | Tony Cave <t-cave@ti.com> | |
Fri, 10 Apr 2015 11:11:17 +0000 (11:11 +0000) |
diff --git a/hag-client/nwkmgr.js b/hag-client/nwkmgr.js
index 3b99449fc2f5890304b8764d28c04150d8d4f6c0..7c7367a2061dea3b1405055782169bb7daf8d8af 100755 (executable)
--- a/hag-client/nwkmgr.js
+++ b/hag-client/nwkmgr.js
case nwkmgr_pb.nwkMgrCmdId_t.NWK_ZIGBEE_DEVICE_IND:
var devInd = nwkmgr_pb.NwkZigbeeDeviceInd.decode(rx_pkt_buf.copy(PKT_HEADER_SIZE, rx_pkt_len).buffer);
- console.log("NWK_ZIGBEE_DEVICE_IND: ", devInd, " : ", nwkmgr_pb.nwkDeviceStatus_t.DEVICE_ON_LINE);
+ //console.log("NWK_ZIGBEE_DEVICE_IND: ", devInd, " : ", nwkmgr_pb.nwkDeviceStatus_t.DEVICE_ON_LINE);
//did it join the network
if(devInd.deviceInfo.deviceStatus === nwkmgr_pb.nwkDeviceStatus_t.DEVICE_ON_LINE)
{
}
}
}
+ else if(devInd.deviceInfo.deviceStatus === nwkmgr_pb.nwkDeviceStatus_t.DEVICE_REMOVED)
+ {
+ nwkmgrInstance.emit('removeDev', devInd.deviceInfo.ieeeAddress);
+ }
break;
case nwkmgr_pb.nwkMgrCmdId_t.NWK_GET_LOCAL_DEVICE_INFO_CNF:
index f8b1bacb4a2c70c83b3137b379d0ab333112d7c2..6833f46d296ae133da420cc97e115e75d3a581e0 100644 (file)
<body>
<!-- Home -->
<div data-role="page" id="page1" align="center">
- <div data-role="header" class="ui-header ui-bar-a" role="banner" style="max-width:600px; align:center;" >
+ <div data-role="header" class="ui-header ui-bar-a" role="banner" style="max-width:600px;" align="center">
<h1 class="ui-title" role="heading" aria-level="1">ZigBee IoT Meh Demo</h1>
<a href="#popupPanel" data-rel="popup" data-transition="slide" data-position-to="window" data-icon="bars" class="ui-btn-right ui-btn ui-shadow ui-btn-icon-right ui-btn-up-a" data-theme="a">
<span class="ui-btn-inner">
</select>
</div>
- </div>
- <div data-role="content" align="right">
<div data-role="popup" id="popupPanel" data-corners="false" data-theme="a" data-shadow="false">
- <a href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
+ <a id="backButton" href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
<a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">quickstartLink</a>
<button data-corners="false" data-theme="a" data-mini="false" id="removeDeviceButton">Remove Device</button>
<a href="#ProvisioningDialog" data-rel="popup" id="ProvisionDeviceButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Provision Device</a>
$("#removeDeviceButton").click(function() {
self.socket.emit('removeDevice', self.device.info.ieee);
+ $( "#popupPanel" ).popup( "close" );
+ window.location.href = 'http://' + location.host + '/'
});
+
+ $("#quickstartLink").click(function() {
+ $( "#popupPanel" ).popup( "close" );
+ });
+
+
</script>
index 0ec8a3204ff743ee8637e4aa86ec17ebe9ba0c51..9c92652186df2f2d2eb9283b289cd73d0f58757a 100644 (file)
</div>
<div data-role="popup" id="popupPanel" data-corners="false" data-theme="a" data-shadow="false">
- <a href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">Back</a>
- <a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">Quickstart Link</a>
- <a href="#reportIntervalDialog" data-rel="popup" id="setReportIntervalButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Set Report Interval</a>
+ <a id="backButton" href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
+ <a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">quickstartLink</a>
<button data-corners="false" data-theme="a" data-mini="false" id="removeDeviceButton">Remove Device</button>
<a href="#ProvisioningDialog" data-rel="popup" id="ProvisionDeviceButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Provision Device</a>
</div>
$("#removeDeviceButton").click(function() {
self.socket.emit('removeDevice', self.device.info.ieee);
- })
+ $( "#popupPanel" ).popup( "close" );
+ window.location.href = 'http://' + location.host + '/'
+ });
+
+ $("#quickstartLink").click(function() {
+ $( "#popupPanel" ).popup( "close" );
+ });
</script>
index 0e1d494fa7f1965109b29fd4c9b987d133101200..1c00e8008811b96180a024b64eb64ea912848218 100644 (file)
</div>
<div data-role="popup" id="popupPanel" data-corners="false" data-theme="a" data-shadow="false">
- <a href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
+ <a id="backButton" href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
<a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">quickstartLink</a>
<button data-corners="false" data-theme="a" data-mini="false" id="removeDeviceButton">Remove Device</button>
<a href="#ProvisioningDialog" data-rel="popup" id="ProvisionDeviceButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Provision Device</a>
$("#removeDeviceButton").click(function() {
self.socket.emit('removeDevice', self.device.info.ieee);
+ $( "#popupPanel" ).popup( "close" );
+ window.location.href = 'http://' + location.host + '/'
+ });
+
+ $("#quickstartLink").click(function() {
+ $( "#popupPanel" ).popup( "close" );
});
</script>
index 57adc9c13110f02dfe7a19ac775b1132470308f4..26e91e910bcabcd8f9a377a8ca9f1d9237e4d288 100644 (file)
</div>
<div data-role="popup" id="popupPanel" data-corners="false" data-theme="a" data-shadow="false">
- <a id="backbutton" href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">Back</a>
- <a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">Quickstart Link</a>
- <a href="#reportIntervalDialog" data-rel="popup" id="setReportIntervalButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Set Report Interval</a>
+ <a id="backButton" href="http://beaglebone.local:5000/" target=\"_top\" data-role="button" data-corners="false" data-theme="a">back</a>
+ <a id="quickstartLink" href="https://quickstart.internetofthings.ibmcloud.com/" target=\"_blank\" data-role="button" data-corners="false" data-theme="a" data-mini="false" id="quickstartLink">quickstartLink</a>
<button data-corners="false" data-theme="a" data-mini="false" id="removeDeviceButton">Remove Device</button>
<a href="#ProvisioningDialog" data-rel="popup" id="ProvisionDeviceButton" data-role="button" data-transition="pop" data-position-to="window" data-corners="false" data-mini="false">Provision Device</a>
</div>
$("#removeDeviceButton").click(function() {
self.socket.emit('removeDevice', self.device.info.ieee);
- })
+ $( "#popupPanel" ).popup( "close" );
+ window.location.href = 'http://' + location.host + '/'
+ });
+
+ $("#quickstartLink").click(function() {
+ $( "#popupPanel" ).popup( "close" );
+ });
</script>
diff --git a/zb-iot-agent.js b/zb-iot-agent.js
index 83196da2380c1a4748dfde262d38ce2e5910855b..1956687b00c56cf01d326bc09c1b739c97415d07 100755 (executable)
--- a/zb-iot-agent.js
+++ b/zb-iot-agent.js
}
self.devArray.push(data);
self.webserver.upDateDeviceList(self.devArray);
+ })
+ .on('removeDev', function(data) {
+ console.log("nwkmgr emitted removeDev: ", data);
+ //remove all devices with this ieee addr
+ for(var devIdx in self.devArray)
+ {
+ var ieeeBb = new ByteBuffer(8, ByteBuffer.LITTLE_ENDIAN)
+ .append(self.devArray[devIdx].info.ieee, "hex", 0);
+ var ieeeRemoveBb = new ByteBuffer(8, ByteBuffer.LITTLE_ENDIAN)
+ .append(data, "hex", 0);
+
+ console.log("searching[", devIdx, "]: ", ieeeRemoveBb.toString('hex'), ":", ieeeBb.toString('hex'), ":", ieeeRemoveBb.toString('hex').localeCompare(ieeeBb.toString('hex')));
+ if(ieeeRemoveBb.toString('hex').localeCompare(ieeeBb.toString('hex')) === 0)
+ {
+ console.log("zb-iot-agent: removing device");
+ var removeDevice = self.devArray.splice(devIdx, 1);
+ removeDevice[0].delete();
+ delete removeDevice[0];
+ //we just removed an array element, so reduce devIdx by 1;
+ devIdx = devIdx-1;
+ }
+ }
+ self.webserver.upDateDeviceList(self.devArray);
});
this.webserver.on('addDevice', function(data) {
console.log("searching[", devIdx, "]: ", ieeeRemoveBb.toString('hex'), ":", ieeeBb.toString('hex'), ":", ieeeRemoveBb.toString('hex').localeCompare(ieeeBb.toString('hex')));
if(ieeeRemoveBb.toString('hex').localeCompare(ieeeBb.toString('hex')) === 0)
- {
-
+ {
console.log("found: ", ieeeRemoveBb.buffer);
//only send network leave for 1 endpoint
if( found === false) {