diff --git a/src/components/Status.tsx b/src/components/Status.tsx index 6640c6d..482a3de 100644 --- a/src/components/Status.tsx +++ b/src/components/Status.tsx @@ -48,11 +48,10 @@ export const Status: React.FC = ({ notifications, verbose, }) => { - 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 allspaceKiB = typeof status?.allspace === "number" ? status.allspace : 0; + const freespaceKiB = typeof status?.freespace === "number" ? status.freespace : 0; + const allspace = allspaceKiB * 1024; + const freespace = freespaceKiB * 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 a94259d..56fbb6c 100644 --- a/src/lib/core/beambox-uploader.ts +++ b/src/lib/core/beambox-uploader.ts @@ -183,7 +183,7 @@ export class BeamBoxUploader { // Check device storage before upload if (!this.checkStorageCapacity(fullData.length)) { throw new UploadError( - `Insufficient device storage. Image requires ${Math.ceil(fullData.length / 1024)}KB. ` + + `Insufficient device storage. Image requires ${Math.ceil(fullData.length / 1024)}KiB. ` + `Try reducing image size or quality.`, ); } @@ -221,20 +221,19 @@ export class BeamBoxUploader { return false; } - const freespaceMB = Number(deviceStatus.freespace) || 0; - const freespaceBytes = freespaceMB * 1024 * 1024; - const payloadMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2); + const freespaceKiB = Number(deviceStatus.freespace) || 0; + const freespaceBytes = freespaceKiB * 1024; + const payloadKiB = (payloadSizeBytes / 1024).toFixed(2); logger.info( - `Storage check: payload=${payloadMB}MB, available=${freespaceMB}MB`, + `Storage check: payload=${payloadKiB}KiB, available=${freespaceKiB}KiB`, ); - // Add 10% safety margin to avoid filling device completely const requiredBytes = Math.ceil(payloadSizeBytes * 1.1); if (freespaceBytes < requiredBytes) { logger.error( - `Insufficient storage: need ${(requiredBytes / (1024 * 1024)).toFixed(2)}MB (with 10% margin), have ${freespaceMB}MB`, + `Insufficient storage: need ${(requiredBytes / 1024).toFixed(2)}KiB (with 10% margin), have ${freespaceKiB}KiB`, ); return false; } @@ -434,7 +433,7 @@ export class BeamBoxUploader { if (!this.checkStorageCapacity(fullData.length)) { throw new UploadError( - `Insufficient device storage. Animation requires ${Math.ceil(fullData.length / 1024)}KB. ` + + `Insufficient device storage. Animation requires ${Math.ceil(fullData.length / 1024)}KiB. ` + `Try reducing frames or image quality.`, ); } diff --git a/src/lib/protocol/interfaces/device-status.ts b/src/lib/protocol/interfaces/device-status.ts index 04f4fd4..2b3aab3 100644 --- a/src/lib/protocol/interfaces/device-status.ts +++ b/src/lib/protocol/interfaces/device-status.ts @@ -7,14 +7,10 @@ export interface DeviceStatus { /** Packet type identifier (always 13 for DEVICE_STATUS) */ type: PacketType.DEVICE_STATUS; - /** - * Total storage capacity in megabytes (MB) - */ + /** Total storage capacity in KiB */ allspace: number; - /** - * Available free storage in megabytes (MB) - */ + /** Available free storage in KiB */ freespace: number; /** diff --git a/src/lib/protocol/packet-types.ts b/src/lib/protocol/packet-types.ts index 8b38107..c994cc5 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 MB - * "freespace": 13892, // Free storage in MB + * "allspace": 16384, // Total storage in KiB + * "freespace": 13892, // Free storage in KiB * "devname": "", // Device name (usually empty) * "size": "368,368", // Display resolution (width,height) * "brand": 0 // Brand/model identifier