pub struct AttributeTable<'d, M: RawMutex, const MAX: usize> { /* private fields */ }Expand description
A table of attributes.
Implementations§
Source§impl<'d, M: RawMutex, const MAX: usize> AttributeTable<'d, M, MAX>
impl<'d, M: RawMutex, const MAX: usize> AttributeTable<'d, M, MAX>
Sourcepub fn add_service(
&mut self,
service: Service,
) -> ServiceBuilder<'_, 'd, M, MAX>
pub fn add_service( &mut self, service: Service, ) -> ServiceBuilder<'_, 'd, M, MAX>
Add a service to the attribute table (group of characteristics)
Sourcepub fn add_secondary_service(
&mut self,
service: Service,
) -> ServiceBuilder<'_, 'd, M, MAX>
pub fn add_secondary_service( &mut self, service: Service, ) -> ServiceBuilder<'_, 'd, M, MAX>
Add a service to the attribute table (group of characteristics)
Sourcepub fn permissions(&self, attribute: u16) -> Option<AttPermissions>
pub fn permissions(&self, attribute: u16) -> Option<AttPermissions>
Get the permissions for the attribute
Returns None if the attribute handle is invalid.
Sourcepub fn uuid(&self, attribute: u16) -> Option<Uuid>
pub fn uuid(&self, attribute: u16) -> Option<Uuid>
Get the UUID of the attribute type
Returns None if the attribute handle is invalid.
Sourcepub fn read(
&self,
attribute: u16,
offset: usize,
data: &mut [u8],
) -> Result<usize, Error>
pub fn read( &self, attribute: u16, offset: usize, data: &mut [u8], ) -> Result<usize, Error>
Read the raw value of the attribute
If the attribute value is larger than the data buffer, data will be filled with as many bytes as fit. Use additional reads with an offset to read the remaining data.
The value of the attribute is undefined for connection-specific attributes (like CCCD).
Sourcepub fn write(
&self,
attribute: u16,
offset: usize,
data: &[u8],
) -> Result<(), Error>
pub fn write( &self, attribute: u16, offset: usize, data: &[u8], ) -> Result<(), Error>
Write the raw value of the attribute
If the attribute is variable length, its length will be set to offset + data.len().
If the attribute is fixed length, the range offset..(offset + data.len()) will be
overwritten.
Sourcepub fn set<T: AttributeHandle>(
&self,
attribute_handle: &T,
input: &T::Value,
) -> Result<(), Error>
pub fn set<T: AttributeHandle>( &self, attribute_handle: &T, input: &T::Value, ) -> Result<(), Error>
Set the value of a characteristic
The provided data must exactly match the size of the storage for the characteristic, otherwise this function will panic.
If the characteristic for the handle cannot be found, or the shape of the data does not match the type of the characterstic, an error is returned
Sourcepub fn get<T: AttributeHandle<Value = V>, V: FromGatt>(
&self,
attribute_handle: &T,
) -> Result<T::Value, Error>
pub fn get<T: AttributeHandle<Value = V>, V: FromGatt>( &self, attribute_handle: &T, ) -> Result<T::Value, Error>
Read the value of the characteristic and pass the value to the provided closure.
The return value of the closure is returned in this function and is assumed to be infallible.
If the characteristic for the handle cannot be found, an error is returned.
Sourcepub fn find_characteristic_by_value_handle<T: AsGatt>(
&self,
handle: u16,
) -> Result<Characteristic<T>, Error>
pub fn find_characteristic_by_value_handle<T: AsGatt>( &self, handle: u16, ) -> Result<Characteristic<T>, Error>
Return the characteristic which corresponds to the supplied value handle
If no characteristic corresponding to the given value handle was found, returns an error