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

后端 未结 3 1334
予麋鹿
予麋鹿 2021-02-04 02:27

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 Andr

相关标签:
3条回答
  • 2021-02-04 02:44

    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

    0 讨论(0)
  • 2021-02-04 02:44

    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.

    0 讨论(0)
  • 2021-02-04 02:48

    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.

    0 讨论(0)
提交回复
热议问题