embassy-rs / nrf-softdevice

Apache License 2.0
254 stars 74 forks source link

Add descriptor and attribute value to `gatt_service` proc macro #239

Closed HaoboGu closed 4 months ago

HaoboGu commented 4 months ago

Descriptor and attribute value settings are commonly used in BLE characteristic, with this PR, they can be specified as:

#[nrf_softdevice::gatt_service(uuid = "1812")]
pub struct HidService {
    #[characteristic(
        uuid = "2A4D",
        read,
        write,
        value = "[0u8, 1u8]",
        descriptor(uuid = "2908", security = "justworks", value = "[0, 1]")
    )]
    pub data: [u8; 1],
alexmoon commented 4 months ago

Can you add an example to the examples project demonstrating how this is used?

HaoboGu commented 4 months ago

Sure, will do!

alexmoon commented 4 months ago

Is it possible to allow multiple descriptors per characteristic by repeating the descriptor(...) argument?

HaoboGu commented 4 months ago

It might be possible, I'm not sure.. will have a try tomorrow!

HaoboGu commented 4 months ago

Multiple descriptor fields is supported. Just tested it, works fine.