check_codes.py
Verify that the Matter commissioning codes shown on the browser flasher page still match the firmware it flashes. Recomp…
Overview
Verify that the Matter commissioning codes shown on the browser flasher page still match the firmware it flashes. Recomputes the QR payload and manual pairing code from the CHIP test-setup constants, checks the page against them, and can regenerate the inline QR image.
API
Fcheck_digit(digits: str) -> str
Return the Verhoeff check digit for a decimal string, the last digit of a Matter manual pairing code.
manual_codeFbase38(data: bytes) -> str
Encode bytes in Matter's base-38 alphabet: three bytes become five characters, a two-byte tail four, a one-byte tail two.
qr_payloadFqr_payload(vid=None, pid=None, rendezvous=None, disc=None, passcode=None) -> str
Return the MT: onboarding payload string, packing the fields least-significant-bit first the way CHIP's QRCodeSetupPayloadGenerator does. The arguments exist so self_test() can run CHIP's own vector through this; they resolve at call time, not at definition, so the module constants stay the single source of truth.
main · calls base38Fmanual_code(disc=None, passcode=None) -> str
Return the 11-digit manual pairing code: one digit of discriminator, five of passcode plus discriminator, four of passcode, and a check digit. Arguments resolve at call time; see qr_payload.
main · calls check_digitFgrouped(code: str) -> str
Return the manual pairing code in the 4-3-4 grouping Apple Home and the Matter spec print.
mainFqr_svg(payload: str) -> str
Render the payload as an inline SVG QR code, one path with a horizontal run per dark segment. Needs segno, so this runs only when regenerating.
mainFupstream_layer(payload_ok: list[str]) -> None
Re-read the four upstream constants from an esp-matter checkout when ESP_MATTER_PATH names one, and record a pass, a skip or a failure.
mainFmain() -> int
Check the flasher page's commissioning codes against the constants, or print a fresh QR block with --svg. Returns 1 on drift.
grouped, manual_code, qr_payload, qr_svg, upstream_layer