ble_peripheral_rust/gatt/
peripheral_event.rs

1use tokio::sync::oneshot;
2use uuid::Uuid;
3
4#[derive(Debug)]
5pub enum PeripheralEvent {
6    StateUpdate {
7        is_powered: bool,
8    },
9    CharacteristicSubscriptionUpdate {
10        request: PeripheralRequest,
11        subscribed: bool,
12    },
13    ReadRequest {
14        request: PeripheralRequest,
15        offset: u64,
16        responder: oneshot::Sender<ReadRequestResponse>,
17    },
18    WriteRequest {
19        request: PeripheralRequest,
20        value: Vec<u8>,
21        offset: u64,
22        responder: oneshot::Sender<WriteRequestResponse>,
23    },
24}
25
26#[derive(Debug, Clone)]
27pub struct PeripheralRequest {
28    pub client: String,
29    pub service: Uuid,
30    pub characteristic: Uuid,
31}
32
33#[derive(Debug)]
34pub struct ReadRequestResponse {
35    pub value: Vec<u8>,
36    pub response: RequestResponse,
37}
38
39#[derive(Debug)]
40pub struct WriteRequestResponse {
41    pub response: RequestResponse,
42}
43
44#[derive(Debug, PartialEq)]
45pub enum RequestResponse {
46    Success,
47    InvalidHandle,
48    RequestNotSupported,
49    InvalidOffset,
50    UnlikelyError,
51}