Skip to content

feat: NFC tag spool_id for Spoolman integration#173

Closed
joostliebregts wants to merge 1 commit into
paxx12-snapmaker-u1:developfrom
joostliebregts:feature/nfc-spoolman-integration
Closed

feat: NFC tag spool_id for Spoolman integration#173
joostliebregts wants to merge 1 commit into
paxx12-snapmaker-u1:developfrom
joostliebregts:feature/nfc-spoolman-integration

Conversation

@joostliebregts
Copy link
Copy Markdown

@joostliebregts joostliebregts commented Jan 22, 2026

Summary

Thanks for building the extended firmware - it's made the U1 so much more usable.

I added an optional spool_id field to the OpenSpool parsing so users with Spoolman can get automatic spool tracking when they load filament. Tags without spool_id still work exactly as before.

Changes

  • filament_protocol_ndef.py: Extract optional spool_id field from OpenSpool JSON into info['SPOOL_ID']
  • 02-add-ndef-protocol.patch: Call ON_NFC_SPOOL_READ CHANNEL=<n> SPOOL_ID=<id> macro when spool_id is present
  • docs/rfid_support.md: Add Spoolman Integration section with field reference and example macro
  • examples/nfc_spoolman.cfg: Ready-to-use macro file users can copy to their config

Tag Format

Users add spool_id to their existing OpenSpool tags:

{
  "protocol": "openspool",
  "version": "1.0",
  "brand": "Elegoo",
  "type": "PLA",
  "color_hex": "#FF5733",
  "spool_id": 42
}

Backward Compatibility

  • Tags without spool_id work exactly as before
  • The macro call only fires when spool_id is present
  • No configuration required unless user wants Spoolman integration

Example Macro

Users create extended/klipper/nfc_spoolman.cfg:

[gcode_macro ON_NFC_SPOOL_READ]
gcode:
    {% set channel = params.CHANNEL|int %}
    {% set spool_id = params.SPOOL_ID|int %}
    {% set tool = "T" ~ channel %}
    SET_GCODE_VARIABLE MACRO={tool} VARIABLE=spool_id VALUE={spool_id}
    RESPOND PREFIX="NFC" MSG="Spool {spool_id} assigned to {tool}"

Testing

  • Tested with NTAG215 tags containing OpenSpool JSON with spool_id field
  • Verified backward compatibility with tags without spool_id
  • Verified macro is called with correct channel and spool_id parameters

- Extract optional spool_id field from OpenSpool JSON payload
- Call ON_NFC_SPOOL_READ macro when spool_id is present
- Add Spoolman Integration section to documentation
- Enables automatic spool tracking via NFC tags
- Backward compatible: tags without spool_id work as before

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@joostliebregts joostliebregts force-pushed the feature/nfc-spoolman-integration branch from 83071a4 to b27829b Compare January 22, 2026 19:59
@joostliebregts
Copy link
Copy Markdown
Author

joostliebregts commented Jan 23, 2026

Not entirely sure, but I believe this implementation has more 'read nfc and spoolman' features built in. #163

@unlucio
Copy link
Copy Markdown

unlucio commented Jan 23, 2026

Not entirely sure, but I believe this implementation has more 'read nfc and spoolman' features built in. #163

Indeed.
Setting the spool is a start, but to achieve accuracy, the tool map needs to be taken into account; otherwise, it will track the wrong spool for every situation where the G-code's T-number does not match the physical one.

+ if spool_id is not None:
+ try:
+ gcode = self.printer.lookup_object('gcode')
+ gcode.run_script_from_command(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://en.wikipedia.org/wiki/Separation_of_concerns
This is probably not the place to deal with this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool that you picked up on that! Do you have software development experience? Seems like you know what you're doing. Whereas I am trusting the magnificent Opus 😄 I appreciate you taking a look and letting me know!

Copy link
Copy Markdown

@unlucio unlucio Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool that you picked up on that! Do you have software development experience? Seems like you know what you're doing. Whereas I am trusting the magnificent Opus 😄 I appreciate you taking a look and letting me know!

I might have a bit of experience in the SW/IT field, and pondered this "problem" and its solution for a bit before implementing it 😄
I have no idea what Opus is

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, with Opus I refer to the almighty Claude Opus 4.5. The state of the art AI model from Anthropic.

@paxx12 paxx12 added the nfc Set of features related to NFC and RFID tags label Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nfc Set of features related to NFC and RFID tags

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants