在使用蓝牙连接到设备之前,如何请求身份验证? [英] How to ask for authentication before connect to devices using bluetooth?

查看:512
本文介绍了在使用蓝牙连接到设备之前,如何请求身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要制作演示应用程序,其中包含以下功能.

I want to make demo application, which contains following features.

  1. 在我的设备蓝牙范围内搜索并显示设备列表.
  2. 连接(配对)所选设备.
  3. 然后共享字符串数据.

为此,我正在使用核心蓝牙框架(中央和外围设备类).使用该工具,我可以搜索设备,连接设备并传输字符串数据.

For doing that I am using core Bluetooth framework(Central and peripheral classes). using that I am able to search devices, connect devices and transfer string data also.

但是我无法在配对之前对设备进行身份验证(当我调用connect方法时,会直接向我显示连接状态).在iOS中如何处理?

but I am not able to authenticate devices before pairing(when I call connect method it is directly shown me connected status). how is it handled in ios?

还请建议我使用正确的路径,或者我需要使用另一个库来实现此功能.

also please suggest me I am on the right path or I need to use another library to implement this functionality.

推荐答案

对于其他撞墙撞头的人,我有解决此问题的方法.这就像为BLE设备上的特征设置AUTHENTICATION required标志一样简单.设置该标志后,您需要使用iOS设备尝试从该服务/特征读取.请求读取后,BLE设备将发送回一条失败消息,然后提示iOS显示PAIRING/BONDING弹出窗口.之后,您就是黄金.

For anyone else beating their head against a wall, I have the solution to this issue. It's as simple as setting the AUTHENTICATION required flag for a characteristic on your BLE device. Once that flag is set, you need to attempt a READ from that service / characteristic using the iOS device. Once the read is requested, the BLE device will send back a failure message which then prompts iOS to display the PAIRING / BONDING popup. After that, you're golden.

以下是赛普拉斯BLE设备权限组的示例.那里的大多数BLE嵌入式设备的设置都是相似的.

Here is an example of a Cypress BLE device permission group. The settings are similar for most BLE embedded devices out there.

这篇关于在使用蓝牙连接到设备之前,如何请求身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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