closed-captioner

p2p-radio — Mac test radio

This tool is a nearby Closed Captioner radio: it sends and receives over Multipeer Connectivity (local Wi‑Fi and/or Bluetooth). It does not use cellular or any server.

“Radio” matches the in-app control — one peer that can talk both ways.

Requirements

Run

From the repository root:

cd tools/p2p-radio
swift run p2p-radio

It starts silent. Nothing is sent until you type a line and press Enter.

On the phone:

  1. Open Closed Captioner.
  2. Tap the radio icon (top right) so it lights up.
  3. Allow Local Network if iOS asks.
  4. Type a line in the Mac terminal and press Enter.
  5. The nearby message log should show [Your-Mac-Name] your text.

Incoming traffic on the Mac prints as:

[Karthiks-iPhone] hello  14:02:11

If the line was relayed (someone else originated it; a neighbor forwarded it here), the neighbor that emitted it to this process is appended:

[Karthiks-iPhone] hello  14:02:11  via Mids-iPhone

Two Mac processes can talk to each other the same way.

Ctrl+C stops.

If nothing appears

This stub travels over local Wi‑Fi / Bonjour more often than Bluetooth. Two iPhones are still required to prove Bluetooth in a room with no network.

Protocol

JSON envelope, UTF-8:

{"v":1,"text":"hello","from":"Karthiks-MacBook"}

Bonjour service type: cc-p2p (_cc-p2p._tcp in the iOS Info.plist). Discovery info: role=emit, id=<uuid>.

Keep Sources/RadioPeer/P2PConfig.swift in sync with ClosedCaptioner/Services/P2PConfig.swift.