Interface CBCentralManagerDelegate


  • public interface CBCentralManagerDelegate
    [@protocol] CBCentralManagerDelegate The delegate of a CBCentralManager object must adopt the CBCentralManagerDelegate protocol. The single required method indicates the availability of the central manager, while the optional methods allow for the discovery and connection of peripherals.
    • Method Detail

      • centralManagerDidConnectPeripheral

        default void centralManagerDidConnectPeripheral​(CBCentralManager central,
                                                        CBPeripheral peripheral)
        centralManager:didConnectPeripheral: This method is invoked when a connection initiated by {@link connectPeripheral:options:} has succeeded.
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that has connected.
      • centralManagerDidDisconnectPeripheralError

        default void centralManagerDidDisconnectPeripheralError​(CBCentralManager central,
                                                                CBPeripheral peripheral,
                                                                NSError error)
        centralManager:didDisconnectPeripheral:error: This method is invoked upon the disconnection of a peripheral that was connected by {@link connectPeripheral:options:}. If the disconnection was not initiated by cancelPeripheralConnection, the cause will be detailed in the error parameter. Once this method has been called, no more methods will be invoked on peripheral's CBPeripheralDelegate.
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that has disconnected.
        error - If an error occurred, the cause of the failure.
      • centralManagerDidDiscoverPeripheralAdvertisementDataRSSI

        default void centralManagerDidDiscoverPeripheralAdvertisementDataRSSI​(CBCentralManager central,
                                                                              CBPeripheral peripheral,
                                                                              NSDictionary<java.lang.String,​?> advertisementData,
                                                                              NSNumber RSSI)
        centralManager:didDiscoverPeripheral:advertisementData:RSSI: 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.
        Parameters:
        central - The central manager providing this update.
        peripheral - A CBPeripheral object.
        advertisementData - A dictionary containing any advertisement and scan response data.
        RSSI - The current RSSI of peripheral, in dBm. A value of 127 is reserved and indicates the RSSI was not available.
        See Also:
        CBAdvertisementData.h
      • centralManagerDidFailToConnectPeripheralError

        default void centralManagerDidFailToConnectPeripheralError​(CBCentralManager central,
                                                                   CBPeripheral peripheral,
                                                                   NSError error)
        centralManager:didFailToConnectPeripheral:error: This method is invoked when a connection initiated by {@link 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.
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that has failed to connect.
        error - The cause of the failure.
      • centralManagerWillRestoreState

        default void centralManagerWillRestoreState​(CBCentralManager central,
                                                    NSDictionary<java.lang.String,​?> dict)
        centralManager:willRestoreState: 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.
        Parameters:
        central - The central manager providing this information.
        dict - A dictionary containing information about central that was preserved by the system at the time the app was terminated.
      • centralManagerDidUpdateState

        void centralManagerDidUpdateState​(CBCentralManager central)
        centralManagerDidUpdateState: 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.
        Parameters:
        central - The central manager whose state has changed.
        See Also:
        state
      • centralManagerConnectionEventDidOccurForPeripheral

        default void centralManagerConnectionEventDidOccurForPeripheral​(CBCentralManager central,
                                                                        long event,
                                                                        CBPeripheral peripheral)
        centralManager:connectionEventDidOccur:forPeripheral: This method is invoked upon the connection or disconnection of a peripheral that matches any of the options provided in {@link registerForConnectionEventsWithOptions:}.
        Parameters:
        central - The central manager providing this information.
        event - The CBConnectionEvent that has occurred.
        peripheral - The CBPeripheral that caused the event.
      • centralManagerDidUpdateANCSAuthorizationForPeripheral

        default void centralManagerDidUpdateANCSAuthorizationForPeripheral​(CBCentralManager central,
                                                                           CBPeripheral peripheral)
        centralManager:didUpdateANCSAuthorizationForPeripheral: This method is invoked when the authorization status changes for a peripheral connected with {@link connectPeripheral:} option CBConnectPeripheralOptionRequiresANCS.
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that caused the event.