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 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.

Github

link
Stars: 132

Dependencies

Used By

Total: 0

Releases

v4.1.0 - 2019-04-29 19:04:16

  • b6d4904 Support Swift 5
  • 2e3c8ff Added NSPOSIXError

v4.0.0 - 2018-11-18 23:50:39

  • d123f40 Updated for Swift 4.1, deprecated Swift 3 support

v3.2.0 - 2018-09-12 05:42:02

  • 881c319 MakeL2CAPSocket non-blocking

v3.1.2 - 2018-08-04 23:29:17

  • #33 Fixed HCI Remote Name Request usage.

v3.1.1 - 2018-07-20 16:32:47

  • Updated AddressType

v3.1.0 - 2018-06-16 22:23:14

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

v3.0.5 - 2018-04-17 04:39:51

  • 8b89a04 Fixed typo in L2CAP socket

v3.0.4 - 2018-04-16 23:53:58

  • f0d82df Fixed Swift 3 compilation errors

v3.0.3 - 2018-03-31 16:02:02

  • 5789264 Updated DeviceRequest

v3.0.2 - 2018-03-30 19:46:25

  • a4b9054 Fixed CommandCompleteParameter

v3.0.1 - 2018-03-27 18:39:09

  • 965bf6c Added HCIPollEvent()

v3.0.0 - 2018-03-26 23:28:57

  • #29 Added Jazzy documentation
  • 527c8f3 Migrated GATT and HostController code to PureSwift/Bluetooth
  • cce5114 Renamed Adapter to HostController

v2.6.4 - 2018-02-24 13:50:35

  • #12 LE L2CAP Socket should never be BREDR
  • #23 Fixed GATTServerTest for 16 bit UUID
  • 2d9b5af Updated for Xcode 9
  • 1dee118 Added GATTClient.readCharacteristic()
  • b0ba4b8 Return .attributeNotLong error
  • 7530895 Added GATTClient.readCharacteristics(using:)
  • b1ff4c1 Swift 3.0.2 fix

v2.6.3 - 2017-12-11 06:01:28

  • a250d5c Improved performance with BitMaskOptionSet

v2.6.2 - 2017-12-11 05:21:53

  • 5688f1c Implemented Discover Characteristics by UUID
  • 9386d64 Improved performance with BitMaskOptionSet

v2.6.1 - 2017-12-08 18:33:47

  • #20 Implemented GATTClient.discoverAllCharacteristics()

v2.6.0 - 2017-12-04 18:17:54

  • #13 Implemented GATTClient
  • 7226186 Updated support for request callbacks in ATTConnection
  • 89ce8b7 Fixed ATTConnection.pickNextSendOpcode()
  • 84cd38d Added ATT error handling for responses in ATTConnection
  • e135ff2 AddedGATTClientTest command line tool

v2.5.3 - 2017-12-02 09:09:40

  • #16 Integrated Travis CI

v2.5.2 - 2017-12-01 06:16:08

  • 9604da3 Removed Carthage support and added SPM support for macOS

v2.5.1 - 2017-11-30 15:37:32

  • 218a54f Updated Adapter.setLowEnergyScanResponse() to support Foundation.Data as a parameter.
  • ac0b86b Updated HCISendRequest() for LE events
  • 4355535 Added Adapter.deviceRequest() support for HCICommandReturnParameter
  • 87f49de Fixed HCIPacketHeader byte parsing implementations
  • 427661a Added LECreateConnection command line tool

v2.5.0 - 2017-11-29 07:44:53

  • #14 Implemented LE Scan
  • 529401f Added LE Scan Response
  • 64d857c Added LE scan command line tool

v2.4.2 - 2017-04-06 15:43:26

  • Updated for Swift 3.1
  • Removed SwiftFoundation dependency

v2.4.1 - 2016-08-06 15:07:38

  • Updated for Swift 3.0 Development 04-08-2016

v2.4.0 - 2016-07-02 17:38:38

  • Updated for Xcode 8 beta 1 and Swift 3.0

v2.3.12 - 2016-06-12 19:40:11

  • Ignored HCIError.CommandDisallowed when enabling Bluetooth LE Advertising

2.3.11 - 2016-05-06 09:31:35

  • Removed Deque dependency
  • Updated for latest Swift 3.0 development snapshot (2016-05-03)

v2.3.10 - 2016-04-30 05:36:16

  • Fixed typo in APIs

v2.3.9 - 2016-04-30 04:12:58

  • #6 Fixed iBeacon functionality
  • Fixed HCI Requests and Commands

v2.3.8 - 2016-04-29 21:05:47

  • Fixed InvalidOffset error for Read Blob Request

v2.3.7 - 2016-04-29 18:55:47

  • Fixed Read Response
  • New Test Profile