whad-team / whad-client

Wireless Hacking Devices Protocol client
MIT License
103 stars 4 forks source link

wble-central: If a GATT Timeout occurs, command never exits #50

Open jsmif opened 1 week ago

jsmif commented 1 week ago

Regarding trying to create a profile from https://whad.readthedocs.io/en/stable/cli/ble/ble-spawn.html, I get the following error:

wble-central -i hci0 -b <my device bdaddr> profile mydevice.json
[!] GATT Timeout while discovering services and characteristics. Aborted.
Writing profile JSON data to mydevice.json ...

I know the GATT Timeout isn't an error, and I do see adv_data and scan_rsp values in the mydevice.json, but the error is that the command never exits back to the shell and just sits there on the "Writing profile" line forever.

Tested w/ commit 909b4af17959cac04e21aca5eeb21e6b319da246

virtualabs commented 1 week ago

It looks like the HCI adapter struggles to disconnect from device, blocking the nice exit procedure of wble-central. I managed to reproduce with a nRF52 USB dongle running ButteRFly, but not with my HCI USB adapter. I fixed some parts of the code to avoid this to happen when using an UART-based interface (nRF52 and others), but I guess this is the same type of behavior for HCI.

Could you paste/attach a full debug log (you can generate such log with --log debug --log-file debug-log.txt options) ?

jsmif commented 1 week ago

The first time I was trying to write steps for ticket #52 I accidentally picked a bad example in the form of peripheral_gatt_write, which apparently doesn't have enumerable GATT services (despite its name). So if you do those steps and try to connect to the peripheral_gatt_write Zephyr peripheral, it should fairly reliably timeout (it actually succeeded one time for me, but failed all other files. Failure log attached.)

(venv-root) root@VM:/home/user/whad-client# wble-central -i hci0 --log debug --log-file ./profiling.log -b 11:22:33:44:55:66 profile ZP_GR.json
[!] GATT Timeout while discovering services and characteristics. Aborted.
Writing profile JSON data to ZP_GR.json ...
^C/!\ Interrupted by user (CTL-C)

profiling.log