mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
Merge branch 'master' into patch-1
This commit is contained in:
@@ -77,6 +77,17 @@ def cmdLog(chameleon, arg):
|
||||
bytesReceived = chameleon.cmdDownloadLog(fileHandle)
|
||||
return "{} Bytes successfully written to {}".format(bytesReceived, arg)
|
||||
|
||||
def cmdLogMode(chameleon, arg):
|
||||
result = chameleon.cmdLogMode(arg)
|
||||
|
||||
if (arg is None):
|
||||
return "Current logmode is: {}".format(result['response'])
|
||||
else:
|
||||
if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS):
|
||||
return "logmode have been set to {}".format(arg)
|
||||
else:
|
||||
return "Setting logmode failed: {}".format(arg, result['statusText'])
|
||||
|
||||
def cmdLButton(chameleon, arg):
|
||||
result = chameleon.cmdLButton(arg)
|
||||
|
||||
@@ -155,6 +166,22 @@ def cmdRedLED(chameleon, arg):
|
||||
else:
|
||||
return "Setting red LED function to {} failed: {}".format(arg, result['statusText'])
|
||||
|
||||
def cmdThreshold(chameleon, arg):
|
||||
result = chameleon.cmdThreshold(arg)
|
||||
|
||||
if (arg is None):
|
||||
return "Current threshold is: {}".format(result['response'])
|
||||
else:
|
||||
if (result['statusCode'] in chameleon.STATUS_CODES_SUCCESS):
|
||||
return "Threshold have been set to {}".format(arg)
|
||||
else:
|
||||
return "Setting threshold failed: {}".format(arg, result['statusText'])
|
||||
|
||||
def cmdUpgrade(chameleon, arg):
|
||||
if(chameleon.cmdUpgrade() == 0):
|
||||
print ("Device changed into Upgrade Mode")
|
||||
exit(0)
|
||||
|
||||
# Custom class for argparse
|
||||
class CmdListAction(argparse.Action):
|
||||
def __init__(self, option_strings, dest, default=False, required=False,
|
||||
@@ -188,12 +215,16 @@ def main():
|
||||
cmdArgGroup.add_argument("-I", "--identify", dest="identify", action=CmdListAction, nargs='?', help="identify device in range")
|
||||
cmdArgGroup.add_argument("-D", "--dumpmfu", dest="dumpmfu", action=CmdListAction, nargs='?', help="dump information about card in range")
|
||||
cmdArgGroup.add_argument("-c", "--config", dest="config", action=CmdListAction, metavar="CFGNAME", nargs='?', help="retrieve or set the current configuration")
|
||||
cmdArgGroup.add_argument("-lm", "--logmode", dest="logmode", action=CmdListAction, metavar="LOGMODE", nargs='?', help="retrieve or set the current log mode")
|
||||
cmdArgGroup.add_argument("-lb", "--lbutton", dest="lbutton", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current left button action")
|
||||
cmdArgGroup.add_argument("-lbl", "--lbuttonlong", dest="lbutton_long", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current left button long press action")
|
||||
cmdArgGroup.add_argument("-rb", "--rbutton", dest="rbutton", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current right button action")
|
||||
cmdArgGroup.add_argument("-rbl", "--rbuttonlong", dest="rbutton_long", action=CmdListAction, metavar="ACTION", nargs='?', help="retrieve or set the current right button long press action")
|
||||
cmdArgGroup.add_argument("-gl", "--gled", dest="gled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current green led function")
|
||||
cmdArgGroup.add_argument("-rl", "--rled", dest="rled", action=CmdListAction, metavar="FUNCTION", nargs='?', help="retrieve or set the current red led function")
|
||||
cmdArgGroup.add_argument("-th", "--threshold", dest="threshold", action=CmdListAction, nargs='?', help="retrieve or set the threshold")
|
||||
cmdArgGroup.add_argument("-ug", "--upgrade", dest="upgrade", action=CmdListAction, nargs=0, help="set the micro Controller to upgrade mode")
|
||||
|
||||
args = argParser.parse_args()
|
||||
|
||||
if (args.verbose):
|
||||
@@ -218,12 +249,15 @@ def main():
|
||||
"upload" : cmdUpload,
|
||||
"download" : cmdDownload,
|
||||
"log" : cmdLog,
|
||||
"logmode" : cmdLogMode,
|
||||
"lbutton" : cmdLButton,
|
||||
"lbutton_long" : cmdLButtonLong,
|
||||
"rbutton_long" : cmdRButtonLong,
|
||||
"rbutton" : cmdRButton,
|
||||
"gled" : cmdGreenLED,
|
||||
"rled" : cmdRedLED,
|
||||
"threshold" : cmdThreshold,
|
||||
"upgrade" : cmdUpgrade,
|
||||
}
|
||||
|
||||
if hasattr(args, "cmdList"):
|
||||
|
||||
Reference in New Issue
Block a user