iOS docs

Types

Protocols

Global Typealiases

AbleATTRequest

A request made to an IAbleGATTServer, to which the server can respond. Can't be directly instantiated.

public class AbleATTRequest
  • Tag: AbleATTRequest

Properties

peer

Peer from which this request came.

var peer: AblePeer

characteristics

The characteristic whose value will be read or written.

var characteristics: AbleCharacteristic

offset

The zero-based index of the first byte for the read or write.

var offset: Int

value

The data being read or written. For read requests, value will be nil and should be set before responding. For write requests, value will contain the data to be written.

var value: Data?

AbleAdverisementData

Data to be advertised when IAbleManager.startAdvertising is called. When in the foreground, an application can utilize up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data types. If this space is used up, there are an additional 10 bytes of space in the scan response that can be used only for the local name. Note that these sizes do not include the 2 bytes of header information that are required for each new data type. Any service UUIDs that do not fit in the allotted space will be added to a special "overflow" area, and can only be discovered by an iOS device that is explicitly scanning for them. While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able to advertise anything while in the background.

public struct AbleAdverisementData

Initializers

init(localName:services:)

public init(localName: String?, services: [AbleUUID]?)

Parameters

  • localName: Optional, specifies the name of the local device under which it will be visible to other devices.
  • services: UUIDs of services to include in the advertisement.

AbleCentralConnectionCallback

Callback used to notify of an attempt at establishing a connection with peripheral device.

public typealias AbleCentralConnectionCallback = ((Result<AbleDevice, AbleCentralManagerError>) -> Void)

Callback returns AbleDevice, or .AbleCentralManagerError in case of a failure.

  • Tag: AbleCentralConnectionSuccessCallback

AbleCentralConnectionFailureCallback

Callback used to notify of failure to connect with peripheral device.

public typealias AbleCentralConnectionFailureCallback = ((AbleDevice, AbleCentralManagerError)->())

Callback returns AbleDevice with which central failed to connect along with .failedToConnect error.

  • Tag: AbleCentralConnectionFailureCallback

AbleCentralConnectionSuccessCallback

Callback used to notify of successfully established connection with peripheral device.

public typealias AbleCentralConnectionSuccessCallback = ((AbleDevice)->())

Callback returns AbleDevice.

  • Tag: AbleCentralConnectionSuccessCallback

AbleCentralDisconnectedPeripheralCallback

Callback used to notify of terminated connection with peripheral device.

public typealias AbleCentralDisconnectedPeripheralCallback = ((Result<AbleDevice, AbleCentralManagerError>) -> Void)

Callback returns AbleDevice which was disconnected along with error that may have occurred.

  • Tag: AbleCentralDisconnectedPeripheralCallback

AbleCentralDiscoveredPeripheralCallback

Callback used to notify peripheral discovery.

public typealias AbleCentralDiscoveredPeripheralCallback = ((Result<AblePeripheralInfo, AbleCentralManagerError>)->())

Callback returns AblePeripheralInfo.

  • Tag: AbleCentralDiscoveredPeripheralCallback

AbleCentralDiscoveredPeripheralsCallback

Callback used to notify peripheral discovery.

public typealias AbleCentralDiscoveredPeripheralsCallback = ((Result<Set<AblePeripheralInfo>, AbleCentralManagerError>)->())

Callback returns AblePeripheralInfo.

  • Tag: AbleCentralDiscoveredPeripheralCallback

AbleCentralManagerError

Enum used to handle different AbleCentralManager errors.

public enum AbleCentralManagerError
  • Tag: AbleCentralManagerError

Inheritance

Error

Enumeration Cases

notInitialized

Indicates that AbleCentralManager has not been initialized.

case notInitialized

Use initAbleCentralManager(with queue:using options:_ onCompletion:) method of AbleManager to initialize AbleCentralManager.

  • Tag: ErrorNotInitialized

unauthorized

Indicates that AbleCentralManager's state is .unauthorized.

case unauthorized

This error indicated that Bluetooth permission has not been given. In order to use Able-iOS framework use of Bluetooth must be allowed in Settings.

  • Tag: ErrorUnauthorized

incorrectState

Indicates that AbleCentralManager's state is not .poweredOn.

case incorrectState
  • Tag: ErrorIncorrectState

illegalOperation

Indicates that the current operation is unsupported. E.g, if the app is backgrounded, and the scan operation was called without providing a service UUID. The associated String indicates the reason why the error occurred.

case illegalOperation(reason: String)
  • Tag: ErrorIllegalOperation

failedToConnect

Indicates that AbleCentralManager has failed to connect to peripheral device.

case failedToConnect(retries: Int, error: Error?)
  • Tag: ErrorFailedToConnect

disconnect

Indicates that an error occurred when AbleCentralManager attempted to disconnect from peripheral.

case disconnect(with: Error)
  • Tag: ErrorDisconnect

Properties

debugDescription

Short description of an error case that occurred.

var debugDescription: String

localizedDescription

var localizedDescription: String

AbleCentralManagerRestoredState

Contains data restored when AbleCentralManager is restored upon app relaunch.

public protocol AbleCentralManagerRestoredState
  • Tag: AbleCentralManagerRestoredState

Requirements

devices

var devices: [AbleDevice]

qualityOfService

var qualityOfService: QualityOfService

services

var services: [AbleService]

AbleCentralManagerRestoredStateCallback

Callback for when central manager state is restored upon app relaunch, a part of IAbleManager#initialize.

public typealias AbleCentralManagerRestoredStateCallback = (AbleCentralManagerRestoredState) -> Void
  • Tag: AbleCentralManagerRestoredStateCallback

AbleCentralManagerRestoredStateImpl

Implementation of AbleCentralManagerRestoredState, derives data from the passed dictionary supplied by launch options.

public struct AbleCentralManagerRestoredStateImpl: AbleCentralManagerRestoredState
  • Tag: AbleCentralManagerRestoredStateImpl

Inheritance

AbleCentralManagerRestoredState

Properties

devices

let devices: [AbleDevice]

qualityOfService

let qualityOfService: QualityOfService

services

let services: [AbleService]

AbleCentralManagerState

Enum used to define central device's current state.

public enum AbleCentralManagerState
  • Tag: AbleCentralManagerState

Inheritance

Int

Enumeration Cases

unknown

The manager’s state is unknown.

case unknown

This is a temporary state. After central initializes or resets, it updates the state value.

  • Tag: Unknown

resetting

A state that indicates the connection with the system service was momentarily lost.

case resetting

This state indicates that Bluetooth is trying to reconnect. After it reconnects, central updates the state value.

  • Tag: Resetting

unsupported

A state that indicates this device doesn’t support the Bluetooth low energy central or client role.

case unsupported
  • Tag: Unsupported

unauthorized

A state that indicates the application isn’t authorized to use the Bluetooth low energy role.

case unauthorized
  • Tag: Unauthorized

poweredOff

A state that indicates Bluetooth is currently powered off.

case poweredOff
  • Tag: PoweredOff

poweredOn

A state that indicates Bluetooth is currently powered on and available to use.

case poweredOn
  • Tag: PoweredOn

AbleCentralManagerStateCallback

Callback used to notify of AbleCentralManager's state change.

public typealias AbleCentralManagerStateCallback = ((Result<AbleCentralManagerState, AbleCentralManagerError>) -> ())

If AbleCentralManager's state is not .poweredOn call will be made that returns .failure with an appropriate error - .incorrectstate.

  • Tag: AbleCentralManagerStateCallback

AbleCharacteristic

public class AbleCharacteristic: NSObject, AbleServiceComponent

Inheritance

AbleServiceComponent, NSObject

Initializers

init(uuid:properties:permissions:)

public init(uuid: AbleUUID, properties: CBCharacteristicProperties, permissions: CBAttributePermissions)

init(uuid:properties:permissions:assign:)

public convenience init(uuid: AbleUUID, properties: CBCharacteristicProperties, permissions: CBAttributePermissions, assign to: inout AbleCharacteristic?)

Properties

service

var service: AbleService

value

var value: Data?

descriptors

var descriptors: [AbleDescriptor]?

properties

var properties: AbleCharacteristicProperties?

isNotifying

var isNotifying: Bool

uuid

var uuid: AbleUUID

AbleCharacteristicProperties

Values that represent the possible properties of a characteristic.

public struct AbleCharacteristicProperties: OptionSet

Since you can combine characteristic properties, a characteristic may have multiple property values set.

Inheritance

OptionSet

Initializers

init(rawValue:)

public init(rawValue: UInt)

Properties

rawValue

let rawValue: UInt

broadcast

Permits broadcasts of the characteristic value using a characteristic configuration descriptor. Not allowed for local characteristics

var broadcast

read

Permits reads of the characteristic value.

var read

writeWithoutResponse

Permits writes of the characteristic value, without a response.

var writeWithoutResponse

write

Permits writes of the characteristic value.

var write

notify

Permits notifications of the characteristic value, without a response.

var notify

indicate

Permits indications of the characteristic value.

var indicate

authenticatedSignedWrites

