Skip to content

FSEQ Usermod: integrate sd_card usermod and add support for compressed xLights sequence uploads#5417

Closed
Danit2 wants to merge 10 commits intowled:mainfrom
Danit2:FSEQ_Zip
Closed

FSEQ Usermod: integrate sd_card usermod and add support for compressed xLights sequence uploads#5417
Danit2 wants to merge 10 commits intowled:mainfrom
Danit2:FSEQ_Zip

Conversation

@Danit2
Copy link

@Danit2 Danit2 commented Mar 11, 2026

FSEQ Usermod: integrate sd_card usermod and add support for compressed xLights sequence uploads

This PR introduces two improvements to the FSEQ usermod.


1. Use the sd_card usermod

The FSEQ usermod now uses the existing sd_card usermod for SD card access instead of implementing its own SD handling.

Benefits:

  • Ensures consistent SD card handling across usermods
  • Reduces duplicated code
  • Simplifies maintenance

2. Support compressed xLights sequence uploads (.xlz)

Uploading large sequence files can take significant time over the network.
To improve upload performance, the SD upload API now supports compressed xLights sequence archives (.xlz).

Behavior

  • .xlz files can be uploaded via the SD upload API

  • Uploaded archives are not unpacked immediately to avoid blocking the main loop

  • The archive will be unpacked:

    • 10 seconds after the last upload, or
    • automatically on the next device reboot

This allows faster uploads while keeping runtime performance stable.


Summary

  • Switch FSEQ usermod to the shared sd_card usermod
  • Add support for compressed .xlz sequence uploads
  • Implement deferred extraction to avoid blocking the ESP main loop
  • Extraction runs 10 seconds after upload or on reboot

Summary by CodeRabbit

Release Notes

  • New Features
    • Added FSEQ audio file playback from SD card with web management interface
    • Integrated UDP synchronization support via FPP protocol
    • Added file upload and management capabilities to web UI
    • Support for compressed archive file uploads and automatic extraction
    • Playback controls including start, stop, and loop modes
    • Real-time playback status and synchronization tracking

Introduce a new FSEQ usermod that enables playing .fseq animations from an SD card with a web UI and FPP/UDP synchronization. Adds core components: FSEQ player (fseq_player.cpp/.h), SD manager (sd_manager.*), web/UI & upload/FPP handling (usermod_fpp.h, web_ui_manager.*), registration (register_usermod.cpp), library metadata and auto-build script (library.json, auto_fseq_sd.py) and a README. Also includes helpers for buffered uploads and FPP ping/sync packets. Small updates in existing wled00 files (const.h, json.cpp) are included to integrate the usermod.
Added additional author credit and improved project description.
Multiple cleanups and feature changes across the FSEQ usermod:

- fseq_player: Add a bool loop parameter to loadRecording(), use file_header.channel_data_offset when seeking, avoid prematurely closing recordingFile, and open files via WLED_FS.open for FS paths. Set recordingRepeats from the new loop flag instead of using secondsElapsed heuristics.
- fseq_player.h: Update loadRecording signature and remove unused REALTIME_MODE_FSEQ define.
- sd_manager: Add compile-time check that an SD backend is enabled (SPI or MMC) and remove the listFiles implementation/API; keep deleteFile. Corresponding header prototype removed.
- web_ui_manager: Switch FSEQ/SD endpoints to POST with application/x-www-form-urlencoded bodies (start, startloop, stop, delete). Replace manual string-based SD file listing with a JSON response using DynamicJsonDocument. Improve file upload handling by storing a File pointer on the request and cleaning up on completion. Return status/info endpoints as JSON.
- usermod_fpp/usermod_fseq: Various robustness and modernizations — null-buffer check in write(), inline constexpr and inline variables for UDP and timing, use snprintf for time formatting, suppress noisy debug hex dump, add override annotations, and rework SD reinit to accept and deallocate old pins before reinitializing.

