public interface 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.
| Modifier and Type | Method and Description |
|---|---|
default void |
centralManagerConnectionEventDidOccurForPeripheral(CBCentralManager central,
long event,
CBPeripheral peripheral)
centralManager:connectionEventDidOccur:forPeripheral:
|
default void |
centralManagerDidConnectPeripheral(CBCentralManager central,
CBPeripheral peripheral)
centralManager:didConnectPeripheral:
|
default void |
centralManagerDidDisconnectPeripheralError(CBCentralManager central,
CBPeripheral peripheral,
NSError error)
centralManager:didDisconnectPeripheral:error:
|
default void |
centralManagerDidDiscoverPeripheralAdvertisementDataRSSI(CBCentralManager central,
CBPeripheral peripheral,
NSDictionary<java.lang.String,?> advertisementData,
NSNumber RSSI)
centralManager:didDiscoverPeripheral:advertisementData:RSSI:
|
default void |
centralManagerDidFailToConnectPeripheralError(CBCentralManager central,
CBPeripheral peripheral,
NSError error)
centralManager:didFailToConnectPeripheral:error:
|
default void |
centralManagerDidUpdateANCSAuthorizationForPeripheral(CBCentralManager central,
CBPeripheral peripheral)
centralManager:didUpdateANCSAuthorizationForPeripheral:
|
void |
centralManagerDidUpdateState(CBCentralManager central)
centralManagerDidUpdateState:
|
default void |
centralManagerWillRestoreState(CBCentralManager central,
NSDictionary<java.lang.String,?> dict)
centralManager:willRestoreState:
|
default void centralManagerDidConnectPeripheral(CBCentralManager central, CBPeripheral peripheral)
This method is invoked when a connection initiated by connectPeripheral:options: has succeeded.
central - The central manager providing this information.peripheral - The CBPeripheral that has connected.default void centralManagerDidDisconnectPeripheralError(CBCentralManager central, CBPeripheral peripheral, NSError error)
This method is invoked upon the disconnection of a peripheral that was connected by 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.
central - The central manager providing this information.peripheral - The CBPeripheral that has disconnected.error - If an error occurred, the cause of the failure.default void centralManagerDidDiscoverPeripheralAdvertisementDataRSSI(CBCentralManager central, CBPeripheral peripheral, NSDictionary<java.lang.String,?> advertisementData, NSNumber 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.
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.CBAdvertisementData.hdefault void centralManagerDidFailToConnectPeripheralError(CBCentralManager central, CBPeripheral peripheral, NSError error)
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.
central - The central manager providing this information.peripheral - The CBPeripheral that has failed to connect.error - The cause of the failure.default void centralManagerWillRestoreState(CBCentralManager central, NSDictionary<java.lang.String,?> dict)
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.
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.CBCentralManagerRestoredStatePeripheralsKey;,
CBCentralManagerRestoredStateScanServicesKey;,
CBCentralManagerRestoredStateScanOptionsKey;void centralManagerDidUpdateState(CBCentralManager central)
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.
central - The central manager whose state has changed.statedefault void centralManagerConnectionEventDidOccurForPeripheral(CBCentralManager central, long event, CBPeripheral peripheral)
This method is invoked upon the connection or disconnection of a peripheral that matches any of the options provided in registerForConnectionEventsWithOptions:.
central - The central manager providing this information.event - The CBConnectionEvent that has occurred.peripheral - The CBPeripheral that caused the event.default void centralManagerDidUpdateANCSAuthorizationForPeripheral(CBCentralManager central, CBPeripheral peripheral)
This method is invoked when the authorization status changes for a peripheral connected with connectPeripheral: option CBConnectPeripheralOptionRequiresANCS.
central - The central manager providing this information.peripheral - The CBPeripheral that caused the event.