Permits signed writes of the characteristic value

var authenticatedSignedWrites

extendedProperties

If set, additional characteristic properties are defined in the characteristic extended properties descriptor. Not allowed for local characteristics.

var extendedProperties

notifyEncryptionRequired

If set, only trusted devices can enable notifications of the characteristic value.

var notifyEncryptionRequired

indicateEncryptionRequired

If set, only trusted devices can enable indications of the characteristic value.

var indicateEncryptionRequired

AbleCharacteristicWriteType

Values representing the possible write types to a characteristic’s value.

public enum AbleCharacteristicWriteType

Characteristic write types have corresponding restrictions on the length of the data that you can write to a characteristic’s value.

  • Tag: AbleCharacteristicWriteType

Inheritance

Int

Enumeration Cases

withResponse

Write a characteristic value, with a response from AbleDevice to indicate whether the write was successful.

case withResponse

If the write is unsuccessful, AbleDevice responds with an error that details the cause of the failure.

See:

withoutResponse

Write a characteristic value, without any response from AbleDevice to indicate whether the write was successful.

case withoutResponse

You receive no notification if writing to a characteristic value fails with this write type.

See:

AbleComm

Manages the communication with a Bluetooth peripheral. Takes care of data scheduling, retries and distributes requests and responses to appropriate callbacks.

public class AbleComm: IAbleComm
  • Tag: AbleComm

Inheritance

IAbleComm

Properties

manager

var manager: IAbleManager

Methods

onDiscoverServices(_:)

@discardableResult public func onDiscoverServices(_ callback: @escaping AbleDeviceDidDiscoverServicesCallback) -> Self

onDiscoverCharacteristics(_:)

@discardableResult public func onDiscoverCharacteristics(_ callback: @escaping AbleDeviceDidDiscoverCharacteristicsCallback) -> Self

onDiscoverDescriptors(_:)

@discardableResult public func onDiscoverDescriptors(_ callback: @escaping AbleDeviceDidDiscoverDescriptorsCallback) -> Self

onDescriptorRead(_:)

@discardableResult public func onDescriptorRead(_ callback: @escaping AbleDeviceDidUpdateValueForDescriptorCallback) -> Self

onDescriptorWrite(_:)

@discardableResult public func onDescriptorWrite(_ callback: @escaping AbleDeviceDidWriteValueForDescriptorCallback) -> Self

onCharacteristicUpdateValue(_:)

@discardableResult public func onCharacteristicUpdateValue(_ callback: @escaping AbleDeviceDidUpdateValueForCharacteristicCallback) -> Self

onCharacteristicWrite(_:)

@discardableResult public func onCharacteristicWrite(_ callback: @escaping AbleDeviceDidWriteValueForCharacteristicCallback) -> Self

setAbleDeviceDidUpdateNameCallback(_:)

Method used to setup a callback that will be invoked on AbleDevice name change.

public func setAbleDeviceDidUpdateNameCallback(_ callback: @escaping AbleDeviceUpdatedNameCallback)

Parameters

readConnectedDeviceRSSI(with:)

Method used to retrieve connected device's RSSI - Received Signal Strength Indicator.

public func readConnectedDeviceRSSI(with completion: @escaping AbleDeviceDidReadRSSICallback)

Parameters

connectWithoutScan(with:callback:)

The same as connect, but doesn't scan if the *cbperipheral * isn't found. instead, it automatically throws .failedtoconnect() error.

public func connectWithoutScan(with options: [String: Any]? = nil, callback: @escaping AbleCentralConnectionCallback)

connect(with:callback:)

Method used to initiate connection with AbleDevice. If the AbleDevice's associated CBPeripheral can't be found, the method will automatically scan to find it.

public func connect(with options: [String: Any]? = nil, callback: @escaping AbleCentralConnectionCallback)

Upon establishing connection with AbleDevice onSuccess block will be call to notify of connection event. In case of a failure to connect to the AbleDevice, retry attempts will be made up to a maximum number of times defined by numberOfRetries variable of ablecentralmanager. each consecutive retry is made after retrydelay time interval defined by AbleCentralManager has elapsed from the moment onFailure callback has notified of failed attempt to connect. To cancel a pending connection call cancelConnection(with ableDevice:) method of AbleComm or deallocate AbleDevice object to which AbleCentralManager is attempting to connect.

See:

Parameters

disconnect(with:)

Method used to cancel pending or established peripheral connection.

public func disconnect(with completion: @escaping AbleCentralDisconnectedPeripheralCallback)
  • Tag: cancelConnectionWithAbleDevice

Parameters

setAbleDeviceDidModifyServicesCallback(_:)

Method used to setup a callback that will be invoked when AbleDevice services are modified.

public func setAbleDeviceDidModifyServicesCallback(_ callback: @escaping AbleDeviceDidModifyServicesCallback)

Parameters

discoverServices(_:with:)

Method used to discover connected device's services.

public func discoverServices(_ serviceUUIDs: [AbleUUID]?, with completion: @escaping AbleDeviceDidDiscoverServicesCallback)

Parameters

discoverServices(_:)

Method used to discover connected device's services.

public func discoverServices(_ serviceUUIDs: [AbleUUID]?)

Parameters

  • serviceUUIDs: An array of AbleUUID objects that you are interested in. Each AbleUUID object represents a UUID that identifies the type of service you want to discover.

discoverConnectedDeviceIncludedServices(_:for:with:)

Method used to discover connected device's included services for specified service.

public func discoverConnectedDeviceIncludedServices(_ serviceUUIDs: [AbleUUID]?, for service: AbleService, with completion: @escaping AbleDeviceDidDiscoverIncludedServicesCallback)

You can provide an array of AbleUUID objects—representing included service UUIDs—in the serviceUUIDs parameter. When you do, AbleDevice returns only the services that match the provided UUIDs.

Parameters

  • serviceUUIDs: An array of AbleUUID objects that you are interested in. Each AbleUUID object represents a UUID that identifies the type of service you want to discover.
  • service: The previously-discovered AbleService whose included services you want to discover.
  • completion: AbleDeviceDidDiscoverIncludedServicesCallback invoked when included services have been discovered.

discoverCharacteristics(_:for:with:)

Discovers the specified characteristics of a service.

public func discoverCharacteristics(_ characteristicUUIDs: [AbleUUID]?, for ableService: AbleService, with completion: @escaping AbleDeviceDidDiscoverCharacteristicsCallback)

You can provide an array of AbleUUID objects—representing characteristic UUIDs— in the characteristicUUIDs parameter. When you do, AbleDevice 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.

  • Note If the characteristicUUIDs parameter is nil, this method returns all of the service’s characteristics. This is much slower than providing an array of characteristic UUIDs to search for.

Parameters

  • characteristicUUIDs: An array of AbleUUID objects that you are interested in. Each AbleUUID object represents a UUID that identifies the type of a characteristic you want to discover.
  • ableService: The service whose characteristics you want to discover.
  • completion: AbleDeviceDidDiscoverCharacteristicsCallback invoked when characteristics have been discovered.

discoverCharacteristics(_:for:)

Discovers the specified characteristics of a service.

public func discoverCharacteristics(_ characteristicUUIDs: [AbleUUID]?, for ableService: AbleService)

You can provide an array of AbleUUID objects—representing characteristic UUIDs— in the characteristicUUIDs parameter. When you do, AbleDevice 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.

  • Note If the characteristicUUIDs parameter is nil, this method returns all of the service’s characteristics. This is much slower than providing an array of characteristic UUIDs to search for.

Parameters

  • characteristicUUIDs: An array of AbleUUID objects that you are interested in. Each AbleUUID object represents a UUID that identifies the type of a characteristic you want to discover.
  • ableService: The service whose characteristics you want to discover.

discoverDescriptors(for:with:)

Discovers the descriptors of a characteristic.

public func discoverDescriptors(for ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidDiscoverDescriptorsCallback)

When AbleDevice discovers one or more descriptors of the specified characteristic, it calls the peripheral(_:didDiscoverDescriptorsFor:error:) method of its delegate object. After AbleDevice discovers the descriptors of the characteristic, you can access them through the characteristic’s descriptors property.

Parameters

discoverDescriptors(for:)

Discovers the descriptors of a characteristic.

public func discoverDescriptors(for ableCharacteristic: AbleCharacteristic)

When AbleDevice discovers one or more descriptors of the specified characteristic, it calls the peripheral(_:didDiscoverDescriptorsFor:error:) method of its delegate object. After AbleDevice discovers the descriptors of the characteristic, you can access them through the characteristic’s descriptors property.

Parameters

readCharacteristic(_:with:)

Retrieves the value of a specified characteristic.

public func readCharacteristic(_ ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidUpdateValueForCharacteristicCallback)

When you call this method to read the value of a characteristic, AbleDevice calls the peripheral(_:didUpdateValueFor:error:) method of its delegate object. If AbleDevice successfully reads the value of the characteristic, you can access it through the characteristic’s value property.

Parameters

readCharacteristic(_:)

Retrieves the value of a specified characteristic.

