From 43524a8ef567dfce30a992e550251edfd305af4f Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Fri, 24 Feb 2023 14:49:14 -0500 Subject: [PATCH] support NDEF test cases >= 256 bytes --- testing/conftest.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index a2cbcde6..6bc020b7 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -1383,11 +1383,21 @@ def nfc_write(request, only_mk4): return doit_usb def ccfile_wrap(recs): + from struct import pack CC_FILE = bytes([0xE2, 0x43, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x03]) - if len(recs) >= 255: # testing code limitation here FIXME - raise pytest.xfail('cant do NFC > 250 bytes yet in tests') - return CC_FILE + bytes([len(recs)]) + recs + b'\xfe' + ln = len(recs) + rv = bytearray(CC_FILE) + if ln <= 0xfe: + rv.append(ln) + else: + rv.append(0xff) + rv.extend(pack('>H', ln)) + + rv.extend(recs) + rv.extend(b'\xfe') + + return rv @pytest.fixture() def nfc_write_text(nfc_write):