-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
esp_prov: switch from bluez/dbus to bleak (IDFGH-7556) #9117
Conversation
fcb3f81
to
8112f67
Compare
Thanks for your contribution. |
I updated my commits - I had installed the pre-commit hook halfway through, but apparently |
@ccutrer Thank you for sending this PR. It looks mighty useful, we are performing some tests on this and then we shall queue it for internal merge. |
Tested working on Archlinux but failed on Windows 10 with error Full log:
|
Apparently Windows requires pairing. Tested working on Windows 11 and Windows 10. |
Yes f8ba16f is working on Windows 10. |
print('{0: >4} {1: <33} {2: <12}'.format( | ||
'S.N.', 'Name', 'Address')) | ||
for i in range(len(devices)): | ||
print('[{0: >2}] {1: <33} {2: <12}'.format(i + 1, devices[i].name or 'Unknown', devices[i].address)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devices[i].name
need more handling.
On windows some device name have a bytearray part which cause following error:
==== BLE Discovery results ====
S.N. Name Address
[ 1] Linkify_00000A 84:F7:03:33:A3:EE
Traceback (most recent call last):
File "E:\mcu\esp-idf/tools/esp_prov\esp_prov.py", line 524, in <module>
asyncio.run(main())
File "C:\Program Files\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "E:\mcu\esp-idf/tools/esp_prov\esp_prov.py", line 397, in main
obj_transport = await get_transport(args.mode.lower(), args.name)
File "E:\mcu\esp-idf/tools/esp_prov\esp_prov.py", line 70, in get_transport
await tp.connect(devname=service_name)
File "E:\mcu\esp-idf/tools/esp_prov\transport\transport_ble.py", line 26, in connect
if not await self.cli.connect(devname=devname, iface='hci0',
File "E:\mcu\esp-idf/tools/esp_prov\transport\ble_cli.py", line 66, in connect
print('[{0: >2}] {1: <33} {2: <12}'.format(i + 1, devices[i].name, devices[i].address))
TypeError: unsupported format string passed to NoneType.__format__
If I add
for i in range(len(devices)):
print(devices[i])
I got :
88:C6:26:B1:43:21: IBM Corp. (b'\x00~Q\x00\x00\x0bT3\xcb\x9b\xa8\x8b\x88\xc6&\xb1C!\x12')
90:DD:5D:D4:93:A7: Apple, Inc. (b'\x0f\x08\xc0\n\x86b\xb1\x00\x04\x0b\x10\x02\x01\x00')
5B:41:61:6C:CE:C6: Apple, Inc. (b'\x10\x06W\x1e\xb8\x1d\xf3K')
21:E1:31:80:D3:00: Apple, Inc. (b'\t\x06\x03C\xc0\xa8\x01a')
F4:98:29:D7:7A:36: Apple, Inc. (b'\x12\x02\x00\x03')
84:F7:03:33:A3:EE: Linkify_00000A
15:11:FB:F5:8A:08: Apple, Inc. (b'\t\x06\x03A\xc0\xa8\x01\x18')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure you're running the latest commit? I pushed up a fix for unsupported format string passed to NoneType.__format__
(adding or 'Unknown'
) right around the time you commented that it's working on Windows 10. Assuming you are, would the fix be to change it to str(device[I].name or 'Unknown')
? I'm a relative novice in Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure you're running the latest commit?
You are right, it's already fixed in last commit.
to enable multiplatform ble compatibility
and allow interactive scanning and selection of device
@laukik-hase: done. |
sha=265ad3eea657fb3d4f064fbb49132ff8b128d1b8 |
Merged with 3f77c65 |
to enable multiplatform BLE compatibility
tested on MacOS 12.4 and Ubuntu 20.04
also includes several discrete commits to allow interactive provisioning if necessary data isn't provided on command line.