trouble-host

Crates

git

Versions

default

Flavors

Attribute Macro gatt_service

Source
#[gatt_service]
Expand description

Gatt Service attribute macro.

ยงExample

use trouble_host::prelude::*;

const DESCRIPTOR_VALUE: &str = "Can be specified from a const";

#[gatt_service(uuid = "7e701cf1-b1df-42a1-bb5f-6a1028c793b0")]
struct HeartRateService {
   /// Docstrings can be
   /// Multiple lines
   #[descriptor(uuid = "2a21", read, value = [0x00,0x01,0x02,0x03])]
   #[characteristic(uuid = characteristic::HEART_RATE_MEASUREMENT, read, notify, value = 3.14)]
   rate: f32,
   #[descriptor(uuid = descriptors::MEASUREMENT_DESCRIPTION, read, value = DESCRIPTOR_VALUE)]
   #[characteristic(uuid = "2a28", read, write, notify, value = 42.0)]
   /// Can be in any order
   location: f32,
   #[characteristic(uuid = "2a39", write)]
   control: u8,
   #[characteristic(uuid = "2a63", read, notify)]
   energy_expended: u16,
}