pub struct BLEServer { /* private fields */ }Implementations§
Source§impl BLEServer
impl BLEServer
pub fn on_connect( &mut self, callback: impl FnMut(&mut Self, &BLEConnDesc) + Send + Sync + 'static, ) -> &mut Self
Sourcepub fn on_disconnect(
&mut self,
callback: impl FnMut(&BLEConnDesc, Result<(), BLEError>) + Send + Sync + 'static,
) -> &mut Self
pub fn on_disconnect( &mut self, callback: impl FnMut(&BLEConnDesc, Result<(), BLEError>) + Send + Sync + 'static, ) -> &mut Self
Handle a client disconnection.
- callback first parameter: A reference to a
esp_idf_sys::ble_gap_conn_descinstance with information about the peer connection parameters. - callback second parameter: The reason code for the disconnection.
Sourcepub fn on_passkey_request(
&mut self,
callback: impl Fn() -> u32 + Send + Sync + 'static,
) -> &mut Self
pub fn on_passkey_request( &mut self, callback: impl Fn() -> u32 + Send + Sync + 'static, ) -> &mut Self
Set a callback fn for generating a passkey if required by the connection
- The passkey will always be exactly 6 digits. Setting the passkey to 1234 will require the user to provide ‘001234’
- a static passkey can also be set by
crate::BLESecurity::set_passkey
pub fn on_confirm_pin( &mut self, callback: impl Fn(u32) -> bool + Send + Sync + 'static, ) -> &mut Self
Sourcepub fn on_authentication_complete(
&mut self,
callback: impl Fn(&mut Self, &BLEConnDesc, Result<(), BLEError>) + Send + Sync + 'static,
) -> &mut Self
pub fn on_authentication_complete( &mut self, callback: impl Fn(&mut Self, &BLEConnDesc, Result<(), BLEError>) + Send + Sync + 'static, ) -> &mut Self
The callback function is called when the pairing procedure is complete.
- callback first parameter: A reference to a
BLEConnDescinstance. - callback second parameter: Indicates the result of the encryption state change attempt; o 0: the encrypted state was successfully updated; o BLE host error code: the encryption state change attempt failed for the specified reason.
pub fn start(&mut self) -> Result<(), BLEError>
Sourcepub fn disconnect(&mut self, conn_id: u16) -> Result<(), BLEError>
pub fn disconnect(&mut self, conn_id: u16) -> Result<(), BLEError>
Disconnect the specified client.
Sourcepub fn disconnect_with_reason(
&mut self,
conn_id: u16,
reason: u8,
) -> Result<(), BLEError>
pub fn disconnect_with_reason( &mut self, conn_id: u16, reason: u8, ) -> Result<(), BLEError>
Disconnect the specified client with optional reason.
Sourcepub fn ble_gatts_show_local(&self)
pub fn ble_gatts_show_local(&self)
Prints dump of local GATT database. This is useful to log local state of database in human readable form.
pub fn connected_count(&self) -> usize
pub fn connections(&self) -> impl Iterator<Item = BLEConnDesc> + '_
pub fn create_service(&mut self, uuid: BleUuid) -> Arc<Mutex<BLEService>>
Sourcepub async fn get_service(
&self,
uuid: BleUuid,
) -> Option<&Arc<Mutex<BLEService>>>
pub async fn get_service( &self, uuid: BleUuid, ) -> Option<&Arc<Mutex<BLEService>>>
Get the service object for the UUID.
Sourcepub fn advertise_on_disconnect(&mut self, value: bool) -> &mut Self
pub fn advertise_on_disconnect(&mut self, value: bool) -> &mut Self
Set the server to automatically start advertising when a client disconnects.
Sourcepub fn update_conn_params(
&mut self,
conn_handle: u16,
min_interval: u16,
max_interval: u16,
latency: u16,
timeout: u16,
) -> Result<(), BLEError>
pub fn update_conn_params( &mut self, conn_handle: u16, 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.
conn_handle: The connection handle of the peer to send the request to.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.
Auto Trait Implementations§
impl Freeze for BLEServer
impl !RefUnwindSafe for BLEServer
impl Send for BLEServer
impl !Sync for BLEServer
impl Unpin for BLEServer
impl UnsafeUnpin for BLEServer
impl !UnwindSafe for BLEServer
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more