Skip to content

Commit

Permalink
fix dfu with changes suggested by @enrikb
Browse files Browse the repository at this point in the history
  • Loading branch information
conorpp committed Apr 29, 2021
1 parent 863c84a commit fe93797
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions solo/cli/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ def enter_dfu(serial):
"""

p = solo.client.find(serial)
p.enter_st_dfu()
# this doesn't really work yet ;)
# p.reboot()

print("Please powercycle the device (pull out, plug in again)")
try:
p.enter_st_dfu()
print("Please powercycle the device (pull out, plug in again)")
except Exception as e:
if "wrong channel" in str(e).lower():
print("Command wasn't accepted by Solo. It must be in bootloader mode first and be a 'hacker' device.")


aux.add_command(enter_dfu)
Expand Down
9 changes: 8 additions & 1 deletion solo/devices/solo_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import tempfile
import time
from threading import Event

from fido2.client import Fido2Client
from fido2.ctap import CtapError
Expand Down Expand Up @@ -105,7 +106,13 @@ def use_hid(
def send_only_hid(self, cmd, data):
if not isinstance(data, bytes):
data = struct.pack("%dB" % len(data), *[ord(x) for x in data])
self.dev._dev.InternalSend(0x80 | cmd, bytearray(data))

no_reply = Event()
no_reply.set()
try:
self.dev.call(0x80 | cmd, bytearray(data), no_reply)
except IOError:
pass

def exchange_hid(self, cmd, addr=0, data=b"A" * 16):
req = Client.format_request(cmd, addr, data)
Expand Down

0 comments on commit fe93797

Please sign in to comment.