public func readCharacteristic(_ ableCharacteristic: AbleCharacteristic)

When you call this method to read the value of a characteristic, AbleDevice calls the peripheral(_:didUpdateValueFor:error:) method of its delegate object. If AbleDevice successfully reads the value of the characteristic, you can access it through the characteristic’s value property.

Parameters

readDescriptor(_:with:)

Retrieves the value of a specified characteristic descriptor.

public func readDescriptor(_ ableDescriptor: AbleDescriptor, with completion: @escaping AbleDeviceDidUpdateValueForDescriptorCallback)

When you call this method to read the value of a characteristic descriptor, AbleDevice calls the peripheral(_:didUpdateValueFor:error:) method of its delegate object. If AbleDevice successfully retrieves the value of the characteristic descriptor, you can access it through the characteristic descriptor’s value property.

Parameters

readDescriptor(_:)

Retrieves the value of a specified characteristic descriptor.

public func readDescriptor(_ ableDescriptor: AbleDescriptor)

When you call this method to read the value of a characteristic descriptor, AbleDevice calls the peripheral(_:didUpdateValueFor:error:) method of its delegate object. If AbleDevice successfully retrieves the value of the characteristic descriptor, you can access it through the characteristic descriptor’s value property.

Parameters

writeDescriptor(_:data:with:)

Writes the value of a characteristic descriptor.

public func writeDescriptor(_ ableDescriptor: AbleDescriptor, data: Data, with completion: @escaping AbleDeviceDidWriteValueForDescriptorCallback)

When you call this method to write the value of a characteristic descriptor, AbleDevice calls the peripheral(:didWriteValueFor:error:) 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 setNotifyValue(:for:) method instead.

Parameters

writeDescriptor(_:data:)

Writes the value of a characteristic descriptor.

public func writeDescriptor(_ ableDescriptor: AbleDescriptor, data: Data)

When you call this method to write the value of a characteristic descriptor, AbleDevice calls the peripheral(:didWriteValueFor:error:) 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 setNotifyValue(:for:) method instead.

Parameters

  • data: Value to write.
  • ableDescriptor: AbleDescriptor containing the value to write.

writeCharacteristic(_:data:type:with:)

Writes the value of a characteristic.

public func writeCharacteristic(_ ableCharacteristic: AbleCharacteristic, data: Data, type: AbleCharacteristicWriteType, with completion: @escaping AbleDeviceDidWriteValueForCharacteristicCallback)

When you call this method to write the value of a characteristic, AbleDevice calls the peripheral(_:didWriteValueFor:error:) method of its delegate object only if you specified the write type as AbleCharacteristicWriteType.withResponse. The response you receive through AbleDeviceDidWriteValueForDescriptorCallback 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 AbleCharacteristicWriteType.withoutResponse, Able-iOS 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 write and writeWithoutResponse members of the characteristic’s 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.

Parameters

writeCharacteristic(_:data:type:)

Writes the value of a characteristic.

public func writeCharacteristic(_ ableCharacteristic: AbleCharacteristic, data: Data, type: AbleCharacteristicWriteType)

When you call this method to write the value of a characteristic, AbleDevice calls the peripheral(_:didWriteValueFor:error:) method of its delegate object only if you specified the write type as AbleCharacteristicWriteType.withResponse. The response you receive through AbleDeviceDidWriteValueForDescriptorCallback 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 AbleCharacteristicWriteType.withoutResponse, Able-iOS 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 write and writeWithoutResponse members of the characteristic’s 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.

Parameters

  • data: Value to write.
  • ableCharacteristic: AbleCharacteristic containing the value to write.

setNotifyValue(_:for:with:)

Sets notifications or indications for the value of a specified characteristic.

public func setNotifyValue(_ enabled: Bool, for ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidUpdateNotificationStateCallback)

When you enable notifications for the characteristic’s value, AbleDevice calls the peripheral(:didUpdateNotificationStateFor:error:) method of its delegate object to indicate if the action succeeded. If successful, AbleDevice then calls the peripheral(:didUpdateValueFor:error:) method of its delegate object whenever the characteristic value changes. Because AbleDevice 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.

Parameters

  • 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.
  • ableCharacteristic: The specified characteristic.
  • completion: AbleDeviceDidUpdateNotificationStateCallback invoked when AbleDevice updates notifying state of characteristic.

maximumWriteValueLength(for:)

The maximum amount of data, in bytes, you can send to a characteristic in a single write type.

public func maximumWriteValueLength(for writeType: AbleCharacteristicWriteType) -> Int?

Parameters

  • writeType: The characteristic write type to inspect.

AbleCommActionBlock

public typealias AbleCommActionBlock = (IAbleComm, Any?, @escaping AbleCommCompletionCallback) -> Void

AbleCommActions

Comm actions allow you to write cleaner code, less cluttered by callbacks. Even if the code looks sequential, all the actions are actually performed asynchronously, so make sure to check on the runcallback to know when they're done. Actions can't be reused - run can only be called once per action. This is to simplify action state management and prevent edge cases from multiple runs.

public class AbleCommActions
  • Tag: AbleCommActions

Methods

run(_:)

Start the action chain.. It will execute all the actions sequentially, and invoke its callback when everything is done.

public func run(_ completionCallback: AbleCommCompletionCallback? = nil)

Parameters

  • callback: completionCallback invoked when all the actions have been executed.

connect(options:)

Connects to the comm's device. See AbleComm,

public func connect(options: [String: Any]? = nil) -> Self
  • Tag: connect

disconnect()

Disconnects from the comm's device. See AbleComm,

public func disconnect() -> Self

discoverServices(_:mapper:)

Discovers services for the currently connected device. You must call connect before using this method. See AbleComm,

public func discoverServices(_ uuids: [AbleUUID]? = nil, mapper: (([AbleService]) throws -> AbleService)? = nil) -> ServiceAbleCommActions

Parameters

  • mapper: selects a single service from the list to be used by the chain. If this parameter isn't provided, the chain will automatically select the first service, if it exists, or throw an exception otherwise.

useService(_:)

Makes the actions use the provided service. The service is provided via a block as AbleCommActions are extecuted asynchronously.

public func useService(_ provider: @escaping () -> AbleService) -> ServiceAbleCommActions

Parameters

  • provider: provides the AbleService to be used by the action chain.

useCharacteristic(_:)

Makes the actions use the provided characteristic. The characteristic is provided via a block as AbleCommActions are extecuted asynchronously.

public func useCharacteristic(_ provider: @escaping () -> AbleCharacteristic) -> CharacteristicAbleCommActions

Parameters

  • provider: provides the AbleCharacteristic to be used by the action chain.

useDescriptor(_:)

Makes the actions use the provided descriptor. The descriptor is provided via a block as AbleCommActions are extecuted asynchronously.

public func useDescriptor(_ provider: @escaping () -> AbleDescriptor) -> DescriptorAbleCommActions

Parameters

  • provider: provides the AbleDescriptor to be used by the action chain.

include(_:)

Includes the other Actions into the current action chain.

public func include<Actions: AbleCommActions>(_ other: Actions) -> Actions

Parameters

  • other: AbleCommActions to include in the current chain.

AbleCommActionsError

public class AbleCommActionsError: Error

Inheritance

Error

Initializers

init(message:)

public init(message: String)

AbleCommCompletionCallback

public typealias AbleCommCompletionCallback = (Result<Any, Error>) -> Void

AbleDescriptor

public class AbleDescriptor: NSObject

Inheritance

NSObject

Properties

characteristic

var characteristic: AbleCharacteristic

value

var value: Any?

uuid

var uuid: AbleUUID

AbleDevice

Wrapper class which contains information on discovered peripheral devices.

public class AbleDevice: NSObject, Codable
  • Tag: AbleDevice

Inheritance

CBPeripheralDelegate, Codable, NSObject

Initializers

init(name:identifier:)

public init(name: String?, identifier: UUID)

init(from:)

public required convenience init(from decoder: Decoder) throws

Properties

name

let name: String?

identifier

let identifier: UUID

l2capCallbacks

var l2capCallbacks

isConnected

var isConnected: Bool

services

var services: [AbleService]?

comm

Instance of AbleComm used to perform common communication tasks. Note that this is not an IAbleComm instance! Use AbleManager.comm(with:) to get an IAbleComm instance if that matters.

var comm: AbleComm

hash

var hash: Int

Methods

==(lhs:rhs:)

public static func ==(lhs: AbleDevice, rhs: AbleDevice) -> Bool

isEqual(_:)

public override func isEqual(_ object: Any?) -> Bool

peripheralDidUpdateName(_:)

public func peripheralDidUpdateName(_ peripheral: CBPeripheral)

peripheral(_:didModifyServices:)

public func peripheral(_ peripheral: CBPeripheral, didModifyServices invalidatedServices: [CBService])

peripheral(_:didReadRSSI:error:)

public func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?)

peripheral(_:didDiscoverServices:)

public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?)

peripheral(_:didDiscoverIncludedServicesFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didDiscoverIncludedServicesFor service: CBService, error: Error?)

peripheral(_:didDiscoverCharacteristicsFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?)

peripheral(_:didUpdateValueFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)

peripheral(_:didWriteValueFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?)

peripheral(_:didUpdateNotificationStateFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?)

peripheral(_:didDiscoverDescriptorsFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error: Error?)

peripheral(_:didUpdateValueFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error: Error?)

peripheral(_:didWriteValueFor:error:)

public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor descriptor: CBDescriptor, error: Error?)

peripheralIsReady(toSendWriteWithoutResponse:)

public func peripheralIsReady(toSendWriteWithoutResponse peripheral: CBPeripheral)

peripheral(_:didOpen:error:)

@available(iOS 11.0, *) public func peripheral(_ peripheral: CBPeripheral, didOpen channel: CBL2CAPChannel?, error: Error?)

AbleDeviceDidDiscoverCharacteristicsCallback

Notifies that AbleDevice found characteristics for a service.

public typealias AbleDeviceDidDiscoverCharacteristicsCallback = ((Result<[AbleCharacteristic], Error>) -> Void)

This callback is invoked when your app calls the discoverCharacteristics(_:for:) method. If AbleDevice successfully discovers the characteristics of the specified service, you can access them through the service’s characteristics property. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidDiscoverCharacteristicsCallback

AbleDeviceDidDiscoverDescriptorsCallback

Notifies that the peripheral found descriptors for a characteristic.

public typealias AbleDeviceDidDiscoverDescriptorsCallback = ((Result<[AbleDescriptor], Error>) -> Void)

This callback is invoked when your app calls the discoverDescriptors(for:) method. If AbleDevice successfully discovers the descriptors of the specified characteristic, you can access them through the characteristic’s descriptors property. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidDiscoverDescriptorsCallback

AbleDeviceDidDiscoverIncludedServicesCallback

Notifies that discovering included services within the indicated service completed.

public typealias AbleDeviceDidDiscoverIncludedServicesCallback = ((_ ableDevice: AbleDevice, _ service: AbleService?, _ error: Error?)->())

This callback is invoked when your app calls the discoverIncludedServices(_:for:) method. If AbleDevice successfully discovers services, you can access them through the service’s includedServices property. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidDiscoverIncludedServicesCallback

AbleDeviceDidDiscoverServicesCallback

Notifies that AbleDevice service discovery succeeded.

public typealias AbleDeviceDidDiscoverServicesCallback = ((Result<[AbleService], Error>) -> Void)

This callback is invoked when your app calls the discoverServices(_:) method. If AbleDevice successfully discovers services, you can access them through AbleDevice’s services property. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidDiscoverServicesCallback

AbleDeviceDidModifyServicesCallback

Callback used to notify of AbleDevice service change.

public typealias AbleDeviceDidModifyServicesCallback = ((_ ableDevice: AbleDevice, _ invalidatedServices: [AbleService]) -> Void)

Callback is invoked whenever one or more services of AbleDevice change. Services have changed if:

  • AbleDevice removes a service from its database.

  • AbleDevice adds a new service to its database.

  • AbleDevice 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 discoverServices(_:) method to discover any new services that AbleDevice 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 AbleDevice's database.

  • Tag: AbleDeviceDidModifyServicesCallback

AbleDeviceDidReadRSSICallback

Notifies that retrieving the value of AbleDevice’s current Received Signal Strength Indicator (RSSI) succeeded.

public typealias AbleDeviceDidReadRSSICallback = ((_ ableDevice: AbleDevice, _ RSSI: NSNumber, _ error: Error?) -> Void)

This callback is invoked when your app calls the readRSSI() method, while AbleDevice is connected to AbleCentralManager. If successful, the error parameter is nil and the parameter RSSI reports AbleDevice’s signal strength, in decibels. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidReadRSSICallback

AbleDeviceDidUpdateNotificationStateCallback

Notifies that AbleDevice received a request to start or stop providing notifications for a specified characteristic’s value.

public typealias AbleDeviceDidUpdateNotificationStateCallback = ((Result<AbleCharacteristic,Error>) -> Void)

This callback is invoked when your app calls the setNotifyValue(_:for:) method. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidUpdateNotificationStateCallback

AbleDeviceDidUpdateValueForCharacteristicCallback

Notifies that retrieving the specified characteristic’s value succeeded, or that the characteristic’s value changed.

public typealias AbleDeviceDidUpdateValueForCharacteristicCallback = ((Result<AbleCharacteristic, Error>) -> Void)

This callback is invoked when your app calls the readCharacteristic() method. AbleDevice 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 setNotifyValue(:for:). If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidUpdateValueForCharacteristicCallback

AbleDeviceDidUpdateValueForDescriptorCallback

Notifies that retrieving a specified characteristic descriptor’s value succeeded.

public typealias AbleDeviceDidUpdateValueForDescriptorCallback = ((Result<AbleDescriptor, Error>) -> Void)

This callback is invoked when your app calls the readDescriptor(_) method. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidUpdateValueForDescriptorCallback

AbleDeviceDidWriteValueForCharacteristicCallback

Notifies that AbleDevice successfully set a value for the characteristic.

public typealias AbleDeviceDidWriteValueForCharacteristicCallback = ((Result<AbleCharacteristic, Error>) -> Void)

This callback is invoked only when your app calls the writeCharacteristic(_:data:type:) method with the AbleCharacteristicWriteType.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.

  • Tag: AbleDeviceDidWriteValueForCharacteristicCallback

AbleDeviceDidWriteValueForDescriptorCallback

Notifies that AbleDevice successfully set a value for the descriptor.

public typealias AbleDeviceDidWriteValueForDescriptorCallback = ((Result<AbleDescriptor, Error>) -> Void)

This callback is invoked when your app calls the writeDescriptor(:data:) method. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure.

  • Tag: AbleDeviceDidWriteValueForDescriptorCallback

AbleDeviceIsReadyToSendWriteWithoutResponseCallback

Notifies that AbleDevice is again ready to send characteristic updates.

public typealias AbleDeviceIsReadyToSendWriteWithoutResponseCallback = ((_ ableDevice: AbleDevice) -> Void)

AbleDevice calls invokes this callback after a failed call to writeValue(_:for:type:), once AbleDevice is ready to send characteristic value updates.

  • Tag: AbleDeviceIsReadyToSendWriteWithoutResponseCallback

AbleDeviceState

Enum used to define AbleDevice's connection state.

public enum AbleDeviceState

Inheritance

Int

Enumeration Cases

disconnected

AbleDevice is not connected to the central manager.

case disconnected

connecting

AbleDevice is in the process of connecting to the central manager.

case connecting

connected

AbleDevice is connected to the central manager.

case connected

disconnecting

AbleDevice is in the process of disconnecting from the central manager.

case disconnecting

AbleDeviceStorage

public class AbleDeviceStorage: IAbleDeviceStorage

Inheritance

IAbleDeviceStorage

Properties

`default`

let `default`

devices

var devices: Set<AbleDevice>

Methods

find(device:)

public func find(device: AbleDevice) -> AbleDevice?

findBy(name:)

public func findBy(name: String) -> AbleDevice?

findBy(identifier:)

public func findBy(identifier: UUID) -> AbleDevice?

add(device:)

public func add(device: AbleDevice)

remove(device:)

public func remove(device: AbleDevice)

AbleDeviceUpdatedNameCallback

Callback used to notify of AbleDevice name change.

public typealias AbleDeviceUpdatedNameCallback = ((AbleDevice) -> Void)

Callback is invoked whenever AbleDevice’s Generic Access Profile (GAP) device name changes.

  • Tag: AbleDeviceUpdatedNameCallback

AbleGATTServer

Default implementation of IAbleGATTServer. Allows the device to run a local GATT server (i.e, in peripheral mode). Internally uses AbleManager.shared.

@available(iOS 11.0, *) public class AbleGATTServer: NSObject, IAbleGATTServer

Inheritance

CBPeripheralManagerDelegate, IAbleGATTServer, NSObject

Initializers

init(_:)

public required init(_ components: @escaping () -> [AbleGATTServerComponent])

Properties

isOpen

var isOpen = false

Methods

service(uuid:type:_:)

public func service(uuid: AbleUUID, type: AbleServiceType, _ components: () -> [AbleServiceComponent])

remove(service:)

public func remove(service: AbleService)

notifyCharacteristicChanged(_:value:)

public func notifyCharacteristicChanged(_ characteristic: AbleCharacteristic, value: Data)

respond(to:status:)

public func respond(to request: AbleATTRequest, status: AbleGATTServerStatus)

close()

public func close()

peripheralManagerDidUpdateState(_:)

public func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager)

peripheralManager(_:didReceiveRead:)

public func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest)

peripheralManager(_:didReceiveWrite:)

public func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveWrite requests: [CBATTRequest])

peripheralManager(_:central:didSubscribeTo:)

public func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic)

peripheralManager(_:central:didUnsubscribeFrom:)

public func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic)

peripheralManagerDidStartAdvertising(_:error:)

public func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?)

peripheralManager(_:didPublishL2CAPChannel:error:)

