• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scan BLE device in the background in iPhone 4S
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scan BLE device in the background in iPhone 4S


  • Subject: Re: Scan BLE device in the background in iPhone 4S
  • From: Joakim Linde <email@hidden>
  • Date: Wed, 15 Feb 2012 08:12:25 -0800


Hi Kai,

From a Bluetooth LE specification perspective, you can have services that are broadcast only services. One example would be thermostat advertising the temperature in a room. It would be non-connectable and without any GATT services or characteristics. The advertising data would contain a temperature service and the temperature value as service data. 

Thanks,
Joakim

On Feb 15, 2012, at 8:01 AM, Kai Wang (STC) wrote:

Hi  Bob,
 
Thank you for the information!
 
I don’t see the requirements of not null serviceID array in CoreBluetooth document for scanForPeripheralsWithServices works in the background. I can understand if it is required for saving power by not bothering the application with non-relevant BLE devices.
 
But the interesting thing is that for a device running in broadcaster role, it does not implement any service.  I’m not sure if it works in the background by including service UUID AD type in the BLE device’s advertisement and use the UUID to do filtering with scanForPeripheralsWithServices.  I can take a try to see if it works and any insight/comment is appreciated!
 
Thanks,
Kai
 
>hi kai,
> 
>correct me if i'm wrong, but i believe you need to pass an array of (at least one) service IDs to 'scanForPeripheralsWithServices'....  passing 'nil' will indeed work in the foreground, but not in the background as i understand it....
> 
>bob.
 
>On 2/15/2012 2:43 AM, Kai Wang (STC) wrote:
>> 
>> Hi all,
>> 
>> I'm using CoreBluetooth framework to discover the BLE device running
>> in pure broadcaster role on iPhone 4S.
>> 
>>The problem is: the code works fine when it runs in the foreground.
>>But the advertisement of the BLE device is not able to discovered when
>>the application is switched to the background (didDiscoverPeripheral
>>is never called). The application comes back to find advertisements
>>when it is switched back from the background to the foreground.
>> 
>>According to the thread "How to make BLE app work on background of
>>iPhone4S"
>> <http://lists.apple.com/archives/bluetooth-dev/2011/Dec/msg00012.html>
>>, it is supported to do scanning in the background. And I did add the
>>background mode entry  "bluetooth-central"  to UIBackgroundModes in
>>the app's info.plist. And the code doing scan is as below:
>> 
>>NSDictionary *options = [NSDictionary
>>dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:TRUE],
>>CBCentralManagerScanOptionAllowDuplicatesKey, nil];
>> 
>> [self.CM scanForPeripheralsWithServices:nil options:options];
>> 
>>And in the didDiscoverPeripheral delegate, the UI is updated through
>>the code in another class like:
>> 
>>If([NSThread isMainThread] == true) {
>> 
>>   [self updateScanningStatus];
>> 
>>}
>> 
>>else {
>> 
>>     [NSObject
>> performSelectorOnMainThread:@selector(updateScanningStatus)
>> withObject:nil waitUntilDone:No];
>> 
>> }
>> 
>> Hope someone here could help me to figure the root cause of the problem.
>> 
>> Thanks,
>> 
>> Kai
>> 
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • RE: Scan BLE device in the background in iPhone 4S
      • From: "Kai Wang (STC)" <email@hidden>
References: 
 >Scan BLE device in the background in iPhone 4S (From: "Kai Wang (STC)" <email@hidden>)
 >RE: Scan BLE device in the background in iPhone 4S (From: "Kai Wang (STC)" <email@hidden>)

  • Prev by Date: Re: Scan BLE device in the background in iPhone 4S
  • Next by Date: RE: Scan BLE device in the background in iPhone 4S
  • Previous by thread: RE: Scan BLE device in the background in iPhone 4S
  • Next by thread: RE: Scan BLE device in the background in iPhone 4S
  • Index(es):
    • Date
    • Thread