You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you attempt to call peripheral.connect from the callback of set_callback_on_scan_found or set_callback_on_scan_updated, self.peripheral.state will be forever stuck in CBPeripheralStateConnecting until the WAIT_UNTIL_FALSE_WITH_TIMEOUT(self, _task.pending, 5.0) times out.
This is because set_callback_on_scan_found callbacks are called from delegate_did_discover_peripheral which is called from a CBCentralManager delegate callback, which is run on the CBCentralManager's queue. I'd guess the CBCentralManager does updates to all of its data structures on that queue (this is generally how Apple APIs handle thread safety), so by blocking the queue (by sleeping in connect) you prevent the code that updates peripheral.state from running.
This probably applies to any other callbacks as well (e.g. the notify callback).
The text was updated successfully, but these errors were encountered:
If you attempt to call
peripheral.connect
from the callback ofset_callback_on_scan_found
orset_callback_on_scan_updated
,self.peripheral.state
will be forever stuck inCBPeripheralStateConnecting
until theWAIT_UNTIL_FALSE_WITH_TIMEOUT(self, _task.pending, 5.0)
times out.This is because
set_callback_on_scan_found
callbacks are called fromdelegate_did_discover_peripheral
which is called from a CBCentralManager delegate callback, which is run on the CBCentralManager's queue. I'd guess the CBCentralManager does updates to all of its data structures on that queue (this is generally how Apple APIs handle thread safety), so by blocking the queue (by sleeping inconnect
) you prevent the code that updatesperipheral.state
from running.This probably applies to any other callbacks as well (e.g. the notify callback).
The text was updated successfully, but these errors were encountered: