Skip to content

feat: add NTAG215/216 NDEF text record parser for filament#1

Open
bonduodevs wants to merge 2 commits into
Snapmaker:mainfrom
bonduodevs:feature/ntag215-support
Open

feat: add NTAG215/216 NDEF text record parser for filament#1
bonduodevs wants to merge 2 commits into
Snapmaker:mainfrom
bonduodevs:feature/ntag215-support

Conversation

@bonduodevs
Copy link
Copy Markdown

@bonduodevs bonduodevs commented Apr 2, 2026

Summary

Add NTAG215/216 (NFC Forum Type 2 Tag) support to the FM175xx RFID reader, enabling automatic filament identification from third-party NFC-tagged spools.

Motivation

The current RFID system only recognizes MIFARE Classic M1 cards (SAK=0x08), which limits filament auto-detection to official Snapmaker-tagged spools. Many third-party filament manufacturers/personal use NTAG215/216 NFC tags. This change allows those tags to be read and parsed automatically, providing material type and color information to the printer.

How It Works

  • After ISO14443-A activation, the reader checks the SAK byte:
    • SAK=0x08 → existing M1 flow (unchanged)
    • SAK=0x00 → new NTAG flow: read user memory pages, parse NDEF Text Record
  • Users write a simple MATERIAL#RRGGBB string to the NTAG tag using any NFC app (e.g. NFC Tools)
    • Example: PLA#FF5733 (orange PLA), PETG#FFFFFF (white PETG)
  • The parsed material type is matched against the built-in filament_parameters database for temperature and flow defaults
  • The filament info is delivered through the same callback pipeline as M1 cards — downstream code is unaware of the tag type

For basic users

  • Write PLA#FF5733 as a Text Record on any NTAG215/216 tag using NFC Tools or similar app and U1 handles the rest automatically. It will now automatically detect your filaments in U1!

Changes (Too simple)

File Change
klippy/extras/filament_protocol.py Add ntag_ndef_data_parse() — NDEF TLV + Text Record parser, returns filament_info dict with VENDOR='Generic', OFFICIAL=False
klippy/extras/fm175xx_reader.py Add FM175XX_MIFARE_CARD_TYPE_NTAG constant, __reader_a_ntag_read_user_data() page reader, and SAK-based elif branch in background thread
klippy/extras/filament_detect.py Add elif routing for NTAG card type in _fm175xx_card_info_deal_callback

3 files changed, 203 insertions(+), 0 deletions(-)

Backward Compatibility

  • No existing code modified — all changes are additive elif branches and new functions
  • M1 card detection, HKDF authentication, and RSA signature verification are completely untouched
  • No configuration changes required (printer.cfg works as-is)

Supported Tag Format

Field Format Example
NDEF Record Type Text (T)
Language any (skipped) en
Payload MATERIAL#RRGGBB PLA#FF5733

Supported materials: PLA, PLA-CF, PETG, PETG-CF, PETG-HF, PCTG, ABS, ASA, TPU, PVA, PA, PA-CF, PA6-CF, PA-GF, PA6-GF, PC, PC-ABS, EVA

@bonduodevs bonduodevs marked this pull request as ready for review April 2, 2026 14:24
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