6
Home
Lasan Mahaliyana edited this page 2026-02-05 03:49:54 +05:30
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, WiFi, 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.h and connections/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, WiFi LAN/Hotspot/Direct, WebRTC, AWDL).

Typical lifecycle (short)

  1. App calls Core::StartAdvertising(...) or Core::StartDiscovery(...) (or V3 variants).
  2. ServiceControllerRouter routes the request to OfflineServiceController, which starts/stops medium-specific advertising/scanning.
  3. When a remote endpoint is found, RequestConnection() is used to send a connection request; the responder sees OnConnectionInitiated.
  4. If accepted, the medium-specific EndpointChannel is registered in EndpointManager; payloads are sent via PayloadManager.
  5. Optionally, InitiateBandwidthUpgrade() triggers BwuManager to negotiate a higher-bandwidth medium and swap the active EndpointChannel.

Where to read next

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.