Connection problems when using iPhone as peripheral

廉价感情. 提交于 2019-12-04 15:38:28

The 20 second delay before diconnection is a classic symptom of security manager issues.

The Security Manager Protocol is a new block added for BLE. The Link Layer will allow a connection, then there is a 20 second gap while the Security Manager has a look to see if it has stored the Long Term Keys that it should have stored after pairing with the device it is now connected to. If it doesn't find those keys, then it will kill the Link Layer connection.

If you don't need a secure connection, then remove the 'EncryptionRequired' attributes when you create your device's attributes:

self.cp_charac = [[CBMutableCharacteristic alloc]
                  initWithType:[CBUUID UUIDWithString:CONTROL_POINT_CHARAC]
                  properties:CBCharacteristicPropertyRead | CBCharacteristicPropertyWrite |
                  CBCharacteristicPropertyWriteWithoutResponse | CBCharacteristicPropertyNotify
                  value:nil
                  permissions:CBAttributePermissionsReadEncryptionRequired | CBAttributePermissionsWriteEncryptionRequired ];

You can see them in the snippet above under permissions.

Page 16 of Security_Manager.pdf from BT SIG website (doc by thomas.t.muller@nmp.nokia.com).

Also look in the BT Spec, https://www.bluetooth.org/en-us/specification/adopted-specifications Page 631 of Core_v4.1.pdf states

If the Security Manager Timer reaches 30 seconds, the procedure shall be con- sidered to have failed, and the local higher layer shall be notified.

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