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

Commit

Permalink
Merge pull request #2 from ZondaX/nanox
Browse files Browse the repository at this point in the history
Improving nano X detection
  • Loading branch information
jleni committed May 16, 2019
2 parents 1e64b51 + 5efff18 commit 1c99b41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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

0 comments on commit 1c99b41

Please sign in to comment.