pub struct AttributeServer<'values, M: RawMutex, P: PacketPool, const ATT_MAX: usize, const CONN_MAX: usize> { /* private fields */ }Expand description
A GATT server capable of processing the GATT protocol using the provided table of attributes.
Implementations§
Source§impl<'values, M: RawMutex, P: PacketPool, const ATT_MAX: usize, const CONN_MAX: usize> AttributeServer<'values, M, P, ATT_MAX, CONN_MAX>
impl<'values, M: RawMutex, P: PacketPool, const ATT_MAX: usize, const CONN_MAX: usize> AttributeServer<'values, M, P, ATT_MAX, CONN_MAX>
Sourcepub fn new(
att_table: AttributeTable<'values, M, ATT_MAX>,
) -> AttributeServer<'values, M, P, ATT_MAX, CONN_MAX>
pub fn new( att_table: AttributeTable<'values, M, ATT_MAX>, ) -> AttributeServer<'values, M, P, ATT_MAX, CONN_MAX>
Create a new instance of the AttributeServer
Sourcepub fn read(
&self,
connection: &Connection<'_, P>,
handle: u16,
offset: usize,
data: &mut [u8],
) -> Result<usize, AttErrorCode>
pub fn read( &self, connection: &Connection<'_, P>, handle: u16, offset: usize, data: &mut [u8], ) -> Result<usize, AttErrorCode>
Read an attribute value with permission checks for the given connection.
Sourcepub fn process(
&self,
connection: &Connection<'_, P>,
packet: &AttClient<'_>,
rx: &mut [u8],
) -> Result<Option<usize>, Error>
pub fn process( &self, connection: &Connection<'_, P>, packet: &AttClient<'_>, rx: &mut [u8], ) -> Result<Option<usize>, Error>
Process an event and produce a response if necessary
Sourcepub fn table(&self) -> &AttributeTable<'values, M, ATT_MAX>
pub fn table(&self) -> &AttributeTable<'values, M, ATT_MAX>
Get a reference to the attribute table
Sourcepub async fn write_and_notify<C: Controller, T: AsGatt + ?Sized>(
&self,
stack: &Stack<'_, C, P>,
value_handle: u16,
data: &T,
) -> Result<(), Error>
pub async fn write_and_notify<C: Controller, T: AsGatt + ?Sized>( &self, stack: &Stack<'_, C, P>, value_handle: u16, data: &T, ) -> Result<(), Error>
Write a value to the attribute table and send notifications/indications to all connected peers that have subscribed via the CCCD.
If the attribute at value_handle + 1 is a CCCD (UUID 0x2902), each
connection is checked for notification/indication subscriptions and
sent the appropriate PDU.
Sourcepub async fn notify<C: Controller, T: AsGatt + ?Sized>(
&self,
stack: &Stack<'_, C, P>,
value_handle: u16,
data: &T,
) -> Result<(), Error>
pub async fn notify<C: Controller, T: AsGatt + ?Sized>( &self, stack: &Stack<'_, C, P>, value_handle: u16, data: &T, ) -> Result<(), Error>
Send notifications/indications to all connected peers that have subscribed via the CCCD without updating the value stored in the attribute table.
If the attribute at value_handle + 1 is not a CCCD (UUID 0x2902), an error
is returned. Each connection is checked for notification/indication
subscriptions and sent the appropriate PDU.
Sourcepub fn get_client_att_table(
&self,
connection: &Connection<'_, P>,
) -> Option<ClientAttTable>
pub fn get_client_att_table( &self, connection: &Connection<'_, P>, ) -> Option<ClientAttTable>
Get the client-specific attribute table for a connection
Sourcepub fn set_client_att_table(
&self,
connection: &Connection<'_, P>,
table: &ClientAttTableView<'_>,
)
pub fn set_client_att_table( &self, connection: &Connection<'_, P>, table: &ClientAttTableView<'_>, )
Set the client-specific attribute table for a connection