27
27
import com .zsmartsystems .zigbee .database .ZigBeeEndpointDao ;
28
28
import com .zsmartsystems .zigbee .database .ZigBeeNodeDao ;
29
29
import com .zsmartsystems .zigbee .internal .NotificationService ;
30
+ import com .zsmartsystems .zigbee .internal .ZigBeeNodeLinkQualityHandler ;
30
31
import com .zsmartsystems .zigbee .transaction .ZigBeeTransactionMatcher ;
31
32
import com .zsmartsystems .zigbee .zcl .ZclCluster ;
32
33
import com .zsmartsystems .zigbee .zcl .ZclCommand ;
53
54
* @author Chris Jackson
54
55
*
55
56
*/
56
- public class ZigBeeNode implements ZigBeeCommandListener {
57
+ public class ZigBeeNode {
57
58
/**
58
59
* The {@link Logger}.
59
60
*/
@@ -143,6 +144,11 @@ public enum ZigBeeNodeState {
143
144
OFFLINE
144
145
}
145
146
147
+ /**
148
+ * A handler to manage the {@link ZigBeeLinkQualityStatistics}
149
+ */
150
+ private ZigBeeNodeLinkQualityHandler linkQualityStatistics = new ZigBeeNodeLinkQualityHandler ();
151
+
146
152
/**
147
153
* Constructor
148
154
*
@@ -319,13 +325,23 @@ public boolean isReducedFuntionDevice() {
319
325
return nodeDescriptor .getMacCapabilities ().contains (MacCapabilitiesType .REDUCED_FUNCTION_DEVICE );
320
326
}
321
327
328
+ /**
329
+ * Returns true if the node is capable of supporting security. This tests the {@link NodeDescriptor}.
330
+ *
331
+ * @return true if the node is capable of supporting security
332
+ */
322
333
public boolean isSecurityCapable () {
323
334
if (nodeDescriptor == null ) {
324
335
return false ;
325
336
}
326
337
return nodeDescriptor .getMacCapabilities ().contains (MacCapabilitiesType .SECURITY_CAPABLE );
327
338
}
328
339
340
+ /**
341
+ * Returns true if the node is the primary trust centre. This tests the {@link NodeDescriptor}.
342
+ *
343
+ * @return true if the node is the primary trust centre
344
+ */
329
345
public boolean isPrimaryTrustCenter () {
330
346
if (nodeDescriptor == null ) {
331
347
return false ;
@@ -670,8 +686,15 @@ public Date getLastUpdateTime() {
670
686
return lastUpdateTime ;
671
687
}
672
688
673
- @ Override
674
- public void commandReceived (ZigBeeCommand command ) {
689
+ /**
690
+ * Incoming command handler. The node will process any commands addressed to this node ID and pass to
691
+ * the appropriate endpoint.
692
+ *
693
+ * @param command the {@link ZigBeeCommand} received
694
+ * @param rssi the Received Signal Strength Indicator of the received packet, or null
695
+ * @param lqi the Link Quality Indicator of the received packet, or null
696
+ */
697
+ public void commandReceived (ZigBeeCommand command , Integer rssi , Integer lqi ) {
675
698
// This gets called for all received commands
676
699
// Check if it's our address
677
700
if (!(command instanceof ZclCommand ) || networkAddress == null
@@ -681,6 +704,9 @@ public void commandReceived(ZigBeeCommand command) {
681
704
682
705
logger .trace ("{}: ZigBeeNode.commandReceived({})" , ieeeAddress , command );
683
706
707
+ linkQualityStatistics .updateReceivedLqi (lqi );
708
+ linkQualityStatistics .updateReceivedRssi (rssi );
709
+
684
710
ZclCommand zclCommand = (ZclCommand ) command ;
685
711
ZigBeeEndpointAddress endpointAddress = (ZigBeeEndpointAddress ) zclCommand .getSourceAddress ();
686
712
@@ -888,6 +914,15 @@ public ZigBeeNodeState getNodeState() {
888
914
return nodeState ;
889
915
}
890
916
917
+ /**
918
+ * Retrieves the {@link ZigBeeLinkQualityStatistics} for the node
919
+ *
920
+ * @return the {@link ZigBeeLinkQualityStatistics} for the node
921
+ */
922
+ public ZigBeeLinkQualityStatistics getLinkQualityStatistics () {
923
+ return linkQualityStatistics ;
924
+ }
925
+
891
926
@ Override
892
927
public String toString () {
893
928
StringBuilder builder = new StringBuilder (100 );
0 commit comments