Target only USB ledger with interface number 0

This commit is contained in:
Sebastien Mondet 2018-10-10 19:19:02 -04:00
parent f4e07221f1
commit 02bc43b094

View File

@ -304,12 +304,18 @@ let find_ledgers ?id () =
log_info "Found %d Ledger(s)" (List.length ledgers) ; log_info "Found %d Ledger(s)" (List.length ledgers) ;
filter_map_s begin fun device_info -> filter_map_s begin fun device_info ->
log_info "Processing Ledger at path [%s]" device_info.Hidapi.path ; log_info "Processing Ledger at path [%s]" device_info.Hidapi.path ;
match Hidapi.(open_path device_info.path) with if device_info.Hidapi.interface_number <> 0
| None -> return_none then
| Some h -> (* HID interfaces get number 0:
Lwt.finalize https://github.com/LedgerHQ/ledger-nano-s/issues/48 *)
(fun () -> Ledger.of_hidapi ?id device_info h) return_none
(fun () -> Hidapi.close h ; Lwt.return_unit) else
match Hidapi.(open_path device_info.path) with
| None -> return_none
| Some h ->
Lwt.finalize
(fun () -> Ledger.of_hidapi ?id device_info h)
(fun () -> Hidapi.close h ; Lwt.return_unit)
end ledgers end ledgers
let with_ledger id f = let with_ledger id f =