简体   繁体   English

设备间近距离通讯

[英]Inter device near field communication

I have been working on an app to communicate between devices that come in and out of range. 我一直在开发一个应用程序,以在范围内和范围外的设备之间进行通信。

I originally looked at using iBeacon for this but have since realised android cant act as a beacon so this is no good. 我最初看是为此使用iBeacon,但自从意识到android无法充当信标以来,这就不好了。

Is there any near field technology which provides proximity updates when a device is in range that work on both android and ios (and allows android to message ios and visa versa) without using bluetooth (as the app needs to be running in the background)? 当设备在适用于android和ios的范围内(并且允许android向ios发出消息,反之亦然)时,是否有任何近场技术可提供邻近更新,而无需使用蓝牙(因为该应用程序需要在后台运行)?

I would suggest avoiding the term "near field" as that term is usually used to refer specifically to "Near Field Communication" (NFC), a specific hardware/software protocol. 我建议避免使用术语“近场”,因为该术语通常用于专门指代“近场通信”(NFC),这是一种特定的硬件/软件协议。

Some Android devices have NFC hardware. 某些Android设备具有NFC硬件。 No iOS devices do. 没有iOS设备可以使用。

Some Android devices support Bluetooth Low Energy (BLE) All iOS devices from the iPhone 4s and iPad 2 forward support BLE. 某些Android设备支持低功耗蓝牙(BLE)。iPhone4s和iPad 2之前的所有iOS设备均支持BLE。

The iBeacon protocol is built on top of BLE. iBeacon协议建立在BLE之上。 I understand that Android devices can receive iBeacon signals, but can't act as iBeacon transmitters (at least not yet.) 我了解Android设备可以接收iBeacon信号,但不能充当iBeacon发射器(至少现在还没有)。

The only other possibility I can think of would be WiFi Ad Hoc, but as far as I know iOS does not support Ad Hoc (no base station) WiFi connections. 我能想到的唯一其他可能性是WiFi Ad Hoc,但据我所知,iOS不支持Ad Hoc(无基站)WiFi连接。

Thus I think your best bet is to do custom development using BLE 4.0. 因此,我认为您最好的选择是使用BLE 4.0进行自定义开发。 You'll need to define your own peripheral codes and services. 您需要定义自己的外围设备代码和服务。

I believe that with the proper permissions, it IS possible to both transmit and receive BLE signals from the background in iOS, but I could be wrong. 我相信,有相应权限的,也可以发送和从iOS设备上的后台接收BLE信号,但我可能是错的。

You can both transmit and receive Bluetooth LE signals from the background in iOS. 您可以在iOS中从后台发送和接收Bluetooth LE信号。 You have to set (in your Info.plist file), "Required background modes" -> "App shares data using CoreBluetooth" for the phone to act as a bluetooth peripheral while in background mode, and "App communicates using CoreBluetooth" for the phone to act as a central while in background mode. 您必须设置(在Info.plist文件中)“必需的后台模式”->“应用程序使用CoreBluetooth共享数据”,以便手机在后台模式下充当蓝牙外围设备,而“应用程序使用CoreBluetooth进行通信”手机在后台模式下充当中心。

You can check out this project for an easy way to get Bluetooth LE sharing set up between iOS devices: SimpleShare - Easy Proximity-based Sharing for iOS 您可以查看此项目,以获取在iOS设备之间建立蓝牙LE共享的简便方法: SimpleShare-适用于iOS的基于邻近的轻松共享

I can't help you make the connection to Android, but presumably once you've got your iOS devices to share info via Bluetooth LE you should be able to find a way to set up the Android devices to communicate with them as well. 我无法帮助您建立与Android的连接,但是大概您使iOS设备可以通过Bluetooth LE共享信息时,您应该能够找到一种方法来设置Android设备以与之通信。 I've heard that there are some bugs with the way Android tries to talk to iOS over Bluetooth LE, but hopefully these will be fixed in a release soon. 我听说Android尝试通过Bluetooth LE与iOS进行通讯的方式存在一些错误,但希望这些错误会在不久的发布中得到修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM