Discovery of channels should be done immediately on join
Closed this issue · 2 comments
Currently, when a node joins the network, the binding reads all the data required to decide what the device is. However, it does not read attributes etc that are used to determine the channels that will be supported - this is done once the thing handler is instantiated.
While this is fine from a binding perspective (the channel information isn't required at the time of association), it has one major drawback with battery devices. Since a battery device may sleep shortly after joining the network, if the user does not create a thing immediately, then the creation of channels may fail as the device may be sleeping.
It is probably a good idea to perform a channel search during the initial discovery to at least ensure that attributes etc have been read from the device while it is awake.
In facilitate this, I plan the following refactoring in the near future as I consider this quite a major issue when supporting battery devices.
- The
initialize
method in the channel converter will have theThingHandler
field removed. This allows the channel converter to be created without knowledge of the handler (ie before the thing is created - ie, during discovery. - The
initializeConverter
method will have theThingHandler
field added. - A new
isChannelSupported
method will be added. Converters should then be refactored so that all the detection of the channel which is currently in thegetChannel
method is moved to theisChannelSupported
method and thegetChannel
method should call this for detection. - The channel factory will be made available to the discovery service so that following the retrieval of the device properties, it can do a channel discovery by calling
isChannelSupported
, and then callinitializeDevice
if the channel is supported.
This provides a better separation within the converter between the converter functionality, and the device functionality allowing the channel to be detected, and the device configured without knowledge of the thing.
@triller-telekom FYI. I know you're probably about to go on holiday, but comments would be welcome. @hsudbrock - also FYI although I'm not sure if you're back yet?