Platforms to show: All Mac Windows Linux Cross-Platform

Back to CBCentralManagerMBS class.

CBCentralManagerMBS.cancelPeripheralConnection(Peripheral as CBPeripheralMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Cancels an active or pending local connection to a peripheral.

peripheral: The peripheral to which the central manager is either trying to connect or has already connected.

This method is nonblocking, and any CBPeripheral class commands that are still pending to peripheral may or may not complete. Because other apps may still have a connection to the peripheral, canceling a local connection does not guarantee that the underlying physical link is immediately disconnected. From the app’s perspective, however, the peripheral is considered disconnected, and the central manager object calls the didDisconnectPeripheral event.

CBCentralManagerMBS.connectPeripheral(peripheral as CBPeripheralMBS, options as Dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Establishes a local connection to a peripheral.

peripheral: The peripheral to which the central is attempting to connect.
options: A dictionary to customize the behavior of the connection. For available options, see Peripheral Connection Options.

If a local connection to a peripheral is successfully established, the central manager object calls the centralManager:didConnectPeripheral: method of its delegate object. If the connection attempt fails, the central manager object calls the didFailToConnectPeripheral event. Attempts to connect to a peripheral do not time out. To explicitly cancel a pending connection to a peripheral, call the cancelPeripheralConnection method. The cancelPeripheralConnection method is implicitly called when peripheral is deallocated.

Some examples using this method:

CBCentralManagerMBS.Constructor(options as dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes the central manager.

options: An optional dictionary containing initialization options for a central manager.

CBCentralManagerMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
The destructor.

CBCentralManagerMBS.retrieveConnectedPeripheralsWithServices(serviceUUIDs() as CBUUIDMBS) as CBPeripheralMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a list of the peripherals (containing any of the specified services) currently connected to the system.

serviceUUIDs: A list of service UUIDs (represented by CBUUID objects).

Returns a list of the peripherals that are currently connected to the system and that contain any of the services specified in the serviceUUID parameter.

The list of connected peripherals can include those that are connected by other apps and that will need to be connected locally using the connectPeripheral method before they can be used.

Some examples using this method:

CBCentralManagerMBS.retrievePeripheralsWithIdentifiers(identifiers() as NSUUIDMBS) as CBPeripheralMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a list of known peripherals by their identifiers.

identifiers: A list of peripheral identifiers (represented by NSUUID objects) from which CBPeripheral objects can be retrieved.

Returns a list of peripherals that the central manager is able to match to the provided identifiers.

CBCentralManagerMBS.scanForPeripheralsWithServices(serviceUUIDs() as CBUUIDMBS = nil, options as Dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Scans for peripherals that are advertising services.

serviceUUIDs: An array of CBUUID objects that the app is interested in. In this case, each CBUUID object represents the UUID of a service that a peripheral is advertising.
options: An optional dictionary specifying options to customize the scan. For available options, see Peripheral Scanning Options.

You can provide an array of CBUUID objects—representing service UUIDs—in the serviceUUIDs parameter. When you do, the central manager returns only peripherals that advertise the services you specify (recommended). If the serviceUUIDs parameter is nil, all discovered peripherals are returned regardless of their supported services (not recommended). If the central manager is already scanning with different parameters, the provided parameters replace them. When the central manager object discovers a peripheral, it calls the didDiscoverPeripheral event.
Apps that have specified the bluetooth-central background mode are allowed to scan while in the background. That said, they must explicitly scan for one or more services by specifying them in the serviceUUIDs parameter. The CBCentralManager scan option is ignored while scanning in the background.

Some examples using this method:

CBCentralManagerMBS.stopScan

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Bluetooth MBS Bluetooth Plugin 18.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Asks the central manager to stop scanning for peripherals.

The items on this page are in the following plugins: MBS Bluetooth Plugin.


The biggest plugin in space...