connect to device directly if it was a disconnect with existing device#3110
connect to device directly if it was a disconnect with existing device#3110
Conversation
|
why do we need this step but not let the discovery auto connect to the desirable device? discovery will scan for the devices nearby; that's the source of truth to let us know which device is ready to connect. why do we need to add the device that's not in range? |
|
1/ Scanning for devices in the background is resource-intensive on iOS, and the operating system itself tries to limit excessive scanning. Since the device ID remains the same, we first attempt to connect directly to check if the device is available. If the device is available, the connection succeeds; if not, we then proceed to scan for it. 2/ We also store the most recently connected device in preferences. If a disconnect occurs and the device list is empty, we fall back to connecting with the device stored in preferences. This works because that was the last connected device, and if it’s still in range, the connection will succeed. If not, the attempt will fail. The device list can be empty because iOS may delay or batch scan operations in the background, as mentioned in Apple’s documentation. Scanning in the background is not the same as scanning in the foreground. In both cases (1 and 2), we take an optimistic approach by attempting to connect first, hoping the device is available. This reduces the need for unnecessary scans. From Apple’s documentation:
I might be missing some edge case or confusing something here, so pls lmk if any part of this reasoning is off sir |
|
nice, lgmt @mdmohsin7, please go ahead. |
BasedHardware#3110) * connect to device directly if it was a disconnect with existing device * bump ver to 433 for testing * test * restoreState and remove imageCache on app minimised * bump to 434 for testing * use device from pref _devices is empty * bump to 435 * save locator as well in pref when saving btdevice * bump to 436 * revert codemagic test changes
Uh oh!
There was an error while loading. Please reload this page.