pub struct Connection { /* private fields */ }Expand description
A GATT connection to one peer.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn open(
address: &str,
random_address: bool,
sink: Arc<dyn NotificationSink>,
) -> Result<Self, Error>
pub fn open( address: &str, random_address: bool, sink: Arc<dyn NotificationSink>, ) -> Result<Self, Error>
Open an ATT connection to address.
random_address must match how the peer advertised — connecting to a
random address as though it were public simply times out.
pub fn peer(&self) -> &str
pub fn is_connected(&self) -> bool
pub fn close(&self)
Sourcepub fn discover_services(&self) -> Result<Vec<Service>, Error>
pub fn discover_services(&self) -> Result<Vec<Service>, Error>
Every primary service on the peer.
Repeats Read By Group Type from where the last reply stopped until the
peer answers ATTRIBUTE_NOT_FOUND, which is how it says “no more”.
Sourcepub fn discover_included_services(
&self,
service: &Service,
) -> Result<Vec<Service>, Error>
pub fn discover_included_services( &self, service: &Service, ) -> Result<Vec<Service>, Error>
Every characteristic within a service’s handle range. The services this one includes.
An Include declaration whose included service has a 128-bit UUID does
not carry it, so the UUID is read from the included service’s own
declaration — otherwise the caller would have a handle range it cannot
name.
pub fn discover_characteristics( &self, service: &Service, ) -> Result<Vec<Characteristic>, Error>
Sourcepub fn discover_descriptors(
&self,
start: u16,
end: u16,
) -> Result<Vec<Descriptor>, Error>
pub fn discover_descriptors( &self, start: u16, end: u16, ) -> Result<Vec<Descriptor>, Error>
The descriptors of one characteristic — everything between its value handle and the next characteristic (or the end of the service).
Sourcepub fn read(&self, handle: u16) -> Result<Vec<u8>, Error>
pub fn read(&self, handle: u16) -> Result<Vec<u8>, Error>
Read an attribute, following on with Read Blob if the value filled the
MTU — which is the only signal that there is more of it.
Sourcepub fn write(&self, handle: u16, value: &[u8]) -> Result<(), Error>
pub fn write(&self, handle: u16, value: &[u8]) -> Result<(), Error>
Write and wait for the peer to acknowledge.