open-transfer

Nearby sharing and the device mesh (design, V2)

Status: design, not built. Nothing here ships until Phase M0 (below) shows each piece works on real hardware.

Goal

Open Transfer works like Quick Share or AirDrop: any nearby device shows up and can be sent to from the share menu, whether or not it’s on the same Wi‑Fi. And your own devices form one connected mesh, the way Echo devices do: each one reaches the others over whatever link it has (the same Wi‑Fi, Bluetooth, a phone’s local hotspot), and passes things on for a device the sender can’t reach itself.

Three ways in, one network:

Way in Who Exists today
Same Wi‑Fi (discovery) anyone nearby, asked first ✅
Pairing code / QR link your devices: trusted, then introduced to the rest ✅
Bluetooth nearby your devices, or anyone while you’re visible to everyone new (this design)

Paired devices find each other and send files, text, links and clipboard even when they are not on the same Wi‑Fi and there is no internet: on a train, in a field, on two different networks. Everything stays local: no relay server, no cloud, no internet.

Required connection scenarios (product requirement)

Any supported combination of phones and computers connects and transfers over a local network path, with no internet and no shared router. These four are requirements, not experiments:

# Scenario Host Joins
S1 Phone hosts a hotspot → laptop joins Android phone Mac, Windows, Linux laptop
S2 Laptop hosts a hotspot → phone joins Windows, Linux, Mac laptop Android phone (also any browser phone)
S3 Both on the room’s Wi‑Fi the router everyone (✅ today)
S4 Phone A hosts → phone B joins, both running Open Transfer Android phone Android phone or tablet

The connection manager (below) detects which paths exist, picks the best usable one, and takes the host or the joining role wherever the platform allows each. Where a platform forbids a role, the manager uses the other device in that role, and the app says so. Where no device can take it (see the restrictions table), the scenario falls back to the user switching the hotspot on by hand, which the app then uses as in S3. Each restriction below is either verified (with the evidence) or marked must verify in M0; nothing is assumed.

The model is bitchat: devices talk over Bluetooth LE, and messages can hop through other devices in range. Bluetooth is slow, so for anything bigger than a message the devices use Bluetooth only to arrange a fast link: one phone opens a private, local-only Wi‑Fi hotspot and the other joins it for the transfer. This is how Nearby Share and AirDrop work.

Not in scope, and why

Asked for Why not
WebRTC in the apps WebRTC needs an IP route between the devices. With no shared network and no internet there is none, and STUN/TURN are internet servers. It would also add aiortc, a native library with no Android build (the same trap as cryptography, see v1.md). The hotspot link below gives the same speed with the transfer code that already exists.
Share links to browsers over the mesh A browser can’t use Bluetooth mesh (Web Bluetooth can’t advertise, and iPhones have none). Instead a phone can show a Wi‑Fi QR code for its local hotspot: a browser joins it, then opens the usual link (Phase M6).
iPhone / iPad apps There’s no native iOS app; the browser can’t do Bluetooth.
Long-range or internet relays Out of scope by choice: all local.

What already exists and is reused

So the new parts are a Bluetooth link, a mesh layer over it, and the hotspot handoff. Once two devices share the hotspot, the rest is today’s code.

Hotspot roles per platform: restrictions (verified 2026-11-12)

Checked against the SDKs on the development Mac (macOS 27.0.1 SDK headers; Android android-34…android-37.0 platform jars and sources) and on this Mac’s own Wi‑Fi. Windows could not be checked: the test laptop was not on the network.

