I had the problem when I try to use aioble compiled in as a module in MicroPython. When I install aioble with mpi on the board itself, everything works.
aioble 'BLE' object has no attribute 'l2cap_connect' on Pico-W
I'm trying to run the l2cap_file_client.py and l2cap_file_server.py examples from https://github.com/micropython/micropython-lib/tree/master/micropython/bluetooth/aioble on my Pico-W. I'm currently running MicroPython v1.22.0-preview.236.ge1a7aa23f on 2023-12-09; Raspberry Pi Pico W with RP2040
It sounds like the BLE support for the Pico-W is missing l2cap functionality, I get stack traces like:
...
Connecting to Device(ADDR_PUBLIC, d8:3a:dd:94:88:0e)
Discovering...
Connecting channel
Task exception wasn't retrieved
future: <Task> coro= <generator object 'getPrefsFromServer' at 20012c60>
Traceback (most recent call last):
File "asyncio/core.py", line 1, in run_until_complete
File "l2cap_file_client.py", line 152, in getPrefsFromServer
File "l2cap_file_client.py", line 62, in connect
File "aioble/device.py", line 288, in l2cap_connect
File "aioble/l2cap.py", line 205, in connect
AttributeError: 'BLE' object has no attribute 'l2cap_connect'
What can I do to get this working? More documentation about what is/isn't supported on a given platform would be really helpful as I just blew an afternoon getting to this point. Seems to be a bit of a theme, see https://github.com/micropython/micropython-lib/issues/444 and https://github.com/micropython/micropython-lib/issues/686
aioble: AttributeError: 'module' object has no attribute 'Service' (and - no instructions, and lack of useful examples)
It is not clear from this page:-
https://github.com/micropython/micropython-lib/tree/master/micropython/bluetooth/aioble#passive-scan-for-nearby-devices-for-5-seconds-observer
how to use any of that code
>>> import l2cap_file_server
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "l2cap_file_server.py", line 53, in <module>
AttributeError: 'module' object has no attribute 'Service'
>>>
we need to be told what to do to make it work, and there needs to be working examples to show the features - especially the "scan" - and the examples need to tell you what you need to to do run them.
even the multitests don't seem to work? (and there's no tests for the scan feature):
MicroPython v1.21.0 on 2023-10-06; Generic ESP32 module with OTA with ESP32
Type "help()" for more information.
>>> import notify
>>> notify.instance1()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "notify.py", line 148, in instance1
AttributeError: 'module' object has no attribute 'stop'
>>>
disclaimer: I'm not an expert in MicroPython
@gitcnd Does installing the module with mip solve the problem, as suggested by @fpetzold ?
Installing the module with mip solve the problem also for me.
thank's @fpetzold
Yes unfortunately l2cap support hasn't been added on btstack BLE integration yet which rp2 uses.
https://docs.micropython.org/en/latest/library/bluetooth.html#l2cap-connection-oriented-channels
Okay, thank you!