Overall these changes improve robustness of file handling, enforce SD backend presence at compile time, reduce string concatenation overhead by using JSON, and standardize the web API to POST for mutating actions.
…ks & UI

Widen FSEQ frame size counters to 32-bit and make frame buffer reads safe (fixed 48-byte buffer and proper length casts). Add stricter UDP packet length checks for sync packets. Replace raw SD file ops with SD_ADAPTER (exists/remove/open) and add upload open-failure handling/cleanup. Refactor web UI SD list to emit proper JSON via ArduinoJson, fix JS loop-state bug, and adjust loadRecording loop parameter. Remove stale backup file.
Update FSEQ usermod and docs to new API routes and add FPP endpoints; adjust usermod IDs and fix minor web UI handling.

Changes:
- README: revise endpoints (use /api/ prefix, switch some endpoints to POST, rename /sd/ui to /fsequi) and add FPP control endpoints (system info/status and multisync). Merge author line.
- const.h: add USERMOD_ID_FSEQ (59) and USERMOD_ID_FPP (60).
- usermod_fpp.h: change getId() to return USERMOD_ID_FPP instead of USERMOD_ID_SD_CARD.
- web_ui_manager.cpp: store file.name() in a temporary String before use, fix upload handler brace/formatting, and remove an outdated comment about loop mode.

Notes: API route and usermod ID changes may require updates elsewhere that reference the old routes or IDs.
Update README to correct and standardize API paths (/api/...), add FPP endpoints and format SPI pin block. In usermod_fpp.h remove unused helpers, parse versionString into major/minor, change typeId to 195, and harden UDP sync handling with length checks and safe filename extraction to avoid buffer overruns (also remove an old commented sendSyncMessage). In web_ui_manager.cpp only update UI buttons after successful server response and add JSON overflow handling when returning file lists. These changes improve correctness, safety, and UX.
Replace unsafe reinterpret_cast of UDP sync packet with explicit parsing of sync action, frame number and seconds elapsed, and pass those parsed values to ProcessSyncPacket. Add a concurrent-upload guard (returns 409) and make UsermodFPP::_name inline. In the web UI manager add UploadContext for safer upload state handling, rework /api/sd/upload to use the context (better error handling, proper cleanup and file close), write chunks only when the file is valid, and return appropriate responses. Also check JSON overflow when serializing file lists and return 507 if the buffer is too small.
Replace the human-readable hostname with a deterministic unique device ID built from "WLED-" + MAC (colons removed) and use this ID consistently across all FPP payloads.

This change prevents conflicts in FPP when multiple WLED devices share the same default hostname (e.g. multiple devices left as "WLED"). FPP requires unique host identifiers; duplicate hostnames can cause device collisions, sync issues, or undefined behavior in the player.

The new unique ID is now used in:

advancedView

sys.id

FPP ping packet hostname field (truncated to 64 bytes)

The human-readable device name is preserved in HostDescription.
…orrection

This changes replaces the previous hard frame-based synchronization logic in FSEQPlayer::syncPlayback() with a proportional time-based drift correction mechanism.

Instead of immediately jumping to the expected frame when a small deviation is detected, the new implementation performs a smooth time adjustment using a proportional correction model. Hard resynchronization is now only triggered when the drift exceeds a defined safety threshold.

This significantly improves visual smoothness during Multisync playback, especially on ESP32-based controllers where clock drift is common.
…d xLights sequence uploads

PR Description

This PR introduces two improvements to the FSEQ usermod:

1. Use the sd_card usermod

The FSEQ usermod now depends on and uses the existing sd_card usermod instead of implementing its own SD handling.
This ensures consistent SD card access across usermods and reduces duplicated code.

2. Support compressed xLights sequence uploads (.xlz)

Uploading large sequence files can take significant time over the network.
To improve upload performance, the web API now supports uploading compressed xLights sequence archives (.xlz).

Behavior:

.xlz files can be uploaded via the SD upload API.

Uploaded archives are not unpacked immediately to avoid blocking the main loop.

The archive will be unpacked:

10 seconds after the last upload, or

automatically on the next device reboot.

This approach allows faster uploads while keeping runtime performance stable.

Summary

Switch FSEQ usermod to the shared sd_card usermod

Add support for compressed .xlz sequence uploads

Implement deferred extraction to avoid blocking the ESP main loop

Extraction runs 10s after upload or on reboot
@Danit2 Danit2 closed this Mar 11, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7042eb48-0e79-4cd1-ba08-fcf47adbb0dd

📥 Commits

Reviewing files that changed from the base of the PR and between 4044255 and 46cfcf7.

📒 Files selected for processing (14)
  • usermods/FSEQ/README.md
  • usermods/FSEQ/fseq_player.cpp
  • usermods/FSEQ/fseq_player.h
  • usermods/FSEQ/library.json
  • usermods/FSEQ/register_usermod.cpp
  • usermods/FSEQ/usermod_fpp.h
  • usermods/FSEQ/usermod_fseq.h
  • usermods/FSEQ/web_ui_manager.cpp
  • usermods/FSEQ/web_ui_manager.h
  • usermods/FSEQ/xlz_unzip.cpp
  • usermods/FSEQ/xlz_unzip.h
  • usermods/sd_card/sd_card.cpp
  • wled00/const.h
  • wled00/json.cpp

Walkthrough

Adds a comprehensive FSEQ (Fast Sequence) playback usermod system including core playback engine, FPP Connect UDP synchronization, web UI with file management, XLZ archive extraction, and integration with WLED's realtime LED control framework.

Changes

Cohort / File(s) Summary
Core FSEQ Playback Engine
usermods/FSEQ/fseq_player.h, usermods/FSEQ/fseq_player.cpp
Implements FSEQ file parsing, frame decoding, LED mapping, playback timing, looping, synchronization (hard/soft resync), and header validation with static state management.
FPP Connect Synchronization
usermods/FSEQ/usermod_fpp.h
Adds UDP multicast FPP protocol support, file upload streaming with buffering, HTTP /fpp endpoints, status JSON builders, and deferred XLZ unzip processing with inactivity tracking.
FSEQ Usermod Integration
usermods/FSEQ/usermod_fseq.h
Registers FSEQ playback as a usermod with web UI endpoints and Info tab integration; calls FSEQPlayer::handlePlayRecording() in loop().
Web UI Management
usermods/FSEQ/web_ui_manager.h, usermods/FSEQ/web_ui_manager.cpp
Embeds full HTML/CSS/JS UI for SD/FSEQ file management and playback control; implements API endpoints for file listing, upload, delete, play/stop with storage reporting.
XLZ Archive Extraction
usermods/FSEQ/xlz_unzip.h, usermods/FSEQ/xlz_unzip.cpp
Provides ZIP abstraction layer, entry name sanitization to prevent path traversal, single-file unpack workflow, and batch processing of pending .xlz files from SD root.
Module Registration & Manifest
usermods/FSEQ/register_usermod.cpp, usermods/FSEQ/library.json, usermods/FSEQ/README.md
Declares UsermodFseq and UsermodFPP instances, specifies unzipLIB dependency, documents installation and HTTP endpoints.
System Integration
wled00/const.h, wled00/json.cpp, usermods/sd_card/sd_card.cpp
Adds USERMOD_ID_FSEQ/FPP and REALTIME_MODE_FSEQ constants; adds FSEQ label to livemode serialization; conditionalizes SPI port selection by ESP32 target.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • custom_usermod improvements #5403: Introduces usermod registration mechanism changes (dynarray/REGISTER_USERMOD rework) that this PR depends on for registering the new FSEQ and FPP usermods.

Suggested reviewers

  • willmmiles
  • softhack007
  • netmindz
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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