Skip to content

NFC over neard - #17

Merged
colemancda merged 16 commits into
masterfrom
feature/nfc
Nov 22, 2026
Merged

colemancda merged 16 commits into
masterfrom
feature/nfc

Conversation

@colemancda

Copy link
Copy Markdown
Member

Implements the NFC contracts on Linux over neard (org.neard on the system bus): the reader role, reading and writing NDEF. Plan.md gains §13 NFC, and the later sections are renumbered.

Sessions.

  • begin polls the first adapter that's on (StartPollLoop("Initiator")).
  • A tag is reported once neard has read its records. neard sends its own org.neard.Tag.PropertyChanged("Records") signal for that, and it can arrive before the tag's InterfacesAdded. A tag with no NDEF gets no such signal, so it's reported after a second without one.
  • neard won't poll while a tag is in the field, and doesn't start again on its own. So restartPolling, and a tag of a kind not asked for, poll again once the field is empty.
  • The process has one session at a time.

Tags.

  • Operations run one at a time per tag, in order, and each gets one callback on the next turn.
  • neard publishes records as properties, not bytes.
    • Reading gives text, URI, MIME, Smart Poster and Android application records. Handovers are left out.
    • Writing takes text, URI and MIME records, as one record or under Records. A read after a write waits for neard to read the tag again.
  • neard has no way to lock a tag or send it raw commands, so writeLock and transceive fail with unsupported.
  • queryNDEFStatus reports a capacity of 0, because neard doesn't say how much a tag holds.
  • The NDEF model is the Android host's.

Not in this PR: raw commands. The kernel has AF_NFC raw sockets, but neard holds the tag it found.

Testing.

  • The contract is tested against a fake neard that plays its adapter, tags, records and signals. neard's records are tested as NDEF and back. The packager accepts the contracts with nfc.
  • The full suite passes on Linux (Debian trixie, aarch64, Swift 6.4.2).
  • Nothing has run against real neard and an adapter. The behaviour follows neard's source, which differs from its docs in places.

This PR is independent of #16 (Motion), but both touch Plan.md, the README, Package.swift and the module lists. Whichever merges second needs a rebase, and Plan.md's sections renumbered.

@colemancda
colemancda merged commit 6637e6d into master Nov 22, 2026
2 checks passed
@colemancda
colemancda deleted the feature/nfc branch November 22, 2026 14:03
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