Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow application to set the local endpoint ID #1143

Merged
merged 1 commit into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class ZigBeeNetworkManager implements ZigBeeTransportReceive {
/**
* The local endpoint ID used for all ZCL commands
*/
private static final int LOCAL_ENDPOINT_ID = 1;
private static final int DEFAULT_LOCAL_ENDPOINT_ID = 1;

/**
* The broadcast endpoint
Expand Down Expand Up @@ -208,6 +208,11 @@ public class ZigBeeNetworkManager implements ZigBeeTransportReceive {
*/
private final ZigBeeTransactionManager transactionManager;

/**
* The local endpoint ID used for all ZCL commands
*/
private int localEndpointId = DEFAULT_LOCAL_ENDPOINT_ID;

/**
* The {@link ApsDataEntity} provides APS layer services such as duplicate removal and fragmentation control
*/
Expand Down Expand Up @@ -345,6 +350,16 @@ public void setSerializer(Class<?> serializer, Class<?> deserializer) {
this.deserializerClass = (Class<ZigBeeDeserializer>) deserializer;
}

/**
* Sets the local endpoint ID
*
* @param localEndpointId
*/
public void setLocalEndpointId(int localEndpointId) {
this.localEndpointId = localEndpointId;
transport.setDefaultLocalEndpointId(localEndpointId);
}

/**
* Initializes ZigBee manager components and initializes the transport layer. This call may only be called once in
* the life of the network.
Expand Down Expand Up @@ -418,18 +433,6 @@ public ZigBeeTransportTransmit getZigBeeTransport() {
return transport;
}

/**
* Gets the local node. If not found, or the local IEEE address is not known, this will return null
*
* @return the local {@link ZigBeeNode} or null if not found or local {@link IeeeAddress} is not known
*/
private ZigBeeNode getLocalNode() {
if (localIeeeAddress == null) {
return null;
}
return networkNodes.get(localIeeeAddress);
}

/**
* Gets the current ZigBee RF channel.
*
Expand Down Expand Up @@ -1020,7 +1023,7 @@ private ZigBeeCommand receiveZdoCommand(final ZclFieldDeserializer fieldDeserial

private ZigBeeCommand receiveZclCommand(final ZclFieldDeserializer fieldDeserializer,
final ZigBeeApsFrame apsFrame) {
if (apsFrame.getDestinationEndpoint() != LOCAL_ENDPOINT_ID
if (apsFrame.getDestinationEndpoint() != localEndpointId
&& apsFrame.getDestinationEndpoint() != BROADCAST_ENDPOINT_ID) {
logger.debug("Unknown local endpoint for APS frame {}", apsFrame);
return null;
Expand Down Expand Up @@ -1788,7 +1791,7 @@ public ZigBeeStatus addSupportedClientCluster(int cluster) {

logger.debug("Adding supported client cluster {}", String.format("%04X", cluster));
if (clusterMatcher == null) {
clusterMatcher = new ClusterMatcher(this, LOCAL_ENDPOINT_ID, defaultProfileId);
clusterMatcher = new ClusterMatcher(this, localEndpointId, defaultProfileId);
}
clusterMatcher.addClientCluster(cluster);
return ZigBeeStatus.SUCCESS;
Expand All @@ -1812,7 +1815,7 @@ public ZigBeeStatus addSupportedServerCluster(int cluster) {

logger.debug("Adding supported server cluster {}", String.format("%04X", cluster));
if (clusterMatcher == null) {
clusterMatcher = new ClusterMatcher(this, LOCAL_ENDPOINT_ID, defaultProfileId);
clusterMatcher = new ClusterMatcher(this, localEndpointId, defaultProfileId);
}
clusterMatcher.addServerCluster(cluster);
return ZigBeeStatus.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ default void setDefaultProfileId(int defaultProfileId) {
default void setDefaultDeviceId(int defaultDeviceId) {
}

/**
* Sets the default local endpoint Id.
*
* @param localEndpointId the local endpoint ID
*/
default void setDefaultLocalEndpointId(int localEndpointId) {
}

/**
* Provides the node descriptor to the transport layer. The {@link NodeDescriptor} contains information that may be
* of use to the transport layer and this is provided when available.
Expand Down