Documentation
¶
Overview ¶
Package corebluetooth provides Go bindings for the CoreBluetooth framework.
Communicate with Bluetooth low energy and BR/EDR (“Classic”) Devices.
The Core Bluetooth framework provides the classes needed for your apps to communicate with Bluetooth-equipped low energy (LE) and Basic Rate / Enhanced Data Rate (BR/EDR) wireless technology.
Centrals ¶
- CBCentral: A remote device connected to a local app, which is acting as a peripheral.
- CBCentralManager: An object that scans for, discovers, connects to, and manages peripherals. (CBConnectionEvent, CBConnectionEventMatchingOption)
- CBCentralManagerDelegate: A protocol that provides updates for the discovery and management of peripheral devices.
Peripherals ¶
- CBPeripheral: A remote peripheral device. (CBCharacteristicWriteType, CBPeripheralState, CBL2CAPChannel, CBL2CAPPSM)
- CBPeripheralDelegate: A protocol that provides updates on the use of a peripheral’s services.
- CBPeripheralManager: An object that manages and advertises peripheral services exposed by this app. (CBPeripheralManagerAuthorizationStatus, CBPeripheralManagerState, CBPeripheralManagerConnectionLatency)
- 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.
Channel Sounding ¶
Services ¶
- CBService: A collection of data and associated behaviors that accomplish a function or feature of a device.
- CBMutableService: A service with writeable property values.
- CBCharacteristic: A characteristic of a remote peripheral’s service. (CBCharacteristicProperties)
- CBMutableCharacteristic: A characteristic of a local peripheral’s service. (CBAttributePermissions)
- CBDescriptor: An object that provides further information about a remote peripheral’s characteristic.
- CBMutableDescriptor: An object that provides additional information about a local peripheral’s characteristic.
Supporting Types ¶
- CBManager: The abstract base class that manages central and peripheral objects. (CBManagerState, CBManagerAuthorization)
- CBATTRequest: A request that uses the Attribute Protocol (ATT).
- CBPeer: An object that represents a remote device.
- CBUUID: A universally unique identifier, as defined by Bluetooth standards.
Bluetooth Classic Support ¶
- Using Core Bluetooth Classic: Discover and communicate with a Bluetooth Classic device by using the Core Bluetooth APIs.
Errors ¶
- CBErrorDomain: The domain for Core Bluetooth errors.
- CBError: The codes for errors that Core Bluetooth returns during Bluetooth transactions.
- CBATTErrorDomain: The domain for Core Bluetooth ATT errors.
- CBATTError: The possible errors returned by a GATT server (a remote peripheral) during Bluetooth low energy ATT transactions.
Enumerations ¶
Key Types ¶
- CBPeripheral - A remote peripheral device.
- CBPeripheralManager - An object that manages and advertises peripheral services exposed by this app.
- CBCentralManager - An object that scans for, discovers, connects to, and manages peripherals.
- CBMutableCharacteristic - A characteristic of a local peripheral’s service.
- CBCharacteristic - A characteristic of a remote peripheral’s service.
- CBUUID - A universally unique identifier, as defined by Bluetooth standards.
- CBATTRequest - A request that uses the Attribute Protocol (ATT).
- CBL2CAPChannel - A live L2CAP connection to a remote device.
- CBService - A collection of data and associated behaviors that accomplish a function or feature of a device.
- CBMutableService - A service with writeable property values.
Code generated from Apple documentation. DO NOT EDIT.
Index ¶
- Variables
- type CBATTError
- type CBATTRequest
- func (c CBATTRequest) Autorelease() CBATTRequest
- func (c CBATTRequest) Central() ICBCentral
- func (c CBATTRequest) Characteristic() ICBCharacteristic
- func (c CBATTRequest) Init() CBATTRequest
- func (c CBATTRequest) Offset() uint
- func (c CBATTRequest) SetValue(value foundation.NSData)
- func (c CBATTRequest) Value() foundation.NSData
- type CBATTRequestClass
- type CBAttribute
- type CBAttributeClass
- type CBAttributePermissions
- type CBCentral
- type CBCentralClass
- type CBCentralManager
- func CBCentralManagerFromID(id objc.ID) CBCentralManager
- func NewCBCentralManager() CBCentralManager
- func NewCBCentralManagerWithDelegateQueue(delegate CBCentralManagerDelegate, queue dispatch.Queue) CBCentralManager
- func NewCBCentralManagerWithDelegateQueueOptions(delegate CBCentralManagerDelegate, queue dispatch.Queue, ...) CBCentralManager
- func (c CBCentralManager) Autorelease() CBCentralManager
- func (c CBCentralManager) CancelPeripheralConnection(peripheral ICBPeripheral)
- func (c CBCentralManager) ConnectPeripheralOptions(peripheral ICBPeripheral, options foundation.INSDictionary)
- func (c CBCentralManager) Delegate() CBCentralManagerDelegate
- func (c CBCentralManager) Init() CBCentralManager
- func (c CBCentralManager) InitWithDelegateQueue(delegate CBCentralManagerDelegate, queue dispatch.Queue) CBCentralManager
- func (c CBCentralManager) InitWithDelegateQueueOptions(delegate CBCentralManagerDelegate, queue dispatch.Queue, ...) CBCentralManager
- func (c CBCentralManager) IsScanning() bool
- func (c CBCentralManager) RetrieveConnectedPeripheralsWithServices(serviceUUIDs []CBUUID) []CBPeripheral
- func (c CBCentralManager) RetrievePeripheralsWithIdentifiers(identifiers []foundation.NSUUID) []CBPeripheral
- func (c CBCentralManager) ScanForPeripheralsWithServicesOptions(serviceUUIDs []CBUUID, options foundation.INSDictionary)
- func (c CBCentralManager) SetDelegate(value CBCentralManagerDelegate)
- func (c CBCentralManager) StopScan()
- type CBCentralManagerClass
- type CBCentralManagerDelegate
- type CBCentralManagerDelegateConfig
- type CBCentralManagerDelegateObject
- func (o CBCentralManagerDelegateObject) BaseObject() objectivec.Object
- func (o CBCentralManagerDelegateObject) CentralManagerConnectionEventDidOccurForPeripheral(central ICBCentralManager, event CBConnectionEvent, peripheral ICBPeripheral)
- func (o CBCentralManagerDelegateObject) CentralManagerDidConnectPeripheral(central ICBCentralManager, peripheral ICBPeripheral)
- func (o CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralError(central ICBCentralManager, peripheral ICBPeripheral, error_ foundation.NSError)
- func (o CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralTimestampIsReconnectingError(central ICBCentralManager, peripheral ICBPeripheral, ...)
- func (o CBCentralManagerDelegateObject) CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI(central ICBCentralManager, peripheral ICBPeripheral, ...)
- func (o CBCentralManagerDelegateObject) CentralManagerDidFailToConnectPeripheralError(central ICBCentralManager, peripheral ICBPeripheral, error_ foundation.NSError)
- func (o CBCentralManagerDelegateObject) CentralManagerDidUpdateANCSAuthorizationForPeripheral(central ICBCentralManager, peripheral ICBPeripheral)
- func (o CBCentralManagerDelegateObject) CentralManagerDidUpdateState(central ICBCentralManager)
- func (o CBCentralManagerDelegateObject) CentralManagerWillRestoreState(central ICBCentralManager, dict foundation.INSDictionary)
- type CBCentralManagerFeature
- type CBCentralManagerState
- type CBChannelSoundingSessionConfigurationRole
- type CBCharacteristic
- func (c CBCharacteristic) Autorelease() CBCharacteristic
- func (c CBCharacteristic) Descriptors() []CBDescriptor
- func (c CBCharacteristic) Init() CBCharacteristic
- func (c CBCharacteristic) IsNotifying() bool
- func (c CBCharacteristic) Properties() CBCharacteristicProperties
- func (c CBCharacteristic) Service() ICBService
- func (c CBCharacteristic) Value() foundation.NSData
- type CBCharacteristicClass
- type CBCharacteristicProperties
- type CBCharacteristicWriteType
- type CBConnectionEvent
- type CBConnectionEventMatchingOption
- type CBDescriptor
- type CBDescriptorClass
- type CBError
- type CBL2CAPChannel
- func (c CBL2CAPChannel) Autorelease() CBL2CAPChannel
- func (c CBL2CAPChannel) Init() CBL2CAPChannel
- func (c CBL2CAPChannel) InputStream() foundation.InputStream
- func (c CBL2CAPChannel) OutputStream() foundation.OutputStream
- func (c CBL2CAPChannel) PSM() CBL2CAPPSM
- func (c CBL2CAPChannel) Peer() ICBPeer
- type CBL2CAPChannelClass
- type CBL2CAPPSM
- type CBManager
- type CBManagerAuthorization
- type CBManagerClass
- type CBManagerState
- type CBMutableCharacteristic
- func CBMutableCharacteristicFromID(id objc.ID) CBMutableCharacteristic
- func NewCBMutableCharacteristic() CBMutableCharacteristic
- func NewCBMutableCharacteristicWithTypePropertiesValuePermissions(UUID ICBUUID, properties CBCharacteristicProperties, value foundation.NSData, ...) CBMutableCharacteristic
- func (c CBMutableCharacteristic) Autorelease() CBMutableCharacteristic
- func (c CBMutableCharacteristic) Init() CBMutableCharacteristic
- func (c CBMutableCharacteristic) InitWithTypePropertiesValuePermissions(UUID ICBUUID, properties CBCharacteristicProperties, value foundation.NSData, ...) CBMutableCharacteristic
- func (c CBMutableCharacteristic) Permissions() CBAttributePermissions
- func (c CBMutableCharacteristic) SetPermissions(value CBAttributePermissions)
- func (c CBMutableCharacteristic) SubscribedCentrals() []CBCentral
- type CBMutableCharacteristicClass
- type CBMutableDescriptor
- type CBMutableDescriptorClass
- type CBMutableService
- type CBMutableServiceClass
- type CBPeer
- type CBPeerClass
- type CBPeripheral
- func (c CBPeripheral) Autorelease() CBPeripheral
- func (c CBPeripheral) CanSendWriteWithoutResponse() bool
- func (c CBPeripheral) Delegate() CBPeripheralDelegate
- func (c CBPeripheral) DiscoverCharacteristicsForService(characteristicUUIDs []CBUUID, service ICBService)
- func (c CBPeripheral) DiscoverDescriptorsForCharacteristic(characteristic ICBCharacteristic)
- func (c CBPeripheral) DiscoverIncludedServicesForService(includedServiceUUIDs []CBUUID, service ICBService)
- func (c CBPeripheral) DiscoverServices(serviceUUIDs []CBUUID)
- func (c CBPeripheral) Init() CBPeripheral
- func (c CBPeripheral) MaximumWriteValueLengthForType(type_ CBCharacteristicWriteType) uint
- func (c CBPeripheral) Name() string
- func (c CBPeripheral) OpenL2CAPChannel(PSM CBL2CAPPSM)
- func (c CBPeripheral) ReadRSSI()
- func (c CBPeripheral) ReadValueForCharacteristic(characteristic ICBCharacteristic)
- func (c CBPeripheral) ReadValueForDescriptor(descriptor ICBDescriptor)
- func (c CBPeripheral) Services() []CBService
- func (c CBPeripheral) SetDelegate(value CBPeripheralDelegate)
- func (c CBPeripheral) SetNotifyValueForCharacteristic(enabled bool, characteristic ICBCharacteristic)
- func (c CBPeripheral) State() CBPeripheralState
- func (c CBPeripheral) WriteValueForCharacteristicType(data foundation.NSData, characteristic ICBCharacteristic, ...)
- func (c CBPeripheral) WriteValueForDescriptor(data foundation.NSData, descriptor ICBDescriptor)
- type CBPeripheralClass
- type CBPeripheralDelegate
- type CBPeripheralDelegateConfig
- type CBPeripheralDelegateObject
- func (o CBPeripheralDelegateObject) BaseObject() objectivec.Object
- func (o CBPeripheralDelegateObject) PeripheralDidCompleteChannelSoundingSession(peripheral ICBPeripheral, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidDiscoverCharacteristicsForServiceError(peripheral ICBPeripheral, service ICBService, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidDiscoverDescriptorsForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, ...)
- func (o CBPeripheralDelegateObject) PeripheralDidDiscoverIncludedServicesForServiceError(peripheral ICBPeripheral, service ICBService, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidDiscoverServices(peripheral ICBPeripheral, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidModifyServices(peripheral ICBPeripheral, invalidatedServices []CBService)
- func (o CBPeripheralDelegateObject) PeripheralDidOpenL2CAPChannelError(peripheral ICBPeripheral, channel ICBL2CAPChannel, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidReadRSSIError(peripheral ICBPeripheral, RSSI foundation.NSNumber, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidReceiveChannelSoundingProcedureResultsError(peripheral ICBPeripheral, results *uintptr, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidUpdateName(peripheral ICBPeripheral)
- func (o CBPeripheralDelegateObject) PeripheralDidUpdateNotificationStateForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, ...)
- func (o CBPeripheralDelegateObject) PeripheralDidUpdateValueForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, ...)
- func (o CBPeripheralDelegateObject) PeripheralDidUpdateValueForDescriptorError(peripheral ICBPeripheral, descriptor ICBDescriptor, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralDidWriteValueForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, ...)
- func (o CBPeripheralDelegateObject) PeripheralDidWriteValueForDescriptorError(peripheral ICBPeripheral, descriptor ICBDescriptor, error_ foundation.NSError)
- func (o CBPeripheralDelegateObject) PeripheralIsReadyToSendWriteWithoutResponse(peripheral ICBPeripheral)
- type CBPeripheralManager
- func CBPeripheralManagerFromID(id objc.ID) CBPeripheralManager
- func NewCBPeripheralManager() CBPeripheralManager
- func NewCBPeripheralManagerWithDelegateQueue(delegate CBPeripheralManagerDelegate, queue dispatch.Queue) CBPeripheralManager
- func NewCBPeripheralManagerWithDelegateQueueOptions(delegate CBPeripheralManagerDelegate, queue dispatch.Queue, ...) CBPeripheralManager
- func (c CBPeripheralManager) AddService(service ICBMutableService)
- func (c CBPeripheralManager) Autorelease() CBPeripheralManager
- func (c CBPeripheralManager) Delegate() CBPeripheralManagerDelegate
- func (c CBPeripheralManager) Init() CBPeripheralManager
- func (c CBPeripheralManager) InitWithDelegateQueue(delegate CBPeripheralManagerDelegate, queue dispatch.Queue) CBPeripheralManager
- func (c CBPeripheralManager) InitWithDelegateQueueOptions(delegate CBPeripheralManagerDelegate, queue dispatch.Queue, ...) CBPeripheralManager
- func (c CBPeripheralManager) IsAdvertising() bool
- func (c CBPeripheralManager) PublishL2CAPChannelWithEncryption(encryptionRequired bool)
- func (c CBPeripheralManager) RemoveAllServices()
- func (c CBPeripheralManager) RemoveService(service ICBMutableService)
- func (c CBPeripheralManager) RespondToRequestWithResult(request ICBATTRequest, result CBATTError)
- func (c CBPeripheralManager) SetDelegate(value CBPeripheralManagerDelegate)
- func (c CBPeripheralManager) SetDesiredConnectionLatencyForCentral(latency CBPeripheralManagerConnectionLatency, central ICBCentral)
- func (c CBPeripheralManager) StartAdvertising(advertisementData foundation.INSDictionary)
- func (c CBPeripheralManager) StopAdvertising()
- func (c CBPeripheralManager) UnpublishL2CAPChannel(PSM CBL2CAPPSM)
- func (c CBPeripheralManager) UpdateValueForCharacteristicOnSubscribedCentrals(value foundation.NSData, characteristic ICBMutableCharacteristic, ...) bool
- type CBPeripheralManagerAuthorizationStatus
- type CBPeripheralManagerClass
- type CBPeripheralManagerConnectionLatency
- type CBPeripheralManagerDelegate
- type CBPeripheralManagerDelegateConfig
- type CBPeripheralManagerDelegateObject
- func (o CBPeripheralManagerDelegateObject) BaseObject() objectivec.Object
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidSubscribeToCharacteristic(peripheral ICBPeripheralManager, central ICBCentral, ...)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidUnsubscribeFromCharacteristic(peripheral ICBPeripheralManager, central ICBCentral, ...)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidAddServiceError(peripheral ICBPeripheralManager, service ICBService, error_ foundation.NSError)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidOpenL2CAPChannelError(peripheral ICBPeripheralManager, channel ICBL2CAPChannel, ...)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidPublishL2CAPChannelError(peripheral ICBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveReadRequest(peripheral ICBPeripheralManager, request ICBATTRequest)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveWriteRequests(peripheral ICBPeripheralManager, requests []CBATTRequest)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidStartAdvertisingError(peripheral ICBPeripheralManager, error_ foundation.NSError)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidUnpublishL2CAPChannelError(peripheral ICBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidUpdateState(peripheral ICBPeripheralManager)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerIsReadyToUpdateSubscribers(peripheral ICBPeripheralManager)
- func (o CBPeripheralManagerDelegateObject) PeripheralManagerWillRestoreState(peripheral ICBPeripheralManager, dict foundation.INSDictionary)
- type CBPeripheralManagerState
- type CBPeripheralState
- type CBService
- type CBServiceClass
- type CBUUID
- type CBUUIDClass
- type ICBATTRequest
- type ICBAttribute
- type ICBCentral
- type ICBCentralManager
- type ICBCharacteristic
- type ICBDescriptor
- type ICBL2CAPChannel
- type ICBManager
- type ICBMutableCharacteristic
- type ICBMutableDescriptor
- type ICBMutableService
- type ICBPeer
- type ICBPeripheral
- type ICBPeripheralManager
- type ICBService
- type ICBUUID
Constants ¶
This section is empty.
Variables ¶
var ( // CBATTErrorDomain is the domain for Core Bluetooth ATT errors. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBATTErrorDomain CBATTErrorDomain string // CBAdvertisementDataIsConnectable is a Boolean value that indicates whether the advertising event type is connectable. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataIsConnectable CBAdvertisementDataIsConnectable string // CBAdvertisementDataLocalNameKey is the local name of a peripheral. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataLocalNameKey CBAdvertisementDataLocalNameKey string // CBAdvertisementDataManufacturerDataKey is the manufacturer data of a peripheral. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataManufacturerDataKey CBAdvertisementDataManufacturerDataKey string // CBAdvertisementDataOverflowServiceUUIDsKey is an array of UUIDs found in the overflow area of the advertisement data. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataOverflowServiceUUIDsKey CBAdvertisementDataOverflowServiceUUIDsKey string // CBAdvertisementDataServiceDataKey is a dictionary that contains service-specific advertisement data. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataServiceDataKey CBAdvertisementDataServiceDataKey string // CBAdvertisementDataServiceUUIDsKey is an array of service UUIDs. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataServiceUUIDsKey CBAdvertisementDataServiceUUIDsKey string // CBAdvertisementDataSolicitedServiceUUIDsKey is an array of solicited service UUIDs. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataSolicitedServiceUUIDsKey CBAdvertisementDataSolicitedServiceUUIDsKey string // CBAdvertisementDataTxPowerLevelKey is the transmit power of a peripheral. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBAdvertisementDataTxPowerLevelKey CBAdvertisementDataTxPowerLevelKey string // CBCentralManagerOptionRestoreIdentifierKey is a string containing a unique identifier (UID) for the central manager to instantiate. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerOptionRestoreIdentifierKey CBCentralManagerOptionRestoreIdentifierKey string // CBCentralManagerOptionShowPowerAlertKey is a Boolean value that specifies whether the system warns the user if the app instantiates the central manager when Bluetooth service isn’t available. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerOptionShowPowerAlertKey CBCentralManagerOptionShowPowerAlertKey string // CBCentralManagerRestoredStatePeripheralsKey is an array of peripherals for use when restoring the state of a central manager. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerRestoredStatePeripheralsKey CBCentralManagerRestoredStatePeripheralsKey string // CBCentralManagerRestoredStateScanOptionsKey is a dictionary of peripheral scan options for use when restoring state. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerRestoredStateScanOptionsKey CBCentralManagerRestoredStateScanOptionsKey string // CBCentralManagerRestoredStateScanServicesKey is an array of service IDs for use when restoring state. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerRestoredStateScanServicesKey CBCentralManagerRestoredStateScanServicesKey string // CBCentralManagerScanOptionAllowDuplicatesKey is a Boolean value that specifies whether the scan should run without duplicate filtering. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerScanOptionAllowDuplicatesKey CBCentralManagerScanOptionAllowDuplicatesKey string // CBCentralManagerScanOptionSolicitedServiceUUIDsKey is an array of service UUIDs that you want to scan for. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerScanOptionSolicitedServiceUUIDsKey CBCentralManagerScanOptionSolicitedServiceUUIDsKey string // CBConnectPeripheralOptionEnableAutoReconnect is a Boolean value that specifies whether the system automatically reconnects with a peripheral. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectPeripheralOptionEnableAutoReconnect CBConnectPeripheralOptionEnableAutoReconnect string // CBConnectPeripheralOptionNotifyOnConnectionKey is a Boolean value that specifies whether the system should display an alert when connecting a peripheral in the background. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectPeripheralOptionNotifyOnConnectionKey CBConnectPeripheralOptionNotifyOnConnectionKey string // CBConnectPeripheralOptionNotifyOnDisconnectionKey is a Boolean value that specifies whether the system should display an alert when disconnecting a peripheral in the background. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectPeripheralOptionNotifyOnDisconnectionKey CBConnectPeripheralOptionNotifyOnDisconnectionKey string // CBConnectPeripheralOptionNotifyOnNotificationKey is a Boolean value that specifies whether the system should display an alert for any notification sent by a peripheral. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectPeripheralOptionNotifyOnNotificationKey CBConnectPeripheralOptionNotifyOnNotificationKey string // CBConnectPeripheralOptionStartDelayKey is an option that indicates a delay before the system makes a connection. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectPeripheralOptionStartDelayKey CBConnectPeripheralOptionStartDelayKey string // CBErrorDomain is the domain for Core Bluetooth errors. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBErrorDomain CBErrorDomain string // CBPeripheralManagerOptionRestoreIdentifierKey is a string containing a unique identifier (UID) for the peripheral manager to instantiate. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerOptionRestoreIdentifierKey CBPeripheralManagerOptionRestoreIdentifierKey string // CBPeripheralManagerOptionShowPowerAlertKey is a Boolean value specifying whether the system should warn if Bluetooth is in the powered-off state when instantiating the peripheral manager. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerOptionShowPowerAlertKey CBPeripheralManagerOptionShowPowerAlertKey string // CBPeripheralManagerRestoredStateAdvertisementDataKey is a dictionary of restored advertising data. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerRestoredStateAdvertisementDataKey CBPeripheralManagerRestoredStateAdvertisementDataKey string // CBPeripheralManagerRestoredStateServicesKey is an array of restored peripheral services. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerRestoredStateServicesKey CBPeripheralManagerRestoredStateServicesKey string // CBUUIDCharacteristicAggregateFormatString is the UUID for the Aggregate Format descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicAggregateFormatString CBUUIDCharacteristicAggregateFormatString string // CBUUIDCharacteristicExtendedPropertiesString is the UUID for the Extended Properties descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicExtendedPropertiesString CBUUIDCharacteristicExtendedPropertiesString string // CBUUIDCharacteristicFormatString is the UUID for the Presentation Format descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicFormatString CBUUIDCharacteristicFormatString string // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicObservationScheduleString CBUUIDCharacteristicObservationScheduleString string // CBUUIDCharacteristicUserDescriptionString is the UUID for the User Description descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicUserDescriptionString CBUUIDCharacteristicUserDescriptionString string // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDCharacteristicValidRangeString CBUUIDCharacteristicValidRangeString string // CBUUIDClientCharacteristicConfigurationString is the UUID for the Client Configuration descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDClientCharacteristicConfigurationString CBUUIDClientCharacteristicConfigurationString string // CBUUIDL2CAPPSMCharacteristicString is the PSM of an L2CAP channel associated with the GATT service containing this characteristic. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDL2CAPPSMCharacteristicString CBUUIDL2CAPPSMCharacteristicString string // CBUUIDServerCharacteristicConfigurationString is the UUID for the Server Configuration descriptor, as a string. // // See: https://developer.apple.com/documentation/CoreBluetooth/CBUUIDServerCharacteristicConfigurationString CBUUIDServerCharacteristicConfigurationString string )
var CBConnectionEventMatchingOptions struct { // PeripheralUUIDs: An array of UUID objects that represents peripherals to match. PeripheralUUIDs CBConnectionEventMatchingOption // ServiceUUIDs: An array that represents service identifiers to match. ServiceUUIDs CBConnectionEventMatchingOption }
CBConnectionEventMatchingOptions provides typed accessors for CBConnectionEventMatchingOption constants.
Functions ¶
This section is empty.
Types ¶
type CBATTError ¶
type CBATTError int
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTError-swift.struct/Code
const ( // CBATTErrorAttributeNotFound: The attribute wasn’t found within the specified attribute handle range. CBATTErrorAttributeNotFound CBATTError = 0xa // CBATTErrorAttributeNotLong: The ATT read blob request can’t read or write the attribute. CBATTErrorAttributeNotLong CBATTError = 0xb // CBATTErrorInsufficientAuthentication: Reading or writing the attribute’s value failed for lack of authentication. CBATTErrorInsufficientAuthentication CBATTError = 0x5 // CBATTErrorInsufficientAuthorization: Reading or writing the attribute’s value failed for lack of authorization. CBATTErrorInsufficientAuthorization CBATTError = 0x8 // CBATTErrorInsufficientEncryption: Reading or writing the attribute’s value failed for lack of encryption. CBATTErrorInsufficientEncryption CBATTError = 0xf // CBATTErrorInsufficientEncryptionKeySize: The encryption key size used for encrypting this link is insufficient. CBATTErrorInsufficientEncryptionKeySize CBATTError = 0xc // CBATTErrorInsufficientResources: Resources are insufficient to complete the ATT request. CBATTErrorInsufficientResources CBATTError = 0x11 // CBATTErrorInvalidAttributeValueLength: The length of the attribute’s value is invalid for the intended operation. CBATTErrorInvalidAttributeValueLength CBATTError = 0xd // CBATTErrorInvalidHandle: The attribute handle is invalid on this peripheral. CBATTErrorInvalidHandle CBATTError = 0x1 // CBATTErrorInvalidOffset: The specified offset value was past the end of the attribute’s value. CBATTErrorInvalidOffset CBATTError = 0x7 // CBATTErrorInvalidPdu: The attribute Protocol Data Unit (PDU) is invalid. CBATTErrorInvalidPdu CBATTError = 0x4 // CBATTErrorPrepareQueueFull: The prepare queue is full, as a result of there being too many write requests in the queue. CBATTErrorPrepareQueueFull CBATTError = 0x9 // CBATTErrorReadNotPermitted: The permissions prohibit reading the attribute’s value. CBATTErrorReadNotPermitted CBATTError = 0x2 // CBATTErrorRequestNotSupported: The attribute server doesn’t support the request received from the client. CBATTErrorRequestNotSupported CBATTError = 0x6 // CBATTErrorSuccess: The ATT command or request successfully completed. CBATTErrorSuccess CBATTError = 0 // CBATTErrorUnlikelyError: The ATT request encountered an unlikely error and wasn’t completed. CBATTErrorUnlikelyError CBATTError = 0xe // CBATTErrorUnsupportedGroupType: The attribute type isn’t a supported grouping attribute as defined by a higher-layer specification. CBATTErrorUnsupportedGroupType CBATTError = 0x10 // CBATTErrorWriteNotPermitted: The permissions prohibit writing the attribute’s value. CBATTErrorWriteNotPermitted CBATTError = 0x3 )
func (CBATTError) String ¶
func (e CBATTError) String() string
type CBATTRequest ¶
type CBATTRequest struct {
objectivec.Object
}
A request that uses the Attribute Protocol (ATT).
Overview ¶
The CBATTRequest class represents Attribute Protocol (ATT) read and write requests from remote central devices (represented by CBCentral objects). Remote centrals use these ATT requests to read and write characteristic values on local peripherals (represented by CBPeripheralManager objects). Local peripherals, on the other hand, use the properties of CBATTRequest objects to respond to the read and write requests appropriately, using the CBPeripheralManager.RespondToRequestWithResult method of the CBPeripheralManager class.
Requesting to Read and Write Characteristic Values ¶
- CBATTRequest.Central: The remote central device that originated the request.
- CBATTRequest.Characteristic: The characteristic to read or write the value of.
- CBATTRequest.Value: The data that the central reads from or writes to the peripheral.
- CBATTRequest.SetValue
- CBATTRequest.Offset: The zero-based index of the first byte for the read or write request.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest
func CBATTRequestFromID ¶
func CBATTRequestFromID(id objc.ID) CBATTRequest
CBATTRequestFromID constructs a CBATTRequest from an objc.ID.
A request that uses the Attribute Protocol (ATT).
func NewCBATTRequest ¶
func NewCBATTRequest() CBATTRequest
NewCBATTRequest creates a new CBATTRequest instance.
func (CBATTRequest) Autorelease ¶
func (c CBATTRequest) Autorelease() CBATTRequest
Autorelease adds the receiver to the current autorelease pool.
func (CBATTRequest) Central ¶
func (c CBATTRequest) Central() ICBCentral
The remote central device that originated the request.
Overview ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest/central
func (CBATTRequest) Characteristic ¶
func (c CBATTRequest) Characteristic() ICBCharacteristic
The characteristic to read or write the value of.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest/characteristic
func (CBATTRequest) Offset ¶
func (c CBATTRequest) Offset() uint
The zero-based index of the first byte for the read or write request.
Discussion ¶
You can use the value of this property to ensure that the ATT request is attempting to read or write within the proper bounds of the characteristic’s value. For an example of how to take a request’s offset property into account when responding to a read or write request, see Responding to Read and Write Requests from a Central.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest/offset
func (CBATTRequest) SetValue ¶
func (c CBATTRequest) SetValue(value foundation.NSData)
func (CBATTRequest) Value ¶
func (c CBATTRequest) Value() foundation.NSData
The data that the central reads from or writes to the peripheral.
Discussion ¶
The value of this property depends on whether the request type is read or write. For read requests, the property is `nil,` and you should set it before responding to the remote central through the CBPeripheralManager.RespondToRequestWithResult method. For write requests, the value is the data to write to the characteristic’s value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest/value
type CBATTRequestClass ¶
type CBATTRequestClass struct {
// contains filtered or unexported fields
}
func GetCBATTRequestClass ¶
func GetCBATTRequestClass() CBATTRequestClass
GetCBATTRequestClass returns the class object for CBATTRequest.
func (CBATTRequestClass) Alloc ¶
func (cc CBATTRequestClass) Alloc() CBATTRequest
Alloc allocates memory for a new instance of the class.
func (CBATTRequestClass) Class ¶
func (cc CBATTRequestClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBAttribute ¶
type CBAttribute struct {
objectivec.Object
}
A representation of common aspects of services offered by a peripheral.
Overview ¶
Concrete subclasses of CBAttribute (and their mutable counterparts) represent the services a peripheral offers, the characteristics of those services, and the descriptors attached to those characteristics. The concrete subclasses are:
- CBService - CBCharacteristic - CBDescriptor
Identifying an Attribute ¶
- CBAttribute.UUID: The Bluetooth-specific UUID of the attribute.
See: https://developer.apple.com/documentation/CoreBluetooth/CBAttribute
func CBAttributeFromID ¶
func CBAttributeFromID(id objc.ID) CBAttribute
CBAttributeFromID constructs a CBAttribute from an objc.ID.
A representation of common aspects of services offered by a peripheral.
func NewCBAttribute ¶
func NewCBAttribute() CBAttribute
NewCBAttribute creates a new CBAttribute instance.
func (CBAttribute) Autorelease ¶
func (c CBAttribute) Autorelease() CBAttribute
Autorelease adds the receiver to the current autorelease pool.
func (CBAttribute) UUID ¶
func (c CBAttribute) UUID() ICBUUID
The Bluetooth-specific UUID of the attribute.
Discussion ¶
This property is a 128-bit UUID that identifies the attribute.
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBAttribute/uuid
type CBAttributeClass ¶
type CBAttributeClass struct {
// contains filtered or unexported fields
}
func GetCBAttributeClass ¶
func GetCBAttributeClass() CBAttributeClass
GetCBAttributeClass returns the class object for CBAttribute.
func (CBAttributeClass) Alloc ¶
func (cc CBAttributeClass) Alloc() CBAttribute
Alloc allocates memory for a new instance of the class.
func (CBAttributeClass) Class ¶
func (cc CBAttributeClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBAttributePermissions ¶
type CBAttributePermissions uint
See: https://developer.apple.com/documentation/CoreBluetooth/CBAttributePermissions
const ( // CBAttributePermissionsReadEncryptionRequired: A permission that indicates only trusted devices can read the attribute’s value. CBAttributePermissionsReadEncryptionRequired CBAttributePermissions = 0x4 // CBAttributePermissionsReadable: A permission that indicates a peripheral can read the attribute’s value. CBAttributePermissionsReadable CBAttributePermissions = 0x1 // CBAttributePermissionsWriteEncryptionRequired: A permission that indicates only trusted devices can write the attribute’s value. CBAttributePermissionsWriteEncryptionRequired CBAttributePermissions = 0x8 // CBAttributePermissionsWriteable: A permission that indicates a peripheral can write the attribute’s value. CBAttributePermissionsWriteable CBAttributePermissions = 0x2 )
func (CBAttributePermissions) String ¶
func (e CBAttributePermissions) String() string
type CBCentral ¶
type CBCentral struct {
CBPeer
}
A remote device connected to a local app, which is acting as a peripheral.
Overview ¶
The CBCentral class represents remote central devices (or centrals) that have connected to an app implementing the peripheral role on a local device. Remote centrals use universally unique identifiers (UUIDs), represented by NSUUID objects, to identify themselves.
Identifying a Remote Central ¶
- CBCentral.MaximumUpdateValueLength: The maximum amount of data, in bytes, that the central can receive in a single notification or indication.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentral
func CBCentralFromID ¶
CBCentralFromID constructs a CBCentral from an objc.ID.
A remote device connected to a local app, which is acting as a peripheral.
func (CBCentral) Autorelease ¶
Autorelease adds the receiver to the current autorelease pool.
func (CBCentral) MaximumUpdateValueLength ¶
The maximum amount of data, in bytes, that the central can receive in a single notification or indication.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentral/maximumUpdateValueLength
type CBCentralClass ¶
type CBCentralClass struct {
// contains filtered or unexported fields
}
func GetCBCentralClass ¶
func GetCBCentralClass() CBCentralClass
GetCBCentralClass returns the class object for CBCentral.
func (CBCentralClass) Alloc ¶
func (cc CBCentralClass) Alloc() CBCentral
Alloc allocates memory for a new instance of the class.
func (CBCentralClass) Class ¶
func (cc CBCentralClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBCentralManager ¶
type CBCentralManager struct {
CBManager
}
An object that scans for, discovers, connects to, and manages peripherals.
Overview ¶
CBCentralManager objects manage discovered or connected remote peripheral devices (represented by CBPeripheral objects), including scanning for, discovering, and connecting to advertising peripherals.
Before calling the CBCentralManager methods, set the state of the central manager object to powered on, as indicated by the CBCentralManagerState.poweredOn constant. This state indicates that the central device (your iPhone or iPad, for instance) supports Bluetooth low energy and that Bluetooth is on and available for use.
Initializing a Central Manager ¶
- CBCentralManager.InitWithDelegateQueue: Initializes the central manager with a specified delegate and dispatch queue.
- CBCentralManager.InitWithDelegateQueueOptions: Initializes the central manager with specified delegate, dispatch queue, and initialization options.
Establishing or Canceling Connections with Peripherals ¶
- CBCentralManager.ConnectPeripheralOptions: Establishes a local connection to a peripheral.
- CBCentralManager.CancelPeripheralConnection: Cancels an active or pending local connection to a peripheral.
Retrieving Lists of Peripherals ¶
- CBCentralManager.RetrieveConnectedPeripheralsWithServices: Returns a list of the peripherals connected to the system whose services match a given set of criteria.
- CBCentralManager.RetrievePeripheralsWithIdentifiers: Returns a list of known peripherals by their identifiers.
Scanning or Stopping Scans of Peripherals ¶
- CBCentralManager.ScanForPeripheralsWithServicesOptions: Scans for peripherals that are advertising services.
- CBCentralManager.StopScan: Asks the central manager to stop scanning for peripherals.
- CBCentralManager.IsScanning: A Boolean value that indicates whether the central is currently scanning.
Monitoring Properties ¶
- CBCentralManager.Delegate: The delegate object that you want to receive central manager events.
- CBCentralManager.SetDelegate
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager
func CBCentralManagerFromID ¶
func CBCentralManagerFromID(id objc.ID) CBCentralManager
CBCentralManagerFromID constructs a CBCentralManager from an objc.ID.
An object that scans for, discovers, connects to, and manages peripherals.
func NewCBCentralManager ¶
func NewCBCentralManager() CBCentralManager
NewCBCentralManager creates a new CBCentralManager instance.
func NewCBCentralManagerWithDelegateQueue ¶
func NewCBCentralManagerWithDelegateQueue(delegate CBCentralManagerDelegate, queue dispatch.Queue) CBCentralManager
Initializes the central manager with a specified delegate and dispatch queue.
delegate: The delegate that receives central events.
queue: 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.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/init(delegate:queue:)
func NewCBCentralManagerWithDelegateQueueOptions ¶
func NewCBCentralManagerWithDelegateQueueOptions(delegate CBCentralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBCentralManager
Initializes the central manager with specified delegate, dispatch queue, and initialization options.
delegate: The delegate that receives the central events.
queue: 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.
options: An optional dictionary that contains initialization options for a central manager. For available options, see Central Manager Initialization Options.
Return Value ¶
Returns a newly initialized central manager.
Discussion ¶
This method is the designated initializer for the CBCentralManager class.
func (CBCentralManager) Autorelease ¶
func (c CBCentralManager) Autorelease() CBCentralManager
Autorelease adds the receiver to the current autorelease pool.
func (CBCentralManager) CancelPeripheralConnection ¶
func (c CBCentralManager) CancelPeripheralConnection(peripheral ICBPeripheral)
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.
Discussion ¶
This method is nonblocking, and any CBPeripheral class commands that are still pending to `peripheral` may not complete. Because other apps may still have a connection to the peripheral, canceling a local connection doesn’t guarantee that the underlying physical link is immediately disconnected. From the app’s perspective, however, the peripheral is effectively disconnected, and the central manager object calls the [CentralManagerDidDisconnectPeripheralError] method of its delegate object.
func (CBCentralManager) ConnectPeripheralOptions ¶
func (c CBCentralManager) ConnectPeripheralOptions(peripheral ICBPeripheral, options foundation.INSDictionary)
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.
Discussion ¶
After successfully establishing a local connection to a peripheral, the central manager object calls the [CentralManagerDidConnectPeripheral] method of its delegate object. If the connection attempt fails, the central manager object calls the [CentralManagerDidFailToConnectPeripheralError] method of its delegate object instead. Attempts to connect to a peripheral don’t time out. To explicitly cancel a pending connection to a peripheral, call the CBCentralManager.CancelPeripheralConnection method. Deallocating `peripheral` also implicitly calls CBCentralManager.CancelPeripheralConnection.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/connect(_:options:)
func (CBCentralManager) Delegate ¶
func (c CBCentralManager) Delegate() CBCentralManagerDelegate
The delegate object that you want to receive central manager events.
Discussion ¶
For information about how to implement your central manager delegate, see CBCentralManagerDelegate.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/delegate
func (CBCentralManager) Init ¶
func (c CBCentralManager) Init() CBCentralManager
Init initializes the instance.
func (CBCentralManager) InitWithDelegateQueue ¶
func (c CBCentralManager) InitWithDelegateQueue(delegate CBCentralManagerDelegate, queue dispatch.Queue) CBCentralManager
Initializes the central manager with a specified delegate and dispatch queue.
delegate: The delegate that receives central events.
queue: 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.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/init(delegate:queue:)
func (CBCentralManager) InitWithDelegateQueueOptions ¶
func (c CBCentralManager) InitWithDelegateQueueOptions(delegate CBCentralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBCentralManager
Initializes the central manager with specified delegate, dispatch queue, and initialization options.
delegate: The delegate that receives the central events.
queue: 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.
options: An optional dictionary that contains initialization options for a central manager. For available options, see Central Manager Initialization Options.
Return Value ¶
Returns a newly initialized central manager.
Discussion ¶
This method is the designated initializer for the CBCentralManager class.
func (CBCentralManager) IsScanning ¶
func (c CBCentralManager) IsScanning() bool
A Boolean value that indicates whether the central is currently scanning.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/isScanning
func (CBCentralManager) RetrieveConnectedPeripheralsWithServices ¶
func (c CBCentralManager) RetrieveConnectedPeripheralsWithServices(serviceUUIDs []CBUUID) []CBPeripheral
Returns a list of the peripherals connected to the system whose services match a given set of criteria.
serviceUUIDs: A list of service UUIDs, represented by CBUUID objects.
Return Value ¶
A list of the peripherals that are currently connected to the system and that contain any of the services specified in the `serviceUUID` parameter.
Discussion ¶
The list of connected peripherals can include those that other apps have connected. You need to connect these peripherals locally using the CBCentralManager.ConnectPeripheralOptions method before using them.
func (CBCentralManager) RetrievePeripheralsWithIdentifiers ¶
func (c CBCentralManager) RetrievePeripheralsWithIdentifiers(identifiers []foundation.NSUUID) []CBPeripheral
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.
Return Value ¶
A list of peripherals that the central manager is able to match to the provided identifiers.
func (CBCentralManager) ScanForPeripheralsWithServicesOptions ¶
func (c CBCentralManager) ScanForPeripheralsWithServicesOptions(serviceUUIDs []CBUUID, options foundation.INSDictionary)
Scans for peripherals that are advertising services.
serviceUUIDs: An array of CBUUID objects that the app is interested in. Each CBUUID object represents the UUID of a service that a peripheral advertises.
options: A dictionary of options for customizing the scan. For available options, see Peripheral Scanning Options.
Discussion ¶
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. If the `serviceUUIDs` parameter is `nil`, this method returns all discovered peripherals, regardless of their supported services.
If the central manager is actively scanning with one set of parameters and it receives another set to scan, the new parameters override the previous set. When the central manager discovers a peripheral, it calls the [CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI] method of its delegate object.
Your app can scan for Bluetooth devices in the background by specifying the `bluetooth-central` background mode. To do this, your app must explicitly scan for one or more services by specifying them in the `serviceUUIDs` parameter. The CBCentralManager scan option has no effect while scanning in the background.
func (CBCentralManager) SetDelegate ¶
func (c CBCentralManager) SetDelegate(value CBCentralManagerDelegate)
func (CBCentralManager) StopScan ¶
func (c CBCentralManager) StopScan()
Asks the central manager to stop scanning for peripherals.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/stopScan()
type CBCentralManagerClass ¶
type CBCentralManagerClass struct {
// contains filtered or unexported fields
}
func GetCBCentralManagerClass ¶
func GetCBCentralManagerClass() CBCentralManagerClass
GetCBCentralManagerClass returns the class object for CBCentralManager.
func (CBCentralManagerClass) Alloc ¶
func (cc CBCentralManagerClass) Alloc() CBCentralManager
Alloc allocates memory for a new instance of the class.
func (CBCentralManagerClass) Class ¶
func (cc CBCentralManagerClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBCentralManagerDelegate ¶
type CBCentralManagerDelegate interface {
objectivec.IObject
// Tells the delegate the central manager’s state updated.
//
// See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerDelegate/centralManagerDidUpdateState(_:)
CentralManagerDidUpdateState(central ICBCentralManager)
}
A protocol that provides updates for the discovery and management of peripheral devices.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerDelegate
type CBCentralManagerDelegateConfig ¶
type CBCentralManagerDelegateConfig struct {
// Monitoring Connections with Peripherals
// CentralManagerDidDisconnectPeripheralError — Tells the delegate that the central manager disconnected from a peripheral.
CentralManagerDidDisconnectPeripheralError func(central CBCentralManager, peripheral CBPeripheral, error_ foundation.NSError)
// Monitoring the Central Manager’s State
// CentralManagerDidUpdateState — Tells the delegate the central manager’s state updated.
CentralManagerDidUpdateState func(central CBCentralManager)
// CentralManagerWillRestoreState — Tells the delegate the system is about to restore the central manager, as part of relaunching the app into the background.
CentralManagerWillRestoreState func(central CBCentralManager, dict foundation.INSDictionary)
// Other Methods
// CentralManagerDidConnectPeripheral — Tells the delegate that the central manager connected to a peripheral.
CentralManagerDidConnectPeripheral func(central CBCentralManager, peripheral CBPeripheral)
// CentralManagerDidFailToConnectPeripheralError — Tells the delegate the central manager failed to create a connection with a peripheral.
CentralManagerDidFailToConnectPeripheralError func(central CBCentralManager, peripheral CBPeripheral, error_ foundation.NSError)
// CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI — Tells the delegate the central manager discovered a peripheral while scanning for devices.
CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI func(central CBCentralManager, peripheral CBPeripheral, advertisementData foundation.INSDictionary, RSSI foundation.NSNumber)
}
CBCentralManagerDelegateConfig holds optional typed callbacks for CBCentralManagerDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.
See Apple Documentation for protocol details.
type CBCentralManagerDelegateObject ¶
type CBCentralManagerDelegateObject struct {
objectivec.Object
}
CBCentralManagerDelegateObject wraps an existing Objective-C object that conforms to the CBCentralManagerDelegate protocol.
func CBCentralManagerDelegateObjectFromID ¶
func CBCentralManagerDelegateObjectFromID(id objc.ID) CBCentralManagerDelegateObject
CBCentralManagerDelegateObjectFromID constructs a CBCentralManagerDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.
func NewCBCentralManagerDelegate ¶
func NewCBCentralManagerDelegate(config CBCentralManagerDelegateConfig) CBCentralManagerDelegateObject
NewCBCentralManagerDelegate creates an Objective-C object implementing the CBCentralManagerDelegate protocol.
Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.
The returned CBCentralManagerDelegateObject satisfies the CBCentralManagerDelegate interface and can be passed directly to SetDelegate and similar methods.
See Apple Documentation for protocol details.
func (CBCentralManagerDelegateObject) BaseObject ¶
func (o CBCentralManagerDelegateObject) BaseObject() objectivec.Object
func (CBCentralManagerDelegateObject) CentralManagerConnectionEventDidOccurForPeripheral ¶
func (o CBCentralManagerDelegateObject) CentralManagerConnectionEventDidOccurForPeripheral(central ICBCentralManager, event CBConnectionEvent, peripheral ICBPeripheral)
Tells the delegate that a connection event occurred which matches the registered options.
Discussion ¶
The manager calls this method when it observes a connection event that matches the options provided to [CBCentralManager.RegisterForConnectionEventsWithOptions].
func (CBCentralManagerDelegateObject) CentralManagerDidConnectPeripheral ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidConnectPeripheral(central ICBCentralManager, peripheral ICBPeripheral)
Tells the delegate that the central manager connected to a peripheral.
central: The central manager that provides this information.
peripheral: The now-connected peripheral.
Discussion ¶
The manager invokes this method when a call to CBCentralManager.ConnectPeripheralOptions succeeds. You typically implement this method to set the peripheral’s delegate and discover its services.
For more information, see Core Bluetooth Programming Guide.
func (CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralError ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralError(central ICBCentralManager, peripheral ICBPeripheral, error_ foundation.NSError)
Tells the delegate that the central manager disconnected from a peripheral.
central: The central manager that provides this information.
peripheral: The now-disconnected peripheral.
error: The cause of the failure, or `nil` if no error occurred.
Discussion ¶
The manager invokes this method when disconnecting a peripheral previously connected with the CBCentralManager.ConnectPeripheralOptions method. The error parameter contains the reason for the disconnection, unless the disconnect resulted from a call to CBCentralManager.CancelPeripheralConnection. After this method executes, the peripheral device’s CBPeripheralDelegate object receives no further method calls.
All services, characteristics, and characteristic descriptors a peripheral become invalidated after it disconnects.
func (CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralTimestampIsReconnectingError ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidDisconnectPeripheralTimestampIsReconnectingError(central ICBCentralManager, peripheral ICBPeripheral, timestamp corefoundation.CFAbsoluteTime, isReconnecting bool, error_ foundation.NSError)
func (CBCentralManagerDelegateObject) CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidDiscoverPeripheralAdvertisementDataRSSI(central ICBCentralManager, peripheral ICBPeripheral, advertisementData foundation.INSDictionary, RSSI foundation.NSNumber)
Tells the delegate the central manager discovered a peripheral while scanning for devices.
central: The central manager that provides the update.
peripheral: The discovered peripheral.
advertisementData: A dictionary containing any advertisement data.
RSSI: The current received signal strength indicator (RSSI) of the peripheral, in decibels.
Discussion ¶
You can access the advertisement data with the keys listed in Advertisement Data Retrieval Keys. You must retain a local copy of the peripheral if you want to perform commands on it. Use the RSSI data to determine the proximity of a discoverable peripheral device, and whether you want to connect to it automatically.
func (CBCentralManagerDelegateObject) CentralManagerDidFailToConnectPeripheralError ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidFailToConnectPeripheralError(central ICBCentralManager, peripheral ICBPeripheral, error_ foundation.NSError)
Tells the delegate the central manager failed to create a connection with a peripheral.
central: The central manager that provides this information.
peripheral: The peripheral that failed to connect.
error: The cause of the failure, or `nil` if no error occurred.
Discussion ¶
The manager invokes this method when a connection initiated with the CBCentralManager.ConnectPeripheralOptions method fails to complete. Because connection attempts don’t time out, a failed connection usually indicates a transient issue, in which case you may attempt connecting to the peripheral again.
func (CBCentralManagerDelegateObject) CentralManagerDidUpdateANCSAuthorizationForPeripheral ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidUpdateANCSAuthorizationForPeripheral(central ICBCentralManager, peripheral ICBPeripheral)
Tells the delegate the authorization status changed for a ANCS-requiring connected peripheral.
central: The central manager providing this information.
peripheral: The CBPeripheral that caused the event.
func (CBCentralManagerDelegateObject) CentralManagerDidUpdateState ¶
func (o CBCentralManagerDelegateObject) CentralManagerDidUpdateState(central ICBCentralManager)
Tells the delegate the central manager’s state updated.
central: The central manager whose state has changed.
Discussion ¶
You implement this required method to ensure that the central device supports Bluetooth low energy and that it’s available to use. You should issue commands to the central manager only when the central manager’s CBManager.State indicates it’s powered on. A state with a value lower than CBManagerState.poweredOn implies that scanning has stopped, which in turn disconnects any previously-connected peripherals. If the state moves below CBManagerState.poweredOff, all CBPeripheral objects obtained from this central manager become invalid; you must retrieve or discover these peripherals again. For a complete list of possible states, see CBManagerState.
func (CBCentralManagerDelegateObject) CentralManagerWillRestoreState ¶
func (o CBCentralManagerDelegateObject) CentralManagerWillRestoreState(central ICBCentralManager, dict foundation.INSDictionary)
Tells the delegate the system is about to restore the central manager, as part of relaunching the app into the background.
central: The central manager that provides this information.
dict: A dictionary that contains information about the central manager preserved by the system when it terminated the app. For the available keys to this dictionary, see Central Manager State Restoration Options.
Discussion ¶
This method only applies to apps that opt in to the state preservation and restoration feature of Core Bluetooth. The system invokes this method when relaunching your app into the background to complete some Bluetooth-related task. Use this method to synchronize the state of your app with the state of the Bluetooth system.
type CBCentralManagerFeature ¶
type CBCentralManagerFeature uint
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager/Feature
const ( // CBCentralManagerFeatureExtendedScanAndConnect: The hardware supports extended scans and enhanced connection creation. CBCentralManagerFeatureExtendedScanAndConnect CBCentralManagerFeature = 1 )
func (CBCentralManagerFeature) String ¶
func (e CBCentralManagerFeature) String() string
type CBCentralManagerState ¶
type CBCentralManagerState int
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManagerState
const ( // CBCentralManagerStatePoweredOff: A state that indicates Bluetooth is currently powered off. CBCentralManagerStatePoweredOff CBCentralManagerState = 4 // CBCentralManagerStatePoweredOn: A state that indicates Bluetooth is currently powered on and available to use. CBCentralManagerStatePoweredOn CBCentralManagerState = 5 // CBCentralManagerStateResetting: A state that indicates the connection with the system service was momentarily lost. CBCentralManagerStateResetting CBCentralManagerState = 1 CBCentralManagerStateUnauthorized CBCentralManagerState = 3 // CBCentralManagerStateUnknown: The manager’s state is unknown. CBCentralManagerStateUnknown CBCentralManagerState = 0 // CBCentralManagerStateUnsupported: A state that indicates this device doesn’t support the Bluetooth low energy central or client role. CBCentralManagerStateUnsupported CBCentralManagerState = 2 )
func (CBCentralManagerState) String ¶
func (e CBCentralManagerState) String() string
type CBChannelSoundingSessionConfigurationRole ¶
type CBChannelSoundingSessionConfigurationRole int
type CBCharacteristic ¶
type CBCharacteristic struct {
CBAttribute
}
A characteristic of a remote peripheral’s service.
Overview ¶
CBCharacteristic and its subclass CBMutableCharacteristic represent further information about a peripheral’s service. In particular, CBCharacteristic objects represent the characteristics of a remote peripheral’s service. A characteristic contains a single value and any number of descriptors describing that value. The properties of a characteristic determine how you can use a characteristic’s value, and how you access the descriptors.
Identifying a Characteristic ¶
- CBCharacteristic.Service: The service to which this characteristic belongs.
Accessing Characteristic Data ¶
- CBCharacteristic.Value: The value of the characteristic.
- CBCharacteristic.Descriptors: A list of the descriptors discovered in this characteristic.
- CBCharacteristic.Properties: The properties of the characteristic.
- CBCharacteristic.IsNotifying: A Boolean value that indicates whether the characteristic is currently notifying a subscribed central of its value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic
func CBCharacteristicFromID ¶
func CBCharacteristicFromID(id objc.ID) CBCharacteristic
CBCharacteristicFromID constructs a CBCharacteristic from an objc.ID.
A characteristic of a remote peripheral’s service.
func NewCBCharacteristic ¶
func NewCBCharacteristic() CBCharacteristic
NewCBCharacteristic creates a new CBCharacteristic instance.
func (CBCharacteristic) Autorelease ¶
func (c CBCharacteristic) Autorelease() CBCharacteristic
Autorelease adds the receiver to the current autorelease pool.
func (CBCharacteristic) Descriptors ¶
func (c CBCharacteristic) Descriptors() []CBDescriptor
A list of the descriptors discovered in this characteristic.
Discussion ¶
The value of this property is an array of CBDescriptor objects that represent a characteristic’s descriptors. Characteristic descriptors provide more information about a characteristic’s value. For example, they may describe the value in human-readable form and describe how to format the value for presentation purposes. For more information about characteristic descriptors, see CBDescriptor.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic/descriptors
func (CBCharacteristic) Init ¶
func (c CBCharacteristic) Init() CBCharacteristic
Init initializes the instance.
func (CBCharacteristic) IsNotifying ¶
func (c CBCharacteristic) IsNotifying() bool
A Boolean value that indicates whether the characteristic is currently notifying a subscribed central of its value.
Discussion ¶
This value is true if you enabled notifications or indications for the characteristic by successfully calling the CBPeripheral.SetNotifyValueForCharacteristic method of the CBPeripheral class. In this case, the peripheral updates its connected central that whenever the characteristic’s value changes.
If the value of the property is false, notifications (or indications) aren’t enabled for the characteristic, and the peripheral doesn’t update its connected central when the characteristic’s value changes.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic/isNotifying
func (CBCharacteristic) Properties ¶
func (c CBCharacteristic) Properties() CBCharacteristicProperties
The properties of the characteristic.
Discussion ¶
The properties of a characteristic determine the access to and use of the characteristic’s value and descriptors. For a list of the possible values representing the properties of a characteristic, see CBCharacteristicProperties.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic/properties
func (CBCharacteristic) Service ¶
func (c CBCharacteristic) Service() ICBService
The service to which this characteristic belongs.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic/service
func (CBCharacteristic) Value ¶
func (c CBCharacteristic) Value() foundation.NSData
The value of the characteristic.
Discussion ¶
This property contains the value of the characteristic. For example, a temperature measurement characteristic of a health thermometer service may have a value that indicates a temperature in Celsius.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic/value
type CBCharacteristicClass ¶
type CBCharacteristicClass struct {
// contains filtered or unexported fields
}
func GetCBCharacteristicClass ¶
func GetCBCharacteristicClass() CBCharacteristicClass
GetCBCharacteristicClass returns the class object for CBCharacteristic.
func (CBCharacteristicClass) Alloc ¶
func (cc CBCharacteristicClass) Alloc() CBCharacteristic
Alloc allocates memory for a new instance of the class.
func (CBCharacteristicClass) Class ¶
func (cc CBCharacteristicClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBCharacteristicProperties ¶
type CBCharacteristicProperties uint
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristicProperties
const ( // CBCharacteristicPropertyAuthenticatedSignedWrites: A property that indicates the perhipheral allows signed writes of the characteristic’s value, without a response to indicate the write succeeded. CBCharacteristicPropertyAuthenticatedSignedWrites CBCharacteristicProperties = 0x40 // CBCharacteristicPropertyBroadcast: A property that indicates the characteristic can broadcast its value using a characteristic configuration descriptor. CBCharacteristicPropertyBroadcast CBCharacteristicProperties = 0x1 // CBCharacteristicPropertyExtendedProperties: A property that indicates the characteristic defines additional properties in the extended properties descriptor. CBCharacteristicPropertyExtendedProperties CBCharacteristicProperties = 0x80 // CBCharacteristicPropertyIndicate: A property that indicates the peripheral permits notifications of the characteristic’s value, with a response from the central to indicate receipt of the notification. CBCharacteristicPropertyIndicate CBCharacteristicProperties = 0x20 // CBCharacteristicPropertyIndicateEncryptionRequired: A property that indicates only trusted devices can enable indications of the characteristic’s value. CBCharacteristicPropertyIndicateEncryptionRequired CBCharacteristicProperties = 0x200 // CBCharacteristicPropertyNotify: A property that indicates the peripheral permits notifications of the characteristic’s value, without a response from the central to indicate receipt of the notification. CBCharacteristicPropertyNotify CBCharacteristicProperties = 0x10 // CBCharacteristicPropertyNotifyEncryptionRequired: A property that indicates that only trusted devices can enable notifications of the characteristic’s value. CBCharacteristicPropertyNotifyEncryptionRequired CBCharacteristicProperties = 0x100 // CBCharacteristicPropertyRead: A property that indicates a peripheral can read the characteristic’s value. CBCharacteristicPropertyRead CBCharacteristicProperties = 0x2 // CBCharacteristicPropertyWrite: A property that indicates a peripheral can write the characteristic’s value, with a response to indicate that the write succeeded. CBCharacteristicPropertyWrite CBCharacteristicProperties = 0x8 // CBCharacteristicPropertyWriteWithoutResponse: A property that indicates a peripheral can write the characteristic’s value, without a response to indicate that the write succeeded. CBCharacteristicPropertyWriteWithoutResponse CBCharacteristicProperties = 0x4 )
func (CBCharacteristicProperties) String ¶
func (e CBCharacteristicProperties) String() string
type CBCharacteristicWriteType ¶
type CBCharacteristicWriteType int
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristicWriteType
const ( // CBCharacteristicWriteWithResponse: Write a characteristic value, with a response from the peripheral to indicate whether the write was successful. CBCharacteristicWriteWithResponse CBCharacteristicWriteType = 0 // CBCharacteristicWriteWithoutResponse: Write a characteristic value, without any response from the peripheral to indicate whether the write was successful. CBCharacteristicWriteWithoutResponse CBCharacteristicWriteType = 1 )
func (CBCharacteristicWriteType) String ¶
func (e CBCharacteristicWriteType) String() string
type CBConnectionEvent ¶
type CBConnectionEvent int
See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectionEvent
const ( // CBConnectionEventPeerConnected: The peer has connected to the local device. CBConnectionEventPeerConnected CBConnectionEvent = 1 // CBConnectionEventPeerDisconnected: The peer has disconnected from the local device. CBConnectionEventPeerDisconnected CBConnectionEvent = 0 )
func (CBConnectionEvent) String ¶
func (e CBConnectionEvent) String() string
type CBConnectionEventMatchingOption ¶
type CBConnectionEventMatchingOption = string
CBConnectionEventMatchingOption is a set of options to use when registering for connection events.
See: https://developer.apple.com/documentation/CoreBluetooth/CBConnectionEventMatchingOption
type CBDescriptor ¶
type CBDescriptor struct {
CBAttribute
}
An object that provides further information about a remote peripheral’s characteristic.
Overview ¶
CBDescriptor and its subclass CBMutableDescriptor represent a descriptor of a peripheral’s characteristic. In partcular, CBDescriptor objects represent the descriptors of a remote peripheral’s characteristic. Descriptors provide further information about a characteristic’s value. For example, they may describe the value in human-readable form and describe how to format the value for presentation purposes. Characteristic descriptors also indicate whether a characteristic’s value indicates or notifies a client (a central) when the value of the characteristic changes.
CBUUID details six predefined descriptors and their corresponding value types. CBDescriptor lists the predefined descriptors and the CBUUID constants that represent them.
[Table data omitted]
Identifying a Descriptor ¶
- CBDescriptor.Characteristic: The characteristic to which this descriptor belongs.
Accessing Descriptor Data ¶
- CBDescriptor.Value: The value of the descriptor.
See: https://developer.apple.com/documentation/CoreBluetooth/CBDescriptor
func CBDescriptorFromID ¶
func CBDescriptorFromID(id objc.ID) CBDescriptor
CBDescriptorFromID constructs a CBDescriptor from an objc.ID.
An object that provides further information about a remote peripheral’s characteristic.
func NewCBDescriptor ¶
func NewCBDescriptor() CBDescriptor
NewCBDescriptor creates a new CBDescriptor instance.
func (CBDescriptor) Autorelease ¶
func (c CBDescriptor) Autorelease() CBDescriptor
Autorelease adds the receiver to the current autorelease pool.
func (CBDescriptor) Characteristic ¶
func (c CBDescriptor) Characteristic() ICBCharacteristic
The characteristic to which this descriptor belongs.
See: https://developer.apple.com/documentation/CoreBluetooth/CBDescriptor/characteristic
func (CBDescriptor) Value ¶
func (c CBDescriptor) Value() objectivec.IObject
The value of the descriptor.
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 CBPeripheral.ReadValueForDescriptor method of the CBPeripheral class. You can write the value of a descriptor by calling the CBPeripheral.WriteValueForDescriptor method of the CBPeripheral class. You can’t, however, use the CBPeripheral.WriteValueForDescriptor method to write the value of a client configuration descriptor (CBUUIDClientCharacteristicConfigurationString). Instead, you use the CBPeripheral.SetNotifyValueForCharacteristic method of the CBPeripheral class to configure client indications or notifications of a characteristic’s value on a server.
See: https://developer.apple.com/documentation/CoreBluetooth/CBDescriptor/value
type CBDescriptorClass ¶
type CBDescriptorClass struct {
// contains filtered or unexported fields
}
func GetCBDescriptorClass ¶
func GetCBDescriptorClass() CBDescriptorClass
GetCBDescriptorClass returns the class object for CBDescriptor.
func (CBDescriptorClass) Alloc ¶
func (cc CBDescriptorClass) Alloc() CBDescriptor
Alloc allocates memory for a new instance of the class.
func (CBDescriptorClass) Class ¶
func (cc CBDescriptorClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBError ¶
type CBError int
See: https://developer.apple.com/documentation/CoreBluetooth/CBError-swift.struct/Code
const ( // CBErrorAlreadyAdvertising: The peripheral is already advertising. CBErrorAlreadyAdvertising CBError = 9 // CBErrorConnectionFailed: The connection failed. CBErrorConnectionFailed CBError = 10 // CBErrorConnectionLimitReached: The device already has the maximum number of connections. CBErrorConnectionLimitReached CBError = 11 // CBErrorConnectionTimeout: The connection timed out. CBErrorConnectionTimeout CBError = 6 CBErrorEncryptionTimedOut CBError = 15 // CBErrorInvalidHandle: The specified attribute handle is invalid. CBErrorInvalidHandle CBError = 2 // CBErrorInvalidParameters: The specified parameters are invalid. CBErrorInvalidParameters CBError = 1 CBErrorLeGattExceededBackgroundNotificationLimit CBError = 17 CBErrorLeGattNearBackgroundNotificationLimit CBError = 18 // CBErrorNotConnected: The device isn’t currently connected. CBErrorNotConnected CBError = 3 // CBErrorOperationCancelled: The error represents a canceled operation. CBErrorOperationCancelled CBError = 5 // CBErrorOperationNotSupported: The operation isn’t supported. CBErrorOperationNotSupported CBError = 13 // CBErrorOutOfSpace: The device has run out of space to complete the intended operation. CBErrorOutOfSpace CBError = 4 CBErrorPeerRemovedPairingInformation CBError = 14 // CBErrorPeripheralDisconnected: The peripheral disconnected. CBErrorPeripheralDisconnected CBError = 7 CBErrorTooManyLEPairedDevices CBError = 16 // CBErrorUUIDNotAllowed: The specified UUID isn’t permitted. CBErrorUUIDNotAllowed CBError = 8 // CBErrorUnknown: An unknown error occurred. CBErrorUnknown CBError = 0 CBErrorUnknownDevice CBError = 12 // CBErrorUnkownDevice: A misspelled version of the unknown device error code. CBErrorUnkownDevice CBError = 12 )
type CBL2CAPChannel ¶
type CBL2CAPChannel struct {
objectivec.Object
}
A live L2CAP connection to a remote device.
Accessing Streams ¶
- CBL2CAPChannel.InputStream: The stream used for reading data from the remote peer.
- CBL2CAPChannel.OutputStream: The stream used for writing data to the peer.
Accessing the Peer ¶
- CBL2CAPChannel.Peer: The peer connected to the channel.
Accessing the Protocol/Service Multiplexer ¶
- CBL2CAPChannel.PSM: The PSM of the channel.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel
func CBL2CAPChannelFromID ¶
func CBL2CAPChannelFromID(id objc.ID) CBL2CAPChannel
CBL2CAPChannelFromID constructs a CBL2CAPChannel from an objc.ID.
A live L2CAP connection to a remote device.
func NewCBL2CAPChannel ¶
func NewCBL2CAPChannel() CBL2CAPChannel
NewCBL2CAPChannel creates a new CBL2CAPChannel instance.
func (CBL2CAPChannel) Autorelease ¶
func (c CBL2CAPChannel) Autorelease() CBL2CAPChannel
Autorelease adds the receiver to the current autorelease pool.
func (CBL2CAPChannel) Init ¶
func (c CBL2CAPChannel) Init() CBL2CAPChannel
Init initializes the instance.
func (CBL2CAPChannel) InputStream ¶
func (c CBL2CAPChannel) InputStream() foundation.InputStream
The stream used for reading data from the remote peer.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel/inputStream
func (CBL2CAPChannel) OutputStream ¶
func (c CBL2CAPChannel) OutputStream() foundation.OutputStream
The stream used for writing data to the peer.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel/outputStream
func (CBL2CAPChannel) PSM ¶
func (c CBL2CAPChannel) PSM() CBL2CAPPSM
The PSM of the channel.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel/psm
func (CBL2CAPChannel) Peer ¶
func (c CBL2CAPChannel) Peer() ICBPeer
The peer connected to the channel.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel/peer
type CBL2CAPChannelClass ¶
type CBL2CAPChannelClass struct {
// contains filtered or unexported fields
}
func GetCBL2CAPChannelClass ¶
func GetCBL2CAPChannelClass() CBL2CAPChannelClass
GetCBL2CAPChannelClass returns the class object for CBL2CAPChannel.
func (CBL2CAPChannelClass) Alloc ¶
func (cc CBL2CAPChannelClass) Alloc() CBL2CAPChannel
Alloc allocates memory for a new instance of the class.
func (CBL2CAPChannelClass) Class ¶
func (cc CBL2CAPChannelClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBL2CAPPSM ¶
type CBL2CAPPSM = uint16
CBL2CAPPSM is the type of PSM identifiers.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPPSM
type CBManager ¶
type CBManager struct {
objectivec.Object
}
The abstract base class that manages central and peripheral objects.
Accessing the Manager’s Properties ¶
- CBManager.State: The current state of the manager.
Deprecated Properties ¶
- CBManager.Authorization: The current authorization status for using Bluetooth.
See: https://developer.apple.com/documentation/CoreBluetooth/CBManager
func CBManagerFromID ¶
CBManagerFromID constructs a CBManager from an objc.ID.
The abstract base class that manages central and peripheral objects.
func (CBManager) Authorization ¶
func (c CBManager) Authorization() CBManagerAuthorization
The current authorization status for using Bluetooth.
See: https://developer.apple.com/documentation/CoreBluetooth/CBManager/authorization-swift.property
func (CBManager) Autorelease ¶
Autorelease adds the receiver to the current autorelease pool.
func (CBManager) State ¶
func (c CBManager) State() CBManagerState
The current state of the manager.
Discussion ¶
This state is initially set to CBManagerState.unknown. When the state updates, the manager calls its delegate’s [CentralManagerDidUpdateState] method.
See: https://developer.apple.com/documentation/CoreBluetooth/CBManager/state
type CBManagerAuthorization ¶
type CBManagerAuthorization int
See: https://developer.apple.com/documentation/CoreBluetooth/CBManagerAuthorization
const ( // CBManagerAuthorizationAllowedAlways: A state that indicates the user has authorized Bluetooth at any time. CBManagerAuthorizationAllowedAlways CBManagerAuthorization = 3 // CBManagerAuthorizationDenied: A state that indicates the user explicitly denied Bluetooth access for this app. CBManagerAuthorizationDenied CBManagerAuthorization = 2 // CBManagerAuthorizationNotDetermined: A state that indicates the user has yet to authorize Bluetooth for this app. CBManagerAuthorizationNotDetermined CBManagerAuthorization = 0 // CBManagerAuthorizationRestricted: A state that indicates this app isn’t authorized to use Bluetooth. CBManagerAuthorizationRestricted CBManagerAuthorization = 1 )
func (CBManagerAuthorization) String ¶
func (e CBManagerAuthorization) String() string
type CBManagerClass ¶
type CBManagerClass struct {
// contains filtered or unexported fields
}
func GetCBManagerClass ¶
func GetCBManagerClass() CBManagerClass
GetCBManagerClass returns the class object for CBManager.
func (CBManagerClass) Alloc ¶
func (cc CBManagerClass) Alloc() CBManager
Alloc allocates memory for a new instance of the class.
func (CBManagerClass) Class ¶
func (cc CBManagerClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBManagerState ¶
type CBManagerState int
See: https://developer.apple.com/documentation/CoreBluetooth/CBManagerState
const ( // CBManagerStatePoweredOff: A state that indicates Bluetooth is currently powered off. CBManagerStatePoweredOff CBManagerState = 4 // CBManagerStatePoweredOn: A state that indicates Bluetooth is currently powered on and available to use. CBManagerStatePoweredOn CBManagerState = 5 // CBManagerStateResetting: A state that indicates the connection with the system service was momentarily lost. CBManagerStateResetting CBManagerState = 1 CBManagerStateUnauthorized CBManagerState = 3 // CBManagerStateUnknown: The manager’s state is unknown. CBManagerStateUnknown CBManagerState = 0 // CBManagerStateUnsupported: A state that indicates this device doesn’t support the Bluetooth low energy central or client role. CBManagerStateUnsupported CBManagerState = 2 )
func (CBManagerState) String ¶
func (e CBManagerState) String() string
type CBMutableCharacteristic ¶
type CBMutableCharacteristic struct {
CBCharacteristic
}
A characteristic of a local peripheral’s service.
Overview ¶
CBMutableCharacteristic objects represent the characteristics of a local peripheral’s service. This class adds write access to many of the properties in the CBCharacteristic class, which it inherits from.
You use this class to create a characteristic and to set its properties and permissions as desired. After you create and add a characteristic to a local service, you can publish it (and the service) to the peripheral’s local database with the CBPeripheralManager.AddService method of the CBPeripheralManager class. After you publish a characteristic, Core Bluetooth caches the characteristic and you can’t make changes to it.
Creating a Mutable Characteristic ¶
- CBMutableCharacteristic.InitWithTypePropertiesValuePermissions: Creates a mutable characteristic with specified permissions, properties, and value.
Managing a Mutable Characteristic ¶
- CBMutableCharacteristic.Permissions: The permissions of the characteristic value.
- CBMutableCharacteristic.SetPermissions
- CBMutableCharacteristic.SubscribedCentrals: A list of centrals that are currently subscribed to the characteristic’s value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableCharacteristic
func CBMutableCharacteristicFromID ¶
func CBMutableCharacteristicFromID(id objc.ID) CBMutableCharacteristic
CBMutableCharacteristicFromID constructs a CBMutableCharacteristic from an objc.ID.
A characteristic of a local peripheral’s service.
func NewCBMutableCharacteristic ¶
func NewCBMutableCharacteristic() CBMutableCharacteristic
NewCBMutableCharacteristic creates a new CBMutableCharacteristic instance.
func NewCBMutableCharacteristicWithTypePropertiesValuePermissions ¶
func NewCBMutableCharacteristicWithTypePropertiesValuePermissions(UUID ICBUUID, properties CBCharacteristicProperties, value foundation.NSData, permissions CBAttributePermissions) CBMutableCharacteristic
Creates a mutable characteristic with specified permissions, properties, and value.
UUID: A 128-bit UUID that identifies the characteristic.
properties: The properties of the characteristic.
value: The characteristic value to cache. If `nil`, the value is dynamic and the peripheral manager fetches it on demand.
permissions: The permissions of the characteristic value.
Return Value ¶
A newly initialized mutable characteristic.
Discussion ¶
If you specify a value for the characteristic, the characteristic caches the value and sets its properties and permissions to CBCharacteristicPropertyRead and CBAttributePermissionsReadable, respectively. Therefore, if you need the value of a characteristic to be writeable, or if you expect the value to change during the lifetime of the published service to which the characteristic belongs, you must specify the value as `nil`. This ensures that the characteristic treats the value dynamically. With a dynamic value, the peripheral manager requests the value whenever the peripheral manager receives a read or write request from a central. The peripheral does this by calling the [PeripheralManagerDidReceiveReadRequest] and [PeripheralManagerDidReceiveWriteRequests] methods of its delegate object, respectively.
For more information, see Core Bluetooth Programming Guide.
func (CBMutableCharacteristic) Autorelease ¶
func (c CBMutableCharacteristic) Autorelease() CBMutableCharacteristic
Autorelease adds the receiver to the current autorelease pool.
func (CBMutableCharacteristic) Init ¶
func (c CBMutableCharacteristic) Init() CBMutableCharacteristic
Init initializes the instance.
func (CBMutableCharacteristic) InitWithTypePropertiesValuePermissions ¶
func (c CBMutableCharacteristic) InitWithTypePropertiesValuePermissions(UUID ICBUUID, properties CBCharacteristicProperties, value foundation.NSData, permissions CBAttributePermissions) CBMutableCharacteristic
Creates a mutable characteristic with specified permissions, properties, and value.
UUID: A 128-bit UUID that identifies the characteristic.
properties: The properties of the characteristic.
value: The characteristic value to cache. If `nil`, the value is dynamic and the peripheral manager fetches it on demand.
permissions: The permissions of the characteristic value.
Return Value ¶
A newly initialized mutable characteristic.
Discussion ¶
If you specify a value for the characteristic, the characteristic caches the value and sets its properties and permissions to CBCharacteristicPropertyRead and CBAttributePermissionsReadable, respectively. Therefore, if you need the value of a characteristic to be writeable, or if you expect the value to change during the lifetime of the published service to which the characteristic belongs, you must specify the value as `nil`. This ensures that the characteristic treats the value dynamically. With a dynamic value, the peripheral manager requests the value whenever the peripheral manager receives a read or write request from a central. The peripheral does this by calling the [PeripheralManagerDidReceiveReadRequest] and [PeripheralManagerDidReceiveWriteRequests] methods of its delegate object, respectively.
For more information, see Core Bluetooth Programming Guide.
func (CBMutableCharacteristic) Permissions ¶
func (c CBMutableCharacteristic) Permissions() CBAttributePermissions
The permissions of the characteristic value.
Discussion ¶
Characteristic permissions represent the read, write, and encryption permissions for a characteristic’s value. For a complete list and discussion of the available characteristic permissions, see CBAttributePermissions.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableCharacteristic/permissions
func (CBMutableCharacteristic) SetPermissions ¶
func (c CBMutableCharacteristic) SetPermissions(value CBAttributePermissions)
func (CBMutableCharacteristic) SubscribedCentrals ¶
func (c CBMutableCharacteristic) SubscribedCentrals() []CBCentral
A list of centrals that are currently subscribed to the characteristic’s value.
Discussion ¶
The value of this property is an array of CBCentral objects that currently subscribe to the characteristic’s value. The array is empty if the characteristic isn’t configured to support notifications or indications. Even if the characteristic’s configuration supports notifications or indications, the array is empty if centrals aren’t subscribing to the characteristic’s value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableCharacteristic/subscribedCentrals
type CBMutableCharacteristicClass ¶
type CBMutableCharacteristicClass struct {
// contains filtered or unexported fields
}
func GetCBMutableCharacteristicClass ¶
func GetCBMutableCharacteristicClass() CBMutableCharacteristicClass
GetCBMutableCharacteristicClass returns the class object for CBMutableCharacteristic.
func (CBMutableCharacteristicClass) Alloc ¶
func (cc CBMutableCharacteristicClass) Alloc() CBMutableCharacteristic
Alloc allocates memory for a new instance of the class.
func (CBMutableCharacteristicClass) Class ¶
func (cc CBMutableCharacteristicClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBMutableDescriptor ¶
type CBMutableDescriptor struct {
CBDescriptor
}
An object that provides additional information about a local peripheral’s characteristic.
Overview ¶
You use the CBMutableDescriptor class to create a local characteristic descriptor. After you create a descriptor and associate it with a local characteristic, you can publish it to the peripheral’s local database using the CBPeripheralManager.AddService method of the CBPeripheralManager class. This also publishes the characteristic and local service to which the descriptor belongs. After you publish a local descriptor, Core Bluetooth caches the descriptor and you can no longer make changes to it.
CBUUID details predefined descriptor types and their corresponding value types. That said, only two of these are currently supported when creating local, mutable descriptors: the characteristic user description descriptor and the characteristic format descriptor. CBUUID declares these as the constants CBUUIDCharacteristicUserDescriptionString and CBUUIDCharacteristicFormatString, respectively. The system automatically creates the extended properties descriptor and the client configuration descriptor, depending on the properties of the characteristic to which the descriptor belongs.
Creating a Mutable Descriptor ¶
- CBMutableDescriptor.InitWithTypeValue: Creates a mutable descriptor with a specified value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableDescriptor
func CBMutableDescriptorFromID ¶
func CBMutableDescriptorFromID(id objc.ID) CBMutableDescriptor
CBMutableDescriptorFromID constructs a CBMutableDescriptor from an objc.ID.
An object that provides additional information about a local peripheral’s characteristic.
func NewCBMutableDescriptor ¶
func NewCBMutableDescriptor() CBMutableDescriptor
NewCBMutableDescriptor creates a new CBMutableDescriptor instance.
func NewCBMutableDescriptorWithTypeValue ¶
func NewCBMutableDescriptorWithTypeValue(UUID ICBUUID, value objectivec.IObject) CBMutableDescriptor
Creates a mutable descriptor with a specified value.
UUID: A 128-bit UUID that identifies the characteristic. You must use only one of the two currently supported descriptor types: CBUUIDCharacteristicUserDescriptionString or CBUUIDCharacteristicFormatString. For more details about these descriptor types, see CBUUID.
value: The descriptor value to cache. You must provide a non-`nil` value. Once published, you can’t update the value dynamically.
Return Value ¶
A newly initialized mutable descriptor.
Discussion ¶
The value type of `value` depends on the type of descriptor:
- The value type of CBUUIDCharacteristicUserDescriptionString is a string you use to provide a human-readable description of the characteristic’s value. - The value type of a CBUUIDCharacteristicFormatString is an NSData object that you use to specify how to format the characteristic’s value for presentation purposes.
If you want to create a local characteristic format descriptor, the descriptor’s value must conform to the attribute value of the characteristic format descriptor as defined in the Bluetooth 4.0 specification, Volume 3, Part G, Section 3.3.3.5.
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableDescriptor/init(type:value:)
func (CBMutableDescriptor) Autorelease ¶
func (c CBMutableDescriptor) Autorelease() CBMutableDescriptor
Autorelease adds the receiver to the current autorelease pool.
func (CBMutableDescriptor) Init ¶
func (c CBMutableDescriptor) Init() CBMutableDescriptor
Init initializes the instance.
func (CBMutableDescriptor) InitWithTypeValue ¶
func (c CBMutableDescriptor) InitWithTypeValue(UUID ICBUUID, value objectivec.IObject) CBMutableDescriptor
Creates a mutable descriptor with a specified value.
UUID: A 128-bit UUID that identifies the characteristic. You must use only one of the two currently supported descriptor types: CBUUIDCharacteristicUserDescriptionString or CBUUIDCharacteristicFormatString. For more details about these descriptor types, see CBUUID.
value: The descriptor value to cache. You must provide a non-`nil` value. Once published, you can’t update the value dynamically.
Return Value ¶
A newly initialized mutable descriptor.
Discussion ¶
The value type of `value` depends on the type of descriptor:
- The value type of CBUUIDCharacteristicUserDescriptionString is a string you use to provide a human-readable description of the characteristic’s value. - The value type of a CBUUIDCharacteristicFormatString is an NSData object that you use to specify how to format the characteristic’s value for presentation purposes.
If you want to create a local characteristic format descriptor, the descriptor’s value must conform to the attribute value of the characteristic format descriptor as defined in the Bluetooth 4.0 specification, Volume 3, Part G, Section 3.3.3.5.
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableDescriptor/init(type:value:)
type CBMutableDescriptorClass ¶
type CBMutableDescriptorClass struct {
// contains filtered or unexported fields
}
func GetCBMutableDescriptorClass ¶
func GetCBMutableDescriptorClass() CBMutableDescriptorClass
GetCBMutableDescriptorClass returns the class object for CBMutableDescriptor.
func (CBMutableDescriptorClass) Alloc ¶
func (cc CBMutableDescriptorClass) Alloc() CBMutableDescriptor
Alloc allocates memory for a new instance of the class.
func (CBMutableDescriptorClass) Class ¶
func (cc CBMutableDescriptorClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBMutableService ¶
type CBMutableService struct {
CBService
}
A service with writeable property values.
Overview ¶
The CBMutableService class adds write access to all of the properties in the CBService class it inherits from. You use this class to create a service or an included service on a local peripheral device (represented by a CBPeripheralManager object). After creating a service, you can add it to the peripheral’s local database using the CBPeripheralManager.AddService method of the CBPeripheralManager class. After you add a service to the peripheral’s local database, Core Bluetooth caches the service and you can no longer make changes to it.
Creating a Mutable Service ¶
- CBMutableService.InitWithTypePrimary: Creates a newly initialized mutable service specified by UUID and service type.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableService
func CBMutableServiceFromID ¶
func CBMutableServiceFromID(id objc.ID) CBMutableService
CBMutableServiceFromID constructs a CBMutableService from an objc.ID.
A service with writeable property values.
func NewCBMutableService ¶
func NewCBMutableService() CBMutableService
NewCBMutableService creates a new CBMutableService instance.
func NewCBMutableServiceWithTypePrimary ¶
func NewCBMutableServiceWithTypePrimary(UUID ICBUUID, isPrimary bool) CBMutableService
Creates a newly initialized mutable service specified by UUID and service type.
UUID: A 128-bit UUID that identifies the service.
isPrimary: A Boolean value that indicates whether the type of service is primary or secondary. If the value is true, the type of service is primary. If the value is false, the type of service is secondary.
Return Value ¶
A newly initialized mutable service.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableService/init(type:primary:)
func (CBMutableService) Autorelease ¶
func (c CBMutableService) Autorelease() CBMutableService
Autorelease adds the receiver to the current autorelease pool.
func (CBMutableService) Init ¶
func (c CBMutableService) Init() CBMutableService
Init initializes the instance.
func (CBMutableService) InitWithTypePrimary ¶
func (c CBMutableService) InitWithTypePrimary(UUID ICBUUID, isPrimary bool) CBMutableService
Creates a newly initialized mutable service specified by UUID and service type.
UUID: A 128-bit UUID that identifies the service.
isPrimary: A Boolean value that indicates whether the type of service is primary or secondary. If the value is true, the type of service is primary. If the value is false, the type of service is secondary.
Return Value ¶
A newly initialized mutable service.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableService/init(type:primary:)
type CBMutableServiceClass ¶
type CBMutableServiceClass struct {
// contains filtered or unexported fields
}
func GetCBMutableServiceClass ¶
func GetCBMutableServiceClass() CBMutableServiceClass
GetCBMutableServiceClass returns the class object for CBMutableService.
func (CBMutableServiceClass) Alloc ¶
func (cc CBMutableServiceClass) Alloc() CBMutableService
Alloc allocates memory for a new instance of the class.
func (CBMutableServiceClass) Class ¶
func (cc CBMutableServiceClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBPeer ¶
type CBPeer struct {
objectivec.Object
}
An object that represents a remote device.
Overview ¶
The CBPeer class is an abstract base class that defines common behavior for objects representing remote devices. You typically don’t create instances of either CBPeer or its concrete subclasses. Instead, the system creates them for you during the process of peer discovery.
Your app takes the role of either a central (by creating an instance of CBCentralManager) or a peripheral (by creating an instance of CBPeripheralManager), and interacts through the manager with remote devices in the opposite role. During the process of peer discovery, where a central device scans for peripherals advertising services, the system creates objects from the concrete subclasses of CBPeer to represent discovered remote devices. The concrete subclasses of CBPeer are CBPeripheral and CBCentral.
Identifying a Peer ¶
- CBPeer.Identifier: The UUID associated with the peer.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeer
func CBPeerFromID ¶
CBPeerFromID constructs a CBPeer from an objc.ID.
An object that represents a remote device.
func (CBPeer) Autorelease ¶
Autorelease adds the receiver to the current autorelease pool.
func (CBPeer) Identifier ¶
func (c CBPeer) Identifier() foundation.NSUUID
The UUID associated with the peer.
Discussion ¶
The value of this property represents the unique identifier of the peer. The first time a local manager encounters a peer, the system assigns the peer a UUID, represented by a new UUID object. Peers use UUID instances to identify themselves, instead of by the CBUUID objects that identify a peripheral’s services, characteristics, and descriptors.
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeer/identifier
type CBPeerClass ¶
type CBPeerClass struct {
// contains filtered or unexported fields
}
func GetCBPeerClass ¶
func GetCBPeerClass() CBPeerClass
GetCBPeerClass returns the class object for CBPeer.
func (CBPeerClass) Alloc ¶
func (cc CBPeerClass) Alloc() CBPeer
Alloc allocates memory for a new instance of the class.
func (CBPeerClass) Class ¶
func (cc CBPeerClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBPeripheral ¶
type CBPeripheral struct {
CBPeer
}
A remote peripheral device.
Overview ¶
The CBPeripheral class represents remote peripheral devices that your app discovers with a central manager (an instance of CBCentralManager). Peripherals use universally unique identifiers (UUIDs), represented by NSUUID objects, to identify themselves. Peripherals may contain one or more services or provide useful information about their connected signal strength.
You use this class to discover, explore, and interact with the services available on a remote peripheral that supports Bluetooth low energy. A service encapsulates the way part of the device behaves. For example, one service of a heart rate monitor may be to expose heart rate data from a sensor. Services themselves contain of characteristics or included services (references to other services). Characteristics provide further details about a peripheral’s service. For example, the heart rate service may contain multiple characteristics. One characteristic could describe the intended body location of the device’s heart rate sensor, and another characteristic could transmit the heart rate measurement data. Finally, characteristics contain any number of descriptors that provide more information about the characteristic’s value, such as a human-readable description and a way to format the value.
Identifying a Peripheral ¶
- CBPeripheral.Name: The name of the peripheral.
- CBPeripheral.Delegate: The delegate object specified to receive peripheral events.
- CBPeripheral.SetDelegate
Discovering Services ¶
- CBPeripheral.DiscoverServices: Discovers the specified services of the peripheral.
- CBPeripheral.DiscoverIncludedServicesForService: Discovers the specified included services of a previously-discovered service.
- CBPeripheral.Services: A list of a peripheral’s discovered services.
Discovering Characteristics and Descriptors ¶
- CBPeripheral.DiscoverCharacteristicsForService: Discovers the specified characteristics of a service.
- CBPeripheral.DiscoverDescriptorsForCharacteristic: Discovers the descriptors of a characteristic.
Reading Characteristic and Descriptor Values ¶
- CBPeripheral.ReadValueForCharacteristic: Retrieves the value of a specified characteristic.
- CBPeripheral.ReadValueForDescriptor: Retrieves the value of a specified characteristic descriptor.
Writing Characteristic and Descriptor Values ¶
- CBPeripheral.WriteValueForCharacteristicType: Writes the value of a characteristic.
- CBPeripheral.WriteValueForDescriptor: Writes the value of a characteristic descriptor.
- CBPeripheral.MaximumWriteValueLengthForType: The maximum amount of data, in bytes, you can send to a characteristic in a single write type.
Setting Notifications for a Characteristic’s Value ¶
- CBPeripheral.SetNotifyValueForCharacteristic: Sets notifications or indications for the value of a specified characteristic.
Monitoring a Peripheral’s Connection State ¶
- CBPeripheral.State: The connection state of the peripheral.
- CBPeripheral.CanSendWriteWithoutResponse: A Boolean value that indicates whether the remote device can send a write without a response.
Accessing a Peripheral’s Signal Strength ¶
- CBPeripheral.ReadRSSI: Retrieves the current RSSI value for the peripheral while connected to the central manager.
Working with L2CAP Channels ¶
- CBPeripheral.OpenL2CAPChannel: Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM).
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral
func CBPeripheralFromID ¶
func CBPeripheralFromID(id objc.ID) CBPeripheral
CBPeripheralFromID constructs a CBPeripheral from an objc.ID.
A remote peripheral device.
func NewCBPeripheral ¶
func NewCBPeripheral() CBPeripheral
NewCBPeripheral creates a new CBPeripheral instance.
func (CBPeripheral) Autorelease ¶
func (c CBPeripheral) Autorelease() CBPeripheral
Autorelease adds the receiver to the current autorelease pool.
func (CBPeripheral) CanSendWriteWithoutResponse ¶
func (c CBPeripheral) CanSendWriteWithoutResponse() bool
A Boolean value that indicates whether the remote device can send a write without a response.
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 [PeripheralIsReadyToSendWriteWithoutResponse].
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/canSendWriteWithoutResponse
func (CBPeripheral) Delegate ¶
func (c CBPeripheral) Delegate() CBPeripheralDelegate
The delegate object specified to receive peripheral events.
Discussion ¶
For information about how to implement your peripheral delegate, see CBPeripheralDelegate.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/delegate
func (CBPeripheral) DiscoverCharacteristicsForService ¶
func (c CBPeripheral) DiscoverCharacteristicsForService(characteristicUUIDs []CBUUID, service ICBService)
Discovers the specified characteristics of a service.
characteristicUUIDs: An array of CBUUID objects that you are interested in. Each CBUUID object represents a UUID that identifies the type of a characteristic you want to discover.
service: The service whose characteristics you want to discover.
Discussion ¶
You can provide an array of CBUUID objects—representing characteristic UUIDs— in the `characteristicUUIDs` parameter. When you do, the peripheral returns only the characteristics of the service that match the provided UUIDs. If the `characteristicUUIDs` parameter is `nil`, this method returns all characteristics of the service.
When the peripheral discovers one or more characteristics of the specified service, it calls the [PeripheralDidDiscoverCharacteristicsForServiceError] method of its delegate object. After the peripheral discovers the service’s characteristics, you can access them through the service’s CBService.Characteristics property.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/discoverCharacteristics(_:for:)
func (CBPeripheral) DiscoverDescriptorsForCharacteristic ¶
func (c CBPeripheral) DiscoverDescriptorsForCharacteristic(characteristic ICBCharacteristic)
Discovers the descriptors of a characteristic.
characteristic: The characteristic whose descriptors you want to discover.
Discussion ¶
When the peripheral discovers one or more descriptors of the specified characteristic, it calls the [PeripheralDidDiscoverDescriptorsForCharacteristicError] method of its delegate object. After the peripheral discovers the descriptors of the characteristic, you can access them through the characteristic’s CBCharacteristic.Descriptors property.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/discoverDescriptors(for:)
func (CBPeripheral) DiscoverIncludedServicesForService ¶
func (c CBPeripheral) DiscoverIncludedServicesForService(includedServiceUUIDs []CBUUID, service ICBService)
Discovers the specified included services of a previously-discovered service.
includedServiceUUIDs: An array of CBUUID objects that you are interested in. Here, each CBUUID object represents a UUID that identifies the type of included service you want to discover.
service: The previously-discovered service whose included services you want to discover.
Discussion ¶
You can provide an array of CBUUID objects—representing included service UUIDs—in the `includedServiceUUIDs` parameter. When you do, the peripheral returns only the services of the peripheral that match the provided UUIDs.
When the peripheral discovers one or more included services of the specified service, it calls the [PeripheralDidDiscoverIncludedServicesForServiceError] method of its delegate object. After the service discovers its included services, you can access them through the service’s CBService.IncludedServices property.
func (CBPeripheral) DiscoverServices ¶
func (c CBPeripheral) DiscoverServices(serviceUUIDs []CBUUID)
Discovers the specified services of the peripheral.
serviceUUIDs: 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.
Discussion ¶
You can provide an array of CBUUID objects—representing service UUIDs—in the `serviceUUIDs` parameter. When you do, the peripheral returns only the services of the peripheral that match the provided UUIDs.
When the peripheral discovers one or more services, it calls the [PeripheralDidDiscoverServices]: method of its delegate object. After a peripheral discovers services, you can access them through the peripheral’s CBPeripheral.Services property.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/discoverServices(_:)
func (CBPeripheral) MaximumWriteValueLengthForType ¶
func (c CBPeripheral) MaximumWriteValueLengthForType(type_ CBCharacteristicWriteType) uint
The maximum amount of data, in bytes, you can send to a characteristic in a single write type.
type: The characteristic write type to inspect.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/maximumWriteValueLength(for:)
func (CBPeripheral) Name ¶
func (c CBPeripheral) Name() string
The name of the peripheral.
Discussion ¶
Use this property to retrieve a human-readable name of the peripheral. A peripheral may have two different name types: one that the device advertises and another that the device publishes in its database as its Bluetooth low energy Generic Access Profile (GAP) device name. If a peripheral has both types of names, this property returns its GAP device name.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/name
func (CBPeripheral) OpenL2CAPChannel ¶
func (c CBPeripheral) OpenL2CAPChannel(PSM CBL2CAPPSM)
Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM).
PSM: The PSM of the channel to open.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/openL2CAPChannel(_:)
func (CBPeripheral) ReadRSSI ¶
func (c CBPeripheral) ReadRSSI()
Retrieves the current RSSI value for the peripheral while connected to the central manager.
Discussion ¶
On macOS, when you call this method to retrieve the Received Signal Strength Indicator (RSSI) of the peripheral while connected to the central manager, the peripheral calls the peripheralDidUpdateRSSI(_:error:) method of its delegate object. If retrieving the RSSI value of the peripheral succeeds, you can access it through the peripheral’s rssi property.
On iOS and tvOS, when you call this method to retrieve the RSSI of the peripheral while connected to the central manager, the peripheral calls the [PeripheralDidReadRSSIError] method of its delegate object, which includes the RSSI value as a parameter.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/readRSSI()
func (CBPeripheral) ReadValueForCharacteristic ¶
func (c CBPeripheral) ReadValueForCharacteristic(characteristic ICBCharacteristic)
Retrieves the value of a specified characteristic.
characteristic: The characteristic whose value you want to read.
Discussion ¶
When you call this method to read the value of a characteristic, the peripheral calls the [PeripheralDidUpdateValueForDescriptorError] method of its delegate object. If the peripheral successfully reads the value of the characteristic, you can access it through the characteristic’s CBCharacteristic.Value property.
Not all characteristics have a readable value. You can determine whether a characteristic’s value is readable by accessing the relevant properties of the CBCharacteristicProperties enumeration.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/readValue(for:)-6u2kr
func (CBPeripheral) ReadValueForDescriptor ¶
func (c CBPeripheral) ReadValueForDescriptor(descriptor ICBDescriptor)
Retrieves the value of a specified characteristic descriptor.
descriptor: The characteristic descriptor whose value you want to read.
Discussion ¶
When you call this method to read the value of a characteristic descriptor, the peripheral calls the [PeripheralDidUpdateValueForDescriptorError] method of its delegate object. If the peripheral successfully retrieves the value of the characteristic descriptor, you can access it through the characteristic descriptor’s CBDescriptor.Value property.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/readValue(for:)-91hhp
func (CBPeripheral) Services ¶
func (c CBPeripheral) Services() []CBService
A list of a peripheral’s discovered services.
Discussion ¶
Returns an array of services (represented by CBService objects) that successful call to the CBPeripheral.DiscoverServices method discovered. If you haven’t yet called the CBPeripheral.DiscoverServices method to discover the services of the peripheral, or if there was an error in doing so, the value of this property is `nil`.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/services
func (CBPeripheral) SetDelegate ¶
func (c CBPeripheral) SetDelegate(value CBPeripheralDelegate)
func (CBPeripheral) SetNotifyValueForCharacteristic ¶
func (c CBPeripheral) SetNotifyValueForCharacteristic(enabled bool, characteristic ICBCharacteristic)
Sets notifications or indications for the value of a specified characteristic.
enabled: A Boolean value that indicates whether to receive notifications or indications whenever the characteristic’s value changes. true if you want to enable notifications or indications for the characteristic’s value. false if you don’t want to receive notifications or indications whenever the characteristic’s value changes.
characteristic: The specified characteristic.
Discussion ¶
When you enable notifications for the characteristic’s value, the peripheral calls the [PeripheralDidUpdateNotificationStateForCharacteristicError] method of its delegate object to indicate if the action succeeded. If successful, the peripheral then calls the [PeripheralDidUpdateValueForDescriptorError] method of its delegate object whenever the characteristic value changes. Because the peripheral chooses when it sends an update, your app should prepare to handle them as long as notifications or indications remain enabled. If the specified characteristic’s configuration allows both notifications and indications, calling this method enables notifications only. You can disable notifications and indications for a characteristic’s value by calling this method with the `enabled` parameter set to false.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/setNotifyValue(_:for:)
func (CBPeripheral) State ¶
func (c CBPeripheral) State() CBPeripheralState
The connection state of the peripheral.
Discussion ¶
This property represents the current connection state of the peripheral. For a list of the possible values, see CBPeripheralState.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/state
func (CBPeripheral) WriteValueForCharacteristicType ¶
func (c CBPeripheral) WriteValueForCharacteristicType(data foundation.NSData, characteristic ICBCharacteristic, type_ CBCharacteristicWriteType)
Writes the value of a characteristic.
data: The value to write.
characteristic: The characteristic containing the value to write.
type: The type of write to execute. For a list of the possible types of writes to a characteristic’s value, see CBCharacteristicWriteType.
Discussion ¶
When you call this method to write the value of a characteristic, the peripheral calls the [PeripheralDidWriteValueForDescriptorError] method of its delegate object only if you specified the write type as CBCharacteristicWriteType.withResponse. The response you receive through the [PeripheralDidWriteValueForDescriptorError] delegate method indicates whether the write was successful; if the write failed, it details the cause of the failure in an error.
On the other hand, if you specify the write type as CBCharacteristicWriteType.withoutResponse, Core Bluetooth attempts to write the value but doesn’t guarantee success. If the write doesn’t succeed in this case, you aren’t notified and you don’t receive an error indicating the cause of the failure.
Use the CBCharacteristicPropertyWrite and CBCharacteristicPropertyWriteWithoutResponse members of the characteristic’s CBCharacteristic.Properties enumeration to determine which kinds of writes you can perform.
This method copies the data passed into the `data` parameter, and you can dispose of it after the method returns.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/writeValue(_:for:type:)
func (CBPeripheral) WriteValueForDescriptor ¶
func (c CBPeripheral) WriteValueForDescriptor(data foundation.NSData, descriptor ICBDescriptor)
Writes the value of a characteristic descriptor.
data: The value to write.
descriptor: The descriptor containing the value to write.
Discussion ¶
When you call this method to write the value of a characteristic descriptor, the peripheral calls the [PeripheralDidWriteValueForDescriptorError] method of its delegate object.
This method copies the `data` passed into the data parameter, and you can dispose of it after the method returns.
You can’t use this method to write the value of a client configuration descriptor (represented by the CBUUIDClientCharacteristicConfigurationString constant), which describes the configuration of notification or indications for a characteristic’s value. If you want to manage notifications or indications for a characteristic’s value, you must use the CBPeripheral.SetNotifyValueForCharacteristic method instead.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral/writeValue(_:for:)
type CBPeripheralClass ¶
type CBPeripheralClass struct {
// contains filtered or unexported fields
}
func GetCBPeripheralClass ¶
func GetCBPeripheralClass() CBPeripheralClass
GetCBPeripheralClass returns the class object for CBPeripheral.
func (CBPeripheralClass) Alloc ¶
func (cc CBPeripheralClass) Alloc() CBPeripheral
Alloc allocates memory for a new instance of the class.
func (CBPeripheralClass) Class ¶
func (cc CBPeripheralClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBPeripheralDelegate ¶
type CBPeripheralDelegate interface {
objectivec.IObject
}
A protocol that provides updates on the use of a peripheral’s services.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralDelegate
type CBPeripheralDelegateConfig ¶
type CBPeripheralDelegateConfig struct {
// Discovering Services
// PeripheralDidDiscoverServices — Tells the delegate that peripheral service discovery succeeded.
PeripheralDidDiscoverServices func(peripheral CBPeripheral, error_ foundation.NSError)
// Retrieving a Peripheral’s RSSI Data
// PeripheralDidReadRSSIError — Tells the delegate that retrieving the value of the peripheral’s current Received Signal Strength Indicator (RSSI) succeeded.
PeripheralDidReadRSSIError func(peripheral CBPeripheral, RSSI foundation.NSNumber, error_ foundation.NSError)
// Monitoring Changes to a Peripheral’s Name or Services
// PeripheralDidUpdateName — Tells the delegate that a peripheral’s name changed.
PeripheralDidUpdateName func(peripheral CBPeripheral)
// Other Methods
// PeripheralDidDiscoverIncludedServicesForServiceError — Tells the delegate that discovering included services within the indicated service completed.
PeripheralDidDiscoverIncludedServicesForServiceError func(peripheral CBPeripheral, service CBService, error_ foundation.NSError)
// PeripheralDidDiscoverCharacteristicsForServiceError — Tells the delegate that the peripheral found characteristics for a service.
PeripheralDidDiscoverCharacteristicsForServiceError func(peripheral CBPeripheral, service CBService, error_ foundation.NSError)
// PeripheralDidDiscoverDescriptorsForCharacteristicError — Tells the delegate that the peripheral found descriptors for a characteristic.
PeripheralDidDiscoverDescriptorsForCharacteristicError func(peripheral CBPeripheral, characteristic CBCharacteristic, error_ foundation.NSError)
// PeripheralDidUpdateValueForCharacteristicError — Tells the delegate that retrieving the specified characteristic’s value succeeded, or that the characteristic’s value changed.
PeripheralDidUpdateValueForCharacteristicError func(peripheral CBPeripheral, characteristic CBCharacteristic, error_ foundation.NSError)
// PeripheralDidUpdateValueForDescriptorError — Tells the delegate that retrieving a specified characteristic descriptor’s value succeeded.
PeripheralDidUpdateValueForDescriptorError func(peripheral CBPeripheral, descriptor CBDescriptor, error_ foundation.NSError)
// PeripheralDidWriteValueForCharacteristicError — Tells the delegate that the peripheral successfully set a value for the characteristic.
PeripheralDidWriteValueForCharacteristicError func(peripheral CBPeripheral, characteristic CBCharacteristic, error_ foundation.NSError)
// PeripheralDidWriteValueForDescriptorError — Tells the delegate that the peripheral successfully set a value for the descriptor.
PeripheralDidWriteValueForDescriptorError func(peripheral CBPeripheral, descriptor CBDescriptor, error_ foundation.NSError)
// PeripheralIsReadyToSendWriteWithoutResponse — Tells the delegate that a peripheral is again ready to send characteristic updates.
PeripheralIsReadyToSendWriteWithoutResponse func(peripheral CBPeripheral)
// PeripheralDidUpdateNotificationStateForCharacteristicError — Tells the delegate that the peripheral received a request to start or stop providing notifications for a specified characteristic’s value.
PeripheralDidUpdateNotificationStateForCharacteristicError func(peripheral CBPeripheral, characteristic CBCharacteristic, error_ foundation.NSError)
// PeripheralDidOpenL2CAPChannelError — Delivers the result of an attempt to open an L2CAP channel.
PeripheralDidOpenL2CAPChannelError func(peripheral CBPeripheral, channel CBL2CAPChannel, error_ foundation.NSError)
}
CBPeripheralDelegateConfig holds optional typed callbacks for CBPeripheralDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.
See Apple Documentation for protocol details.
type CBPeripheralDelegateObject ¶
type CBPeripheralDelegateObject struct {
objectivec.Object
}
CBPeripheralDelegateObject wraps an existing Objective-C object that conforms to the CBPeripheralDelegate protocol.
func CBPeripheralDelegateObjectFromID ¶
func CBPeripheralDelegateObjectFromID(id objc.ID) CBPeripheralDelegateObject
CBPeripheralDelegateObjectFromID constructs a CBPeripheralDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.
func NewCBPeripheralDelegate ¶
func NewCBPeripheralDelegate(config CBPeripheralDelegateConfig) CBPeripheralDelegateObject
NewCBPeripheralDelegate creates an Objective-C object implementing the CBPeripheralDelegate protocol.
Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.
The returned CBPeripheralDelegateObject satisfies the CBPeripheralDelegate interface and can be passed directly to SetDelegate and similar methods.
See Apple Documentation for protocol details.
func (CBPeripheralDelegateObject) BaseObject ¶
func (o CBPeripheralDelegateObject) BaseObject() objectivec.Object
func (CBPeripheralDelegateObject) PeripheralDidCompleteChannelSoundingSession ¶
func (o CBPeripheralDelegateObject) PeripheralDidCompleteChannelSoundingSession(peripheral ICBPeripheral, error_ foundation.NSError)
peripheral: The peripheral providing this update.
error: If an error occurred, the cause of the failure.
Discussion ¶
This method is called when a channel sounding session completes.
func (CBPeripheralDelegateObject) PeripheralDidDiscoverCharacteristicsForServiceError ¶
func (o CBPeripheralDelegateObject) PeripheralDidDiscoverCharacteristicsForServiceError(peripheral ICBPeripheral, service ICBService, error_ foundation.NSError)
Tells the delegate that the peripheral found characteristics for a service.
peripheral: The peripheral providing this information.
service: The service to which the characteristics belong.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.DiscoverCharacteristicsForService method. If the peripheral successfully discovers the characteristics of the specified service, you can access them through the service’s CBService.Characteristics property. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidDiscoverDescriptorsForCharacteristicError ¶
func (o CBPeripheralDelegateObject) PeripheralDidDiscoverDescriptorsForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, error_ foundation.NSError)
Tells the delegate that the peripheral found descriptors for a characteristic.
peripheral: The peripheral providing this information.
characteristic: The characteristic to which the characteristic descriptors belong.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.DiscoverDescriptorsForCharacteristic method. If the peripheral successfully discovers the descriptors of the specified characteristic, you can access them through the characteristic’s CBCharacteristic.Descriptors property. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidDiscoverIncludedServicesForServiceError ¶
func (o CBPeripheralDelegateObject) PeripheralDidDiscoverIncludedServicesForServiceError(peripheral ICBPeripheral, service ICBService, error_ foundation.NSError)
Tells the delegate that discovering included services within the indicated service completed.
peripheral: The peripheral providing this information.
service: The CBService object containing the included service.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.DiscoverIncludedServicesForService method. If the peripheral successfully discovers services, you can access them through the service’s CBService.IncludedServices property. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidDiscoverServices ¶
func (o CBPeripheralDelegateObject) PeripheralDidDiscoverServices(peripheral ICBPeripheral, error_ foundation.NSError)
Tells the delegate that peripheral service discovery succeeded.
peripheral: The peripheral to which the services belong.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.DiscoverServices method. If the peripheral successfully discovers services, you can access them through the peripheral’s CBPeripheral.Services property. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
For more information, see Core Bluetooth Programming Guide.
func (CBPeripheralDelegateObject) PeripheralDidModifyServices ¶
func (o CBPeripheralDelegateObject) PeripheralDidModifyServices(peripheral ICBPeripheral, invalidatedServices []CBService)
Tells the delegate that a peripheral’s services changed.
peripheral: The peripheral providing this information.
invalidatedServices: A list of services invalidated by this change.
Discussion ¶
Core Bluetooth invokes this method whenever one or more services of a peripheral change. A peripheral’s services have changed if:
- The peripheral removes a service from its database. - The peripheral adds a new service to its database. - The peripheral adds back a previously-removed service, but at a different location in the database.
The `invalidatedServices` parameter includes any changed services that you previously discovered; you can no longer use these services. You can use the CBPeripheral.DiscoverServices method to discover any new services that the peripheral added to its database. Use this same method to find out whether any of the invalidated services that you were using (and want to continue using) now have a different location in the peripheral’s database.
func (CBPeripheralDelegateObject) PeripheralDidOpenL2CAPChannelError ¶
func (o CBPeripheralDelegateObject) PeripheralDidOpenL2CAPChannelError(peripheral ICBPeripheral, channel ICBL2CAPChannel, error_ foundation.NSError)
Delivers the result of an attempt to open an L2CAP channel.
Discussion ¶
This method delivers the result of a previous call to CBPeripheral.OpenL2CAPChannel.
func (CBPeripheralDelegateObject) PeripheralDidReadRSSIError ¶
func (o CBPeripheralDelegateObject) PeripheralDidReadRSSIError(peripheral ICBPeripheral, RSSI foundation.NSNumber, error_ foundation.NSError)
Tells the delegate that retrieving the value of the peripheral’s current Received Signal Strength Indicator (RSSI) succeeded.
peripheral: The peripheral providing this information.
RSSI: The RSSI, in decibels, of the peripheral.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.ReadRSSI method, while the peripheral is connected to the central manager. If successful, the `error` parameter is `nil` and the parameter [RSSI] reports the peripheral’s signal strength, in decibels. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidReceiveChannelSoundingProcedureResultsError ¶
func (o CBPeripheralDelegateObject) PeripheralDidReceiveChannelSoundingProcedureResultsError(peripheral ICBPeripheral, results *uintptr, error_ foundation.NSError)
peripheral: The peripheral providing this update.
results: An object containing the results of a channel sounding procedure.
error: If an error occurred, the cause of the failure.
Discussion ¶
This method returns the results of a channel sounding procedure.
func (CBPeripheralDelegateObject) PeripheralDidUpdateName ¶
func (o CBPeripheralDelegateObject) PeripheralDidUpdateName(peripheral ICBPeripheral)
Tells the delegate that a peripheral’s name changed.
peripheral: The peripheral providing this information.
Discussion ¶
Core Bluetooth invokes this method whenever the peripheral’s Generic Access Profile (GAP) device name changes. Since a peripheral device can change its GAP device name, you can implement this method if your app needs to display the current name of the peripheral device.
func (CBPeripheralDelegateObject) PeripheralDidUpdateNotificationStateForCharacteristicError ¶
func (o CBPeripheralDelegateObject) PeripheralDidUpdateNotificationStateForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, error_ foundation.NSError)
Tells the delegate that the peripheral received a request to start or stop providing notifications for a specified characteristic’s value.
peripheral: The peripheral providing this information.
characteristic: The characteristic for which to configure value notifications.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.SetNotifyValueForCharacteristic method. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidUpdateValueForCharacteristicError ¶
func (o CBPeripheralDelegateObject) PeripheralDidUpdateValueForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, error_ foundation.NSError)
Tells the delegate that retrieving the specified characteristic’s value succeeded, or that the characteristic’s value changed.
peripheral: The peripheral providing this information.
characteristic: The characteristic containing the value.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.ReadValueForDescriptor method. A peripheral also invokes this method to notify your app of a change to the value of the characteristic for which the app previously enabled notifications by calling CBPeripheral.SetNotifyValueForCharacteristic. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidUpdateValueForDescriptorError ¶
func (o CBPeripheralDelegateObject) PeripheralDidUpdateValueForDescriptorError(peripheral ICBPeripheral, descriptor ICBDescriptor, error_ foundation.NSError)
Tells the delegate that retrieving a specified characteristic descriptor’s value succeeded.
peripheral: The peripheral providing this information.
descriptor: The characteristic descriptor containing the value.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.ReadValueForDescriptor method. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidWriteValueForCharacteristicError ¶
func (o CBPeripheralDelegateObject) PeripheralDidWriteValueForCharacteristicError(peripheral ICBPeripheral, characteristic ICBCharacteristic, error_ foundation.NSError)
Tells the delegate that the peripheral successfully set a value for the characteristic.
peripheral: The peripheral providing this information.
characteristic: The characteristic containing the value.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method only when your app calls the CBPeripheral.WriteValueForCharacteristicType method with the CBCharacteristicWriteType.withResponse constant specified as the write type. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralDidWriteValueForDescriptorError ¶
func (o CBPeripheralDelegateObject) PeripheralDidWriteValueForDescriptorError(peripheral ICBPeripheral, descriptor ICBDescriptor, error_ foundation.NSError)
Tells the delegate that the peripheral successfully set a value for the descriptor.
peripheral: The peripheral providing this information.
descriptor: The characteristic descriptor containing the value.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheral.WriteValueForDescriptor method. If successful, the `error` parameter is `nil`. If unsuccessful, the `error` parameter returns the cause of the failure.
func (CBPeripheralDelegateObject) PeripheralIsReadyToSendWriteWithoutResponse ¶
func (o CBPeripheralDelegateObject) PeripheralIsReadyToSendWriteWithoutResponse(peripheral ICBPeripheral)
Tells the delegate that a peripheral is again ready to send characteristic updates.
peripheral: The peripheral providing this update.
Discussion ¶
The peripheral calls this delegate method after a failed call to CBPeripheral.WriteValueForCharacteristicType, once `peripheral` is ready to send characteristic value updates.
type CBPeripheralManager ¶
type CBPeripheralManager struct {
CBManager
}
An object that manages and advertises peripheral services exposed by this app.
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 CBPeripheralManagerState.poweredOn. 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.
In watchOS, tvOS, and visionOS, you can’t advertise services using a CBPeripheralManager object because support for doing so is unavailable.
Initializing a Peripheral Manager ¶
- CBPeripheralManager.InitWithDelegateQueue: Initializes the peripheral manager with a specified delegate and dispatch queue.
- CBPeripheralManager.InitWithDelegateQueueOptions: Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.
- CBPeripheralManager.Delegate: The delegate object specified to receive peripheral events.
- CBPeripheralManager.SetDelegate
Adding and Removing Services ¶
- CBPeripheralManager.AddService: Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.
- CBPeripheralManager.RemoveService: Removes a specified published service from the local GATT database.
- CBPeripheralManager.RemoveAllServices: Removes all published services from the local GATT database.
Managing Advertising ¶
- CBPeripheralManager.StartAdvertising: Advertises peripheral manager data.
- CBPeripheralManager.StopAdvertising: Stops advertising peripheral manager data.
- CBPeripheralManager.IsAdvertising: A Boolean value that indicates whether the peripheral is advertising data.
Sending Updates of a Characteristic’s Value ¶
- CBPeripheralManager.UpdateValueForCharacteristicOnSubscribedCentrals: Send an updated characteristic value to one or more subscribed centrals, using a notification or indication.
Responding to Read and Write Requests ¶
- CBPeripheralManager.RespondToRequestWithResult: Responds to a read or write request from a connected central.
Setting Connection Latency ¶
- CBPeripheralManager.SetDesiredConnectionLatencyForCentral: Sets the desired connection latency for an existing connection to a central device.
Using L2CAP Channels ¶
- CBPeripheralManager.PublishL2CAPChannelWithEncryption: Creates a listener for incoming L2CAP channel connections.
- CBPeripheralManager.UnpublishL2CAPChannel: Removes a published service from the local system.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager
func CBPeripheralManagerFromID ¶
func CBPeripheralManagerFromID(id objc.ID) CBPeripheralManager
CBPeripheralManagerFromID constructs a CBPeripheralManager from an objc.ID.
An object that manages and advertises peripheral services exposed by this app.
func NewCBPeripheralManager ¶
func NewCBPeripheralManager() CBPeripheralManager
NewCBPeripheralManager creates a new CBPeripheralManager instance.
func NewCBPeripheralManagerWithDelegateQueue ¶
func NewCBPeripheralManagerWithDelegateQueue(delegate CBPeripheralManagerDelegate, queue dispatch.Queue) CBPeripheralManager
Initializes the peripheral manager with a specified delegate and dispatch queue.
delegate: The delegate to receive the peripheral role events.
queue: 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.
Return Value ¶
Returns a newly initialized peripheral manager.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/init(delegate:queue:)
func NewCBPeripheralManagerWithDelegateQueueOptions ¶
func NewCBPeripheralManagerWithDelegateQueueOptions(delegate CBPeripheralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBPeripheralManager
Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.
delegate: The delegate to receive the peripheral role events.
queue: 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: An optional dictionary containing initialization options for a peripheral manager. For available options, see Peripheral Manager Initialization Options.
Return Value ¶
Returns a newly initialized peripheral manager.
Discussion ¶
This method is the designated initializer for the CBPeripheralManager class.
func (CBPeripheralManager) AddService ¶
func (c CBPeripheralManager) AddService(service ICBMutableService)
Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.
service: The service you want to publish.
Discussion ¶
When you add a service to the database, the peripheral manager calls the [PeripheralManagerDidAddServiceError] method of its delegate object. If the service contains any included services, you must first publish them.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/add(_:)
func (CBPeripheralManager) Autorelease ¶
func (c CBPeripheralManager) Autorelease() CBPeripheralManager
Autorelease adds the receiver to the current autorelease pool.
func (CBPeripheralManager) Delegate ¶
func (c CBPeripheralManager) Delegate() CBPeripheralManagerDelegate
The delegate object specified to receive peripheral events.
Discussion ¶
For information about how to implement your peripheral manager delegate, see CBPeripheralManagerDelegate.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/delegate
func (CBPeripheralManager) Init ¶
func (c CBPeripheralManager) Init() CBPeripheralManager
Init initializes the instance.
func (CBPeripheralManager) InitWithDelegateQueue ¶
func (c CBPeripheralManager) InitWithDelegateQueue(delegate CBPeripheralManagerDelegate, queue dispatch.Queue) CBPeripheralManager
Initializes the peripheral manager with a specified delegate and dispatch queue.
delegate: The delegate to receive the peripheral role events.
queue: 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.
Return Value ¶
Returns a newly initialized peripheral manager.
Discussion ¶
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/init(delegate:queue:)
func (CBPeripheralManager) InitWithDelegateQueueOptions ¶
func (c CBPeripheralManager) InitWithDelegateQueueOptions(delegate CBPeripheralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBPeripheralManager
Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.
delegate: The delegate to receive the peripheral role events.
queue: 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: An optional dictionary containing initialization options for a peripheral manager. For available options, see Peripheral Manager Initialization Options.
Return Value ¶
Returns a newly initialized peripheral manager.
Discussion ¶
This method is the designated initializer for the CBPeripheralManager class.
func (CBPeripheralManager) IsAdvertising ¶
func (c CBPeripheralManager) IsAdvertising() bool
A Boolean value that indicates whether the peripheral is advertising data.
Discussion ¶
This value is true if the peripheral is advertising data as a result of successfully calling the CBPeripheralManager.StartAdvertising method. The value is false if the peripheral is no longer advertising its data.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/isAdvertising
func (CBPeripheralManager) PublishL2CAPChannelWithEncryption ¶
func (c CBPeripheralManager) PublishL2CAPChannelWithEncryption(encryptionRequired bool)
Creates a listener for incoming L2CAP channel connections.
encryptionRequired: true if the service requires link encryption before a stream can be established. false if the service supports use over an unsecured link.
Discussion ¶
The system determines an unused Protocol and Service Multiplexer (PSM) at the time of publishing, and provides it to your app with [PeripheralManagerDidPublishL2CAPChannelError]. L2CAP channels aren’t discoverable by themselves, so it’s the app’s responsibility to handle PSM discovery on the client.
func (CBPeripheralManager) RemoveAllServices ¶
func (c CBPeripheralManager) RemoveAllServices()
Removes all published services from the local GATT database.
Discussion ¶
Use this when you want to remove all services you’ve previously published, for example, if your app has a toggle button to expose GATT services.
Because apps on the local peripheral device share the GATT database, this method removes only the services that you added using the CBPeripheralManager.AddService method. This call doesn’t remove any services published by other apps on the local peripheral device.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/removeAllServices()
func (CBPeripheralManager) RemoveService ¶
func (c CBPeripheralManager) RemoveService(service ICBMutableService)
Removes a specified published service from the local GATT database.
service: The service you want to remove.
Discussion ¶
Because apps on the local peripheral device share the GATT database, more than one instance of a service may exist in the database. As a result, this method removes only the instance of the service that your app added to the database (using the CBPeripheralManager.AddService method). If any other services contains this service, you must first remove them.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/remove(_:)
func (CBPeripheralManager) RespondToRequestWithResult ¶
func (c CBPeripheralManager) RespondToRequestWithResult(request ICBATTRequest, result CBATTError)
Responds to a read or write request from a connected central.
request: The read or write request received from the connected central. For more information about read and write requests, see CBATTRequest.
result: The result of attempting to fulfill the request. For a list of possible results, see Deprecated Constants.
Discussion ¶
When the peripheral manager receives a request from a connected central to read or write a characteristic’s value, it calls the [PeripheralManagerDidReceiveReadRequest] or [PeripheralManagerDidReceiveWriteRequests] method of its delegate object. To respond to the corresponding read or write request, you call this method whenever you recevie one of these delegate method callbacks.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/respond(to:withResult:)
func (CBPeripheralManager) SetDelegate ¶
func (c CBPeripheralManager) SetDelegate(value CBPeripheralManagerDelegate)
func (CBPeripheralManager) SetDesiredConnectionLatencyForCentral ¶
func (c CBPeripheralManager) SetDesiredConnectionLatencyForCentral(latency CBPeripheralManagerConnectionLatency, central ICBCentral)
Sets the desired connection latency for an existing connection to a central device.
latency: The desired connection latency. For a list of the possible connection latency values that you may set for the peripheral manager, see CBPeripheralManagerConnectionLatency.
central: The central to which the peripheral manager is currently connected.
Discussion ¶
The latency of a peripheral-central connection controls how frequently the peripheral and the peripheral’s connected central can exchange messages. By setting a desired connection latency, you manage the relationship between the frequency of the data exchange and the resulting battery performance of the peripheral device. When you call this method to set the connection latency, note that connection latency changes aren’t guaranteed. As a result, the latency may vary. If you don’t explicitly set a latency, the central device uses the connection latency it chose when establishing the connection. Typically, you don’t need to change the connection latency.
func (CBPeripheralManager) StartAdvertising ¶
func (c CBPeripheralManager) StartAdvertising(advertisementData foundation.INSDictionary)
Advertises peripheral manager data.
advertisementData: An optional dictionary containing the data you want to advertise. The peripheral manager only supports two keys: CBAdvertisementDataLocalNameKey and CBAdvertisementDataServiceUUIDsKey.
Discussion ¶
When you start advertising peripheral data, the peripheral manager calls the [PeripheralManagerDidStartAdvertisingError] method of its delegate object.
Core Bluetooth advertises data on a “best effort” basis, due to limited space and because there may be multiple apps advertising simultaneously. While in the foreground, your app can use up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data keys. If no this space remains, there’s an additional 10 bytes of space in the scan response, usable only for the local name (represented by the value of the CBAdvertisementDataLocalNameKey key). Note that these sizes don’t include the 2 bytes of header information required for each new data type.
Any service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey key that don’t fit in the allotted space go to a special “overflow” area. These services are discoverable only by an iOS device explicitly scanning for them.
While your app is in the background, the local name isn’t advertised and all service UUIDs are in the overflow area.
For details about the format of advertising and response data, see the Bluetooth 4.0 specification, Volume 3, Part C, Section 11.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/startAdvertising(_:)
func (CBPeripheralManager) StopAdvertising ¶
func (c CBPeripheralManager) StopAdvertising()
Stops advertising peripheral manager data.
Discussion ¶
Call this method when you no longer want to advertise peripheral manager data.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager/stopAdvertising()
func (CBPeripheralManager) UnpublishL2CAPChannel ¶
func (c CBPeripheralManager) UnpublishL2CAPChannel(PSM CBL2CAPPSM)
Removes a published service from the local system.
PSM: The Protocol and Service Multiplexer (PSM) to remove from the system.
Discussion ¶
After you make this call, the peripheral manager accepts no new connections for this PSM, and closes any existing L2CAP channels using this PSM.
func (CBPeripheralManager) UpdateValueForCharacteristicOnSubscribedCentrals ¶
func (c CBPeripheralManager) UpdateValueForCharacteristicOnSubscribedCentrals(value foundation.NSData, characteristic ICBMutableCharacteristic, centrals []CBCentral) bool
Send an updated characteristic value to one or more subscribed centrals, using a notification or indication.
value: The characteristic value you want to send via a notification or indication.
characteristic: The characteristic whose value has changed.
centrals: A list of centrals (represented by CBCentral objects) that have subscribed to receive updates of the characteristic’s value. If `nil`, the manager updates all subscribed centrals. The manager ignores any centrals that haven’t subscribed to the characteristic’s value.
Return Value ¶
This value is true if the update is successfully sent to the subscribed central or centrals. false if the update isn’t successfully sent because the underlying transmit queue is full.
Discussion ¶
You use this method to send updates of a characteristic’s value—through a notification or indication—to selected centrals that have subscribed to that characteristic’s value. If the method returns false because the underlying transmit queue is full, the peripheral manager calls the [PeripheralManagerIsReadyToUpdateSubscribers] method of its delegate object when more space in the transmit queue becomes available. After you receive this delegate method callback, you may resend the update.
If the length of the `value` parameter exceeds the length of the CBCentral.MaximumUpdateValueLength property of a subscribed CBCentral, the `value` parameter truncates accordingly.
type CBPeripheralManagerAuthorizationStatus ¶
type CBPeripheralManagerAuthorizationStatus int
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerAuthorizationStatus
const ( // CBPeripheralManagerAuthorizationStatusAuthorized: An authorization status that indicates the user authorized this app to share data using Bluetooth while in the background. CBPeripheralManagerAuthorizationStatusAuthorized CBPeripheralManagerAuthorizationStatus = 3 // CBPeripheralManagerAuthorizationStatusDenied: An authorization status that indicates the user explicitly denied this app from sharing data using Bluetooth while in the background. CBPeripheralManagerAuthorizationStatusDenied CBPeripheralManagerAuthorizationStatus = 2 // CBPeripheralManagerAuthorizationStatusNotDetermined: An authorization status that indicates the user hasn’t indicated whether this app can share data using Bluetooth while in the background. CBPeripheralManagerAuthorizationStatusNotDetermined CBPeripheralManagerAuthorizationStatus = 0 // CBPeripheralManagerAuthorizationStatusRestricted: An authorization status that indicates this app isn’t authorized to share data using Bluetooth while in the background. CBPeripheralManagerAuthorizationStatusRestricted CBPeripheralManagerAuthorizationStatus = 1 )
func (CBPeripheralManagerAuthorizationStatus) String ¶
func (e CBPeripheralManagerAuthorizationStatus) String() string
type CBPeripheralManagerClass ¶
type CBPeripheralManagerClass struct {
// contains filtered or unexported fields
}
func GetCBPeripheralManagerClass ¶
func GetCBPeripheralManagerClass() CBPeripheralManagerClass
GetCBPeripheralManagerClass returns the class object for CBPeripheralManager.
func (CBPeripheralManagerClass) Alloc ¶
func (cc CBPeripheralManagerClass) Alloc() CBPeripheralManager
Alloc allocates memory for a new instance of the class.
func (CBPeripheralManagerClass) Class ¶
func (cc CBPeripheralManagerClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBPeripheralManagerConnectionLatency ¶
type CBPeripheralManagerConnectionLatency int
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerConnectionLatency
const ( // CBPeripheralManagerConnectionLatencyHigh: A latency setting that prioritizes extending battery life over rapid communication. CBPeripheralManagerConnectionLatencyHigh CBPeripheralManagerConnectionLatency = 2 // CBPeripheralManagerConnectionLatencyLow: A latency setting indicating that prioritizes rapid communication over battery life. CBPeripheralManagerConnectionLatencyLow CBPeripheralManagerConnectionLatency = 0 // CBPeripheralManagerConnectionLatencyMedium: A latency setting that balances communication frequency and battery life. CBPeripheralManagerConnectionLatencyMedium CBPeripheralManagerConnectionLatency = 1 )
func (CBPeripheralManagerConnectionLatency) String ¶
func (e CBPeripheralManagerConnectionLatency) String() string
type CBPeripheralManagerDelegate ¶
type CBPeripheralManagerDelegate interface {
objectivec.IObject
// Tells the delegate the peripheral manager’s state updated.
//
// See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerDelegate/peripheralManagerDidUpdateState(_:)
PeripheralManagerDidUpdateState(peripheral ICBPeripheralManager)
}
A protocol that provides updates for local peripheral state and interactions with remote central devices.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerDelegate
type CBPeripheralManagerDelegateConfig ¶
type CBPeripheralManagerDelegateConfig struct {
// Monitoring Changes to the Peripheral Manager’s State
// PeripheralManagerDidUpdateState — Tells the delegate the peripheral manager’s state updated.
PeripheralManagerDidUpdateState func(peripheral CBPeripheralManager)
// PeripheralManagerWillRestoreState — Tells the delegate the system is about to restore the peripheral manager.
PeripheralManagerWillRestoreState func(peripheral CBPeripheralManager, dict foundation.INSDictionary)
// Advertising Peripheral Data
// PeripheralManagerDidStartAdvertisingError — Tells the delegate the peripheral manager started advertising the local peripheral device’s data.
PeripheralManagerDidStartAdvertisingError func(peripheral CBPeripheralManager, error_ foundation.NSError)
// Using L2CAP Channels
// PeripheralManagerDidPublishL2CAPChannelError — Tells the delegate that the peripheral manager created a listener for incoming L2CAP channel connections.
PeripheralManagerDidPublishL2CAPChannelError func(peripheral CBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
// PeripheralManagerDidUnpublishL2CAPChannelError — Tells the delegate that the peripheral manager removed a published service from the local system.
PeripheralManagerDidUnpublishL2CAPChannelError func(peripheral CBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
// Other Methods
// PeripheralManagerDidAddServiceError — Tells the delegate the peripheral manager published a service to the local GATT database.
PeripheralManagerDidAddServiceError func(peripheral CBPeripheralManager, service CBService, error_ foundation.NSError)
// PeripheralManagerCentralDidSubscribeToCharacteristic — Tells the delegate that a remote central device subscribed to a characteristic’s value.
PeripheralManagerCentralDidSubscribeToCharacteristic func(peripheral CBPeripheralManager, central CBCentral, characteristic CBCharacteristic)
// PeripheralManagerCentralDidUnsubscribeFromCharacteristic — Tells the delegate that a remote central device unsubscribed from a characteristic’s value.
PeripheralManagerCentralDidUnsubscribeFromCharacteristic func(peripheral CBPeripheralManager, central CBCentral, characteristic CBCharacteristic)
// PeripheralManagerIsReadyToUpdateSubscribers — Tells the delegate that a local peripheral device is ready to send characteristic value updates.
PeripheralManagerIsReadyToUpdateSubscribers func(peripheral CBPeripheralManager)
// PeripheralManagerDidReceiveReadRequest — Tells the delegate that a local peripheral received an Attribute Protocol (ATT) read request for a characteristic with a dynamic value.
PeripheralManagerDidReceiveReadRequest func(peripheral CBPeripheralManager, request CBATTRequest)
// PeripheralManagerDidOpenL2CAPChannelError — Tells the delegate that the peripheral manager opened an L2CAP channel.
PeripheralManagerDidOpenL2CAPChannelError func(peripheral CBPeripheralManager, channel CBL2CAPChannel, error_ foundation.NSError)
}
CBPeripheralManagerDelegateConfig holds optional typed callbacks for CBPeripheralManagerDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.
See Apple Documentation for protocol details.
type CBPeripheralManagerDelegateObject ¶
type CBPeripheralManagerDelegateObject struct {
objectivec.Object
}
CBPeripheralManagerDelegateObject wraps an existing Objective-C object that conforms to the CBPeripheralManagerDelegate protocol.
func CBPeripheralManagerDelegateObjectFromID ¶
func CBPeripheralManagerDelegateObjectFromID(id objc.ID) CBPeripheralManagerDelegateObject
CBPeripheralManagerDelegateObjectFromID constructs a CBPeripheralManagerDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.
func NewCBPeripheralManagerDelegate ¶
func NewCBPeripheralManagerDelegate(config CBPeripheralManagerDelegateConfig) CBPeripheralManagerDelegateObject
NewCBPeripheralManagerDelegate creates an Objective-C object implementing the CBPeripheralManagerDelegate protocol.
Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.
The returned CBPeripheralManagerDelegateObject satisfies the CBPeripheralManagerDelegate interface and can be passed directly to SetDelegate and similar methods.
See Apple Documentation for protocol details.
func (CBPeripheralManagerDelegateObject) BaseObject ¶
func (o CBPeripheralManagerDelegateObject) BaseObject() objectivec.Object
func (CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidSubscribeToCharacteristic ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidSubscribeToCharacteristic(peripheral ICBPeripheralManager, central ICBCentral, characteristic ICBCharacteristic)
Tells the delegate that a remote central device subscribed to a characteristic’s value.
peripheral: The peripheral manager connected to the remote central.
central: The remote central device that subscribed to the characteristic’s value.
characteristic: The characteristic subscribed to.
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 CBPeripheralManager.UpdateValueForCharacteristicOnSubscribedCentrals method of the CBPeripheralManager class.
func (CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidUnsubscribeFromCharacteristic ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerCentralDidUnsubscribeFromCharacteristic(peripheral ICBPeripheralManager, central ICBCentral, characteristic ICBCharacteristic)
Tells the delegate that a remote central device unsubscribed from a characteristic’s value.
peripheral: The peripheral manager connected to the remote central.
central: The remote central device that subscribed to the characteristic’s value.
characteristic: The characteristic unsubscribed from.
Discussion ¶
Core Bluetooth calls this method when a remote central device unsubscribes from the value of one of the local peripheral’s characteristics, by disabling notifications or indications on the characteristic’s value. When called, stop sending the subscribed central updates of updates to the characteristic’s value.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidAddServiceError ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidAddServiceError(peripheral ICBPeripheralManager, service ICBService, error_ foundation.NSError)
Tells the delegate the peripheral manager published a service to the local GATT database.
peripheral: The peripheral manager adding the service.
service: The service added to the local GATT database.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth invokes this method when your app calls the CBPeripheralManager.AddService method to publish a service to the local peripheral’s GATT database. If the service published successfully to the local database, the `error` parameter is `nil`. If unsuccessful, the `error` parameter provides the cause of the failure.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidOpenL2CAPChannelError ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidOpenL2CAPChannelError(peripheral ICBPeripheralManager, channel ICBL2CAPChannel, error_ foundation.NSError)
Tells the delegate that the peripheral manager opened an L2CAP channel.
peripheral: The peripheral manager that opened the channel.
channel: The channel opened by the manager.
error: The error that occurred, or `nil` if no error occurred.
Discussion ¶
The peripheral manager calls this method after you call CBPeripheralManager.PublishL2CAPChannelWithEncryption.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidPublishL2CAPChannelError ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidPublishL2CAPChannelError(peripheral ICBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
Tells the delegate that the peripheral manager created a listener for incoming L2CAP channel connections.
peripheral: The peripheral manager that published the channel.
PSM: The Protocol/Service Multiplexer (PSM) of the published channel.
error: The error that prevented publishing, or `nil` if no error occurred.
Discussion ¶
The peripheral manager calls this method after you call CBPeripheralManager.PublishL2CAPChannelWithEncryption. The [PSM] parameter contains the PSM assigned for the published channel.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveReadRequest ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveReadRequest(peripheral ICBPeripheralManager, request ICBATTRequest)
Tells the delegate that a local peripheral received an Attribute Protocol (ATT) read request for a characteristic with a dynamic value.
peripheral: The peripheral manager that received the request.
request: A CBATTRequest object that represents a request to read a characteristic’s value.
Discussion ¶
When you receive this callback, call the CBPeripheralManager.RespondToRequestWithResult method of the CBPeripheralManager class exactly once to respond to the read request.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveWriteRequests ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidReceiveWriteRequests(peripheral ICBPeripheralManager, requests []CBATTRequest)
Tells the delegate that a local peripheral device received an Attribute Protocol (ATT) write request for a characteristic with a dynamic value.
peripheral: The peripheral manager that received the request.
requests: A list of one or more CBATTRequest objects, each representing a request to write the value of a characteristic.
Discussion ¶
In the same way that you respond to a read request, each time you receive this callback, call the CBPeripheralManager.RespondToRequestWithResult method of the CBPeripheralManager class exactly once. If the `requests` parameter contains multiple requests, treat them as you would a single request—if you can’t fulfill an individual request, you shouldn’t fulfill any of them. Instead, call the CBPeripheralManager.RespondToRequestWithResult method immediately, and provide a result that indicates the cause of the failure.
When you respond to a write request, note that the first parameter of the CBPeripheralManager.RespondToRequestWithResult method expects a single CBATTRequest object, even though you received an array of them from the [PeripheralManagerDidReceiveWriteRequests] method. To respond properly, pass in the first request of the `requests` array.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidStartAdvertisingError ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidStartAdvertisingError(peripheral ICBPeripheralManager, error_ foundation.NSError)
Tells the delegate the peripheral manager started advertising the local peripheral device’s data.
peripheral: The peripheral manager that is starting advertising.
error: The reason the call failed, or `nil` if no error occurred.
Discussion ¶
Core Bluetooth calls this method when your app calls the CBPeripheralManager.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.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidUnpublishL2CAPChannelError ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidUnpublishL2CAPChannelError(peripheral ICBPeripheralManager, PSM CBL2CAPPSM, error_ foundation.NSError)
Tells the delegate that the peripheral manager removed a published service from the local system.
peripheral: The peripheral manager that stopped publishing.
PSM: The Protocol/Service Multiplexer (PSM) of the channel that was unpublished.
error: The error that occurred, or `nil` if no error occurred.
Discussion ¶
The peripheral manager calls this method after you call CBPeripheralManager.UnpublishL2CAPChannel.
func (CBPeripheralManagerDelegateObject) PeripheralManagerDidUpdateState ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerDidUpdateState(peripheral ICBPeripheralManager)
Tells the delegate the peripheral manager’s state updated.
peripheral: The peripheral manager whose state has changed.
Discussion ¶
You implement this required method to ensure that Bluetooth low energy is available to use on the local peripheral device.
Issue commands to the peripheral manager only when the peripheral manager is in the powered-on state, as indicated by the CBPeripheralManagerState.poweredOn constant. A state with a value lower than CBPeripheralManagerState.poweredOn implies that advertising has stopped and that any connected centrals have been disconnected. If the state moves below CBPeripheralManagerState.poweredOff, advertising has stopped you must explicitly restart it. In addition, the powered off state clears the local database; in this case you must explicitly re-add all services. For a complete list and discussion of the possible values representing the state of the peripheral manager, see the CBPeripheralManagerState enumeration in CBPeripheralManager.
For more information, see Core Bluetooth Programming Guide.
func (CBPeripheralManagerDelegateObject) PeripheralManagerIsReadyToUpdateSubscribers ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerIsReadyToUpdateSubscribers(peripheral ICBPeripheralManager)
Tells the delegate that a local peripheral device is ready to send characteristic value updates.
peripheral: The peripheral manager that sends characteristic value updates.
Discussion ¶
When a call to the CBPeripheralManager.UpdateValueForCharacteristicOnSubscribedCentrals method fails because the underlying queue used to transmit the updated characteristic value is full, Core Bluetooth calls the [PeripheralManagerIsReadyToUpdateSubscribers] method when more space in the transmit queue becomes available. You can then implement this delegate method to resend the value.
func (CBPeripheralManagerDelegateObject) PeripheralManagerWillRestoreState ¶
func (o CBPeripheralManagerDelegateObject) PeripheralManagerWillRestoreState(peripheral ICBPeripheralManager, dict foundation.INSDictionary)
Tells the delegate the system is about to restore the peripheral manager.
peripheral: The peripheral manager undergoing state restoration.
dict: A dictionary that contains information about the peripheral manager, which the system preserved when the app terminated. For the available keys to this dictionary, see Peripheral Manager State Restoration Options.
Discussion ¶
For apps that opt in to the state preservation and restoration feature, Core Bluetooth invokes this method when relaunching your app into the background to complete some Bluetooth-related task. Use this method to synchronize the state of your app with the state of the Bluetooth system.
type CBPeripheralManagerState ¶
type CBPeripheralManagerState int
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManagerState
const ( // CBPeripheralManagerStatePoweredOff: A manager state that indicates Bluetooth is currently powered off. CBPeripheralManagerStatePoweredOff CBPeripheralManagerState = 4 // CBPeripheralManagerStatePoweredOn: A manager state that indicates Bluetooth is currently powered on and is available to use. CBPeripheralManagerStatePoweredOn CBPeripheralManagerState = 5 // CBPeripheralManagerStateResetting: A manager state that indicates the connection with the system service was momentarily lost. CBPeripheralManagerStateResetting CBPeripheralManagerState = 1 CBPeripheralManagerStateUnauthorized CBPeripheralManagerState = 3 // CBPeripheralManagerStateUnknown: A manager state that indicates the current state of the peripheral manager is unknown. CBPeripheralManagerStateUnknown CBPeripheralManagerState = 0 // CBPeripheralManagerStateUnsupported: A manager state that indicates the platform doesn’t support the Bluetooth low energy peripheral/server role. CBPeripheralManagerStateUnsupported CBPeripheralManagerState = 2 )
func (CBPeripheralManagerState) String ¶
func (e CBPeripheralManagerState) String() string
type CBPeripheralState ¶
type CBPeripheralState int
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralState
const ( // CBPeripheralStateConnected: The peripheral is connected to the central manager. CBPeripheralStateConnected CBPeripheralState = 2 // CBPeripheralStateConnecting: The peripheral is in the process of connecting to the central manager. CBPeripheralStateConnecting CBPeripheralState = 1 // CBPeripheralStateDisconnected: The peripheral isn’t connected to the central manager. CBPeripheralStateDisconnected CBPeripheralState = 0 // CBPeripheralStateDisconnecting: The peripheral is disconnecting from the central manager. CBPeripheralStateDisconnecting CBPeripheralState = 3 )
func (CBPeripheralState) String ¶
func (e CBPeripheralState) String() string
type CBService ¶
type CBService struct {
CBAttribute
}
A collection of data and associated behaviors that accomplish a function or feature of a device.
Overview ¶
CBService objects represent services of a remote peripheral. Services are either primary or secondary and may contain multiple characteristics or included services (references to other services).
Identifying a Service ¶
- CBService.Peripheral: The peripheral to which this service belongs.
- CBService.IsPrimary: A Boolean value that indicates whether the type of service is primary or secondary.
Accessing Service Data ¶
- CBService.Characteristics: A list of characteristics discovered in this service.
- CBService.IncludedServices: A list of included services discovered in this service.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService
func CBServiceFromID ¶
CBServiceFromID constructs a CBService from an objc.ID.
A collection of data and associated behaviors that accomplish a function or feature of a device.
func (CBService) Autorelease ¶
Autorelease adds the receiver to the current autorelease pool.
func (CBService) Characteristics ¶
func (c CBService) Characteristics() []CBCharacteristic
A list of characteristics discovered in this service.
Discussion ¶
This array contains CBCharacteristic objects that represent a service’s characteristics. Characteristics provide further details about a peripheral’s service. For example, a heart rate service may contain one characteristic that describes the intended body location of the device’s heart rate sensor, while another characteristic transmits heart rate measurement data.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService/characteristics
func (CBService) IncludedServices ¶
A list of included services discovered in this service.
Discussion ¶
This array contains CBService objects that represent the included services of a service. A service of a peripheral may contain a reference to other services that are available on the peripheral. These other services are the included services of the service. You discover included services using the CBPeripheral.DiscoverIncludedServicesForService method of the CBPeripheral class.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService/includedServices
func (CBService) IsPrimary ¶
A Boolean value that indicates whether the type of service is primary or secondary.
Discussion ¶
A peripheral’s service is either primary or secondary. A primary service describes the primary function of a device. A secondary service describes a service that’s relevant only in the context of another service that references it. For example, the primary service of a heart rate monitor may be to expose heart rate data from the monitor’s heart rate sensor. In this example, a secondary service may be to expose the sensor’s battery data.
If the value of this property is true, the type of service is primary. If the value of this property is false, the type of service is secondary.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService/isPrimary
func (CBService) Peripheral ¶
func (c CBService) Peripheral() ICBPeripheral
The peripheral to which this service belongs.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService/peripheral
type CBServiceClass ¶
type CBServiceClass struct {
// contains filtered or unexported fields
}
func GetCBServiceClass ¶
func GetCBServiceClass() CBServiceClass
GetCBServiceClass returns the class object for CBService.
func (CBServiceClass) Alloc ¶
func (cc CBServiceClass) Alloc() CBService
Alloc allocates memory for a new instance of the class.
func (CBServiceClass) Class ¶
func (cc CBServiceClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type CBUUID ¶
type CBUUID struct {
objectivec.Object
}
A universally unique identifier, as defined by Bluetooth standards.
Overview ¶
Instances of the CBUUID class represent the 128-bit universally unique identifiers (UUIDs) of attributes used in Bluetooth low energy communication, such as a peripheral’s services, characteristics, and descriptors. This class provides a number of factory methods for dealing with long UUIDs when developing your app. For example, instead of passing around the string representation of a 128-bit Bluetooth low energy attribute in your code, you can create a CBUUID object that represents it, and pass that around instead.
The Bluetooth Special Interest Group (SIG) publishes a list of commonly-used UUIDs, many of which are 16- or 32-bits for convenience. The CBUUID class provides methods that automatically transform these predefined shorter UUIDs into their 128-bit equivalent UUIDs. When you create a CBUUID object from a predefined 16- or 32-bit UUID, Core Bluetooth pre-fills the rest of the 128-bit UUID with the Bluetooth base UUID, as defined in the Bluetooth 4.0 specification, Volume 3, Part F, Section 3.2.1.
In addition to providing methods for creating CBUUID objects, this class defines constants that represent the UUIDs of the Bluetooth-defined characteristic descriptors, as defined in the Bluetooth 4.0 specification, Volume 3, Part G, Section 3.3.3.
Inspecting CBUUID Properties ¶
- CBUUID.Data: The data of the UUID.
- CBUUID.UUIDString: The UUID represented as a string.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID
func CBUUIDFromID ¶
CBUUIDFromID constructs a CBUUID from an objc.ID.
A universally unique identifier, as defined by Bluetooth standards.
func NewCBUUIDWithData ¶
func NewCBUUIDWithData(theData foundation.NSData) CBUUID
Creates a Core Bluetooth UUID object from a 16-, 32-, or 128-bit UUID data container.
theData: Data containing a 16-, 32-, or 128-bit UUID.
Return Value ¶
A new CBUUID object for the specified UUID data.
Discussion ¶
This method is useful when handling the UUID of a Bluetooth attribute in raw bytes.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID/init(data:)
func NewCBUUIDWithNSUUID ¶
func NewCBUUIDWithNSUUID(theUUID foundation.NSUUID) CBUUID
Creates a Core Bluetooth UUID object from a Foundation UUID object.
theUUID: A UUID represented by an NSUUID object.
Return Value ¶
A new CBUUID object for the specified UUID.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID/init(nsuuid:)
func NewCBUUIDWithString ¶
Creates a Core Bluetooth UUID object from a 16-, 32-, or 128-bit UUID string.
theString: 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, for example, 68753A44-4D6F-1226-9C60-0050E4C00067. Specify 16- or 32-bit UUIDs as a string of 4 or 8 hexadecimal digits, respectively. For an example of how to use this method, see Services and Characteristics Are Identified by UUIDs and Create Your Own UUIDs for Custom Services and Characteristics.
For more information, see Core Bluetooth Programming Guide.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID/init(string:)
func (CBUUID) Autorelease ¶
Autorelease adds the receiver to the current autorelease pool.
func (CBUUID) Data ¶
func (c CBUUID) Data() foundation.NSData
The data of the UUID.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID/data
func (CBUUID) UUIDString ¶
The UUID represented as a string.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID/uuidString
type CBUUIDClass ¶
type CBUUIDClass struct {
// contains filtered or unexported fields
}
func GetCBUUIDClass ¶
func GetCBUUIDClass() CBUUIDClass
GetCBUUIDClass returns the class object for CBUUID.
func (CBUUIDClass) Alloc ¶
func (cc CBUUIDClass) Alloc() CBUUID
Alloc allocates memory for a new instance of the class.
func (CBUUIDClass) Class ¶
func (cc CBUUIDClass) Class() objc.Class
Class returns the underlying Objective-C class pointer.
type ICBATTRequest ¶
type ICBATTRequest interface {
objectivec.IObject
// The remote central device that originated the request.
Central() ICBCentral
// The characteristic to read or write the value of.
Characteristic() ICBCharacteristic
// The data that the central reads from or writes to the peripheral.
Value() foundation.NSData
SetValue(value foundation.NSData)
// The zero-based index of the first byte for the read or write request.
Offset() uint
}
An interface definition for the CBATTRequest class.
Requesting to Read and Write Characteristic Values ¶
- ICBATTRequest.Central: The remote central device that originated the request.
- ICBATTRequest.Characteristic: The characteristic to read or write the value of.
- ICBATTRequest.Value: The data that the central reads from or writes to the peripheral.
- ICBATTRequest.SetValue
- ICBATTRequest.Offset: The zero-based index of the first byte for the read or write request.
See: https://developer.apple.com/documentation/CoreBluetooth/CBATTRequest
type ICBAttribute ¶
type ICBAttribute interface {
objectivec.IObject
// The Bluetooth-specific UUID of the attribute.
UUID() ICBUUID
}
An interface definition for the CBAttribute class.
Identifying an Attribute ¶
- ICBAttribute.UUID: The Bluetooth-specific UUID of the attribute.
See: https://developer.apple.com/documentation/CoreBluetooth/CBAttribute
type ICBCentral ¶
type ICBCentral interface {
ICBPeer
// The maximum amount of data, in bytes, that the central can receive in a single notification or indication.
MaximumUpdateValueLength() uint
}
An interface definition for the CBCentral class.
Identifying a Remote Central ¶
- ICBCentral.MaximumUpdateValueLength: The maximum amount of data, in bytes, that the central can receive in a single notification or indication.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentral
type ICBCentralManager ¶
type ICBCentralManager interface {
ICBManager
// Initializes the central manager with a specified delegate and dispatch queue.
InitWithDelegateQueue(delegate CBCentralManagerDelegate, queue dispatch.Queue) CBCentralManager
// Initializes the central manager with specified delegate, dispatch queue, and initialization options.
InitWithDelegateQueueOptions(delegate CBCentralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBCentralManager
// Establishes a local connection to a peripheral.
ConnectPeripheralOptions(peripheral ICBPeripheral, options foundation.INSDictionary)
// Cancels an active or pending local connection to a peripheral.
CancelPeripheralConnection(peripheral ICBPeripheral)
// Returns a list of the peripherals connected to the system whose services match a given set of criteria.
RetrieveConnectedPeripheralsWithServices(serviceUUIDs []CBUUID) []CBPeripheral
// Returns a list of known peripherals by their identifiers.
RetrievePeripheralsWithIdentifiers(identifiers []foundation.NSUUID) []CBPeripheral
// Scans for peripherals that are advertising services.
ScanForPeripheralsWithServicesOptions(serviceUUIDs []CBUUID, options foundation.INSDictionary)
// Asks the central manager to stop scanning for peripherals.
StopScan()
// A Boolean value that indicates whether the central is currently scanning.
IsScanning() bool
// The delegate object that you want to receive central manager events.
Delegate() CBCentralManagerDelegate
SetDelegate(value CBCentralManagerDelegate)
}
An interface definition for the CBCentralManager class.
Initializing a Central Manager ¶
- ICBCentralManager.InitWithDelegateQueue: Initializes the central manager with a specified delegate and dispatch queue.
- ICBCentralManager.InitWithDelegateQueueOptions: Initializes the central manager with specified delegate, dispatch queue, and initialization options.
Establishing or Canceling Connections with Peripherals ¶
- ICBCentralManager.ConnectPeripheralOptions: Establishes a local connection to a peripheral.
- ICBCentralManager.CancelPeripheralConnection: Cancels an active or pending local connection to a peripheral.
Retrieving Lists of Peripherals ¶
- ICBCentralManager.RetrieveConnectedPeripheralsWithServices: Returns a list of the peripherals connected to the system whose services match a given set of criteria.
- ICBCentralManager.RetrievePeripheralsWithIdentifiers: Returns a list of known peripherals by their identifiers.
Scanning or Stopping Scans of Peripherals ¶
- ICBCentralManager.ScanForPeripheralsWithServicesOptions: Scans for peripherals that are advertising services.
- ICBCentralManager.StopScan: Asks the central manager to stop scanning for peripherals.
- ICBCentralManager.IsScanning: A Boolean value that indicates whether the central is currently scanning.
Monitoring Properties ¶
- ICBCentralManager.Delegate: The delegate object that you want to receive central manager events.
- ICBCentralManager.SetDelegate
See: https://developer.apple.com/documentation/CoreBluetooth/CBCentralManager
type ICBCharacteristic ¶
type ICBCharacteristic interface {
ICBAttribute
// The service to which this characteristic belongs.
Service() ICBService
// The value of the characteristic.
Value() foundation.NSData
// A list of the descriptors discovered in this characteristic.
Descriptors() []CBDescriptor
// The properties of the characteristic.
Properties() CBCharacteristicProperties
// A Boolean value that indicates whether the characteristic is currently notifying a subscribed central of its value.
IsNotifying() bool
}
An interface definition for the CBCharacteristic class.
Identifying a Characteristic ¶
- ICBCharacteristic.Service: The service to which this characteristic belongs.
Accessing Characteristic Data ¶
- ICBCharacteristic.Value: The value of the characteristic.
- ICBCharacteristic.Descriptors: A list of the descriptors discovered in this characteristic.
- ICBCharacteristic.Properties: The properties of the characteristic.
- ICBCharacteristic.IsNotifying: A Boolean value that indicates whether the characteristic is currently notifying a subscribed central of its value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBCharacteristic
type ICBDescriptor ¶
type ICBDescriptor interface {
ICBAttribute
// The characteristic to which this descriptor belongs.
Characteristic() ICBCharacteristic
// The value of the descriptor.
Value() objectivec.IObject
}
An interface definition for the CBDescriptor class.
Identifying a Descriptor ¶
- ICBDescriptor.Characteristic: The characteristic to which this descriptor belongs.
Accessing Descriptor Data ¶
- ICBDescriptor.Value: The value of the descriptor.
See: https://developer.apple.com/documentation/CoreBluetooth/CBDescriptor
type ICBL2CAPChannel ¶
type ICBL2CAPChannel interface {
objectivec.IObject
// The stream used for reading data from the remote peer.
InputStream() foundation.InputStream
// The stream used for writing data to the peer.
OutputStream() foundation.OutputStream
// The peer connected to the channel.
Peer() ICBPeer
// The PSM of the channel.
PSM() CBL2CAPPSM
}
An interface definition for the CBL2CAPChannel class.
Accessing Streams ¶
- ICBL2CAPChannel.InputStream: The stream used for reading data from the remote peer.
- ICBL2CAPChannel.OutputStream: The stream used for writing data to the peer.
Accessing the Peer ¶
- ICBL2CAPChannel.Peer: The peer connected to the channel.
Accessing the Protocol/Service Multiplexer ¶
- ICBL2CAPChannel.PSM: The PSM of the channel.
See: https://developer.apple.com/documentation/CoreBluetooth/CBL2CAPChannel
type ICBManager ¶
type ICBManager interface {
objectivec.IObject
// The current state of the manager.
State() CBManagerState
// The current authorization status for using Bluetooth.
Authorization() CBManagerAuthorization
}
An interface definition for the CBManager class.
Accessing the Manager’s Properties ¶
- ICBManager.State: The current state of the manager.
Deprecated Properties ¶
- ICBManager.Authorization: The current authorization status for using Bluetooth.
See: https://developer.apple.com/documentation/CoreBluetooth/CBManager
type ICBMutableCharacteristic ¶
type ICBMutableCharacteristic interface {
ICBCharacteristic
// Creates a mutable characteristic with specified permissions, properties, and value.
InitWithTypePropertiesValuePermissions(UUID ICBUUID, properties CBCharacteristicProperties, value foundation.NSData, permissions CBAttributePermissions) CBMutableCharacteristic
// The permissions of the characteristic value.
Permissions() CBAttributePermissions
SetPermissions(value CBAttributePermissions)
// A list of centrals that are currently subscribed to the characteristic’s value.
SubscribedCentrals() []CBCentral
}
An interface definition for the CBMutableCharacteristic class.
Creating a Mutable Characteristic ¶
- ICBMutableCharacteristic.InitWithTypePropertiesValuePermissions: Creates a mutable characteristic with specified permissions, properties, and value.
Managing a Mutable Characteristic ¶
- ICBMutableCharacteristic.Permissions: The permissions of the characteristic value.
- ICBMutableCharacteristic.SetPermissions
- ICBMutableCharacteristic.SubscribedCentrals: A list of centrals that are currently subscribed to the characteristic’s value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableCharacteristic
type ICBMutableDescriptor ¶
type ICBMutableDescriptor interface {
ICBDescriptor
// Creates a mutable descriptor with a specified value.
InitWithTypeValue(UUID ICBUUID, value objectivec.IObject) CBMutableDescriptor
}
An interface definition for the CBMutableDescriptor class.
Creating a Mutable Descriptor ¶
- ICBMutableDescriptor.InitWithTypeValue: Creates a mutable descriptor with a specified value.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableDescriptor
type ICBMutableService ¶
type ICBMutableService interface {
ICBService
// Creates a newly initialized mutable service specified by UUID and service type.
InitWithTypePrimary(UUID ICBUUID, isPrimary bool) CBMutableService
}
An interface definition for the CBMutableService class.
Creating a Mutable Service ¶
- ICBMutableService.InitWithTypePrimary: Creates a newly initialized mutable service specified by UUID and service type.
See: https://developer.apple.com/documentation/CoreBluetooth/CBMutableService
type ICBPeer ¶
type ICBPeer interface {
objectivec.IObject
// The UUID associated with the peer.
Identifier() foundation.NSUUID
}
An interface definition for the CBPeer class.
Identifying a Peer ¶
- ICBPeer.Identifier: The UUID associated with the peer.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeer
type ICBPeripheral ¶
type ICBPeripheral interface {
ICBPeer
// The name of the peripheral.
Name() string
// The delegate object specified to receive peripheral events.
Delegate() CBPeripheralDelegate
SetDelegate(value CBPeripheralDelegate)
// Discovers the specified services of the peripheral.
DiscoverServices(serviceUUIDs []CBUUID)
// Discovers the specified included services of a previously-discovered service.
DiscoverIncludedServicesForService(includedServiceUUIDs []CBUUID, service ICBService)
// A list of a peripheral’s discovered services.
Services() []CBService
// Discovers the specified characteristics of a service.
DiscoverCharacteristicsForService(characteristicUUIDs []CBUUID, service ICBService)
// Discovers the descriptors of a characteristic.
DiscoverDescriptorsForCharacteristic(characteristic ICBCharacteristic)
// Retrieves the value of a specified characteristic.
ReadValueForCharacteristic(characteristic ICBCharacteristic)
// Retrieves the value of a specified characteristic descriptor.
ReadValueForDescriptor(descriptor ICBDescriptor)
// Writes the value of a characteristic.
WriteValueForCharacteristicType(data foundation.NSData, characteristic ICBCharacteristic, type_ CBCharacteristicWriteType)
// Writes the value of a characteristic descriptor.
WriteValueForDescriptor(data foundation.NSData, descriptor ICBDescriptor)
// The maximum amount of data, in bytes, you can send to a characteristic in a single write type.
MaximumWriteValueLengthForType(type_ CBCharacteristicWriteType) uint
// Sets notifications or indications for the value of a specified characteristic.
SetNotifyValueForCharacteristic(enabled bool, characteristic ICBCharacteristic)
// The connection state of the peripheral.
State() CBPeripheralState
// A Boolean value that indicates whether the remote device can send a write without a response.
CanSendWriteWithoutResponse() bool
// Retrieves the current RSSI value for the peripheral while connected to the central manager.
ReadRSSI()
// Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM).
OpenL2CAPChannel(PSM CBL2CAPPSM)
}
An interface definition for the CBPeripheral class.
Identifying a Peripheral ¶
- ICBPeripheral.Name: The name of the peripheral.
- ICBPeripheral.Delegate: The delegate object specified to receive peripheral events.
- ICBPeripheral.SetDelegate
Discovering Services ¶
- ICBPeripheral.DiscoverServices: Discovers the specified services of the peripheral.
- ICBPeripheral.DiscoverIncludedServicesForService: Discovers the specified included services of a previously-discovered service.
- ICBPeripheral.Services: A list of a peripheral’s discovered services.
Discovering Characteristics and Descriptors ¶
- ICBPeripheral.DiscoverCharacteristicsForService: Discovers the specified characteristics of a service.
- ICBPeripheral.DiscoverDescriptorsForCharacteristic: Discovers the descriptors of a characteristic.
Reading Characteristic and Descriptor Values ¶
- ICBPeripheral.ReadValueForCharacteristic: Retrieves the value of a specified characteristic.
- ICBPeripheral.ReadValueForDescriptor: Retrieves the value of a specified characteristic descriptor.
Writing Characteristic and Descriptor Values ¶
- ICBPeripheral.WriteValueForCharacteristicType: Writes the value of a characteristic.
- ICBPeripheral.WriteValueForDescriptor: Writes the value of a characteristic descriptor.
- ICBPeripheral.MaximumWriteValueLengthForType: The maximum amount of data, in bytes, you can send to a characteristic in a single write type.
Setting Notifications for a Characteristic’s Value ¶
- ICBPeripheral.SetNotifyValueForCharacteristic: Sets notifications or indications for the value of a specified characteristic.
Monitoring a Peripheral’s Connection State ¶
- ICBPeripheral.State: The connection state of the peripheral.
- ICBPeripheral.CanSendWriteWithoutResponse: A Boolean value that indicates whether the remote device can send a write without a response.
Accessing a Peripheral’s Signal Strength ¶
- ICBPeripheral.ReadRSSI: Retrieves the current RSSI value for the peripheral while connected to the central manager.
Working with L2CAP Channels ¶
- ICBPeripheral.OpenL2CAPChannel: Attempts to open an L2CAP channel to the peripheral using the supplied Protocol/Service Multiplexer (PSM).
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheral
type ICBPeripheralManager ¶
type ICBPeripheralManager interface {
ICBManager
// Initializes the peripheral manager with a specified delegate and dispatch queue.
InitWithDelegateQueue(delegate CBPeripheralManagerDelegate, queue dispatch.Queue) CBPeripheralManager
// Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.
InitWithDelegateQueueOptions(delegate CBPeripheralManagerDelegate, queue dispatch.Queue, options foundation.INSDictionary) CBPeripheralManager
// The delegate object specified to receive peripheral events.
Delegate() CBPeripheralManagerDelegate
SetDelegate(value CBPeripheralManagerDelegate)
// Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.
AddService(service ICBMutableService)
// Removes a specified published service from the local GATT database.
RemoveService(service ICBMutableService)
// Removes all published services from the local GATT database.
RemoveAllServices()
// Advertises peripheral manager data.
StartAdvertising(advertisementData foundation.INSDictionary)
// Stops advertising peripheral manager data.
StopAdvertising()
// A Boolean value that indicates whether the peripheral is advertising data.
IsAdvertising() bool
// Send an updated characteristic value to one or more subscribed centrals, using a notification or indication.
UpdateValueForCharacteristicOnSubscribedCentrals(value foundation.NSData, characteristic ICBMutableCharacteristic, centrals []CBCentral) bool
// Responds to a read or write request from a connected central.
RespondToRequestWithResult(request ICBATTRequest, result CBATTError)
// Sets the desired connection latency for an existing connection to a central device.
SetDesiredConnectionLatencyForCentral(latency CBPeripheralManagerConnectionLatency, central ICBCentral)
// Creates a listener for incoming L2CAP channel connections.
PublishL2CAPChannelWithEncryption(encryptionRequired bool)
// Removes a published service from the local system.
UnpublishL2CAPChannel(PSM CBL2CAPPSM)
}
An interface definition for the CBPeripheralManager class.
Initializing a Peripheral Manager ¶
- ICBPeripheralManager.InitWithDelegateQueue: Initializes the peripheral manager with a specified delegate and dispatch queue.
- ICBPeripheralManager.InitWithDelegateQueueOptions: Initializes the peripheral manager with a specified delegate, dispatch queue, and initialization options.
- ICBPeripheralManager.Delegate: The delegate object specified to receive peripheral events.
- ICBPeripheralManager.SetDelegate
Adding and Removing Services ¶
- ICBPeripheralManager.AddService: Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.
- ICBPeripheralManager.RemoveService: Removes a specified published service from the local GATT database.
- ICBPeripheralManager.RemoveAllServices: Removes all published services from the local GATT database.
Managing Advertising ¶
- ICBPeripheralManager.StartAdvertising: Advertises peripheral manager data.
- ICBPeripheralManager.StopAdvertising: Stops advertising peripheral manager data.
- ICBPeripheralManager.IsAdvertising: A Boolean value that indicates whether the peripheral is advertising data.
Sending Updates of a Characteristic’s Value ¶
- ICBPeripheralManager.UpdateValueForCharacteristicOnSubscribedCentrals: Send an updated characteristic value to one or more subscribed centrals, using a notification or indication.
Responding to Read and Write Requests ¶
- ICBPeripheralManager.RespondToRequestWithResult: Responds to a read or write request from a connected central.
Setting Connection Latency ¶
- ICBPeripheralManager.SetDesiredConnectionLatencyForCentral: Sets the desired connection latency for an existing connection to a central device.
Using L2CAP Channels ¶
- ICBPeripheralManager.PublishL2CAPChannelWithEncryption: Creates a listener for incoming L2CAP channel connections.
- ICBPeripheralManager.UnpublishL2CAPChannel: Removes a published service from the local system.
See: https://developer.apple.com/documentation/CoreBluetooth/CBPeripheralManager
type ICBService ¶
type ICBService interface {
ICBAttribute
// The peripheral to which this service belongs.
Peripheral() ICBPeripheral
// A Boolean value that indicates whether the type of service is primary or secondary.
IsPrimary() bool
// A list of characteristics discovered in this service.
Characteristics() []CBCharacteristic
// A list of included services discovered in this service.
IncludedServices() []CBService
}
An interface definition for the CBService class.
Identifying a Service ¶
- ICBService.Peripheral: The peripheral to which this service belongs.
- ICBService.IsPrimary: A Boolean value that indicates whether the type of service is primary or secondary.
Accessing Service Data ¶
- ICBService.Characteristics: A list of characteristics discovered in this service.
- ICBService.IncludedServices: A list of included services discovered in this service.
See: https://developer.apple.com/documentation/CoreBluetooth/CBService
type ICBUUID ¶
type ICBUUID interface {
objectivec.IObject
// The data of the UUID.
Data() foundation.NSData
// The UUID represented as a string.
UUIDString() string
}
An interface definition for the CBUUID class.
Inspecting CBUUID Properties ¶
- ICBUUID.Data: The data of the UUID.
- ICBUUID.UUIDString: The UUID represented as a string.
See: https://developer.apple.com/documentation/CoreBluetooth/CBUUID
Source Files
¶
- cb_attribute.gen.go
- cb_central.gen.go
- cb_central_manager.gen.go
- cb_central_manager_delegate_protocol.gen.go
- cb_characteristic.gen.go
- cb_descriptor.gen.go
- cb_manager.gen.go
- cb_mutable_characteristic.gen.go
- cb_mutable_descriptor.gen.go
- cb_mutable_service.gen.go
- cb_peer.gen.go
- cb_peripheral.gen.go
- cb_peripheral_delegate_protocol.gen.go
- cb_peripheral_manager.gen.go
- cb_peripheral_manager_delegate_protocol.gen.go
- cb_service.gen.go
- cbatt_request.gen.go
- cbl2_cap_channel.gen.go
- cbuuid.gen.go
- delegate_class_counter.gen.go
- doc.gen.go
- enums.gen.go
- functions.gen.go
- generate.go
- global_vars.gen.go
- typedefs.gen.go
- types.gen.go
- undefined_types.gen.go