Skip to main content

beyond_lib/
lib.rs

1use thiserror::Error;
2
3pub mod helpers;
4pub mod protocol;
5#[cfg(feature = "usb")]
6pub mod usb;
7
8/// The Bigscreen Beyond's various VIDs & PIDs.
9///
10/// Bigscreen uses the PID of the headset's components to denote the state of
11/// the headset.
12/// Each state may contain different subcommands that can be used.
13pub mod device_ids {
14    pub const BIGSCREEN_VID: u16 = 0x35BD;
15
16    pub const BEYOND_PID: u16 = 0x0101;
17    pub const BEYOND_PID_FIRMWARE: u16 = 0x4004;
18    pub const BEYOND_PID_ERROR: u16 = 0x1001;
19    pub const BIGEYE_PID: u16 = 0x0202;
20    pub const BIGEYE_PID_DFU: u16 = 0x0282;
21}
22
23// TODO: Move elsewhere
24#[derive(Debug, Error, Clone, PartialEq, Eq)]
25pub enum ParseError {
26    // /// First argument is the expected value, second is received value.
27    // #[error("ID of {1:02X?} was recieved, despite {0:02X?} was requested")]
28    // InvalidId(u8, u8),
29    // #[error("The size of the returned message was {0}")]
30    // InvalidSize(u8),
31    #[error("There was some sort of issue parsing the data")]
32    Parse,
33    #[error("Buffer attempted to be read, but the end of the buffer was reached")]
34    OutOfData,
35}
36
37impl From<bytes::TryGetError> for ParseError {
38    fn from(_: bytes::TryGetError) -> Self {
39        Self::OutOfData
40    }
41}