Improvement #285

Do not automtically unbind from device

Added by Philipp Buluschek almost 4 years ago. Updated almost 4 years ago.

Status:New Start date:12/04/2014
Priority:Normal Due date:
Assignee:Stefano Lenzi % Done:


Category:zigbee.zcl.library Spent time: -
Target version:org.aaloa.zb4osgi.zigbee.zcl.library-1.X
Has a patch:No Has license agreement signed:No


In SubscriptionBase.removeReportListner(ReportListener), if you remove the last listener, an unbind request is sent to the device. I believe it is bad idea to do this automatically.

When you stop the bundle which provides the listener, it must deregister the listener in the stop process (else ZB4O holds references to code which is no longer "active"). This means that shutting down a bundle will trigger the sending of messages on the network. This is especially a problem, if the devices are sleepy and only respond to the request later (max 7.5 sec) or not at all, as the shut-down will be blocked while waiting for an answer or a timeout (imagine many devices = long blocking...)

It is also not necessary: the calling code knows whether the stop is temporary (eg. because an update is happening) and so the binding should be kept or definitive (because we don't want to receive these reports anymore). Only in the definitive case, should an unbind happen.

In short, I would recommend separating the listener addition/removal from the bind/unbind process, so that the calling code can decide itself if it wants to unbind.

Calling code could look like:

public void start(final BundleContext bc){
  sub.doBind(); //-> does nothing if already bound
public void stop(final BundleContext bc){
  //  sub.doUnbind(); not called as the stop is only temporary

Note additionally, that @doUnbind()@ must do nothing if other listeners are still registered.

Related issues

related to Bug #286: Binding may be removed although it is still needed New 12/04/2014


#1 Updated by Stefano Lenzi almost 4 years ago

  • Category set to zigbee.zcl.library
  • Assignee set to Stefano Lenzi
  • Target version set to org.aaloa.zb4osgi.zigbee.zcl.library-1.X

Also available in: Atom PDF