Skip to content

QR code pairing for the phone apps - #38

Merged
i2cjak merged 1 commit into
mainfrom
backplane/qr-pairing
Oct 2, 2026
Merged

i2cjak merged 1 commit into
mainfrom
backplane/qr-pairing

Conversation

@i2cjak

@i2cjak i2cjak commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Pair a phone by scanning a code instead of pasting the link.

  • src/core/qr.bend: a pure QR encoder (byte mode, level M, versions 1-40, the mask with the least penalty). Qr.link wraps the pairing link as backplane://pair?url=…, so the phone's own camera app opens Backplane with it. Laws qr_* and pair_qr_none.
  • The hub sends the code as info pair.qr (Info.qr in server.bend). The Settings "Pairing link" row gets a QR code button (flag pairqr, client.bend's Pair.qr):
    • window: an overlay; a click anywhere closes it (Pq.* in layout.bend).
    • web: an inline SVG under the row (View.pair.qr, Qr.path).
    • phones: the settings row carries qr, drawn natively (Mob.set.pair).
  • Scanning: a "Scan QR code" button on the phones' pairing screen and in Hubs. iOS uses AVFoundation (Pair.swift, plus NSCameraUsageDescription). Android uses Google Play services' code scanner (Pair.kt), so it needs no camera permission of its own; androidx.fragment is pinned because that dependency brought in an old one that lint rejects.
  • scripts/bridge-native.py: String.eq's pattern hard-coded the minifier's name Q; the larger bundle renamed it, so it now matches any name (still gated on the String.eq/Cmp.is_eq shape, still exactly once).

Tests

  • scripts/check.sh (PROOF: all terms check) and scripts/test.sh: 75 programs, all ok, including the new test/qr_test.bend.
  • The encoder matches python-qrcode module for module, with the same mask forced, on all 40 versions (each filled exactly) and on UTF-8 text; zxing decodes every code.
  • Native window on Xvfb with a throwaway hub: Settings, then QR code. zxing decodes the screenshot to backplane://pair?url=http://<tailnet ip>:3911/%23token=…, and a click closes the overlay.
  • Web client against the same hub: the inline SVG decodes the same way.
  • Android release APK builds; iOS builds and launches in the Simulator. Scanning with a real camera was not tried (no device attached).

The hub sends its pairing link as a QR code (core/qr.bend: byte mode,
level M, versions 1-40, least-penalty mask; info pair.qr). Settings'
QR code shows it in the window, on the web and on phones; the code
holds backplane://pair?url=<link>, so a phone's own camera opens the
app. The apps scan it from the pairing screen and Hubs (iOS with
AVFoundation, Android with Play services' code scanner).

bridge-native.py no longer assumes the minifier names String.cmp's
forcing call Q.
@i2cjak
i2cjak merged commit 79b778f into main Oct 2, 2026
2 checks passed
Snaiderbg pushed a commit to Snaiderbg/Backplane that referenced this pull request Oct 9, 2026
Composer: Up/Down by shown lines, click to place the caret, drag to select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant