mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-07-10 19:04:28 -04:00
Add xap cli functions to test secure
This commit is contained in:
@@ -70,12 +70,30 @@ class XAPShell(cmd.Cmd):
|
||||
# TODO: request stuff?
|
||||
print(self.device.info()['xap'])
|
||||
|
||||
def do_status(self, arg):
|
||||
"""Prints out the current device state
|
||||
"""
|
||||
status = self.device.status()
|
||||
print('Secure:%s' % status.get('lock', '???'))
|
||||
|
||||
def do_unlock(self, arg):
|
||||
"""Initiate secure unlock
|
||||
"""
|
||||
self.device.unlock()
|
||||
print('Unlock Requested...')
|
||||
|
||||
def do_lock(self, arg):
|
||||
"""Disable secure routes
|
||||
"""
|
||||
self.device.lock()
|
||||
|
||||
def do_reset(self, arg):
|
||||
"""Jump to bootloader if unlocked
|
||||
"""
|
||||
if not self.device.reset():
|
||||
print("Reboot to bootloader failed")
|
||||
return True
|
||||
|
||||
def do_listen(self, arg):
|
||||
"""Log out XAP broadcast messages
|
||||
"""
|
||||
@@ -89,9 +107,7 @@ class XAPShell(cmd.Cmd):
|
||||
|
||||
cli.log.info(' Secure[%s]', secure_status)
|
||||
else:
|
||||
data_str = ' '.join(['{:02X}'.format(b) for b in data])
|
||||
|
||||
cli.log.info(' Broadcast: type[%02x] data:[%s]', event, data_str)
|
||||
cli.log.info(' Broadcast: type[%02x] data:[%s]', event, data.hex())
|
||||
|
||||
except KeyboardInterrupt:
|
||||
cli.log.info('Stopping...')
|
||||
|
||||
@@ -148,9 +148,23 @@ class XAPDevice:
|
||||
data['xap'] = self.version()['xap']
|
||||
return data
|
||||
|
||||
def status(self):
|
||||
lock = int.from_bytes(self.transaction(b'\x00\x03') or bytes(0), 'little')
|
||||
|
||||
data = {}
|
||||
data['lock'] = XAPSecureStatus(lock).name
|
||||
return data
|
||||
|
||||
def unlock(self):
|
||||
self.transaction(b'\x00\x04')
|
||||
|
||||
def lock(self):
|
||||
self.transaction(b'\x00\x05')
|
||||
|
||||
def reset(self):
|
||||
status = int.from_bytes(self.transaction(b'\x01\x07') or bytes(0), 'little')
|
||||
return status == 1
|
||||
|
||||
|
||||
class XAPClient:
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user