mirror of
https://github.com/pollen-robotics/microduck.git
synced 2026-12-03 02:47:45 +08:00
`nfc.write { text, timeout_s }` (API v55) has nfcd write the text onto the
next NTAG touched to the head, or one already on the reader, as one NDEF
text record, then read it back. The robot quacks when it took. While a
write waits, a touched tag is written rather than acted on, and the tag
just written is not then read as a touch, so writing a pairing tag does
not pair.
nfcd serves it on its own socket, /run/nfcd/nfc.sock (group robot, 0660),
from threads that hand each write to the poll loop, which owns the reader.
`robotctl nfc-flash <text>` asks it there; btd now holds a fourth socket
and permits nfc.write over BLE, so `duckctl nfc-flash <text>` does the same
from a laptop. mediad refuses it: someone has to be at the robot to touch
a tag.
Only Type 2 is written. The capability container decides: a MIFARE Classic
or an e-ink refuses its READ, an unformatted or read-only tag says so, a
text longer than the tag is refused, all before any page is written. Pages
0-3 and the configuration pages are never written, so a write cannot lock
a tag. The WRITE's four-bit ACK is taken loosely — a reader may not frame
it — and the read-back is what says the tag holds the text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>