use of com.zsmartsystems.zigbee.ZigBeeNode in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleNetworkLeaveCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
if (args.length > 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
ZigBeeNode leaver = getNode(networkManager, args[1]);
if (args.length == 2) {
networkManager.leave(leaver.getNetworkAddress(), leaver.getIeeeAddress());
return;
}
if (args.length == 3) {
ZigBeeNode parent = getNode(networkManager, args[2]);
networkManager.leave(parent.getNetworkAddress(), leaver.getIeeeAddress());
return;
}
}
use of com.zsmartsystems.zigbee.ZigBeeNode in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleNodeListCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
final Set<ZigBeeNode> nodes = networkManager.getNodes();
final List<Integer> nodeIds = new ArrayList<Integer>();
for (ZigBeeNode node : nodes) {
nodeIds.add(node.getNetworkAddress());
}
Collections.sort(nodeIds);
out.println("Network Addr IEEE Address Device Type EP Profile");
for (Integer nodeId : nodeIds) {
ZigBeeNode node = networkManager.getNode(nodeId);
out.print(String.format("%-6d %04X %s %-11s", node.getNetworkAddress(), node.getNetworkAddress(), node.getIeeeAddress(), node.getLogicalType()));
List<Integer> endpointIds = new ArrayList<Integer>();
for (final ZigBeeEndpoint endpoint : node.getEndpoints()) {
endpointIds.add(endpoint.getEndpointId());
}
Collections.sort(endpointIds);
boolean first = true;
for (Integer endpointId : endpointIds) {
if (!first) {
out.print(" ");
}
first = false;
ZigBeeEndpoint endpoint = node.getEndpoint(endpointId);
out.println(String.format("%-3d %s", endpoint.getEndpointId(), ZigBeeProfileType.getProfileType(endpoint.getProfileId())));
}
if (first) {
out.println();
}
}
}
use of com.zsmartsystems.zigbee.ZigBeeNode in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleDescribeNodeCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
if (args.length != 2) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeNode node = getNode(networkManager, args[1]);
out.println("IEEE Address : " + node.getIeeeAddress());
out.println("Network Address : " + node.getNetworkAddress());
out.println("Node Descriptor : " + node.getNodeDescriptor());
out.println("Power Descriptor : " + node.getPowerDescriptor());
out.println("Associations : " + node.getAssociatedDevices().toString());
out.println("Endpoints:");
for (ZigBeeEndpoint endpoint : node.getEndpoints()) {
out.println(endpoint.toString());
}
out.println("Neighbors:");
for (NeighborTable neighbor : node.getNeighbors()) {
out.println(neighbor.toString());
}
out.println("Routes:");
for (RoutingTable route : node.getRoutes()) {
out.println(route.toString());
}
}
use of com.zsmartsystems.zigbee.ZigBeeNode in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleNetworkJoinCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
if (args.length < 2 | args.length > 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final int join;
if ("enable".equalsIgnoreCase(args[1])) {
join = 255;
} else if ("disable".equalsIgnoreCase(args[1])) {
join = 0;
} else {
join = Integer.parseInt(args[1]);
}
if (args.length == 3) {
// Node defined
ZigBeeNode node = getNode(networkManager, args[2]);
node.permitJoin(join);
if (join != 0) {
out.println("Permit join enable node " + node.getNetworkAddress() + " success.");
} else {
out.println("Permit join disable " + node.getNetworkAddress() + " success.");
}
} else {
networkManager.permitJoin(join);
if (join != 0) {
out.println("Permit join enable broadcast success.");
} else {
out.println("Permit join disable broadcast success.");
}
}
}
use of com.zsmartsystems.zigbee.ZigBeeNode in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeDaoTest method testSerialize.
@Test
public void testSerialize() {
ZigBeeTransportTransmit mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("1234567890ABCDEF"));
node.setNetworkAddress(12345);
ZigBeeEndpoint endpoint;
endpoint = new ZigBeeEndpoint(networkManager, node, 1);
endpoint.setProfileId(123);
node.addEndpoint(endpoint);
endpoint = new ZigBeeEndpoint(networkManager, node, 2);
endpoint.setProfileId(321);
node.addEndpoint(endpoint);
/*
* ZigBeeNodeDao nodeDao = ZigBeeNodeDao.createFromZigBeeNode(node);
* assertEquals(new IeeeAddress("1234567890ABCDEF").toString(), nodeDao.getIeeeAddress());
* assertEquals(Integer.valueOf(12345), nodeDao.getNetworkAddress());
*
* node = ZigBeeNodeDao.createFromZigBeeDao(networkManager, nodeDao);
* assertEquals(new IeeeAddress("1234567890ABCDEF"), node.getIeeeAddress());
* assertEquals(Integer.valueOf(12345), node.getNetworkAddress());
* assertEquals(2, node.getEndpoints().size());
*
* endpoint = node.getEndpoint(1);
* assertEquals(123, endpoint.getProfileId());
*/
}
Aggregations