Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Improving nano X detection #2

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
)

const (
VendorLedger = 0x2c97
UsagePageLedger = 0xffa0
VendorLedger = 0x2c97
UsagePageLedgerNanoS = 0xffa0
//ProductNano = 1
Channel = 0x0101
PacketSize = 64
Expand Down Expand Up @@ -71,8 +71,11 @@ func FindLedger() (*Ledger, error) {
devices := hid.Enumerate(VendorLedger, 0)

for _, d := range devices {
deviceFound := d.UsagePage == UsagePageLedger
deviceFound = deviceFound || (d.Product == "Nano S" && d.Interface == 0)
deviceFound := d.UsagePage == UsagePageLedgerNanoS
// Workarounds for possible empty usage pages
deviceFound = deviceFound ||
(d.Product == "Nano S" && d.Interface == 0) ||
(d.Product == "Nano X" && d.Interface == 0)

if deviceFound {
device, err := d.Open()
Expand Down
2 changes: 1 addition & 1 deletion ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_BasicExchange(t *testing.T) {
t.Fatalf("Error: %s", err.Error())
}

assert.Equal(t, 4, len(response))
assert.Equal(t, 5, len(response))
}
}

Expand Down