GithubHelp home page GithubHelp logo

pureswift / bluetooth Goto Github PK

View Code? Open in Web Editor NEW
172.0 13.0 24.0 8.74 MB

Pure Swift Bluetooth library

Home Page: http://pureswift.github.io/Bluetooth/

License: MIT License

Swift 99.36% Shell 0.60% Dockerfile 0.04%
bluetooth bluetooth-low-energy gatt swift l2cap

bluetooth's People

Contributors

carlos21 avatar colemancda avatar jmarkstar avatar jurjdev avatar ksinghal avatar vignesh-jeyaraj2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluetooth's Issues

Unable to compile under Swift 4.1.1 on Raspberry Pi

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?

Exclude redundant types from iOS build

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.

GATT Descriptors

Implement GATT Descriptor procedures (Discovery, Read, Write).

Update 16 Bit UUIDs For Members

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.

Fix GATT Notifications

GATTServer should not be sending GATT notifications to the connected client that wrote the value.

  • If the Peripheral wrote a new value, all connected clients should be notified.
  • If a Central wrote a value, all connected centrals, except the one that wrote the value, should be notified.

Refactor source layout

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.

Add @frozen to API

Improve performance of library when used across modules as a shared library (e.g. .so, .dylib, .framework).

Update iBeacon

  • Create AppleBeacon struct with parameters. See PureSwift/GATT - Beacon.swift.
  • Use GAP data types (depends on #44)
  • Check if controller supports LE features (Read Local Features HCI Command).
  • Read LE Advertising Power (depends on #3).

Add submodules

Separate the code into separate libraries and remove the platform conditional compilation introduced in #108 for modular and smaller binaries.

Implement `CaseIterable`

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

[Help Needed] <compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26GATTCharacteristicPropertyON'

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

Optimize Data parsing for HCI and ATT PDUs

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.

Remove Swift 3 support

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.

Unknown architecture arm64_32 on Linux

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

GATT Profile

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.