-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
144 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub(crate) mod control; | ||
pub mod device; | ||
pub mod errors; | ||
pub(crate) mod internals; | ||
pub mod resist; | ||
pub mod responses; | ||
pub(crate) mod sealed; | ||
pub mod traits; | ||
pub mod uuids; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use thiserror::Error; | ||
|
||
/// Error type for general brainbit errors and internal btleplug Ble errors | ||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
/// Bluetooth adapter is not found on attempt to scan it | ||
#[error("No BLE adaptor")] | ||
NoBleAdaptor, | ||
/// Could not connect to a device by filter | ||
#[error("No BLE device")] | ||
NoDevice, | ||
/// Device looks as it's not connected, but command was called | ||
#[error("Not connected")] | ||
NotConnected, | ||
/// UUID device's characteristic is missing | ||
#[error("Characteristic not found")] | ||
CharacteristicNotFound, | ||
/// EEG Data packets received from device is not parsed | ||
#[error("Invalid '{0}'")] | ||
InvalidData(String), | ||
/// The command did not return a response | ||
#[error("No command response")] | ||
NoControlPointResponse, | ||
/// An error occurred in the underlying BLE library. | ||
#[error("BLE error: {0}")] | ||
BleError(#[from] btleplug::Error), | ||
#[error("Error generated by event handler")] | ||
HandlerError(#[from] Box<dyn std::error::Error + Sync + Send>), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::bbit::device::CommandData; | ||
use crate::bbit::responses::DeviceStatusData; | ||
use async_trait::async_trait; | ||
|
||
/// Base trait for handling events coming from a BrainBit device. | ||
#[async_trait] | ||
pub trait EventHandler { | ||
/// Dispatched when a internal device status update is received. | ||
/// | ||
/// Contains the status, cmd error, battery level. | ||
async fn device_status_update(&self, _status: DeviceStatusData) {} | ||
|
||
/// Dispatched when an eeg data is received. | ||
/// | ||
/// Contains information about the O1, O2, T3, T4 + interval. | ||
async fn eeg_update(&mut self, _eeg_data: Vec<u8>) {} | ||
|
||
/// Dispatched when measurement data is received over the PMD data UUID. | ||
/// | ||
/// Contains data in a [`CommandData`]. | ||
async fn send_command(&self, _command_data: CommandData) {} | ||
|
||
/// Checked at start of each event loop. | ||
/// | ||
/// Returns [`false`] if the event loop should be terminated and close connection. | ||
async fn should_continue(&self) -> bool { | ||
true | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.