cbgo

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 13

README

cbgo

cbgo implements Go bindings for CoreBluetooth.

Documentation

For documentation, see the CoreBluetooth docs.

Examples are in the examples directory.

Scope

cbgo aims to implement all functionality that is supported in macOS 10.13.

Naming

Function and type names in cbgo are intended to match the corresponding CoreBluetooth functionality as closely as possible. There are a few (consistent) deviations:

  • All cbgo identifiers start with a capital letter to make them public.
  • Named arguments in CoreBluetooth functions are eliminated.
  • Properties are implemented as a pair of functions (PropertyName and SetPropertyName).

Issues

There are definitely memory leaks. ARC is not compatible with cgo, so objective C memory has to be managed manually. I didn't see a set of consistent guidelines for object ownership in the CoreBluetooth documentation, so cbgo errs on the side of leaking. Hopefully this is only an issue for very long running processes! Any fixes here are much appreciated.

Documentation

Index

Constants

View Source
const (
	AttributePermissionsReadable                = AttributePermissions(C.CBAttributePermissionsReadable)
	AttributePermissionsWriteable               = AttributePermissions(C.CBAttributePermissionsWriteable)
	AttributePermissionsReadEncryptionRequired  = AttributePermissions(C.CBAttributePermissionsReadEncryptionRequired)
	AttributePermissionsWriteEncryptionRequired = AttributePermissions(C.CBAttributePermissionsWriteEncryptionRequired)
)
View Source
const (
	ATTErrorSuccess                       = ATTError(C.CBATTErrorSuccess)
	ATTErrorInvalidHandle                 = ATTError(C.CBATTErrorInvalidHandle)
	ATTErrorReadNotPermitted              = ATTError(C.CBATTErrorReadNotPermitted)
	ATTErrorWriteNotPermitted             = ATTError(C.CBATTErrorWriteNotPermitted)
	ATTErrorInvalidPdu                    = ATTError(C.CBATTErrorInvalidPdu)
	ATTErrorInsufficientAuthentication    = ATTError(C.CBATTErrorInsufficientAuthentication)
	ATTErrorRequestNotSupported           = ATTError(C.CBATTErrorRequestNotSupported)
	ATTErrorInvalidOffset                 = ATTError(C.CBATTErrorInvalidOffset)
	ATTErrorInsufficientAuthorization     = ATTError(C.CBATTErrorInsufficientAuthorization)
	ATTErrorPrepareQueueFull              = ATTError(C.CBATTErrorPrepareQueueFull)
	ATTErrorAttributeNotFound             = ATTError(C.CBATTErrorAttributeNotFound)
	ATTErrorAttributeNotLong              = ATTError(C.CBATTErrorAttributeNotLong)
	ATTErrorInsufficientEncryptionKeySize = ATTError(C.CBATTErrorInsufficientEncryptionKeySize)
	ATTErrorInvalidAttributeValueLength   = ATTError(C.CBATTErrorInvalidAttributeValueLength)
	ATTErrorUnlikelyError                 = ATTError(C.CBATTErrorUnlikelyError)
	ATTErrorInsufficientEncryption        = ATTError(C.CBATTErrorInsufficientEncryption)
	ATTErrorUnsupportedGroupType          = ATTError(C.CBATTErrorUnsupportedGroupType)
	ATTErrorInsufficientResources         = ATTError(C.CBATTErrorInsufficientResources)
)
View Source
const (
	CharacteristicPropertyBroadcast                  = CharacteristicProperties(C.CBCharacteristicPropertyBroadcast)
	CharacteristicPropertyRead                       = CharacteristicProperties(C.CBCharacteristicPropertyRead)
	CharacteristicPropertyWriteWithoutResponse       = CharacteristicProperties(C.CBCharacteristicPropertyWriteWithoutResponse)
	CharacteristicPropertyWrite                      = CharacteristicProperties(C.CBCharacteristicPropertyWrite)
	CharacteristicPropertyNotify                     = CharacteristicProperties(C.CBCharacteristicPropertyNotify)
	CharacteristicPropertyIndicate                   = CharacteristicProperties(C.CBCharacteristicPropertyIndicate)
	CharacteristicPropertyAuthenticatedSignedWrites  = CharacteristicProperties(C.CBCharacteristicPropertyAuthenticatedSignedWrites)
	CharacteristicPropertyExtendedProperties         = CharacteristicProperties(C.CBCharacteristicPropertyExtendedProperties)
	CharacteristicPropertyNotifyEncryptionRequired   = CharacteristicProperties(C.CBCharacteristicPropertyNotifyEncryptionRequired)
	CharacteristicPropertyIndicateEncryptionRequired = CharacteristicProperties(C.CBCharacteristicPropertyIndicateEncryptionRequired)
)
View Source
const (
	ManagerStatePoweredOff   = ManagerState(C.CBManagerStatePoweredOff)
	ManagerStatePoweredOn    = ManagerState(C.CBManagerStatePoweredOn)
	ManagerStateResetting    = ManagerState(C.CBManagerStateResetting)
	ManagerStateUnauthorized = ManagerState(C.CBManagerStateUnauthorized)
	ManagerStateUnknown      = ManagerState(C.CBManagerStateUnknown)
	ManagerStateUnsupported  = ManagerState(C.CBManagerStateUnsupported)
)
View Source
const (
	PeripheralStateDisconnected  = PeripheralState(C.CBPeripheralStateDisconnected)
	PeripheralStateConnecting    = PeripheralState(C.CBPeripheralStateConnecting)
	PeripheralStateConnected     = PeripheralState(C.CBPeripheralStateConnected)
	PeripheralStateDisconnecting = PeripheralState(C.CBPeripheralStateDisconnecting)
)
View Source
const UUID128StringLength = 36
View Source
const UUID16StringLength = 4

