Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Core Bluetooth Pin Code

I have a BLE peripheral that requires a PIN code. I am connecting to this peripheral using Core Bluetooth CBCentralManager on iOS 7.

When I connect to this peripheral, 'didConnectPeripheral' (central delegate) gets called before the PIN code authentication is successfully completed.

iOS only displays the pin code dialog after 'didConnectPeripheral' is called.

I need to start interacting with the peripheral as soon as this PIN code dialog is finished and authentication process is complete. 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.
  2. iOS does not call 'didConnectPeripheral' again if the PIN code authorisation succeeded.
  3. iOS does not call 'didFailToConnectPeripheral' again if the PIN code authorisation failed.

From the above, I have been unable to determine:

  1. When the dialog completes.
  2. Whether the PIN code authorisation was successful.

Any help would be appreciated.

like image 920
user4165247 Avatar asked Dec 10 '25 00:12

user4165247


1 Answers

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:

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)

like image 87
Robert Haworth Avatar answered Dec 12 '25 12:12

Robert Haworth