这是indexloc提供的服务,不要输入任何密码

How and when to use .confirmAuthorization option with AccessorySetupKit

I am developing an app that communicates with external BLE device over GATT. The device has a secure-read characteristic exposing some of it's data and requires pairing/bonding in order to communicate with it.

I was able to pair and connect with the device using AccessorySetupKit and .bluetoothPairingLE option:

 let descriptor = ASDiscoveryDescriptor()
 descriptor.bluetoothServiceUUID = CBUUID(string: serviceUUID)
 descriptor.supportedOptions = [.bluetoothPairingLE]
 let picketItem = ASPickerDisplayItem(name: name, productImage: image, descriptor: descriptor)

In this case when setting up accessory, I was prompted to compare passkeys and after confirming I can read the characteristic etc.

Then I tried adding .confirmAuthorization to picker item and problems started:

 let descriptor = ASDiscoveryDescriptor()
 descriptor.bluetoothServiceUUID = CBUUID(string: serviceUUID)
 descriptor.supportedOptions = [.bluetoothPairingLE]
 let picketItem = ASPickerDisplayItem(name: name, productImage: image, desc
 pickerItem.setupOptions = [.confirmAuthorization]

When setting up, I can see a passkey to be confirmed, but when confirmed the setup ui get's suck in loading state. Under the hood in logs, I can see that my app has connected to peripheral and was able to read the characteristic.

I am unsure why the ui is stuck in loading state in this case. What is the difference when using .confirmAuthorization option and what should be the proper flow of events to setup accessory and then access protoected characteristic?

.confirmAuthorization is meant for pairing to be completed before the Setup UI is displayed.

If the Setup UI is hanging, this is something the ASK team should take a look at. Whether this is due to the some pattern in your code is difficult to determine from a snippet too.

I would suggest to file a bug report about this so we can see what is actually going on with the timing of the pairing vs the UI, and so on.

First, please go to https://developer.apple.com/bug-reporting/profiles-and-logs/ and follow the instructions for Accessory Setup Kit for iOS to install a logging profile on your device.

Then, once the logging profile is installed, reproduce the problem, keeping track of the actual time of the actions you take and the result you see.

Once the problem is reproduced, follow the instructions at the above link to trigger a sysdiagnose.

Then create a bug report at https://feedbackassistant.apple.com and include all the info, and attach the sysdiagnose to it. If you have a small focused sample project that demonstrates the problem, that would be helpful to see if there is an issue with your usage, and to repro the issue easily.

Once done, please respond with the Feedback ID, and @tag me when you do in your response, so I can associate the bug report correctly.

Bug Reporting: How and Why? has tips on creating a successful bug report.


Argun Tekant /  DTS Engineer / Core Technologies

How and when to use .confirmAuthorization option with AccessorySetupKit
 
 
Q