Skip to content

Fix: MaterialType enum values to match OpenPrintTag specification#5

Open
gienne wants to merge 10 commits into
SimplyPrint:mainfrom
gienne:main
Open

Fix: MaterialType enum values to match OpenPrintTag specification#5
gienne wants to merge 10 commits into
SimplyPrint:mainfrom
gienne:main

Conversation

@gienne

@gienne gienne commented Jun 1, 2026

Copy link
Copy Markdown

Problem

The MaterialType enum constants in openprinttag.go do not match the official OpenPrintTag specification (material_type_enum.yaml).

The enum was shifted from position 1 onward, causing incorrect material type decoding. For example, a Prusament ASA Signal White spool is returned as "materialType":"PC" instead of "materialType":"ASA".

Root cause

Value nfc-agent (before) OpenPrintTag spec
0 PLA PLA
1 ABS PETG
2 PETG TPU
3 ASA ABS
4 PC ASA
5 Nylon PC
6 TPU PCTG
7 PVA PP
8 HIPS PA6
9 PP PA11
10 PEI PA12
11 PEEK PA66
12 PA CPE
13 PA-CF TPE
14 PA-GF HIPS
15 PLA-CF PHA
16 PLA-GF PET
17 PETG-CF PEI
18 PETG-GF PBT
255 Other Other

Only value 0 (PLA) was correct. Every other type was misidentified.

Fix

Enum constants updated to match the official spec order (values 0–22 corrected). Composite types (PA-CF, PLA-CF, etc.) not defined in the base spec are assigned vendor-specific values above 100 to avoid collisions.

Tested with

  • Reader: ACS ACR1552U-M1 (ISO 15693 / NFC-V)
  • Tag: Prusament ASA Signal White (ICode SLIX2)
  • materialType now correctly returns "ASA"

gienne added 3 commits June 1, 2026 17:49
WriteDataWithURL was calling writeNTAGPages(card, 4, ...) for all non-MIFARE
cards, including ISO 15693 (NFC-V) tags such as the NXP ICode SLIX2 used on
Prusa filament spools.

Two bugs for ISO 15693:
1. Wrong start block: NTAG user memory begins at page 4; ISO 15693 NDEF begins
   at block 1 (block 0 holds the Capability Container).
2. Padding to card.Size (320 bytes) caused writes to blocks 80-83, which are
   out of range for ICode SLIX2 (80 blocks, 0-79).

Fix: detect NFC-V protocol and write CC to block 0 then NDEF TLV from block 1,
mirroring the correct logic already present in WriteMultipleRecords.

Tested on ACR1552U with blank NXP ICode SLIX2 tags and with Prusa-branded
filament spool tags (write + readback verified).
Add BrandSpecificInstanceID, BrandSpecificPackageID and BrandSpecificMaterialID
to the Response struct so they are included in the JSON output of the card read
API endpoint.

These fields are already decoded from the CBOR payload (MainSection keys 5-7)
but were not propagated to the API response, making them invisible to consumers
of the /v1/readers/{n}/card endpoint.

Use cases:
- BrandSpecificInstanceID: per-spool serial/lot number (e.g. Prusa instance ref)
  useful for traceability and inventory management systems
- BrandSpecificPackageID: product/SKU reference for the package
- BrandSpecificMaterialID: material reference identifier

JSON keys follow the existing camelCase convention used by the other UUID
fields (instanceUuid, packageUuid, etc.).
gienne added 7 commits June 16, 2026 09:57
Binary payloads (CBOR/OpenPrintTag) can contain 0xFE as a data byte.
Once NDEF TLV length is known, use length-based termination instead
of byte-scanning for the 0xFE terminator. Fixes ICode SLIX2 reads
stopping at 60 bytes when a UUID byte equals 0xFE.
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