feat: offline HIDProx tag copy

- refines comments
- use unified code for `lf tag not found` error
- merge lf_em410x_data.h & lf_hidprox_data.h, remove unused macros
- split btn_fn_copy_ic_uid as btn_fn_copy_lf & btn_fn_copy_hf
- fixes offline em410x tag copy not working
- fixes conflict SAADC usage between battery level service & lf fsk demodulator
This commit is contained in:
TeCHiScy
2025-08-11 21:01:04 +08:00
parent 584284c5d5
commit b4c1c63698
24 changed files with 354 additions and 455 deletions
+3 -16
View File
@@ -466,19 +466,6 @@ class LFHIDIdArgsUnit(DeviceRequiredUnit):
if oem is not None and oem > limit[3]:
raise ArgsParserError(f"{HIDFormat(format)}: OEM must between 0 to {limit[3]}")
"""
HIDFormat.: [0xFFF, 0x3FFFF, 0x7, 0],
HIDFormat.: [0x3FF, 0xFFFFFF, 0, 0x7],
HIDFormat.: [0xFFFF, 0xFFFFF, 0, 0],
HIDFormat.: [0xFFF, 0xFFFF, 0, 0],
HIDFormat.: [0, 0xFFFFFFFFFF, 0, 0],
HIDFormat.: [0xFFF, 0xFFFFF, 0, 0x7F],
HIDFormat.: [0x3FFF, 0x3FFFFFFF, 0, 0],
HIDFormat.: [0x003FFFFF, 0x007FFFFF, 0, 0],
HIDFormat.: [0xFFFFF, 0x3FFFFFFFF, 0, 0],
HIDFormat.: [0xFFFFFF, 0xFFFFFFFF, 0, 0],
"""
def before_exec(self, args: argparse.Namespace):
if super().before_exec(args):
format = HIDFormat.H10301.value
@@ -3209,9 +3196,9 @@ class LFHIDProxEconfig(SlotIndexArgsAndGoUnit, LFHIDIdArgsUnit):
args.il = 0
if args.oem is None:
args.oem = 0
if args.format is None:
format = HIDFormat.H10301
format = HIDFormat[args.format]
format = HIDFormat.H10301
if args.format is not None:
format = HIDFormat[args.format]
id = struct.pack(">BIBIBH", format.value, args.fc, (args.cn >> 32), args.cn & 0xffffffff, args.il, args.oem)
self.cmd.hidprox_set_emu_id(id)
print(' - Set hidprox tag id success.')
+1 -2
View File
@@ -434,7 +434,7 @@ class ChameleonCMD:
"""
resp = self.device.send_cmd_sync(Command.EM410X_SCAN)
if resp.status == Status.LF_TAG_OK:
resp.parsed = struct.unpack('!h5s', resp.data[0:7]) # card type + uid
resp.parsed = struct.unpack('!h5s', resp.data) # tag type + uid
return resp
@expect_response(Status.LF_TAG_OK)
@@ -475,7 +475,6 @@ class ChameleonCMD:
data = struct.pack(f'!13s4s{4*len(old_keys)}s', id_bytes, new_key, b''.join(old_keys))
return self.device.send_cmd_sync(Command.HIDPROX_WRITE_TO_T55XX, data)
@expect_response(Status.SUCCESS)
def get_slot_info(self):
"""
+1 -9
View File
@@ -137,11 +137,7 @@ class Status(enum.IntEnum):
# Some operations with low frequency cards succeeded!
LF_TAG_OK = 0x40
# Unable to search for a valid EM410X tag
EM410X_TAG_NO_FOUND = 0x41
# Unable to search for a valid LF tag
LF_TAG_NO_FOUND = 0x42
# Unable to search for a valid HIDProx tag
HIDPROX_TAG_NO_FOUND = 0x43
LF_TAG_NO_FOUND = 0x41
# The parameters passed by the BLE instruction are wrong, or the parameters passed
# by calling some functions are wrong
@@ -176,12 +172,8 @@ class Status(enum.IntEnum):
return "HF tag was supposed to send ATS but didn't"
elif self == Status.LF_TAG_OK:
return "LF tag operation succeeded"
elif self == Status.EM410X_TAG_NO_FOUND:
return "EM410x tag no found"
elif self == Status.LF_TAG_NO_FOUND:
return "LF tag not found"
elif self == Status.HIDPROX_TAG_NO_FOUND:
return "HIDProx tag no found"
elif self == Status.PAR_ERR:
return "API request fail, param error"
elif self == Status.DEVICE_MODE_ERROR: