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

Add methods to get supported cluster list from converters #517

Merged
merged 6 commits into from
Jan 2, 2020

Conversation

cdjackson
Copy link
Contributor

@cdjackson cdjackson commented Nov 14, 2019

This PR is incomplete and will fail CI - do not merge!!

From recent versions of the Z-Smart Systems ZigBee library (1.2.6 I think), we need to tell the framework what clusters we support. This is to allow the framework to only process messages that the application supports, and more importantly, to reject ones that are not supported with the appropriate error.

This is required for ZigBee certification and there is a test for this.

To achieve this, I've added two methods to the converters, and the converter factory to allow the coordinator handler to get the list of clusters that are implemented by the system. Each cluster will return a Set of cluster IDs it supports through the Set<Integer> getSupportedClientClusters() and Set<Integer> getSupportedServerClusters() methods. The converter factory has a similar set of methods and will return the consolidated Set of cluster IDs supported by all converters so that this can be passed to the framework.

@hsudbrock or @triller-telekom you should review this concept please.

Design questions - I have one thought - the framework methods set the client/server clusters the framework supports, but the converters internally use client/server clusters on the remote device, so the naming is reversed. Within the converter, does the getSupportedServerClusters method return the server clusters consumed by the converter, or the server clusters implemented by the converted?


This PR currently only implements the initial concept, and the methods in a single converter for comment.

Note that we probably also need to add the converter factory provider to the coordinator factories as this information is required in the ZigBeeCoordinatorHandler class (I've added this as a parameter on the constructor, but not hooked this all together yet).

Signed-off-by: Chris Jackson [email protected]

@cdjackson
Copy link
Contributor Author

I have renamed getSupportedClientClusters and getSupportedServerClusters to getImplementedClientClusters and getImplementedServerClusters to try and make it easier to understand that the definition is about what is implemented in the converter. Otherwise there is confusion about "supported" - if it means supported by the converter, or supported by the remote device, since they are opposite.

@cdjackson
Copy link
Contributor Author

I've now added the ZigBeeChannelConverterFactory to the Ember coordinator factory. Other than updating the other coordinators, and all of the converters to add the implemented clusters, this should be complete.

@hsudbrock or @triller-telekom I would really appreciate it if you can take a quick look at this ASAP as I would like to get this included into the latest OH for the 2.5 release so we can update the ZSS libraries. (Thanks).

@triller-telekom
Copy link
Contributor

Hi Chris,

sorry to get back to you this late again. I wish I could use more time on this here...

While seeing the latest changes in ZSS I also thought about a way that the converters should announce their used clusters by themselves. It certainly makes sense to define the clusters where we use them, so in the converters is a good idea.

I also like "implemented" over "supported" due to the confusion mentioned by you.

However, what we should not miss, is those clusters which are used by instances of com.zsmartsystems.zigbee.app.ZigBeeApplication. Those have to be registered to the ZigbeeNetworkManager as well. For example the ZclIasZoneClient which is in ZSS.

I don't know if you plan to register them within ZSS, or if any program who wants to make use of these applications has to register the clusters.

@cdjackson
Copy link
Contributor Author

Thanks for your thoughts @triller-telekom.

I don't know if you plan to register them within ZSS, or if any program who wants to make use of these applications has to register the clusters.

Yes, there is a plan to do this, but it's not all joined up - zsmartsystems/com.zsmartsystems.zigbee#411 is basically linked to this. In the first instance I might add these explicitly to the binding to make sure it's registered, but the above issue is becoming more important now that we have code to reject packets received from clusters that aren't registered...

You will find as well that there are now 2 APIs - one to set the clusters in theZigBeeManager, and another that is setting the clusters in the dongle and these should be aligned. In the past we never bothered to set the clusters in the Ember dongle as it was not really required, but you may find that certification requires this ;)

I will progress with this then and try and finish it tonight or tomorrow - I think it's all done now so it just needs testing. Do you want to review? Or should I ask - do you have time to review ;)

@triller-telekom
Copy link
Contributor

Do you want to review? Or should I ask - do you have time to review ;)

Rather the later, but I can try to have a deeper look at this PR during this week. Sorry can't promise.

@Nullable
private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory;

@Reference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the @Reference directly on the field would remove the need for the set and unset methods.

@@ -50,6 +54,16 @@

private ZclPressureMeasurementCluster cluster;

@Override
public Set<Integer> getImplementedClientClusters() {
return Stream.of(ZclPressureMeasurementCluster.CLUSTER_ID).collect(Collectors.toSet());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collections.singleton()

@@ -439,6 +445,13 @@ private synchronized void initialiseZigBee() {
return;
}

// Add all the clusters that we are supporting.
// If we don't do this, the framework will reject any packets for clusters we have not stated support for.
channelFactory.getImplementedClientClusters().stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the OSGi references in the handler factories the channelFactory can be null.
This would throw a NPE here.

// If we don't do this, the framework will reject any packets for clusters we have not stated support for.
channelFactory.getImplementedClientClusters().stream()
.forEach(clusterId -> networkManager.addSupportedClientCluster(clusterId));
channelFactory.getImplementedServerClusters().stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be reduced to channelFactory.getImplementedServerClusters().forEach(networkManager::addSupportedServerCluster)

@cdjackson
Copy link
Contributor Author

Thanks for the review @t-8ch

@cdjackson cdjackson changed the base branch from master to 2.5.x December 22, 2019 19:46
@cdjackson cdjackson force-pushed the supported_clusters branch 3 times, most recently from fc01e2b to 07e942e Compare December 25, 2019 20:37
@cdjackson cdjackson force-pushed the supported_clusters branch 2 times, most recently from 7ea289b to a3287ac Compare January 2, 2020 12:14
@cdjackson
Copy link
Contributor Author

Closes #531

Signed-off-by: Chris Jackson <[email protected]>
@cdjackson
Copy link
Contributor Author

This now updates to the ZSmart System libraries 1.2.8.

openhab/openhab-distro#1043

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/zigbee-binding/15763/2348

@cdjackson cdjackson changed the title [WIP] Add methods to get supported cluster list from converters Add methods to get supported cluster list from converters Jan 2, 2020
@cdjackson cdjackson merged commit f7cd109 into openhab:2.5.x Jan 2, 2020
@cdjackson cdjackson deleted the supported_clusters branch January 2, 2020 20:51
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/mijia-windows-door-sensor-model-mccgq01lm/104082/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants