tlaukkan / zigbee4java

Zigbee API for Java provides simple Java interface to ZigBee network.
Apache License 2.0
144 stars 68 forks source link

Delegate endpoint registration to the application #66

Open cdealti opened 8 years ago

cdealti commented 8 years ago

ApplicationFrameworkLayer.createDefaultSendingEndPoint() registers 3 endpoints, apparently without any real reason.

The code is weird too because it iterates over a set of 34 clusters and registers as many endpoints as needed (i.e. 3 endpoints) each with 16 clusters as inputs and outputs (the third only contains 2 clusters).

Also, each endpoint is registered specifying a device ID=0 in the Home Automation Profile which is the On/Off Switch in the HA specification.

I believe this default registration should not be hardcoded in the ApplicationFrameworkLayer and delegated to the application (e.g. the ZigBeeConsole).

Hint: the HA Combined Interface described in the HA spec could be a better choice.

Ciao, Cristiano

Brhett commented 8 years ago

Hi Cristiano,

My understanding is that the default sending endpoint(s) implement all the clients to be able to interoperate with other servers of ZigBee devices.

I believe this default registration should not be hardcoded in the ApplicationFrameworkLayer and delegated to the application (e.g. the ZigBeeConsole).

Agree.

Regards, Brhett

drugo72 commented 8 years ago

Hi Brhett, If you plan to create a PR with your fixes to addCustomEndopint, would you also consider the above? Thanks, Cristiano

Brhett commented 8 years ago

The code is weird too because it iterates over a set of 34 clusters and registers as many endpoints as needed (i.e. 3 endpoints) each with 16 clusters as inputs and outputs (the third only contains 2 clusters).

Actually, the clusters are registered as outputs only. See https://github.com/tlaukkan/zigbee4java/blob/master/zigbee-api/src/main/java/org/bubblecloud/zigbee/network/impl/ApplicationFrameworkLayer.java#L202

I think its original purpose was create a ZigBee On/Off Switch to control the Philip Hue for example. But then it became to a "Combined Interface Device"+. It is used to control other ZigBee devices as many as possible.

In order to be HA specification compliant, I think there should be several specific endpoints being registered to cover the functionalities. e.g. "Combined Interface Device" + "Thermostat" + "Home Gateway" + "IAS CIE" + ... However, some of them have common clusters, which might introduce more complexity.

So I think it's better to delegate the endpoints registration to the application. e.g. ZigBeeConsole