RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it provides nice API, for both Central and Peripheral modes. All to work with and make your code more readable, reliable and easier to maintain.
Here is a sneak peek of what you can do with RxBluetoothKit:
manager.scanForPeripherals(withServices: [serviceId])
.take(1)
.flatMap { $0.peripheral.establishConnection() }
.flatMap { $0.discoverServices([serviceId]) }
.flatMap { Observable.from($0) }
.flatMap { $0.discoverCharacteristics([characteristicId]) }
.flatMap { Observable.from($0) }
.flatMap { $0.readValue() }
.subscribe(onNext: { print("Value: \($0.value)") })
With just 9 lines it started scanning, connecting to the peripheral, discovering service and characteristics and read charecteristic's value!
Central mode features
- Observing manager states
- Scanning for peripherals
- Connecting to peripheral
- Discovering peripheral's services and characteristics
- Reading & Writing to characteristic's value
- Monitoring characteristic value change
- Opening L2CAP channels
- Convenience helper methods
- And a lot more!
Peripheral mode features
- Observing manager states
- Advertising
- Observing read & writes
- Observing subscribe
- Publishing L2CAP channels
- And a lot more!
Recent Changes
6.0.0
- Increased deployment target for iOS to 9.0 and for osx to 10.13 (#379, #380)
- Added support for observing ancsAuthorized property on peripheral. (#370)
- Added Bluetooth usage description to Info.plist in Example project (#369)
- Added initial state improvement & a minor fix for BluetoothState methods. (#371)
- Fixed problems with SPM support (#358, #368)
- Updated RxSwift version to 5.1 (#376)
- Updated project configurations to decrease build time on TravisCI (#376)
- Updated scripts to fixed problems with generating mocks (#378)
Want to migrate from 4.x to 5.x? Check guidelines here.
Installation
CocoaPods
CocoaPods is a dependency manager for CocoaProjects.
To integrate RxBluetoothKit into your Xcode project using CocoaPods specify it in your Podfile
:
pod 'RxBluetoothKit'
Then, run the following command:
$ pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
To integrate RxBluetoothKit into your Xcode project using Carthage specify it in your Cartfile
:
github "Polidea/RxBluetoothKit"
Then, run carthage update
to build framework and drag RxBluetoothKit.framework
into your Xcode project.
Swift Package Manager
Versions >= 4.0 of the library integrate with the Swift Package Manager. In order to do that please specify our project as one of your dependencies in Package.swift
file.
Getting Started
Check our Wiki with guidelines to (almost) all library functionalites.
Documentation & Support
- Api reference
- Sample App
- Gitter channel if you want to talk about it, ask questions or give feedback.
- StackOverflow if you have a problem
- Or open an issue on GitHub
Remember to follow Polidea's Blog blog to get all the news and updates!
Learn more about Polidea's BLE services here.
Requirements
- iOS 9.0+
- OSX 10.13+
- watchOS 4.0+
- tvOS 11.0+
- Xcode 11.4+
Swift versions
- 3.0 version supports Swift 3.0 and 3.1
- 5.0 version supports Swift 3.2 and 4.0
- 5.1.2 version supports Swift 4.1
- 5.2 version supports Swift 5.0 and 4.2
Github
link |
Stars: 1199 |
You may find interesting
Dependencies
Releases
6.0.0 - 2020-09-04T12:23:44
- Increased deployment target for iOS to 9.0 and for osx to 10.13 (#379, #380)
- Added support for observing ancsAuthorized property on peripheral. (#370)
- Added Bluetooth usage description to Info.plist in Example project (#369)
- Added initial state improvement & a minor fix for BluetoothState methods. (#371)
- Fixed problems with SPM support (#358, #368)
- Updated RxSwift version to 5.1 (#376)
- Updated project configurations to decrease build time on TravisCI (#376)
- Updated scripts to fixed problems with generating mocks (#378)
5.3.0 - 2019-07-26T11:49:03
- Always connect to retrieved peripherals first (#337)
- Addded a customisation point for injecting a logger (#341)
- Fixed L2CAP API to support OSX 10.14 (#345)
5.2.1 - 2019-05-17T13:56:57
- Updated RxSwift to version 5.0 (#335)
5.2.0 - 2019-04-13T20:17:30
- Added support for Xcode 10.2 and Swift 5 (#321)
- Fixed "API MISUSE" after canceling notification state when bluetooth is powered off (#319)
- Fixed problems when
discoverServices
doesn't emit any result (#309)
5.1.4 - 2018-09-21T13:16:36
- Updated RxSwift library to version 4.3
- fix API MISUSE when calling stop scan on dispose (#283)
- add option to disable checking of canSendWriteWithoutReponse while writing (#282)
5.1.3 - 2018-06-29T08:17:16
- Changed back deployment target from 10.0 to 8.0. (#275)
5.1.2 - 2018-06-21T12:50:41
- Updated RxSwift to 4.2 with support for XCode 9.4 (#268)
4.0.3 - 2018-06-11T09:49:53
Update Cartfile.resolved
and generate binary framework for XCode 9.4.
5.1.1 - 2018-06-08T08:10:37
- Fixed
PeripheralManager
not public (#264)
5.1.0 - 2018-05-28T08:11:25
- Added support for
CBPeripheralManager
. ReadPeripheralManager
documentation for more info (#166) - Deprecated
RestoredState
andCentralManager.init(queue:options:onWillRestoreCentralManagerState:)
. From now on please use correspondingCentralManagerRestoredState
andCentralManager.init(queue:options:onWillRestoreCentralManagerState:)
5.0.2 - 2018-05-07T13:28:31
- Changed error name from
BluetoothError.peripheralIsConnectingOrAlreadyConnected
toBluetoothError.peripheralIsAlreadyObservingConnection
- old error has been deprecated (#245) - To each method, that returns observable, added documentation with a list of errors that this observable can return (#225)
- Rewritten example app that is now using RxBluetoothKit 5.x (#240, #220)
- Added available annotation for
canSendWriteWithoutResponse
property (#253)
5.0.1 - 2018-04-10T10:06:41
- Added method to observe notyfing state change for the characteristic (#229)
- Aligned the API for
establishConnection
with the rest of the implementation - Made restore state api public (#224)
- Enabled getting an
Observable<Peripheral>
from already connected peripheral provided by the system (#238) - Fixed writting without response on older systems (#241)
- Added queues for discovery requests (fixed #235)
- Added support for XCode 9.3 and swift 4.1
5.0.0 - 2018-03-14T14:28:29
- Changed BluetoothManager to CentralManager
- Reimplemented connection and notification API's
- Added watchOS and tvOS targets
- Added support for L2CAP
- Rewritten unit tests
4.0.2 - 2018-01-10T07:35:03
- Allow projects that depend on RxBluetoothKit to update RxSwift to 4.1.0 and newer (#201 by @DevAndArtist)
4.0.1 - 2017-11-29T13:20:10
- Add missing logs for CBPeripheral and CBCentralManager classes.
- Fixed implementation of scanning subscription queue.
4.0.0 - 2017-11-20T10:32:43
- App updated to newest iOS & macOS SDK
- Swift 4 adoption
- Possible memory leaks removed
- 2017-10-02T11:49:43
- RxSwift 4 alpha added as dependency
4.0.0 alpha 0 - 2017-09-26T10:11:13
- Added compatibility with Swift 4
- Updated RxSwift dependency to version 4.
v3.1.0 - 2017-08-28T07:57:57
- Access from library objects to
CBCentralManager
andPeripheral
instances is now public - Fixed a bug regarding doing unnecessary operations when peripheral was disconnected
Initial release - 2017-07-19T10:04:39
- Initial release
v0.3.4 - 2017-07-19T10:04:09
- Deleted jazzy.yaml in order to make cocoadocs work
v0.3.6 - 2017-07-19T10:03:29
- Added convenience methods to
Peripheral
. Check more about it in README.
v0.3.7 - 2017-07-19T10:02:34
- Improved APIs of
Characteristic
andService
v0.4.0 - 2017-07-19T10:02:11
- Documentation updated
- Use cases added to example app
- Added convenience methods to peripheral
- Added protocols that are giving user access to convenience API.
v0.4.1 - 2017-07-19T10:01:47
- Fixed possible race condition in
setNotifyAndMonitor
function
v1.0.1 - 2017-07-19T10:00:45
- Fixed issues related to scan sharing
v1.1.0 - 2017-07-19T10:00:18
- New API in
BluetoothManager
:rx_state
to monitorCBCentralManager
state changes - New API in
Peripheral
:rx_state
to monitorCBPeripheral
state change andrx_isConntected
to monitor connection state changes monitorState()
andmonitorStateChange()
marked as deprecated- Added dependency for RxCocoa
v1.1.1 - 2017-07-19T09:59:54
- Fixed a bug regarding
rx_state
behavior
v1.2.0 - 2017-07-19T09:59:29
- Added support for Core Bluetooth state restoration
v1.2.1 - 2017-07-19T09:58:54
listenOnRestoredState
method made public