From ed2de11d739bbd0d7eeef612b48d7bbd453f2f39 Mon Sep 17 00:00:00 2001 From: SJ Date: Wed, 27 Nov 2019 11:46:09 -0500 Subject: [PATCH] See issue #36: Added remainder of callbacks, but they don't do anything --- Sources/SwiftyTooth/SwiftyTooth.swift | 40 ++++++++++++++++++++++++++- SwiftyTeeth.xcodeproj/project.pbxproj | 27 ------------------ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Sources/SwiftyTooth/SwiftyTooth.swift b/Sources/SwiftyTooth/SwiftyTooth.swift index a85937b..7a9a867 100644 --- a/Sources/SwiftyTooth/SwiftyTooth.swift +++ b/Sources/SwiftyTooth/SwiftyTooth.swift @@ -47,7 +47,7 @@ public extension SwiftyTooth { } } -// MARK: - Manager Advertise functions +// MARK: - SwiftyTooth Advertise functions public extension SwiftyTooth { var isAdvertising: Bool { @@ -75,6 +75,8 @@ public extension SwiftyTooth { // MARK: - Peripheral manager extension SwiftyTooth: CBPeripheralManagerDelegate { + + // MARK: - Peripheral Manager State Changes public func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { switch (peripheral.state) { case .unknown: @@ -99,8 +101,44 @@ extension SwiftyTooth: CBPeripheralManagerDelegate { stateChangedHandler?(state) } + public func peripheralManager(_ peripheral: CBPeripheralManager, willRestoreState dict: [String : Any]) { + + } + + // MARK: - Peripheral Manager Services + + public func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) { + + } + + // MARK: - Peripheral Manager Advertisments + public func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { Log(v: "Started advertising") print("Started advertising") } + + // MARK: - Peripheral Manager Characteristic Subscriptions + public func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic) { + + } + + public func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic) { + + } + + public func peripheralManagerIsReady(toUpdateSubscribers peripheral: CBPeripheralManager) { + + } + + // MARK: - Peripheral Manager Read/Write requests + public func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest) { + request.value = Data(base64Encoded: "Hello") + peripheralManager.respond(to: request, withResult: .success) + } + + public func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveWrite requests: [CBATTRequest]) { + peripheralManager.respond(to: <#T##CBATTRequest#>, withResult: <#T##CBATTError.Code#>) + } + } diff --git a/SwiftyTeeth.xcodeproj/project.pbxproj b/SwiftyTeeth.xcodeproj/project.pbxproj index cbcf8e0..1a38fc9 100644 --- a/SwiftyTeeth.xcodeproj/project.pbxproj +++ b/SwiftyTeeth.xcodeproj/project.pbxproj @@ -146,10 +146,7 @@ isa = PBXGroup; children = ( 8B64D1951DC2E39900D41A2C /* Enums */, - 8B64D1961DC2E39900D41A2C /* Errors */, 8B64D1971DC2E39900D41A2C /* Extensions */, - 8B64D1981DC2E39900D41A2C /* Helpers */, - 8B64D1991DC2E39900D41A2C /* Logging */, 8B64D19A1DC2E39900D41A2C /* Models */, 8B64D19C1DC2E39900D41A2C /* Protocols */, 8B64D19E1DC2E39900D41A2C /* Security */, @@ -219,14 +216,6 @@ path = Enums; sourceTree = ""; }; - 8B64D1961DC2E39900D41A2C /* Errors */ = { - isa = PBXGroup; - children = ( - ); - name = Errors; - path = ../Errors; - sourceTree = ""; - }; 8B64D1971DC2E39900D41A2C /* Extensions */ = { isa = PBXGroup; children = ( @@ -238,22 +227,6 @@ path = Extensions; sourceTree = ""; }; - 8B64D1981DC2E39900D41A2C /* Helpers */ = { - isa = PBXGroup; - children = ( - ); - name = Helpers; - path = ../Helpers; - sourceTree = ""; - }; - 8B64D1991DC2E39900D41A2C /* Logging */ = { - isa = PBXGroup; - children = ( - ); - name = Logging; - path = ../Logging; - sourceTree = ""; - }; 8B64D19A1DC2E39900D41A2C /* Models */ = { isa = PBXGroup; children = (