mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge pull request #63 from augustozanellato/factory_reset
Add factory reset command
This commit is contained in:
@@ -98,6 +98,7 @@ class ChameleonCLI:
|
||||
'reset': new_uint(chameleon_cli_unit.HWSettingsReset, "Reset settings to default values"),
|
||||
'help': "Chameleon settings management"
|
||||
},
|
||||
'factory_reset': new_uint(chameleon_cli_unit.HWFactoryReset, "Wipe all data and return to factory settings"),
|
||||
'help': "hardware controller",
|
||||
},
|
||||
'hf': {
|
||||
|
||||
@@ -1067,3 +1067,27 @@ class HWSettingsReset(DeviceRequiredUnit):
|
||||
print(" - Reset success @.@~")
|
||||
else:
|
||||
print(" - Reset failed")
|
||||
|
||||
class HWFactoryReset(DeviceRequiredUnit):
|
||||
def args_parser(self) -> ArgumentParserNoExit:
|
||||
parser = ArgumentParserNoExit()
|
||||
parser.description = "Permanently wipes Chameleon to factory settings. " \
|
||||
"This will delete all your slot data and custom settings. " \
|
||||
"There's no going back."
|
||||
parser.add_argument(
|
||||
"--i-know-what-im-doing",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Just to be sure :)"
|
||||
)
|
||||
return parser
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
if not args.i_know_what_im_doing:
|
||||
print("This time your data's safe. Read the command documentation next time.")
|
||||
return
|
||||
resp = self.cmd_positive.factory_reset()
|
||||
if resp.status == chameleon_status.Device.STATUS_DEVICE_SUCCESS:
|
||||
print(" - Reset successful! Please reconnect.")
|
||||
print(" - A Serial Error below is normal, please ignore it")
|
||||
else:
|
||||
print(" - Reset failed!")
|
||||
|
||||
@@ -30,6 +30,8 @@ DATA_CMD_GET_GIT_VERSION = 1017
|
||||
DATA_CMD_GET_ACTIVE_SLOT = 1018
|
||||
DATA_CMD_GET_SLOT_INFO = 1019
|
||||
|
||||
DATA_CMD_WIPE_FDS = 1020
|
||||
|
||||
DATA_CMD_SCAN_14A_TAG = 2000
|
||||
DATA_CMD_MF1_SUPPORT_DETECT = 2001
|
||||
DATA_CMD_MF1_NT_LEVEL_DETECT = 2002
|
||||
@@ -495,6 +497,12 @@ class BaseChameleonCMD:
|
||||
Store settings to flash memory
|
||||
"""
|
||||
return self.device.send_cmd_sync(DATA_CMD_SAVE_SETTINGS, 0x00)
|
||||
|
||||
def factory_reset(self):
|
||||
"""
|
||||
Reset to factory settings
|
||||
"""
|
||||
return self.device.send_cmd_sync(DATA_CMD_WIPE_FDS, 0x00)
|
||||
|
||||
|
||||
class NegativeResponseError(Exception):
|
||||
|
||||
Reference in New Issue
Block a user