本文整理了Java中com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension
类的一些代码示例,展示了ZigBeeDiscoveryExtension
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeeDiscoveryExtension
类的具体详情如下:
包路径:com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension
类名称:ZigBeeDiscoveryExtension
[英]This class implements a ZigBeeNetworkExtension to perform network discovery and monitoring.
[中]此类实现ZigBeeNetworkExtension以执行网络发现和监视。
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Starts a rediscovery on a node. This will send a {@link NetworkAddressRequest} as a broadcast and will receive
* the response to trigger a full discovery.
*
* @param ieeeAddress the {@link IeeeAddress} of the node to rediscover
*/
public void rediscoverNode(IeeeAddress address) {
ZigBeeDiscoveryExtension networkDiscoverer = (ZigBeeDiscoveryExtension) getExtension(
ZigBeeDiscoveryExtension.class);
if (networkDiscoverer == null) {
return;
}
networkDiscoverer.rediscoverNode(address);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void commandReceived(ZigBeeCommand command) {
// Listen for specific commands that may indicate that the mesh has changed
if (command instanceof ManagementLeaveResponse || command instanceof DeviceAnnounce) {
logger.debug("DISCOVERY Extension: Mesh related command received. Triggering mesh update.");
refresh();
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void nodeAdded(ZigBeeNode node) {
if (nodeDiscovery.containsKey(node.getIeeeAddress())) {
return;
}
logger.debug("DISCOVERY Extension: Adding discoverer for {}", node.getIeeeAddress());
startDiscovery(node);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Sets the update period for the mesh update service. This is the number of seconds between
* subsequent mesh updates. Setting the period to 0 will disable mesh updates.
*
* @param updatePeriod number of seconds between mesh updates. Setting to 0 will stop updates.
*/
public void setUpdatePeriod(final int updatePeriod) {
this.updatePeriod = updatePeriod;
if (!extensionStarted) {
return;
}
logger.debug("DISCOVERY Extension: Set mesh update interval to {} seconds", updatePeriod);
if (updatePeriod == 0) {
stopScheduler();
return;
}
startScheduler(updatePeriod);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
Mockito.doNothing().when(extension).startDiscovery(node);
Mockito.doNothing().when(extension).stopDiscovery(node);
Mockito.doNothing().when(extension).startScheduler(ArgumentMatchers.any(int.class));
extension.setUpdatePeriod(0);
assertEquals(ZigBeeStatus.SUCCESS, extension.extensionInitialize(networkManager));
extension.extensionStartup();
extension.setUpdatePeriod(0);
Mockito.verify(extension, Mockito.times(1)).stopScheduler();
assertEquals(0, extension.getUpdatePeriod());
extension.setUpdatePeriod(1);
Mockito.verify(extension, Mockito.times(1)).startScheduler(1);
assertEquals(1, extension.getUpdatePeriod());
extension.nodeAdded(node);
Mockito.verify(extension, Mockito.times(1)).startDiscovery(node);
assertEquals(1, extension.getNodeDiscoverers().size());
extension.nodeAdded(node);
Mockito.verify(extension, Mockito.times(1)).startDiscovery(node);
extension.nodeUpdated(node);
Mockito.verify(extension, Mockito.times(1)).startDiscovery(node);
Mockito.verify(extension, Mockito.times(0)).stopDiscovery(node);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
case "period":
if (args.length >= 3) {
extension.setUpdatePeriod(parseInteger(args[2]));
out.println("Mesh update period is set to " + extension.getUpdatePeriod() + " seconds.");
return;
default:
extension.rediscoverNode(node.getIeeeAddress());
out.println("Rediscovery for " + node.getIeeeAddress().toString() + " has been started.");
break;
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
networkManager.addExtension(new ZigBeeOtaUpgradeExtension());
ZigBeeDiscoveryExtension discoveryExtension = new ZigBeeDiscoveryExtension();
discoveryExtension.setUpdatePeriod(60);
networkManager.addExtension(discoveryExtension);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void nodeUpdated(ZigBeeNode node) {
// We need to handle the cases where the node changes to ONLINE, or to OFFLINE
if (node.getNodeState() == ZigBeeNodeState.ONLINE && !nodeDiscovery.containsKey(node.getIeeeAddress())) {
// If the state is ONLINE, then ensure discovery is running
startDiscovery(node);
} else if (node.getNodeState() != ZigBeeNodeState.ONLINE && nodeDiscovery.containsKey(node.getIeeeAddress())) {
// If state is not ONLINE, then stop discovery
stopDiscovery(node);
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
private void outputDiscoveryTasks(ZigBeeDiscoveryExtension extension, PrintStream out) {
out.println("Mesh update period : " + extension.getUpdatePeriod() + " seconds");
out.println();
out.println("Address Nwk Last Start Last Complete Current Tasks");
for (ZigBeeNodeServiceDiscoverer discoverer : extension.getNodeDiscoverers()) {
ZigBeeNode node = discoverer.getNode();
out.println(String.format("%s %-5d %-20s %-20s %s", node.getIeeeAddress(), node.getNetworkAddress(),
discoverer.getLastDiscoveryStarted() == null ? NEVER
: dfIso8601.format(discoverer.getLastDiscoveryStarted().getTime()),
discoverer.getLastDiscoveryCompleted() == null ? NEVER
: dfIso8601.format(discoverer.getLastDiscoveryCompleted().getTime()),
tasksToString(discoverer.getTasks())));
}
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
/**
* Performs an immediate refresh of the network. Subsequent updates are performed at the current update rate, and
* the timer is restarted from the time of calling this method.
*/
public void refresh() {
logger.debug("DISCOVERY Extension: Start mesh update task with interval of {} seconds", updatePeriod);
// Delay the start slightly to allow any further processing to complete.
// Also allows successive responses to filter through without retriggering an update.
startScheduler(10);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public void nodeRemoved(ZigBeeNode node) {
logger.debug("DISCOVERY Extension: Removing discoverer for {}", node.getIeeeAddress());
stopDiscovery(node);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
protected void startScheduler(int initialPeriod) {
stopScheduler();
Runnable meshUpdateThread = new Runnable() {
@Override
public void run() {
logger.debug("DISCOVERY Extension: Starting mesh update");
for (ZigBeeNodeServiceDiscoverer node : nodeDiscovery.values()) {
logger.debug("DISCOVERY Extension: Starting mesh update for {}", node.getNode().getIeeeAddress());
node.updateMesh();
}
}
};
futureTask = networkManager.scheduleTask(meshUpdateThread, initialPeriod, updatePeriod * 1000);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
private ZigBeeNodeServiceDiscoverer getNodeDiscoverer(ZigBeeDiscoveryExtension extension, IeeeAddress ieeeAddress) {
for (ZigBeeNodeServiceDiscoverer discoverer : extension.getNodeDiscoverers()) {
if (discoverer.getNode().getIeeeAddress().equals(ieeeAddress)) {
return discoverer;
}
}
return null;
}
代码示例来源:origin: openhab/org.openhab.binding.zigbee
ZigBeeDiscoveryExtension discoveryExtension = new ZigBeeDiscoveryExtension();
discoveryExtension.setUpdatePeriod(meshUpdateTime);
networkManager.addExtension(discoveryExtension);
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public ZigBeeStatus extensionStartup() {
logger.debug("DISCOVERY Extension: Startup");
networkManager.addNetworkNodeListener(this);
networkManager.addCommandListener(this);
networkDiscoverer = new ZigBeeNetworkDiscoverer(networkManager);
networkDiscoverer.startup();
if (updatePeriod != 0) {
startScheduler(10);
}
extensionStarted = true;
return ZigBeeStatus.SUCCESS;
}
内容来源于网络,如有侵权,请联系作者删除!