-
Notifications
You must be signed in to change notification settings - Fork 372
9. Other functionalities
Here you'll find some other useful functionalities of the library
Property isConnected
on Peripheral
allows checking if Peripheral
is connected. To monitor Peripheral
connection state changes use:
peripheral.observeConnection()
It emits new element after connection state changes.
CentralManager
also lets to retrieve peripherals in two ways:
- via its identifier using array of
UUID
objects:
manager.retrieveConnectedPeripherals(withServices: services)
- connected ones via services identifiers using array of
CBUUID
objects:
manager.retrievePeripherals(withIdentifiers: identifiers)
In both cases, return type is [Peripheral]
.
Triggers read of Peripheral RSSI value. To do it, call readRSSI()
on Peripheral instance:
peripheral.readRSSI()
Method returns Single<(Peripheral, Int)>
. Peripheral is returned in order to enable chaining.
When you want to know, when services are modified, do:
let observable: Observable<(Peripheral, [Service])> = peripheral.observeServicesModification()
Next event is generated each time, when service changes.
Call observeNameUpdate() -> Observable<(Peripheral, String?)>
in order to know, when peripheral changes its name:
By calling observeWrite(for characteristic: Characteristic) -> Observable<Characteristic>
you're able to receive event each time, when value is being written to characteristic.