检查蓝牙低耗能信标是在附近的机器人 [英] Check if Bluetooth Low Energy Beacons are nearby in Android

查看:216
本文介绍了检查蓝牙低耗能信标是在附近的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我想将程序Android应用程序可以检测,如果我进入或离开一个区域。每个区域(​​可以说建筑)的BLE灯塔的广告模式。我知道了信标MAC adressess。 该应用程序将在后台运行,并应是节能。它并不重要立即识别的区域中,但5分钟的窗口就足够了。

I want to programm an android app which can detect if I enter or leave a region. Each region (lets say a building) has a BLE Beacon in advertising mode. I do know the mac adressess of the beacons. The app shall run in background and shall be energy efficient. It is not important to recognize the region immediately, but a window of 5 minutes would be sufficient.

  • On http://developer.android.com/guide/topics/connectivity/bluetooth-le.html its said that you should not "scan on a loop" but is there any other way to realize region enter/leave events?

另外,我有点困惑的UUID,服务和连接。它是正确的,这些问题的不可以有关我的问题?

Also I am bit confused about UUIDs, Services and connections. Is it correct that these issues are NOT relevant to my question?

相关问题

我想知道,似乎是一个普遍的问题:

What i want to know seems to be a common question:

  • <一个href="http://stackoverflow.com/questions/19914244/creating-background-services-for-bluetooth-low-energy-on-android?rq=1">Creating蓝牙低能量的后台服务在Android
  • <一个href="http://stackoverflow.com/questions/22535654/how-exactly-does-android-and-ios-scan-the-beacon-without-battery-issue">how究竟Android和iOS扫描不带电池问题的灯塔?
  • <一个href="http://stackoverflow.com/questions/19638118/bluetooth-low-energy-android-search-in-background">Bluetooth低能量的Andr​​oid - 在后台搜索
  • Creating background services for Bluetooth low energy on Android
  • how exactly does android and ios scan the beacon without battery issue?
  • Bluetooth Low Energy Android - Search in Background

但关于Android的iBeacon库,这是我不希望使用大部分的答案。

but most of the answers are regarding the "Android iBeacon Library", which I don't want to use.

推荐答案

即使你不知道要使用Android iBeacon库,它可能是一个好主意,看它的源$ C ​​$ c和复制的想法和或从code片段,这样你就可以得到的贡献者和我所学,同时构建它的教训的优势。这就是开源的优势。

Even if you do not sure want to use the Android iBeacon Library, it is probably a good idea to look at its source code and copy ideas and or code snippets from it so you can get the advantage of the lessons that the contributors and I have learned while building it. That is the advantage of open source.

有关您的问题具体教训:

Specific lessons related to your questions:

  • 是的,你需要某种逻辑,启动和停止蓝牙LE定期扫描,这样你就需要在最广泛的意义上的循环。我相信你引用的文件只是指的是Android的BLE扫描的API,它具有在开始扫描一次,然后得到回调发现每个设备的同步性。对于最简单的用例,因此,循环是适得其反。

  • Yes, you will need some kind of logic that starts and stops Bluetooth LE scans periodically, so you do need as "loop" in the broadest sense. I believe the documentation you reference is just referring to the asynchronous nature of Android's BLE scanning APIs, which have you start a scan once, then get callbacks for each device discovered. For the simplest use case, therefore, a loop is counter-productive.

是的,如果你连接到一个BLE装置,它将停止广告。所以,除非你需要在广告不是适合来交换更多的数据,不这样做。或者只连接了非常短的时间。

Yes, if you connect to a BLE device it will stop advertising. So unless you need to exchange more data than fits in the advertisement, do not do this. Or only connect for as very short time period.

术语UUID与BLE标两个主要的含义。它意味着一个服务的UUID,其是由BLE设备提供的总协定的服务的唯一标识符。它也可以指一个ProximityUUID,这对于信标的三部分组成的标识符获取在广告发送的最显著部苹果iBeacon特定术语。这两个词无关彼此。除非你犯了一个连接的信标(见上文)的服务UUID和关贸总协定服务不相关的任务。

The term UUID has two main meanings with BLE beacons. It can mean a Service UUID, which is a unique identifier of a GATT service offered by BLE device. It can also mean a ProximityUUID, which is an Apple iBeacon-specific term for the most significant part of the three-part identifier of the beacon that gets sent in the advertisement. The two terms have nothing to do with one another. Unless you make a connectable beacon (see above) the Service UUID and GATT Service are not relevant to your task.

您是否打算检测标准iBeacons或定制BLE灯塔这是不是从你的问题清楚。以上这些问题的答案是更一般的情况,但知道标准iBeacons是无连接的,不依赖于已知或静态蓝牙MAC地址。虽然你的问题是具体到Android,如果你建立要不断努力与iOS定制的灯塔的解决方案,知道的iOS打乱蓝牙MAC地址,它的API,让你永远无法看到真实的MAC地址。

It is not clear from your question whether you plan to detect standard iBeacons or a custom BLE beacon. The answers above are for the more general case, but know that standard iBeacons are connectionless and do not rely on known or even static Bluetooth Mac addresses. While your question is specific to Android, if you build a custom beacon solution that you want to ever work with iOS, know that iOS scrambles Bluetooth Mac addresses in its APIs, so you can never see the real Mac address.

如果您正在构建您 Android的唯一解决方案能够使用蓝牙的Mac作为iBeacon标识。但是,如果你这样做,然后意识到你的信标将有标识符都是静态的,不能在很多BLE平台上方便地进行配置。这是一个原因,苹果的iBeacon使用一个单独的ProximityUUID /主/次方案嵌入在广告中一盏明灯标识符。

If you are building an Android-only solution you can use the Bluetooth Mac as the iBeacon identifier. But if you do so, then realize that your beacons will have identifiers that are static and cannot be easily configured on many BLE platforms. This is one reason Apple's iBeacon uses a separate ProximityUUID/major/minor scheme as a beacon identifier embedded in the advertisement.

这篇关于检查蓝牙低耗能信标是在附近的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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