pub mod csi_receiver;
mod hardware_adapter;
mod neural_adapter;
mod signal_adapter;
pub use hardware_adapter::{
AntennaConfig,
AtherosDriver,
Bandwidth,
ChannelConfig,
CsiMetadata,
CsiReadings,
CsiStream,
DeviceSettings,
DeviceType,
FlowControl,
FrameControlType,
HardwareAdapter,
HardwareConfig,
HardwareHealth,
HealthStatus,
NetworkInterfaceSettings,
Parity,
PcapSettings,
SensorCsiReading,
SensorInfo,
SensorStatus,
SerialSettings,
StreamingStats,
UdpSettings,
};
pub use neural_adapter::NeuralAdapter;
pub use signal_adapter::SignalAdapter;
pub use csi_receiver::{
CsiPacket,
CsiPacketFormat,
CsiPacketMetadata,
CsiParser,
CsiSource,
PcapCsiReader,
PcapSourceConfig,
ReceiverConfig,
ReceiverStats,
SerialCsiReceiver,
SerialParity,
SerialSourceConfig,
UdpCsiReceiver,
UdpSourceConfig,
};
#[derive(Debug, Clone, Default)]
pub struct IntegrationConfig {
pub use_gpu: bool,
pub batch_size: usize,
pub optimize_signal: bool,
pub hardware: Option<HardwareConfig>,
}
impl IntegrationConfig {
pub fn realtime() -> Self {
Self {
use_gpu: true,
batch_size: 1,
optimize_signal: true,
hardware: None,
}
}
pub fn batch(batch_size: usize) -> Self {
Self {
use_gpu: true,
batch_size,
optimize_signal: true,
hardware: None,
}
}
pub fn with_hardware(hardware: HardwareConfig) -> Self {
Self {
use_gpu: true,
batch_size: 1,
optimize_signal: true,
hardware: Some(hardware),
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum AdapterError {
#[error("Signal adapter error: {0}")]
Signal(String),
#[error("Neural adapter error: {0}")]
Neural(String),
#[error("Hardware adapter error: {0}")]
Hardware(String),
#[error("Hardware unavailable: {0}")]
HardwareUnavailable(String),
#[error("Unsupported adapter: {0}")]
UnsupportedAdapter(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Data format error: {0}")]
DataFormat(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Timeout error: {0}")]
Timeout(String),
}
pub mod prelude {
pub use super::{
AdapterError, AtherosDriver, Bandwidth, CsiPacket, CsiPacketFormat, CsiReadings,
DeviceType, HardwareAdapter, HardwareConfig, IntegrationConfig,
};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_integration_config_defaults() {
let config = IntegrationConfig::default();
assert!(!config.use_gpu);
assert_eq!(config.batch_size, 0);
assert!(!config.optimize_signal);
assert!(config.hardware.is_none());
}
#[test]
fn test_integration_config_realtime() {
let config = IntegrationConfig::realtime();
assert!(config.use_gpu);
assert_eq!(config.batch_size, 1);
assert!(config.optimize_signal);
}
#[test]
fn test_integration_config_batch() {
let config = IntegrationConfig::batch(32);
assert!(config.use_gpu);
assert_eq!(config.batch_size, 32);
}
#[test]
fn test_integration_config_with_hardware() {
let hw_config = HardwareConfig::esp32("/dev/ttyUSB0", 921600);
let config = IntegrationConfig::with_hardware(hw_config);
assert!(config.hardware.is_some());
assert!(matches!(
config.hardware.as_ref().unwrap().device_type,
DeviceType::Esp32
));
}
}