ios - AccessorySetupKit picker doesn't show accessory unless previously paired in Setting app first - Stack Overflow

admin2025-04-30  0

I'm using AccessorySetupKit to discover and connect to a bluetooth device via BLE pairing.

I added Info.plist key to filter bluetoothServiceUUIDs like so and my descriptor is defined like :

ASDiscoveryDescriptor *descriptor1 = [[ASDiscoveryDescriptor alloc] init];
    descriptor1.bluetoothServiceUUID = [CBUUID UUIDWithString:serviceUUID]; // Replace with actual UUID
  
    ASPickerDisplayItem *item1 = [[ASPickerDisplayItem alloc] initWithName:@"Item 1"
                                                               productImage:[UIImage systemImageNamed:@"person"]
                                                                 descriptor:descriptor1];

  
  
  [self.session showPickerForDisplayItems:@[item1] completionHandler:^(NSError * _Nullable error) {
     
    if (error) {
        NSLog(@"Failed to show picker: %@", error.localizedDescription);
      }
  }];

The picker can't find the device unless it has been paired outside of the app (paired by another app like "BLE scanner" app).

My bluetooth device is NOT advertising its service UUID in the advertising section when scanning the device. I found the UUID in Services section and pick a custom service UUID available.

I tried on a device that advertise directly its serviceUUIDs in advertising section and it work perfectly fine without previous pairing outside the app.

I'm using AccessorySetupKit to discover and connect to a bluetooth device via BLE pairing.

I added Info.plist key to filter bluetoothServiceUUIDs like so and my descriptor is defined like :

ASDiscoveryDescriptor *descriptor1 = [[ASDiscoveryDescriptor alloc] init];
    descriptor1.bluetoothServiceUUID = [CBUUID UUIDWithString:serviceUUID]; // Replace with actual UUID
  
    ASPickerDisplayItem *item1 = [[ASPickerDisplayItem alloc] initWithName:@"Item 1"
                                                               productImage:[UIImage systemImageNamed:@"person"]
                                                                 descriptor:descriptor1];

  
  
  [self.session showPickerForDisplayItems:@[item1] completionHandler:^(NSError * _Nullable error) {
     
    if (error) {
        NSLog(@"Failed to show picker: %@", error.localizedDescription);
      }
  }];

The picker can't find the device unless it has been paired outside of the app (paired by another app like "BLE scanner" app).

My bluetooth device is NOT advertising its service UUID in the advertising section when scanning the device. I found the UUID in Services section and pick a custom service UUID available.

I tried on a device that advertise directly its serviceUUIDs in advertising section and it work perfectly fine without previous pairing outside the app.

Share Improve this question edited Apr 21 at 18:11 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Jan 5 at 1:01 EliteSquadronEliteSquadron 211 silver badge3 bronze badges 1
  • If your peripheral isn't advertising the service you are looking for I wouldn't expect it to show in accessory setup. That is how it identifies a candidate accessory. – Paulw11 Commented Jan 5 at 1:44
Add a comment  | 

1 Answer 1

Reset to default 1

My bluetooth device is NOT advertising its service UUID in the advertising section when scanning the devic

Your peripheral needs to advertise the service that you have provided to your ASDiscoveryDescriptor in order for the accessory picker to show it. If the service isn't being advertised then a connection is required to interrogate the services data. That is why the accessory shows up after you have paired it using some other process

转载请注明原文地址:http://anycun.com/QandA/1746022424a91469.html