feat(admin): M110 phone label batch print (Bluefy / Web Bluetooth)#294

open1
main
feat/admin-m110-phone-labels
openedAug 25, 2026byAAviddaram
View on GitHubTwo-way sync enabledPR last imported 19d ago

Summary

  • Adds a small Phomemo M110 client under apps/admin/src/lib/phomemo (protocol + 1bpp phone raster + Web Bluetooth), ported from pyphomemo.
  • Orders list batch toolbar gets Утас хэвлэх — sequential phone-only labels; selection stays so you can TU-send next.
  • iOS path: open admin in Bluefy (not Safari). Capacitor left as fallback if Bluefy fails a 30-label stress test.
  • Research/impl notes in docs/research/phomemo-m110-*.md.

Test plan

  • Phase 0 (home): Bluefy → Phomymo → M110 → print 1, then 5, then 30 labels
  • Measure real label mm; adjust LABEL_WIDTH_MM / LABEL_HEIGHT_MM / DEFAULT_MEDIA in constants.ts if not 40×30 gap
  • Staging/prod admin in Bluefy: select pending orders → Утас хэвлэх → connect M110 → verify phones on stickers
  • Cancel mid-batch; confirm printed vs remaining in the dialog
  • Confirm selection remains for TU руу илгээх
  • Safari: button should toast that Bluefy is required
  • bun run --cwd apps/admin check-types

Label size is provisional (40×30 mm). Hardware gate has not been run from this machine.

Made with Cursor

Checks

4 successful · 1 skipped
All checks passed
c5ac53e

Added 1 commit

  • feat(admin): batch-print M110 phone labels via Web Bluetoothc5ac53e
Synced from GitHub

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc7cf049-bf5f-4a7e-a153-e4dd819acd57


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.

Synced from GitHub

Greptile Summary

Adds Bluefy/Web Bluetooth support for sequentially printing phone-number labels from selected pending orders in the admin dashboard.

  • Introduces M110 protocol framing, 1bpp canvas rasterization, BLE transport, and sequential batch orchestration.
  • Adds print progress, cancellation, per-order status display, and result notifications to the orders toolbar.
  • Documents the provisional hardware assumptions, protocol research, and Bluefy-first rollout plan.

Confidence Score: 5/5

The PR appears safe to merge from code review, with hardware compatibility and the provisional label dimensions remaining explicit rollout gates rather than established code defects.

The reviewed UI, batch-state, raster, protocol, and Bluetooth paths form a coherent printing flow, and no concrete changed-code failure meeting the publication criteria remains.

Important Files Changed

FilenameOverview
apps/admin/src/components/order/orders-list.tsxAdds the phone-label batch action, printer lifecycle state, cancellation control, progress dialog, and result notifications without clearing order selection.
apps/admin/src/lib/phomemo/batch.tsImplements sequential label jobs with immutable progress snapshots, cancellation handling, and stop-on-first-failure behavior.
apps/admin/src/lib/phomemo/printer.tsImplements the structured M110 command, raster, chunking, delay, and footer sequence.
apps/admin/src/lib/phomemo/protocol.tsDefines byte-level M110 commands, little-endian raster headers, footer framing, and payload chunking.
apps/admin/src/lib/phomemo/raster.tsFormats phone numbers and converts canvas-rendered text into fixed-size MSB-first 1bpp raster data.
apps/admin/src/lib/phomemo/web-bluetooth.tsAdds device selection, saved-device reconnection, FF00/FF02 GATT setup, and characteristic write-mode fallback.
apps/admin/src/lib/phomemo/constants.tsCentralizes provisional label geometry, BLE identifiers, protocol settings, and print timing parameters.

Sequence Diagram

mermaid
1sequenceDiagram
2 actor Admin
3 participant Orders as Orders List
4 participant Batch as Batch Printer
5 participant Raster as Phone Rasterizer
6 participant BLE as Web Bluetooth
7 participant M110 as Phomemo M110
8 Admin->>Orders: Select pending orders
9 Admin->>Orders: Click Утас хэвлэх
10 Orders->>BLE: Connect or reuse connection
11 loop Each selected order
12 Orders->>Batch: Print phone
13 Batch->>Raster: Render 1bpp phone label
14 Raster-->>Batch: Packed raster bytes
15 Batch->>BLE: Send commands and raster chunks
16 BLE->>M110: GATT writes
17 M110-->>Batch: Write completion or error
18 Batch-->>Orders: Update per-order progress
19 end
20 Orders-->>Admin: Show printed, failed, or cancelled states

Reviews (1): Last reviewed commit: "feat(admin): batch-print M110 phone labe..." | Re-trigger Greptile