Skip to content

Add Spoolman card_uid lookup, Snapmaker U1 CARD_UID API, and wifi_ssid/wifi_pass commands#5

Open
ChrisBGL wants to merge 2 commits into
Rocka84:masterfrom
ChrisBGL:feature/spoolman-card-uid-lookup
Open

Add Spoolman card_uid lookup, Snapmaker U1 CARD_UID API, and wifi_ssid/wifi_pass commands#5
ChrisBGL wants to merge 2 commits into
Rocka84:masterfrom
ChrisBGL:feature/spoolman-card-uid-lookup

Conversation

@ChrisBGL

Copy link
Copy Markdown

Summary

1. Spoolman card_uids lookup (NetworkManager.cpp, main.cpp)

  • fetchSpoolmanByExternalId fetches /api/v1/spool?allow_archived=true in a single HTTP request and iterates all spools in one pass
  • Priority 1: checks spool.extra.card_uids (Spoolman JSON-encoded string, comma-separated) against data.hardware_uid — normalises both sides (uppercase, strip colons/hyphens/spaces/quotes/0x prefix) before comparing
  • Priority 2: falls back to lot_nr match if no card_uid hit is found
  • fetchSpoolmanData gate widened: hardware_uid or lot_nr now triggers the lookup (previously required hardware_uid)
  • main.cpp Spoolman fetch condition extended to also fire when hardware_uid is set

2. Snapmaker U1 CARD_UID payload (NetworkManager.cpp)

  • When hardware_uid is valid, sends {"channel":N,"info":{"CARD_UID":[86,132,77,206]}} instead of vendor/material/colour fields — the U1 Extended Firmware resolves the spool from Spoolman automatically via CARD_UID
  • UID normalisation: strips 0x, colons, hyphens, spaces, quotes; uppercases; splits into decimal byte array (e.g. 56:84:4D:CE[86,132,77,206])
  • Validation before sending: non-empty, even hex-character length, only [0-9A-F] — logs error and skips request if invalid
  • Backwards compatible: falls back to existing VENDOR/MAIN_TYPE/RGB_1/... payload when no valid UID is present
  • Serial debug logs show raw UID, normalised UID, byte array, and HTTP response

3. Wi-Fi SSID/password with spaces (SerialTerminal.cpp)

  • New commands set wifi_ssid <ssid> and set wifi_pass <password> accept the full remainder of the line, so SSIDs or passwords containing spaces work without quoting
  • Existing set wifi <ssid> <password> is unchanged (backwards compatible)
  • get config outputs set wifi_ssid / set wifi_pass when the stored SSID contains spaces, so the output is always directly re-enterable
  • help text updated to document all three variants

Test plan

  • pio test -e desktop — 18/18 tests pass (verified)
  • pio run -e pn5180 — builds and flashes successfully (verified)
  • Scan a proprietary tag with a UID stored in spool.extra.card_uids in Spoolman — spool resolves correctly
  • Scan a Bambu/lot_nr tag without card_uid — existing lot_nr fallback still works
  • U1 configured: tag with valid UID — Serial log shows CARD_UID byte array, U1 accepts request
  • U1 configured: tag without UID — falls back to VENDOR/MAIN_TYPE payload as before
  • set wifi_ssid My Network Name + set wifi_pass secret — connects successfully
  • set wifi simpleSSID password — still works as before

🤖 Generated with Claude Code

…s commands

Spoolman card_uid lookup (NetworkManager.cpp, main.cpp):
- fetchSpoolmanByExternalId now fetches /api/v1/spool?allow_archived=true
  in a single request and searches all spools in one pass - no extra HTTP call
- Checks spool.extra.card_uids first (comma-separated, JSON-encoded strings)
  against data.hardware_uid; normalises both sides (uppercase, strip
  colons/hyphens/spaces/quotes/0x prefix) before comparing
- Falls back to lot_nr match if no card_uid hit is found
- fetchSpoolmanData gate widened: hardware_uid OR lot_nr triggers the lookup
- main.cpp Spoolman fetch condition extended to also fire on hardware_uid

Snapmaker U1 CARD_UID payload (NetworkManager.cpp):
- When hardware_uid is valid, sends {channel:N,info:{CARD_UID:[...]}}
  instead of vendor/material/colour data; U1 Extended Firmware resolves the
  spool from Spoolman itself via CARD_UID
- UID normalisation: strips 0x, colons, hyphens, spaces, quotes; uppercases;
  splits into decimal byte array
- Validation: non-empty, even hex length, only [0-9A-F] chars; logs error
  and skips request if invalid
- Falls back to existing VENDOR/MAIN_TYPE/RGB_1/... payload when no valid
  UID is present (backwards compatible)
- Serial debug logs show raw UID, normalised UID, byte array, HTTP response

Wi-Fi SSID/password with spaces (SerialTerminal.cpp):
- New commands: set wifi_ssid <ssid> and set wifi_pass <password>
  accept the full remainder of the line, so SSIDs or passwords containing
  spaces work without quoting
- Existing set wifi <ssid> <password> unchanged (backwards compatible)
- get config outputs set wifi_ssid / set wifi_pass when SSID contains spaces
- help text updated to document all three variants

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added static labelHardwareUid member to DisplayUI
- create_ext_row for Card UID in buildExtendedInfoScreen, placed after Lot Nr
- set_field for hardware_uid in showExtendedInfoScreen
- Row is hidden automatically when no UID is present

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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