This page last changed on Jun 12, 2009 by mredeker.

Hi guys,

looking at the latest code in trunk I saw that the iPhone console includes a lot of code for the ORB discovery and also on the controller side quite some work. I was wondering if the "zeroconf" specifications would help making this much easier to implement?

On the iPhone side the Bonjour service is already there to use and implements the zeroconf protocols and for the controller side we could use jmdns which is distributed under the apache licence.

Here is a presentation which describes the stuff:http://www.bosatsu.net/talks/JmDNS.pdf
You can find JmDNS on sourceforge: http://jmdns.sourceforge.net/

On the iPhone side you just create a delegate to react on bonjour events and start NSNetServiceBrowser. The code would be a  3-liner :

id delegateObject; // Assume this exists.
NSNetServiceBrowser *serviceBrowser;
serviceBrowser = [[NSNetServiceBrowser alloc] init];
[serviceBrowser setDelegate:delegateObject];
[serviceBrowser searchForServicesOfType:@"_orb._tcp" inDomain:@""];
What do you think?

Not that I am one to comment but anything by Arthur Van Hoff is golden.  He was one of the original java creators and left to do Marimba, he is one hell of a guy.  In general, discovery of ORB is going to be important and anything that can automate discovery should be welcomed.  Wait for juha's feedback but this sounds like a winner.

Posted by marcf at Jun 12, 2009 15:48

Why are you guys always so Java-centric? Why not just install the mDNS package which is part of Debian? A simple
apt-get install avahi-daemon
gives you all the functionality you need. Beside this - the jmdns will not work if there is already avahi installed (only one mdns responder allowed per IP address) which is sometimes the case on some desktop linux distributions...

As I know from experience, we will have to register a service type ID somewhere (I will have to check) - I did this some years ago for the printers I build.

Posted by jfalkenberg at Jun 13, 2009 07:37

why are we so java centric?

You were schnoozing while we were furously chatting yesterday so I will give you a summerized version: write once, run everywhere. Means more distribution for us.

JP Joubert, an integrator  you have seen writing on the sales alias says "can I test on my PC" (meaning windows).  He uses KNX.  Answer: yes, in principle it should work AS IS on a windows PC. The bottom line there will be that it will be easier to test. Lower barrier to adoption is good.

KNX uses Calimero, Calimero is pure java, voila!

unfortunatetly not everything is java and there I agree we should prioritize linux support for the ORB.

Posted by marcf at Jun 13, 2009 09:41

Marc, sorry if I tapped on your foot. However, the famous "run once, run everywhere" is only a marketing slogan from sun. In principle yes, but. At least for Java applets it is not true. My collegue lost a lot of hair writing his applets so they could run properly on the different VMs, different Java versions and so on. Even the same Java versions behave differently on Windows and Linux.

However, I agree that Java is great for applications without need of direct control of the underlying system. But we should concentrate on the OR system itself. If there's already support for some things in the system (like the mDNS here), there's no need to do the work twice.

Posted by jfalkenberg at Jun 13, 2009 12:42

Hi Marcus,

I was looking for something like application discovery for another project. There is many ways to do it, Bonjour is one of them, and in OR case, can be very usefull as it is native to the IPhone as you mentionned.

I has also a look with UPnP and DPWS for the same usage, assuming that a DHCP server is available on the target network (which is often the case in automated houses).

My guess is that on such a project, all "discovery" protocols may be used...

Posted by mgallissot at Jun 13, 2009 13:55

OK, boring TV program today. Mosquitoes outside, so time to configure mDNS

Just login to your ORB (Alix with Voyage linux assumed):

remountrw
apt-get install avahi-daemon
cd /etc/avahi/services
vi orb.service

Now put the following XML into the new file:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">OpenRemote on %h</name>
  <service>
    <type>_orb._tcp</type>
    <port>80</port>
  </service>
</service-group>

Just restart avahi now (/etc/init.d/avahi restart).

Et voila Using your favorite mDNS browser (e.g. the free mDNS app on the iPhone), you can now find a _orb._tcp service on your local net. Who's doing the registering of the ORB services on dns-sd.org now?

Posted by jfalkenberg at Jun 13, 2009 21:23

Hi Mathieu,

the LinuxMCE project is using the DHCP approach. But that means the LinuxMCE must be the one and only DHCP server in the house. Most of the users probably already have an internet router which acts as a DHCP server and then you have a problem.

Using an independent service like zeroconf would make things easier I suppose. And since we want the ORB to be the interface to all other HA hardware it's good enough if we can just detect the ORB who then will do the rest of the communication.

Posted by mredeker at Jun 14, 2009 00:22

For the controller software running on a Linux system or on the ORB hardware that is fine. But if a user want to have the controller run on Windows we have a problem.

I was just trying the Java solution which I mentioned and that works nicely. All I had todo was create a bean and register that with our spring context. So we have one line in our applicationContext.xml:

<bean id="bonjourService" class="org.openremote.controller.service.impl.BonjourService" lazy-init="false" />
And the service class could look like this:

package org.openremote.controller.service.impl;

import java.io.IOException;
import java.net.InetAddress;

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;

public class BonjourService {

