Post

After the Handshake: How an Oculus Controller Actually Talks to the Headset

In the previous protocol post I covered discovery, pairing and the SPL command set. At the end I promised a deep dive into the “real” protocol, the one that carries button presses, stick movements and motion data while you play. It took a while, but here it is.

Since then I built a small tool for this research. I call it Pulsar Connect (plsr-connect). It’s firmware for a cheap nRF52840 USB dongle (the Nordic PCA10059) that speaks the controller’s radio protocol, plus a Python client to drive it from a PC. The dongle can pretend to be a headset, so a paired controller connects to it and streams its data. This let me poke at the link from both sides and figure out how it works.

This is the first post of a small series about what I learned:

  1. The APP link - beacons, slots, hopping and encryption (this post)
  2. The timing - why every microsecond matters
  3. The data - buttons, sticks, touch and the IMU
  4. A fun side project - the controller as a USB mouse
  5. How the dongle firmware is built

Please note that all information presented here is the result of independent research and may contain mistakes or inconsistencies. Everything was tested against a (left) Quest 2 controller running firmware v1.9.2.

SPL vs APP

Quick recap. Pairing happens over SPL on 2426 MHz. (In the previous post I wrote that the main communication uses 2426 MHz too. That was wrong. As you’ll see below, the APP link hops all over the band and avoids 2426 MHz on purpose.) When pairing is done, both the controller and the headset know two things:

ItemSizeUsed for
Link address4 bytesThe radio base address of every packet, and the seed of the hop sequence
Link key16 bytesThe AES-128 key that protects everything the controller sends

After pairing, the controller leaves SPL and switches to what I call the APP link. It works very differently. SPL is a chatty command/response protocol on one channel, while the APP link is a strict time-slotted link that hops across the whole 2.4 GHz band, 500 times per second.

There are two roles:

  • Host (the headset, or my dongle playing one): owns the clock, the slot grid and the hop sequence. Sends a beacon every slot.
  • Client (the controller): follows the beacons and answers in its own time slot, in every slot.

The Physical Layer

Mostly the same radio setup as SPL, with a few differences in the frame:

ParameterValue
Modulation2 Mbit/s GFSK (Nordic proprietary mode), no whitening
Preamble1 byte
Address5 bytes: 1-byte prefix + 4-byte base (the link address)
HeaderS0 (1 byte), LEN (1 byte)
Body0-70 bytes
CRC24-bit, polynomial 0x108421, initial value 0xFFFFFF

The address is worth a closer look. Every frame on the link uses the link address from pairing as its base address, so the radio hardware drops packets from other controllers/headsets before the CPU even sees them. The 1-byte prefix then says which “stream” the packet belongs to:

PrefixStreamSent by
0xF0BeaconsHost
0x01Seek answers (attach requests)A controller that hasn’t joined yet
0x02-0x05Endpoint answers (endpoint n uses prefix n + 1)A joined controller

So the link has room for up to 4 endpoints. Two controllers is the obvious use. (My dongle has only been tested with one so far.)

The Slot Grid

Everything on the APP link happens inside a 2 ms slot. The host sends a beacon at the very start of the slot, and each answer has a fixed offset from it:

APP Link 2 ms Slot Grid

Answer slotOffset from beacon startPrefix
Seek350 µs0x01
Endpoint 1575 µs0x02
Endpoint 2875 µs0x03
Endpoint 31175 µs0x04
Endpoint 41475 µs0x05

That’s 500 beacons a second, and a joined controller answers every one of them. So the input latency stays low, there’s always a slot coming up within 2 ms.

The controller measures every offset from the beacon it actually received, so it doesn’t need the headset’s local clock to place its answers. It only has to hear the beacon. In practice it’s a bit more subtle than that, but the timing gets its own post next week.

The Beacon

The host sends a beacon at the start of every slot. S0 is 0x04 and the body looks like this:

BytesFieldNotes
0-4Channel mask40 bits, channel c is bit c + 3 (bits 0-2 are always 0)
5Raw hop index0-36
6-7Sync intervalu16, in slots
8-13System timeu48, microseconds: the host’s time at the start of this slot
14-PayloadUp to 56 bytes

I like this part of the design. The 14-byte header has everything a receiver needs to join the link, which is the channels in use, the position in the hop sequence and the current time. So a controller that lost track, rebooted or is connecting for the first time can get in sync from one beacon. It doesn’t need any history or handshake for that.

Beacons are not encrypted. The payload is exactly one of:

PayloadBytesMeaning
Idle12 zero bytesNothing to say
Accept01 00 02 + device ID (8) + endpoint (1)“Controller with this ID, you’re on endpoint n”
Commandendpoint mask, ack mask, cmd, TL control, dataA command for the controller
Ack00 + ack mask + 10 zero bytesAcknowledge a reply without a new command

One gotcha: the payload must never be empty. The controller reads the payload area as a possible “accept”, and if the payload is short it reads leftover bytes from its buffer. That’s why the idle payload is 12 zeros, the same length as a full accept.

Frequency Hopping

The link uses 37 logical channels on a 2 MHz raster from 2404 to 2478 MHz. It skips 2426 MHz, the pairing channel, so link traffic never lands on top of a pairing in progress:

1
2
RF (MHz) = 2404 + 2·c        for c = 0 … 10
RF (MHz) = 2406 + 2·c        for c = 11 … 36

The hop sequence is computed in two stages.

Stage 1: advance the raw index

1
2
seed s = (A₀ mod 11) + 5          # A₀ = first byte of the link address, so s is 5..15
r ← (r + s · Δ) mod 37            # Δ = slots since the last hop, normally 1

37 is prime, and the step s is between 5 and 15, so the step is always coprime with 37. Because of that, every run of 37 consecutive slots visits every raw index exactly once (with all channels allowed, every channel once). The traffic is spread evenly over the band, and the only state that changes is a single raw index.

The Δ makes missed slots cheap too. If the controller missed three beacons, it doesn’t have to “replay” the hops, it just multiplies and jumps straight to the right channel.

Stage 2: map onto allowed channels

The host can exclude bad channels (WiFi, for example) with the channel mask. The allowed channels form a “good list” G:

1
2
channel = r                      if channel r is allowed
channel = G[r mod |G|]           otherwise

Important detail: remapping never touches r. The raw index always follows stage 1 alone. A mask change only changes which RF channel is used, and the position in the sequence stays where it was, so both ends stay aligned through a mask change.

A worked example

Link address 3d… gives the seed (0x3d mod 11) + 5 = 11:

SlotRawAll channels allowedChannels 10-19 excluded (|G| = 27)
01111 → 2428 MHz11 excluded → G[11] = 21 → 2448 MHz
12222 → 2450 MHz22 → 2450 MHz
23333 → 2472 MHz33 → 2472 MHz
377 → 2418 MHz7 → 2418 MHz
41818 → 2442 MHz18 excluded → G[18] = 28 → 2462 MHz
52929 → 2464 MHz29 → 2464 MHz

If your implementation reproduces this table, both stages are right, so it works well as a conformance test.

Mask rules

The host can’t announce just any mask:

  • only bits 0-36 can be set;
  • at least 8 channels must be allowed;
  • at least one of the seek channels must be allowed (more on those below).

A controller ignores a mask that breaks one of the first two rules and keeps its old one (the seek-channel rule is the host’s job). A mask change takes effect on the same slot at both ends. The beacon that announces it is still sent on the channel chosen by the old mask, because the controller has to tune before it can read it. The new mask applies from the next slot.

Joining: the seek channels

A controller that isn’t synced yet doesn’t know where in the sequence the host is, so it needs some fixed place to look. For that there are three special seek channels: 0, 17 and 36 (2404, 2440 and 2478 MHz), so the low, middle and high end of the band. It reminds me of the three advertising channels in BLE.

While it’s not synced, the controller listens on one seek channel at a time for about 75 ms, then moves to the next (0 → 17 → 36 → 0 …). A full 37-slot cycle of the host takes 74 ms and visits every allowed channel once, so one dwell on an allowed seek channel is enough to hear a beacon there. The first beacon it hears gives it the raw index and the mask, and from then on it hops in step with the host.

stateDiagram-v2
    [*] --> Joining
    Joining --> Joining: dwell ends / next seek channel
    Joining --> Tracking: beacon / apply mask, latch raw index
    Tracking --> Tracking: beacon / apply mask, re-latch
    Tracking --> Tracking: window missed / hop by Δ
    Tracking --> Joining: link lost / reset to seed

Hearing beacons isn’t enough, the controller also needs an endpoint. A controller that isn’t attached answers every beacon it hears with an attach request in the seek slot (350 µs, prefix 0x01):

BytesFieldNotes
0-1HeaderFixed 00 01
2-9Device ID8 bytes
10-13Controller typeu32

The controller type carries the hand in byte 2 (1 left, 2 right). The host replies with an accept in a beacon payload, and after that the controller answers in its endpoint slot.

sequenceDiagram
    participant H as Host
    participant C as Controller
    H->>C: beacon (idle)
    C->>H: attach request (seek slot)
    H->>C: beacon (accept: device ID, endpoint n)
    C->>H: answer (endpoint n slot)
    Note over H,C: attached: the controller answers in its slot every 2 ms

On the host side, each endpoint has a tiny state machine:

stateDiagram-v2
    [*] --> Seeking
    Seeking --> Accepting: attach request
    Accepting --> Connected: answer on the endpoint
    Accepting --> Seeking: 8 slots without one
    Connected --> Seeking: 32 slots without an answer

