bluetooth lowenergy - iOS how to reconnect to BLE device in background? -
there many related questions (apparently) no answers. so...
my ios app does updates ble device while app in background. if lose touch ble device, in centralmanager:diddisconnectperipheral:
call -[cbcentralmanager cancelperipheralconnection:]
-- otherwise never reconnect lost peripheral. call [(re)call -[cbcentralmanager scanforperipheralswithservices:options:]
.
logging shows me diddisconnectperipheral
call, , contained calls, both happening while in background. however, reconnect happens when app wakes background.
so able communicate connected ble device while in background (yay!) not reconnect. quite important app, , (one think) other apps. suggestions welcome.
you don't need cancel connection - disconnected don't need rescan peripheral - have identified peripheral.
in diddisconnectperipheral
can call
[central connectperipheral:peripheral options:nil];
core bluetooth reconnect once peripheral visible again
a complete sample here - https://github.com/paulw11/btbackground
Comments
Post a Comment