Skip to content

investigate: capture raw NDEF bytes for app-written tags (#1098, #1106)#1107

Draft
wizzomafizzo wants to merge 2 commits into
mainfrom
investigate/nfc-write-1098-1106
Draft

investigate: capture raw NDEF bytes for app-written tags (#1098, #1106)#1107
wizzomafizzo wants to merge 2 commits into
mainfrom
investigate/nfc-write-1098-1106

Conversation

@wizzomafizzo

Copy link
Copy Markdown
Member

Why

App-written NTAG213 tags don't launch on Core (#1098, #1106). Across the attached logs the failing
scans show a validly-formatted NTAG213 (valid Capability Container → variant=NTAG213,
hasNDEF=true) whose NDEF message is empty: messageNil=false with zero records, which is emitted
only when the NDEF TLV has a length byte of 0 (03 00). The record the app intended to write is not
where Core reads it.

go-pn532 already prints the exact bytes it reads from a tag (readNDEFHeader: user data = [...]) via
Debugf, but Core never wired that output anywhere, so the decisive bytes are absent from every log.
This PR captures them.

What

  • New pkg/readers/pn532/debug.go: a zerologDebugWriter that forwards each go-pn532 debug line to
    log.Debug().Str("src","pn532"), installed once via sync.Once.
  • pkg/readers/pn532/pn532.go: Open installs it when the existing debug_logging config is
    enabled. No new config key.
  • Pairs with a new SetDebugWriter(io.Writer) hook in go-pn532 (see note below).

With debug_logging on, a failing app-written tag and a working Core-written tag can be scanned and
their byte dumps diffed to decide write-side vs read-side.

⚠️ Draft — remove local go-pn532 wiring before merge

This branch builds against a local sibling ../go-pn532 checkout because the SetDebugWriter
hook it calls is not yet in a released go-pn532. Two temporary bits must be undone before this can
merge:

  1. go.modreplace github.com/ZaparooProject/go-pn532 => ../go-pn532
  2. scripts/tasks/docker.yml — the GOPN532_MOUNT var + its {{.GOPN532_MOUNT}} mount, which
    bind the sibling checkout into the build container so the replace resolves there too.

Before merge: land SetDebugWriter in go-pn532, cut a release, bump the go-pn532 version in go.mod,
and delete both items above.

Status

Parked pending on-device reproduction (a physically app-written failing tag scanned on the MiSTer
with debug_logging on). If the captured bytes show a genuine empty NDEF (03 00), the fix is
app-side (write read-back verification); if they show a valid record Core misreads, a read-side fix
lands in go-pn532.

An app-team write-up (read-back verification for #1098, hidden error toast for #1106) is kept locally
in docs/plans/nfc-app-write-verification.md (that directory is git-excluded, so it is not in this
PR).

App-written NTAG213 tags (#1098, #1106) read on Core as a validly-formatted
tag with an empty NDEF message (messageNil=false, zero records = an NDEF TLV
of length 0). go-pn532 already prints the raw bytes it reads from the tag via
Debugf, but Core never captured that output, so the decisive bytes never
reached the log.

Add a zerolog adapter in the PN532 reader that forwards go-pn532's debug lines
to log.Debug(), installed once when the existing debug_logging config is on.
Pairs with go-pn532's new SetDebugWriter hook.

Includes temporary local wiring to build against a sibling go-pn532 checkout
(go.mod replace + docker mount); see PR description for removal.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e46e772-147c-42a0-bd41-eb920599ae2d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch investigate/nfc-write-1098-1106

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant