• 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: Peripheral not being discovered in the background until I open the BlueTooth Settings page
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Peripheral not being discovered in the background until I open the BlueTooth Settings page


  • Subject: Re: Peripheral not being discovered in the background until I open the BlueTooth Settings page
  • From: Jan Lübeck (Fyrastudio) <email@hidden>
  • Date: Mon, 09 Nov 2015 14:47:51 -0500
  • X_v_e_cd: e0589476708c5a281863be1aa1383c87
  • X_v_r_cd: f16157868fd596a5c80c78bc456e2204

The only thing that would apply there is:

  • If all apps that are scanning for peripherals are in the background, the interval at which your central device scans for advertising packets increases. As a result, it may take longer to discover an advertising peripheral.


That would explain why it shows up when opening the BlueTooth settings. But how much longer can it take? Is the increase in scanning interval documented somewhere? I tried waiting for over 5 minutes and it still didn't discover it 



______
Jan Lübeck
Chief Technology Officer
fyrastudio.com

On Mon, Nov 9, 2015 at 2:43 PM, Zachary Kaplan <email@hidden> wrote:
You're right sorry about that. But scrolling down there are other reasons that it may not be discovering.

For example:

Although you can perform many Bluetooth-related tasks while your app is in the background, keep in mind that scanning for peripherals while your app is in the background operates differently than when your app is in the foreground. In particular, when your app is scanning for device while in the background:

  • The CBCentralManagerScanOptionAllowDuplicatesKey scan option key is ignored, and multiple discoveries of an advertising peripheral are coalesced into a single discovery event.

  • If all apps that are scanning for peripherals are in the background, the interval at which your central device scans for advertising packets increases. As a result, it may take longer to discover an advertising peripheral.


On Mon, Nov 9, 2015 at 11:21 AM, Jan Lübeck (Fyrastudio) <email@hidden> wrote:
Zachary,

Your example mentions foreground-only apps, which is not my case. But thanks!

______
Jan Lübeck
Chief Technology Officer
fyrastudio.com

On Mon, Nov 9, 2015 at 2:18 PM, Zachary Kaplan <email@hidden> wrote:
Jan,

I think this is the default behavior. Have you read this?

https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html

For example it says:

On the central side, foreground-only apps—apps that have not declared to support either of the Core Bluetooth background execution modes—cannot scan for and discover advertising peripherals while in the background or while suspended. On the peripheral side, advertising is disabled, and any central trying to access a dynamic characteristic value of one of the app’s published services receives an error.

Depending on the use case, this default behavior can affect your app in several ways. As an example, imagine that you are interacting with the data on a peripheral that you’re currently connected to. Now imagine that your app moves to the suspended state (because, for example, the user switches to another app). If the connection to the peripheral is lost while your app is suspended, you won’t be aware that any disconnection occurred until your app resumes to the foreground.



On Mon, Nov 9, 2015 at 11:00 AM, Jan Lübeck (Fyrastudio) <email@hidden> wrote:
Hey all, first message here, so I hope I don't sound too newbie.

I've been looking at the documentation to have my app discover peripherals while on the background and I think I have it all set up correctly.

1) I wait until the CBCentralManager's state is CBCentralManagerStatePoweredOn before I start scanning.
2) On scanForPeripheralsWithServices I pass an array of UUIDs with the services. NOT scanning with nil as that doesn't work in the background. 
3) I have bluetooth-central inside UIBackgroundModes in my plist

With all these, eveything works great in the foreground, plus it works great if I discover the peripheral in the foreground and then go to the background. But if I go to the background before discovering the peripheral, it is never discovered.

UNLESS

I go to my phone Settings and open the BlueTooth page. Without even touching anything else, centralManager:didDiscoverPeripheral is called on my app as expected. 

This surprised me, but at least gave me something solid to come and ask here. 

Is there something I'm missing? 

I'm running iOS 9.1. Couldn't test on 8.x yet to see if it is a new thing.

Thanks!
______
Jan Lübeck
Chief Technology Officer
fyrastudio.com

 _______________________________________________
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




 _______________________________________________
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

References: 
 >Peripheral not being discovered in the background until I open the BlueTooth Settings page (From: Jan Lübeck (Fyrastudio) <email@hidden>)

  • Prev by Date: Re: Reinitiate CoreBluetooth BTLE Pairing Connection
  • Next by Date: Re: Peripheral not being discovered in the background until I open the BlueTooth Settings page
  • Previous by thread: Re: Peripheral not being discovered in the background until I open the BlueTooth Settings page
  • Next by thread: RE: Retrieve peripheral and connect
  • Index(es):
    • Date
    • Thread