设备的BLE扫描服务,而无需连接到它 [英] Ble Scan service of a device without connecting to it

查看:837
本文介绍了设备的BLE扫描服务,而无需连接到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望扫描BLE的一些设备。
我只是想表明我的设备,所以知道我得到的设备的名称,如果是好的我把它放在我的名单。

I want to scan some device with BLE. I only want to show my device, so for know I get the name of the device and if it is the good one I put it in my list.

if (device.getName().contains(DEVICE_NAME)) {
        mDevices.put(device.hashCode(), device);
        invalidateOptionsMenu();
    }

我的问题是,如果我改变我的设备的名称这一检查将是错误的。
所以我看,如果有可能获得一些服务,我加做的东西,是不会改变的检查一些UUID。
而唯一的办法就是连接到该设备做了
device.connectGatt(这一点,假的,mGattCallback);
经与关贸总协定我发现服务,但是,是否有可能发现从设备的一些服务不接法将其

My problem is that if I change the name of my device this check will be false. So I look if it was possible to get some uuid of some services that I add to do the check with something that would not change. And the only way is to connect to the device doing a device.connectGatt(this, false, mGattCallback); and after with the gatt I discover service but, is it possible to discover some services from a device without connectiong to it ?

推荐答案

我不与Android背景,但我有多么BLE作品的理解。

I am not with the android background, but I have understanding of how BLE works.

特性<一个href=\"https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_access.xml\"相对=nofollow>设备名称,UUID = 0x2A00 被捆绑成<一个href=\"https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_access.xml\"相对=nofollow> GAP(通用访问),UUID = 0x1800 。
的间隙总是从GATT服务器通告报文内广播。结果
关贸总协定客户应运行发现扫描,以收到广告和解析通告报文接收GAP描述符。当你这样做,从技术上来讲连接尚未作出。

The characteristics Device Name, UUID=0x2A00 is bundled into GAP (Generic Access), UUID = 0x1800. The GAP is always broadcasted within the advertisement packet from the GATT Server.
A GATT Client should run a discovery scan to receive the advertisement and parse the advertisement packet to receive the GAP descriptor. While you are doing this, technically speaking the connection is yet to be made.

Adressing为:

Adressing to:

如果我改变我的设备的名称,该检查将是错误的,所以我看,如果有可能获得一些服务,我加做的东西,是不会改变的检查一些UUID。

If I change the name of my device this check will be false, So I look if it was possible to get some uuid of some services that I add to do the check with something that would not change.

假设你希望你的应用程序只能连接到特定的一组设备,有一些独特的识别。比方说,你所配置的启用BLE-数字笔只能连接到您的应用程序,并没有其他设备的小工具应该能够与您的应用程序连接。如果是这样的用例,如果你有自由配置BLE装置在GATT服务器,那么你可以加入关贸总协定服务器上的服务GAP一些自定义的特性,这将是独一无二的那些设备。不用说,你将不得不生成该特征的128位定制UUID和UUID会知道你的应用程序也是如此。这更像是一个变通的解决方案。

Assuming that you want your app to connect only to a particular set of device that has some unique identification. Say for example, a BLE-enabled digital pen configured by you should only connect to your app and no other device gadget should be able to connect with your app. If that is the use case and if you have the liberty to configure the GATT server on the BLE device then you can add some custom characteristics in GAP service on GATT server which will be unique to those devices. Needless to say, you will have to generate a 128-bit custom UUID for that characteristics and the UUID will be known to your application as well. This is more like a work-around solution.

请参见蓝牙发展门户了解更多详情。

这篇关于设备的BLE扫描服务,而无需连接到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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