rainmaker_components/ble/
base.rs

1pub use uuid::Uuid;
2
3pub trait GattReadFn = Fn() -> Vec<u8> + Send + Sync + 'static;
4pub trait GattWriteFn = Fn(Vec<u8>) + Send + Sync + 'static;
5
6#[derive(Default)]
7pub struct Descriptor {
8    pub uuid: Uuid,
9    pub value: Vec<u8>,
10}
11
12#[derive(Default)]
13pub struct Characteristic {
14    pub uuid: Uuid,
15    pub read: Option<Box<dyn GattReadFn>>,
16    pub write: Option<Box<dyn GattWriteFn>>,
17    pub descriptors: Vec<Descriptor>,
18}
19
20pub struct Service {
21    pub uuid: Uuid,
22    pub primary: bool,
23    pub characteristics: Vec<Characteristic>,
24}
25
26pub struct GattApplication {
27    pub services: Vec<Service>,
28}
29
30#[derive(Debug, Default)]
31pub struct Advertisement {
32    pub device_name: Option<String>,
33    pub discoverable: bool,
34    pub primary_service: Uuid,
35    pub service_uuids: Vec<Uuid>,
36}
37
38pub struct AdvertisementHandleGeneric<T>(pub(crate) T);
39pub struct ApplicationHandleGeneric<T>(pub(crate) T);