3

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.

user4165247
  • 51
  • 1
  • 3
  • Have you tried just reconnecting in `didFailToConnectPeripheral`? Keep doing this until you get a successful connection. Once you have the call to `didConnectPerioheral` you are good to go. – Paulw11 Oct 21 '14 at 19:46
  • Did you find a solution for this? Even in iOS 9, it doesn't give any notification when Authentication Alert completes. –  Feb 10 '16 at 14:26
  • Hi Bhupesh, no solution as of yet. – user4165247 Aug 15 '16 at 04:54

1 Answers1

2

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)

Robert Haworth
  • 448
  • 4
  • 14