@@ -964,7 +964,7 @@ def args_parser(self) -> ArgumentParserNoExit:
964964 parser = ArgumentParserNoExit ()
965965 parser .description = 'Mifare Classic clone tag from dump'
966966 parser .add_argument ('-t' , '--dump-file-type' , type = str , required = False , help = "Dump file content type" , choices = ['bin' , 'hex' ])
967- parser .add_argument ('-a' , '--clone-access' , type = bool , default = False , help = "Write ACL from original dump too (/!\ could brick your tag)" )
967+ parser .add_argument ('-a' , '--clone-access' , type = bool , default = False , help = r "Write ACL from original dump too (/!\ could brick your tag)" )
968968 parser .add_argument ('-f' , '--dump-file' , type = argparse .FileType ("rb" ), required = True ,
969969 help = "Dump file containing data to write on new tag" )
970970 parser .add_argument ('-d' , '--dic' , type = argparse .FileType ("r" ), required = True ,
@@ -3473,18 +3473,7 @@ def on_exec(self, args: argparse.Namespace):
34733473 print (AnimationMode (self .cmd .get_animation_mode ()))
34743474
34753475
3476- @hw_settings .group ('wakeuptime' )
3477- class HWSettingsWakeupTime (DeviceRequiredUnit ):
3478- def args_parser (self ) -> ArgumentParserNoExit :
3479- parser = ArgumentParserNoExit ()
3480- return parser
3481-
3482- def on_exec (self , args : argparse .Namespace ):
3483- # Show help if no subcommand is provided
3484- self .args_parser ().print_help ()
3485-
3486-
3487- @HWSettingsWakeupTime .command ('button' )
3476+ @hw_settings .command ('wakeuptime_button' )
34883477class HWSettingsWakeupTimeButton (DeviceRequiredUnit ):
34893478 def args_parser (self ) -> ArgumentParserNoExit :
34903479 parser = ArgumentParserNoExit ()
@@ -3494,26 +3483,47 @@ def args_parser(self) -> ArgumentParserNoExit:
34943483 return parser
34953484
34963485 def on_exec (self , args : argparse .Namespace ):
3497- if args .set is not None :
3498- if not 1000 <= args .set <= 60000 :
3499- print (f"{ CR } Error: Wake-up time must be between 1000 and 60000 milliseconds{ C0 } " )
3500- return
3501-
3502- resp = self .cmd .set_wakeup_button_time (args .set )
3503- if resp .status == Status .SUCCESS :
3504- print (f"Successfully set button wake-up time to { args .set } ms" )
3505- print (f"{ CY } Do not forget to store your settings in flash!{ C0 } " )
3506- else :
3507- print (f"Failed to set button wake-up time: { Status (resp .status )} " )
3508- else :
3509- resp = self .cmd .get_wakeup_button_time ()
3510- if resp .status == Status .SUCCESS :
3511- print (f"Button wake-up time: { resp .parsed } ms" )
3486+ try :
3487+ if args .set is not None :
3488+ print (f"[CLI] Setting button wake-up time to { args .set } ms" )
3489+ try :
3490+ resp = self .cmd .set_wakeup_button_time (args .set )
3491+ if resp is None :
3492+ print (f"{ CR } Error: No response from device{ C0 } " )
3493+ return
3494+
3495+ print (f"{ CG } Successfully set button wake-up time to { args .set } ms{ C0 } " )
3496+
3497+ # Try to save settings to flash
3498+ try :
3499+ print ("Saving settings to flash..." )
3500+ save_resp = self .cmd .save_settings ()
3501+ if save_resp and hasattr (save_resp , 'status' ):
3502+ if save_resp .status == Status .SUCCESS :
3503+ print (f"{ CG } Settings saved to flash memory{ C0 } " )
3504+ else :
3505+ print (f"{ CY } Warning: Save failed with status: { Status (save_resp .status ).name } { C0 } " )
3506+ else :
3507+ print (f"{ CY } Warning: Invalid response when saving settings{ C0 } " )
3508+ except Exception as e :
3509+ print (f"{ CY } Warning: Could not save settings: { str (e )} { C0 } " )
3510+
3511+ except Exception as e :
3512+ print (f"{ CR } Error setting wake-up time: { str (e )} { C0 } " )
35123513 else :
3513- print (f"Failed to get button wake-up time: { Status (resp .status )} " )
3514+ print ("[CLI] Getting button wake-up time" )
3515+ resp = self .cmd .get_wakeup_button_time ()
3516+ if resp is None :
3517+ print (f"{ CR } Error: No response from device{ C0 } " )
3518+ elif resp .status == Status .SUCCESS :
3519+ print (f"Button wake-up time: { CG } { resp .parsed } ms{ C0 } " )
3520+ else :
3521+ print (f"{ CR } Failed to get button wake-up time: { Status (resp .status ).name } { C0 } " )
3522+ except Exception as e :
3523+ print (f"{ CR } Error: { str (e )} { C0 } " )
35143524
35153525
3516- @HWSettingsWakeupTime .command ('field ' )
3526+ @hw_settings .command ('wakeuptime_field ' )
35173527class HWSettingsWakeupTimeField (DeviceRequiredUnit ):
35183528 def args_parser (self ) -> ArgumentParserNoExit :
35193529 parser = ArgumentParserNoExit ()
@@ -3523,23 +3533,44 @@ def args_parser(self) -> ArgumentParserNoExit:
35233533 return parser
35243534
35253535 def on_exec (self , args : argparse .Namespace ):
3526- if args .set is not None :
3527- if not 1000 <= args .set <= 60000 :
3528- print (f"{ CR } Error: Wake-up time must be between 1000 and 60000 milliseconds{ C0 } " )
3529- return
3530-
3531- resp = self .cmd .set_wakeup_field_time (args .set )
3532- if resp .status == Status .SUCCESS :
3533- print (f"Successfully set field detection wake-up time to { args .set } ms" )
3534- print (f"{ CY } Do not forget to store your settings in flash!{ C0 } " )
3535- else :
3536- print (f"Failed to set field detection wake-up time: { Status (resp .status )} " )
3537- else :
3538- resp = self .cmd .get_wakeup_field_time ()
3539- if resp .status == Status .SUCCESS :
3540- print (f"Field detection wake-up time: { resp .parsed } ms" )
3536+ try :
3537+ if args .set is not None :
3538+ print (f"[CLI] Setting field detection wake-up time to { args .set } ms" )
3539+ try :
3540+ resp = self .cmd .set_wakeup_field_time (args .set )
3541+ if resp is None :
3542+ print (f"{ CR } Error: No response from device{ C0 } " )
3543+ return
3544+
3545+ print (f"{ CG } Successfully set field detection wake-up time to { args .set } ms{ C0 } " )
3546+
3547+ # Try to save settings to flash
3548+ try :
3549+ print ("Saving settings to flash..." )
3550+ save_resp = self .cmd .save_settings ()
3551+ if save_resp and hasattr (save_resp , 'status' ):
3552+ if save_resp .status == Status .SUCCESS :
3553+ print (f"{ CG } Settings saved to flash memory{ C0 } " )
3554+ else :
3555+ print (f"{ CY } Warning: Save failed with status: { Status (save_resp .status ).name } { C0 } " )
3556+ else :
3557+ print (f"{ CY } Warning: Invalid response when saving settings{ C0 } " )
3558+ except Exception as e :
3559+ print (f"{ CY } Warning: Could not save settings: { str (e )} { C0 } " )
3560+
3561+ except Exception as e :
3562+ print (f"{ CR } Error setting field detection wake-up time: { str (e )} { C0 } " )
35413563 else :
3542- print (f"Failed to get field detection wake-up time: { Status (resp .status )} " )
3564+ print ("[CLI] Getting field detection wake-up time" )
3565+ resp = self .cmd .get_wakeup_field_time ()
3566+ if resp is None :
3567+ print (f"{ CR } Error: No response from device{ C0 } " )
3568+ elif resp .status == Status .SUCCESS :
3569+ print (f"Field detection wake-up time: { CG } { resp .parsed } ms{ C0 } " )
3570+ else :
3571+ print (f"{ CR } Failed to get field detection wake-up time: { Status (resp .status ).name } { C0 } " )
3572+ except Exception as e :
3573+ print (f"{ CR } Error: { str (e )} { C0 } " )
35433574
35443575
35453576@hw_settings .command ('bleclearbonds' )
0 commit comments