prolink-proto 0.5.0

Wire codecs for the Pioneer Pro DJ Link protocol: discovery, status, dbserver and ONC RPC/NFSv2
Documentation
// SPDX-License-Identifier: GPL-3.0-only

//! Captured packets used as the skeleton for the ones we emit.
//!
//! # Why a template and not a constructor
//!
//! A CDJ status packet is 284 bytes of which about a dozen can be named and
//! roughly 260 cannot. Across 749 consecutive packets from an idle
//! CDJ-2000nexus only **six** bytes ever changed: the USB slot state, the
//! link-available flag, two still-unidentified bytes at `0x6a` and `0x74`, and
//! the packet counter (F23).
//!
//! Building one field by field would therefore mean inventing values for 260
//! bytes we do not understand, and sending a plausible zero has broken playback
//! twice (F33, F35). Starting from a real packet and substituting only the
//! fields we understand is the difference between plausible and
//! indistinguishable.
//!
//! Both templates were captured from the author's own hardware — a CDJ-2000NXS
//! on firmware 1.44 — with the identifying and per-medium fields zeroed, so
//! nothing about the source deck is baked in.

/// A type-`0x0a` CDJ status packet, 284 bytes.
///
/// The device name, device number, media states, link flag, play state,
/// firmware string and packet counter are zeroed here and substituted by
/// [`super::CdjStatusBuilder`]. Everything else is reproduced exactly.
pub(crate) const CDJ_STATUS: [u8; 284] = [
    /* 0x0000 */ 0x51, 0x73, 0x70, 0x74, 0x31, 0x57, 0x6d, 0x4a, 0x4f, 0x4c, 0x0a, 0x00,
    /* 0x000c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0018 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0xf8,
    /* 0x0024 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0030 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x003c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0048 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0054 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x04,
    /* 0x006c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
    /* 0x0078 */ 0x00, 0x00, 0x00, 0x00, 0x31, 0x2e, 0x34, 0x34, 0x00, 0x00, 0x00, 0x00,
    /* 0x0084 */ 0x00, 0x00, 0x00, 0x03, 0x00, 0x84, 0xff, 0xfe, 0x00, 0x0f, 0x83, 0x12,
    /* 0x0090 */ 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
    /* 0x009c */ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x04, 0x01, 0xff, 0x00, 0x00,
    /* 0x00a8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00b4 */ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00c0 */ 0x00, 0x0f, 0x83, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00cc */ 0x0f, 0x01, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x01,
    /* 0x00d8 */ 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00e4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00f0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00fc */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0108 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15,
    /* 0x0114 */ 0x00, 0x00, 0x07, 0x53, 0x00, 0x00, 0x05, 0xb4,
];

/// A type-`0x06` media response, 192 bytes.
///
/// The device number, slot, volume name, the track and playlist counts and the
/// two eight-byte sizes are zeroed here and substituted by
/// [`super::MediaResponseBuilder`].
pub(crate) const MEDIA_RESPONSE: [u8; 192] = [
    /* 0x0000 */ 0x51, 0x73, 0x70, 0x74, 0x31, 0x57, 0x6d, 0x4a, 0x4f, 0x4c, 0x06, 0x00,
    /* 0x000c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0018 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x9c,
    /* 0x0024 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0030 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x003c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0048 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0054 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x006c */ 0x00, 0x32, 0x00, 0x30, 0x00, 0x32, 0x00, 0x35, 0x00, 0x2d, 0x00, 0x30,
    /* 0x0078 */ 0x00, 0x36, 0x00, 0x2d, 0x00, 0x32, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00,
    /* 0x0084 */ 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
    /* 0x0090 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x009c */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00a8 */ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    /* 0x00b4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];