For a binding I am currently developing, I need to do an “active” scanning to discover devices in the network. The device implements a custom MQTT protocol, and my discovery service extends AbstractMQTTDiscovery.
Internally, the AbstractMQTTDiscovery provides me with an implementation of MQTTTopicDiscoveryService interface implemented in MqttBrokerHandlerFactory.
The methods currently exposed are subscribe and unsubscribe in order to receive MQTT messages and implement custom logic for thing discovery, but in order to implement discovery in my case, I need to also publish a trigger message. I intend to submit a PR for this change, and I wanted to check with you guys if this implementation makes sense:
Extend MQTTTopicDiscoveryService with the following method:
void publish(String topic, byte payload);
Implement the publish method in MqttBrokerHandlerFactory and inside iterate the existing MQTT handlers and publish asynchronously the message.
Any thoughts are welcome.