diff --git a/src/components/Status.tsx b/src/components/Status.tsx index 3a7463f..6640c6d 100644 --- a/src/components/Status.tsx +++ b/src/components/Status.tsx @@ -48,9 +48,11 @@ export const Status: React.FC = ({ notifications, verbose, }) => { - const allspace = typeof status?.allspace === "number" ? status.allspace : 0; - const freespace = + const allspaceMB = typeof status?.allspace === "number" ? status.allspace : 0; + const freespaceMB = typeof status?.freespace === "number" ? status.freespace : 0; + const allspace = allspaceMB * 1024 * 1024; + const freespace = freespaceMB * 1024 * 1024; const usedSpace = allspace - freespace; const freePercentage = allspace > 0 ? Math.round((freespace / allspace) * 100) : 0; diff --git a/src/lib/core/beambox-uploader.ts b/src/lib/core/beambox-uploader.ts index 95ef6ae..439a0b3 100644 --- a/src/lib/core/beambox-uploader.ts +++ b/src/lib/core/beambox-uploader.ts @@ -195,12 +195,12 @@ export class BeamBoxUploader { return false; } - const freespaceKB = Number(deviceStatus.freespace) || 0; - const freespaceBytes = freespaceKB * 1024; - const payloadKB = Math.ceil(payloadSizeBytes / 1024); + const freespaceMB = Number(deviceStatus.freespace) || 0; + const freespaceBytes = freespaceMB * 1024 * 1024; + const payloadMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2); logger.info( - `Storage check: payload=${payloadKB}KB, available=${freespaceKB}KB`, + `Storage check: payload=${payloadMB}MB, available=${freespaceMB}MB`, ); // Add 10% safety margin to avoid filling device completely @@ -208,7 +208,7 @@ export class BeamBoxUploader { if (freespaceBytes < requiredBytes) { logger.error( - `Insufficient storage: need ${Math.ceil(requiredBytes / 1024)}KB (with 10% margin), have ${freespaceKB}KB`, + `Insufficient storage: need ${(requiredBytes / (1024 * 1024)).toFixed(2)}MB (with 10% margin), have ${freespaceMB}MB`, ); return false; } diff --git a/src/lib/protocol/interfaces/device-status.ts b/src/lib/protocol/interfaces/device-status.ts index ed173f3..04f4fd4 100644 --- a/src/lib/protocol/interfaces/device-status.ts +++ b/src/lib/protocol/interfaces/device-status.ts @@ -8,12 +8,12 @@ export interface DeviceStatus { type: PacketType.DEVICE_STATUS; /** - * Total storage capacity in kilobytes (KB) + * Total storage capacity in megabytes (MB) */ allspace: number; /** - * Available free storage in kilobytes (KB) + * Available free storage in megabytes (MB) */ freespace: number; diff --git a/src/lib/protocol/packet-types.ts b/src/lib/protocol/packet-types.ts index 96c60d1..8b38107 100644 --- a/src/lib/protocol/packet-types.ts +++ b/src/lib/protocol/packet-types.ts @@ -109,8 +109,8 @@ export enum PacketType { * ```json * { * "type": 13, - * "allspace": 16384, // Total storage in KB - * "freespace": 13892, // Free storage in KB + * "allspace": 16384, // Total storage in MB + * "freespace": 13892, // Free storage in MB * "devname": "", // Device name (usually empty) * "size": "368,368", // Display resolution (width,height) * "brand": 0 // Brand/model identifier