Platform Host a hotspot from the app Join a given network from the app Evidence / restriction
Android 8–15 ✅ WifiManager.startLocalOnlyHotspot: no internet, random SSID and passphrase chosen by Android, read back from the reservation ✅ WifiNetworkSpecifier + ConnectivityManager.requestNetwork: Android always shows its own Connect dialog; the network belongs to the app, which must bind to it (bindProcessToNetwork) Verified in the SDK. Hosting needs CHANGE_WIFI_STATE + NEARBY_WIFI_DEVICES (Android 13+) or ACCESS_FINE_LOCATION (12 and below). The hotspot fails with ERROR_INCOMPATIBLE_MODE / ERROR_TETHERING_DISALLOWED when the user’s own Mobile hotspot is on or tethering is blocked; the user can stop it in Settings; it ends when the app releases it. On phones without isStaApConcurrencySupported() the phone leaves its Wi‑Fi while hosting; on phones without isStaConcurrencyForLocalOnlyConnectionsSupported() it leaves its Wi‑Fi while joining.
Android 16+ ✅ as above, plus startLocalOnlyHotspotWithConfiguration (app picks band etc.) ✅ as above Verified in the SDK: new in API 36. TetheringManager.startTethering (the user’s normal hotspot) is public in API 36 but needs TETHER_PRIVILEGED, which apps can’t hold: the app can’t switch on the normal Mobile hotspot.
Android 9 and older (phone 2) — — The app needs Android 10 (minSdk 29). Such a phone joins a hotspot by hand and uses the browser.
macOS ❌ No public API. CoreWLAN only has startIBSSMode… (ad-hoc, WEP only, deprecated since macOS 11; Android can’t join ad-hoc networks). Internet Sharing has no API and needs an admin and a source interface ✅ networksetup -setairportnetwork <if> <ssid> <password> joins by name without Location permission (verified in M0). CWInterface.associate(to:password:) needs a CWNetwork from a scan, and a scan returns no network names without Location Verified: CWInterface.h in the macOS 27 SDK; a scan on this Mac without Location permission found 4 networks, 0 with names, and couldn’t read the current network’s name. Verified in M0: networksetup joins without Location (S1 app-driven, below). Still to verify: Internet Sharing (Wi‑Fi) with no upstream connection, by hand.
Windows 10/11 ⚠️ (a) Wi‑Fi Direct legacy access point (WiFiDirectAdvertisementPublisher with LegacySettings: SSID + passphrase, phones join it as a normal Wi‑Fi); (b) Mobile Hotspot (NetworkOperatorTetheringManager), which may need an upstream connection ⚠️ netsh wlan add profile (per user) + netsh wlan connect, or the WLAN API Must verify in M0 on the Windows laptop: which of (a)/(b) starts with no internet and no router; whether joining needs admin. netsh wlan … hostednetwork is deprecated and most current drivers report Hosted network supported: No (check netsh wlan show drivers).
Linux ✅ NetworkManager (nmcli device wifi hotspot) ✅ nmcli device wifi connect Not a target device for M0; follows after.
iPhone / iPad (browser) ❌ (Personal Hotspot by hand only) by hand; the Camera app joins a Wi‑Fi QR code Browser only, as today.

What this means for the four scenarios:

  Android phone Samsung tablet Mac Windows laptop
Can host from the app ✅ (verify on device) ✅ (verify on device) ❌ (by hand: Internet Sharing, must verify) ⚠️ must verify
Can join from the app ✅ with Android’s dialog ✅ with Android’s dialog ✅ networksetup, no Location needed (M0) ⚠️ must verify

Bluetooth roles per platform

  Android app Mac app Windows app Linux Browser / iPhone
BLE scan (central) ✅ Kotlin ✅ CoreBluetooth ⚠️ WinRT ⚠️ BlueZ ❌ for this
BLE advertise + GATT server (peripheral) ⚠️ most phones (isMultipleAdvertisementSupported) ✅ verified (M0, run as its own app) ⚠️ WinRT, only on adapters that report IsPeripheralRoleSupported ⚠️ BlueZ D-Bus ❌
Runs in the background ✅ foreground service (connectedDevice) ✅ menu-bar app ✅ tray app ✅ —
Permissions the user grants Nearby devices (Bluetooth), Nearby Wi‑Fi devices Bluetooth (per app: the app’s Info.plist needs NSBluetoothAlwaysUsageDescription); Location (to join Wi‑Fi by name) none special none special —

⚠️ = must be proven on the real devices in M0. The user grants every permission themselves; the app never changes system or security settings.

Connection manager

One component on every app decides how two devices connect. It runs whenever a send targets a device that isn’t reachable on any current address.

1. Already connected?  The same Wi‑Fi (S3), or both already on some hotspot
   (one of them switched it on by hand): use it. Nothing to arrange.
2. Can the two arrange a hotspot?  Host = the first device in this order that can host
   from the app: Android (LocalOnlyHotspot) › Windows (if M0 passes) › Linux.
   The other must be able to join: from the app (Android, Windows, Linux, Mac with
   Location) or, failing that, by hand with the name and password shown.
3. Credentials: host → joiner over
     a. Bluetooth, sealed under the pair key (once M1/M2 exist), or
     b. a QR code on the host's screen: `WIFI:T:WPA;S:<ssid>;P:<pass>;;` plus the
        Open Transfer link, scanned by the joiner's app (or any phone's camera), or
     c. the name and password shown, typed by hand.
