public interface CBPeripheralManagerDelegate
The delegate of a @link CBPeripheralManager @/link object must adopt the CBPeripheralManagerDelegate protocol. The
single required method indicates the availability of the peripheral manager, while the optional methods provide information about
centrals, which can connect and access the local database.
| Modifier and Type | Method and Description |
|---|---|
default void |
peripheralManagerCentralDidSubscribeToCharacteristic(CBPeripheralManager peripheral,
CBCentral central,
CBCharacteristic characteristic)
peripheralManager:central:didSubscribeToCharacteristic:
|
default void |
peripheralManagerCentralDidUnsubscribeFromCharacteristic(CBPeripheralManager peripheral,
CBCentral central,
CBCharacteristic characteristic)
peripheralManager:central:didUnsubscribeFromCharacteristic:
|
default void |
peripheralManagerDidAddServiceError(CBPeripheralManager peripheral,
CBService service,
NSError error)
peripheralManager:didAddService:error:
|
default void |
peripheralManagerDidOpenL2CAPChannelError(CBPeripheralManager peripheral,
CBL2CAPChannel channel,
NSError error)
peripheralManager:didOpenL2CAPChannel:error:
|
default void |
peripheralManagerDidPublishL2CAPChannelError(CBPeripheralManager peripheral,
char PSM,
NSError error)
peripheralManager:didPublishL2CAPChannel:error:
|
default void |
peripheralManagerDidReceiveReadRequest(CBPeripheralManager peripheral,
CBATTRequest request)
peripheralManager:didReceiveReadRequest:
|
default void |
peripheralManagerDidReceiveWriteRequests(CBPeripheralManager peripheral,
NSArray<? extends CBATTRequest> requests)
peripheralManager:didReceiveWriteRequests:
|
default void |
peripheralManagerDidStartAdvertisingError(CBPeripheralManager peripheral,
NSError error)
peripheralManagerDidStartAdvertising:error:
|
default void |
peripheralManagerDidUnpublishL2CAPChannelError(CBPeripheralManager peripheral,
char PSM,
NSError error)
peripheralManager:didUnublishL2CAPChannel:error:
|
void |
peripheralManagerDidUpdateState(CBPeripheralManager peripheral)
peripheralManagerDidUpdateState:
|
default void |
peripheralManagerIsReadyToUpdateSubscribers(CBPeripheralManager peripheral)
peripheralManagerIsReadyToUpdateSubscribers:
|
default void |
peripheralManagerWillRestoreState(CBPeripheralManager peripheral,
NSDictionary<java.lang.String,?> dict)
peripheralManager:willRestoreState:
|
default void peripheralManagerCentralDidSubscribeToCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
This method is invoked when a central configures characteristic to notify or indicate. It should be used as a cue to start sending updates as the characteristic value changes.
peripheral - The peripheral manager providing this update.central - The central that issued the command.characteristic - The characteristic on which notifications or indications were enabled.default void peripheralManagerCentralDidUnsubscribeFromCharacteristic(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
This method is invoked when a central removes notifications/indications from characteristic.
peripheral - The peripheral manager providing this update.central - The central that issued the command.characteristic - The characteristic on which notifications or indications were disabled.default void peripheralManagerDidAddServiceError(CBPeripheralManager peripheral, CBService service, NSError error)
This method returns the result of an @link addService: @/link call. If the service could not be published to the local database, the cause will be detailed in the error parameter.
peripheral - The peripheral manager providing this information.service - The service that was added to the local database.error - If an error occurred, the cause of the failure.default void peripheralManagerDidReceiveReadRequest(CBPeripheralManager peripheral, CBATTRequest request)
This method is invoked when peripheral receives an ATT request for a characteristic with a dynamic value. For every invocation of this method, @link respondToRequest:withResult: @/link must be called.
peripheral - The peripheral manager requesting this information.request - A CBATTRequest object.CBATTRequestdefault void peripheralManagerDidReceiveWriteRequests(CBPeripheralManager peripheral, NSArray<? extends CBATTRequest> requests)
This method is invoked when peripheral receives an ATT request or command for one or more characteristics with a dynamic value.
For every invocation of this method, @link respondToRequest:withResult: @/link should be called exactly once. If requests contains
multiple requests, they must be treated as an atomic unit. If the execution of one of the requests would cause a failure, the request
and error reason should be provided to respondToRequest:withResult: and none of the requests should be executed.
peripheral - The peripheral manager requesting this information.requests - A list of one or more CBATTRequest objects.CBATTRequestdefault void peripheralManagerWillRestoreState(CBPeripheralManager peripheral, 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.
peripheral - The peripheral manager providing this information.dict - A dictionary containing information about peripheral that was preserved by the system at the time the app was terminated.CBPeripheralManagerRestoredStateServicesKey;,
CBPeripheralManagerRestoredStateAdvertisementDataKey;default void peripheralManagerDidStartAdvertisingError(CBPeripheralManager peripheral, NSError error)
This method returns the result of a @link startAdvertising: @/link call. If advertisement could not be started, the cause will be detailed in the error parameter.
peripheral - The peripheral manager providing this information.error - If an error occurred, the cause of the failure.void peripheralManagerDidUpdateState(CBPeripheralManager peripheral)
Invoked whenever the peripheral manager's state has been updated. Commands should only be issued when the state is
CBPeripheralManagerStatePoweredOn. A state below CBPeripheralManagerStatePoweredOn
implies that advertisement has paused and any connected centrals have been disconnected. If the state moves below
CBPeripheralManagerStatePoweredOff, advertisement is stopped and must be explicitly restarted, and the
local database is cleared and all services must be re-added.
peripheral - The peripheral manager whose state has changed.statedefault void peripheralManagerIsReadyToUpdateSubscribers(CBPeripheralManager peripheral)
This method is invoked after a failed call to @link updateValue:forCharacteristic:onSubscribedCentrals: @/link, when peripheral is again ready to send characteristic value updates.
peripheral - The peripheral manager providing this update.default void peripheralManagerDidOpenL2CAPChannelError(CBPeripheralManager peripheral, CBL2CAPChannel channel, NSError error)
This method returns the result of establishing an incoming L2CAP channel , following publishing a channel using @link publishL2CAPChannel: @link call.
peripheral - The peripheral manager requesting this information.channel - A CBL2CAPChannel object.error - If an error occurred, the cause of the failure.default void peripheralManagerDidPublishL2CAPChannelError(CBPeripheralManager peripheral, char PSM, NSError error)
This method is the response to a @link publishL2CAPChannel: @/link call. The PSM will contain the PSM that was assigned for the published channel
peripheral - The peripheral manager requesting this information.PSM - The PSM of the channel that was published.error - If an error occurred, the cause of the failure.default void peripheralManagerDidUnpublishL2CAPChannelError(CBPeripheralManager peripheral, char PSM, NSError error)
This method is the response to a @link unpublishL2CAPChannel: @/link call.
peripheral - The peripheral manager requesting this information.PSM - The PSM of the channel that was published.error - If an error occurred, the cause of the failure.