Latest 0.9.1
Homepage https://github.com/mkoehnke/QuickBLE
License MIT
Platforms ios 9.1, osx 10.11, requires ARC

Twitter: @mkoehnke
Version
Carthage compatible
SPM compatible
License
Platform

A simple wrapper for CoreBluetooth to easily connect to Bluetooth LE devices and read/write it’s values. It is not intended as a fully-featured library. You can consider it as a simple prototyping tool to get a connection to your device up and running quickly.

Take a look at the iOS demo in the Example directory to see how to use it. It shows how to turn on/off the LED of an Arduino 101.

QuickBLE

Usage

QuickBLE has only a four methods to connect and manipulate the values of a connected peripheral:

Initialization

This static function returns an initialized QuickBLE object and starts the service discovery / connection:

class func start(service: String, delegate: QuickBLEDelegate?) -> QuickBLE

Example

helper = QuickBLE.start(service: "arduino", delegate: self)

Reading a value

This function reads the value of the specified characteristic and calls the passed closure with the result:

func read<T:CharacteristicValue>(uuid: String, result: @escaping (_ value: T?) -> Void)

Example

helper.read(uuid: "led") { (value : Int8?) in
    // evaluate value
}

Writing a value

The following sets a value for the specified characteristic unique identifier:

func write<T:CharacteristicValue>(value: T, for uuid: String)

Example

helper.write(value: Int8(1), for: "led")

Stop

Cancels the connection to the peripheral.

func stop()

Example

helper.stop()

Supported Types

QuickBLE currently supports the following types for characteristic values:

  • String
  • Int8

This list can be easily expanded with additional types by implementing the following protocol:

public protocol CharacteristicValue {
    static func getValue(fromData data: Data?) -> Self?
}

Attributions

License

QuickBLE is available under the MIT license. See the LICENSE file for more info.

Recent Changes

The release notes can be found here.

Latest podspec

{
    "name": "QuickBLE",
    "version": "0.9.1",
    "summary": "A simple helper for communicating with Bluetooth LE devices (Arduino 101, etc.)",
    "description": "A simple helper for communicating with Bluetooth LE devices (Arduino 101, etc.) written in Swift.",
    "homepage": "https://github.com/mkoehnke/QuickBLE",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Mathias Ku00f6hnke",
    "platforms": {
        "ios": "9.1",
        "osx": "10.11"
    },
    "source": {
        "git": "https://github.com/mkoehnke/QuickBLE.git",
        "tag": "0.9.1"
    },
    "source_files": "Sources/*.{swift}",
    "exclude_files": "Sources/Exclude",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    }
}

Pin It on Pinterest

Share This