4. Find each other on the hotspot: the joiner connects to **its default gateway**
   (on a hotspot that is the host) on the app port; multicast and the /24 sweep (H7)
   as usual. The host never needs to know its own hotspot address (Android apps can't
   list interfaces; see the 192.0.0.4 fix).
5. Transfer: the usual signed offer + `ot-file/2`. The hotspot adds no trust.
6. Tear down: the host releases the hotspot; the joiner forgets the network and
   rejoins its previous Wi‑Fi. On failure the send ends with the reason
   (*declined in Android's dialog*, *Location is off*, *hotspot blocked by the user's
   Mobile hotspot*…).

Paths are ranked by speed and by how much they disturb the user: existing Wi‑Fi > an existing hotspot > an arranged hotspot where nobody leaves a network > one where the joiner leaves its Wi‑Fi > Bluetooth (small items only).

Architecture

            ┌──────────────── existing ────────────────┐
 page/UI ── │ jobs, offers, ot-file/2, sync/1, history │
            └───────────────┬──────────────────────────┘
                            │ "send this to device X"
                     ┌──────┴──────┐
                     │  Link picker │  LAN first; else BLE (small) or hotspot handoff (big)
                     └──┬────┬───┬─┘
              LAN (HTTP)│    │   │Hotspot handoff → then LAN (HTTP) on the hotspot
                        │  BLE mesh
                        │    │
            ┌───────────┴────┴───────────────────┐
            │ Native Bluetooth per platform       │  Kotlin · CoreBluetooth · WinRT · BlueZ
            │ (advertise, scan, GATT, framing)    │
            └─────────────────────────────────────┘

Quick Share-style sharing

How Quick Share and AirDrop behave, and what Open Transfer does the same way:

Each app keeps a list of neighbours on every link: Wi‑Fi (today’s discovery), Bluetooth, and a hotspot it hosts or joined. Your devices then work as one network:

Mesh layer (bitchat-style)

Envelope (CBOR), sent over one hop and possibly relayed:

v        1
id       16 random bytes            dedupe; replays refused
ttl      hops left (start 4, max 7)
to       routing tag for the destination (rotating, as in the advertisement)
from_tag the sender's rotating tag (lets the receiver find the pair key)
kind     "sync" | "offer" | "handoff" | "ack"
body     sealed with the sync/1 seal (HKDF from the pair key, HMAC-SHA256 counter-mode
         keystream, encrypt-then-MAC), the MAC also covering id, to and kind

What goes over the mesh: clipboard (sync/1), text and links, files up to 64 KiB, introductions and revocations, and the handoff messages below. Everything else waits for a fast link.

Hotspot handoff (big files, one hop)

Both devices must be in Bluetooth range of each other (not relayed): the hotspot only reaches as far as Wi‑Fi does anyway.

1. Sender → receiver (BLE, sealed):  handoff-request {job, total size, file count}
2. The device that can host (Android preferred; the receiver if both can) starts a
   LocalOnlyHotspot. Android picks the SSID and a random WPA2 passphrase each time.
3. Host → other (BLE, sealed):       handoff-offer {ssid, passphrase, host ip, port,
                                      expires in 120 s}
4. The other device joins (Android: the system's Connect dialog; Mac: CoreWLAN;
   Windows: a temporary WLAN profile), saying first that it leaves its current Wi‑Fi.
5. Both apps already listen on the new interface (H7). The sender runs the usual
   signed offer + ot-file/2 transfer over HTTP to host ip:port.
6. Done, failed or 10 minutes idle: the host stops the hotspot; the joiner forgets
   the network and rejoins its previous Wi‑Fi.

Security and privacy

Threat Answer
Tracking a phone by its Bluetooth advertisement Rotating tags, no ids or names in the clear except while Visible to everyone is open. The OS rotates the Bluetooth MAC address.
Someone pretending to be a paired device Tags and envelopes need the pair key; the seal’s MAC covers the header too; ids are remembered, so replays are refused.
A relay reading or changing messages It holds no key: it sees ciphertext; a change fails the seal.
Flooding the mesh Per-neighbour rate limits, TTL ≤ 7, 64 KiB cap, relaying only for its own network by default.
Hotspot credentials stolen over the air Sent sealed; random per handoff; valid 120 s; the transfer on top is ot-file/2 anyway.
A revoked device keeps relaying or advertising Its key is gone everywhere: its tags aren’t recognised and its envelopes don’t open.
Downgrade from the LAN The link picker never prefers Bluetooth when the LAN works; encryption rules are the same on every link.

Security review (as for ot-file/2 in encryption.md) is a gate before M2 ships.

Phases

