### Start Advertising Peripheral Data Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/startadvertising%28_%3A%29 Use this method to begin advertising peripheral manager data. The peripheral manager will call its delegate's peripheralManagerDidStartAdvertising(_:error:) method upon starting. ```swift func startAdvertising(_ advertisementData: [String : Any]?) ``` -------------------------------- ### Start Advertising Peripheral Data Source: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager Starts advertising peripheral manager data. Advertising data can be provided as a dictionary of options. ```swift func startAdvertising([String : Any]?) ``` -------------------------------- ### Setup Peripheral for Data Transfer Source: https://developer.apple.com/documentation/corebluetooth/transferring-data-between-bluetooth-low-energy-devices Configures a Core Bluetooth peripheral by creating a service and a characteristic that supports notify and writeWithoutResponse properties. This setup is essential for enabling data transfer from the peripheral. ```swift private func setupPeripheral() { // Build our service. // Start with the CBMutableCharacteristic. let transferCharacteristic = CBMutableCharacteristic(type: TransferService.characteristicUUID, properties: [.notify, .writeWithoutResponse], value: nil, permissions: [.readable, .writeable]) // Create a service from the characteristic. let transferService = CBMutableService(type: TransferService.serviceUUID, primary: true) // Add the characteristic to the service. transferService.characteristics = [transferCharacteristic] // And add it to the peripheral manager. peripheralManager.add(transferService) // Save the characteristic for later. self.transferCharacteristic = transferCharacteristic } ``` -------------------------------- ### Implement peripheralManagerDidStartAdvertising(_:error:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/peripheralmanagerdidstartadvertising%28_%3Aerror%3A%29 Implement this method to be notified when your app calls `startAdvertising(_:)`. Check the `error` parameter to determine if advertising started successfully. ```swift optional func peripheralManagerDidStartAdvertising( _ peripheral: CBPeripheralManager, error: (any Error)? ) ``` -------------------------------- ### CBPeripheralManager - startAdvertising(_:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/startadvertising%28_%3A%29 Starts advertising peripheral manager data. This method is used to make a device discoverable by other Bluetooth devices. ```APIDOC ## CBPeripheralManager - startAdvertising(_:) ### Description Advertises peripheral manager data. This method initiates the advertising process for the peripheral manager. ### Method Instance Method ### Endpoint N/A (This is an instance method, not a network endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **advertisementData** (Dictionary?) - Optional. A dictionary containing the data to advertise. Supported keys are `CBAdvertisementDataLocalNameKey` and `CBAdvertisementDataServiceUUIDsKey`. ### Request Example ```swift let advertisementData: [String: Any] = [ CBAdvertisementDataLocalNameKey: "MyPeripheral", CBAdvertisementDataServiceUUIDsKey: [CBUUID(string: "180D")] // Heart Rate Service UUID ] peripheralManager.startAdvertising(advertisementData) ``` ### Response #### Success Response (Implicit) When advertising starts successfully, the `peripheralManagerDidStartAdvertising(_:error:)` delegate method is called. #### Response Example ```swift func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { if let error = error { print("Failed to start advertising: \(error.localizedDescription)") } else { print("Peripheral started advertising successfully.") } } ``` ### Discussion Core Bluetooth advertises data on a "best effort" basis. In the foreground, up to 28 bytes are available for advertising data, with an additional 10 bytes for the local name in the scan response. Background advertising has limitations on local name and service UUIDs. For detailed specifications, refer to the Bluetooth 4.0 specification, Volume 3, Part C, Section 11. ``` -------------------------------- ### Managing Advertising Source: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager Methods to start and stop advertising peripheral data to central devices. ```APIDOC ## Managing Advertising ### Description Controls the advertising state of the peripheral manager to make services discoverable by centrals. ### Methods - `func startAdvertising([String : Any]?)` - `func stopAdvertising()` ### Parameters - **advertisementData** ([String : Any]?) - Optional - A dictionary containing the data to advertise. ``` -------------------------------- ### Core Bluetooth init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbcharacteristicwritetype/init%28rawvalue%3A%29 This initializer allows you to create a Core Bluetooth object from its raw integer value. It is available on various Apple platforms starting from specific OS versions. ```APIDOC ## Initializer: init(rawValue:) ### Description Initializes a Core Bluetooth object with a given raw integer value. ### Method Initializer ### Endpoint N/A (This is an initializer, not an API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```swift // Example usage (syntax may vary based on the specific Core Bluetooth type) let myValue = 1 let myObject = MyCoreBluetoothObject(rawValue: myValue) ``` ### Response #### Success Response (200) N/A (Initializers do not return HTTP responses) #### Response Example N/A ### Availability iOS 5.0+ iPadOS 5.0+ Mac Catalyst 13.0+ macOS 10.10+ tvOS 9.0+ visionOS 1.0+ watchOS 4.0+ ``` -------------------------------- ### GET /retrievePeripherals(withIdentifiers:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/retrieveperipherals%28withidentifiers%3A%29 Retrieves a list of known peripherals that match the provided list of identifiers. ```APIDOC ## retrievePeripherals(withIdentifiers:) ### Description Returns a list of known peripherals by their identifiers. ### Method Instance Method ### Parameters #### Path Parameters - **identifiers** ([UUID]) - Required - A list of peripheral identifiers from which CBPeripheral objects can be retrieved. ### Return Value A list of peripherals that the central manager is able to match to the provided identifiers. ### Request Example func retrievePeripherals(withIdentifiers identifiers: [UUID]) -> [CBPeripheral] ``` -------------------------------- ### CBPeripheralManagerDelegate - peripheralManagerDidStartAdvertising(_:error:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/peripheralmanagerdidstartadvertising%28_%3Aerror%3A%29 This delegate method is called when the peripheral manager successfully starts advertising or encounters an error. ```APIDOC ## CBPeripheralManagerDelegate - peripheralManagerDidStartAdvertising(_:error:) ### Description Tells the delegate the peripheral manager started advertising the local peripheral device’s data. ### Method `optional func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: (any Error)?) ` ### Parameters #### Path Parameters - **peripheral** (CBPeripheralManager) - Required - The peripheral manager that is starting advertising. - **error** (Error?) - Optional - The reason the call failed, or `nil` if no error occurred. ### Discussion Core Bluetooth calls this method when your app calls the `startAdvertising(_:)` method to advertise the local peripheral device’s data. If successful, the `error` parameter is `nil`. If a problem prevents advertising the data, the `error` parameter returns the cause of the failure. ``` -------------------------------- ### Initialize CBCentralManager with delegate, queue, and options Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/init%28%29 Initializes the central manager with a specified delegate, dispatch queue, and initialization options. This provides more control over the manager's setup, including state restoration. Available on iOS 5.0+, iPadOS 5.0+, Mac Catalyst 13.1+, macOS 10.7+, tvOS 9.0+, visionOS 1.0+, and watchOS 2.0+. ```swift init(delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?) ``` -------------------------------- ### Retrieve Connected Peripherals by Service Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/retrieveconnectedperipherals%28withservices%3A%29 Use this method to get a list of peripherals connected to the system that offer at least one of the specified services. Peripherals obtained this way might have been connected by other apps and may require a local connection using `connect(_:options:)` before they can be used. ```swift func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBUUID]) -> [CBPeripheral] ``` -------------------------------- ### connect(_:options:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/connect%28_%3Aoptions%3A%29 Establishes a local connection to a peripheral. ```APIDOC ## connect(_:options:) ### Description Establishes a local connection to a peripheral. After a successful connection, the central manager calls the centralManager(_:didConnect:) method of its delegate. If the connection fails, it calls centralManager(_:didFailToConnect:error:). ### Method Swift Instance Method ### Parameters #### Path Parameters - **peripheral** (CBPeripheral) - Required - The peripheral to which the central is attempting to connect. - **options** ([String : Any]?) - Optional - A dictionary to customize the behavior of the connection. ### Request Example ```swift func connect( _ peripheral: CBPeripheral, options: [String : Any]? = nil ) ``` ``` -------------------------------- ### connect(_:options:) Source: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/connect%28_%3Aoptions%3A%29 Establishes a local connection to a peripheral. ```APIDOC ## connect(_:options:) ### Description Establishes a local connection to a peripheral. ### Method Instance Method ### Parameters #### Path Parameters - **peripheral** (CBPeripheral) - Required - The peripheral to which the central is attempting to connect. - **options** ([String : Any]?) - Optional - A dictionary to customize the behavior of the connection. ### Discussion After successfully establishing a local connection to a peripheral, the central manager object calls the centralManager(_:didConnect:) method of its delegate object. If the connection attempt fails, the central manager object calls the centralManager(_:didFailToConnect:error:) method of its delegate object instead. Attempts to connect to a peripheral don’t time out. ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/init%28%29 Initializes the peripheral manager without a delegate. ```APIDOC ## init() ### Description Initializes the peripheral manager without a delegate. ### Method Initializer ### Request Example convenience init() ``` -------------------------------- ### Start and Stop Peripheral Advertising Source: https://developer.apple.com/documentation/corebluetooth/transferring-data-between-bluetooth-low-energy-devices Manages the advertising state of a Bluetooth Low Energy peripheral. Use this to start advertising the peripheral's service UUID when the switch is on and stop advertising when it's off. ```swift @IBAction func switchChanged(_ sender: Any) { // All we advertise is our service's UUID. if advertisingSwitch.isOn { peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [TransferService.serviceUUID]]) } else { peripheralManager.stopAdvertising() } } ``` -------------------------------- ### init(delegate:queue:options:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/init%28delegate%3Aqueue%3Aoptions%3A%29 Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. ```APIDOC ## init(delegate:queue:options:) ### Description Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. ### Parameters - **delegate** ((any CBPeripheralManagerDelegate)?) - Optional - The delegate to receive the peripheral role events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue for dispatching the peripheral role events. If the value is nil, the peripheral manager dispatches peripheral role events using the main queue. - **options** ([String : Any]?) - Optional - An optional dictionary containing initialization options for a peripheral manager. ### Return Value Returns a newly initialized peripheral manager. ``` -------------------------------- ### GET CBService.peripheral Source: https://developer.apple.com/documentation/corebluetooth/cbservice/peripheral Retrieves the peripheral object to which the service belongs. ```APIDOC ## GET CBService.peripheral ### Description The peripheral property returns the CBPeripheral object to which this service belongs. ### Method GET ### Endpoint CBService.peripheral ### Response - **peripheral** (CBPeripheral?) - The peripheral to which this service belongs. ``` -------------------------------- ### init(delegate:queue:options:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/init%28%29 Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. ```APIDOC ## init(delegate:queue:options:) ### Description Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. ### Method Initializer ### Parameters #### Parameters - **delegate** ((any CBPeripheralManagerDelegate)?) - Optional - The delegate object specified to receive peripheral events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue to use for peripheral events. - **options** ([String : Any]?) - Optional - Keys used to specify options when creating a peripheral manager. ``` -------------------------------- ### GET CBService.characteristics Source: https://developer.apple.com/documentation/corebluetooth/cbservice/characteristics Access the list of characteristics discovered in a service. ```APIDOC ## Property: characteristics ### Description A list of CBCharacteristic objects discovered in this service. Characteristics provide further details about a peripheral’s service, such as sensor data or device configuration. ### Declaration `var characteristics: [CBCharacteristic]? { get }` ### Availability - iOS 5.0+ - iPadOS 5.0+ - Mac Catalyst 13.1+ - macOS 10.7+ - tvOS 9.0+ - visionOS 1.0+ - watchOS 2.0+ ### Response - **characteristics** ([CBCharacteristic]?) - An array of characteristics associated with the service, or nil if none have been discovered. ``` -------------------------------- ### init(delegate:queue:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/init%28%29 Initializes the peripheral manager with a specified delegate and dispatch queue. ```APIDOC ## init(delegate:queue:) ### Description Initializes the peripheral manager with a specified delegate and dispatch queue. ### Method Initializer ### Parameters #### Parameters - **delegate** ((any CBPeripheralManagerDelegate)?) - Optional - The delegate object specified to receive peripheral events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue to use for peripheral events. ``` -------------------------------- ### GET CBCharacteristic.properties Source: https://developer.apple.com/documentation/corebluetooth/cbcharacteristic/properties Retrieves the access properties of a Bluetooth characteristic. ```APIDOC ## GET CBCharacteristic.properties ### Description The properties of a characteristic determine the access to and use of the characteristic’s value and descriptors. ### Method GET ### Endpoint CBCharacteristic.properties ### Response - **properties** (CBCharacteristicProperties) - The properties of the characteristic. ``` -------------------------------- ### init(delegate:queue:options:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/init%28delegate%3Aqueue%3Aoptions%3A%29 Initializes the central manager with specified delegate, dispatch queue, and initialization options. ```APIDOC ## init(delegate:queue:options:) ### Description Initializes the central manager with specified delegate, dispatch queue, and initialization options. This is the designated initializer for the CBCentralManager class. ### Parameters - **delegate** ((any CBCentralManagerDelegate)?) - Optional - The delegate that receives the central events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue used to dispatch the central role events. If nil, the main queue is used. - **options** ([String : Any]?) - Optional - A dictionary containing initialization options for a central manager. ### Return Value - **CBCentralManager** - Returns a newly initialized central manager. ``` -------------------------------- ### init(delegate:queue:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/init%28delegate%3Aqueue%3A%29 Initializes the central manager with a specified delegate and dispatch queue. ```APIDOC ## init(delegate:queue:) ### Description Initializes the central manager with a specified delegate and dispatch queue. ### Parameters #### Parameters - **delegate** ((any CBCentralManagerDelegate)?) - Optional - The delegate that receives central events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue used to dispatch the central role events. If the value is nil, the central manager dispatches central role events using the main queue. ### Return Value Returns a newly initialized central manager. ### Request Example ```swift convenience init( delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t? ) ``` ``` -------------------------------- ### GET CBUUID.data Source: https://developer.apple.com/documentation/corebluetooth/cbuuid/data Retrieves the raw data representation of a CBUUID instance. ```APIDOC ## GET CBUUID.data ### Description The data property returns the raw data associated with the CBUUID instance. ### Endpoint CBUUID.data ### Response - **data** (Data) - The data of the UUID. ``` -------------------------------- ### Peripheral Manager Initialization Options Source: https://developer.apple.com/documentation/corebluetooth/peripheral-manager-initialization-options Keys used to specify options when creating a peripheral manager. ```APIDOC ## Initialization Options ### `CBPeripheralManagerOptionShowPowerAlertKey` * **Type**: `String` * **Description**: A Boolean value specifying whether the system should warn if Bluetooth is in the powered-off state when instantiating the peripheral manager. ### `CBPeripheralManagerOptionRestoreIdentifierKey` * **Type**: `String` * **Description**: A unique identifier (UID) with which to instantiate the peripheral manager. ``` -------------------------------- ### GET CBManager.state Source: https://developer.apple.com/documentation/corebluetooth/cbmanager/state Retrieves the current state of the Core Bluetooth manager. ```APIDOC ## GET CBManager.state ### Description The current state of the manager. This state is initially set to CBManagerState.unknown. When the state updates, the manager calls its delegate’s centralManagerDidUpdateState(_:) method. ### Method GET ### Endpoint CBManager.state ### Response #### Success Response (200) - **state** (CBManagerState) - The current state of the manager. ``` -------------------------------- ### GET ancsAuthorized Source: https://developer.apple.com/documentation/corebluetooth/cbperipheral/ancsauthorized Retrieves the authorization status of a remote device for the ANCS protocol. ```APIDOC ## GET ancsAuthorized ### Description A Boolean value that indicates if the remote device has authorization to receive data over the ANCS protocol. ### Method GET ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **ancsAuthorized** (Bool) - Indicates if the remote device has authorization to receive data over ANCS protocol. ### Discussion If this value is false, a user authorization sets this value to true, which results in a call to the delegate’s centralManager(_:didUpdateANCSAuthorizationFor:) method. ``` -------------------------------- ### Initializing a Peripheral Manager Source: https://developer.apple.com/documentation/corebluetooth/peripheral-manager-initialization-options Methods for initializing a peripheral manager. ```APIDOC ### Initializing a Peripheral Manager #### `convenience init()` * **Description**: Initializes the peripheral manager without a delegate. #### `convenience init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?)` * **Description**: Initializes the peripheral manager with a specified delegate and dispatch queue. * **Parameters**: * **delegate** (`any CBPeripheralManagerDelegate`?) - The delegate object to receive peripheral events. * **queue** (`dispatch_queue_t`?) - The dispatch queue for handling peripheral events. #### `init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?)` * **Description**: Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. * **Parameters**: * **delegate** (`any CBPeripheralManagerDelegate`?) - The delegate object to receive peripheral events. * **queue** (`dispatch_queue_t`?) - The dispatch queue for handling peripheral events. * **options** (`[String : Any]`?) - Initialization options for the peripheral manager. ``` -------------------------------- ### CBCentralManager Initialization Options Source: https://developer.apple.com/documentation/corebluetooth/central-manager-initialization-options Keys used to pass options when initializing a central manager. ```APIDOC ## Constants `let CBCentralManagerOptionShowPowerAlertKey: String` A Boolean value that specifies whether the system warns the user if the app instantiates the central manager when Bluetooth service isn’t available. `let CBCentralManagerOptionRestoreIdentifierKey: String` A string containing a unique identifier (UID) for the central manager to instantiate. ``` -------------------------------- ### GET subscribedCentrals Source: https://developer.apple.com/documentation/corebluetooth/cbmutablecharacteristic/subscribedcentrals Retrieves the list of centrals currently subscribed to the characteristic's value. ```APIDOC ## GET subscribedCentrals ### Description A list of centrals that are currently subscribed to the characteristic’s value. The array is empty if the characteristic isn’t configured to support notifications or indications, or if no centrals are currently subscribed. ### Method GET ### Response #### Success Response (200) - **subscribedCentrals** ([CBCentral]?) - An array of CBCentral objects that currently subscribe to the characteristic’s value. ``` -------------------------------- ### GET CBL2CAPChannel.inputStream Source: https://developer.apple.com/documentation/corebluetooth/cbl2capchannel/inputstream Retrieves the input stream used for reading data from the remote peer. ```APIDOC ## GET CBL2CAPChannel.inputStream ### Description The stream used for reading data from the remote peer. ### Property Definition `var inputStream: InputStream! { get }` ### Availability - iOS 11.0+ - iPadOS 11.0+ - Mac Catalyst 13.1+ - macOS 10.13+ - tvOS 11.0+ - visionOS 1.0+ - watchOS 4.0+ ``` -------------------------------- ### Initialize Peripheral Manager with Options Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/init%28%29 Initializes the peripheral manager with a delegate, dispatch queue, and specific initialization options. Use options to customize the manager's behavior upon creation. ```swift init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?) ``` -------------------------------- ### CBAttributePermissions Initialization Source: https://developer.apple.com/documentation/corebluetooth/cbattributepermissions Demonstrates how to create a CBAttributePermissions instance using its raw value. ```APIDOC ### Creating a Permissions Instance `init(rawValue: UInt)` Creates a permissions instance from the provided raw value. ``` -------------------------------- ### CBDescriptor - value Property Source: https://developer.apple.com/documentation/corebluetooth/cbdescriptor/value The value of the descriptor. This property can be read using the get accessor. ```APIDOC ## CBDescriptor - value Property ### Description The value of the descriptor. ### Availability iOS 5.0+ | iPadOS 5.0+ | Mac Catalyst 13.1+ | macOS 10.7+ | tvOS 9.0+ | visionOS 1.0+ | watchOS 2.0+ ### Syntax ```swift var value: Any? { get } ``` ### Discussion The documentation for `CBUUID` details the value types for the various descriptor types. You can read the value of a descriptor by calling the `readValue(for:)` method of the `CBPeripheral` class. You can write the value of a descriptor by calling the `writeValue(_:for:)` method of the `CBPeripheral` class. You can’t, however, use the `writeValue(_:for:)` method to write the value of a client configuration descriptor (`CBUUIDClientCharacteristicConfigurationString`). Instead, you use the `setNotifyValue(_:for:)` method of the `CBPeripheral` class to configure client indications or notifications of a characteristic’s value on a server. ``` -------------------------------- ### Get InputStream Property Source: https://developer.apple.com/documentation/corebluetooth/cbl2capchannel/inputstream Access the InputStream for reading data from the remote peer. This property is read-only. ```swift var inputStream: InputStream! { get } ``` -------------------------------- ### Initializer: init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbattributepermissions/init%28rawvalue%3A%29 Creates a permissions instance from the provided raw value. Available on iOS 6.0+, iPadOS 6.0+, Mac Catalyst 13.1+, macOS 10.9+, tvOS 9.0+, visionOS 1.0+, and watchOS 2.0+. ```APIDOC ## Initializer: init(rawValue:) ### Description Creates a permissions instance from the provided raw value. ### Method Initializer ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### Availability iOS 6.0+ iPadOS 6.0+ Mac Catalyst 13.1+ macOS 10.9+ tvOS 9.0+ visionOS 1.0+ watchOS 2.0+ ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/feature/init%28rawvalue%3A%29 Initializes a new CBCentralManager.Feature instance using a raw UInt value. ```APIDOC ## init(rawValue:) ### Description Creates a central manager feature instance. ### Parameters #### Request Body - **rawValue** (UInt) - Required - The raw value used to initialize the feature instance. ### Request Example init(rawValue: 1) ### Response #### Success Response (200) - **instance** (CBCentralManager.Feature) - The initialized feature object. ``` -------------------------------- ### Initializer: init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbconnectioneventmatchingoption/init%28rawvalue%3A%29 Creates a matching option from the provided raw value. This initializer is available on iOS 5.0+, iPadOS 5.0+, Mac Catalyst 13.0+, macOS 10.10+, tvOS 9.0+, visionOS 1.0+, and watchOS 4.0+. ```APIDOC ## Initializer: init(rawValue:) ### Description Creates a matching option from the provided raw value. ### Method Initializer ### Endpoint N/A (Initializer) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Availability iOS 5.0+ iPadOS 5.0+ Mac Catalyst 13.0+ macOS 10.10+ tvOS 9.0+ visionOS 1.0+ watchOS 4.0+ ### Code Signature ```swift init(rawValue: String) ``` ``` -------------------------------- ### GET canSendWriteWithoutResponse Source: https://developer.apple.com/documentation/corebluetooth/cbperipheral/cansendwritewithoutresponse Retrieves the Boolean value indicating if the remote device can send a write without a response. ```APIDOC ## GET canSendWriteWithoutResponse ### Description A Boolean value that indicates whether the remote device can send a write without a response. ### Method GET ### Endpoint CBPeripheral.canSendWriteWithoutResponse ### Response - **canSendWriteWithoutResponse** (Bool) - Returns true if the device can accept writes without response, false otherwise. ### Discussion If this value is false, flushing all current writes sets the value to true. This also results in a call to the delegate’s peripheralIsReady(toSendWriteWithoutResponse:). ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cberror-swift.struct/code/init%28rawvalue%3A%29 Initializes a CBError instance from a raw integer value. ```APIDOC ## init(rawValue:) ### Description Creates a new CBError instance from the specified raw integer value. ### Method Initializer ### Parameters #### Parameters - **rawValue** (Int) - Required - The raw integer value representing the error code. ### Request Example init?(rawValue: Int) ``` -------------------------------- ### GET authorizationStatus() Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/authorizationstatus%28%29 Retrieves the current authorization status for the app to share data using Bluetooth services while in the background. ```APIDOC ## GET authorizationStatus() ### Description Returns the app’s authorization status for sharing data while in the background. This method does not prompt the user for access; it is used to detect restricted access to hide UI features. ### Method GET ### Return Value - **CBPeripheralManagerAuthorizationStatus** (enum) - A value indicating whether the app has authorization to share data using Bluetooth services while in the background. ``` -------------------------------- ### init(type:primary:) Source: https://developer.apple.com/documentation/corebluetooth/cbmutableservice/init%28type%3Aprimary%3A%29 Initializes a new mutable service with a specified UUID and primary status. ```APIDOC ## init(type:primary:) ### Description Creates a newly initialized mutable service specified by UUID and service type. ### Parameters - **type** (CBUUID) - Required - A 128-bit UUID that identifies the service. - **primary** (Bool) - Required - A Boolean value that indicates whether the type of service is primary (true) or secondary (false). ### Return Value A newly initialized mutable service. ``` -------------------------------- ### Get CBAttribute UUID Source: https://developer.apple.com/documentation/corebluetooth/cbattribute/uuid Retrieve the 128-bit Bluetooth-specific UUID that identifies the attribute. Available on iOS 8.0+ and later. ```swift var uuid: CBUUID { get } ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbmanagerauthorization/init%28rawvalue%3A%29 Initializes a CBManagerAuthorization instance from a raw integer value. ```APIDOC ## init(rawValue:) ### Description Creates a CBManagerAuthorization instance from the specified raw integer value. ### Parameters #### Parameters - **rawValue** (Int) - Required - The raw integer value to initialize the authorization status. ### Request Example init?(rawValue: Int) ``` -------------------------------- ### See Also Source: https://developer.apple.com/documentation/corebluetooth/cbmutablecharacteristic Related classes for services, characteristics, and descriptors in Core Bluetooth. ```APIDOC ## See Also ### Services - `class CBService` A collection of data and associated behaviors that accomplish a function or feature of a device. - `class CBMutableService` A service with writeable property values. - `class CBCharacteristic` A characteristic of a remote peripheral’s service. - `class CBDescriptor` An object that provides further information about a remote peripheral’s characteristic. - `class CBMutableDescriptor` An object that provides additional information about a local peripheral’s characteristic. ``` -------------------------------- ### CBError.Code alreadyAdvertising Source: https://developer.apple.com/documentation/corebluetooth/cberror-swift.struct/connectionfailed Indicates that the peripheral is already advertising. This error occurs if you attempt to start advertising when it's already in progress. ```swift static var alreadyAdvertising: CBError.Code ``` -------------------------------- ### Implement centralManager(_:didConnect:) Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/centralmanager%28_%3Adidconnect%3A%29 Use this method to set the peripheral's delegate and initiate service discovery after a successful connection. ```swift optional func centralManager( _ central: CBCentralManager, didConnect peripheral: CBPeripheral ) ``` -------------------------------- ### init(nsuuid:) Source: https://developer.apple.com/documentation/corebluetooth/cbuuid/init%28nsuuid%3A%29-2amob Creates a Core Bluetooth UUID object from a Foundation UUID object. ```APIDOC ## init(nsuuid:) ### Description Creates a Core Bluetooth UUID object from a Foundation UUID object. ### Method Initializer ### Parameters #### Path Parameters - **theUUID** (UUID) - Required - A UUID represented by an `NSUUID` object. ### Return Value A new `CBUUID` object for the specified UUID. ``` -------------------------------- ### CBDescriptor value Property Source: https://developer.apple.com/documentation/corebluetooth/cbdescriptor/value The value property of a CBDescriptor. This is an observable property that returns the descriptor's value. Use this to get the value of a descriptor. ```swift var value: Any? { get } ``` -------------------------------- ### Publish a Service using add(_:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/add%28_%3A%29 Use this method to publish a service and its associated characteristics and descriptors to the local GATT database. Ensure all included services are published first. The peripheral manager calls the delegate method `peripheralManager(_:didAdd:error:)` upon successful addition. ```swift func add(_ service: CBMutableService) ``` -------------------------------- ### Get Maximum Update Value Length Source: https://developer.apple.com/documentation/corebluetooth/cbcentral/maximumupdatevaluelength Retrieve the maximum data size in bytes that a central can receive in a single notification or indication. This property is read-only. ```swift var maximumUpdateValueLength: Int { get } ``` -------------------------------- ### Initialize CBCentralManager with Delegate, Queue, and Options Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/init%28delegate%3Aqueue%3Aoptions%3A%29 Use this initializer to create a `CBCentralManager` instance, specifying a delegate for event handling, a dispatch queue for event delivery, and optional initialization parameters. ```swift init( delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]? = nil ) ``` -------------------------------- ### See Also Source: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic Related classes for Core Bluetooth services and characteristics. ```APIDOC ## See Also ### Services `class CBService` A collection of data and associated behaviors that accomplish a function or feature of a device. `class CBMutableService` A service with writeable property values. `class CBMutableCharacteristic` A characteristic of a local peripheral’s service. `class CBDescriptor` An object that provides further information about a remote peripheral’s characteristic. `class CBMutableDescriptor` An object that provides additional information about a local peripheral’s characteristic. ``` -------------------------------- ### Get Core Bluetooth errorDomain Source: https://developer.apple.com/documentation/corebluetooth/cbatterror-swift.struct/errordomain Retrieve the error domain string for Core Bluetooth errors. This property is available across multiple Apple platforms. ```swift static var errorDomain: String { get } ``` -------------------------------- ### Initialize CBAttributePermissions with raw value Source: https://developer.apple.com/documentation/corebluetooth/cbattributepermissions/init%28rawvalue%3A%29 Creates a permissions instance using a raw UInt value. Available across all Apple platforms starting from iOS 6.0. ```swift init(rawValue: UInt) ``` -------------------------------- ### CBPeripheral discoverServices(_:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheral/discoverservices%28_%3A%29 Discovers the specified services of the peripheral. ```APIDOC ## discoverServices(_:) ### Description Discovers the specified services of the peripheral. If the serviceUUIDs parameter is nil, this method returns all of the peripheral’s available services. ### Method Instance Method ### Parameters #### Path Parameters - **serviceUUIDs** ([CBUUID]?) - Optional - An array of CBUUID objects that you are interested in. Each CBUUID object represents a UUID that identifies the type of service you want to discover. ### Request Example func discoverServices([CBUUID(string: "180D")]) ### Response - The peripheral calls the peripheral(_:didDiscoverServices:) method of its delegate object upon discovery. ``` -------------------------------- ### Get Maximum Write Value Length Source: https://developer.apple.com/documentation/corebluetooth/cbperipheral/writevalue%28_%3Afor%3A%29 Retrieves the maximum amount of data, in bytes, that can be sent to a characteristic in a single write operation, based on the specified write type. ```swift func maximumWriteValueLength(for: CBCharacteristicWriteType) -> Int ``` -------------------------------- ### init(rawValue:) Initializer Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerauthorizationstatus/init%28rawvalue%3A%29 Documentation for the deprecated init(rawValue:) initializer for CBPeripheralManagerAuthorizationStatus. ```APIDOC ## init(rawValue:) ### Description Initializes a CBPeripheralManagerAuthorizationStatus instance from a raw integer value. This method is deprecated. ### Method Initializer ### Parameters #### Parameters - **rawValue** (Int) - Required - The raw integer value to initialize the status from. ### Request Example let status = CBPeripheralManagerAuthorizationStatus(rawValue: 0) ``` -------------------------------- ### Peripheral Manager Initialization Option Keys Source: https://developer.apple.com/documentation/corebluetooth/peripheral-manager-initialization-options Keys used to configure the behavior of a peripheral manager during instantiation. ```swift let CBPeripheralManagerOptionShowPowerAlertKey: String ``` ```swift let CBPeripheralManagerOptionRestoreIdentifierKey: String ``` -------------------------------- ### Handle Characteristic Subscription Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/peripheralmanager%28_%3Acentral%3Adidsubscribeto%3A%29 Implement this method to be notified when a remote central subscribes to a characteristic's value. Start sending updates to the subscribed central using `updateValue(_:for:onSubscribedCentrals:)`. ```swift optional func peripheralManager( _ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic ) ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralstate/init%28rawvalue%3A%29 Initializes a CBPeripheralState instance from a raw integer value. ```APIDOC ## init(rawValue:) ### Description Creates a CBPeripheralState instance from the specified raw integer value. ### Parameters #### Parameters - **rawValue** (Int) - Required - The raw integer value representing the peripheral state. ### Request Example init?(rawValue: 0) ### Response #### Success Response - **instance** (CBPeripheralState) - An optional instance of CBPeripheralState if the raw value is valid. ``` -------------------------------- ### CBError.Code.encryptionTimedOut Source: https://developer.apple.com/documentation/corebluetooth/cberror-swift.struct/encryptiontimedout The `encryptionTimedOut` property represents an error code indicating that the Bluetooth encryption process timed out. This is available on iOS, iPadOS, macOS, tvOS, and watchOS starting from specific versions. ```APIDOC ## CBError.Code.encryptionTimedOut ### Description Indicates that the Bluetooth encryption process timed out. ### Availability iOS 13.4+ iPadOS 13.4+ Mac Catalyst 13.4+ macOS 10.15+ tvOS 13.4+ visionOS 1.0+ watchOS 6.2+ ### Type `static var encryptionTimedOut: CBError.Code { get }` ``` -------------------------------- ### CBPeripheralManager Initialization Source: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager Methods to initialize the peripheral manager with a delegate and dispatch queue. ```APIDOC ## Initializing CBPeripheralManager ### Description Initializes a new peripheral manager object to handle Bluetooth peripheral operations. ### Methods - `init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?)` - `convenience init()` ### Parameters - **delegate** (any CBPeripheralManagerDelegate?) - Optional - The delegate object to receive peripheral events. - **queue** (dispatch_queue_t?) - Optional - The dispatch queue to use for delegate methods. - **options** ([String : Any]?) - Optional - Initialization options for the peripheral manager. ``` -------------------------------- ### Get Peripheral Connection State Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralstate Access the current connection state of a peripheral. This property returns a CBPeripheralState value indicating whether the peripheral is connected, disconnected, or in the process of connecting or disconnecting. ```swift var state: CBPeripheralState ``` -------------------------------- ### Initializing a Peripheral Manager Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/delegate Methods for initializing a CBPeripheralManager instance, with options for specifying a delegate, dispatch queue, and initialization options. ```APIDOC ## Initializing a Peripheral Manager ### `convenience init()` Initializes the peripheral manager without a delegate. ### `convenience init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?)` Initializes the peripheral manager with a specified delegate and dispatch queue. ### `init(delegate: (any CBPeripheralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?)` Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options. ### Peripheral Manager Initialization Options Keys used to specify options when creating a peripheral manager. ``` -------------------------------- ### Get CBCharacteristic Properties Source: https://developer.apple.com/documentation/corebluetooth/cbmutablecharacteristic/properties Accesses the properties of a characteristic. These properties define the characteristic's capabilities, such as read, write, or broadcast. Note that 'broadcast' and 'extendedProperties' cannot be used when creating a mutable characteristic. ```swift var properties: CBCharacteristicProperties { get set } ``` -------------------------------- ### Get encryptionTimedOut Error Code Source: https://developer.apple.com/documentation/corebluetooth/cberror-swift.struct/encryptiontimedout Use this static property to check for encryption timeouts. Available on iOS 13.4+, iPadOS 13.4+, macOS 10.15+, tvOS 13.4+, and watchOS 6.2+. ```swift static var encryptionTimedOut: CBError.Code { get } ``` -------------------------------- ### Initializing a Central Manager Source: https://developer.apple.com/documentation/corebluetooth/central-manager-initialization-options Convenience initializers for CBCentralManager. ```APIDOC ### Initializing a Central Manager `convenience init()` Initializes the central manager without a delegate. `convenience init(delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t?)` Initializes the central manager with a specified delegate and dispatch queue. `init(delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?)` Initializes the central manager with specified delegate, dispatch queue, and initialization options. ``` -------------------------------- ### Get the PSM of a CBL2CAPChannel Source: https://developer.apple.com/documentation/corebluetooth/cbl2capchannel/psm Access the Protocol Service Multiplexer (PSM) of the channel. Available on iOS 11.0+, iPadOS 11.0+, macOS 10.13+, tvOS 11.0+, watchOS 4.0+, and visionOS 1.0+. ```swift var psm: CBL2CAPPSM { get } ``` -------------------------------- ### Get Core Bluetooth Authorization Status Source: https://developer.apple.com/documentation/corebluetooth/cbmanager/authorization-swift.type.property Access this property to determine if your app is authorized to use Core Bluetooth. Check this status in delegate methods or before creating a manager instance. The initial value is `CBManagerAuthorization.notDetermined`. ```swift class var authorization: CBManagerAuthorization { get } ``` -------------------------------- ### Initialize CBCentralManager with Delegate and Queue Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/init%28delegate%3Aqueue%3A%29 Use this initializer to create a CBCentralManager instance. Provide a delegate to receive Bluetooth events and a dispatch queue for event handling. If the queue is nil, events are dispatched on the main queue. ```swift convenience init( delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t? ) ``` -------------------------------- ### Get Peripheral RSSI Source: https://developer.apple.com/documentation/corebluetooth/cbperipheral/rssi Retrieves the Received Signal Strength Indicator (RSSI) of a connected peripheral. This property is deprecated and its value is updated by calling `readRSSI()` and receiving the result in the delegate method `peripheral(_:didReadRSSI:error:)`. ```swift var rssi: NSNumber? { get } ``` -------------------------------- ### Core Bluetooth Connection Options Reference Source: https://developer.apple.com/documentation/corebluetooth/cbconnectperipheraloptionnotifyonconnectionkey Additional configuration keys for peripheral connections. ```APIDOC ## Related Connection Options - **CBConnectPeripheralOptionEnableAutoReconnect**: A Boolean value that specifies whether the system automatically reconnects with a peripheral. - **CBConnectPeripheralOptionEnableTransportBridgingKey**: An option to bridge classic Bluetooth technology profiles, if already connected over Bluetooth Low Energy. - **CBConnectPeripheralOptionNotifyOnDisconnectionKey**: A Boolean value that specifies whether the system should display an alert when disconnecting a peripheral in the background. - **CBConnectPeripheralOptionNotifyOnNotificationKey**: A Boolean value that specifies whether the system should display an alert for any notification sent by a peripheral. - **CBConnectPeripheralOptionRequiresANCS**: An option to require Apple Notification Center Service (ANCS) when connecting a device. - **CBConnectPeripheralOptionStartDelayKey**: An option that indicates a delay before the system makes a connection. ``` -------------------------------- ### CBL2CAPPSM Type Alias Source: https://developer.apple.com/documentation/corebluetooth/cbl2cappsm Defines the CBL2CAPPSM type alias, which is used to identify Protocol/Service Multiplexer (PSM) values for L2CAP channels. This type is available across multiple Apple platforms starting from specific OS versions. ```APIDOC ## Type Alias: CBL2CAPPSM ### Description The type of PSM identifiers. ### Platforms iOS 5.0+ | iPadOS 5.0+ | Mac Catalyst 13.0+ | macOS 10.10+ | tvOS 9.0+ | visionOS 1.0+ | watchOS 4.0+ ### Code ```swift typealias CBL2CAPPSM = UInt16 ``` ### See Also - **Working with L2CAP Channels** - `func openL2CAPChannel(CBL2CAPPSM)`: Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM). - `class CBL2CAPChannel`: A live L2CAP connection to a remote device. ``` -------------------------------- ### Get UUID as String - CBUUID uuidString Source: https://developer.apple.com/documentation/corebluetooth/cbuuid/uuidstring Access the UUID represented as a string. Available on iOS 7.1+, iPadOS 7.1+, Mac Catalyst 13.1+, macOS 10.10+, tvOS 9.0+, visionOS 1.0+, and watchOS 2.0+. ```swift var uuidString: String { get } ``` -------------------------------- ### Core Bluetooth Connection Options Reference Source: https://developer.apple.com/documentation/corebluetooth/cbconnectperipheraloptionstartdelaykey Additional configuration keys for peripheral connection management. ```APIDOC ## Connection Options - **CBConnectPeripheralOptionEnableAutoReconnect**: A Boolean value that specifies whether the system automatically reconnects with a peripheral. - **CBConnectPeripheralOptionEnableTransportBridgingKey**: An option to bridge classic Bluetooth technology profiles, if already connected over Bluetooth Low Energy. - **CBConnectPeripheralOptionNotifyOnConnectionKey**: A Boolean value that specifies whether the system should display an alert when connecting a peripheral in the background. - **CBConnectPeripheralOptionNotifyOnDisconnectionKey**: A Boolean value that specifies whether the system should display an alert when disconnecting a peripheral in the background. - **CBConnectPeripheralOptionNotifyOnNotificationKey**: A Boolean value that specifies whether the system should display an alert for any notification sent by a peripheral. - **CBConnectPeripheralOptionRequiresANCS**: An option to require Apple Notification Center Service (ANCS) when connecting a device. ``` -------------------------------- ### Access CBDescriptor's Parent Characteristic Source: https://developer.apple.com/documentation/corebluetooth/cbdescriptor/characteristic Use this property to get the CBCharacteristic object to which this descriptor belongs. Available on iOS 5.0+, iPadOS 5.0+, Mac Catalyst 13.1+, macOS 10.7+, tvOS 9.0+, visionOS 1.0+, and watchOS 2.0+. ```swift weak var characteristic: CBCharacteristic? { get } ``` -------------------------------- ### Connect to a Peripheral Source: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/connect%28_%3Aoptions%3A%29 Establishes a local connection to a specified peripheral with optional connection parameters. ```swift func connect( _ peripheral: CBPeripheral, options: [String : Any]? = nil ) ``` -------------------------------- ### CBPeripheralManagerDelegate - peripheralManager(_:central:didSubscribeTo:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/peripheralmanager%28_%3Acentral%3Adidsubscribeto%3A%29 Tells the delegate that a remote central device subscribed to a characteristic’s value. This method is called when a central enables notifications or indications for a characteristic. You should start sending updated values to the subscribed central using `updateValue(_:for:onSubscribedCentrals:)`. ```APIDOC ## peripheralManager(_:central:didSubscribeTo:) ### Description Tells the delegate that a remote central device subscribed to a characteristic’s value. ### Method `optional func peripheralManager( _ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic )` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example * Not applicable for delegate methods. ### Response #### Success Response (200) * Not applicable for delegate methods. #### Response Example * Not applicable for delegate methods. ### Discussion Core Bluetooth invokes this method when a remote central device subscribes to the value of one of the local peripheral’s characteristics, by enabling notifications or indications on the characteristic’s value. When called, start sending the subscribed central updates as the characteristic’s value changes. To send updated characteristic values to subscribed centrals, use the `updateValue(_:for:onSubscribedCentrals:)` method of the `CBPeripheralManager` class. ### See Also * `func peripheralManager(CBPeripheralManager, central: CBCentral, didUnsubscribeFrom: CBCharacteristic)` * `func peripheralManagerIsReady(toUpdateSubscribers: CBPeripheralManager)` ``` -------------------------------- ### publishL2CAPChannel(withEncryption:) Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/publishl2capchannel%28withencryption%3A%29 Creates a listener for incoming L2CAP channel connections. ```APIDOC ## publishL2CAPChannel(withEncryption:) ### Description Creates a listener for incoming L2CAP channel connections. The system determines an unused Protocol and Service Multiplexer (PSM) at the time of publishing and provides it to the app via the peripheralManager(_:didPublishL2CAPChannel:error:) delegate method. ### Method Instance Method ### Parameters #### Parameters - **encryptionRequired** (Bool) - Required - true if the service requires link encryption before a stream can be established. false if the service supports use over an unsecured link. ### Request Example func publishL2CAPChannel(withEncryption encryptionRequired: Bool) ``` -------------------------------- ### init(string:) Source: https://developer.apple.com/documentation/corebluetooth/cbuuid/init%28string%3A%29 Initializes a CBUUID object using a string representation of a UUID. ```APIDOC ## init(string:) ### Description Creates a Core Bluetooth UUID object from a 16-, 32-, or 128-bit UUID string. ### Parameters #### Path Parameters - **theString** (String) - Required - A string containing a 16-, 32-, or 128-bit UUID. ### Return Value A new CBUUID object for the specified UUID string. ### Discussion Specify 128-bit UUIDs as a string of hexadecimal digits punctuated by hyphens (e.g., 68753A44-4D6F-1226-9C60-0050E4C00067). Specify 16- or 32-bit UUIDs as a string of 4 or 8 hexadecimal digits, respectively. ``` -------------------------------- ### Get Bluetooth Authorization Status Source: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager/authorizationstatus%28%29 Use this class method to retrieve the app's current authorization status for sharing data using Bluetooth services while in the background. This method does not prompt the user for access; it is intended for detecting restricted access and hiding relevant UI elements. ```swift class func authorizationStatus() -> CBPeripheralManagerAuthorizationStatus ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/corebluetooth/cbmanagerstate/init%28rawvalue%3A%29 Initializes a CBManagerState instance from a raw integer value. ```APIDOC ## init(rawValue:) ### Description Creates a CBManagerState instance from the specified raw integer value. ### Parameters #### Parameters - **rawValue** (Int) - Required - The raw integer value representing the state. ### Request Example init?(rawValue: Int) ``` -------------------------------- ### scanForPeripherals(withServices:options:) Source: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/scanForPeripherals%28withServices%3Aoptions%3A%29 Scans for peripherals that are advertising services. ```APIDOC ## scanForPeripherals(withServices:options:) ### Description Scans for peripherals that are advertising services. When serviceUUIDs are provided, the central manager returns only peripherals that advertise those services. ### Method Instance Method ### Parameters #### Path Parameters - **serviceUUIDs** ([CBUUID]?) - Optional - An array of CBUUID objects that the app is interested in. - **options** ([String : Any]?) - Optional - A dictionary of options for customizing the scan. ### Request Example func scanForPeripherals( withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil ) ```