Table of Contents
Welcome to the nearby wiki!
NOTE: This wiki is not maintained by google or anyone affiliated with google. I'm doing this because I'm developing the linux implementation of nearby connections and sharing because I think its pretty cool and should be available everywhere
Nearby Connections — Overview
This page provides a concise architecture-level overview of Nearby Connections as implemented in the nearby_latest tree.
What Nearby Connections is
- A medium-agnostic, encrypted, reliable socket-like protocol layered atop local radios (Bluetooth, BLE, Wi‑Fi, WebRTC, AWDL, etc.).
- Devices advertise and discover services, exchange connection requests, and (after establishing a baseline channel) optionally upgrade to a higher-bandwidth medium.
Core components (high level)
- Core: public client API. See
connections/core.handconnections/core.cc. - ServiceControllerRouter: serializes Core-level requests and routes them to a ServiceController (see
connections/implementation/service_controller_router.*). - ServiceController (OfflineServiceController): orchestrates PCP handlers and medium lifecycle.
- EndpointManager: tracks remote endpoints and dispatches incoming frames to frame processors.
- EndpointChannelManager: holds the active EndpointChannel for each endpoint and manages encryption context and channel replacement (used during BWU).
- PayloadManager / Payload types: chunking and transfer of payloads.
- BwuManager: bandwidth-upgrade orchestrator; coordinates per-medium BwuHandlers.
- Medium implementations: per-platform/per-medium modules (Bluetooth, BLE, Wi‑Fi LAN/Hotspot/Direct, WebRTC, AWDL).
Typical lifecycle (short)
- App calls
Core::StartAdvertising(...)orCore::StartDiscovery(...)(or V3 variants). - ServiceControllerRouter routes the request to OfflineServiceController, which starts/stops medium-specific advertising/scanning.
- When a remote endpoint is found,
RequestConnection()is used to send a connection request; the responder seesOnConnectionInitiated. - If accepted, the medium-specific EndpointChannel is registered in EndpointManager; payloads are sent via PayloadManager.
- Optionally,
InitiateBandwidthUpgrade()triggers BwuManager to negotiate a higher-bandwidth medium and swap the active EndpointChannel.
Where to read next
- Bandwidth Upgrade
- Discovery and Advertising
- API
- Mediums
- Testing and Implementations
- There are some implementations you can test drive here. There is an apk you can install for the android side that is prebuilt. But for the linux side of things, you'll have to setup a dev environment and build it using bazel.
What I'm working on next
Next I'd like to focus on creating a long-lived service for Linux that can accept Nearby Connections continuously (vs. one-off test binaries).
Before I add more features, I want to improve reliability and error recovery in the Linux platform layer. Right now there are some deadlocks when closing L2CAP sockets (among other issues). I'd like to fix those first so the service can run unattended without getting wedged.