Pure Swift Bluetooth Stack for Linux
Does not require BlueZ, communicates directly with the Linux kernel and Bluetooth controller.
import Bluetooth
import BluetoothLinux
guard let hostController = BluetoothLinux.HostController.default
else { fatalError("No Bluetooth adapters found") }
let uuid = UUID(rawValue: "E2C56DB5-DFFB-48D2-B060-D0F5A71096E0")!
let beacon = AppleBeacon(uuid: uuid, major: 1, minor: 1, rssi: -29)
do { try hostController.iBeacon(beacon) }
catch { print("Error enabling iBeacon: \(error)") }
import PackageDescription
let package = Package(
dependencies: [
.package(
url: "https://github.com/PureSwift/BluetoothLinux.git",
.branch("master")
)
]
)
Documentation can be generated with Jazzy.
swift package generate-xcodeproj
jazzy
Read the documentation here. For more information, see the gh-pages branch.
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 5.1.5 on ARMv7 and a Linux-comptible Bluetooth dongle (e.g. CSR8510 A10).
- Bluetooth - Pure Swift Bluetooth Definitions.
- GATT - Bluetooth Generic Attribute Profile (GATT) for Swift
- Silica - Pure Swift CoreGraphics (Quartz2D) implementation
- Predicate - Pure Swift Predicate implementation
BluetoothLinux is released under the MIT license. See LICENSE for details.