use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestNetworkAddress.
/**
* Get node descriptor
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestNetworkAddress() throws InterruptedException, ExecutionException {
NetworkAddressRequest networkAddressRequest = new NetworkAddressRequest();
networkAddressRequest.setIeeeAddr(node.getIeeeAddress());
networkAddressRequest.setRequestType(0);
networkAddressRequest.setStartIndex(0);
networkAddressRequest.setDestinationAddress(new ZigBeeEndpointAddress(ZigBeeBroadcastDestination.BROADCAST_ALL_DEVICES.getKey()));
CommandResult response = networkManager.unicast(networkAddressRequest, networkAddressRequest).get();
final NetworkAddressResponse networkAddressResponse = (NetworkAddressResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery NetworkAddressRequest returned {}", node.getNetworkAddress(), networkAddressResponse);
if (networkAddressResponse == null) {
return false;
}
if (networkAddressResponse.getStatus() == ZdoStatus.SUCCESS) {
node.setNetworkAddress(networkAddressResponse.getNwkAddrRemoteDev());
return true;
}
return false;
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestActiveEndpoints.
/**
* Get the active endpoints for a node
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestActiveEndpoints() throws InterruptedException, ExecutionException {
final ActiveEndpointsRequest activeEndpointsRequest = new ActiveEndpointsRequest();
activeEndpointsRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
activeEndpointsRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.unicast(activeEndpointsRequest, activeEndpointsRequest).get();
final ActiveEndpointsResponse activeEndpointsResponse = (ActiveEndpointsResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery ActiveEndpointsResponse returned {}", node.getIeeeAddress(), response);
if (activeEndpointsResponse == null) {
return false;
}
// Get the simple descriptors for all endpoints
List<ZigBeeEndpoint> endpoints = new ArrayList<ZigBeeEndpoint>();
for (final int endpointId : activeEndpointsResponse.getActiveEpList()) {
ZigBeeEndpoint endpoint = getSimpleDescriptor(endpointId);
if (endpoint == null) {
return false;
}
endpoints.add(endpoint);
}
// All endpoints have been received, so add them to the node
for (ZigBeeEndpoint endpoint : endpoints) {
node.addEndpoint(endpoint);
}
return true;
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestRoutingTable.
/**
* Get node routing table by making a {@link ManagementRoutingRequest} request
*
* @return list of {@link RoutingTable} if the request was processed ok, null otherwise
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestRoutingTable() throws InterruptedException, ExecutionException {
// Start index for the list is 0
int startIndex = 0;
int totalRoutes = 0;
Set<RoutingTable> routes = new HashSet<RoutingTable>();
do {
final ManagementRoutingRequest routeRequest = new ManagementRoutingRequest();
routeRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
routeRequest.setStartIndex(startIndex);
CommandResult response = networkManager.unicast(routeRequest, routeRequest).get();
final ManagementRoutingResponse routingResponse = response.getResponse();
logger.debug("{}: Node SVC Discovery ManagementRoutingRequest returned {}", node.getIeeeAddress(), response);
if (routingResponse == null) {
return false;
}
if (routingResponse.getStatus() == ZdoStatus.NOT_SUPPORTED) {
supportsManagementRouting = false;
return true;
} else if (routingResponse.getStatus() != ZdoStatus.SUCCESS) {
return false;
}
// Save the routes
routes.addAll(routingResponse.getRoutingTableList());
// Continue with next request
startIndex += routingResponse.getRoutingTableList().size();
totalRoutes = routingResponse.getRoutingTableEntries();
} while (startIndex < totalRoutes);
node.setRoutes(routes);
return true;
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclCluster method unbind.
/**
* Removes a binding from the cluster to the destination {@link ZigBeeEndpoint}.
*
* @param address the destination {@link IeeeAddress}
* @param endpointId the destination endpoint ID
* @return Command future
*/
public Future<CommandResult> unbind(IeeeAddress address, int endpointId) {
final UnbindRequest command = new UnbindRequest();
command.setDestinationAddress(new ZigBeeEndpointAddress(zigbeeEndpoint.getEndpointAddress().getAddress()));
command.setSrcAddress(zigbeeEndpoint.getIeeeAddress());
command.setSrcEndpoint(zigbeeEndpoint.getEndpointId());
command.setBindCluster(clusterId);
// 64 bit addressing
command.setDstAddrMode(3);
command.setDstAddress(address);
command.setDstEndpoint(endpointId);
return zigbeeManager.unicast(command, new UnbindRequest());
}
use of com.zsmartsystems.zigbee.ZigBeeEndpointAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleConBee method sendCommand.
@Override
public void sendCommand(final ZigBeeApsFrame apsFrame) {
ConBeeEnqueueSendDataRequest request = new ConBeeEnqueueSendDataRequest();
request.setRequestId(apsFrame.getSequence());
request.setClusterId(apsFrame.getCluster());
switch(apsFrame.getAddressMode()) {
case DEVICE:
request.setDestinationAddress(new ZigBeeEndpointAddress(apsFrame.getDestinationAddress(), apsFrame.getDestinationEndpoint()));
request.setDestinationAddressMode(ConBeeAddressMode.NWK);
if (apsFrame.getDestinationAddress() > 0xfff8) {
//
request.setTxOptions(0);
}
break;
case GROUP:
request.setDestinationAddress(new ZigBeeGroupAddress(apsFrame.getDestinationAddress()));
request.setDestinationAddressMode(ConBeeAddressMode.GROUP);
break;
default:
break;
}
request.setProfileId(apsFrame.getProfile());
request.setRadius(apsFrame.getRadius());
request.setSourceEndpoint(apsFrame.getSourceEndpoint());
// request.setTxOptions(txOptions);
request.setAdsuData(apsFrame.getPayload());
conbeeHandler.queueFrame(request);
}
Aggregations