Post not yet marked as solved
Post marked as unsolved with 1 replies, 1,017 views
Hello,
I'm working on a project where the iPhone is in a peripheral role. During some testing I encountered different behaviours between iOS 12 and iOS 13 in following testscenario: Start advertising
Turn BLE off from control center
Turn BLE on fron control center
Tested with:
iPhone 6+ (iOS 12.2)
iPhone 8 (iOS 12.1)
iPhone X (iOS 13.2.3)
iOS 12:
It seems like the stack automatically restarts the advertising when the BLE is turned on. When there is a BLE state change I check whether the peripheral is advertising. The call isAdvertising() returns false:
07-29 11:00:30.111 | BluetoothLink | D(💙) | [99] Peripheral isAdvertising: false
When I then try to call start advertising I receive following error in the delegate:
07-29 11:00:30.136 | BluetoothLink | D(💙) | [514] Peripheral manager did start advertising with error: Optional(Error Domain=CBErrorDomain Code=9 "Advertising has already started." UserInfo={NSLocalizedDescription=Advertising has already started.})
iOS 13:
When the BLE is turned back on, the advertising won't be restarted. When I call isAdvertising() it also returns false. Once I start the advertising again it calls the delegate didStartAdvertising without an error.
Are there any changes in the OS which could explain such a behaviour? How should I handle the different behaviour? Is it inteded from the OS to automatically restart the advertising?
Should I just call stopAdvertising everytime before starting the advertisement? Would this approach have negative side effects on the BLE stack?
Thank you for the support.
Regards,
Sebastian P