21

On iPhone if I create custom service for example "_test._tcp.local." in Bonjour I can seek/broadcast this service through WiFi or/and Bluetooth.

It is possible on Android ?

I know that there is jmDNS but from what I understand it works only through WiFi/Network, not Bluetooth.

Thanks

EDIT by Seva Alekseyev, who offered the bounty: I'm not after workarounds (like Zeroconf sans Bluetooth or Bluetooth sans Zeroconf). I'm after the real thing.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
dancio
  • 243
  • 3
  • 9
  • I'm very curious to know the answer regarding bluetooth...is JmDNS alowed to detect bonjour services exposed by bluetooth ?? – fvisticot Mar 03 '12 at 14:15
  • Let start from the basics: is there a way to run TCP/IP over Bluetooth in Android? If so, one might be able to sic JmDNS on that particular interface. Maybe just the exposure, not the discovery, or vice versa. – Seva Alekseyev Aug 01 '12 at 14:01
  • Related: [TCP/IP over Bluetooth in Linux](http://giovanni.wordpress.com/2007/04/06/how-to-use-tcpip-over-bluetooth/) – Seva Alekseyev Aug 01 '12 at 15:00
  • Related: [same question on Android StackExchange](http://android.stackexchange.com/questions/6072/is-it-possible-to-have-a-tcp-ip-network-using-bluetooth) – Seva Alekseyev Aug 01 '12 at 15:00
  • Related: http://stackoverflow.com/questions/9367055/ios-android-tcp-ip-over-bluetooth – Seva Alekseyev Aug 01 '12 at 15:16
  • Yes, I think using the PAN profile should do it.. – Ron Aug 02 '12 at 15:33
  • @userSeven7s: elaborate please. The bounty may be yet yours! – Seva Alekseyev Aug 04 '12 at 19:11
  • Take a look at this thread about bonjour over bluetooth in iphone..http://stackoverflow.com/questions/3350094/how-does-bonjour-over-bluetooth-work – Ron Aug 05 '12 at 08:23
  • 1
    PAN profile is not yet released for android. The code is present in the project but hidden. There are classes like BluetoothPan for PAN profile but but not to be used by developers – Ron Aug 05 '12 at 10:19

3 Answers3

3

Not on bluetooth, because Android currently doesn't support TCP/IP over bluetooth, and Android's native NSD support (network service discovery) works over IP.

It DOES, however, work over Wi-Fi. Also, Android supports service discovery over Wi-Fi Direct, which gives you greater range and battery efficiency than bluetooth. For a guide on how to integrate service discovery into a wi-fi direct enabled application, check out the Android Training lesson.

Portions of this answer are duplicated from our Dear Android video response to this question

Alexander Lucas
  • 22,171
  • 3
  • 46
  • 43
0

You can use BluetoothSocket and BluetoothServerSocket to create TCP like sockets over Bluetooth.

Here is a sample of android dnssd : https://github.com/twitwi/AndroidDnssdDemo

You may need to modify the jmdns library such that it creates bluetooth sockets if bluetooth is ON, otherwise creates simple sockets. Encapsulate the socket communication in a different class that creates socket conditionally.

Ron
  • 24,175
  • 8
  • 56
  • 97
  • Um, I'm ultimately after iOS-to-Android and vice versa service discovery. I don't think those would interoperate, as the iOS implementation is TCP/IP-based. – Seva Alekseyev Aug 05 '12 at 15:03
  • yes, Thats a high probability, but the documentation says its similar to TCP sockets.. So give it a try.. – Ron Aug 05 '12 at 15:59
  • The sample doesn't claim Bluetooth compatibility and does not implement it. I had JmDNS integrated in my app for a while now; over TCP/IP on WiFi it talks to iOS fine. Now, just because the interface is similar, doesn't mean RFCOMM sockets can talk to TCP/IP ones. Those are different transports. I don't know enough about BT to know if it's possible to reimplement TCP/IP from scratch on top of Android's stack. – Seva Alekseyev Aug 05 '12 at 16:14
  • Sample rfcomm implementation... http://people.csail.mit.edu/albert/bluez-intro/x502.html – Ron Aug 06 '12 at 13:07
  • Thanks, that's not helping at all. Need I restate the original goal yet again? By the way - is there a native interface to Bluetooth that's on lower level than sockets? – Seva Alekseyev Aug 06 '12 at 13:32
  • 1
    You can talk directly to the Bluetooth microcontroller and speak HCI to it, which lets you do anything, but that's only possible if you're root. The kernel's public API to all this is firmly socket based. Unfortunately raw sockets in Bluetooth aren't very useful and in order to do anything interesting you also have to talk to the local SDP server, which speaks godsdamned dbus and not any sensible protocol. – David Given Aug 06 '12 at 15:37
  • You need to use an implementation of PAN profile.. not sure how.. Try bluez – Ron Aug 06 '12 at 15:55
  • @DavidGiven: can you elaborate? Sockets as in POSIX, with PF_BLUETOOTH? Where's the interface to SDP documented? – Seva Alekseyev Aug 06 '12 at 17:02
  • @userSeven7s: bluez requires root IIRC. I'm not going there. – Seva Alekseyev Aug 06 '12 at 17:09
  • @Seva Yes, Posix. The Bluez documentation is appalling, alas, and there's no man pages or anything useful like that; I mostly work off http://people.csail.mit.edu/albert/bluez-intro/x502.html and the headers. It's probably not what you're looking for, though. The low-level SDP interface isn't accessible from Android and while raw sockets work without being root they aren't much use unless you know the Bluetooth address and port you want to connect to, which you don't. – David Given Aug 06 '12 at 21:30
  • @SevaAlekseyev, have you found any solution to this? – ticofab Jun 24 '13 at 21:51
0

There's a couple of reasons why this is not possible currently. The one most related to your question is that - as you probably experienced - jmDNS requires a TCP/IP link to publish or browse services (it requires an IP address to bind to). As the other answers & comments state, you'd need an established PANU link for that, which Android currently doesn't provide.

The other reasons it will not work are:

  • Apple uses a couple of mechanisms to assure iOS devices will only talk to other iOS devices. So even if you'd get Android into talking Bonjour-over-Bluetooth, it would only work Android-to-Android.
  • Apple certified devices in the MFi program have a special crypto chip which is supplied by Apple. I'm not sure if this applies to Bonjour-over-Bluetooth connections as well, but I'd assume it does.

You could instead look into using Bluetooth 4 LE - at least there's an Apple API for that starting in iOS 5 providing a Slave profile, and extended to support a Master profile in iOS 6.

domsom
  • 3,163
  • 1
  • 22
  • 27