Variables

View Source
var DfltCentralManagerConnectOpts = CentralManagerConnectOpts{
	NotifyOnConnection:    true,
	NotifyOnDisconnection: true,
	NotifyOnNotification:  true,
}

DfltCentralManagerConnectOpts is the set of options that gets used when nil is passed to `Connect()`.

View Source
var DfltCentralManagerScanOpts = CentralManagerScanOpts{}

DfltCentralManagerScanOpts is the set of options that gets used when nil is passed to `Scan()`.

View Source
var DfltManagerOpts = ManagerOpts{
	ShowPowerAlert:    false,
	RestoreIdentifier: "",
}

DfltManagerOpts is the set of options that gets used when nil is passed to `NewCentralManager()`.

Functions

func BTCentralManagerDidConnectPeripheral

func BTCentralManagerDidConnectPeripheral(cmgr unsafe.Pointer, prph unsafe.Pointer)

func BTCentralManagerDidDisconnectPeripheral

func BTCentralManagerDidDisconnectPeripheral(cmgr unsafe.Pointer, prph unsafe.Pointer, err *C.struct_bt_error)

func BTCentralManagerDidDiscoverPeripheral

func BTCentralManagerDidDiscoverPeripheral(cmgr unsafe.Pointer, prph unsafe.Pointer, advData *C.struct_adv_fields,
	rssi C.int)

func BTCentralManagerDidFailToConnectPeripheral

func BTCentralManagerDidFailToConnectPeripheral(cmgr unsafe.Pointer, prph unsafe.Pointer, err *C.struct_bt_error)

func BTCentralManagerDidUpdateState

func BTCentralManagerDidUpdateState(cmgr unsafe.Pointer)

func BTCentralManagerWillRestoreState

func BTCentralManagerWillRestoreState(cmgr unsafe.Pointer, opts *C.struct_cmgr_restore_opts)

func BTPeripheralDidDiscoverCharacteristics

