Skip to main content

rodecaster_protocol/names/
system.rs

1//! [`SystemParam`]: the singleton root `SYSTEM`-node device-state family.
2
3// The forty-nine properties a real Pro II / Duo fullSync carries on the single
4// root-level SYSTEM node (confirmed from capture, firmware 1.7.3). SYSTEM is the
5// device-wide state singleton: identity (serial, firmware, board type), the
6// firmware/app update + download lifecycle, the date/time + personalization
7// settings, the global output disables, and USB / storage / sharing status. None
8// of it is per-strip audio routing.
9//
10// Note the `system` prefix is NOT uniform: the identity/date/personalization
11// props carry it (`systemFirmwareVersion`, `systemDateTimezone`, ...), but the
12// update lifecycle, the disables, and the USB/storage status props do not
13// (`updateChecking`, `disableAllLineoutOutputs`, `usbHostOnUsb2`, ...). The
14// variant names strip the `system` prefix where present and otherwise PascalCase
15// the wire name verbatim, so each `=> "wireName"` is the exact firmware string.
16wire_param_enum! {
17    /// A device-wide system parameter: one of the flat properties the device
18    /// carries on the single root `SYSTEM` node. This is global device state, not
19    /// per-strip audio routing: identity (serial / firmware / board type), the
20    /// firmware-update + download lifecycle, date/time + personalization
21    /// settings, the global output disables, and USB / storage / sharing status.
22    ///
23    /// Two things worth calling out:
24    /// - [`SystemParam::PowerOffRequest`] (`powerOffRequest`) is the *readback /
25    ///   generic-write* identity of the power-off flag. It is distinct from
26    ///   [`crate::Command::PowerOff`], which is a dedicated, layout-independent
27    ///   power-off frame pinned to a fixed node index. Writing this param via
28    ///   [`crate::Command::SetSystemParam`] instead addresses the discovered
29    ///   `SYSTEM` node; on firmware 1.7.3 that resolves to the same node, so the
30    ///   two are equivalent there.
31    /// - Several wire names carry firmware casing/spelling quirks kept verbatim:
32    ///   `updateViaUSB`, `lastRecordingID`, `updateResetAfterFWURequested`, and
33    ///   the misspelled `usbHostUnspportedFirmware`.
34    SystemParam {
35    // Identity / selection / engine.
36    MidiControl => "systemMidiControl",
37    ChannelSelected => "systemChannelSelected",
38    MixSelected => "systemMixSelected",
39    FirmwareVersion => "systemFirmwareVersion",
40    EngineMode => "engineMode",
41    SerialNumber => "systemSerialNumber",
42    BoardType => "boardType",
43    // Date / time + clock display.
44    DateTimezone => "systemDateTimezone",
45    DateTimeDaylightSavings => "systemDateTimeDaylightSavings",
46    DateTimeOnHome => "systemDateTimeOnHome",
47    DateTime24h => "systemDateTime24h",
48    // Device behaviour / personalization.
49    BetaMode => "systemBetaMode",
50    HapticSetting => "systemHapticSetting",
51    RecButtonSetting => "systemRecButtonSetting",
52    UnifyMode => "unifyMode",
53    PresenterMode => "presenterMode",
54    PresenterSoftware => "presenterSoftware",
55    AssignableMeterSource => "assignableMeterSource",
56    LastRecordingId => "lastRecordingID",
57    TransferModeType => "transferModeType",
58    // Firmware / app update lifecycle (status flags).
59    AppUpdateAvailable => "appUpdateAvailable",
60    OsUpdateAvailable => "osUpdateAvailable",
61    UpdateDownloaded => "updateDownloaded",
62    UpdateChecking => "updateChecking",
63    UpdateNoInternet => "updateNoInternet",
64    UpdateComplete => "updateComplete",
65    UpdateDownloadProgress => "updateDownloadProgress",
66    UpdateInstalledProgress => "updateInstalledProgress",
67    UpdateVersion => "updateVersion",
68    UpdateViaUsb => "updateViaUSB",
69    // Update / download command channel (request flags).
70    UpdateCheckRequested => "updateCheckRequested",
71    UpdateInitiateRequested => "updateInitiateRequested",
72    DownloadInitiateRequested => "downloadInitiateRequested",
73    DownloadCancelRequested => "downloadCancelRequested",
74    UpdateRebootRequested => "updateRebootRequested",
75    UpdateResetDeviceRequested => "updateResetDeviceRequested",
76    UpdateResetAppRequested => "updateResetAppRequested",
77    UpdateResetAfterFwuRequested => "updateResetAfterFWURequested",
78    // Power.
79    PowerOffRequest => "powerOffRequest",
80    // Global output disables.
81    DisableAllHeadphoneOutputs => "disableAllHeadphoneOutputs",
82    DisableAllLineoutOutputs => "disableAllLineoutOutputs",
83    DisableAllPhysicalButtons => "disableAllPhysicalButtons",
84    // USB / storage / hardware status.
85    Usb1Connected => "usb1Connected",
86    UsbHostOnUsb2 => "usbHostOnUsb2",
87    UsbHostUnsupportedFirmware => "usbHostUnspportedFirmware",
88    RemountPadStorage => "remountPadStorage",
89    BadPadDetected => "badPadDetected",
90    // Sharing / analytics.
91    ShareAnom => "shareAnom",
92    ShareResource => "shareResource",
93    }
94}
95
96#[cfg(test)]
97mod tests {
98    use super::*;
99
100    #[test]
101    fn system_param_round_trips_and_exact_wire_names() {
102        for p in [
103            SystemParam::MidiControl,
104            SystemParam::FirmwareVersion,
105            SystemParam::BoardType,
106            SystemParam::EngineMode,
107            SystemParam::DateTimezone,
108            SystemParam::BetaMode,
109            SystemParam::PowerOffRequest,
110            SystemParam::DisableAllLineoutOutputs,
111            SystemParam::UsbHostOnUsb2,
112            SystemParam::ShareAnom,
113        ] {
114            assert_eq!(SystemParam::from_name(p.as_str()), p);
115            assert!(p.is_known());
116            assert_eq!(p.to_string(), p.as_str());
117        }
118        // The `system`-prefixed identity/date props strip the prefix.
119        assert_eq!(SystemParam::SerialNumber.as_str(), "systemSerialNumber");
120        assert_eq!(
121            SystemParam::ChannelSelected.as_str(),
122            "systemChannelSelected"
123        );
124        assert_eq!(SystemParam::DateTime24h.as_str(), "systemDateTime24h");
125        // Firmware casing/spelling quirks must survive verbatim.
126        assert_eq!(SystemParam::UpdateViaUsb.as_str(), "updateViaUSB");
127        assert_eq!(SystemParam::LastRecordingId.as_str(), "lastRecordingID");
128        assert_eq!(
129            SystemParam::UpdateResetAfterFwuRequested.as_str(),
130            "updateResetAfterFWURequested"
131        );
132        assert_eq!(
133            SystemParam::UsbHostUnsupportedFirmware.as_str(),
134            "usbHostUnspportedFirmware"
135        );
136    }
137
138    #[test]
139    fn system_param_unknown_falls_back_to_other() {
140        let p = SystemParam::from_name("mysterySystemFlag");
141        assert_eq!(p, SystemParam::Other("mysterySystemFlag".to_string()));
142        assert!(!p.is_known());
143        assert_eq!(SystemParam::from_name(p.as_str()), p);
144    }
145}