Add firmware update helper for LAN-only printers

Enables checking and uploading firmware updates for printers operating
  in LAN-only mode without Bambu Cloud connectivity.

  Features:
  - Automatic firmware version checking against Bambu Lab servers
  - Orange "Update" badge on printer cards when updates available
  - Firmware update modal with version info and release notes
  - One-click firmware upload to printer SD card via FTP
  - Real-time upload progress (actual bytes transferred)
  - Step-by-step instructions for triggering update from printer
  - Local firmware caching for faster re-uploads
  - Supports all Bambu Lab printer models

  New files:
  - backend/app/services/firmware_check.py - Version checking service
  - backend/app/services/firmware_update.py - Upload orchestration
  - backend/app/api/routes/firmware.py - REST API endpoints

  Also includes:
  - FTP upload progress callback support
  - 10-minute upload timeout protection
  - Firmware cache directory in .gitignore
This commit is contained in:
maziggy
2026-01-04 18:41:24 +01:00
parent b0c576c8a8
commit 6fb71de6a2
21 changed files with 10220 additions and 8674 deletions
+54
View File
@@ -2526,3 +2526,57 @@ export const pendingUploadsApi = {
discardAll: () =>
request<{ discarded: number }>('/pending-uploads/discard-all', { method: 'DELETE' }),
};
// Firmware API Types
export interface FirmwareUpdateInfo {
printer_id: number;
printer_name: string;
model: string | null;
current_version: string | null;
latest_version: string | null;
update_available: boolean;
download_url: string | null;
release_notes: string | null;
}
export interface FirmwareUploadPrepare {
can_proceed: boolean;
sd_card_present: boolean;
sd_card_free_space: number;
firmware_size: number;
space_sufficient: boolean;
update_available: boolean;
current_version: string | null;
latest_version: string | null;
firmware_filename: string | null;
errors: string[];
}
export interface FirmwareUploadStatus {
status: 'idle' | 'preparing' | 'downloading' | 'uploading' | 'complete' | 'error';
progress: number;
message: string;
error: string | null;
firmware_filename: string | null;
firmware_version: string | null;
}
// Firmware API
export const firmwareApi = {
checkUpdates: () =>
request<{ updates: FirmwareUpdateInfo[]; updates_available: number }>('/firmware/updates'),
checkPrinterUpdate: (printerId: number) =>
request<FirmwareUpdateInfo>(`/firmware/updates/${printerId}`),
prepareUpload: (printerId: number) =>
request<FirmwareUploadPrepare>(`/firmware/updates/${printerId}/prepare`),
startUpload: (printerId: number) =>
request<{ started: boolean; message: string }>(`/firmware/updates/${printerId}/upload`, {
method: 'POST',
}),
getUploadStatus: (printerId: number) =>
request<FirmwareUploadStatus>(`/firmware/updates/${printerId}/upload/status`),
};