Vinu 펌웨어 다운로더를 다른 웹 페이지에 임베드하기 위한 패키지. 연결(connect) + 굽기(flash) API만 제공하고, UI/버튼은 호출 측이 만든다.
- Web Serial 기반 (Chrome / Edge 89+, HTTPS 또는 localhost 필요)
- 펌웨어 바이트를 입력으로 받는다 — 다운로드(예: 사내 AWS S3 버킷)는 호출 측 책임. 이 패키지는 HTTP/인증/키를 모른다.
- 굽기는 메인스레드에서 진행(탭을 포그라운드로 유지 권장).
- 모델 안전 잠금 내장(기기와 다른 모델 펌웨어 차단). MASTER 기기만 PAD/CAR 둘 다 허용.
소비 레포 package.json 의 dependencies 에 추가:
"@aluxrobot/vinu-downloader": "github:aluxrobot/vinu-downloader#v1.0.0"
또는:
pnpm add "@aluxrobot/vinu-downloader@github:aluxrobot/vinu-downloader#v1.0.0"- private 레포여도 git 접근 권한만 있으면 된다(org 멤버 기본 OK). 별도 레지스트리/
.npmrc/토큰 불필요. - 빌드 산출물(
dist)이 레포에 포함돼 있어 설치 시 빌드도 필요 없다(자급 번들).
import { VinuDownloader } from "@aluxrobot/vinu-downloader"; const dl = new VinuDownloader(); // 1) 연결 — 반드시 버튼 클릭(user gesture) 핸들러 안에서 호출 connectBtn.addEventListener("click", async () => { const dev = await dl.connect(); // 포트 선택창 → 열기 → 모델 감지 statusEl.textContent = `연결됨 · ${dev.name}`; // 예: "VINU KIDS" }); // 2) 굽기 — 펌웨어 바이트는 호출 측이 준비(예: AWS S3 버킷에서 다운로드) flashBtn.addEventListener("click", async () => { const res = await fetch(s3FirmwareUrl /*, { headers: ... } */); const bytes = await res.arrayBuffer(); await dl.flash(bytes, { format: "vinu", // vinu | bin | hex (File 을 넘기면 확장자로 자동 추론) modelLock: true, // 기기와 다른 모델이면 throw (기본 true) onProgress: (e) => { // e.phase: "boot-entry" | "erase" | "write" | "jump" | "complete" // e.progress: 0~1, e.bytesTransferred / e.totalBytes (write 단계) updateBar(e.phase, e.progress); }, }); });
import { VinuError, VinuErrorCode } from "@aluxrobot/vinu-downloader"; try { await dl.flash(bytes, { onProgress }); } catch (err) { if (err instanceof VinuError && err.code === VinuErrorCode.MODEL_MISMATCH) { alert("이 기기에는 맞지 않는 펌웨어입니다."); } else { // TIMEOUT, ERROR_FROM_TARGET, USER_CANCELLED 등 } }
new VinuDownloader({ runtimeBaud? })connect(): Promise<DeviceModel>—{ key, name, code }. user-gesture 필요.flash(firmware, options?)—firmware:File | ArrayBuffer | Uint8Array.disconnect(): Promise<void>getDeviceModel(),isConnected()
Apache-2.0. 펌웨어 프로토콜은 chcbaram/stm32h750 (Apache-2.0) 기반 파생물이며,
해당 코드가 이 패키지에 번들된다. 자세한 사항은 저장소 루트의 NOTICE 참조.