func BTPeripheralDidDiscoverCharacteristics(prph unsafe.Pointer, svc unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidDiscoverDescriptors

func BTPeripheralDidDiscoverDescriptors(prph unsafe.Pointer, chr unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidDiscoverIncludedServices

func BTPeripheralDidDiscoverIncludedServices(prph unsafe.Pointer, svc unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidDiscoverServices

func BTPeripheralDidDiscoverServices(prph unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidModifyServices

func BTPeripheralDidModifyServices(prph unsafe.Pointer, inv_svcs *C.struct_obj_arr)

func BTPeripheralDidReadRSSI

func BTPeripheralDidReadRSSI(prph unsafe.Pointer, rssi C.int, err *C.struct_bt_error)

func BTPeripheralDidUpdateName

func BTPeripheralDidUpdateName(prph unsafe.Pointer)

func BTPeripheralDidUpdateNotificationState

func BTPeripheralDidUpdateNotificationState(prph unsafe.Pointer, chr unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidUpdateValueForCharacteristic

func BTPeripheralDidUpdateValueForCharacteristic(prph unsafe.Pointer, chr unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidUpdateValueForDescriptor

func BTPeripheralDidUpdateValueForDescriptor(prph unsafe.Pointer, dsc unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidWriteValueForCharacteristic

func BTPeripheralDidWriteValueForCharacteristic(prph unsafe.Pointer, chr unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralDidWriteValueForDescriptor

func BTPeripheralDidWriteValueForDescriptor(prph unsafe.Pointer, dsc unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralIsReadyToSendWriteWithoutResponse

func BTPeripheralIsReadyToSendWriteWithoutResponse(prph unsafe.Pointer)

func BTPeripheralManagerCentralDidSubscribe

func BTPeripheralManagerCentralDidSubscribe(pmgr unsafe.Pointer, cent unsafe.Pointer, chr unsafe.Pointer)

func BTPeripheralManagerCentralDidUnsubscribe

func BTPeripheralManagerCentralDidUnsubscribe(pmgr unsafe.Pointer, cent unsafe.Pointer, chr unsafe.Pointer)

func BTPeripheralManagerDidAddService

func BTPeripheralManagerDidAddService(pmgr unsafe.Pointer, svc unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralManagerDidReceiveReadRequest

func BTPeripheralManagerDidReceiveReadRequest(pmgr unsafe.Pointer, req unsafe.Pointer)

func BTPeripheralManagerDidReceiveWriteRequests

func BTPeripheralManagerDidReceiveWriteRequests(pmgr unsafe.Pointer, oa *C.struct_obj_arr)

func BTPeripheralManagerDidStartAdvertising

func BTPeripheralManagerDidStartAdvertising(pmgr unsafe.Pointer, err *C.struct_bt_error)

func BTPeripheralManagerDidUpdateState

func BTPeripheralManagerDidUpdateState(pmgr unsafe.Pointer)

func BTPeripheralManagerIsReadyToUpdateSubscribers

func BTPeripheralManagerIsReadyToUpdateSubscribers(pmgr unsafe.Pointer)

func BTPeripheralManagerWillRestoreState

func BTPeripheralManagerWillRestoreState(pmgr unsafe.Pointer, opts *C.struct_pmgr_restore_opts)

func SetLog

func SetLog(log *logrus.Logger)

SetLog replaces the cbgo logger with a custom one.

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel configures the cbgo logger to use the specified log level.

Types

type AdvData

type AdvData struct {
	LocalName    string
	ServiceUUIDs []UUID

	// If len>0, this overrides the other fields.
	IBeaconData []byte
}

AdvData represents the configurable portion of outgoing advertisements.

type AdvFields

type AdvFields struct {
	LocalName        string
	ManufacturerData []byte
	TxPowerLevel     *int
	Connectable      *bool
	ServiceUUIDs     []UUID
	ServiceData      []AdvServiceData
}

AdvFields represents the contents of an advertisement received during scanning.

type AdvServiceData

type AdvServiceData struct {
	UUID UUID
	Data []byte
}

type Central

type Central struct {
	// contains filtered or unexported fields
}

Central: https://developer.apple.com/documentation/corebluetooth/cbcentral

type CentralManager

type CentralManager struct {
	// contains filtered or unexported fields
}

CentralManager: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager?language=objc

func NewCentralManager

func NewCentralManager(opts *ManagerOpts) CentralManager

NewCentralManager creates a central manager. Specify a nil `opts` value for defaults. Don't forget to call `SetDelegate()` afterwards!

func (CentralManager) RetrieveConnectedPeripheralsWithServices

func (cm CentralManager) RetrieveConnectedPeripheralsWithServices(uuids []UUID) []Peripheral

RetrieveConnectedPeripheralsWithServices: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipheralswith

func (CentralManager) RetrievePeripheralsWithIdentifiers

func (cm CentralManager) RetrievePeripheralsWithIdentifiers(uuids []UUID) []Peripheral

RetrievePeripheralsWithIdentifiers: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1519127-retrieveperipheralswithidentifie

func (CentralManager) SetDelegate

func (cm CentralManager) SetDelegate(d CentralManagerDelegate)

SetDelegate configures a receiver for a central manager's asynchronous callbacks.

type CentralManagerConnectOpts

type CentralManagerConnectOpts struct {
	NotifyOnConnection      bool
	NotifyOnDisconnection   bool
	NotifyOnNotification    bool
	EnableTransportBridging bool
	RequiresANCS            bool
	StartDelay              int
}

CentralManagerConnectOpts: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/peripheral_connection_options

type CentralManagerDelegateBase

type CentralManagerDelegateBase struct {
}

CentralManagerDelegateBase implements the CentralManagerDelegate interface with stub functions. Embed this in your delegate type if you only want to define a subset of the CentralManagerDelegate interface.

func (*CentralManagerDelegateBase) CentralManagerDidUpdateState

func (b *CentralManagerDelegateBase) CentralManagerDidUpdateState(cmgr CentralManager)

func (*CentralManagerDelegateBase) CentralManagerWillRestoreState

func (b *CentralManagerDelegateBase) CentralManagerWillRestoreState(cmgr CentralManager, opts CentralManagerRestoreOpts)

func (*CentralManagerDelegateBase) DidConnectPeripheral

func (b *CentralManagerDelegateBase) DidConnectPeripheral(cmgr CentralManager, prph Peripheral)

func (*CentralManagerDelegateBase) DidDisconnectPeripheral

func (b *CentralManagerDelegateBase) DidDisconnectPeripheral(cmgr CentralManager, prph Peripheral, err error)

func (*CentralManagerDelegateBase) DidDiscoverPeripheral

func (b *CentralManagerDelegateBase) DidDiscoverPeripheral(cmgr CentralManager, prph Peripheral, advFields AdvFields, rssi int)

func (*CentralManagerDelegateBase) DidFailToConnectPeripheral

func (b *CentralManagerDelegateBase) DidFailToConnectPeripheral(cmgr CentralManager, prph Peripheral, err error)

type CentralManagerRestoreOpts

type CentralManagerRestoreOpts struct {
	Peripherals            []Peripheral
	ScanServices           []UUID
	CentralManagerScanOpts *CentralManagerScanOpts // nil if none
}

CentralManagerRestoreOpts: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/central_manager_state_restoration_options

type CentralManagerScanOpts

type CentralManagerScanOpts struct {
	AllowDuplicates       bool
	SolicitedServiceUUIDs []UUID
}

CentralManagerScanOpts: https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/peripheral_scanning_options

type MutableCharacteristic

type MutableCharacteristic struct {
	// contains filtered or unexported fields
}

MutableCharacteristic: https://developer.apple.com/documentation/corebluetooth/cbmutablecharacteristic

func NewMutableCharacteristic

func NewMutableCharacteristic(uuid UUID, properties CharacteristicProperties,
	value []byte, permissions AttributePermissions) MutableCharacteristic

func (MutableCharacteristic) Characteristic

func (c MutableCharacteristic) Characteristic() Characteristic

Characteristic converts a MutableCharacteristic into its underlying Characteristic.

type MutableDescriptor

type MutableDescriptor struct {
	// contains filtered or unexported fields
}

MutableDescriptor: https://developer.apple.com/documentation/corebluetooth/cbmutabledescriptor

func NewMutableDescriptor

func NewMutableDescriptor(uuid UUID, value []byte) MutableDescriptor

func (MutableDescriptor) Descriptor

func (d MutableDescriptor) Descriptor() Descriptor

Descriptor converts a MutableDescriptor into its underlying Descriptor.

type MutableService

type MutableService struct {
	// contains filtered or unexported fields
}

MutableService: https://developer.apple.com/documentation/corebluetooth/cbmutableservice

func NewMutableService

func NewMutableService(uuid UUID, primary bool) MutableService

func (MutableService) Service

func (s MutableService) Service() Service

Service converts a MutableService into its underlying Service.

type NSError

type NSError struct {
	// contains filtered or unexported fields
}

NSError: https://developer.apple.com/documentation/foundation/nserror

func (*NSError) Code

func (e *NSError) Code() int

func (*NSError) Error

func (e *NSError) Error() string

func (*NSError) Message

func (e *NSError) Message() string

type Peripheral

type Peripheral struct {
	// contains filtered or unexported fields
}

Peripheral: https://developer.apple.com/documentation/corebluetooth/cbperipheral

func (Peripheral) DiscoverCharacteristics

func (p Peripheral) DiscoverCharacteristics(chrUUIDs []UUID, svc Service)

DiscoverCharacteristics: https://developer.apple.com/documentation/corebluetooth/cbperipheral/1518797-discovercharacteristics

func (Peripheral) DiscoverIncludedServices

func (p Peripheral) DiscoverIncludedServices(svcUUIDs []UUID, svc Service)

DiscoverIncludedServices: https://developer.apple.com/documentation/corebluetooth/cbperipheral/1519014-discoverincludedservices

func (Peripheral) WriteCharacteristic

func (p Peripheral) WriteCharacteristic(data []byte, chr Characteristic, withRsp bool)

WriteCharacteristic: https://developer.apple.com/documentation/corebluetooth/cbperipheral/1518747-writevalue

type PeripheralDelegate

type PeripheralDelegate interface {
	// DidDiscoverServices: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518744-peripheral
	DidDiscoverServices(prph Peripheral, err error)

	// DidDiscoverIncludedServices: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1519124-peripheral
	DidDiscoverIncludedServices(prph Peripheral, svc Service, err error)

	// DidDiscoverCharacteristics: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518821-peripheral
	DidDiscoverCharacteristics(prph Peripheral, svc Service, err error)

	// DidDiscoverDescriptors: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518785-peripheral
	DidDiscoverDescriptors(prph Peripheral, chr Characteristic, err error)

	// DidUpdateValueForCharacteristic: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518708-peripheral
	DidUpdateValueForCharacteristic(prph Peripheral, chr Characteristic, err error)

	// DidUpdateValueForDescriptor: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518929-peripheral
	DidUpdateValueForDescriptor(prph Peripheral, dsc Descriptor, err error)

	// DidWriteValueForCharacteristic: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518823-peripheral
	DidWriteValueForCharacteristic(prph Peripheral, chr Characteristic, err error)

	// DidWriteValueForDescriptor: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1519062-peripheral
	DidWriteValueForDescriptor(prph Peripheral, dsc Descriptor, err error)

	// IsReadyToSendWriteWithoutResponse: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/2874034-peripheralisreadytosendwritewith
	IsReadyToSendWriteWithoutResponse(prph Peripheral)

	// DidUpdateNotificationState: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518768-peripheral
	DidUpdateNotificationState(prph Peripheral, chr Characteristic, err error)

	// DidReadRSSI: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1620304-peripheral
	DidReadRSSI(prph Peripheral, rssi int, err error)

	// DidUpdateName: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518801-peripheraldidupdatename
	DidUpdateName(prph Peripheral)

	// DidModifyServices: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate/1518865-peripheral
	DidModifyServices(prph Peripheral, invSvcs []Service)
}

PeripheralDelegate: https://developer.apple.com/documentation/corebluetooth/cbperipheraldelegate

type PeripheralDelegateBase

type PeripheralDelegateBase struct {
}

PeripheralDelegateBase implements the PeripheralDelegate interface with stub functions. Embed this in your delegate type if you only want to define a subset of the PeripheralDelegate interface.

func (*PeripheralDelegateBase) DidDiscoverCharacteristics

func (b *PeripheralDelegateBase) DidDiscoverCharacteristics(prph Peripheral, svc Service, err error)

func (*PeripheralDelegateBase) DidDiscoverDescriptors

func (b *PeripheralDelegateBase) DidDiscoverDescriptors(prph Peripheral, chr Characteristic, err error)

func (*PeripheralDelegateBase) DidDiscoverIncludedServices

func (b *PeripheralDelegateBase) DidDiscoverIncludedServices(prph Peripheral, svc Service, err error)

func (*PeripheralDelegateBase) DidDiscoverServices

func (b *PeripheralDelegateBase) DidDiscoverServices(prph Peripheral, err error)

func (*PeripheralDelegateBase) DidModifyServices

func (b *PeripheralDelegateBase) DidModifyServices(prph Peripheral, invSvcs []Service)

func (*PeripheralDelegateBase) DidReadRSSI

func (b *PeripheralDelegateBase) DidReadRSSI(prph Peripheral, rssi int, err error)

func (*PeripheralDelegateBase) DidUpdateName

func (b *PeripheralDelegateBase) DidUpdateName(prph Peripheral)

func (*PeripheralDelegateBase) DidUpdateNotificationState

func (b *PeripheralDelegateBase) DidUpdateNotificationState(prph Peripheral, chr Characteristic, err error)

func (*PeripheralDelegateBase) DidUpdateValueForCharacteristic

func (b *PeripheralDelegateBase) DidUpdateValueForCharacteristic(prph Peripheral, chr Characteristic, err error)

func (*PeripheralDelegateBase) DidUpdateValueForDescriptor

func (b *PeripheralDelegateBase) DidUpdateValueForDescriptor(prph Peripheral, dsc Descriptor, err error)

func (*PeripheralDelegateBase) DidWriteValueForCharacteristic

func (b *PeripheralDelegateBase) DidWriteValueForCharacteristic(prph Peripheral, chr Characteristic, err error)

func (*PeripheralDelegateBase) DidWriteValueForDescriptor

func (b *PeripheralDelegateBase) DidWriteValueForDescriptor(prph Peripheral, dsc Descriptor, err error)

func (*PeripheralDelegateBase) IsReadyToSendWriteWithoutResponse

func (b *PeripheralDelegateBase) IsReadyToSendWriteWithoutResponse(prph Peripheral)

type PeripheralManager

type PeripheralManager struct {
	// contains filtered or unexported fields
}

PeripheralManager: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager

func NewPeripheralManager

func NewPeripheralManager(opts *ManagerOpts) PeripheralManager

NewPeripheralManager creates a peripheral manager. Specify a nil `opts` value for defaults. Don't forget to call `SetDelegate()` afterwards!

func (PeripheralManager) SetDelegate

func (pm PeripheralManager) SetDelegate(d PeripheralManagerDelegate)

SetDelegate configures a receiver for a central manager's asynchronous callbacks.

type PeripheralManagerDelegate

type PeripheralManagerDelegate interface {
	// PeripheralManagerDidUpdateState: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393271-peripheralmanagerdidupdatestate
	PeripheralManagerDidUpdateState(pmgr PeripheralManager)

	// PeripheralManagerWillRestoreState: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393317-peripheralmanager
	PeripheralManagerWillRestoreState(pmgr PeripheralManager, opts PeripheralManagerRestoreOpts)

	// DidAddService: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393279-peripheralmanager
	DidAddService(pmgr PeripheralManager, svc Service, err error)

	// DidStartAdvertising: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393321-peripheralmanagerdidstartadverti
	DidStartAdvertising(pmgr PeripheralManager, err error)

	// CentralDidSubscribe: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393261-peripheralmanager
	CentralDidSubscribe(pmgr PeripheralManager, cent Central, chr Characteristic)

	// CentralDidUnsubscribe: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393289-peripheralmanager
	CentralDidUnsubscribe(pmgr PeripheralManager, cent Central, chr Characteristic)

	// IsReadyToUpdateSubscribers: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393248-peripheralmanagerisreadytoupdate
	IsReadyToUpdateSubscribers(pmgr PeripheralManager)

	// DidReceiveReadRequest: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393257-peripheralmanager
	DidReceiveReadRequest(pmgr PeripheralManager, req ATTRequest)

	// DidReceiveWriteRequests: https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate/1393315-peripheralmanager
	DidReceiveWriteRequests(pmgr PeripheralManager, reqs []ATTRequest)
}

https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate

type PeripheralManagerDelegateBase

type PeripheralManagerDelegateBase struct {
}

PeripheralManagerDelegateBase implements the PeripheralManagerDelegate interface with stub functions. Embed this in your delegate type if you only want to define a subset of the PeripheralManagerDelegate interface.

func (*PeripheralManagerDelegateBase) CentralDidSubscribe

func (b *PeripheralManagerDelegateBase) CentralDidSubscribe(pmgr PeripheralManager, cent Central, chr Characteristic)

func (*PeripheralManagerDelegateBase) CentralDidUnsubscribe

func (b *PeripheralManagerDelegateBase) CentralDidUnsubscribe(pmgr PeripheralManager, cent Central, chr Characteristic)

func (*PeripheralManagerDelegateBase) DidAddService

func (b *PeripheralManagerDelegateBase) DidAddService(pmgr PeripheralManager, svc Service, err error)

func (*PeripheralManagerDelegateBase) DidReceiveReadRequest

func (b *PeripheralManagerDelegateBase) DidReceiveReadRequest(pmgr PeripheralManager, req ATTRequest)

func (*PeripheralManagerDelegateBase) DidReceiveWriteRequests

func (b *PeripheralManagerDelegateBase) DidReceiveWriteRequests(pmgr PeripheralManager, reqs []ATTRequest)

func (*PeripheralManagerDelegateBase) DidStartAdvertising

func (b *PeripheralManagerDelegateBase) DidStartAdvertising(pmgr PeripheralManager, err error)

func (*PeripheralManagerDelegateBase) IsReadyToUpdateSubscribers

func (b *PeripheralManagerDelegateBase) IsReadyToUpdateSubscribers(pmgr PeripheralManager)

func (*PeripheralManagerDelegateBase) PeripheralManagerDidUpdateState

func (b *PeripheralManagerDelegateBase) PeripheralManagerDidUpdateState(pmgr PeripheralManager)

func (*PeripheralManagerDelegateBase) PeripheralManagerWillRestoreState

func (b *PeripheralManagerDelegateBase) PeripheralManagerWillRestoreState(pmgr PeripheralManager, opts PeripheralManagerRestoreOpts)

type UUID

type UUID []byte

UUID is a 16-bit or 128-bit UUID.

func MustParseUUID

func MustParseUUID(s string) UUID

MustParseUUID is like ParseUUID except it panics on failure.

func ParseUUID

func ParseUUID(s string) (UUID, error)

ParseUUID parses a string representing a 16-bit or 128-bit UUID.

func ParseUUID128

func ParseUUID128(s string) (UUID, error)

ParseUUID128 parses a UUID string with the form:

01234567-89ab-cdef-0123-456789abcdef

func ParseUUID16

func ParseUUID16(s string) (UUID, error)

ParseUUID16 parses a UUID string with the form:

1234

func UUID128

func UUID128(b []byte) (UUID, error)

UUID16 constructs a 128-bit UUID from a 16-element byte slice.

func UUID16

func UUID16(i uint16) UUID

UUID16 constructs a 16-bit UUID from a uint16.

func (UUID) String

func (u UUID) String() string

String retruns a CoreBluetooth-friendly string representation of a UUID.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL