I want to implement a discovery service for my binding but I am using an arduino and I don’t have and xml sort of file through which the arduino will advertise its functionalities as it is in the wemo binding, I want to find out if there is an easier way to achieve this maybe by just using MAC address and another name to distinguish it from other devices on my network.
You can use whatever method you like to perform discovery - there is no XML involved. You need to write a discovery handler, and then add the newly discovered item into the discovery inbox. Take a look at some of the examples…
In my case where the only unique thing is MAC address, what do you suggest?
Well, if you can access the MAC address - use that of course . You can use whatever you want…
How do I handle the ip address for the communication after discovery
What do you mean by ‘handle the IP address’?
The process is - discover your device, save it to the discovery inbox. You can set properties here if you want. The someone can accept the discover, and the thing is created. When the thing is created, then you have your thing handler, it can read the configuration and properties that you set, and you interact with the device.
I’d really suggest taking a look through some of the examples or other bindings or take a look at the documentation.
the discovery uses 18.104.22.168:
for the handler how do I configure different port number.
the message the devices reply with come an ip address:port number which is used in the wemohandler
In the handler, I guess you’re using UDP or TCP, so just open up the port that you want to use? This is up to you of course.
If you mean how do you pass the information on what port you’re using, from discovery to the handler, the this is done by setting the thing properties…
Or, maybe I don’t understand what you mean - please can you try and provide more than a 1 line question - it would help us understand you, and help you better.
my handler is using UDP
Ok, so no problem then?
Like Chris already mentioned, please give us more information, not just one line messages, so we can try to help you.
If your handler us using UDP, what about showing us what you already have coded and describe, where your problem is in the code.
My handler is just a modification to the keba binding which uses UDP but has no discovery. I want to add discovery service to it. In the keba handler you specify the ip address and the port number. In the Wemo binding these port number and ip are gotten from the replies from the wemo devices . so in the handler they are retrieved from the configuration details.
Ok, so what is the question here?
In WemoDiscoveryParticipant, you can see how the UDN is stored as a property, and in WeMo handler how this information is read during initialize().
Just do the same for your IP-Address and Port
So in my case when I use the Mac address for the discovery, in storing it I add the ip address and port number I want to use
You should store the information that you need in your handler to communicate with the device.
so I can keep the handler as it is and add a discovery service just to create the thing dynamically.
why do you have multicast.send(discoveryPacket) and wemoReceiveSocket.send(discoveryPacket);
Searching for examples how to write SSDP discovery I found this as an example that worked.
Never tried to find out, why both send methods are really needed.
If you GOOGLE for SSDP discovery, you might find different coding samples you could use.
Due to the fact that the 1.x Version of the WeMo binding is no longer maintained for future features (just bug-fixes in case of) and the ESH/openHAB2 binding makes use of JUPnP for discovery, I don’t really bother if the message is send twice or not.