use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNetworkStateSerializerImpl method deserialize.
/**
* Deserializes the network state.
*
* @param networkState the network state
*/
@Override
public void deserialize(final ZigBeeNetworkManager networkState) {
final File file = new File(networkId);
boolean networkStateExists = file.exists();
if (networkStateExists == false) {
return;
}
logger.info("Loading network state...");
try {
XStream stream = openStream();
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
final List<Object> objects = (List<Object>) stream.fromXML(reader);
for (final Object object : objects) {
if (object instanceof ZigBeeNodeDao) {
ZigBeeNodeDao nodeDao = (ZigBeeNodeDao) object;
ZigBeeNode node = new ZigBeeNode(networkState, new IeeeAddress(nodeDao.getIeeeAddress()));
node.setDao(nodeDao);
networkState.addNode(node);
}
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("Loading network state complete.");
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleUnbindCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length < 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final int clusterId = parseCluster(args[1]);
final ZigBeeEndpoint source = getEndpoint(networkManager, args[2]);
ZclCluster cluster = source.getInputCluster(clusterId);
if (cluster == null) {
throw new IllegalArgumentException("Cluster '" + clusterId + "' not found.");
}
IeeeAddress destAddress;
int destEndpoint;
if (args.length >= 4) {
ZigBeeEndpoint destination = getEndpoint(networkManager, args[3]);
destAddress = destination.getIeeeAddress();
destEndpoint = destination.getEndpointId();
} else {
destAddress = networkManager.getNode(0).getIeeeAddress();
destEndpoint = 1;
}
final CommandResult response = cluster.unbind(destAddress, destEndpoint).get();
processDefaultResponse(response, out);
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleBindCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length < 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final int clusterId = parseCluster(args[1]);
final ZigBeeEndpoint source = getEndpoint(networkManager, args[2]);
ZclCluster cluster = source.getInputCluster(clusterId);
if (cluster == null) {
throw new IllegalArgumentException("Cluster '" + clusterId + "' not found.");
}
IeeeAddress destAddress;
int destEndpoint;
if (args.length >= 4) {
ZigBeeEndpoint destination = getEndpoint(networkManager, args[3]);
destAddress = destination.getIeeeAddress();
destEndpoint = destination.getEndpointId();
} else {
destAddress = networkManager.getNode(0).getIeeeAddress();
destEndpoint = 1;
}
final CommandResult response = cluster.bind(destAddress, destEndpoint).get();
processDefaultResponse(response, out);
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleXBee method sendCommand.
@Override
public void sendCommand(final ZigBeeApsFrame apsFrame) {
if (frameHandler == null) {
logger.debug("XBee frame handler not set for send.");
return;
}
XBeeTransmitRequestExplicitCommand command = new XBeeTransmitRequestExplicitCommand();
command.setNetworkAddress(apsFrame.getDestinationAddress());
command.setDestinationEndpoint(apsFrame.getDestinationEndpoint());
command.setSourceEndpoint(apsFrame.getSourceEndpoint());
command.setProfileId(apsFrame.getProfile());
command.setCluster(apsFrame.getCluster());
command.setBroadcastRadius(0);
if (apsFrame.getDestinationAddress() > 0xFFF8) {
command.setIeeeAddress(broadcastIeeeAddress);
} else if (apsFrame.getDestinationIeeeAddress() == null) {
if (apsFrame.getAddressMode() == ZigBeeNwkAddressMode.GROUP) {
command.setIeeeAddress(groupIeeeAddress);
} else {
}
command.setIeeeAddress(new IeeeAddress("FFFFFFFFFFFFFFFF"));
} else {
command.setIeeeAddress(apsFrame.getDestinationIeeeAddress());
}
if (apsFrame.getDestinationAddress() < 0xFFF8 && apsFrame.getDestinationAddress() != 0) {
// There seems to be a bug in the XBee that causes it to hang if APS Encryption is
// enabled when sending a command to the local coordinator. Don't do it!
command.addOptions(TransmitOptions.ENABLE_APS_ENCRYPTION);
}
command.setData(apsFrame.getPayload());
logger.debug("XBee send: {}", command.toString());
frameHandler.sendRequestAsync(command);
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class TelegesisSleepyDeviceAnnounceEventTest method testExtended.
@Test
public void testExtended() {
TelegesisSleepyDeviceAnnounceEvent event = new TelegesisSleepyDeviceAnnounceEvent();
event.deserialize(stringToIntArray("SED:1234567890ABCDEF,9876,44,AA"));
System.out.println(event);
assertEquals(new IeeeAddress("1234567890ABCDEF"), event.getIeeeAddress());
assertEquals(Integer.valueOf(0x9876), event.getNetworkAddress());
assertEquals(Integer.valueOf(68), event.getRssi());
assertEquals(Integer.valueOf(0xAA), event.getLqi());
}
Aggregations