1use tokio::sync::mpsc::error::SendError;
2
3use thiserror::Error;
4use uuid::Uuid;
5
6#[derive(Debug, Error)]
7pub enum BleError {
8 #[error("Btleplug error: {0}")]
9 Btleplug(#[from] btleplug::Error),
10
11 #[error("JNI {0}")]
12 Jni(#[from] jni::errors::Error),
13
14 #[error("Call init() first.")]
15 RuntimeNotInitialized,
16
17 #[allow(dead_code)]
18 #[error("Cannot initialize CLASS_LOADER")]
19 ClassLoader,
20
21 #[allow(dead_code)]
22 #[error("Cannot initialize RUNTIME")]
23 Runtime,
24
25 #[allow(dead_code)]
26 #[error("Java vm not initialized")]
27 JavaVM,
28
29 #[error("There is no peripheral with id: {0}")]
30 UnknownPeripheral(String),
31
32 #[error("Characteristic with uuid {0:?} not found")]
33 CharacNotFound(Uuid),
34
35 #[error("Characteristic {0} not available")]
36 CharacNotAvailable(String),
37
38 #[error("No device connected")]
39 NoDeviceConnected,
40
41 #[error("Service not found")]
42 ServiceNotFound,
43
44 #[error("Device is already connected.")]
45 AlreadyConnected,
46
47 #[error("Handler not initialized")]
48 HandlerNotInitialized,
49
50 #[error("Handler already initialized")]
51 HandlerAlreadyInitialized,
52
53 #[error("received wrong data")]
54 WrongData,
55
56 #[error("could not send devices: {0}")]
57 SendingDevices(SendError<Vec<crate::BleDevice>>),
58
59 #[error("could not join fuure: {0}")]
60 JoinError(tokio::task::JoinError),
61
62 #[error("no bluetooth adapters found")]
63 NoAdapters,
64}