connectToDevice doesn't time out on iOS
See original GitHub issueThis may be an issue or just a question.
We have a situation where we have to poll a device characteristic for some data. Multiple clients may be in range and do the same polling, which could mean one phone is currently connected while another one also tries to connect. The target may also be turned off so that it’s not available at all.
On Android, connecting while it’s busy or turned off fails with an error after about 5 seconds. On iOS it can wait for several minutes then finally resolve as soon as the target is available again. Log example:
11:06:52 Reading...
11:06:52 Successfully read!
11:07:00 Reading...
11:09:54 Successfully read! <-- Note the timestamp
I also tried waiting for about 10 minutes; the connection seemed to actually hang there and any subsequent connection attempts resulted in an error, I’m guessing because a connection was already underway.
Android log example, what’s expected:
11:24:19 Reading...
11:24:20 Successfully read!
11:24:25 Reading...
11:24:30 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:35 Reading...
11:24:41 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:46 Reading...
11:24:51 Unknown error: BleDisconnectedException{bluetoothDeviceAddress='ABC'}
11:24:56 Reading...
11:24:57 Successfully read!
Is this a known iOS behavior?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top GitHub Comments
autoConnect=true
does two things:autoConnect=false
). I have seen situations that it took more than 5-10 minutes even if devices had been right beside each other.As for the background behaviour I encourage you to read the documentation or check some other articles as this is a complex topic and it is hard to condensate everything into a single post.
@dariuszseweryn Yeah I guess the behavior can differ between vendors like Cierpliwy said (we’re using a mid-range Samsung for testing). So iOS seems to be in something like auto connect mode by default? Would setting
autoConnect=true
for Android affect anything more than the timeout, like automatic reconnect after disconnect or things like that? We only want to do a quick connect-read-disconnect.Could you elaborate a bit on background behavior? It’s something we will explore for a future version so knowing any caveats beforehand would be useful!