Each phase: tests first, then the code, the whole suite and CI, then a real-device run. Emulators have no usable Bluetooth or Wi‑Fi hosting, so every phase needs a person with the devices for its last check; the automated part runs the mesh logic against an in-memory fake radio.

# Phase Done when (automated) Done when (real devices)
M0 Spike, go / no-go. Throwaway native snippets on each platform: advertise + scan + GATT echo; measured throughput Android ↔ Mac ↔ Windows; LocalOnlyHotspot + join from Mac, Windows, Android; Windows hosting without upstream — A table of what works on your Android phone, the Samsung tablet, the Mac and the Windows laptop, with numbers. Anything ❌ re-plans the phases
M1 Find paired devices by Bluetooth (Android + Mac). Tiles say Nearby · Bluetooth Tag rotation and recognition; fake-radio discovery between two in-process apps Phone and Mac with Wi‑Fi off see each other’s tiles within 10 s; a stranger’s scan shows no ids
M2 Send small items over Bluetooth (one hop): clipboard, text, links, files ≤ 64 KiB Framing, windowing, sealing, replay, size cap; history and Activity as for LAN sends Clipboard and a 50 KB file both ways with Wi‑Fi off; a revoked device can’t send
M3 Connection manager + hotspot handoff: S1, S2, S4 arranged by the app (credentials by QR first, Bluetooth once M2 exists) Path ranking; handoff state machine with fakes (timeouts, declined dialog, no Location, hotspot refused, rejoin) The M0 matrix’s S1, S2 and S4 rows, now driven by the app: 1 GB each way, no router, no internet; every joiner back on its Wi‑Fi afterwards
M4 Windows Bluetooth and joining Same tests on Windows CI with the fake radio Windows ↔ phone: small items over Bluetooth, 1 GB by handoff
M5 One mesh across links: reachability in hellos, routing through members, bridging Wi‑Fi ↔ Bluetooth, multi-hop for small items Route choice, dedupe, TTL, rate limits, store-and-forward on a fake 5-device network mixing links Mac → (Wi‑Fi) → tablet → (Bluetooth) → phone with the phone off the Mac’s Wi‑Fi and out of its Bluetooth range
M6 Visible to everyone for 10 minutes: unpaired nearby share over Bluetooth, and a Wi‑Fi QR so a browser (iPhone) can join the phone’s hotspot and use the link Unpaired handoff asks the receiver first; visibility switches back after 10 min; Wi‑Fi QR format A stranger’s phone receives a photo after accepting; an iPhone joins by the Wi‑Fi QR and downloads
M7 Share from anywhere: Mac Services menu, Windows Send to, Android Quick Settings tile Installer creates the SendTo shortcut; the Services entry hands files to the app Right-click a file → Open Transfer → it’s staged, on each computer

M0 test matrix: the four scenarios on the target devices

Devices: P = Android phone (Nirakara), T = Samsung tablet, M = MacBook Air (macOS 27), W = Windows 11 laptop, P2 = Android 9 phone (browser only). Router off or out of reach and no internet in every row except S3.

Each row is run twice: by hand first (the user switches the hotspot on and joins from the system’s Wi‑Fi menu; this needs no new code, because H7 already serves on a hotspot) and then by the spike tools for the from-the-app roles. Record pass/fail, the exact OS dialog or error, and transfer speed (1 GB).

# Host → joiner Host role (how) Join role (how) Pass when
S1a P → M LocalOnlyHotspot (spike app) networksetup -setairportnetwork without Location; then CoreWLAN with Location granted Both see each other’s tile; 1 GB both ways; M rejoins its Wi‑Fi after
S1b P → W LocalOnlyHotspot netsh wlan add profile + connect, as a normal user Same
S1c T → M LocalOnlyHotspot on the tablet as S1a Same
S2a W → P Wi‑Fi Direct legacy AP; else Mobile Hotspot WifiNetworkSpecifier (Android’s dialog) Same; record which Windows option worked with no upstream
S2b M → P Internet Sharing by hand, sharing from an unplugged interface WifiNetworkSpecifier Same, or a documented ❌ for Mac hosting (then S2 with a Mac = not possible)
S2c W → P2 as S2a P2 joins by hand, uses the browser P2 sends and receives in the browser
S3 router → all — — ✅ already verified on real hardware (Mac, Windows, Android, 2026-11-07)
S4a P → T LocalOnlyHotspot WifiNetworkSpecifier Same; record whether each device left its own Wi‑Fi (isStaApConcurrencySupported, isStaConcurrencyForLocalOnlyConnectionsSupported)
S4b T → P LocalOnlyHotspot on the tablet WifiNetworkSpecifier Same
X1 any host — — The hosting phone’s app is reachable at the joiner’s default gateway address
X2 P (its Mobile hotspot on by hand) user’s hotspot the app tries LocalOnlyHotspot Fails cleanly with ERROR_INCOMPATIBLE_MODE and the app uses the hotspot that’s already on

