Peripheral
public class Peripheral
extension Peripheral: Equatable
Peripheral is a class implementing ReactiveX API which wraps all Core Bluetooth functions allowing to talk to peripheral like discovering characteristics, services and all of the read/write calls.
-
Intance of CentralManager which is used to the bluetooth communication
Declaration
Swift
public unowned let manager: CentralManager
-
Implementation of peripheral
Declaration
Swift
public let peripheral: CBPeripheral
-
Attaches RxBluetoothKit delegate to CBPeripheral. This method is useful in cases when delegate of CBPeripheral was reassigned outside of RxBluetoothKit library (e.g. CBPeripheral was used in some other library or used in non-reactive way)
Declaration
Swift
public func attach()
-
Value indicating if peripheral is currently in connected state.
Declaration
Swift
public var isConnected: Bool { get }
-
Current state of
Peripheral
instance described by CBPeripheralState.Declaration
Swift
public var state: CBPeripheralState { get }
Return Value
Current state of
Peripheral
asCBPeripheralState
. -
Current name of
Peripheral
instance. Analogous to name ofCBPeripheral
.Declaration
Swift
public var name: String? { get }
-
Unique identifier of
Peripheral
instance. Assigned once peripheral is discovered by the system.Declaration
Swift
public var identifier: UUID { get }
-
YES if the remote device has space to send a write without response. If this value is NO, the value will be set to YES after the current writes have been flushed, and
peripheralIsReadyToSendWriteWithoutResponse:
will be called.Declaration
Swift
public var canSendWriteWithoutResponse: Bool { get }
-
Continuous value indicating if peripheral is in connected state. This is continuous value, which emits
.next
whenever state change occursObservable can ends with following errors:
Declaration
Swift
public func observeConnection() -> Observable<Bool>
-
Establishes connection with a given
Peripheral
. For more information look intoCentralManager.establishConnection(with:options:)
because this method calls it directly.Observable can ends with following errors:
BluetoothError.peripheralIsAlreadyObservingConnection
BluetoothError.peripheralConnectionFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func establishConnection(options: [String : Any]? = nil) -> Observable<Peripheral>
Parameters
options
Dictionary to customise the behaviour of connection.
Return Value
Observable
which emitsnext
event after connection is established.
-
Triggers discover of specified services of peripheral. If the servicesUUIDs parameter is nil, all the available services of the peripheral are returned; setting the parameter to nil is considerably slower and is not recommended. If all of the specified services are already discovered - these are returned without doing any underlying Bluetooth operations.
Observable can ends with following errors:
BluetoothError.servicesDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func discoverServices(_ serviceUUIDs: [CBUUID]?) -> Single<[Service]>
Parameters
serviceUUIDs
Return Value
Single
that emitsnext
with array ofService
instances, once they’re discovered. -
Function that triggers included services discovery for specified services. Discovery is called after subscribtion to
Observable
is made. If all of the specified included services are already discovered - these are returned without doing any underlying Bluetooth operations.Observable can ends with following errors:
BluetoothError.includedServicesDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Parameters
includedServiceUUIDs
Identifiers of included services that should be discovered. If
nil
- all of the included services will be discovered. If you’ll pass empty array - none of them will be discovered.service
Service of which included services should be discovered.
Return Value
Single
that emitsnext
with array ofService
instances, once they’re discovered.
-
Function that triggers characteristics discovery for specified Services and identifiers. Discovery is called after subscribtion to
Observable
is made. If all of the specified characteristics are already discovered - these are returned without doing any underlying Bluetooth operations.Observable can ends with following errors:
BluetoothError.characteristicsDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func discoverCharacteristics(_ characteristicUUIDs: [CBUUID]?, for service: Service) -> Single<[Characteristic]>
Parameters
characteristicUUIDs
Identifiers of characteristics that should be discovered. If
nil
- all of the characteristics will be discovered. If you’ll pass empty array - none of them will be discovered.service
Service of which characteristics should be discovered.
Return Value
Single
that emitsnext
with array ofCharacteristic
instances, once they’re discovered. -
Function that allow to observe writes that happened for characteristic.
Observable can ends with following errors:
BluetoothError.characteristicWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeWrite(for characteristic: Characteristic? = nil) -> Observable<Characteristic>
Parameters
characteristic
Optional
Characteristic
of which value changes should be observed. When not specified it will observe for anyCharacteristic
.Return Value
Observable that emits
next
withCharacteristic
instance every time when write has happened. It’s infinite stream, so.complete
is never called. -
The maximum amount of data, in bytes, that can be sent to a characteristic in a single write.
Seealso
writeValue(_:for:type:)
Declaration
Swift
@available(OSX 10.12, iOS 9.0, *) public func maximumWriteValueLength(for type: CBCharacteristicWriteType) -> Int
Parameters
type
Type of write operation. Possible values:
.withResponse
,.withoutResponse
-
Function that triggers write of data to characteristic. Write is called after subscribtion to
Observable
is made. Behavior of this function strongly depends on CBCharacteristicWriteType, so be sure to check this out before usage of the method.Behavior is following:
withResponse
- Observable emitsnext
withCharacteristic
instance write was confirmed without any errors. Immediately after thatcomplete
is called. If any problem has happened, errors are emitted.withoutResponse
- Observable emitsnext
withCharacteristic
instance once write was called. Immediately after that.complete
is called. Result of this call is not checked, so as a user you are not sure if everything completed successfully. Errors are not emitted. It ensures that peripheral is ready to write without response by listening to the proper delegate method
Observable can ends with following errors:
BluetoothError.characteristicWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func writeValue(_ data: Data, for characteristic: Characteristic, type: CBCharacteristicWriteType, canSendWriteWithoutResponseCheckEnabled: Bool = true) -> Single<Characteristic>
Parameters
data
Data that’ll be written to
Characteristic
instancecharacteristic
Characteristic
instance to write value to.type
Type of write operation. Possible values:
.withResponse
,.withoutResponse
canSendWriteWithoutResponseCheckEnabled
check if canSendWriteWithoutResponse should be enabled. Done because of internal MacOS bug.
Return Value
Observable that emission depends on
CBCharacteristicWriteType
passed to the function call. -
Function that allow to observe value updates for
Characteristic
instance.Observable can ends with following errors:
BluetoothError.characteristicReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdate(for characteristic: Characteristic? = nil) -> Observable<Characteristic>
Parameters
characteristic
Optional
Characteristic
of which value changes should be observed. When not specified it will observe for anyCharacteristic
.Return Value
Observable that emits
next
withCharacteristic
instance every time when value has changed. It’s infinite stream, so.complete
is never called. -
Function that triggers read of current value of the
Characteristic
instance. Read is called after subscription toObservable
is made.Observable can ends with following errors:
BluetoothError.characteristicReadFailed
Declaration
Swift
public func readValue(for characteristic: Characteristic) -> Single<Characteristic>
Parameters
characteristic
Characteristic
to read value fromReturn Value
Single
which emitsnext
with given characteristic when value is ready to read. -
Setup characteristic notification in order to receive callbacks when given characteristic has been changed. Returned observable will emit
Characteristic
on every notification change. It is possible to setup more observables for the same characteristic and the lifecycle of the notification will be shared among them.Notification is automaticaly unregistered once this observable is unsubscribed
This is infinite stream of values.
Observable can ends with following errors:
BluetoothError.characteristicReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdateAndSetNotification(for characteristic: Characteristic) -> Observable<Characteristic>
Parameters
characteristic
Characteristic
for notification setup.Return Value
Observable
emittingCharacteristic
when given characteristic has been changed. -
Use this function in order to know the exact time, when isNotyfing value has changed on a Characteristic.
Observable can ends with following errors:
BluetoothError.characteristicSetNotifyValueFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeNotifyValue(for characteristic: Characteristic) -> Observable<Characteristic>
Parameters
characteristic
Characteristic
which you observe for isNotyfing changes.Return Value
Observable
emittingCharacteristic
when given characteristic has changed it’s isNoytfing value.
-
Function that triggers descriptors discovery for characteristic If all of the descriptors are already discovered - these are returned without doing any underlying Bluetooth operations.
Observable can ends with following errors:
BluetoothError.descriptorsDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func discoverDescriptors(for characteristic: Characteristic) -> Single<[Descriptor]>
Parameters
characteristic
Characteristic
instance for which descriptors should be discovered.Return Value
Single
that emitsnext
with array ofDescriptor
instances, once they’re discovered. -
Function that allow to observe writes that happened for descriptor.
Observable can ends with following errors:
BluetoothError.descriptorWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeWrite(for descriptor: Descriptor? = nil) -> Observable<Descriptor>
Parameters
descriptor
Optional
Descriptor
of which value changes should be observed. When not specified it will observe for anyDescriptor
.Return Value
Observable that emits
next
withDescriptor
instance every time when write has happened. It’s infinite stream, so.complete
is never called. -
Function that allow to observe value updates for
Descriptor
instance.Observable can ends with following errors:
BluetoothError.descriptorReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdate(for descriptor: Descriptor? = nil) -> Observable<Descriptor>
Parameters
descriptor
Optional
Descriptor
of which value changes should be observed. When not specified it will observe for anyDescriptor
.Return Value
Observable that emits
next
withDescriptor
instance every time when value has changed. It’s infinite stream, so.complete
is never called. -
Function that triggers read of current value of the
Descriptor
instance. Read is called after subscription toObservable
is made.Observable can ends with following errors:
BluetoothError.descriptorReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func readValue(for descriptor: Descriptor) -> Single<Descriptor>
Parameters
descriptor
Descriptor
to read value fromReturn Value
Single
which emitsnext
with given descriptor when value is ready to read. -
Function that triggers write of data to descriptor. Write is called after subscribtion to
Observable
is made.Observable can ends with following errors:
BluetoothError.descriptorWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func writeValue(_ data: Data, for descriptor: Descriptor) -> Single<Descriptor>
Parameters
data
Data
that’ll be written toDescriptor
instancedescriptor
Descriptor
instance to write value to.Return Value
Single
that emitsnext
withDescriptor
instance, once value is written successfully.
-
Function that triggers read of
Peripheral
RSSI value. Read is called after subscription toObservable
is made.Observable can ends with following errors:
BluetoothError.peripheralRSSIReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func readRSSI() -> Single<(Peripheral, Int)>
Return Value
Single
that emits tuple:(Peripheral, Int)
once new RSSI value is read.Int
is new RSSI value,Peripheral
is returned to allow easier chaining. -
Function that allow user to observe incoming
name
property changes ofPeripheral
instance.Observable can ends with following errors:
Declaration
Swift
public func observeNameUpdate() -> Observable<(Peripheral, String?)>
Return Value
Observable
that emits tuples:(Peripheral, String?)
when name has changed. It’soptional String
because peripheral could also lost his name. It’s infinite stream of values, so.complete
is never emitted. -
Function that allow to observe incoming service modifications for
Peripheral
instance. In case you’re interested what exact changes might occur - please refer to Apple DocumentationObservable can ends with following errors:
Declaration
Swift
public func observeServicesModification() -> Observable<(Peripheral, [Service])>
Return Value
Observable
that emits tuples:(Peripheral, [Service])
when services were modified. It’s infinite stream of values, so.complete
is never emitted. -
Resulting observable emits next element if call to
writeValue:forCharacteristic:type:
has failed, to indicate when peripheral is again ready to send characteristic value updates again.Declaration
Swift
public func observeWriteWithoutResponseReadiness() -> Observable<Void>
-
Function that allow to open L2CAP channel for
Peripheral
instance. For more information, please refer to What’s New in CoreBluetooth, 712, WWDC 2017Since
iOS 11, tvOS 11, watchOS 4Observable can ends with following errors:
BluetoothError.openingL2CAPChannelFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
@available(iOS 11, OSX 10.14, tvOS 11, watchOS 4, *) public func openL2CAPChannel(PSM: CBL2CAPPSM) -> Single<CBL2CAPChannel>
Parameters
PSM
PSM
(Protocol/Service Multiplexer) of the channelReturn Value
Single
that emitsCBL2CAPChannel
when channel has opened -
Function used to receive service with given identifier. It’s taken from cache if it’s available, or directly by
discoverServices
callObservable can ends with following errors:
RxError.noElements
BluetoothError.servicesDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func service(with identifier: ServiceIdentifier) -> Single<Service>
Parameters
identifier
Unique identifier of Service
Return Value
Single
which emitsnext
event, when specified service has been found. -
Function used to receive characteristic with given identifier. If it’s available it’s taken from cache. Otherwise - directly by
discoverCharacteristics
callObservable can ends with following errors:
RxError.noElements
BluetoothError.characteristicsDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func characteristic(with identifier: CharacteristicIdentifier) -> Single<Characteristic>
Parameters
identifier
Unique identifier of Characteristic, that has information about service which characteristic belongs to.
Return Value
Single
which emitsnext
event, when specified characteristic has been found. -
Function used to receive descriptor with given identifier. If it’s available it’s taken from cache. Otherwise - directly by
discoverDescriptor
callObservable can ends with following errors:
RxError.noElements
BluetoothError.descriptorsDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func descriptor(with identifier: DescriptorIdentifier) -> Single<Descriptor>
Parameters
identifier
Unique identifier of Descriptor, that has information about characteristic which descriptor belongs to.
Return Value
Single
which emitsnext
event, when specified descriptor has been found. -
Function that allow to observe writes that happened for characteristic.
Observable can ends with following errors:
BluetoothError.characteristicWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeWrite(for identifier: CharacteristicIdentifier) -> Observable<Characteristic>
Parameters
identifier
Identifier of characteristic of which value writes should be observed.
Return Value
Observable that emits
next
withCharacteristic
instance every time when write has happened. It’s infinite stream, so.complete
is never called. -
Function that triggers write of data to characteristic. Write is called after subscribtion to
Observable
is made. Behavior of this function strongly depends on CBCharacteristicWriteType, so be sure to check this out before usage of the method.WithResponse
- Observable emitsnext
withCharacteristic
instance write was confirmed without any errors. Immediately after thatcomplete
is called. If any problem has happened, errors are emitted.WithoutResponse
- Observable emitsnext
withCharacteristic
instance once write was called. Immediately after that.complete
is called. Result of this call is not checked, so as a user you are not sure if everything completed successfully. Errors are not emitted
Observable can ends with following errors:
BluetoothError.characteristicWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func writeValue(_ data: Data, for identifier: CharacteristicIdentifier, type: CBCharacteristicWriteType) -> Single<Characteristic>
Parameters
data
Data that’ll be written written to
Characteristic
instanceforCharacteristicWithIdentifier
unique identifier of characteristic, which also holds information about service characteristic belongs to.
type
Type of write operation. Possible values:
.withResponse
,.withoutResponse
Return Value
Observable that emition depends on
CBCharacteristicWriteType
passed to the function call. Behavior is following: -
Function that allow to observe value updates for
Characteristic
instance.Observable can ends with following errors:
BluetoothError.characteristicReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdate(for identifier: CharacteristicIdentifier) -> Observable<Characteristic>
Parameters
identifier
unique identifier of characteristic, which also holds information about service that characteristic belongs to.
Return Value
Observable that emits
next
withCharacteristic
instance every time when value has changed. It’s infinite stream, so.complete
is never called. -
Function that triggers read of current value of the
Characteristic
instance. Read is called after subscription toObservable
is made.Observable can ends with following errors:
BluetoothError.characteristicReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func readValue(for identifier: CharacteristicIdentifier) -> Single<Characteristic>
Parameters
identifier
unique identifier of characteristic, which also holds information about service that characteristic belongs to.
Return Value
Observable which emits
next
with given characteristic when value is ready to read. Immediately after that.complete
is emitted. -
Setup characteristic notification in order to receive callbacks when given characteristic has been changed. Returned observable will emit
Characteristic
on every notification change. It is possible to setup more observables for the same characteristic and the lifecycle of the notification will be shared among them.Notification is automaticaly unregistered once this observable is unsubscribed
This is infinite stream of values.
Observable can ends with following errors:
BluetoothError.characteristicReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdateAndSetNotification(for identifier: CharacteristicIdentifier) -> Observable<Characteristic>
Parameters
characteristic
Characteristic
for notification setup.Return Value
Observable
emittingCharacteristic
when given characteristic has been changed. -
Function that triggers descriptors discovery for characteristic
Observable can ends with following errors:
BluetoothError.descriptorsDiscoveryFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func discoverDescriptors(for identifier: CharacteristicIdentifier) -> Single<[Descriptor]>
Parameters
identifier
unique identifier of descriptor, which also holds information about characteristic that descriptor belongs to.
Return Value
Single
that emitsnext
with array ofDescriptor
instances, once they’re discovered. -
Function that allow to observe writes that happened for descriptor.
Observable can ends with following errors:
BluetoothError.descriptorWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeWrite(for identifier: DescriptorIdentifier) -> Observable<Descriptor>
Parameters
identifier
unique identifier of descriptor, which also holds information about characteristic that descriptor belongs to.
Return Value
Observable that emits
next
withDescriptor
instance every time when write has happened. It’s infinite stream, so.complete
is never called. -
Function that triggers write of data to descriptor. Write is called after subscribtion to
Observable
is made.Observable can ends with following errors:
BluetoothError.descriptorWriteFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func writeValue(_ data: Data, for identifier: DescriptorIdentifier) -> Single<Descriptor>
Parameters
data
Data
that’ll be written toDescriptor
instanceidentifier
unique identifier of descriptor, which also holds information about characteristic that descriptor belongs to.
Return Value
Single
that emitsnext
withDescriptor
instance, once value is written successfully. -
Function that allow to observe value updates for
Descriptor
instance.Observable can ends with following errors:
BluetoothError.descriptorReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func observeValueUpdate(for identifier: DescriptorIdentifier) -> Observable<Descriptor>
Parameters
identifier
unique identifier of descriptor, which also holds information about characteristic that descriptor belongs to.
Return Value
Observable that emits
next
withDescriptor
instance every time when value has changed. It’s infinite stream, so.complete
is never called. -
Function that triggers read of current value of the
Descriptor
instance. Read is called after subscription toObservable
is made.Observable can ends with following errors:
BluetoothError.descriptorReadFailed
BluetoothError.peripheralDisconnected
BluetoothError.destroyed
BluetoothError.bluetoothUnsupported
BluetoothError.bluetoothUnauthorized
BluetoothError.bluetoothPoweredOff
BluetoothError.bluetoothInUnknownState
BluetoothError.bluetoothResetting
Declaration
Swift
public func readValue(for identifier: DescriptorIdentifier) -> Single<Descriptor>
Parameters
identifier
Descriptor
to read value fromReturn Value
Observable which emits
next
with given descriptor when value is ready to read. Immediately after that.complete
is emitted.