是否可以使用蓝牙连接 iOS 和安卓设备? [英] Is it possible to connect iOS and android device using Bluetooth?

查看:16
本文介绍了是否可以使用蓝牙连接 iOS 和安卓设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须制作一个应用程序来配对 iOS 和 Android 设备(iPhone 5、iPad 3、Galaxy S3、Nexus 7,它们都使用蓝牙 4.0),然后相互发送数据.

I have to make an application to pair an iOS and Android device (iPhone 5, iPad 3, Galaxy S3, Nexus 7 they all use Bluetooth 4.0) and then send data to each other.

  • 这个数据量有限制吗?我们可以发送照片或 PDF 之类的内容吗?

我已经使用 CoreBluetooth 和 Apple 的示例代码在 2 个 iOS 设备之间完成配对和发送数据 BTLE_Transfer

I've already done the pairing and sending data between 2 iOS devices using CoreBluetooth and the sample code from Apple BTLE_Transfer

据我所知,外设(服务器)可以向中央(客户端)做广告.这个中心在自己周围扫描,然后通过查找所通告的服务的 UUID 来尝试找到服务器.

Of what i understood, a Peripheral (Server) can Advertise to a Central (Client). This central is scanning around itself, and then try to find the Server by looking for the UUID of the service advertised.

当我在 Android 上创建服务器时,它正在等待连接(侦听),我知道服务器的 UUID 和 mac 地址.但是当我用我的 iPhone 扫描时(当然是扫描相同的 UUID),我找不到服务器.

When i make a Server on Android, it is waiting for a connection (listening), i know the UUID and the mac address of my Server. But when i scan with my iPhone (scanning for the same UUID of course), i can't find the server.

  • Android 服务器是否有可能像 iOS 上的 Peripheral 那样做广告?
  • 或者我的 iPhone 客户端是否有可能使用服务器的 mac 地址进行连接?

推荐答案

问:这个数据量有限制吗?我们可以发送照片或 PDF 之类的内容吗?

低功耗蓝牙未针对发送大量数据进行优化,也未针对流媒体进行优化.它更适合定期发送小块数据(例如温度读数、时间等).请查看这个答案 了解 BLE 传输与经典蓝牙的不同之处.话虽如此,您仍然可以通过 BLE 发送大量数据,而且数据量是无限的.但是,这最终可能会变得不可靠且速度相对较慢.

Bluetooth Low Energy was not optimised for sending large amounts of data, nor is it optimised for streaming. It is more suitable for sending small chunks of data periodically (e.g. temperature readings, time, etc). Please have a look at this answer to understand how BLE transfer is different from classic Bluetooth. That being said, you can still send large amounts of data over BLE, and the amount of data is unlimited. However, this might end up being unreliable and relatively slow.

问:那么Android服务器有没有可能像iOS上的Peripheral那样做广告?

作为服务器/客户端与作为外围设备/中央设备完全不同:-

Being a server/client is a completely different thing from being a peripheral/central:-

外围设备/中央 决定了连接的方式.中央设备应该发起连接.外围设备应通告并等待连接请求.

Peripheral/central dictates how the connection is made. A central device should initiate the connection. A peripheral device should advertise and wait for a connection request.

客户端/服务器 规定了数据的分布方式.Gatt 服务器保存数据.Gatt 客户端可以读取、写入或收到此数据的通知(获得连续的读数流).大多数情况下,服务器也是外围设备,但这不是强制性的.

Client/Server dictates how the data is distributed. The Gatt Server holds the data. The Gatt Client can read, write or be notified (getting a continuous stream of readings) of this data. In most cases, the server is also the peripheral, but this is not mandatory.

所以回答你的问题,是的,服务器可以像 iOS 上的外围设备一样做广告.但是,对于 Android,此功能尚不可用,并将成为下一个版本 (Android L) 版本的一部分.请参阅此答案了解更多信息.

So to answer your question, yes, the server can advertise like the peripheral on iOS. However, for Android, this feature is not yet available and will be part of the next version (Android L) release. Please see this answer for more information.

问:或者我的 iPhone 客户端是否有可能使用服务器的 mac 地址进行连接?

据我所知,在 coreBluetooth 中,您需要外围设备的 UUID,而不是 MAC 地址才能连接到它.您不需要知道从外围设备通告的服务.最好的办法是扫描外围设备,然后连接到具有 UUID 和/或您知道属于您的外围设备的广告数据的设备.

As far as I know, in coreBluetooth you would need the UUID, not the MAC Address, of a peripheral device to connect to it. You do not need to know the services being advertised from the peripheral device. Your best bet would be to scan for peripheral devices, and then connect to the one with the UUID and/or the advertising data that u know belong to your peripheral.

我希望这会有所帮助.

这篇关于是否可以使用蓝牙连接 iOS 和安卓设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