eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
865 stars 782 forks source link

mDNS: service not found #1507

Closed lolodomo closed 8 years ago

lolodomo commented 8 years ago

I try to implement a mDNS discovery service for the Freebox server but it does not work.

Here is the result of avahi-browser on the same RPI 2 that runs OH2:

avahi-browse --all
+   eth0 IPv4 Freebox Server                                _fbx-api._tcp        local

Here is the log entry when I start OH2:

2016-05-11 15:35:54.849 [DEBUG] [s.i.t.m.d.MDNSDiscoveryService:88   ] - 0 services found for _fbx-api._tcp

Here is my current code:

public class FreeboxServerDiscoveryParticipant implements MDNSDiscoveryParticipant {

    private Logger logger = LoggerFactory.getLogger(FreeboxServerDiscoveryParticipant.class);

    private static final String SERVICE_TYPE = "_fbx-api._tcp";
    private static final String SERVER_ID = "fb";

    @Override
    public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
        return FreeboxBindingConstants.SUPPORTED_BRIDGE_TYPES_UIDS;
    }

    @Override
    public String getServiceType() {
        return SERVICE_TYPE;
    }

    @Override
    public ThingUID getThingUID(ServiceInfo service) {
        logger.info("FreeboxServerDiscoveryParticipant getThingUID");
        if (service != null) {
            logger.trace("ServiceInfo: {}", service);
            if ((service.getType() != null) && service.getType().equals(getServiceType())) {
                return new ThingUID(FreeboxBindingConstants.FREEBOX_BRIDGE_TYPE_SERVER, SERVER_ID);
            }
        }
        return null;
    }

    @Override
    public DiscoveryResult createResult(ServiceInfo service) {
        logger.info("FreeboxServerDiscoveryParticipant createResult");
        DiscoveryResult result = null;
        logger.trace("ServiceInfo: {}", service);
        logger.trace("Service getName: {}", service.getName());
        ThingUID uid = getThingUID(service);
        if (uid != null) {
        }
        return result;
    }

}

What's wrong ? Is mDNS working in openHAB2 ?

maggu2810 commented 8 years ago

This public available bindings are using the MDNSDiscoveryParticipant

So, the digitalstrom binding is rather new in the official ESH tree, so I assume it has been tested and has been working. Perhaps you can install the three bindings and play around with them...

kaikreuzer commented 8 years ago

I just successfully tested the IPP binding on my Pine64 successfully - the mDNS discovery works.

Having said this, it does not find anything on my Mac because of https://github.com/eclipse/smarthome/issues/577. I assume that this is also your problem, @lolodomo.