public func peripheralManager(_ peripheral: CBPeripheralManager, didPublishL2CAPChannel PSM: CBL2CAPPSM, error: Error?)

peripheralManager(_:didUnpublishL2CAPChannel:error:)

public func peripheralManager(_ peripheral: CBPeripheralManager, didUnpublishL2CAPChannel PSM: CBL2CAPPSM, error: Error?)

peripheralManager(_:didOpen:error:)

@available(iOS 11.0, *) public func peripheralManager(_ peripheral: CBPeripheralManager, didOpen channel: CBL2CAPChannel?, error: Error?)

AbleGATTServerBuilder

Allows for declarative creation of IAbleGATTServer using functionBuilder pattern.

@_functionBuilder public struct AbleGATTServerBuilder
  • Tag: AbleGATTServerBuilder

Methods

buildBlock(_:)

static func buildBlock(_ components: AbleGATTServerComponent) -> [AbleGATTServerComponent]

buildIf(_:)

static func buildIf(_ value: AbleGATTServerComponent?) -> AbleGATTServerComponent

buildEither(first:)

static func buildEither(first: AbleGATTServerComponent) -> AbleGATTServerComponent

buildEither(second:)

static func buildEither(second: AbleGATTServerComponent) -> AbleGATTServerComponent

AbleGATTServerComponent