  public BonjourService() {
    try {
      InetAddress thisIp = InetAddress.getLocalHost();
      final JmDNS jmdns = JmDNS.create();
      ServiceInfo info = ServiceInfo.create("_http._tcp.local.", "ORB", 8080, 0, 0, "orbURL=http://"+thisIp.getHostAddress()+"/controller/");
      jmdns.registerService(info);
      System.out.println("\nRegistered Service as "+info);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
Posted by mredeker at Jun 14, 2009 00:27

Bonjour is certainly interesting for the long term, and in particular for iPhone since it is supported by the SDK. It also means one less ad-hoc multicast discovery protocol on the network.

However, what is the implementation overhead for non-iPhone clients?

Feel free to provide an implementation in branches/feature. Also, using the javax.* package name extension for jmdns looks very iffy to me.

Posted by juha at Jun 14, 2009 03:41

I was also wondering about javax but maybe they thought that it would make it into java

When I tried it also on the iPhone side I will create something that can be checked in.

What other non-iPhone clients do you have in mind? For HTML and Flash we need to enter the ORB URL in the browser anyway.

Posted by mredeker at Jun 14, 2009 08:49

I still suspect that this will break if the underlying OS already has support for mDNS - which is the case in every modern Linux and Mac OS. There is only mDNS responder allowed per IP address. This means you have to disable mDNS on your Linux machine before jmDNS can start. Or is there support for the different OS mDNS APIs in jmDNS?

Posted by jfalkenberg at Jun 14, 2009 13:00

I suppose my MAC is already running the responder and it still worked without disabling anything. Could it be that the Java implementation is only starting the responder if none is disvovered and otherwise only registers the service? That would make sense, I guess.

Posted by mredeker at Jun 14, 2009 15:40

In this case I will take back my objections. Can anybody verify this under a Linux with an enabled Avahi stack?

Posted by jfalkenberg at Jun 14, 2009 18:58

Applets? did you say applets?

You stopped learning java in 96 didn't you? and it *write* once, run everywhere, and it yes it works well, very well on server side.

Again the point here is that we don't want to tie to an ORB.

Posted by marcf at Jun 14, 2009 18:58

What other non-iPhone clients do you have in mind? For HTML and Flash we need to enter the ORB URL in the browser anyway.

What kinds of clients? All kinds. Who knows what requirements Neil will come up with!

Also I think for Flash client it should be possible to do a discovery on a local network. I was under the impression that ZeroConf can direct to mDNS for local links anyway? That's why I am asking about the client cause everybody's showing how the server-side works but what does the client query translate to? The RFC seems to indicate its a DNS client lookup to a specifically allocated IP range?

Does anybody have the details?

If the above doesn't work, then Flash client starting point should be a global static URL, such as openremote.org/config, from where you download a SWF that knows how to execute the discovery on the local network (in the browser) and then fetches the local XML UI definition. Your initial configuration becomes simpler since you don't have to figure out what the URL you connect to is (but ZeroConf is supposed to solve this, although at least for Microsoft browsers seems to require a special plugin). At least on Flash you should have access to sockets I think. But you know that better than I do.

SmartHome does something like the above for browser-based discovery although I think they are using ActiveX instead of Flash.

For pure JavaScript it will be trickier.

Looking at Bonjour it looks interesting for the long term but much of an overkill for the simple ORB discovery we are targeting for 1.0. A simple multicast beacon will do. The beacon has an advantage in that the client can be fairly passive just listening for a packet, rather than having to actively connect and query DNS-SD service.

Also, Mathieu is correct in that we cannot live by one discovery mechanism alone. Having a ZeroConf for someone who is managing the rest of the network with UPnP is not as interesting as the UPnP native SSD protocol I think. In other HA setups beacons seem to be pretty well established. For example, GlobalCacheé unit sends out one. I believe they follow a format AMX has specified so they are manageable within an AMX installation. ORB should do the same.

So I wouldn't remove the existing implementation. It seems to have some issues with deployment flexibility but should turn it into a beacon-type discovery mechanism. Bonjour can be added as an extra service but it does way more than what we need for 1.0 (100+ pages of RFC after all). It becomes interesting when you don't have routed IP address (the IPv4 Link-Local RFC) or when the rest of your devices already support DNS-SD service categorization/discovery and you're using an existing browser, all your networked devices including ORB will show up.

So go ahead with the branch to build features but keep in mind the above points – we can do ZeroConf but we also need to integrate (UPnP, AMX, et al). Flash should still be able to do discovery. HTML discovery might work if the web browser already supports ZeroConf? Safari should but any others ?

Posted by juha at Jun 14, 2009 19:26

At least on Flash you should have access to sockets I think.

Nope, not if you download it from a server. Then the flash program is only allowed to connect back to the server it came from.

So go ahead with the branch to build features but keep in mind the above points - we can do ZeroConf but we also need to integrate (UPnP, AMX, et al).

Once I figured out the iPhone part I will put it into the feature branch.

By the way, how does the current implementation work? My iPhone is not discovering my ORB when I use the stuff from trunk.

Posted by mredeker at Jun 14, 2009 19:36

Nope, not if you download it from a server. Then the flash program is only allowed to connect back to the server it came from.

Can you do a signed app, like with Java? I guess you can't listen on a socket for a beacon either?

Then I guess the only option is to find ZeroConf-enabled browser.

By the way, how does the current implementation work? My iPhone is not discovering my ORB when I use the stuff from trunk.

Use the source, Luke. It's two simple classes: http://openremote.svn.sourceforge.net/viewvc/openremote/trunk/Controller/src/org/openremote/controller/net/

I'm pretty sure it's not portable though Needs some fixes for deployment configuration as well.

Posted by juha at Jun 14, 2009 20:00

See: 16. Considerations for Multiple Responders on the Same Machine

http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt

Posted by juha at Jun 14, 2009 20:13

Juha,

From what I remember the smarthome thing did the discovery in the webbased iPhone application, so that cannot have been using Flash?

Posted by jlvh at Jun 14, 2009 20:38

You're right, I just checked. They require Javascript only.

Maybe they just scan the local address space then with XMLHttpRequest. Brute-force style. That's all I can think of at the moment.

Posted by juha at Jun 14, 2009 20:49
Document generated by Confluence on Jun 05, 2016 09:29