Swiftpack.co - Package - PureSwift/BluetoothLinux

BluetoothLinux

Swift Platform Release Build Status License CodeBeat

SPM compatible

Pure Swift Bluetooth Stack for Linux

Does not require BlueZ, communicates directly with the Linux kernel and Bluetooth controller.

Usage

import Bluetooth
import BluetoothLinux

guard let adapter = try? Adapter()
    else { Error("No Bluetooth adapters found") }

print("Found Bluetooth adapter with device ID: \(adapter.identifier)")

let iBeaconUUID = Foundation.UUID(rawValue: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!

do { try adapter.enableBeacon(uuid: iBeaconUUID, major: 1, minor: 1, rssi: -29) }
    
catch { print("Error enabling iBeacon: \(error)") }

Installation

Swift Package Manager

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/PureSwift/BluetoothLinux.git", majorVersion: 3)
        ]
)

Documentation

Documentation can be generated with Jazzy.

swift package generate-xcodeproj
jazzy

Read the documentation here. For more information, see the gh-pages branch.

Troubleshooting

Do not test in Parallels or VMware with the built in Bluetooth adapter found in Macs. You can, however, use VMWare or Parallels, with a Linux compatible Bluetooth LE USB adapter plugged in. VirtualBox will work with the builtin adapter on Macs.

For best results, test with Swift 3.0.2 on an ARM board running Linux (e.g. BeagleBoneBlack, Raspberry Pi, Orange Pi, etc) and a Linux comaptible Bluetooth dongle (e.g. CSR8510 A10).

See Also

  • Bluetooth - Pure Swift Bluetooth Definitions.
  • GATT - Bluetooth Generic Attribute Profile (GATT) for Swift
  • SwiftFoundation - Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library.
  • Cacao - Pure Swift Cross-platform UIKit
  • Silica - Pure Swift CoreGraphics (Quartz2D) implementation
  • Predicate - Pure Swift Predicate implementation

License

BluetoothLinux is released under the MIT license. See LICENSE for details.

Github

link
Stars: 98
Help us keep the lights on

Dependencies

Releases

3.1.0 - Jun 16, 2018

  • 2a20b9e Added HostController.deviceRequest<C, EP>()

3.0.5 - Apr 17, 2018

  • 8b89a04 Fixed typo in L2CAP socket

3.0.4 - Apr 16, 2018

  • f0d82df Fixed Swift 3 compilation errors

3.0.3 - Mar 31, 2018

  • 5789264 Updated DeviceRequest

3.0.2 - Mar 30, 2018

  • a4b9054 Fixed CommandCompleteParameter