Go / no-go: S1, S2 (with Windows) and S4 must pass to start M3. A Mac that can’t host is an accepted platform restriction (S1 covers Mac + phone); anything else that fails re-plans the phases before code is written.

M0 results so far

Check Result
Mac advertises a GATT service (spikes/m0/mac/otble.swift) ✅ Bluetooth on, advertising OT-M0, when run as its own app (otble.app). Started from a shell instead, macOS stops it (exit 134): Bluetooth permission belongs to the app that launched it. The Mac app needs NSBluetoothAlwaysUsageDescription in its Info.plist.
Mac hosting a hotspot from an app ❌ verified: no public API (macOS 27 SDK CWInterface.h: only deprecated ad-hoc IBSS)
Mac joining by network name without Location permission CoreWLAN: ❌ (a scan found 4 networks, 0 with names). networksetup: ✅ (S1 app-driven below)
S1 app-driven P hosts a LocalOnlyHotspot → M joins with networksetup (spikes/m0/mac/s1_app.sh, all over USB while M was offline) ✅ P’s hotspot AndroidShare_… with a random passphrase, P at 10.57.43.87 · M joined in ~10 s, no Location permission · X1 ✅ gateway = P · M → P 200 MB at 8.0 MB/s · cleanup: network forgotten, hotspot stopped, M back on its usual Wi‑Fi and online 8 s later
Android hosting / joining APIs ✅ verified in the SDK (API 26+ hosting, API 29+ joining with Android’s dialog; API 36 adds configured hosting; normal Mobile hotspot not startable by apps)
Phone P capabilities (Nothing A015 / CMF Phone 1, Android 16, 2026-11-13) Host while on Wi‑Fi (STA+AP): ✅ · join while staying on Wi‑Fi (STA+STA local-only): ❌, so joining drops its Wi‑Fi · 5 GHz ✅ · Wi‑Fi Direct ✅. The app’s Java interface list shows ap0 10.18.116.240 (its Mobile hotspot) and v4-ccmni2 192.0.0.4 (464XLAT): Android hands the app its real addresses, which Open Transfer’s Python side couldn’t list (the 192.0.0.4 bug)
X2 P’s Mobile hotspot on, app asks for LocalOnlyHotspot ✅ as the SDK says: onFailed(ERROR_INCOMPATIBLE_MODE). The connection manager uses the hotspot that’s already on
S1 by hand P hosts (its Mobile hotspot, 5G upstream) → M joins from the Wi‑Fi menu ✅ M 10.18.116.97 · X1 ✅ M’s default gateway = P (10.18.116.240) · M → P 1 GB in 133 s = 7.7 MB/s · P → M 100 MB = 9.3 MB/s (TCP, both ends agree)
Bluetooth P ↔ M (otble ↔ spike app, 256 KiB each way) M advertises, P connects: P → M 10.9 KB/s; M → P link dropped by the Mac after starting (status 19, not chased). P advertises, M connects: M → P 16.4 KB/s, P → M 22.4 KB/s. MTU 517 negotiated, but Android refuses attribute values over 512 bytes (IllegalArgumentException; the first spike stalled on it). Bluetooth is ~400–800× slower than the hotspot: small items and arranging links only, as designed
Still to run S2 (Windows laptop; Mac hosting by hand), S4 (tablet), S1 to Windows

New dependencies (each needs your OK before it is added): on macOS pyobjc-framework-CoreBluetooth and pyobjc-framework-CoreWLAN; on Windows the winrt Bluetooth and WLAN packages; Android needs none (platform APIs).

Open questions for you

  1. M0 hardware: which devices can you run the spike on, and is the Samsung tablet available? M0 decides everything after it.
  2. Leaving Wi‑Fi for a handoff: acceptable on a laptop that’s on a work network? The app will always say so and ask first.
  3. Relaying for strangers: keep Help other people’s messages along off by default, as above?
  4. Talking to Google’s Quick Share: the Mac could also receive from any Android phone’s built-in Quick Share (as the open-source NearDrop does), with no Open Transfer on the phone. It’s an unofficial, reverse-engineered protocol Google can break at any time. Worth a separate experiment, or leave it out?