ios8.3 bluetooth lost connection every 30s - ios

Recently, I develop a BLE app in iOS8.3.
But, I found a terrible question.
When I connect the BLE device with iPhone, almost every 30s, the connection is lost. After I restart the iPhone, the problem is disappear.
Who maybe explain this?
Thank all.

Here is your answer
Try switching Airplane mode on for 30 seconds, then turn it off and try connecting again.
Try holding down the home button and the Sleep/Wake button until your device restarts.
Turn your router off for 30 seconds and then switch it on again.
Go to Settings > General > Reset > Reset Network Settings and then setup your Wi-Fi, Bluetooth again.
Try chaining the channel on your router and check the rest of the settings.
Make sure that your router firmware is up to date.
Try a factory reset of your iPhone.

Related

App doesn't reconnect to a Bluetooth device when it is in the background

I have an app that uses Bluetooth (BLE). All BLE communication works fine. State restoration is also implemented and works well. The app has automatic re-connection implementation: whenever the CBError.peripheralDisconnected error occurs, the app tries to reconnect to the peripheral by calling cbCentralManager.connect(cbPeripheral).
Since iOS 15/16 there is a problem. Let's assume that the app is connected to a specific BLE device. I turn off the device (at this moment the automatic re-connection started) and move the app to the background. After several hours (e.g. over the night) I turn on the BLE device and the connection isn't established. I can see this on my Bluetooth device and in the iOS Bluetooth settings. Only when I open the app again, the connection is established immediately. Nothing happens in between. Only the connect call of the CBCentralManager after the Bluetooth device is turned off. The whole thing works when the app is in the background for 3 - 5 hours. If it is over approx. 5 hours, the connection is no longer established as soon as the app is in the background.
At first I thought that the app or the BLE connection is simply killed by the system after a long time. However, the state restoration for Bluetooth is implemented and works (I tested it).
Does anyone have any idea what this could be? Are there perhaps any new settings for state restoration or Bluetooth background mode since iOS 15/16?
Many thanks in advance.

iPhone disconnected USB connection overnight and there are no system logs

I needed to run a long test to see what's making my app crash. So I set the Mac to not sleep and I ran the app on the iPhone connected via USB overnight. In the morning, I found that the iPhone had disconnected during the night.
I looked for in Console and Xcode for device logs and I found there were none at all on the phone, therefore no history of what happened during the night. Logs began after the moment I reconnected the phone to the Mac.
I downloaded the app container and found no useful evidence of what happened.
iOS is 12.4 and Xcode is 10.3.
What can be done to ensure there is some evidence of what caused the crash? Other than filling the app with fprintf's going to a custom log file. Also I am using Fabric.
Do the same thing again, but this time with a camera looking at the PC. Maybe you can grab some evidence from the recording next day. Modern solutions for modern problems.
Go to Settings -> Touch ID and Passcode
Check if USB Accessories has been turned off. Your device may have disconnected then failed to reconnect due to this feature restricting access to the device if it is disconnected for more than an hour.
Change this setting, replace your cable or use a different USB port then try running it again.

iOS 8.2 UIRequiresPersistentWiFi not working

I am making an app that requires consistent wifi connection. The problem is that when the wifi is off and I turn on the app nothing happens, even though I have activated the UIRequiresPersistentWiFi flag. Also when the screen locks, and I go to the app after unlocking, it also can't use the wifi. The only solution that I have found for this problem is the activation of UIRequiresPersistentWiFi, which clearly doesn't work in my app, or I am not doing it right. So does anyone have any idea what could be wrong?
UIRequiresPersistentWiFi doesn't force the device to connect to WiFi when the app is launched, it only specifies that an existing WiFi connection should be kept open for the duration your app is running. The default behaviour is for iOS to drop its WiFi connection after 30 minutes to conserve battery life.
See the documentation for more detail.

CoreBluetooth and Wifi interference

I'm really stuck with a problem, thus, needless to say, I need your help.
I'm using CoreBluetooth to communicate between two iDevices, it is the same app, running as a central on one device and as a peripheral on the other device. In some cases the central loses connection to the peripheral with the following error:
Error Domain=CBErrorDomain Code=10 "The connection has failed unexpectedly." UserInfo=0x14ee8fe0 {NSLocalizedDescription=The connection has failed unexpectedly.}
In this particular case, the peripheral was an iPad 4 and the central was an iPad mini.
I tracked down the problem and it turns out, that once I encounter this issue, the problem will persist every time I connect, regardless of restarting the app or even the bluetooth on both sides, HOWEVER, the interesting part is, if I turn off Wifi on the central device, the connection doesn't time out anymore.
Do you have any suggestions, workarounds? Both devices are running iOS 7.1.1
This is a well known issue, and it has a solution that is confirmed to work for the Mac side.
sudo defaults write /Library/Preferences/com.apple.airport.bt.plist bluetoothCoexMgmt Hybrid
After you run this script, the issue will go away and BT connections will remain stable.
And here is the explanation:
Background: after a lot of snooping and head scratching, here's what I found: the issue here seems to be that the system isn't using the same Bluetooth/Airport coexistance mode for BLE as it uses for BT Classic. One tell tale sign: if you have any BT Classic devices connected and active, the bug won't repro (neither for the Classic device nor any connected BLE device). The moment the Classic device disconnects, the bug repros (ie all the BLE connections are also dropped).
Further, I was able to find reference in the symbol table of an airport configd agent to an override setting for the coexistance mode. If you set the mode manually as above to 'hybrid' (the same mode that is usually invoked when a classic device is connected), the bug no longer repros.
All credits go to William Henderson from Knock for this trick.
There were cases when the same effect was perceived on iOS devices as well. This some times happens when the Core Bluetooth connections are not stable. Sometimes this can lead to the WiFi connection being unusable. But it's hard to reproduce, at least I wasn't able to, and your question does not concern it either.

iPad still connecting to Game Center Sandbox in airplane mode

This seems weird, but the iPad I have is still successfully connecting to the Game Center Sandbox even though airplane mode is on. It would seem when debugging iPad the device somehow connects thru USB to internet (is this the case?)
I'm just trying to test the case where there is no internet connection and make sure there is a graceful fail.
Anyway, how do I disable internet connectivity on the iPad device then?
If you're logged into Game Center on the device, then apparently the GC login request will always appear to work immediately and it will say Welcome back, PLAYERNAME *** Sandbox ***. I think it must be echoing the last known GC server IPs. That doesn't mean you can reach the GC servers though.

Resources