Can Android support Zeroconf/Bonjour over Bluetooth? How about TCP/IP?

那年仲夏 提交于 2019-12-03 00:06:00

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!