Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:26:29+00:00 2026-06-09T01:26:29+00:00

I scan for my peripheral like this: NSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];

  • 0

I scan for my peripheral like this:

NSDictionary *scanOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] 
                                                            forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
        // Scan for peripherals with given UUID
        [cm scanForPeripheralsWithServices:[NSArray arrayWithObject:HeliController.serviceUUID] options:scanOptions]

No problem there, I find the peripheral and are able to connect to it. As you can see I give it CBCentralManagerScanOptionAllowDuplicatesKey with bool NO to not allow for more than one peripheral, but sometimes the didDiscoverPeripheralcallback fires twice.

- (void) centralManager:(CBCentralManager *)central 
  didDiscoverPeripheral:(CBPeripheral *)peripheral 
  advertisementData:(NSDictionary *)advertisementData 
               RSSI:(NSNumber *)RSSI 
{        
if(!discovered){
    discovered = YES;
    NSLog(@"Discovered");

    [cm stopScan];

    [scanButton setTitle:@"Connect" forState:UIControlStateNormal];
}
else if(discovered){
    discovered = YES
    NSLog(@"Already discovered");
}
}

Some times I get

Discovered
Already discovered

as output in my console, and most of the times only the Discoveredmessage shows.

In my peripheral delegate I first discover services, which then call [peripheral discoverCharacteristics and the callback always occurs:

- (void) peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{

NSLog(@"Did discover characteristic for service %@", [service.peripheral UUID]);

for(CBCharacteristic *c in [service characteristics]){
    // We never get here when peripheral is discovered twice
    if([[c UUID] isEqual:myCharacteristicUUID]){

        NSLog(@"Found characteristic");

        self.throttleCharacteristic = c;

    }
}

When didDiscoverPeripheral occur twice, service becomes nilin this method, even though peripheral is not (UUID, name is still correct).

Rebooting the phone or resetting the network settings fixes the problem temporarily.

I really need to get this fixed! Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:26:32+00:00Added an answer on June 9, 2026 at 1:26 am

    Devices may return additional data while advertising. These may arrive in separate packets, arriving at different times. In this case, didDiscoverPeripheral is called first when the device is initially seen, and then again when additional information becomes available for it.

    CBCentralManagerScanOptionAllowDuplicatesKey is different. It tells CoreBluetooth whether you want to receive duplicate results when the device advertises itself again. It doesn’t prevent multiple calls to didDiscoverPeripheral for the same discovery sequence; it prevents it for repeated discovery sequences.

    Source: http://lists.apple.com/archives/bluetooth-dev/2012/Apr/msg00047.html (the Apple rep on bluetooth-dev).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

require 'coderay' puts CodeRay.scan('puts Hello, world!', :ruby).page This code will print full HTML page
I'd like to scan a variables that form vectors from white space delimited text
I would like to scan a directory for any assemblies that are not already
I would like to scan a NSString to find that text: S:027,13 Then If
I'm trying to scan a given string for a number. The number cannot be
I want to scan lines like [25, 28] => 34 I wrote a small
I need to scan a given set of URLs and get the HTTP status
I would like to scan a directory that has image files and populate my
I can scan and get the Wifi list in iPhoneOS4.0. At this time, I
After a scan disk i have a lot of CHK-files in folders like found.000,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.