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
MPY: soft reboot
MicroPython v1.24.0 on 2024-10-25; Raspberry Pi Pico W with RP2040
Type "help()" for more information.
>>>
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
Connecting to Device(ADDR_RANDOM, d7:de:4c:f4:56:e5) ... Timeout.
Traceback (most recent call last):
File "<stdin>", line 47, in print_details
File "aioble/device.py", line 149, in connect
File "aioble/central.py", line 140, in _connect
File "aioble/device.py", line 94, in __exit__
TimeoutError:
enter return (to retry) / q(uit). >
Connecting to Device(ADDR_RANDOM, d7:de:4c:f4:56:e5, CONNECTED) ... Connected.
Error (discovering services): can't convert NoneType to int
Traceback (most recent call last):
File "<stdin>", line 24, in device_details
File "<stdin>", line 14, in gather
File "aioble/client.py", line 128, in __anext__
File "aioble/client.py", line 120, in _start
File "aioble/client.py", line 193, in _start_discovery
TypeError: can't convert NoneType to int
enter return (to retry) / q(uit). >
How to fix it
I added exception handling because of the following problem. (It is not a good idea to fix it in this place.)
When the timeout occurs, the variable "_connection" in aioble is not in the correct state.
When the timeout occurs, the internal state of the module "bluetooth" seems to remain connected.
# https://github.com/micropython/micropython-lib/blob/master/micropython/bluetooth/aioble/aioble/central.py#L107asyncdef_connect(
connection, timeout_ms, scan_duration_ms, min_conn_interval_us, max_conn_interval_us
):
<<Omitted>>try:
withDeviceTimeout(None, timeout_ms):
ble.gap_connect(
device.addr_type,
device.addr,
scan_duration_ms,
min_conn_interval_us,
max_conn_interval_us,
)
# Wait for the connected IRQ.awaitconnection._event.wait()
assertconnection._conn_handleisnotNone# Register connection handle -> device.DeviceConnection._connected[connection._conn_handle] =connectionexcept:
device._connection=Noneble.gap_connect(None)
raisefinally:
# After timeout, don't hold a reference and ignore future events._connecting.remove(device)
The text was updated successfully, but these errors were encountered:
The other device is powered off. However, after a connection timeout, it appears to be connected when retried. In fact, it is failing.
I'm not a native speaker, so sorry if my writing is wrong.
Environment
Steps to reproduce
Code used for testing
I added exception handling because of the following problem. (It is not a good idea to fix it in this place.)
The text was updated successfully, but these errors were encountered: