How-to implement inter-module reuse?


I’m creating a binding for a FAI box. One of the information I can fetch are the DHCP leases.

As does by the freebox binding, one of the useful thing to do with such information is to create a ping monitoring. But, instead of creating such feature myself, I imagined to reuse the network binding, creating NetworkHandler on the fly.

Is it possible? Is it a good idea?
If so, how should I do? How to express a dependency between my module and the network module? How can I (correctly, cleanly) create a Thing from an other module?

Thanks for any thoughts and suggestions.

  1. You would add the network binding to your feature.xml file as runtime dependency.
  2. Lookup the network bindings docu or code to find out the binding-id and thing-id
  3. In your binding you would acquire the ThingRegistry like so:
ThingRegistry thingRegistry;
  1. Create things via the ThingBuilder, use the binding-id and thing-id from earlier, and insert them into the thing registry.

As you can see, you do not even need to talk to the network binding directly. It is installed automatically with your binding via the feature.xml file and you have full control of existing things.
(Those things are managed via the internal database, not via .thing files)

1 Like