1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! # brainbit
//!
//! Rust library for **BrainBit** EEG headband devices via the
//! [NeuroSDK2](https://sdk.brainbit.com/) C library, loaded at runtime.
//!
//! Supports **BrainBit** (original 4-channel), **BrainBit 2**,
//! **BrainBit Pro**, **BrainBit Flex 4/8**, and related devices from
//! [BrainBit LLC](https://brainbit.com/).
//!
//! ## Cross-platform
//!
//! Works on **Windows**, **Linux**, and **macOS**. The `neurosdk2` shared
//! library (`neurosdk2.dll` / `libneurosdk2.so` / `libneurosdk2.dylib`) is
//! loaded at runtime via `libloading` — no build-time C dependencies.
//!
//! Download the native library for your platform:
//! - **Windows**: <https://github.com/BrainbitLLC/neurosdk2-cpp>
//! - **Linux**: <https://github.com/BrainbitLLC/linux_neurosdk2>
//! - **macOS**: <https://github.com/BrainbitLLC/apple_neurosdk2>
//!
//! ## Quick start
//!
//! ```rust,ignore
//! use brainbit::prelude::*;
//! use std::time::Duration;
//!
//! // 1. Scan for devices
//! let scanner = Scanner::new(&[SensorFamily::LEBrainBit])?;
//! scanner.start()?;
//! std::thread::sleep(Duration::from_secs(5));
//! scanner.stop()?;
//!
//! let devices = scanner.devices()?;
//! if devices.is_empty() {
//! eprintln!("No BrainBit device found!");
//! return Ok(());
//! }
//!
//! // 2. Connect
//! let mut device = BrainBitDevice::connect(&scanner, &devices[0])?;
//! println!("Connected to: {}", device.name()?);
//! println!("Battery: {}%", device.battery_level()?);
//! println!("Firmware: {:?}", device.firmware_version()?);
//!
//! // 3. Stream EEG for 4 seconds
//! let samples = device.capture_signal(BRAINBIT_SAMPLING_RATE as usize * 4)?;
//! for s in &samples[..5] {
//! println!("#{}: O1={:.6}V O2={:.6}V T3={:.6}V T4={:.6}V",
//! s.pack_num, s.channels[0], s.channels[1], s.channels[2], s.channels[3]);
//! }
//! ```
//!
//! ## Module overview
//!
//! | Module | Purpose |
//! |---|---|
//! | [`prelude`] | One-line glob import of the most commonly needed types |
//! | [`ffi`] | Cross-platform FFI bindings for NeuroSDK2 (runtime-loaded) |
//! | [`types`] | C-compatible FFI types, enums, and structures |
//! | [`scanner`] | BLE device scanner |
//! | [`device`] | High-level device API: signal streaming, resistance, battery |
//! | [`error`] | Error types |
/// Convenience re-exports for downstream crates.
///
/// ```rust,ignore
/// use brainbit::prelude::*;
///
/// let scanner = Scanner::new(&[SensorFamily::LEBrainBit])?;
/// ```