Skip to main content

GattsEvent

Enum GattsEvent 

Source
pub enum GattsEvent<'a> {
    Register(BleGattRegister),
    Read {
        conn_handle: ConnHandle,
        attr_handle: AttrHandle,
        offset: u16,
        reply: Mbuf<'a>,
    },
    Write {
        conn_handle: ConnHandle,
        attr_handle: AttrHandle,
        data: Mbuf<'a>,
    },
    SubscriptionChanged {
        conn_handle: ConnHandle,
        attr_handle: AttrHandle,
        reason: SubscribeReason,
        prev_notify: bool,
        cur_notify: bool,
        prev_indicate: bool,
        cur_indicate: bool,
    },
    NotifyComplete {
        conn_handle: ConnHandle,
        attr_handle: AttrHandle,
        indication: bool,
        status: i32,
    },
}
Expand description

A GATT-server event, delivered on the host task to the single gatts_subscribe hook.

There are no per-characteristic callbacks: NimBLE dispatches every characteristic read and write through one shared trampoline, and they arrive here as Read / Write, keyed by the globally-unique attr_handle. The Register variants fire as the service table is registered (at start). SubscriptionChanged and NotifyComplete are server-role connection events that NimBLE delivers on the GAP callback and we demux here.

The hook returns the ATT status (0 on success) for Read/Write; the return is ignored for the others.

Variants§

§

Register(BleGattRegister)

§

Read

A peer is reading one of our characteristics; append the value to reply.

This covers every ATT read (Read Request, Read Blob Request, Read By Type Request, Read Multiple Request) — NimBLE reports them all the same way — as well as local reads, which carry CONN_HANDLE_NONE instead of a real connection.

Fields

§conn_handle: ConnHandle
§attr_handle: AttrHandle
§offset: u16

Non-zero only for a long read (ATT Read Blob Request), where it is the offset the peer is asking to continue from.

Always append the whole value regardless of this field: NimBLE hands a long read a scratch buffer and slices [offset..] out of it itself. The offset is informational — use it to tell a continuation from a fresh read (e.g. to snapshot the value at offset 0 so a multi-blob read stays coherent).

Always 0 on ESP-IDF < 5.3, where NimBLE does not report the offset at all.

§reply: Mbuf<'a>
§

Write

A peer wrote one of our characteristics.

This covers every ATT write — Write Request, Write Command (write-without-response), Signed Write Command, and a completed Prepare/Execute long write (NimBLE coalesces the queued fragments into one event) — as NimBLE does not report which opcode carried the write. It need not be distinguished: for a Write Request the status returned by the hook becomes the ATT error response, and for a Write Command (which has no response) it is discarded. Local writes arrive here too, with CONN_HANDLE_NONE.

Fields

§conn_handle: ConnHandle
§attr_handle: AttrHandle
§data: Mbuf<'a>
§

SubscriptionChanged

A peer’s subscription state for one of our characteristics changed: it wrote the CCCD, the connection is going down, or a bond was restored — see reason. The prev_* / cur_* pairs give the edge, so no shadow state is needed to tell a subscribe from an unsubscribe.

Fields

§conn_handle: ConnHandle
§attr_handle: AttrHandle
§prev_notify: bool
§cur_notify: bool
§prev_indicate: bool
§cur_indicate: bool
§

NotifyComplete

An indication/notification we sent completed (for an indication, status is the peer’s confirmation result).

Fields

§conn_handle: ConnHandle
§attr_handle: AttrHandle
§indication: bool
§status: i32

Auto Trait Implementations§

§

impl<'a> !Send for GattsEvent<'a>

§

impl<'a> !Sync for GattsEvent<'a>

§

impl<'a> !UnwindSafe for GattsEvent<'a>

§

impl<'a> Freeze for GattsEvent<'a>

§

impl<'a> RefUnwindSafe for GattsEvent<'a>

§

impl<'a> Unpin for GattsEvent<'a>

§

impl<'a> UnsafeUnpin for GattsEvent<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.