Skip to content

Commit 6518a6d

Browse files
committed
[add] Unique '--transport' parameter to configure HID, U2F or NFC transport
1 parent 85e066d commit 6518a6d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Added
1212

13-
- NFC always enabled on Stax & Flex OSes
14-
- Starting Speculos with the `--nfc` argument will funel all communications as NFC
13+
- NFC communication available
14+
- Starting Speculos with the `--transport` argument allows to choose U2F, HID or NFC transport
15+
- Flex and Stax OSes emulation always consider NFC to be up (it can't be deactivated for now)
1516

1617
## [0.11.0] 2024-11-12
1718

speculos/main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ def main(prog=None) -> int:
269269
'to use a hex seed, prefix it with "hex:"')
270270
parser.add_argument('-t', '--trace', action='store_true', help='Trace syscalls')
271271
parser.add_argument('-u', '--usb', default='hid', help='Configure the USB transport protocol, '
272-
'either HID (default) or U2F')
273-
parser.add_argument('--nfc', action='store_true', help='Use NFC transport instead of USB')
272+
'either HID (default) or U2F (DEPRECATED, use `--transport` instead)')
273+
parser.add_argument('-T', '--transport', default=None, choices=('HID', 'U2F', 'NFC'),
274+
help='Configure the transport protocol: HID (default), U2F or NFC.')
274275

275276
group = parser.add_argument_group('network arguments')
276277
group.add_argument('--apdu-port', default=9999, type=int, help='ApduServer TCP port')
@@ -468,14 +469,20 @@ def main(prog=None) -> int:
468469
qemu_pid = run_qemu(s1, s2, args, use_bagl)
469470
s1.close()
470471

472+
# The `--transport` argument takes precedence over `--usb`
473+
if args.transport is not None:
474+
transport_type = TransportType[args.transport]
475+
else:
476+
transport_type = TransportType[args.usb.upper()]
477+
471478
apdu = apdu_server.ApduServer(host="0.0.0.0", port=args.apdu_port)
472479
seph = seproxyhal.SeProxyHal(
473480
s2,
474481
model=args.model,
475482
use_bagl=use_bagl,
476483
automation=automation_path,
477484
automation_server=automation_server,
478-
transport=TransportType.NFC if args.nfc else TransportType[args.usb.upper()])
485+
transport=transport_type)
479486

480487
button = None
481488
if args.button_port:

0 commit comments

Comments
 (0)