A few rules matter here:

  • One accept per attach request. An attached controller reads beacon payloads as commands, so a repeated accept could be misread as garbage. If the controller missed the accept, it simply sends another request and gets a new one.
  • While accepting or connected, the host listens on both the seek and the endpoint prefix. A controller that missed a few beacons keeps answering on its endpoint, while one that really lost the link goes back to the seek slot. The host can’t know in advance which case it is.
  • The host waits longer than the controller. The controller declares the link lost after more than 24 slots (~50 ms) without a beacon, and the host only drops it after 32 slots without an answer. This way a controller that was briefly out of range isn’t accepted twice, and short dropouts recover on their own.

Encrypted Answers

The link key from pairing is used for this part. Every answer from the controller is encrypted and authenticated with AES-128-CCM:

ElementValue
CipherAES-128-CCM, 4-byte MIC, 2-byte length field, 13-byte nonce
KeyThe link key from pairing
Nonce5 zero bytes + IV (8 bytes)
IVLE48(beacon system time + n · 2000) + the beacon’s sync interval (2 bytes)
Associated dataOne byte: S0 & 0xE3

Here n is the number of slots the controller has advanced since that beacon (normally 0), it’s not the endpoint number. The nonce is built from the system time of the beacon being answered, so it changes every slot and an answer replayed in another slot fails to authenticate. So time is also part of the link’s security.

It’s standard CCM, so any AES-CCM implementation can check it. It matches the nRF CCM peripheral in BLE mode with a zero packet counter, which is probably what the controller uses. On the host side there is one complication: the host has to figure out which beacon an answer belongs to. I try three candidates, and the first one that authenticates wins:

  1. the latest beacon (the normal case);
  2. the previous beacon (the answer was matched after the next beacon went out);
  3. one slot after the latest (the controller missed a beacon and counted forward).

Decrypted, an answer is one of:

KindPlaintextHow to recognize it
Attach request00 01 + device ID + typeSeek slot
Notifications7-byte header + recordsEndpoint slot, bit 6 of byte 2 set
Command reply[endpoint][cmd][TL status][data…]Endpoint slot, bit 6 of byte 2 clear

Notifications carry buttons, sticks, triggers, capacitive touch, battery and the IMU stream. That’s a big topic by itself, so I’ll cover it in post #3.

Sending Commands

Once a controller is attached, the host can send it commands in the beacon payload. Each command is a single byte, handled by one of two dispatchers on the controller: write (accept/reject) or read (returns up to 32 bytes).

Command Request and Reply Format

There’s no length byte. Data runs to the end of the payload, so a request carries at most 52 bytes. Delivery has its own small set of rules:

RuleWhoValue
Duplicate suppressionControllerSame sequence number + command + direction = not executed again
One command in flightHostThe next one waits
ReadsHostRepeat in every beacon until the reply arrives
WritesHostSend once, resend once after 50 ms if nothing came back
Reply timeoutHost2 s (a controller in its slow, idle state takes a while)

Through this channel you can get things like the serial number, firmware versions, battery status, IMU calibration and the IR LED timing (more on that in post #3).

Commands you really don’t want to send by accident

Some commands do things the link can’t undo:

CommandEffect
0x13Unpairs the controller: its link material is erased
0x15Restarts the controller
0x16Restarts it in its maintenance mode

Also, some write handlers read a fixed-length payload no matter what you sent, so with a short payload the handler reads leftover buffer bytes. 0x0F (expects no data) and 0x28 (expects exactly 12 bytes) work like that. My dongle refuses the dangerous ones and only sends the guarded ones with exactly the right length. I don’t want to lose a pairing because of a typo in a script.

Some Thoughts on the Design

After spending a lot of time with this protocol, I started to like how it’s designed. A few things stand out:

  • A frame is either correct when it’s sent, or it’s not sent at all. A late beacon or a late answer is skipped, never sent in a degraded form.
  • Every beacon is a complete rejoin point. Mask, hop position and time are in every one, so nobody needs history.
  • Recovery is built in everywhere. Missed slots, lost accepts, brief dropouts and channel changes all recover on their own.

Conclusion

So that’s the APP link. A 2 ms slot grid, a hop sequence built on a prime number, rejoin from one beacon, and AES-CCM with a time-based nonce. To me it looks more like a stripped-down, latency-focused cousin of BLE than something “proprietary and weird”.

With this, my dongle can act as the headset. It pairs the controller, hosts the link, decrypts everything and forwards it to the PC. Next week I’ll look at the part that was by far the hardest to get right, the timing. The controller has as little as 350 µs (the seek slot) to hear a beacon, build an answer, encrypt it and get it on air, and on a small microcontroller that turned out to be a lot harder than it sounds.

Anyway, this was a fun rabbit hole to go down.


Independent research on devices I own, for security research and interoperability. Not affiliated with or endorsed by Meta/Oculus. No vendor firmware, keys or code are published here. See the Disclaimer.

This post is licensed under CC BY 4.0 by the author.