pub struct Characteristic<T: AsGatt + ?Sized> {
pub cccd_handle: Option<u16>,
pub handle: u16,
pub end_handle: u16,
pub props: CharacteristicProps,
pub uuid: Uuid,
/* private fields */
}Expand description
A characteristic in the attribute table.
Fields§
§cccd_handle: Option<u16>Handle value assigned to the Client Characteristic Configuration Descriptor (if any)
handle: u16Handle value assigned to this characteristic when it is added to the Gatt Attribute Table
end_handle: u16Last attribute handle belonging to this characteristic (value handle + descriptors)
props: CharacteristicPropsProperties of this characteristic
uuid: UuidUUID of this characteristic
Implementations§
Source§impl<T: AsGatt + ?Sized> Characteristic<T>
impl<T: AsGatt + ?Sized> Characteristic<T>
Sourcepub fn should_notify<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
) -> bool
pub fn should_notify<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, ) -> bool
Check if notifications should be sent to connection for this characteristic.
Sourcepub async fn notify<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
value: &T,
store: bool,
) -> Result<(), Error>
pub async fn notify<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, value: &T, store: bool, ) -> Result<(), Error>
Send a notification to connection with a new value for the characteristic.
If store is true, the new value will be written to the table before sending the notification.
If the provided connection has not subscribed for this characteristic, it will not be notified.
If the characteristic does not support notifications, an error is returned.
Sourcepub async fn notify_raw<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
value: &[u8],
store: bool,
) -> Result<(), Error>
pub async fn notify_raw<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, value: &[u8], store: bool, ) -> Result<(), Error>
Send a notification to connection with a new value for the characteristic.
If store is true, the new value will be written to the table before sending the notification.
If the provided connection has not subscribed for this characteristic, it will not be notified.
If the characteristic does not support notifications, an error is returned.
Sourcepub fn should_indicate<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
) -> bool
pub fn should_indicate<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, ) -> bool
Check if indications should be sent to connection for this characteristic.
Sourcepub async fn indicate<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
value: &T,
store: bool,
) -> Result<(), Error>
pub async fn indicate<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, value: &T, store: bool, ) -> Result<(), Error>
Send an indication to connection with a new value for the characteristic.
If store is true, the new value will be written to the table before sending the indication.
If the provided connection has not subscribed for this characteristic, it will not be sent an indication.
If the characteristic does not support indications, an error is returned.
Blocks until the peer’s HandleValueConfirmation is received, for up to 30 seconds
(BT Core Spec Vol 3, Part F, Section 3.3.3 ATT transaction timeout). On timeout the
connection is closed and Error::Timeout is returned. Concurrent calls on the same
connection are serialized; callers do not need to coordinate. Returns
Error::Disconnected if the connection is dropped while waiting.
Sourcepub async fn indicate_raw<P: PacketPool>(
&self,
connection: &GattConnection<'_, '_, P>,
value: &[u8],
store: bool,
) -> Result<(), Error>
pub async fn indicate_raw<P: PacketPool>( &self, connection: &GattConnection<'_, '_, P>, value: &[u8], store: bool, ) -> Result<(), Error>
Send an indication to connection with a new value for the characteristic.
If store is true, the new value will be written to the table before sending the indication.
If the provided connection has not subscribed for this characteristic, it will not be sent an indication.
If the characteristic does not support indications, an error is returned.
Blocks until the peer’s HandleValueConfirmation is received, for up to 30 seconds
(BT Core Spec Vol 3, Part F, Section 3.3.3 ATT transaction timeout). On timeout the
connection is closed and Error::Timeout is returned. Concurrent calls on the same
connection are serialized; callers do not need to coordinate. Returns
Error::Disconnected if the connection is dropped while waiting.
Sourcepub fn set<M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, P, AT, CN>,
value: &T,
) -> Result<(), Error>
pub fn set<M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>( &self, server: &AttributeServer<'_, M, P, AT, CN>, value: &T, ) -> Result<(), Error>
Set the value of the characteristic in the provided attribute server.
Sourcepub fn set_ro<'a, M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>(
&self,
server: &AttributeServer<'a, M, P, AT, CN>,
value: &'a T,
) -> Result<(), Error>
pub fn set_ro<'a, M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>( &self, server: &AttributeServer<'a, M, P, AT, CN>, value: &'a T, ) -> Result<(), Error>
Set the value of the characteristic in the provided attribute server.
Sourcepub fn get<M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, P, AT, CN>,
) -> Result<T, Error>where
T: FromGatt,
pub fn get<M: RawMutex, P: PacketPool, const AT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, P, AT, CN>,
) -> Result<T, Error>where
T: FromGatt,
Read the value of the characteristic.
If the characteristic for the handle cannot be found, an error is returned.
Sourcepub fn with_raw_value<M: RawMutex, P: PacketPool, R, const AT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, P, AT, CN>,
f: impl FnOnce(&[u8]) -> R,
) -> Option<R>
pub fn with_raw_value<M: RawMutex, P: PacketPool, R, const AT: usize, const CN: usize>( &self, server: &AttributeServer<'_, M, P, AT, CN>, f: impl FnOnce(&[u8]) -> R, ) -> Option<R>
Access the raw byte value of the characteristic.
Sourcepub fn cccd_handle(&self) -> Option<CharacteristicPropertiesHandle>
pub fn cccd_handle(&self) -> Option<CharacteristicPropertiesHandle>
Returns the attribute handle for the characteristic’s client characteristic configuration descriptor (if available)
Sourcepub fn to_raw(self) -> Characteristic<[u8]>
pub fn to_raw(self) -> Characteristic<[u8]>
Convert this characteristic’s type to raw bytes
Trait Implementations§
Source§impl<T: AsGatt + ?Sized> AttributeHandle for Characteristic<T>
impl<T: AsGatt + ?Sized> AttributeHandle for Characteristic<T>
Source§impl<T: Clone + AsGatt + ?Sized> Clone for Characteristic<T>
impl<T: Clone + AsGatt + ?Sized> Clone for Characteristic<T>
Source§fn clone(&self) -> Characteristic<T>
fn clone(&self) -> Characteristic<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more