use std::fmt::Display;
use std::time::Duration;

#[derive(Debug)]
pub struct DeviceInfo {
  /// Vendor ID
  pub vid: u16,
  /// Product ID
  pub pid: u16,
}

impl Display for DeviceInfo {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    write!(f, "VID: 0x{:04X} PID: 0x{:04X}", self.vid, self.pid)
  }
}

// Devices
pub const DEVICE_RTL2832U: DeviceInfo = DeviceInfo {
  vid: 0x0BDA,
  pid: 0x2832,
};

// Timeout
pub const TIMEOUT: Duration = Duration::from_secs(1);

// pub const DEFAULT_BUFFER_LENGTH: usize = 4096;
pub const DEFAULT_BUFFER_LENGTH: usize = 64;

// Request Types
pub const REQ_CTRL_OUT: u8 =
  rusb::constants::LIBUSB_ENDPOINT_OUT | rusb::constants::LIBUSB_REQUEST_TYPE_VENDOR;

// Blocks
pub const BLOCK_USB: u16 = 1;

// USB
pub const USB_EPA_CTL: u16 = 0x2148;
pub const USB_SYSCTL: u16 = 0x2000;

/// ADS-B downlink frequency (1090 MHz)
pub const ADSB_FREQUENCY_HZ: u32 = 1_090_000_000;

/// RTL-SDR sample rate in samples/second.
pub const SAMPLE_RATE_HZ: u32 = 2_048_000;
