Class

CBPeripheralManager

An object that manages and advertises peripheral services exposed by this app.

Declaration

@interface CBPeripheralManager : CBManager

Overview

Core Bluetooth uses CBPeripheralManager objects to manage published services within the local peripheral’s Generic Attribute Profile (GATT) database and to advertise these services to central devices (represented by CBCentral objects). While a service is in the database, any connected central can see and connect to it. That said, if your app hasn’t specified the bluetooth-peripheral background mode, the contents of its services become disabled when it’s in the background or in a suspended state. In this scenario, any remote central trying to access the service’s characteristic value or characteristic descriptors receives an error.

Before you call CBPeripheralManager methods, the peripheral manager object must be in the powered-on state, as indicated by the CBPeripheralManagerStatePoweredOn. This state indicates that the device (your iPhone or iPad, for instance) supports Bluetooth low energy and that its Bluetooth is on and available for use.

Topics

Initializing a Peripheral Manager

- init

Initializes the peripheral manager without a delegate.

- initWithDelegate:queue:

Initializes the peripheral manager with a specified delegate and dispatch queue.

- initWithDelegate:queue:options:

Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.

delegate

The delegate object specified to receive peripheral events.

Peripheral Manager Initialization Options

Keys used to specify options when creating a peripheral manager.

Monitoring the State of a Peripheral Manager

+ authorizationStatus

Returns the app’s authorization status for sharing data while in the background.

Deprecated
CBPeripheralManagerAuthorizationStatus

Values representing the current authorization state of the peripheral manager.

Deprecated
CBPeripheralManagerState

Values representing the current state of the peripheral manager.

Deprecated

Adding and Removing Services

- addService:

Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.

- removeService:

Removes a specified published service from the local GATT database.

- removeAllServices

Removes all published services from the local GATT database.

Managing Advertising

- startAdvertising:

Advertises peripheral manager data.

- stopAdvertising

Stops advertising peripheral manager data.

isAdvertising

A Boolean value that indicates whether the peripheral is advertising data.

Sending Updates of a Characteristic’s Value

- updateValue:forCharacteristic:onSubscribedCentrals:

Send an updated characteristic value to one or more subscribed centrals, using a notification or indication.

Responding to Read and Write Requests

- respondToRequest:withResult:

Responds to a read or write request from a connected central.

Setting Connection Latency

- setDesiredConnectionLatency:forCentral:

Sets the desired connection latency for an existing connection to a central device.

CBPeripheralManagerConnectionLatency

Values representing the connection latency of the peripheral manager.

Using L2CAP Channels

- publishL2CAPChannelWithEncryption:

Creates a listener for incoming L2CAP channel connections.

- unpublishL2CAPChannel:

Removes a published service from the local system.

Relationships

Inherits From

See Also

Peripherals

CBPeripheral

A remote peripheral device.

CBPeripheralDelegate

A protocol that provides updates on the use of a peripheral’s services.

CBPeripheralManagerDelegate

A protocol that provides updates for local peripheral state and interactions with remote central devices.

CBAttribute

A representation of common aspects of services offered by a peripheral.

CBAttributePermissions

Values that represent the read, write, and encryption permissions for a characteristic’s value.