简体   繁体   English

使用GATT的Android低能耗蓝牙

[英]Low Energy Bluetooth in Android using GATT

I've done a lot of reading about LE Bluetooth and GATT but I'm still struggling to fully understand what GATT is. 我已经阅读了很多有关LE蓝牙和GATT的文章,但我仍在努力完全理解GATT是什么。 To make it simple I'd like to express how I'd like my app to work, and simply be told if it's possible or not? 为简单起见,我想表达一下我希望我的应用程序如何工作,并仅告诉您是否可行? The basic premise is it will be used as a location tracker and beacons (maybe iBeacons specifically) will be placed around the building and whenever you enter the range of the beacon a message will be sent to the server from the phone. 基本前提是它将用作位置跟踪器,并在建筑物周围放置信标(也许是iBeacons),并且每当您输入信标范围时,都会从电话向服务器发送消息。 The idea is that it doesn't need to scan, the phone just simply listens and whenever a beacon advertises, the phones in range will hear this and raise an event. 这个想法是,它不需要扫描,电话只需要听,只要信标做广告,范围内的电话就会听到并引发事件。

Scenario: 场景:

  • Client downloads the app and enters the building for the first time. 客户端下载应用程序,并首次进入建筑物。
  • The building has a beacon in every room, advertising every 5 seconds for example. 该建筑物在每个房间都有一个信标,例如每5秒发布一次广告。
  • When the client walks into a room and is in range of a beacon, the phone will get an unfriendlier version of the message "Beacon 2 has an RSSI of -87". 当客户走进房间并处于信标范围内时,电话将收到消息“信标2的RSSI为-87”的不友好版本。
  • When they leave the room they will no longer hear the message and so will do nothing until it hears another message from a beacon. 当他们离开房间时,他们将不再听到消息,因此在听到信标发出的另一条消息之前将什么也不做。

NOTE: This scenario doesn't involve any scanning, looping or pairing. 注意:这种情况下不涉及任何扫描,循环或配对。 The phone will just know it has to listen for LE Bluetooth messages. 手机只会知道它必须收听LE蓝牙消息。

So, is this possible? 那么,这可能吗? From what I've seen it seems like you need to scan and connect with each beacon using GATT before you can receive data from them. 从我所看到的情况来看,您似乎需要使用GATT扫描并与每个信标连接,然后才能从它们接收数据。

Any infomation of this matter is greatly appreciated, thankyou! 非常感谢您提供有关此事的任何信息,谢谢!

Yes, this is possible. 是的,这是可能的。 Some high level scenario for a merchant store with beacon. 带有信标的商家商店的一些高级方案。 1) app client needs to have uuid or major id of beacons to be stored locally. 1)应用客户端需要将uuid或信标的主ID本地存储。 2) merchant store with same uuid or major id will broadcast messages. 2)具有相同uuid或主要ID的商户商店将广播消息。 3) phone OS keeps listening those messages when entered into geofence, OS will pass on these messages to the apps who are registered for beacons listening. 3)手机操作系统进入地理围栏后会继续监听这些消息,操作系统会将这些消息传递给已注册信标监听的应用程序。 4) your app will match the uuid embed in the message and identify if its meant for it. 4)您的应用程序将匹配嵌入消息中的uuid,并确定其意图。 5) if message uuid does not match with uuid on client then app will not consume this message. 5)如果消息uuid与客户端上的uuid不匹配,则应用程序将不使用此消息。 6) if message uuid matches then client will consume the message and display it on device, even your app is not running at that point of time. 6)如果消息uuid匹配,则客户端将使用该消息并将其显示在设备上,即使此时您的应用程序未运行。

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

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