GithubHelp home page GithubHelp logo

pureswift / gatt Goto Github PK

View Code? Open in Web Editor NEW
62.0 5.0 18.0 1.58 MB

Bluetooth Generic Attribute Profile (GATT) for Swift (Supports Linux)

License: MIT License

Swift 89.84% Shell 9.54% Dockerfile 0.62%
bluetooth-low-energy corebluetooth iot swift linux bluetooth gatt

gatt's People

Contributors

colemancda avatar hpux735 avatar jmarkstar avatar wlisac 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

Watchers

 avatar  avatar  avatar  avatar  avatar

gatt's Issues

Compilation failed on HighSierra

doing carthage update from another package, that depends on GATT i get the following error

CompileSwift normal x86_64
    cd /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Xcode
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Central.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinAttributes.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/LinuxPeripheral.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinPeripheral.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peripheral.swift /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Beacon.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/BuildProductsPath/Release" -F "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/BuildProductsPath/Release" -F /Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Xcode/../Carthage/Build/Mac -g -import-underlying-module -module-cache-path /Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/ModuleCache -swift-version 3 -serialize-debugging-options -report-errors-to-debugger -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/swift-overrides.hmap" -Xcc -iquote -Xcc "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/GATT-generated-files.hmap" -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/GATT-own-target-headers.hmap" -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/GATT-all-non-framework-target-headers.hmap" -Xcc -ivfsoverlay -Xcc "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/all-product-headers.yaml" -Xcc -iquote -Xcc "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/GATT-project-headers.hmap" -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/BuildProductsPath/Release/include" -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/DerivedSources/x86_64" -Xcc "-I/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/DerivedSources" -Xcc -ivfsoverlay -Xcc "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/unextended-module-overlay.yaml" -Xcc -working-directory/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Xcode -emit-module-doc-path "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/GATT.swiftdoc" -serialize-diagnostics-path "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Central.dia" -O -module-name GATT -emit-module-path "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/GATT.swiftmodule" -emit-objc-header-path "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/GATT-Swift.h" -emit-dependencies-path "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Central.d" -num-threads 8 -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Central.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/DarwinAttributes.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/LinuxPeripheral.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Peer.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/DarwinPeripheral.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/DarwinCentral.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Peripheral.o" -o "/Users/rs/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B46/GATT/0337518dcfc032850f3a764ab751822499db29c5/Build/Intermediates.noindex/ArchiveIntermediates/GATT OS X/IntermediateBuildFilesPath/GATT.build/Release/GATT OS X.build/Objects-normal/x86_64/Beacon.o"
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:68:39: error: 'identifier' is only available on OS X 10.13 or newer
            self.identifier = central.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:68:39: note: add 'if #available' version check
            self.identifier = central.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:66:9: note: add @available attribute to enclosing initializer
        init(_ central: CBCentral) {
        ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:64:5: note: add @available attribute to enclosing extension
    extension Central {
    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:88:39: error: 'identifier' is only available on OS X 10.13 or newer
            self.identifier = central.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:88:39: note: add 'if #available' version check
            self.identifier = central.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:86:9: note: add @available attribute to enclosing initializer
        init(_ central: CBPeripheral) {
        ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/Peer.swift:84:5: note: add @available attribute to enclosing extension
    extension Peripheral {
    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinPeripheral.swift:33:36: error: cannot convert return expression of type 'CBManagerState' to return type 'CBPeripheralManagerState'
            return internalManager.state
                   ~~~~~~~~~~~~~~~~^~~~~
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinPeripheral.swift:245:37: error: cannot convert value of type 'CBManagerState' to expected argument type 'CBPeripheralManagerState'
            stateChanged(peripheral.state)
                         ~~~~~~~~~~~^~~~~
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinPeripheral.swift:364:61: error: cannot force unwrap value of non-optional type 'CBUUID'
                        let foundation = characteristic.uuid!
                                         ~~~~~~~~~~~~~~~~~~~^
                                                            
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:34:36: error: cannot convert return expression of type 'CBManagerState' to return type 'CBCentralManagerState'
            return internalManager.state
                   ~~~~~~~~~~~~~~~~^~~~~
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:241:39: error: 'identifier' is only available on OS X 10.13 or newer
                guard foundPeripheral.identifier != peripheral.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:241:39: note: add 'if #available' version check
                guard foundPeripheral.identifier != peripheral.identifier
                                      ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:237:22: note: add @available attribute to enclosing instance method
        private func peripheral(_ peripheral: Peripheral) -> CBPeripheral? {
                     ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:334:34: error: cannot convert value of type 'CBManagerState' to expected argument type 'CBCentralManagerState'
            stateChanged(central.state)
                         ~~~~~~~~^~~~~
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:365:57: error: 'identifier' is only available on OS X 10.13 or newer
            log?("Connecting to peripheral \(peripheral.identifier.uuidString)")
                                                        ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:365:57: note: add 'if #available' version check
            log?("Connecting to peripheral \(peripheral.identifier.uuidString)")
                                                        ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:363:21: note: add @available attribute to enclosing instance method
        public func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:380:40: error: 'identifier' is only available on OS X 10.13 or newer
            if connectingToPeripheral?.identifier == peripheral.identifier {
                                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:380:40: note: add 'if #available' version check
            if connectingToPeripheral?.identifier == peripheral.identifier {
                                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:376:21: note: add @available attribute to enclosing instance method
        public func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:380:65: error: 'identifier' is only available on OS X 10.13 or newer
            if connectingToPeripheral?.identifier == peripheral.identifier {
                                                                ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:380:65: note: add 'if #available' version check
            if connectingToPeripheral?.identifier == peripheral.identifier {
                                                                ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:376:21: note: add @available attribute to enclosing instance method
        public func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:403:47: error: 'identifier' is only available on OS X 10.13 or newer
                log?("Peripheral \(peripheral.identifier.uuidString) did discover \(peripheral.services?.count ?? 0) services")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:403:47: note: add 'if #available' version check
                log?("Peripheral \(peripheral.identifier.uuidString) did discover \(peripheral.services?.count ?? 0) services")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:395:21: note: add @available attribute to enclosing instance method
        public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:418:47: error: 'identifier' is only available on OS X 10.13 or newer
                log?("Peripheral \(peripheral.identifier.uuidString) did discover \(service.characteristics?.count ?? 0) characteristics for service \(service.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:418:47: note: add 'if #available' version check
                log?("Peripheral \(peripheral.identifier.uuidString) did discover \(service.characteristics?.count ?? 0) characteristics for service \(service.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:410:21: note: add @available attribute to enclosing instance method
        public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:433:47: error: 'identifier' is only available on OS X 10.13 or newer
                log?("Peripheral \(peripheral.identifier.uuidString) did update value for characteristic \(characteristic.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:433:47: note: add 'if #available' version check
                log?("Peripheral \(peripheral.identifier.uuidString) did update value for characteristic \(characteristic.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:425:21: note: add @available attribute to enclosing instance method
        public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:451:47: error: 'identifier' is only available on OS X 10.13 or newer
                log?("Peripheral \(peripheral.identifier.uuidString) did write value for characteristic \(characteristic.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:451:47: note: add 'if #available' version check
                log?("Peripheral \(peripheral.identifier.uuidString) did write value for characteristic \(characteristic.uuid.uuidString)")
                                              ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:443:21: note: add @available attribute to enclosing instance method
        public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Swift.Error?) {
                    ^
/Users/rs/projects/ble-vibro-mat/DemoPeripheral/Carthage/Checkouts/GATT/Sources/GATT/DarwinCentral.swift:20:24: note: add @available attribute to enclosing class
    public final class DarwinCentral: NSObject, NativeCentral, CBCentralManagerDelegate, CBPeripheralDelegate {
                       ^

** ARCHIVE FAILED **


The following build commands failed:
	CompileSwift normal x86_64
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
``

Documentation (for GATTPeripheral)

Would it be possible to provide some documentation or examples of using GATTPeripheral to accomplish something like this?

Also any help would be appreciated, as my peripheral with service and characteristics isn't working for some reason even though nothing that can throw is throwing and it should be discoverable..

(I'm not an expert, but have a good understanding of bluetooth/GATT. I have setup a custom python GATT server that does similar things to the bluez example in the above link. I also have written the Central that talks to it in Swift on iOS - however porting the python code to pure swift so far is proving to be more difficult than anticipated.. )

Kind regards,

Can't figure out how to dynamically set read value on a characteristic based on central UUID

I'm trying to implement a peripheral on a Pi that looks at the central's UUID on a willRead and figures out the reply based on some business logic. The problem is that because peripheral.write is async, there doesn't appear to be a way to dynamically change the value on a willRead in time for the response to go out.

Is there a recommended pattern to follow for this:

private func willRead(_ request: GATTReadRequest<Central>) -> ATTError? {
        logger.info("Recevied read")
        guard let peripheral else {
            return nil
        }
       /// SET THE VALUE OF THE CHARACTERISTIC
}

Implementing a cross platform GATT Peripheral

Using PureSwift GATT I wish to implement a GATT Peripheral that will be deployed on Darwin (MacOS, iOS, Mac Catalyst) and Linux platforms. How can a peripheral such as a Heart rate Monitor be implemented without custom coding for each platform?
Perhaps I am missing a trick?

Implement CoreBluetooth state restoration

CoreBluetooth state restoration needs to be properly implemented, and be an optional feature. Since CoreBluetooth uses Objective-C runtime introspection to check if the CBCentralManagerDelegate instance implements the state restoration delegate methods, it makes optionally enabling this feature a bit more difficult.

Unable to subscribe to notifications for characteristics from different services on Darwin platforms

Issue

Subscribing to notifications for characteristics from different services is not working as expected on Darwin platforms (iOS and macOS).

Expected Behavior

I'd expect for the notification handler to be triggered for all of the characteristics I subscribe to, even if those characteristics are from different services.

Observed Behavior

Only the last characteristics I subscribe to from a single service have the notification handlers called.

Possible Cause

I've done some initial investigation and the cause of this limitation may live in the Cache of DarwinCentral.swift:

struct Cache {
fileprivate init() { }
var services = Services()
struct Services {
fileprivate(set) var values: [UInt: CBService] = [:]
}
mutating func update(_ newValues: [CBService]) {
newValues.enumerated().forEach {
let identifier = UInt($0.offset)
services.values[identifier] = $0.element
}
}
var characteristics = Characteristics()
struct Characteristics {
fileprivate(set) var values: [UInt: (attribute: CBCharacteristic, notification: ((Data) -> ())?)] = [:]
}
mutating func insert(_ newValues: [CBCharacteristic],
for service: CBService) {
// remove old characteristics for service
while let key = characteristics.values
.first(where: { $0.value.attribute.service === service })?.key {
characteristics.values[key] = nil
}
// insert new characteristics
newValues.enumerated().forEach {
let identifier = UInt($0.offset)
characteristics.values[identifier] = (attribute: $0.element, notification: nil)
}
}
}
}

The Cache stores Services and Characteristics as siblings. The Characteristics are stored by the index / order that they were discovered in.

This means that if you discover characteristics from Service A. Then discover characteristics from Service B. The characteristics from Service B overwrite the characteristics from Service A.

Additional Information

Depending on how the caller discovers / subscribes to notifications, this may result in an Invalid characteristic assertion failure when attempting to call the notification handlers:

guard let cache = self.internalState.cache[Peripheral(corePeripheral)],
let characteristicCache = cache.characteristics.values.first(where: { $0.value.attribute === coreCharacteristic })?.value
else { assertionFailure("Invalid characteristic \(coreCharacteristic.uuid)"); return }

[Linux] Command Disallowed

With this test program:

import GATT
import Bluetooth
import BluetoothLinux

typealias LinuxCentral = GATTCentral<BluetoothLinux.HostController, BluetoothLinux.L2CAPSocket>
guard let hostController = await HostController.default else { fatalError("No Bluetooth hardware available") }
let central = LinuxCentral(hostController: hostController, socket: BluetoothLinux.L2CAPSocket.self)

// start scanning
let stream = try await central.scan(filterDuplicates: true)
for try await scanData in stream {
    print(scanData)
    stream.stop()
}

I'm getting Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Command Disallowed (even with sudo).

I'm on an Ubuntu 20.04.2 LTS derivate. Any idea what could be wrong?

GATT peripheral does not advertise services

Services added to a GATTPeripheral are discoverable once a remote central has connected, their UUIDs are, however, now included in the LE advertising payload. This causes nodes acting as a GATTPeripheral to go undiscovered if the central scans for specific service UUIDs.

CharacteristicProperty Notify

I am trying to have listener to read notify (Bluetooth.GATT.CharacteristicProperty.Notify) but i am having falling to do that.

can you help me by doing some example?

This is what i have done.

`let foundPeripherals = central.scan()

    print("Scan results: \(foundPeripherals.map({ $0.identifier }))")
    
    for peripheral in foundPeripherals {
        
        do { try central.connect(to: peripheral) }
        catch {
            
            print("Error connecting to \(peripheral.identifier): \(error)")
            continue
        }
        
        print("Did connect to \(peripheral.identifier)")
        
        let services = try! central.discoverServices(for: peripheral)
        
        print("Discovered services: \(services.map({ $0.UUID }))")
        
        let serviceUuid = BluetoothUUID.init(rawValue: "1706BBC0-88AB-4B8D-877E-2237916EE929")
        
        if services.contains(where: { $0.UUID == serviceUuid }) {
    
            print("    SERVICE FOUND")
            print("    Number of services",services.count)
            print("    service 1 ",services.first?.UUID ?? "null")
            
            
            for service in services {
                
                let characteristics = try! central.discoverCharacteristics(for: service.UUID, peripheral: peripheral)
                
                
                print("Found \(characteristics.count) characteristics for service \(service.UUID)")

                if(characteristics.count == 0){
                    self.central.disconnect(peripheral: peripheral)
                    return
                }
                
                for characteristic in characteristics {
                    
                    print("         characteristic: ",characteristic.UUID)
                    print("         characteristic prop: ",characteristic.properties)
                    
                    let charWriteUuid = BluetoothUUID.init(rawValue: CHARACTERISTIC_WRITE)

                    if (characteristic.UUID == charWriteUuid)  {
                        do { try central.write(data: "Test Write".data(using: .utf8)!, response: true, characteristic: characteristic.UUID, service: service.UUID, peripheral: peripheral) }
                            
                        catch {   print("Error write to \(peripheral.identifier): \(error)")}
                        
                    }
                    
                    let charNotifyUuid = BluetoothUUID.init(rawValue: CHARACTERISTIC_NOTIFY)
                    
                    if(characteristic.UUID == charNotifyUuid){

                        DispatchQueue.main.async(execute: {
                            var value: Data!
                            
                            var a = self.central.stateChanged
                                                            
                            /*do { value = try self.central.read(characteristic: characteristic.UUID, service: service.UUID, peripheral: peripheral) }
                            catch {   print("Error read to \(peripheral.identifier): \(error)")}
                            
                            print("         READDDDD: ",value)*/
                            self.central.disconnect(peripheral: peripheral)

                        })
                    }

                }
            }
            

        }

`

GATTCentral with BluetoothLinux' HostController yields linker error

A simple Swift project using the latest versions of BluetoothLinux and GATT with the following main script

import Bluetooth
import BluetoothLinux
import GATT

let hostController = BluetoothLinux.HostController.default!
let central = GATTCentral<BluetoothLinux.HostController, BluetoothLinux.L2CAPSocket>(hostController: hostController)

causes linking to fail:

<compiler-generated>:0: error: undefined reference to '$s13BluetoothGATT26ATTMaximumTransmissionUnitV3maxACvgZ'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
link command failed with exit code 1 (use -v to see invocation)

Implementing glucose services, need help

I want to implement BLE stuff regarding blood sugar measurement and found this project.
Is there any chance to get general starter information regarding how to implement a simple read workflow of an characteristic: connect device, peripheral service discover, manage notify values, read and write characteristic data?

I took already a look at https://github.com/MillerTechnologyPeru/SmartLock, but honestly, it's not very helpful to get started.

Any help appreciated!

Integrate Travis CI

Use Travis CI to build iOS, macOS, watchOS, and Linux framework target using SPM on Linux and SPM and Carthage on Mac.

See .travis.yml.

Beacon and Service Advertisement

When I start a service as follows, LightBlue sees the device and can scan it, but does not see it advertising a service. ScanBeacon does not see the beacon. Should I be able to see both?

        if let uuid = Foundation.UUID(uuidString: "C870EC7D-4EB9-4549-A355-5663EB99D71D"),                                                                     
           let rssi = RSSI(rawValue: Int8(bitPattern: 0xb3)) {                                                                                                 
            let beacon = Bluetooth.iBeacon(uuid: uuid, major: 787, minor: 0, rssi: rssi, interval: 800)                                                        
            print("Beacon id = \(beacon)")                                                                                                                     
            do {                                                                                                                                               
                let _ = try peripheral.add(service: ConfigurationProfile.Service)       // ConfigurationProfile.Service is a correctly configured service                                                       
                do {                                                                                                                                           
                    try peripheral.start(beacon: beacon)                                                                                               
                    print("Vending ConfigurationService = \n\(ConfigurationProfile.Service)")                                                  
                } catch {                                                                                                                                      
                    print("failed to start service")                                                                                                           
                    print("Exception: \(error.localizedDescription)")                                                                                          
                }                                                                                                                                              
            } catch {                                                                                                                                          
                print("failed to add service")                                                                                                                 
                print("Exception: \(error.localizedDescription)")                                                                                              
            }                                                                                                                                                  
        }                                                                                                                                                      

Decrease CPU usage when scanning

Use a different strategy that doesn't involve sleep() while scanning to improve energy efficiency and decrease unnecessary CPU usage. DispatchSemaphore might be a good solution.

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.