pureswift / bluetooth Goto Github PK
View Code? Open in Web Editor NEWPure Swift Bluetooth library
Home Page: http://pureswift.github.io/Bluetooth/
License: MIT License
Pure Swift Bluetooth library
Home Page: http://pureswift.github.io/Bluetooth/
License: MIT License
I am running the latest Raspbian Stretch on a Pi 3b+ with Swift 4.1.1 installed from https://packagecloud.io/swift-arm/test?page=1
I upgraded Package.swift to Swift 4, rearranged the directory structure to match, fixed few random incompatibilities (e.g. flatMap -> compactMap, etc) and encountered:
swift: /home/linaro/RaspberryPi/buildSwiftOnARM/swift/lib/Serialization/Serialization.cpp:617: TypeID swift::serialization::Serializer::addTypeRef(swift::Type): Assertion `!ty->hasError() && "Serializing error type"' failed.
[snip stack dump]
1. While serializing type 'τ_0_1'
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: merge-module command failed due to signal 6 (use -v to see invocation)
error: terminated(1): /usr/bin/swift-build-tool -f /home/XXXX/Bluetooth/.build/debug.yaml test -v output:
This seems to be the same compiler bug as: https://bugs.swift.org/browse/SR-6754
By playing around I think I have tracked it down to the compiler getting confused on the default
static var in BluetoothHostControllerInterface, though its not clear why it would.
When I remove that variable and its definition in the protocol extension, compilation proceeds normally.
Has anyone else gotten Bluetooth compiling under swift 4.1?
Add TestL2CAPSocket
for unit testing GATT Client and Server.
Implement all HCI comment sent for LE operations.
Decrease the framework binary size by removing non-essential Bluetooth types for iOS, tvOS and watchOS. HCI Commands and Events, non-supported GAP Data types by CoreBluetooth and ATT PDUs cannot be used from iOS.
Implement GATT Descriptor procedures (Discovery, Read, Write).
Implement HCI Informational Parameters Commands to read controller values such as device address.
Depends on #6. Create dummy TestHostController
for unit testing HCI commands and GATT operations.
Allow compiling for Swift 4.2 in Xcode 10
Depends on #7. Add protocol extensions that serve as convenience functions to easily configure the Accept Connection Timeout parameter on the Bluetooth controller.
Update the BluetoothUUID
defined UUID list (in DefinedUUID.swift) from bluetooth.com.
UUIDs are used in Bluetooth® protocols and applications. The SIG provides UUIDs for all the types, services and profiles it defines. The UUID program will run until the available block of 512 UUIDs is fully allocated. A fee of $2,500 per UUID will be charged for each.
Implement the standard GATT Characteristics in GATTCharacteristic.swift
by implementing the GATTProfileCharacteristic
protocol.
Implement ATTHandleValueNotification
for GATT Server and Client.
Depends on #33.
Write Connection Accept Timeout Command
in
BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part page 925
GATTServer
should not be sending GATT notifications to the connected client that wrote the value.
The project currently has GATTCharacteristic.swift
and ATTProtocolDataUnit.swift
which contain over 20 types and over 2k LOC, as well as the HCI commands. We need to separate the project into one file per type (with nested types as exception). This source layout will prevent merge conflicts and make the project scalable for rapid development with a larger team, but at the cost of git history. There is also the worry of a limit of number for files, and longer compile times with Xcode and Swift Package Manager, but this approach is cleaner and scalable.
This should not affect the API, but we might need to rename some of the HCI commands since the Swift compiler has issues compiling nested types in extensions across different files based on the order of input files. This bug is not present when Whole Module Optimization is enabled.
Integrate SwiftLint into the Xcode project.
The parameter packetpayload: LowEnergyPacketPayload is not being using.
Create an Adapter
protocol to represent Bluetooth adapters in a abstract type, and create a dummy TestAdapter
in the unit tests to test HCI commands.
Improve performance of library when used across modules as a shared library (e.g. .so
, .dylib
, .framework
).
Building the package on Xcode 12.5 I am getting such an error on line
public static let allCases: Set<MajorServiceClass> = [
in
ClassOfDevice.swift
.
Implement the GAP / EIR / BLE Advertisement Data Types.
Implement HCI Inquiry procedure. Depends on #100.
AppleBeacon
struct with parameters. See PureSwift/GATT - Beacon.swift.Separate the code into separate libraries and remove the platform conditional compilation introduced in #108 for modular and smaller binaries.
The unit tests for failing with Swift 5 and Xcode 10.2.
Add Class of Device struct according Bluetooth Documentation
Implement BLE mesh protocol.
Implement the new CaseIterable protocol introduced in Swift 4.2
This will allow enum cases that currently rely on BitMaskOption.all
to have the compiler synthesize the value (and prevent missing cases in the set).
Integrate xcov
and generate code coverage to be published with GitHub Pages.
Hello,
I'm desperately trying to revive this project that is based on your libraries stack.
This project is quite old and I've make forks of your libraries and this library to update it and make it compile on Ubuntu.
Unfortunately after I've fixed some issues, mainly due to misalignment between swift version and libraries version, I've found myself stuck with those kind of errors during the linking phase.
Project itself seems to build fine, but as soon as I try to test it swift test
it shows me that error.
lsb_release -r
/usr/bin/swiftc -print-target-info
/usr/bin/swiftc -print-target-info
/usr/bin/swift-frontend -frontend -print-target-info
/usr/bin/swift-frontend -frontend -print-target-info
/usr/bin/swift-frontend -frontend -emit-supported-features /tmp/TemporaryDirectory.R035Th/dummyInput-1.swift
/usr/bin/swiftc -L /home/pi/Desktop/RaspberryBLE/PunchBLE/.build/aarch64-unknown-linux-gnu/debug -o /home/pi/Desktop/RaspberryBLE/PunchBLE/.build/aarch64-unknown-linux-gnu/debug/RaspberryBLE -module-name RaspberryBLE -lBluetoothHCI -lBluetooth -lGATT -emit-executable -Xlinker '-rpath=$ORIGIN' @/home/pi/Desktop/RaspberryBLE/PunchBLE/.build/aarch64-unknown-linux-gnu/debug/RaspberryBLE.product/Objects.LinkFileList -target aarch64-unknown-linux-gnu -L /usr/lib
error: link command failed with exit code 1 (use -v to see invocation)
/home/pi/Desktop/RaspberryBLE/PunchBLE/Sources/RaspberryBLE/Peripheral/Services.swift:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyON'
/home/pi/Desktop/RaspberryBLE/PunchBLE/Sources/RaspberryBLE/Peripheral/Services.swift:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionO0A013BitMaskOptionAAMc'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionON'
<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT22ATTAttributePermissionON'
/home/pi/Desktop/RaspberryBLE/PunchBLE/.build/checkouts/SwiftLinuxBLE/Sources/SwiftLinuxBLE/Characteristic.swift:0: error: undefined reference to '$s13BluetoothGATT13GATTAttributeO10DescriptorVN'
/home/pi/Desktop/RaspberryBLE/PunchBLE/.build/checkouts/SwiftLinuxBLE/Sources/SwiftLinuxBLE/Characteristic.swift:0: error: undefined reference to '$s13BluetoothGATT13GATTAttributeO10DescriptorVN'
/home/pi/Desktop/RaspberryBLE/PunchBLE/.build/checkouts/SwiftLinuxBLE/Sources/SwiftLinuxBLE/Characteristic.swift:44: error: undefined reference to '$s13BluetoothGATT37GATTClientCharacteristicConfigurationV13configurationAC0A016BitMaskOptionSetVyAC0E0OG_tcfC'
/home/pi/Desktop/RaspberryBLE/PunchBLE/.build/checkouts/SwiftLinuxBLE/Sources/SwiftLinuxBLE/Characteristic.swift:44: error: undefined reference to '$s13BluetoothGATT37GATTClientCharacteristicConfigurationV10descriptorAA13GATTAttributeO10DescriptorVvg'
It seems that is looking for some mangled methods and properties that should be present in BluetoothGATT that are referenced from the project but it can't find them.
I've tried different solutions for instance use GATT module definitions (but it seems to be just a proxy if it can import BluetoothGATT).
I really do no not understand what I'm missing, tried to reach the original creator of the library but he/she is not responding.
Could you point me to the right direction?
Best,
Andrea
Add ATT PDU mock data and unit tests.
Implement HCI_Write_Local_Name
and HCI_Read_Local_Name
.
See BLUETOOTH SPECIFICATION Version 5.0 | Vol 2, Part E page 923
Integrate Jazzy to generate documentation.
Android always provides 128 bit UUID.
Add human readable names for HCI commands.
Optimize parsing of Data
for HCI commands, events, and ATT protocol data units. Migrate from parsing only Data
to parsing from Data.Subslice
or a similar type. This is to avoid unnecessary instantiating Data
buffers when decoding bytes.
Implement a function for data types like ATTProtocolDataUnit
that will encode data while reusing and growing a buffer, instead of copying into a buffer.
Well, the time has finally come. This project currently supports Swift 3.0.2 - 4.2. While that is impressive, since Swift 4.1.2 is available for Linux ARM, there is no reason to continue supporting Swift 3 anymore.
Implement HCI Link Control commands and related events.
Modify HostControllerInterface.pollEvents()
and its implementation in BluetoothLinux to allow for different types of events.
Update the list of registered CompanyIdentifier
from bluetooth.com.
Company identifiers are unique numbers assigned by the Bluetooth SIG to member companies requesting one.
The LE Scanning is currently only taking into account LE Advertising Data, not the LE Scan Response data.
See how Android currently handles scanning and advertisements.
Implement the standard GATT Descriptors found in GATTDescriptor.swift
by implementing the GATTDescriptor
protocol.
The defined Bluetooth Units should be specified in a list and automatically generate the extensions and unit tests. The member names should be manually defined and not sanitized from the documentation.
Implement GATT Indication / Confirmation procedure.
This is not severe but the outputs of below warning always pollutes the console:
/home/ubuntu/.build/checkouts/Bluetooth/Sources/Data.swift:89:49: warning: unknown architecture for build configuration 'arch'
#if arch(x86_64) || arch(arm64) || arch(arm64_32) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
^~~~~~~~
arm64
(repeating tens of times, arrow points to arch(arm64_32)
$ uname -a
linux ubuntu 5.3.0-1014-raspi2 #16-Ubuntu SMP Tue Nov 26 11:18:23 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
Add validation os(Android) on POSIXError.swift.
#if os(Linux) || os(Android)
Implement the standard GATT Profiles.
Depends on #58.
Generic Attributes (GATT) services are collections of characteristics and relationships to other services that encapsulate the behavior of part of a device.
A GATT profile describes a use case, roles, and general behaviors based on the GATT functionality, enabling extensive innovation while maintaining full interoperability with other Bluetooth® devices.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.