简体   繁体   English

iOS核心蓝牙PIN码

[英]iOS Core Bluetooth Pin Code

I have a BLE peripheral that requires a PIN code. 我有一个需要PIN码的BLE外设。 I am connecting to this peripheral using Core Bluetooth CBCentralManager on iOS 7. 我在iOS 7上使用Core Bluetooth CBCentralManager连接到此外围设备。

When I connect to this peripheral, 'didConnectPeripheral' (central delegate) gets called before the PIN code authentication is successfully completed. 当我连接到此外围设备时, 成功完成PIN码验证之前 ,会调用“didConnectPeripheral”(中央委托)。

iOS only displays the pin code dialog after 'didConnectPeripheral' is called. iOS仅在调用'didConnectPeripheral' 显示引脚代码对话框。

I need to start interacting with the peripheral as soon as this PIN code dialog is finished and authentication process is complete. 一旦此PIN码对话框完成并且验证过程完成,我需要开始与外围设备进行交互。 How can I determine when this has happened? 如何确定何时发生这种情况?

The challenge is to only proceed after the authentication is successful, but: 挑战是仅身份验证成功继续,但是:

  1. iOS calls 'didFailToConnectPeripheral' prior to the dialog showing. iOS在对话框显示之前调用'didFailToConnectPeripheral'。
  2. iOS does not call 'didConnectPeripheral' again if the PIN code authorisation succeeded. 如果PIN码授权成功,iOS不会再次调用'didConnectPeripheral'。
  3. iOS does not call 'didFailToConnectPeripheral' again if the PIN code authorisation failed. 如果PIN码授权失败,iOS不会再次调用'didFailToConnectPeripheral'。

From the above, I have been unable to determine: 从上面,我一直无法确定:

  1. When the dialog completes. 对话框完成后。
  2. Whether the PIN code authorisation was successful. PIN码授权是否成功。

Any help would be appreciated. 任何帮助,将不胜感激。

From my experience with CoreBluetooth you will not receive any information as to whether you are authorized and when the pin code authorization is completed until you attempt an action that is unauthorized, which will fail with one of three error responses: 根据我对CoreBluetooth的使用经验,您不会收到任何关于您是否获得授权以及何时完成密码授权的信息,直到您尝试未经授权的操作,这将导致三个错误响应之一失败:

InsufficientEncryption
InsufficientAuthentication
InsufficientAuthorization

The peripheral is what determines which error you will be returned. 外围设备决定了您将返回哪个错误。 (Technically they are defined by the GATT in BLE 4.X specs but it is all implementation detail controlled on the peripheral side) (从技术上讲,它们是由GATT在BLE 4.X规范中定义的,但它是在外围端控制的所有实现细节)

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

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