raatiniemi / BluetoothLinux

Pure Swift Linux Bluetooth Stack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 hostController = HostController.default
    else { Error("No Bluetooth adapters found") }
let iBeaconUUID = Foundation.UUID(rawValue: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!
do { try hostController.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 4.1.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.

About

Pure Swift Linux Bluetooth Stack

License:MIT License


Languages

Language:Swift 89.5%Language:C 6.5%Language:Objective-C 4.0%