Something that can be used in [AbleGATTServerBuilder)(#ablegattserverbuilder).

public protocol AbleGATTServerComponent
  • Tag: AbleGATTServerComponent

AbleGATTServerOnConnectionStateChangeCallback

Triggered when a peer subscribes or unsubscribes from the receiving notifications/indications about a characteristic.

public typealias AbleGATTServerOnConnectionStateChangeCallback = (_ server: IAbleGATTServer,
                                                                  _ peer: AblePeer,
                                                                  _ state: AblePeerConnectionState) -> Void
  • Tag: AbleGATTServerOnConnectionStateChangeCallback

AbleGATTServerOnStateChangeCallback

Triggered when an AbleGATTServer's state is changed from open to closed, or vice versa.

public typealias AbleGATTServerOnStateChangeCallback = (_ isOpen: Bool) -> Void
  • Tag: AbleGATTServerOnStateChangeCallback

AbleGATTServerRequestCallback

Triggered when a server receives a request.

public typealias AbleGATTServerRequestCallback = (_ server: IAbleGATTServer, _ request: AbleATTRequest) -> Void
  • Tag: AbleGATTServerRequestCallback

AbleGATTServerStatus

All the possible status codes that can be used with respond(to:status:) method of IAbleGATTServer.

public enum AbleGATTServerStatus

Inheritance

Int

Enumeration Cases

success

case success

invalidHandle

case invalidHandle

readNotPermitted

case readNotPermitted

writeNotPermitted

case writeNotPermitted

invalidPdu

case invalidPdu

insufficientAuthentication

case insufficientAuthentication

requestNotSupported

case requestNotSupported

invalidOffset

case invalidOffset

insufficientAuthorization

case insufficientAuthorization

prepareQueueFull

case prepareQueueFull

attributeNotFound

case attributeNotFound

attributeNotLong

case attributeNotLong

insufficientEncryptionKeySize

case insufficientEncryptionKeySize

invalidAttributeValueLength

case invalidAttributeValueLength

unlikelyError

case unlikelyError

insufficientEncryption

case insufficientEncryption

unsupportedGroupType

case unsupportedGroupType

insufficientResources

case insufficientResources

AbleLib

public class AbleLib

Properties

licenceKey

var licenceKey: String?

AbleLogLevel

public enum AbleLogLevel

Enumeration Cases

info

case info

debug

case debug

error

case error

warning

case warning

data

case data

AbleLogOptionSet

public typealias AbleLogOptionSet = Set<AbleLogLevel>

AbleLogOptions

public enum AbleLogOptions

Enumeration Cases

none

case none

productionBuild

case productionBuild

issues

case issues

debugBuild

case debugBuild

custom

case custom(: AbleLogOptionSet)

full

case full

comm

case comm

AbleLogPrinter

public typealias AbleLogPrinter = (AbleLogLevel, String) -> Void

AbleManager

Manager used to handle central events and peripheral communication.

public class AbleManager: NSObject, IAbleManager
  • Tag: AbleManager

Inheritance

IAbleManager, NSObject

Properties

supportsBackground

var supportsBackground: Bool = false

qualityOfService

var qualityOfService = QualityOfService.DEFAULT

ableCentralState

Returns AbleCentralManagerState value indicating current state of ableCentralManager.

var ableCentralState: AbleCentralManagerState

isAuthorized

var isAuthorized: Bool

isBluetoothOn

Property used to indicate whether or not Bluetooth is powered on.

var isBluetoothOn: Bool
  • Returns

    • Boolean value indicating whether or not Bluetooth is on. true if powered on, false otherwise.

loggingOptions

Property that

var loggingOptions: AbleLogOptions

loggingPrinter

Property that

var loggingPrinter: AbleLogPrinter

shared

Singleton instance of AbleManager.

var shared: AbleManager

If no instance of AbleManager exists creates a new instance and returns it, otherwise uses existing instance.

See:

Methods

checkReady()

Every method that does a root operation should call this method first.

public func checkReady() throws

destroy()

Method used to clear existing singleton instance.

public class func destroy()

initialize(with:using:launchOptions:onRestore:_:)

Method used to initialize ableCentralManager.

public func initialize(with queue: DispatchQueue = .main, using options: [String: Any]? = nil, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil, onRestore: AbleCentralManagerRestoredStateCallback? = nil, _ onCompletion: AbleCentralManagerStateCallback? = nil)

If ableCentralManager is not initialized instructing AbleManager to scan for peripherals will have no effect.

  • Tag: initAbleCentralManager

Parameters

  • queue: The dispatch queue used to dispatch the central role events. Default value is .main.
  • onCompletion: AbleCentralManagerStateCallback which notifies of current manager state once ableCentralManager has been initialized.

setNumberOfRetries(to:)

Method used to set AbleCentralManager's numberOfRetries property.

public func setNumberOfRetries(to value: Int)

If value is less than zero defaults to 3.

setOnAbleCentralManagerStateChangeCallback(with:)

Method used to set AbleCentralManagerStateCallback.

public func setOnAbleCentralManagerStateChangeCallback(with callback: @escaping AbleCentralManagerStateCallback)

In case of AbleCentralManager being used from multiple access points within the app this method can be used to re-set callback which indicated that state change had occurred.

Parameters

comm(with:)

Instantiates a communication with AbleDevice of type IAbleComm.

public func comm(with device: AbleDevice) -> IAbleComm
  • parameters

    • device: Device to coomunicate with.

startScan(with:_:)

Attempts to start scaning for peripherals that are advertising services.

public func startScan(with services: [AbleUUID]? = nil, _ onDiscoveredPeripheral: @escaping AbleCentralDiscoveredPeripheralCallback)

Starts scanning for peripherals that are advertising any of the services listed in services. Although strongly discouraged, if services is nil all discovered peripherals will be returned. Applications that have specified the bluetooth-central background mode are allowed to scan while backgrounded, with two caveats: the scan must specify one or more service types in services, and the CBCentralManagerScanOptionAllowDuplicatesKey scan option will be ignored.

  • f central is not initialized AbleCentralDiscoveredPeripheralCallback will return an error.

  • If use of Bluetooth has not been authorized by user AbleCentralDiscoveredPeripheralCallback will notify of denied permission with an error.

  • If central state is not .poweredOn a call to AbleCentralDiscoveredPeripheralCallback will be made to notify of current central state.

See:

Parameters

  • services: A list of AbleUUID objects representing the service(s) to scan for.
  • onDiscoveredPeripheral: AbleCentralDiscoveredPeripheralCallback which is called each time a new peripheral device has been discovered or if an error has occurred.

stopScan()

Attempts to stop central from further scanning for peripherals.

public func stopScan()

If central is currently scanning for peripherls scanning will be stopped.

scan(for:with:_:)

public func scan(for interval: TimeInterval = 10.0, with services: [AbleUUID]? = nil, _ onDiscoveredPeripherals: @escaping AbleCentralDiscoveredPeripheralsCallback)

scanForStoredDevices(onDiscoveredPeripherals:)

public func scanForStoredDevices(onDiscoveredPeripherals: @escaping AbleCentralDiscoveredPeripheralsCallback)

connect(to:with:callback:)

public func connect(to device: AbleDevice, with options: [String : Any]?, callback: @escaping AbleCentralConnectionCallback)

disconnect(from:with:)

public func disconnect(from device: AbleDevice, with completion: @escaping AbleCentralDisconnectedPeripheralCallback)

openGATTServer(_:)

public func openGATTServer(_ components: @escaping () -> [AbleGATTServerComponent]) -> IAbleGATTServer

startAdvertising(data:callback:)

public func startAdvertising(data: AbleAdverisementData, callback: @escaping (Result<Void, Error>) -> Void)

stopAdvertising()

public func stopAdvertising()

AbleMutableDescriptor

public class AbleMutableDescriptor: AbleDescriptor

Inheritance

AbleDescriptor

Initializers

init(type:value:)

public init(type UUID: AbleUUID, value: Any?)

AbleMutableService

public class AbleMutableService: AbleService

Inheritance

AbleService

AbleOnAnyRead

Add to AbleGATTServerBuilder to receive updates when a read request for any characteristic, except those that are already specified via AbleOnRead.

public struct AbleOnAnyRead: AbleGATTServerComponent

Inheritance

AbleGATTServerComponent

Initializers

init(_:)

public init(_ callback: @escaping AbleGATTServerRequestCallback)

AbleOnAnyWrite

Add to AbleGATTServerBuilder to receive updates when a write request for any characteristic, except those that are already specified via AbleOnWrite.

public struct AbleOnAnyWrite: AbleGATTServerComponent

Inheritance

AbleGATTServerComponent

Initializers

init(_:)

public init(_ callback: @escaping AbleGATTServerRequestCallback)

AbleOnConnectionStateChange

Add to AbleGATTServerBuilder to receive updates via AbleGATTServerOnConnectionStateChangeCallback.

public struct AbleOnConnectionStateChange: AbleGATTServerComponent

Inheritance

AbleGATTServerComponent

Initializers

init(_:)

public init(_ callback: @escaping AbleGATTServerOnConnectionStateChangeCallback)

AbleOnRead

Add to AbleGATTServerBuilder to receive updates when a read request comes in for the provided characteristics.

public struct AbleOnRead: AbleGATTServerComponent
  • Tag: AbleOnRead

Inheritance

AbleGATTServerComponent

Initializers

init(_:_:)

public init(_ characteristics: [AbleUUID], _ callback: @escaping AbleGATTServerRequestCallback)

AbleOnStateChange

Add to AbleGATTServerBuilder to receive updates via AbleGATTServerOnStateChangeCallback.

public struct AbleOnStateChange: AbleGATTServerComponent

Inheritance

AbleGATTServerComponent

Initializers

init(_:)

public init(_ callback: @escaping AbleGATTServerOnStateChangeCallback)

AbleOnWrite

Add to AbleGATTServerBuilder to receive updates when a write request comes in for the provided characteristics.

public struct AbleOnWrite: AbleGATTServerComponent
  • Tag: AbleOnWrite

Inheritance

AbleGATTServerComponent

Initializers

init(_:_:)

public init(_ characteristics: [AbleUUID], _ callback: @escaping AbleGATTServerRequestCallback)

AblePSM

An alias for representation of PSM of an L2CAP channel. See:

public struct AblePSM: Hashable

Inheritance

Hashable

Initializers

init(value:)

public init(value: CBL2CAPPSM)

init(data:)

public init(data: Data)

Properties

value

let value: Int

AblePeer

Represents a peer device connected to a local GATT server.

public class AblePeer: Hashable
  • Tag: AblePeer

Inheritance

Hashable

Properties

uuid

var uuid: AbleUUID

Methods

==(lhs:rhs:)

public static func ==(lhs: AblePeer, rhs: AblePeer) -> Bool

hash(into:)

public func hash(into hasher: inout Hasher)

AblePeerConnectionState

public enum AblePeerConnectionState

Enumeration Cases

unsubscribed

case unsubscribed(: AbleCharacteristic)

subscribed

case subscribed(: AbleCharacteristic)

AblePeripheralInfo

Struct used as callback parameter whenever AbleCentralManager discovers a new peripheral.

public struct AblePeripheralInfo: Hashable

Contains information on peripheral device, said device's advertisementData, and device's current received signal strength indicator.

  • Tag: AblePeripheralInfo

Inheritance

Hashable

Properties

device

let device: AbleDevice

advertisementData

let advertisementData: [String: Any]

rssi

let rssi: NSNumber

Methods

==(lhs:rhs:)

public static func ==(lhs: AblePeripheralInfo, rhs: AblePeripheralInfo) -> Bool

hash(into:)

public func hash(into hasher: inout Hasher)

AbleServerSocketAcceptCallback

public typealias AbleServerSocketAcceptCallback = (Result<IAbleSocketConnection, AbleSocketError>) -> Void

AbleServerSocketCloseCallback

public typealias AbleServerSocketCloseCallback = (Result<Void, AbleSocketError>) -> Void

AbleServerSocketOpenCallback

public typealias AbleServerSocketOpenCallback<SocketData> = (Result<SocketData, AbleSocketError>) -> Void

AbleService

public class AbleService: NSObject, AbleGATTServerComponent

Inheritance

AbleGATTServerComponent, NSObject

Initializers

init(uuid:type:_:)

public init(uuid: AbleUUID, type: AbleServiceType, _ components: () -> [AbleServiceComponent])

Properties

uuid

var uuid: AbleUUID

ableDevice

var ableDevice: AbleDevice?

isPrimary

var isPrimary: Bool

includedServices

var includedServices: [AbleService]?

characteristics

var characteristics: [AbleCharacteristic]?

AbleServiceBuilder

Allows for declarative creation of AbleService using functionBuilder pattern.

@_functionBuilder public struct AbleServiceBuilder
  • Tag: AbleServiceBuilder

Methods

buildBlock(_:)

static func buildBlock(_ components: AbleServiceComponent) -> [AbleServiceComponent]

buildIf(_:)

static func buildIf(_ value: AbleServiceComponent?) -> AbleServiceComponent

buildEither(first:)

static func buildEither(first: AbleServiceComponent) -> AbleServiceComponent

buildEither(second:)

static func buildEither(second: AbleServiceComponent) -> AbleServiceComponent

AbleServiceComponent

Something that can be used in [AbleServiceBuilder)(#ableservicebuilder).

public protocol AbleServiceComponent
  • Tag: AbleServiceComponent

AbleServiceType

public enum AbleServiceType

Enumeration Cases

secondary

case secondary

primary

case primary

AbleSocket

@available(iOS 11.0, *) public protocol AbleSocket

Requirements

connect(to:psm:callback:)

func connect(to device: AbleDevice, psm: AblePSM, callback: AbleSocketConnectionCallback?)

isConnected

var isConnected: Bool

onSend

var onSend: AbleSocketDataCallback?

onReceive

var onReceive: AbleSocketDataCallback?

send(data:)

func send(data: Data)

close(_:)

func close(_ callback: AbleSocketConnectionCallback?)

AbleSocketConnectionCallback

Callback indicating a socket state change (on connect or close).

public typealias AbleSocketConnectionCallback = (Result<IAbleSocketConnection, Error>) -> Void
  • Tag: AbleSocketConnectionCallback

AbleSocketData

@available(iOS 11.0, *) public struct AbleSocketData

Properties

socket

let socket: AbleSocket

data

let data: Data

AbleSocketDataCallback

Callback indicating data transfer in a socket.

public typealias AbleSocketDataCallback = (Result<Data, Error>) -> Void
  • Tag: AbleSocketDataCallback

AbleSocketError

Possible errors that can happen with socket communication.

public enum AbleSocketError

Inheritance

Error

Enumeration Cases

notReady

case notReady

illegalState

case illegalState(reason: String)

invalidData

case invalidData

opening

case opening(error: Error)

closing

case closing(error: Error)

Properties

debugDescription

var debugDescription: String

AbleUUID

Class used to handle all UUID based operations such as scanning for peripherals with services.

public class AbleUUID: NSObject
  • Tag: AbleUUID

Inheritance

NSObject

Initializers

init(with:)

Creates AbleUUID object from a 16-, 32-, or 128-bit UUID String.

public init(with uuidString: String)

Specify 128-bit UUIDs as a string of hexadecimal digits punctuated by hyphens. Specify 16- or 32-bit UUIDs as a string of 4 or 8 hexadecimal digits, respectively.

  • Returns a new AbleUUID object for specified UUID String.

Parameters

  • uuidString: 16-, 32-, or 128-bit UUID String (e.g. "1804", "1804AD02", "68753A44-4D6F-1226-9C60-0050E4C00067").

init(with:)

Creates AbleUUID object from a 16-, 32-, or 128-bit UUID data container.

public init(with data: Data)

This method is useful when handling the UUID of a Bluetooth attribute in raw bytes.

  • Returns a new AbleUUID object for the specified UUID data.

Parameters

  • data: Data containing a 16-, 32-, or 128-bit UUID.

init(with:)

Creates AbleUUID object from a Foundation UUID object.

public init(with nsuuid: UUID)
  • Returns a new AbleUUID object for the specified UUID.

Parameters

  • nsuuid: A UUID represented by an NSUUID object.

Properties

data

The data of the UUID.

var data: Data

uuidString

UUID represented as a String.

var uuidString: String

uuid

var uuid: UUID

Methods

==(lhs:rhs:)

public static func ==(lhs: AbleUUID, rhs: AbleUUID) -> Bool

isEqual(_:)

public override func isEqual(_ object: Any?) -> Bool

CharacteristicAbleCommActions

public class CharacteristicAbleCommActions: AbleCommActions

Inheritance

AbleCommActions

Methods

handle(handler:)

Allows you to execute a custom action with the Characteristic currently used by the chain.

public func handle(handler: @escaping (AbleCharacteristic) throws -> Void) -> Self

Parameters

  • handler: The custom block that handles the characteristic.

discoverDescriptors(_:)

Discovers descriptors of the current characteristic. See AbleComm,

public func discoverDescriptors(_ mapper: (([AbleDescriptor]) throws -> AbleDescriptor)? = nil) -> DescriptorAbleCommActions

Parameters

  • mapper: selects a single descriptor from the list to be used by the chain. If this parameter isn't provided, the chain will automatically select the first descriptor, if it exists, or throw an exception otherwise.

readCharacteristic(_:)

Reads the current characteristic and handles the response . See AbleComm.

public func readCharacteristic(_ handler: @escaping (AbleCharacteristic) throws -> Void) -> Self

Parameters

  • handler: block that's executed when the peripheral responds to characteristic read.

writeCharacteristic(_:)

Writes the current characteristic and handles the response . See AbleComm.

public func writeCharacteristic(_ handler: @escaping () -> (Data, AbleCharacteristicWriteType)) -> Self

Parameters

  • handler: block that's executed when the peripheral responds to characteristic write.

setNotifyValue(_:onStateChanged:)

Sets if the current characteristic should notify or indicate . See AbleComm.

public func setNotifyValue(_ enabled: Bool, onStateChanged: ((AbleCharacteristic) throws -> Void)? = nil) -> Self

Parameters

  • enabled: if true, the characteristic will notify. Otherwise, it will indicate.
  • onStateChanged: called when the characteristic notification state is changed.

DescriptorAbleCommActions

public class DescriptorAbleCommActions: AbleCommActions

Inheritance

AbleCommActions

Methods

handle(handler:)

Allows you to execute a custom action with the Descriptor currently used by the chain.

public func handle(handler: @escaping (AbleDescriptor) throws -> Void) -> Self

Parameters

  • handler: The custom block that handles the descriptor.

readDescriptor(_:)

Reads the current descriptor and handles the response . See AbleComm.

public func readDescriptor(_ handler: @escaping (AbleDescriptor) throws -> Void) -> Self

Parameters

  • handler: block that's executed when the peripheral responds to descriptor read.

writeDescriptor(_:)

Writes the current descriptor and handles the response . See AbleComm.

public func writeDescriptor(_ handler: @escaping () -> Data) -> Self

Parameters

  • handler: block that's executed when the peripheral responds to characteristic descriptor.

EmptyAbleGATTServerComponent

Used to allow for buildIf in the GATT server builder.

public struct EmptyAbleGATTServerComponent: AbleGATTServerComponent

Inheritance

AbleGATTServerComponent

EmptyAbleServiceComponent

Used to allow for buildIf in the AbleService builder.

public struct EmptyAbleServiceComponent: AbleServiceComponent

Inheritance

AbleServiceComponent

IAbleComm

Abstract interface for communicating with a Bluetooth peripheral.

public protocol IAbleComm
  • Tag: IAbleComm

Requirements

manager

var manager: IAbleManager

onDiscoverServices(_:)

func onDiscoverServices(_ callback: @escaping AbleDeviceDidDiscoverServicesCallback) -> Self

onDiscoverCharacteristics(_:)

func onDiscoverCharacteristics(_ callback: @escaping AbleDeviceDidDiscoverCharacteristicsCallback) -> Self

onDiscoverDescriptors(_:)

func onDiscoverDescriptors(_ callback: @escaping AbleDeviceDidDiscoverDescriptorsCallback) -> Self

onDescriptorRead(_:)

func onDescriptorRead(_ callback: @escaping AbleDeviceDidUpdateValueForDescriptorCallback) -> Self

onDescriptorWrite(_:)

func onDescriptorWrite(_ callback: @escaping AbleDeviceDidWriteValueForDescriptorCallback) -> Self

onCharacteristicUpdateValue(_:)

func onCharacteristicUpdateValue(_ callback: @escaping AbleDeviceDidUpdateValueForCharacteristicCallback) -> Self

onCharacteristicWrite(_:)

func onCharacteristicWrite(_ callback: @escaping AbleDeviceDidWriteValueForCharacteristicCallback) -> Self

setAbleDeviceDidUpdateNameCallback(_:)

func setAbleDeviceDidUpdateNameCallback(_ callback: @escaping AbleDeviceUpdatedNameCallback)

readConnectedDeviceRSSI(with:)

func readConnectedDeviceRSSI(with completion: @escaping AbleDeviceDidReadRSSICallback)

connectWithoutScan(with:callback:)

func connectWithoutScan(with options: [String: Any]?, callback: @escaping AbleCentralConnectionCallback)

connect(with:callback:)

func connect(with options: [String: Any]?, callback: @escaping AbleCentralConnectionCallback)

disconnect(with:)

func disconnect(with completion: @escaping AbleCentralDisconnectedPeripheralCallback)

setAbleDeviceDidModifyServicesCallback(_:)

func setAbleDeviceDidModifyServicesCallback(_ callback: @escaping AbleDeviceDidModifyServicesCallback)

discoverServices(_:with:)

func discoverServices(_ serviceUUIDs: [AbleUUID]?, with completion: @escaping AbleDeviceDidDiscoverServicesCallback)

discoverServices(_:)

func discoverServices(_ serviceUUIDs: [AbleUUID]?)

discoverConnectedDeviceIncludedServices(_:for:with:)

func discoverConnectedDeviceIncludedServices(_ serviceUUIDs: [AbleUUID]?, for service: AbleService, with completion: @escaping AbleDeviceDidDiscoverIncludedServicesCallback)

discoverCharacteristics(_:for:with:)

func discoverCharacteristics(_ characteristicUUIDs: [AbleUUID]?, for ableService: AbleService, with completion: @escaping AbleDeviceDidDiscoverCharacteristicsCallback)

discoverCharacteristics(_:for:)

func discoverCharacteristics(_ characteristicUUIDs: [AbleUUID]?, for ableService: AbleService)

discoverDescriptors(for:with:)

func discoverDescriptors(for ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidDiscoverDescriptorsCallback)

discoverDescriptors(for:)

func discoverDescriptors(for ableCharacteristic: AbleCharacteristic)

readCharacteristic(_:with:)

func readCharacteristic(_ ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidUpdateValueForCharacteristicCallback)

readCharacteristic(_:)

func readCharacteristic(_ ableCharacteristic: AbleCharacteristic)

readDescriptor(_:with:)

func readDescriptor(_ ableDescriptor: AbleDescriptor, with completion: @escaping AbleDeviceDidUpdateValueForDescriptorCallback)

readDescriptor(_:)

func readDescriptor(_ ableDescriptor: AbleDescriptor)

writeDescriptor(_:data:with:)

func writeDescriptor(_ ableDescriptor: AbleDescriptor, data: Data, with completion: @escaping AbleDeviceDidWriteValueForDescriptorCallback)

writeDescriptor(_:data:)

func writeDescriptor(_ ableDescriptor: AbleDescriptor, data: Data)

writeCharacteristic(_:data:type:with:)

func writeCharacteristic(_ ableCharacteristic: AbleCharacteristic, data: Data, type: AbleCharacteristicWriteType, with completion: @escaping AbleDeviceDidWriteValueForCharacteristicCallback)

writeCharacteristic(_:data:type:)

func writeCharacteristic(_ ableCharacteristic: AbleCharacteristic, data: Data, type: AbleCharacteristicWriteType)

setNotifyValue(_:for:with:)

func setNotifyValue(_ enabled: Bool, for ableCharacteristic: AbleCharacteristic, with completion: @escaping AbleDeviceDidUpdateNotificationStateCallback)

maximumWriteValueLength(for:)

func maximumWriteValueLength(for writeType: AbleCharacteristicWriteType) -> Int?

actions

var actions: AbleCommActions

IAbleDeviceStorage

public protocol IAbleDeviceStorage

Requirements

devices

var devices: Set<AbleDevice>

find(device:)

func find(device: AbleDevice) -> AbleDevice?

findBy(name:)

func findBy(name: String) -> AbleDevice?

findBy(identifier:)

func findBy(identifier: UUID) -> AbleDevice?

add(device:)

func add(device: AbleDevice)

remove(device:)

func remove(device: AbleDevice)

IAbleGATTServer

Represents a GATT server running locally, allowing the device to operate in peripheral mode (i.e, behave as if it's a BLE peripheral, akin to an AbleDevice.

public protocol IAbleGATTServer
  • Tag: IAbleGATTServer

Requirements

isOpen

Returns true if the server is currently open and able to handle incoming requests.

var isOpen: Bool

service(uuid:type:_:)

Adds a service to the server with the providedAbleUUID and its builder. See guides for more examples.

func service(uuid: AbleUUID, type: AbleServiceType, _ components: () -> [AbleServiceComponent])

remove(service:)

Removes the provided service from the server.

func remove(service: AbleService)

notifyCharacteristicChanged(_:value:)

Notifies subscribed devices that a characteristic has changed, and sets its new value.

func notifyCharacteristicChanged(_ characteristic: AbleCharacteristic, value: Data)

Parameters

  • characteristic: AbleCharacteristic whose value is chaning.
  • value: The new value to set to characteristic.

respond(to:status:)

Responds to a remote request with the given status.

func respond(to request: AbleATTRequest, status: AbleGATTServerStatus)

Parameters

  • request: The request to respond to.
  • status: Response status.

close()

Closes the server instance. Once closed, a server needs to be reinstantiated (i.e, the closing operation is permanent for this instance).

func close()

IAbleManager

public protocol IAbleManager

Requirements

supportsBackground

var supportsBackground: Bool

qualityOfService

var qualityOfService: QualityOfService

ableCentralState

var ableCentralState: AbleCentralManagerState

isAuthorized

var isAuthorized: Bool

isBluetoothOn

var isBluetoothOn: Bool

loggingOptions

var loggingOptions: AbleLogOptions

loggingPrinter

var loggingPrinter: AbleLogPrinter

checkReady()

func checkReady() throws

initialize(with:using:launchOptions:onRestore:_:)

func initialize(with queue: DispatchQueue, using options: [String: Any]?, launchOptions: [UIApplication.LaunchOptionsKey: Any]?, onRestore: AbleCentralManagerRestoredStateCallback?, _ onCompletion: AbleCentralManagerStateCallback?)

setNumberOfRetries(to:)

func setNumberOfRetries(to value: Int)

setOnAbleCentralManagerStateChangeCallback(with:)

func setOnAbleCentralManagerStateChangeCallback(with callback: @escaping AbleCentralManagerStateCallback)

comm(with:)

func comm(with device: AbleDevice) -> IAbleComm

startScan(with:_:)

func startScan(with services: [AbleUUID]?, _ onDiscoveredPeripheral: @escaping AbleCentralDiscoveredPeripheralCallback)

stopScan()

func stopScan()

scan(for:with:_:)

func scan(for interval: TimeInterval, with services: [AbleUUID]?, _ onDiscoveredPeripherals: @escaping AbleCentralDiscoveredPeripheralsCallback)

scanForStoredDevices(onDiscoveredPeripherals:)

func scanForStoredDevices(onDiscoveredPeripherals: @escaping AbleCentralDiscoveredPeripheralsCallback)

connect(to:with:callback:)

func connect(to device: AbleDevice, with options: [String: Any]?, callback: @escaping AbleCentralConnectionCallback)

disconnect(from:with:)

func disconnect(from device: AbleDevice, with completion: @escaping AbleCentralDisconnectedPeripheralCallback)

openGATTServer(_:)

Starts an IAbleGATTServer with the provided builder. If a GATT server is already running, nothing happens.

func openGATTServer(_ components: @escaping () -> [AbleGATTServerComponent]) -> IAbleGATTServer

Returns

  • If a GATT server is already open, return that instance. Otherwise, returns the new server instance that has been set up and started.

startAdvertising(data:callback:)

Starts the device advertising when running in peripheral mode. Requires an open IAbleGATTServer.

func startAdvertising(data: AbleAdverisementData, callback: @escaping (Result<Void, Error>) -> Void)

stopAdvertising()

Stops the device from advertising. Requires an open IAbleGATTServer.

func stopAdvertising()

IAbleServerSocket

A server socket operates a channel and allows other client sockets to connect and use for peer-to-peer communication with this device. Usage requires an open IAbleGATTServer.

public protocol IAbleServerSocket
  • Tag: IAbleServerSocket

Requirements

isSecure

If this socket operates a secure channel or not.

var isSecure: Bool

open(callback:)

Opens a new channel that is managed by this server socket.

func open(callback: @escaping AbleServerSocketOpenCallback<SocketData>)

Parameters

  • callback: Invoked with SocketData when the server socket is successfully opened, or when an error occurs.

accept(callback:)

Indicates that this server socket is ready to accept incoming connections from client sockets. Sets the callback that's invoked when a connection is set.

func accept(callback: @escaping AbleServerSocketAcceptCallback)

Parameters

  • callback: Invoked whenever a connection is established, or when an error occurs.

stopAccepting()

Tells the server socket to stop accepting invoking connection requests.

func stopAccepting()

close(callback:)

Closes the socket and its associated channel. Once closed, the server socket can't be used until opened again.

func close(callback: @escaping AbleServerSocketCloseCallback)

Parameters

  • callback: Invoked when the server socket is closed, or when an error occurs.

IAbleSocket

Represents a bi-directional Bluetooth socket that allows for peer-to-peer BLE communication.

public protocol IAbleSocket
  • Tag: IAbleSocket

Requirements

isSecure

If the socket communication channel is secure.

var isSecure: Bool

device

AbleDevice at the other side of the socket.

var device: AbleDevice

isConnected

If the socket is open.

var isConnected: Bool

connect(callback:)

Connects to the peer AbleDevice.

func connect(callback: AbleSocketConnectionCallback?)

Parameters

connection

The connection you can use to send and receive data. Will be set after connect is called, and nil after close is called.

var connection: IAbleSocketConnection?

IAbleSocketConnection

Represents a bi-directional communication channel that can be used to transfer data between a server socket and a client socket.

public protocol IAbleSocketConnection: class
  • Tag: IAbleSocketConnection

Inheritance

class

Requirements

onSend

Callback that's invoked when this device sends data to the peer.

var onSend: AbleSocketDataCallback?

onReceive

Callback that's invoked when this device receives data from the peer.

var onReceive: AbleSocketDataCallback?

send(data:)

Sends bytes to peer via the socket.

func send(data: Data)

Parameters

  • data: Data to send.

close(_:)

Disconnects from the peer and closes the connection.

func close(_ callback: AbleSocketConnectionCallback)

Parameters

IL2CAPSocket

Represents an IAbleSocket that uses an L2CAP channel to communicate.

public protocol IL2CAPSocket: IAbleSocket
  • Tag: IL2CAPSocket

Inheritance

IAbleSocket

Requirements

psm

PSM of the L2CAP channel associated with this socket.

var psm: AblePSM

L2CAPServerSocket

A IAbleServerSocket implementation that operates on an L2CAP channel. Internally uses AbleManager.shared.

@available(iOS 11.0, *) public class L2CAPServerSocket: IAbleServerSocket
  • Tag: IAbleServerSocket

Inheritance

IAbleServerSocket

Initializers

init(secure:)

public init(secure: Bool)

Properties

isSecure

var isSecure: Bool

psm

var psm: AblePSM

Methods

open(callback:)

public func open(callback: @escaping AbleServerSocketOpenCallback<AblePSM>)

accept(callback:)

public func accept(callback: @escaping AbleServerSocketAcceptCallback)

stopAccepting()

public func stopAccepting()

close(callback:)

public func close(callback: @escaping AbleServerSocketCloseCallback)

L2CAPSocket

Default implementation of IL2capSocket.

@available(iOS 11.0, *) public class L2CAPSocket: IL2CAPSocket

Inheritance

IL2CAPSocket

Initializers

init(secure:device:psm:)

public init(secure: Bool, device: AbleDevice, psm: AblePSM)

Properties

isSecure

var isSecure: Bool

device

var device: AbleDevice

psm

var psm: AblePSM

connection

var connection: IAbleSocketConnection?

isConnected

var isConnected: Bool = false

Methods

connect(callback:)

public func connect(callback: AbleSocketConnectionCallback?)

LicenceUtil

public class LicenceUtil

Methods

checkLicence(onSuccess:)

public static func checkLicence(onSuccess: @escaping () -> ())

QualityOfService

Defines quality of service for AbleManager.

public struct QualityOfService: Equatable

Inheritance

Equatable

Properties

LOW_ENERGY

Offers shortest and farthest spaced scans with least reliability, but is best at conserving battery life

let LOW_ENERGY

DEFAULT

Represents a nice balance between battery conservation and effectiveness of bluetooth actions.

let DEFAULT

INTENSIVE

Scans often and is very efficient, but can be draining on the battery.

let INTENSIVE

Methods

==(lhs:rhs:)

public static func ==(lhs: QualityOfService, rhs: QualityOfService) -> Bool

ServiceAbleCommActions

public class ServiceAbleCommActions: AbleCommActions

Inheritance

AbleCommActions

Methods

handle(handler:)

Allows you to execute a custom action with the Service currently used by the chain.

public func handle(handler: @escaping (AbleService) throws -> Void) -> Self

Parameters

  • handler: The custom block that handles the service.

discoverCharacteristics(_:mapper:)

Discovers characteristics of the current service. See AbleComm,

public func discoverCharacteristics(_ uuids: [AbleUUID]? = nil, mapper: (([AbleCharacteristic]) throws -> AbleCharacteristic)? = nil) -> CharacteristicAbleCommActions

Parameters

  • mapper: selects a single characteristic from the list to be used by the chain. If this parameter isn't provided, the chain will automatically select the first characteristic, if it exists, or throw an exception otherwise.