[![CI Status](http://img.shields.io/travis/Ke Yang/Cusp.svg?style=flat)](https://travis-ci.org/Ke Yang/Cusp)
Cusp is a light-weight BLE framework build on CoreBluetooth, featured multi-thread-operation thanks to powerful GCD.
Same as bluetooth communication, there are two main roles in Cusp: Central and Peripheral. Central is in charge of scan, connect and disconnect ble devices, while the latter performs substantial communication tasks including service/characteristic discovering, read/write value, subscribe/unsubscribe value updates, etc. Upon all these operations, Cusp provides methods in a friendly call-back way. So, just focus on your UI/UE and data tranfer, leave the dirty ble work to Cusp.
Cusp is still an infant in cradle, your advices means its growth, and I am looking forward to any contributor, sincerely.
import Cusp
Cusp.central.prepare()
Cusp.central.scanForUUIDString(nil, completion: { (advertisementInfoArray) -> Void in
for advertisementInfo in advertisementInfoArray {
print(advertisementInfo.peripheral.name)
print(advertisementInfo.advertisingUUIDStrings)
print(advertisementInfo.RSSI)
}
}, abruption: { (error) -> Void in
})
Cusp.central.connect(peripheral, success: { (response) -> Void in
}, failure: { (error) -> Void in
}, abruption: { (error) -> Void in
})
peripheral.discover(serviceUUIDArray, success: { (response) -> Void in
}, failure: { (error) -> Void in
})
peripheral.discover(characteristicUUIDArray, ofService: service, success: { (response) -> Void in
}, failure: { (error) -> Void in
})
peripheral.write(data, forCharacteristic: characteristic, success: { (response) -> Void in
}, failure: { (error) -> Void in
})
peripheral.subscribe(characteristcNotify, success: { (response) -> Void in
}, failure: { (error) -> Void in
}, update: { (value) -> Void in
})
To run the example project, clone the repo, and run pod install
from the Example directory first.
For now, it's recommended using Cusp in Swift. I have been recently testing Cusp in an Unity program, of which the bridge between C# and Swift is Objective-C and pure C, so I think it works well in OC either...(except those Swift-style enums).
To install Cusp, one way is simply download sources from another Git repository: Cusp-Pure, then add those sources into your project and DONE.
OR...
Cusp is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Cusp"
Ke Yang, ofveravi@gmail.com, keyOfVv@Twitter
Cusp is available under the MIT license. See the LICENSE file for more info.