fix(lf): per-protocol identify label (native HID/AWID/FDX-B no longer KeyError)
identify_lf built its label from emitted['id_hex'], which only EM4100 provides — a native HID/AWID/FDX-B tag (no T5577 config) would KeyError. Add credential_label() to format each decoder's own fields: "HID Prox H10301 FC.. Card..", "AWID-26 FC.. Card..", "FDX-B 124-000000000555 (animal)", "EM4100 <id>". Tests for native FDX-B + HID labels. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -343,6 +343,19 @@ class TestIdentifyLF:
|
||||
assert r["found"] and r["chip"] is None
|
||||
assert r["label"] == "EM4100 1122334455"
|
||||
|
||||
def test_native_fdxb_label(self):
|
||||
# a native FDX-B tag (no T55xx) must label per-protocol, not KeyError on id_hex
|
||||
dev = _mock_lf_device(config_env=bytes([128] * 4000),
|
||||
emitted_env=_fdxb_env(124, 555, animal=1))
|
||||
r = identify_lf(dev)
|
||||
assert r["found"] and r["chip"] is None
|
||||
assert r["label"].startswith("FDX-B 124-000000000555")
|
||||
|
||||
def test_native_hid_label(self):
|
||||
dev = _mock_lf_device(config_env=bytes([128] * 4000), emitted_env=_hid_env(12, 3456))
|
||||
r = identify_lf(dev)
|
||||
assert r["label"] == "HID Prox H10301 FC 12 Card 3456"
|
||||
|
||||
def test_nothing_on_antenna(self):
|
||||
dev = _mock_lf_device(config_env=bytes([128] * 4000), emitted_env=bytes([128] * 4000))
|
||||
assert identify_lf(dev) is None
|
||||
|
||||
Reference in New Issue
Block a user