iOS Question BLE disconnect event

megaB4x

Member
Licensed User
Longtime User
Hi,

After few minutes BLE connection gets disconnected. I assume it is normal when iOS decides to do so in order to clear memory.

The problem is, I can't re-initiate the connection after it's disconnected. I am using scan command but does not work. What else needs to be done in order to re-scan and connect again?

B4X:
Sub Manager_Disconnected
    lblStatus.Text = LastException
    manager.Scan(Null)
End Sub
 

megaB4x

Member
Licensed User
Longtime User
It's not the peripheral because I tried on LightBlue and BLE Explorer apps it doesn't disconnect.
Let's take another example: peripheral goes out of range and connection get disconnected and then it comes back in range. If I click on the "Scan and Connect" button it starts scanning and connects fine but if I add manager.scan(Null) command as shown above inside Disconnected event it does not initiate scanning. I am missing something here that needs to be done prior to re-scan?
 
Upvote 0

megaB4x

Member
Licensed User
Longtime User
manager.StopScan is called in the Manager_DeviceFound.

Here is the Log(LastException) of the disconnected event:
B4IExceptionWrapper:Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly" UserInfo=0x17426dc00 {NSLocalizedDescription=Theconnection has timed out unexpectedly.) > -- 09:16:39
 
Upvote 0

megaB4x

Member
Licensed User
Longtime User
Yes, I am using ReadData2. It appears that same app works fine on iPad with iOS 7.1 whereas it keep disconnecting on iPhone 6 with iOS8.x
I will research further. Thanks again!
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Erel,
If a BLE device goes out of range and the app is in background. Should it reconnect automatically upon coming into range?

Thanks
FBP
 
Upvote 0
Top