Re: How should CBPeripheralManager state changes be handled?
Re: How should CBPeripheralManager state changes be handled?
- Subject: Re: How should CBPeripheralManager state changes be handled?
- From: Craig Dooley <email@hidden>
- Date: Fri, 12 Feb 2016 09:27:05 -0800
HI Mihai,On Feb 12, 2016, at 8:29 AM, mihai sardarescu < email@hidden> wrote:
Hi,
We're working on building an iOS application that is supposed to act as a Bluetooth peripheral when the application is in background or suspended. Some of our users are complaining that the iPhone cannot be discovered after the weekend. We think our application may not react correctly to the changes of the state of its CBPeripheralManager.
Our initial strategy was to add the CBServices and to start advertising on first CBPeripheralManagerStatePoweredOn, and to stop advertising on CBPeripheralManagerStatePoweredOff and CBPeripheralManagerStateResetting (this is the common case for the examples we found on the web). This proved to be a bad idea, as sometimes the application stops advertising (take the case when Bluetooth is turned off and then the application is backgrounded). We changed the strategy and we add the CBServices and start advertising on the first CBPeripheralManagerStatePoweredOn or CBPeripheralManagerStatePoweredOff. This seems to be working, but it is something we have not seen in any example on the web. And we're still experiencing some issues when the phone is not found. We have seen a CBPeripheralManagerStateResetting state when this occurred once, but it is very hard to get bluetooth in this test to try and reproduce.
I have a couple of questions (reading the doc did not really help me here): 1. Is it correct to add Bluetooth services and to start advertising on CBPeripheralManagerStatePoweredOff?
Adding services is fine, but advertising will not work unless the power is on. 2. Is there anything specific we should do on CBPeripheralManagerStateResetting?
Wait for the next update (and invalidate any state you had). It will be followed by another state update. 3. Do we need to restart advertising on each CBPeripheralManagerStatePoweredOn?
Yes.
- Craig |
_______________________________________________
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