diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4949b08..7803ed3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,13 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.2.0
+ rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
+ exclude: docs_src/media/adhesive_spec.pdf
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.9.9
+ rev: v0.14.5
hooks:
- id: ruff-format
diff --git a/data/aux_fields.yaml b/data/aux_fields.yaml
index 2455e61..19e2677 100644
--- a/data/aux_fields.yaml
+++ b/data/aux_fields.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/fields.yaml
- key: 0
name: consumed_weight
type: number
diff --git a/data/config_nfcv.yaml b/data/config_nfcv.yaml
index 8524105..3300931 100644
--- a/data/config_nfcv.yaml
+++ b/data/config_nfcv.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/config.yaml
mime_type: application/vnd.openprinttag
root: nfcv
meta_fields: meta_fields.yaml
diff --git a/data/config_noroot.yaml b/data/config_noroot.yaml
index 14e9e07..d8d9469 100644
--- a/data/config_noroot.yaml
+++ b/data/config_noroot.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/config.yaml
mime_type: application/vnd.openprinttag
root: none
meta_fields: meta_fields.yaml
diff --git a/data/main_fields.yaml b/data/main_fields.yaml
index a03b616..54581bd 100644
--- a/data/main_fields.yaml
+++ b/data/main_fields.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/fields.yaml
- key: 0
name: instance_uuid
type: uuid
@@ -185,10 +186,8 @@
- key: 19
name: primary_color
- type: bytes
- max_length: 4
+ type: color_rgba
required: recommended
- unit: "[R, G, B] or [R, G, B, A]"
example: "`\\xff\\x00\\x00\\x7f`"
description:
- Primary color of the material in the RGB(A) format, intended for UI purposes.
@@ -197,39 +196,29 @@
- key: 20
name: secondary_color_0
- type: bytes
- max_length: 4
- unit: "[R, G, B] or [R, G, B, A]"
+ type: color_rgba
description:
- One of secondary colors of the material.
- Data format is the same as for `primary_color`.
- key: 21
name: secondary_color_1
- type: bytes
- max_length: 4
- unit: "[R, G, B] or [R, G, B, A]"
+ type: color_rgba
description: See `secondary_color_0`.
- key: 22
name: secondary_color_2
- type: bytes
- max_length: 4
- unit: "[R, G, B] or [R, G, B, A]"
+ type: color_rgba
description: See `secondary_color_0`.
- key: 23
name: secondary_color_3
- type: bytes
- max_length: 4
- unit: "[R, G, B] or [R, G, B, A]"
+ type: color_rgba
description: See `secondary_color_0`.
- key: 24
name: secondary_color_4
- type: bytes
- max_length: 4
- unit: "[R, G, B] or [R, G, B, A]"
+ type: color_rgba
description: See `secondary_color_0`.
- key: 25
@@ -256,6 +245,13 @@
required: recommended
description: Properties of the material. Can have multiple tags at once.
+- key: 56
+ name: certifications
+ type: enum_array
+ items_file: material_certifications_enum.yaml
+ example: "`ul_2818`"
+ description: Certifications the material has.
+
- key: 29
name: density
type: number
diff --git a/data/material_certifications_enum.yaml b/data/material_certifications_enum.yaml
new file mode 100644
index 0000000..080081e
--- /dev/null
+++ b/data/material_certifications_enum.yaml
@@ -0,0 +1,12 @@
+- key: 0
+ name: ul_2818
+ display_name: UL 2818
+ description:
+ - GREENGUARD Certification Program For Chemical Emissions For Building Materials, Finishes And Furnishings.
+
+- key: 1
+ name: ul_94_v0
+ display_name: UL 94 V0
+ description:
+ - Standard for Safety of Flammability of Plastic Materials for Parts in Devices and Appliances testing.
+ - Indicates a flame-retardant material.
diff --git a/data/material_class_enum.yaml b/data/material_class_enum.yaml
index 84d37d9..376c41d 100644
--- a/data/material_class_enum.yaml
+++ b/data/material_class_enum.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/material_class_enum.yaml
- key: 0
name: FFF
description: Filament
diff --git a/data/material_type_enum.yaml b/data/material_type_enum.yaml
index 8abaa85..3571e01 100644
--- a/data/material_type_enum.yaml
+++ b/data/material_type_enum.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/material_type_enum.yaml
- key: 0
abbreviation: PLA
name: Polylactic Acid
diff --git a/data/meta_fields.yaml b/data/meta_fields.yaml
index 7993a25..1637b47 100644
--- a/data/meta_fields.yaml
+++ b/data/meta_fields.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/fields.yaml
- key: 0
name: main_region_offset
type: int
diff --git a/data/schema/config.yaml b/data/schema/config.yaml
new file mode 100644
index 0000000..70291a2
--- /dev/null
+++ b/data/schema/config.yaml
@@ -0,0 +1,30 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/config.yaml"
+
+title: Configuration root definition
+description: Schema for OpenPrintTag configuration root definitions.
+
+type: object
+required: [ mime_type, meta_fields, main_fields ]
+properties:
+ mime_type:
+ type: string
+ const: "application/vnd.openprinttag"
+ description: The mime type of the configuration.
+
+ root:
+ type: string
+ enum: [nfcv, none]
+ description: The root container of the OpenPrintTag.
+
+ meta_fields:
+ type: string
+ description: Path to the definitions of the Meta Section fields.
+
+ main_fields:
+ type: string
+ description: Path to the definitions of the Main Region fields.
+
+ aux_fields:
+ type: string
+ description: Path to the definitions of the Auxiliary Section fields.
diff --git a/data/schema/fields.yaml b/data/schema/fields.yaml
new file mode 100644
index 0000000..f022dc3
--- /dev/null
+++ b/data/schema/fields.yaml
@@ -0,0 +1,116 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/fields.yaml"
+
+title: Fields definition
+description: Schema for OpenPrintTag section field definitions.
+
+type: array
+items:
+ oneOf:
+ - $ref: "#/definitions/deprecatedField"
+ - $ref: "#/definitions/basicField"
+ - $ref: "#/definitions/arrayField"
+ - $ref: "#/definitions/enumField"
+
+definitions:
+ deprecatedField:
+ type: object
+ additionalProperties: false
+ description: Deprecated field.
+
+ required: [ key, deprecated ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Index of the field in CBOR.
+ deprecated:
+ type: boolean
+ const: true
+ description: Indicates that the field is deprecated.
+
+ baseField:
+ type: object
+ additionalProperties: false
+
+ required: [ key, type, name ]
+
+ not:
+ required: [ deprecated ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Identifier of the field in CBOR.
+ name:
+ type: string
+ pattern: "^[a-z0-9_]*$"
+ description: Name of the field.
+ unit:
+ type: string
+ description: Unit of measurement for the field.
+ example:
+ type: [ integer, number, string ]
+ description: Example value for the field.
+ required:
+ oneOf:
+ - type: boolean
+ - type: string
+ enum: [recommended]
+ description: Whether the field is required.
+ description:
+ oneOf:
+ - type: string
+ - type: array
+ items: { type: string }
+ description: Description of the field.
+ category:
+ type: string
+ description: Category of the field.
+
+ basicField:
+ allOf:
+ - $ref: "#/definitions/baseField"
+ - description: A basic value.
+
+ required: [ type ]
+
+ properties:
+ type:
+ type: string
+ enum: [ int, number, boolean, uuid, timestamp, color ]
+ description: Type of the field.
+
+ arrayField:
+ allOf:
+ - $ref: "#/definitions/baseField"
+ - description: An array of basic values.
+
+ required: [ type, max_length ]
+
+ properties:
+ type:
+ type: string
+ enum: [ bytes, string ]
+ description: Type of the field.
+ max_length:
+ type: integer
+ minimum: 1
+ description: Maximum number of elements in the array.
+
+ enumField:
+ allOf:
+ - $ref: "#/definitions/baseField"
+ description: An enumerated value.
+
+ required: [ items_file ]
+
+ properties:
+ type:
+ type: string
+ enum: [ enum, enum_array ]
+ items_file:
+ type: string
+ description: Path to the definition containing the list of enum values.
diff --git a/data/schema/material_class_enum.yaml b/data/schema/material_class_enum.yaml
new file mode 100644
index 0000000..a3f0421
--- /dev/null
+++ b/data/schema/material_class_enum.yaml
@@ -0,0 +1,32 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/material_class_enum.yaml"
+
+title: Material class variant definition
+description: Schema for OpenPrintTag material class variant definitions.
+
+type: array
+items:
+ type: object
+ description: Material class variant.
+ additionalProperties: false
+
+ required: [ key, name ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Identifier of the material class in CBOR.
+ name:
+ type: string
+ pattern: "^[A-Z0-9_+-]*$"
+ description: Material class name.
+ description:
+ oneOf:
+ - type: string
+ - type: array
+ items: { type: string }
+ description: Description of the material class.
+ deprecated:
+ type: boolean
+ description: Whether the material class is deprecated.
diff --git a/data/schema/material_type_enum.yaml b/data/schema/material_type_enum.yaml
new file mode 100644
index 0000000..812c8b0
--- /dev/null
+++ b/data/schema/material_type_enum.yaml
@@ -0,0 +1,41 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/material_type_enum.yaml"
+
+title: Material type variant definition
+description: Schema for OpenPrintTag material type variant definitions.
+
+type: array
+items:
+ type: object
+ description: Material type variant.
+ additionalProperties: false
+
+ required: [ key, abbreviation, name, category ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Identifier of the material type in CBOR.
+ abbreviation:
+ type: string
+ pattern: "^[A-Z0-9_+-]*$"
+ description: Material type abbreviation.
+ name:
+ type: string
+ description: Human-readable material type name.
+ category:
+ type: string
+ pattern: "^[A-Z0-9_+-]*$"
+ description:
+ Material type category name.
+ See the `material_class` enum for valid categories.
+ description:
+ oneOf:
+ - type: string
+ - type: array
+ items: { type: string }
+ description: Description of the material class.
+ deprecated:
+ type: boolean
+ description: Whether the material class is deprecated.
diff --git a/data/schema/tag_categories_enum.yaml b/data/schema/tag_categories_enum.yaml
new file mode 100644
index 0000000..4a10926
--- /dev/null
+++ b/data/schema/tag_categories_enum.yaml
@@ -0,0 +1,29 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/tag_category_enum.yaml"
+
+title: Tag category variant definition
+description: Schema for OpenPrintTag tag category variant definitions.
+
+type: array
+items:
+ type: object
+ description: Tag category variant.
+ additionalProperties: false
+
+ required: [ name, display_name ]
+
+ properties:
+ name:
+ type: string
+ pattern: "^[a-z0-9_+-]*$"
+ description: Tag category name.
+ display_name:
+ type: string
+ description: The human-readable name of the tag category.
+ emoji:
+ type: string
+ pattern: "^[\\p{So}\\p{Sk}\\p{Sm}\\p{Sc}]\\uFE0F?$"
+ description: Emoji pictogram for this tag category variant.
+ deprecated:
+ type: boolean
+ description: Whether the tag category is deprecated.
diff --git a/data/schema/tags_enum.yaml b/data/schema/tags_enum.yaml
new file mode 100644
index 0000000..6e16b7d
--- /dev/null
+++ b/data/schema/tags_enum.yaml
@@ -0,0 +1,53 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/tags_enum.yaml"
+
+title: Tag variant definition
+description: Schema for OpenPrintTag tag variant definitions.
+
+type: array
+items:
+ type: object
+ description: Material tag variant.
+ additionalProperties: false
+
+ required: [ key, name, category, display_name, category ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Identifier of the tag in CBOR.
+ name:
+ type: string
+ pattern: "^[a-z0-9_]*$"
+ description: Name of the tag.
+ display_name:
+ type: string
+ description: The human-readable name of the tag.
+ description:
+ oneOf:
+ - type: string
+ - type: array
+ items: { type: string }
+ description: Description of the tag.
+ deprecated:
+ type: boolean
+ description: Whether the tag is deprecated.
+ category:
+ type: string
+ pattern: "^[a-z0-9_]*$"
+ description:
+ Tag category name.
+ See the `tag_category` enum for valid categories.
+ implies:
+ type: array
+ items:
+ type: string
+ pattern: "^[a-z0-9_]*$"
+ description: List of tags, by name, that are implied by the tag.
+ hints:
+ type: array
+ items:
+ type: string
+ pattern: "^[a-z0-9_]*$"
+ description: List of tags, by name, that are hinted to with the tag.
diff --git a/data/schema/write_protection_enum.yaml b/data/schema/write_protection_enum.yaml
new file mode 100644
index 0000000..905967d
--- /dev/null
+++ b/data/schema/write_protection_enum.yaml
@@ -0,0 +1,33 @@
+$schema: "https://json-schema.org/draft-07/schema"
+$id: "https://specs.openprinttag.org/schema/write_protection_enum.yaml"
+
+title: Write-protection variant definition
+description: Schema for OpenPrintTag write-protection variant definitions.
+
+type: array
+
+items:
+ type: object
+ description: Write-protection variant.
+ additionalProperties: false
+
+ required: [ key, name ]
+
+ properties:
+ key:
+ type: integer
+ minimum: 0
+ description: Identifier of the write-protection variant in CBOR.
+ name:
+ type: string
+ pattern: "^[a-z0-9_+-]*$"
+ description: Write-protection status name.
+ description:
+ oneOf:
+ - type: string
+ - type: array
+ items: { type: string }
+ description: Description of the write-protection status.
+ deprecated:
+ type: boolean
+ description: Whether the write-protection status is deprecated.
diff --git a/data/tag_categories_enum.yaml b/data/tag_categories_enum.yaml
index fa32165..3c3526c 100644
--- a/data/tag_categories_enum.yaml
+++ b/data/tag_categories_enum.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/tag_categories_enum.yaml
- name: biological
display_name: Biological
emoji: 🧬
diff --git a/data/tags_enum.yaml b/data/tags_enum.yaml
index 56827db..bb6403d 100644
--- a/data/tags_enum.yaml
+++ b/data/tags_enum.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/tags_enum.yaml
## Biological properties
# =====================================
diff --git a/data/write_protection_enum.yaml b/data/write_protection_enum.yaml
index a7c1f6b..c4fc572 100644
--- a/data/write_protection_enum.yaml
+++ b/data/write_protection_enum.yaml
@@ -1,3 +1,4 @@
+# yaml-language-server: $schema=./schema/write_protection_enum.yaml
- key: 0
name: "no"
description: The tag is not write protected.
diff --git a/docs_src/_sidebar.md b/docs_src/_sidebar.md
index 41b0719..379248e 100644
--- a/docs_src/_sidebar.md
+++ b/docs_src/_sidebar.md
@@ -3,6 +3,8 @@
- [Data format](/nfc_data_format)
- [Material types](/material_types)
- [Material tags](/material_tags)
+- [Material certifications](/material_certifications)
- [Technical details](/nfc_technical_details)
+- [Physical specification](/physical_spec)
- [Examples](/examples)
- [Contributing](/contributing)
diff --git a/docs_src/generate.py b/docs_src/generate.py
index a6b8923..c1bf3f3 100644
--- a/docs_src/generate.py
+++ b/docs_src/generate.py
@@ -11,8 +11,8 @@ def gen_material_tag_table():
r.write("
")
r.write("
ID
Name
Display name
Info
")
- tags = yaml.safe_load(open(os.path.join(vars.data_dir, "tags_enum.yaml"), "r"))
- categories = yaml.safe_load(open(os.path.join(vars.data_dir, "tag_categories_enum.yaml"), "r"))
+ tags = yaml.safe_load(open(os.path.join(vars.data_dir, "tags_enum.yaml"), "r", encoding="utf-8"))
+ categories = yaml.safe_load(open(os.path.join(vars.data_dir, "tag_categories_enum.yaml"), "r", encoding="utf-8"))
categories_keys = {c["name"] for c in categories}
@@ -73,6 +73,13 @@ def gen_material_tag_table():
Column(field="description", title="Description"),
]
+env.globals["material_certification_columns"] = [
+ Column(field="key", title="Key"),
+ Column(field="name", title="Name", transform=lambda x: f"`{x}`"),
+ Column(field="display_name", title="Display name"),
+ Column(field="description", title="Description"),
+]
+
gen_doc_file("_navbar")
gen_doc_file("_sidebar")
gen_doc_file("README")
@@ -82,7 +89,12 @@ def gen_material_tag_table():
gen_doc_file("nfc_technical_details")
gen_doc_file("examples")
gen_doc_file("contributing")
-gen_doc_file("material_tags")
gen_doc_file("material_types")
+gen_doc_file("material_tags")
+gen_doc_file("material_certifications")
+gen_doc_file("physical_spec")
+
+shutil.copytree(f"{dir}/media", f"{out_dir}/media", dirs_exist_ok=True)
-shutil.copyfile(f"{dir}/class_diagram.svg", f"{out_dir}/class_diagram.svg")
+# copy definition schemas
+shutil.copytree(os.path.join(vars.data_dir, "schema"), f"{out_dir}/schema")
diff --git a/docs_src/generate_common.py b/docs_src/generate_common.py
index 27558f3..6025b85 100644
--- a/docs_src/generate_common.py
+++ b/docs_src/generate_common.py
@@ -109,7 +109,7 @@ def show_file(file, language="yaml"):
r.write(f"> ```bash\n> cat {file}\n> ```\n\n")
r.write("Commmand output\n\n")
- with open(f"{dir}/{file}", "r") as f:
+ with open(f"{dir}/{file}", "r", encoding="utf-8") as f:
r.write(f"```{language}\n{f.read()}\n```\n")
r.write("\n\n")
diff --git a/docs_src/material_certifications.md b/docs_src/material_certifications.md
new file mode 100644
index 0000000..ba86744
--- /dev/null
+++ b/docs_src/material_certifications.md
@@ -0,0 +1,6 @@
+# Material certifications
+Material certifications allow expressing what certificates a material has.
+
+The certifications are stored as an enum on the tag to reduce memory usage and promote standard encoding. If there is a certification missing in the enum, please create a PR or file an issue in the [OpenPrintTag repository]({{repo}}).
+
+{{ enum_table("material_certifications_enum", material_certification_columns) }}
diff --git a/docs_src/media/adhesive_spec.pdf b/docs_src/media/adhesive_spec.pdf
new file mode 100644
index 0000000..0f837f7
Binary files /dev/null and b/docs_src/media/adhesive_spec.pdf differ
diff --git a/docs_src/class_diagram.mermaid b/docs_src/media/class_diagram.mermaid
similarity index 100%
rename from docs_src/class_diagram.mermaid
rename to docs_src/media/class_diagram.mermaid
diff --git a/docs_src/class_diagram.svg b/docs_src/media/class_diagram.svg
similarity index 100%
rename from docs_src/class_diagram.svg
rename to docs_src/media/class_diagram.svg
diff --git a/docs_src/media/tag_mk1.pdf b/docs_src/media/tag_mk1.pdf
new file mode 100644
index 0000000..68ab4b7
Binary files /dev/null and b/docs_src/media/tag_mk1.pdf differ
diff --git a/docs_src/media/tag_placement.svg b/docs_src/media/tag_placement.svg
new file mode 100644
index 0000000..47cc0b0
--- /dev/null
+++ b/docs_src/media/tag_placement.svg
@@ -0,0 +1,34 @@
+
+
+
diff --git a/docs_src/nfc_data_format.md b/docs_src/nfc_data_format.md
index ff4fad5..e6b0d33 100644
--- a/docs_src/nfc_data_format.md
+++ b/docs_src/nfc_data_format.md
@@ -84,6 +84,7 @@
1. `enum_array` fields are encoded as CBOR arrays of integers, according to the field mapping
1. `timestamp` fields are encoded as UNIX timestamp integers
1. `bytes` and `uuid` types are encoded as CBOR byte string (type 2)
+1. `color_rgba` fields are encoded as a CBOR byte string (type 2) with 3 to 4 bytes representing `[R, G, B]` or `[R, G, B, A]` values
1. `number` types can be encoded as either unsigned integers (type 0), signed integers (type 1), half floats or floats
1. `string` types are encoded as CBOR text string (type 3, UTF-8 is enforced by the CBOR specification)
1. The `X` in the `string:X` or `bytes:X` notation defines maximum permissible length of the data in bytes.
diff --git a/docs_src/physical_spec.md b/docs_src/physical_spec.md
new file mode 100644
index 0000000..403cc43
--- /dev/null
+++ b/docs_src/physical_spec.md
@@ -0,0 +1,221 @@
+# Physical specification
+This document describes the requirements imposed by the OpenPrintTag standard on the physical tag itself, its mechanical and electrical properties. Currently, the **OpenPrintTag standard supports only the reference `OpenPrintTag MK1` tag**. A more generic specification, allowing deviations from the exact reference design and including NFC reader parameters, **will be released later**.
+
+## Reference `OpenPrintTag MK1` tag
+`OpenPrintTag MK1` is a passive paper-label NFC tag with an embedded coil and NFC integrated circuit, compliant with the ISO/IEC 15693 vicinity-RFID standard (13.56 MHz).
+
+Technical drawing
+
+## Placement guidelines on filament spools
+1. The tag SHALL be attached to a flat, non-metallic surface.
+1. The tag SHOULD be placed at either flange of the spool (e.g. not in the middle of the barrel) to ensure compatibility with generic readers.
+1. The tag SHALL be placed no further than 130 mm from either side of the spool.
+ 1. *Note: This limitation ensures the tag remains readable from both sides of the spool.*
+1. The tag SHALL be positioned coaxially with the central axis of the spool.
+1. The design of the material container SHALL provide sufficient mechanical protection of the tag's integrated circuit (IC) during the entire lifecycle.
+1. To achieve this, the tag SHOULD be placed inside a debossed pocket or cavity with a minimum depth of 0.25 mm. The cavity MAY be covered to fully enclose the tag.
+
+
+
+
+
+## Mechanical parameters
+
+