AirPlay.V2.Ptp (AirPlay v0.2.0)

Copy Markdown View Source

Minimal IEEE-1588v2 (PTP) grandmaster for AirPlay 2 — the timing gate for HomePods. HomePods negotiate timingProtocol:"PTP" and schedule playback against a PTP network clock; we advertise ourselves as the grandmaster so the receiver slaves to our clock, then SETRATEANCHORTIME references a real time on this clock.

Runs on PTP multicast 224.0.1.129: general msgs (Announce, Follow_Up, Delay_Resp) on udp/320, event msgs (Sync) on udp/319; answers the receiver's Delay_Req. clock_identity/0 (8 bytes) ↔ timeline_id/0 (its u64) is what goes in the anchor's networkTimeTimelineID. now/0 returns {secs, nanos} on our clock; anchor_time/1 gives {secs, frac64} for the anchor a bit in the future.

Summary

Functions

Anchor time offset_ms in the future as {secs, frac64} (frac = fraction*2^64).

Returns a specification to start this module under a supervisor.

Current PTP clock as {seconds, nanoseconds}.

Start the grandmaster (idempotent-ish; one per node).

Functions

anchor_time(offset_ms \\ 2000)

Anchor time offset_ms in the future as {secs, frac64} (frac = fraction*2^64).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clock_identity()

now()

Current PTP clock as {seconds, nanoseconds}.

start_link(opts \\ [])

Start the grandmaster (idempotent-ish; one per node).

stop()

timeline_id()