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​(@NotNull
                                                        @NotNull CBCentralManager central,
                                                        @NotNull
                                                        @NotNull 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​(@NotNull
                                                                @NotNull CBCentralManager central,
                                                                @NotNull
                                                                @NotNull CBPeripheral peripheral,
                                                                @Nullable
                                                                @Nullable 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​(@NotNull
                                                                              @NotNull CBCentralManager central,
                                                                              @NotNull
                                                                              @NotNull CBPeripheral peripheral,
                                                                              @NotNull
                                                                              @NotNull NSDictionary<java.lang.String,​?> advertisementData,
                                                                              @NotNull
                                                                              @NotNull 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​(@NotNull
                                                                   @NotNull CBCentralManager central,
                                                                   @NotNull
                                                                   @NotNull CBPeripheral peripheral,
                                                                   @Nullable
                                                                   @Nullable 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​(@NotNull
                                                    @NotNull CBCentralManager central,
                                                    @NotNull
                                                    @NotNull 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​(@NotNull
                                          @NotNull 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​(@NotNull
                                                                        @NotNull CBCentralManager central,
                                                                        long event,
                                                                        @NotNull
                                                                        @NotNull 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:}. API-Since: 13.0
        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​(@NotNull
                                                                           @NotNull CBCentralManager central,
                                                                           @NotNull
                                                                           @NotNull CBPeripheral peripheral)
        centralManager:didUpdateANCSAuthorizationForPeripheral: This method is invoked when the authorization status changes for a peripheral connected with {@link connectPeripheral:} option CBConnectPeripheralOptionRequiresANCS. API-Since: 13.0
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that caused the event.
      • centralManagerDidDisconnectPeripheralTimestampIsReconnectingError

        default void centralManagerDidDisconnectPeripheralTimestampIsReconnectingError​(@NotNull
                                                                                       @NotNull CBCentralManager central,
                                                                                       @NotNull
                                                                                       @NotNull CBPeripheral peripheral,
                                                                                       double timestamp,
                                                                                       boolean isReconnecting,
                                                                                       @Nullable
                                                                                       @Nullable NSError error)
        centralManager:didDisconnectPeripheral:timestamp:isReconnecting:error This method is invoked upon the disconnection of a peripheral that was connected by {@link connectPeripheral:options:}. If perihperal is connected with connect option 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 peripheral's CBPeripheralDelegate .
        Parameters:
        central - The central manager providing this information.
        peripheral - The CBPeripheral that has disconnected.
        timestamp - Timestamp of the disconnection, it can be now or a few seconds ago.
        isReconnecting - If reconnect was triggered upon disconnection.
        error - If an error occurred, the cause of the failure.