feat: add NFC tag write support (command 0x0083)#137
Merged
Conversation
Adds validate_nfc_response() for the NFC_ENDPOINT (0x0083) response
frames, distinguishing the write-OK (0x81) and chunk-ACK (0x82)
statuses that the generic validate_ack_response() cannot tell apart,
and decoding the firmware's dedicated {0xFF, 0x83, 0xFF, err} error
frame via NfcWriteError. NfcNotSupportedError covers the separate
case of no response at all, which pre-0x83 firmware produces for any
unknown opcode and so cannot be treated as a confirmed rejection.
Adds the public async NFC write API (write_nfc, write_nfc_url, write_nfc_text, write_nfc_mime) on OpenDisplayDevice, tying together the NFC_ENDPOINT command builders and response validation from the prior two tasks. Inline payloads use a single write; larger payloads chunk through start/data/end frames. A read timeout on the first response of a write maps to NfcNotSupportedError (silent pre-0x83 firmware); later timeouts propagate.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds host-side support for the firmware NFC endpoint (command 0x0083, moved from 0x0082 which collided with PIPE_WRITE_END).
Layers
CommandCode.NFC_ENDPOINT,NfcRecordTypeenum (TEXT/URI/WELL_KNOWN_RAW/MIME/RAW_NDEF), builders for inline write and chunked write (start/data/end), constants (inline threshold 120, chunk size 120, max total 512 matching the firmware staging buffer).validate_nfc_responsedistinguishing write OK (0x81) from chunk ACK (0x82) and decoding the{0xFF,0x83,0xFF,err}error frame intoNfcWriteError(witherror_code).NfcNotSupportedErrorcovers silence from pre-0x83 firmware, which does not NACK unknown opcodes.write_nfc(rec_type, payload)with automatic inline/chunked selection, pluswrite_nfc_url,write_nfc_text, andwrite_nfc_mime(vCards etc., payload[mime_len][mime_type][body]).Verification
NfcNotSupportedError.Consumed by the Home Assistant integration's upcoming
write_nfcaction.