Struct esp32_nimble::BLEServer

source ·
pub struct BLEServer { /* private fields */ }

Implementations§

source§

impl BLEServer

source

pub fn on_connect( &mut self, callback: impl FnMut(&mut Self, &BLEConnDesc) + Send + Sync + 'static ) -> &mut Self

source

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_desc instance with information about the peer connection parameters.
  • callback second parameter: The reason code for the disconnection.
source

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
source

pub fn on_confirm_pin( &mut self, callback: impl Fn(u32) -> bool + Send + Sync + 'static ) -> &mut Self

source

pub fn on_authentication_complete( &mut self, callback: impl Fn(&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 BLEConnDesc instance.
  • 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.
source

pub fn start(&mut self) -> Result<(), BLEError>

source

pub fn disconnect(&mut self, conn_id: u16) -> Result<(), BLEError>

Disconnect the specified client.

source

pub fn disconnect_with_reason( &mut self, conn_id: u16, reason: u8 ) -> Result<(), BLEError>

Disconnect the specified client with optional reason.

source

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.

source

pub fn connected_count(&self) -> usize

source

pub fn connections(&self) -> impl Iterator<Item = BLEConnDesc> + '_

source

pub fn create_service(&mut self, uuid: BleUuid) -> Arc<Mutex<BLEService>>

source

pub fn advertise_on_disconnect(&mut self, value: bool) -> &mut Self

Set the server to automatically start advertising when a client disconnects.

source

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 !RefUnwindSafe for BLEServer

§

impl Send for BLEServer

§

impl !Sync for BLEServer

§

impl Unpin for BLEServer

§

impl !UnwindSafe for BLEServer

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.