Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/core/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,16 @@ func WriteDataWithURL(readerName string, data []byte, dataType string, url strin
if err := writeMifareClassic(card, ndefMessage); err != nil {
return fmt.Errorf("failed to write NDEF message: %w", err)
}
} else if cardInfo.Protocol == "NFC-V" {
// ISO 15693 (ICode SLI/SLIX/SLIX2): CC at block 0, NDEF TLV at block 1.
// Do NOT pad to card.Size — writing past block 79 causes errors on ICode SLIX2.
cc := []byte{0xE1, 0x40, 0x40, 0x00}
if err := writeNTAGPages(card, 0, cc); err != nil {
return fmt.Errorf("failed to write NDEF message: %w", err)
}
if err := writeNTAGPages(card, 1, ndefMessage); err != nil {
return fmt.Errorf("failed to write NDEF message: %w", err)
}
} else {
// NTAG and other cards use page-based writes.
// Zero-fill remaining user pages after the NDEF data so leftover
Expand Down
62 changes: 37 additions & 25 deletions internal/openprinttag/openprinttag.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ const (
type MaterialType uint8

const (
// FFF material types
// FFF material types — valeurs conformes spec OpenPrintTag (material_type_enum.yaml)
MaterialTypePLA MaterialType = 0
MaterialTypeABS MaterialType = 1
MaterialTypePETG MaterialType = 2
MaterialTypeASA MaterialType = 3
MaterialTypePC MaterialType = 4
MaterialTypeNylon MaterialType = 5
MaterialTypeTPU MaterialType = 6
MaterialTypePVA MaterialType = 7
MaterialTypeHIPS MaterialType = 8
MaterialTypePP MaterialType = 9
MaterialTypePEI MaterialType = 10
MaterialTypePEEK MaterialType = 11
MaterialTypePA MaterialType = 12
MaterialTypePACF MaterialType = 13
MaterialTypePAGF MaterialType = 14
MaterialTypePLACF MaterialType = 15
MaterialTypePLAGF MaterialType = 16
MaterialTypePETGCF MaterialType = 17
MaterialTypePETGGF MaterialType = 18
MaterialTypePETG MaterialType = 1
MaterialTypeTPU MaterialType = 2
MaterialTypeABS MaterialType = 3
MaterialTypeASA MaterialType = 4
MaterialTypePC MaterialType = 5
MaterialTypePCTG MaterialType = 6
MaterialTypePP MaterialType = 7
MaterialTypePA MaterialType = 8 // PA6
MaterialTypeHIPS MaterialType = 14
MaterialTypePEI MaterialType = 17
MaterialTypePVA MaterialType = 20
MaterialTypePEEK MaterialType = 22
MaterialTypeNylon MaterialType = 56 // générique, hors spec de base
MaterialTypePACF MaterialType = 100 // composite, valeur propriétaire
MaterialTypePAGF MaterialType = 101
MaterialTypePLACF MaterialType = 102
MaterialTypePLAGF MaterialType = 103
MaterialTypePETGCF MaterialType = 104
MaterialTypePETGGF MaterialType = 105
MaterialTypeOther MaterialType = 255
)

Expand Down Expand Up @@ -173,6 +174,11 @@ type Response struct {
MaterialUUID string `json:"materialUuid,omitempty"`
BrandUUID string `json:"brandUuid,omitempty"`

// Brand-specific identifiers (MainSection keys 5-7)
BrandSpecificInstanceID string `json:"brandSpecificInstanceId,omitempty"`
BrandSpecificPackageID string `json:"brandSpecificPackageId,omitempty"`
BrandSpecificMaterialID string `json:"brandSpecificMaterialId,omitempty"`

// Weight information
NominalWeight float32 `json:"nominalWeight,omitempty"`
ConsumedWeight float32 `json:"consumedWeight,omitempty"`
Expand Down Expand Up @@ -272,6 +278,11 @@ func (o *OpenPrintTag) ToResponse() *Response {
resp.BrandUUID = formatUUID(o.Main.BrandUUID)
}

// Brand-specific identifiers
resp.BrandSpecificInstanceID = o.Main.BrandSpecificInstanceID
resp.BrandSpecificPackageID = o.Main.BrandSpecificPackageID
resp.BrandSpecificMaterialID = o.Main.BrandSpecificMaterialID

// Convert color to hex string
if len(o.Main.PrimaryColor) >= 3 {
resp.PrimaryColor = colorToHex(o.Main.PrimaryColor)
Expand All @@ -296,18 +307,19 @@ func materialClassToString(mc MaterialClass) string {
func materialTypeToString(mt MaterialType) string {
names := map[MaterialType]string{
MaterialTypePLA: "PLA",
MaterialTypeABS: "ABS",
MaterialTypePETG: "PETG",
MaterialTypeTPU: "TPU",
MaterialTypeABS: "ABS",
MaterialTypeASA: "ASA",
MaterialTypePC: "PC",
MaterialTypeNylon: "Nylon",
MaterialTypeTPU: "TPU",
MaterialTypePVA: "PVA",
MaterialTypeHIPS: "HIPS",
MaterialTypePCTG: "PCTG",
MaterialTypePP: "PP",
MaterialTypePA: "PA",
MaterialTypeHIPS: "HIPS",
MaterialTypePEI: "PEI",
MaterialTypePVA: "PVA",
MaterialTypePEEK: "PEEK",
MaterialTypePA: "PA",
MaterialTypeNylon: "Nylon",
MaterialTypePACF: "PA-CF",
MaterialTypePAGF: "PA-GF",
MaterialTypePLACF: "PLA-CF",
Expand Down