Struct esp32_nimble::BLEClient
source · pub struct BLEClient { /* private fields */ }
Implementations§
source§impl BLEClient
impl BLEClient
pub fn new() -> Self
pub fn on_passkey_request( &mut self, callback: impl Fn() -> u32 + Send + Sync + 'static, ) -> &mut Self
pub fn on_confirm_pin( &mut self, callback: impl Fn(u32) -> bool + Send + Sync + 'static, ) -> &mut Self
pub fn on_connect( &mut self, callback: impl Fn(&mut Self) + Send + Sync + 'static, ) -> &mut Self
pub fn on_disconnect( &mut self, callback: impl Fn(i32) + Send + Sync + 'static, ) -> &mut Self
pub async fn connect(&mut self, addr: &BLEAddress) -> Result<(), BLEError>
pub async fn secure_connection(&mut self) -> Result<(), BLEError>
sourcepub fn disconnect(&mut self) -> Result<(), BLEError>
pub fn disconnect(&mut self) -> Result<(), BLEError>
Disconnect from the peer.
sourcepub fn disconnect_with_reason(&mut self, reason: u8) -> Result<(), BLEError>
pub fn disconnect_with_reason(&mut self, reason: u8) -> Result<(), BLEError>
Disconnect from the peer with optional reason.
pub fn connected(&self) -> bool
sourcepub fn set_connection_params(
&mut self,
min_interval: u16,
max_interval: u16,
latency: u16,
timeout: u16,
scan_interval: u16,
scan_window: u16,
)
pub fn set_connection_params( &mut self, min_interval: u16, max_interval: u16, latency: u16, timeout: u16, scan_interval: u16, scan_window: u16, )
Set the connection parameters to use when connecting to a server.
min_interval
: The minimum connection interval in 1.25ms units.max_interval
: The maximum connection interval in 1.25ms units.latency
: The number of packets allowed to skip (extends max interval).timeout
: The timeout time in 10ms units before disconnecting.scan_interval
: The scan interval to use when attempting to connect in 0.625ms units.scan_window
: The scan window to use when attempting to connect in 0.625ms units.
sourcepub fn update_conn_params(
&mut self,
min_interval: u16,
max_interval: u16,
latency: u16,
timeout: u16,
) -> Result<(), BLEError>
pub fn update_conn_params( &mut self, min_interval: u16, max_interval: u16, latency: u16, timeout: u16, ) -> Result<(), BLEError>
Request an Update the connection parameters: Can only be used after a connection has been established.
min_interval
: The minimum connection interval in 1.25ms units.max_interval
: The maximum connection interval in 1.25ms units.latency
: The number of packets allowed to skip (extends max interval).timeout
: The timeout time in 10ms units before disconnecting.
pub fn desc(&self) -> Result<BLEConnDesc, BLEError>
sourcepub fn get_rssi(&self) -> Result<i8, BLEError>
pub fn get_rssi(&self) -> Result<i8, BLEError>
Retrieves the most-recently measured RSSI. A connection’s RSSI is updated whenever a data channel PDU is received.