CBCentralManagerDelegate

Trait CBCentralManagerDelegate 

Source
pub unsafe trait CBCentralManagerDelegate: NSObjectProtocol {
    // Provided methods
    unsafe fn centralManagerDidUpdateState(&self, central: &CBCentralManager)
       where Self: Sized + Message { ... }
    unsafe fn centralManager_willRestoreState(
        &self,
        central: &CBCentralManager,
        dict: &NSDictionary<NSString, AnyObject>,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didDiscoverPeripheral_advertisementData_RSSI(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
        advertisement_data: &NSDictionary<NSString, AnyObject>,
        rssi: &NSNumber,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didConnectPeripheral(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didFailToConnectPeripheral_error(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
        error: Option<&NSError>,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didDisconnectPeripheral_error(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
        error: Option<&NSError>,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didDisconnectPeripheral_timestamp_isReconnecting_error(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
        timestamp: CFAbsoluteTime,
        is_reconnecting: bool,
        error: Option<&NSError>,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_connectionEventDidOccur_forPeripheral(
        &self,
        central: &CBCentralManager,
        event: CBConnectionEvent,
        peripheral: &CBPeripheral,
    )
       where Self: Sized + Message { ... }
    unsafe fn centralManager_didUpdateANCSAuthorizationForPeripheral(
        &self,
        central: &CBCentralManager,
        peripheral: &CBPeripheral,
    )
       where Self: Sized + Message { ... }
}
Available on crate feature CBCentralManager only.
Expand description

The delegate of a {

 CBCentralManager} object must adopt the <code>CBCentralManagerDelegate</code> protocol. The
              single required method indicates the availability of the central manager, while the optional methods allow for the discovery and
              connection of peripherals.

  

See also Apple’s documentation

Provided Methods§

Source

unsafe fn centralManagerDidUpdateState(&self, central: &CBCentralManager)
where Self: Sized + Message,

Available on crate feature CBManager only.

Parameter central: The central manager whose state has changed.

Invoked whenever the central manager’s state has been updated. Commands should only be issued when the state is CBCentralManagerStatePoweredOn . A state below CBCentralManagerStatePoweredOn implies that scanning has stopped and any connected peripherals have been disconnected. If the state moves below CBCentralManagerStatePoweredOff , all CBPeripheral objects obtained from this central manager become invalid and must be retrieved or discovered again.

See: state

Source

unsafe fn centralManager_willRestoreState( &self, central: &CBCentralManager, dict: &NSDictionary<NSString, AnyObject>, )
where Self: Sized + Message,

Available on crate feature CBManager only.

Parameter central: The central manager providing this information.

Parameter dict: A dictionary containing information about central that was preserved by the system at the time the app was terminated.

For apps that opt-in to state preservation and restoration, this is the first method invoked when your app is relaunched into the background to complete some Bluetooth-related task. Use this method to synchronize your app’s state with the state of the Bluetooth system.

See also: CBCentralManagerRestoredStatePeripheralsKey;

See also: CBCentralManagerRestoredStateScanServicesKey;

See also: CBCentralManagerRestoredStateScanOptionsKey;

§Safety

dict generic should be of the correct type.

Source

unsafe fn centralManager_didDiscoverPeripheral_advertisementData_RSSI( &self, central: &CBCentralManager, peripheral: &CBPeripheral, advertisement_data: &NSDictionary<NSString, AnyObject>, rssi: &NSNumber, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this update.

Parameter peripheral: A CBPeripheral object.

Parameter advertisementData: A dictionary containing any advertisement and scan response data.

Parameter RSSI: The current RSSI of peripheral , in dBm. A value of 127 is reserved and indicates the RSSI was not available.

This method is invoked while scanning, upon the discovery of peripheral by central . A discovered peripheral must be retained in order to use it; otherwise, it is assumed to not be of interest and will be cleaned up by the central manager. For a list of advertisementData keys, see {

 CBAdvertisementDataLocalNameKey} and other similar constants.

  @seealso                    CBAdvertisementData.h

  
§Safety

advertisement_data generic should be of the correct type.

Source

unsafe fn centralManager_didConnectPeripheral( &self, central: &CBCentralManager, peripheral: &CBPeripheral, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this information.

Parameter peripheral: The CBPeripheral that has connected.

This method is invoked when a connection initiated by {

 connectPeripheral:options:} has succeeded.

  
Source

unsafe fn centralManager_didFailToConnectPeripheral_error( &self, central: &CBCentralManager, peripheral: &CBPeripheral, error: Option<&NSError>, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this information.

Parameter peripheral: The CBPeripheral that has failed to connect.

Parameter error: The cause of the failure.

This method is invoked when a connection initiated by {

 connectPeripheral:options:} has failed to complete. As connection attempts do not
                      timeout, the failure of a connection is atypical and usually indicative of a transient issue.

  
Source

unsafe fn centralManager_didDisconnectPeripheral_error( &self, central: &CBCentralManager, peripheral: &CBPeripheral, error: Option<&NSError>, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this information.

Parameter peripheral: The CBPeripheral that has disconnected.

Parameter error: If an error occurred, the cause of the failure.

This method is invoked upon the disconnection of a peripheral that was connected by {

 connectPeripheral:options:}. If the disconnection
                      was not initiated by {@link cancelPeripheralConnection}, the cause will be detailed in the <i>error</i> parameter. Once this method has been
                      called, no more methods will be invoked on <i>peripheral</i>'s <code>CBPeripheralDelegate</code>.

  
Source

unsafe fn centralManager_didDisconnectPeripheral_timestamp_isReconnecting_error( &self, central: &CBCentralManager, peripheral: &CBPeripheral, timestamp: CFAbsoluteTime, is_reconnecting: bool, error: Option<&NSError>, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral and objc2-core-foundation only.

Parameter central: The central manager providing this information.

Parameter peripheral: The CBPeripheral that has disconnected.

Parameter timestamp: Timestamp of the disconnection, it can be now or a few seconds ago.

Parameter isReconnecting: If reconnect was triggered upon disconnection.

Parameter error: If an error occurred, the cause of the failure.

This method is invoked upon the disconnection of a peripheral that was connected by {

 connectPeripheral:options:}. If perihperal is
                      connected with connect option {@link CBConnectPeripheralOptionEnableAutoReconnect}, once this method has been called, the system
                      will automatically invoke connect to the peripheral. And if connection is established with the peripheral afterwards,
                      {@link centralManager:didConnectPeripheral:} can be invoked. If perihperal is connected without option
                      CBConnectPeripheralOptionEnableAutoReconnect, once this method has been called, no more methods will be invoked on
                       <i>peripheral</i>'s <code>CBPeripheralDelegate</code> .

  
Source

unsafe fn centralManager_connectionEventDidOccur_forPeripheral( &self, central: &CBCentralManager, event: CBConnectionEvent, peripheral: &CBPeripheral, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this information.

Parameter event: The CBConnectionEvent that has occurred.

Parameter peripheral: The CBPeripheral that caused the event.

This method is invoked upon the connection or disconnection of a peripheral that matches any of the options provided in {

 registerForConnectionEventsWithOptions:}.

  
Source

unsafe fn centralManager_didUpdateANCSAuthorizationForPeripheral( &self, central: &CBCentralManager, peripheral: &CBPeripheral, )
where Self: Sized + Message,

Available on crate features CBManager and CBPeer and CBPeripheral only.

Parameter central: The central manager providing this information.

Parameter peripheral: The CBPeripheral that caused the event.

This method is invoked when the authorization status changes for a peripheral connected with {

 connectPeripheral:} option {@link CBConnectPeripheralOptionRequiresANCS}.

  

Trait Implementations§

Source§

impl ProtocolType for dyn CBCentralManagerDelegate

Source§

const NAME: &'static str = "CBCentralManagerDelegate"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn CBCentralManagerDelegate

Implementations on Foreign Types§

Source§

impl<T> CBCentralManagerDelegate for ProtocolObject<T>

Implementors§