How should CBPeripheralManager state changes be handled?
How should CBPeripheralManager state changes be handled?
- Subject: How should CBPeripheralManager state changes be handled?
- From: mihai sardarescu <email@hidden>
- Date: Fri, 12 Feb 2016 16:29:08 +0000 (UTC)
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?
2. Is there anything specific we should do on CBPeripheralManagerStateResetting?
3. Do we need to restart advertising on each CBPeripheralManagerStatePoweredOn?
Thank you,
Mihai
_______________________________________________
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