M megaB4x Member Licensed User Longtime User Jun 30, 2015 #1 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? Code: Copy Sub Manager_Disconnected lblStatus.Text = LastException manager.Scan(Null) End Sub
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? Code: Copy Sub Manager_Disconnected lblStatus.Text = LastException manager.Scan(Null) End Sub
Erel B4X founder Staff member Licensed User Longtime User Jun 30, 2015 #2 Maybe the peripheral device is turned off? iOS will not disconnect the BLE if your app is in the foreground. Upvote 0
Maybe the peripheral device is turned off? iOS will not disconnect the BLE if your app is in the foreground.
M megaB4x Member Licensed User Longtime User Jul 1, 2015 #3 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
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?
Erel B4X founder Staff member Licensed User Longtime User Jul 2, 2015 #4 Have you previously called StopScan? Check the value of Log(LastException) in the disconnected event. Upvote 0
Have you previously called StopScan? Check the value of Log(LastException) in the disconnected event.
M megaB4x Member Licensed User Longtime User Jul 2, 2015 #5 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
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
Erel B4X founder Staff member Licensed User Longtime User Jul 5, 2015 #6 It seems like a problem in the peripheral device itself. Try to see when this error happens Are you calling ReadData many times? ReadData2 will be more efficient. Upvote 0
It seems like a problem in the peripheral device itself. Try to see when this error happens Are you calling ReadData many times? ReadData2 will be more efficient.
M megaB4x Member Licensed User Longtime User Jul 15, 2015 #7 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
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!
fbritop Well-Known Member Licensed User Longtime User Aug 7, 2015 #8 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
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
Erel B4X founder Staff member Licensed User Longtime User Aug 8, 2015 #9 Please start a new thread for this question. Upvote 0