trezor-firmware icon indicating copy to clipboard operation
trezor-firmware copied to clipboard

BLE support in emulator

Open mmilata opened this issue 8 months ago • 1 comments

🐧🐧🐧 Linux-only 🐧🐧🐧

Consists of:

  • exposing core BLE interface to the outside as two UDP sockets, no connection state handling
  • trezorlib transport that talks to these sockets - as there is no connection state handling it might be useful for writing tests for e.g. misbehaving nRF but not much else (only this part that depends on #4577)
  • python script that launches dbus-daemon and a mock Linux BLE API on it - using env variable you can convince Suite/trezorlib to talk to it instead of the actual BLE devices

Usage:

  • start emu.py
  • start core/tools/bluez-emu-bridge.py -v
  • override dbus socket path export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/tmp/dbus-bluez-emu-bridge
  • run Suite in the same environment :arrow_up:

TODO:

  • [ ] rewrite unix/ble.c to use #4829
  • [ ] rebase on main after #4891 is merged
  • [x] connection state handling emulation
  • [ ] launch DBus api from emu.py
  • [ ] use dbus-fast instead of unmaintained dbus-next
    • would be nice to switch from tealblue.py (uses dbus-fast) to bleak (uses dbus-next) in trezorlib
    • #4948
  • [ ] configurable DBus listen address
    • needed for multicore tests
    • might be easier for trezor-user-env to expose a port than unix socket

mmilata avatar Mar 27 '25 10:03 mmilata

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)
Translations

cs main(all)

model device_test click_test
T2T1 test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all)

de main(all)

model device_test click_test
T2T1 test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all)

es main(all)

model device_test click_test
T2T1 test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all)

fr main(all)

model device_test click_test
T2T1 test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all)

pt main(all)

model device_test click_test
T2T1 test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all)

Latest CI run: 18919133241

github-actions[bot] avatar Mar 27 '25 10:03 github-actions[bot]

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

socket-security[bot] avatar Oct 24 '25 14:10 socket-security[bot]

Thanks for the feedback @romanz, I've pushed some fixes. Did you manage to get this to work (with trezorctl or suite) on your machine?

mmilata avatar Oct 27 '25 22:10 mmilata