Bluetooth 4.0 Low Energy and iOS: How do I detect if device is bondable or not?

女生的网名这么多〃 提交于 2019-12-11 03:09:47

问题


Is it possible, using corebluetooth framework, to detect if peripheral is bondable?

Should I implement the failed to connect to delegate?


回答1:


There is nothing at this time. With later versions of BLE, bonding information (GAP modes) is in the GAP profile, but not one bit of that information is available to you via CoreBluetooth. With the exception of some advertising data and limited scan response data, It only provides GATT information and below.

You could read any desired characteristic properties to see if it requires encryption (CBCharacteristicPropertyNotifyEncryptionRequired), which means you need to have a trusted connection (paired) to access it. That's as close as you're going to get for now.

You shouldn't be prompted to pair when you first connect, so didFailToConnectPeripheral won't help here. You'll only be prompted to pair after you attempt to read one of the encrypted characteristics. So, you should still know before the user is prompted if you check the properties of the characteristic first.

This from Apple's Bluetooth Accessory Design Guidelines:

The accessory should not request pairing until an ATT request is rejected using the Insufficient Authentication error code. See the Bluetooth 4.0 specification, Volume 3, Part F, Section 4 for details.

If, for security reasons,the accessory requires a bonded relationship with the Central,the Peripheral should reject the ATT request using the Insufficient Authentication error code, as appropriate. As a result, the Apple product may proceed with the necessary security procedures.



来源:https://stackoverflow.com/questions/28351579/bluetooth-4-0-low-energy-and-ios-how-do-i-detect-if-device-is-bondable-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!