diff --git a/Package.swift b/Package.swift index 2abe296..5506b72 100644 --- a/Package.swift +++ b/Package.swift @@ -13,8 +13,8 @@ let package = Package( ], products: [ .library( - name: "MillerBluetooth", - targets: ["MillerBluetooth"] + name: "BluetoothAccessory", + targets: ["BluetoothAccessory"] ), ], dependencies: [ @@ -33,7 +33,7 @@ let package = Package( ], targets: [ .target( - name: "MillerBluetooth", + name: "BluetoothAccessory", dependencies: [ .product( name: "Bluetooth", @@ -63,8 +63,8 @@ let package = Package( ] ), .testTarget( - name: "MillerBluetoothTests", - dependencies: ["MillerBluetooth"] + name: "BluetoothAccessoryTests", + dependencies: ["BluetoothAccessory"] ), ] ) diff --git a/README.md b/README.md index ae618f8..13b7a78 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# MillerBluetooth -Bluetooth library with custom encryption +# BluetoothAccessory +Bluetooth Accessory library diff --git a/Sources/MillerBluetooth/Advertisement.swift b/Sources/BluetoothAccessory/Advertisement.swift similarity index 100% rename from Sources/MillerBluetooth/Advertisement.swift rename to Sources/BluetoothAccessory/Advertisement.swift diff --git a/Sources/MillerBluetooth/BuildVersion.swift b/Sources/BluetoothAccessory/BuildVersion.swift similarity index 100% rename from Sources/MillerBluetooth/BuildVersion.swift rename to Sources/BluetoothAccessory/BuildVersion.swift diff --git a/Sources/MillerBluetooth/Central.swift b/Sources/BluetoothAccessory/Central.swift similarity index 100% rename from Sources/MillerBluetooth/Central.swift rename to Sources/BluetoothAccessory/Central.swift diff --git a/Sources/MillerBluetooth/CharacteristicType.swift b/Sources/BluetoothAccessory/CharacteristicType.swift similarity index 100% rename from Sources/MillerBluetooth/CharacteristicType.swift rename to Sources/BluetoothAccessory/CharacteristicType.swift diff --git a/Sources/MillerBluetooth/Chunk.swift b/Sources/BluetoothAccessory/Chunk.swift similarity index 100% rename from Sources/MillerBluetooth/Chunk.swift rename to Sources/BluetoothAccessory/Chunk.swift diff --git a/Sources/MillerBluetooth/Credentials.swift b/Sources/BluetoothAccessory/Credentials.swift similarity index 100% rename from Sources/MillerBluetooth/Credentials.swift rename to Sources/BluetoothAccessory/Credentials.swift diff --git a/Sources/MillerBluetooth/Crypto/Authentication.swift b/Sources/BluetoothAccessory/Crypto/Authentication.swift similarity index 100% rename from Sources/MillerBluetooth/Crypto/Authentication.swift rename to Sources/BluetoothAccessory/Crypto/Authentication.swift diff --git a/Sources/MillerBluetooth/Crypto/AuthenticationError.swift b/Sources/BluetoothAccessory/Crypto/AuthenticationError.swift similarity index 100% rename from Sources/MillerBluetooth/Crypto/AuthenticationError.swift rename to Sources/BluetoothAccessory/Crypto/AuthenticationError.swift diff --git a/Sources/MillerBluetooth/Crypto/Crypto.swift b/Sources/BluetoothAccessory/Crypto/Crypto.swift similarity index 93% rename from Sources/MillerBluetooth/Crypto/Crypto.swift rename to Sources/BluetoothAccessory/Crypto/Crypto.swift index 06270a2..4958310 100644 --- a/Sources/MillerBluetooth/Crypto/Crypto.swift +++ b/Sources/BluetoothAccessory/Crypto/Crypto.swift @@ -21,7 +21,7 @@ typealias HMAC = Crypto.HMAC /// Performs HMAC with the specified key and message. internal func authenticationCode(for message: AuthenticationMessage, using key: KeyData) -> AuthenticationData { - let encoder = TLVEncoder.millerBluetooth + let encoder = TLVEncoder.bluetoothAccessory let messageData = try! encoder.encode(message) let authenticationCode = HMAC.authenticationCode(for: messageData, using: SymmetricKey(key)) return AuthenticationData(authenticationCode) @@ -29,7 +29,7 @@ internal func authenticationCode(for message: AuthenticationMessage, using key: /// Encrypt data internal func encrypt(_ data: Data, using key: KeyData, nonce: Nonce, authentication: AuthenticationMessage) throws -> Data { - let encoder = TLVEncoder.millerBluetooth + let encoder = TLVEncoder.bluetoothAccessory let authenticatedData = try! encoder.encode(authentication) do { let sealed = try ChaChaPoly.seal(data, using: SymmetricKey(key), nonce: ChaChaPoly.Nonce(nonce), authenticating: authenticatedData) @@ -41,7 +41,7 @@ internal func encrypt(_ data: Data, using key: KeyData, nonce: Nonce, authentica /// Decrypt data internal func decrypt(_ data: Data, using key: KeyData, authentication: AuthenticationMessage) throws -> Data { - let encoder = TLVEncoder.millerBluetooth + let encoder = TLVEncoder.bluetoothAccessory let authenticatedData = try! encoder.encode(authentication) do { let sealed = try ChaChaPoly.SealedBox(combined: data) @@ -101,7 +101,7 @@ internal extension SymmetricKey { } internal extension ChaChaPoly.Nonce { - init(_ nonce: MillerBluetooth.Nonce) { + init(_ nonce: BluetoothAccessory.Nonce) { try! self.init(data: nonce.data) } } diff --git a/Sources/MillerBluetooth/Crypto/EncryptedData.swift b/Sources/BluetoothAccessory/Crypto/EncryptedData.swift similarity index 84% rename from Sources/MillerBluetooth/Crypto/EncryptedData.swift rename to Sources/BluetoothAccessory/Crypto/EncryptedData.swift index fcf5c57..74ea052 100644 --- a/Sources/MillerBluetooth/Crypto/EncryptedData.swift +++ b/Sources/BluetoothAccessory/Crypto/EncryptedData.swift @@ -33,7 +33,7 @@ public extension EncryptedData { guard authentication.isAuthenticated(using: key) else { throw AuthenticationError.invalidAuthentication } // attempt to decrypt - return try MillerBluetooth.decrypt(encryptedData, using: key, authentication: authentication.message) + return try BluetoothAccessory.decrypt(encryptedData, using: key, authentication: authentication.message) } } @@ -47,7 +47,7 @@ extension EncryptedData: TLVCodable { return nil } let prefix = Data(tlvData.prefix(prefixLength)) - guard let authentication = try? TLVDecoder.millerBluetooth.decode(Authentication.self, from: prefix) else { + guard let authentication = try? TLVDecoder.BluetoothAccessory.decode(Authentication.self, from: prefix) else { return nil } self.authentication = authentication @@ -55,7 +55,7 @@ extension EncryptedData: TLVCodable { } public var tlvData: Data { - let authenticationData = try! TLVEncoder.millerBluetooth.encode(authentication) + let authenticationData = try! TLVEncoder.BluetoothAccessory.encode(authentication) return authenticationData + encryptedData } } diff --git a/Sources/MillerBluetooth/Crypto/SecureData.swift b/Sources/BluetoothAccessory/Crypto/SecureData.swift similarity index 100% rename from Sources/MillerBluetooth/Crypto/SecureData.swift rename to Sources/BluetoothAccessory/Crypto/SecureData.swift diff --git a/Sources/MillerBluetooth/Extensions/Bool.swift b/Sources/BluetoothAccessory/Extensions/Bool.swift similarity index 100% rename from Sources/MillerBluetooth/Extensions/Bool.swift rename to Sources/BluetoothAccessory/Extensions/Bool.swift diff --git a/Sources/MillerBluetooth/Extensions/Date.swift b/Sources/BluetoothAccessory/Extensions/Date.swift similarity index 100% rename from Sources/MillerBluetooth/Extensions/Date.swift rename to Sources/BluetoothAccessory/Extensions/Date.swift diff --git a/Sources/MillerBluetooth/Extensions/Hexadecimal.swift b/Sources/BluetoothAccessory/Extensions/Hexadecimal.swift similarity index 100% rename from Sources/MillerBluetooth/Extensions/Hexadecimal.swift rename to Sources/BluetoothAccessory/Extensions/Hexadecimal.swift diff --git a/Sources/MillerBluetooth/Extensions/Integer.swift b/Sources/BluetoothAccessory/Extensions/Integer.swift similarity index 100% rename from Sources/MillerBluetooth/Extensions/Integer.swift rename to Sources/BluetoothAccessory/Extensions/Integer.swift diff --git a/Sources/MillerBluetooth/Extensions/UUID.swift b/Sources/BluetoothAccessory/Extensions/UUID.swift similarity index 100% rename from Sources/MillerBluetooth/Extensions/UUID.swift rename to Sources/BluetoothAccessory/Extensions/UUID.swift diff --git a/Sources/MillerBluetooth/GATTError.swift b/Sources/BluetoothAccessory/GATTError.swift similarity index 100% rename from Sources/MillerBluetooth/GATTError.swift rename to Sources/BluetoothAccessory/GATTError.swift diff --git a/Sources/MillerBluetooth/GATTProfile.swift b/Sources/BluetoothAccessory/GATTProfile.swift similarity index 100% rename from Sources/MillerBluetooth/GATTProfile.swift rename to Sources/BluetoothAccessory/GATTProfile.swift diff --git a/Sources/MillerBluetooth/ServiceType.swift b/Sources/BluetoothAccessory/ServiceType.swift similarity index 98% rename from Sources/MillerBluetooth/ServiceType.swift rename to Sources/BluetoothAccessory/ServiceType.swift index f815968..dd0281b 100644 --- a/Sources/MillerBluetooth/ServiceType.swift +++ b/Sources/BluetoothAccessory/ServiceType.swift @@ -18,7 +18,7 @@ public enum ServiceType: UInt16, CaseIterable { case firmwareUpdate case wiFiTransport case threadTransport - case loraTransport + case loRaTransport // Energy case battery = 100 diff --git a/Sources/MillerBluetooth/SoftwareVersion.swift b/Sources/BluetoothAccessory/SoftwareVersion.swift similarity index 100% rename from Sources/MillerBluetooth/SoftwareVersion.swift rename to Sources/BluetoothAccessory/SoftwareVersion.swift diff --git a/Sources/MillerBluetooth/TLVCharacteristic.swift b/Sources/BluetoothAccessory/TLVCharacteristic.swift similarity index 91% rename from Sources/MillerBluetooth/TLVCharacteristic.swift rename to Sources/BluetoothAccessory/TLVCharacteristic.swift index 1d05560..9d8b626 100644 --- a/Sources/MillerBluetooth/TLVCharacteristic.swift +++ b/Sources/BluetoothAccessory/TLVCharacteristic.swift @@ -19,9 +19,9 @@ public protocol TLVCharacteristic: GATTProfileCharacteristic { public extension TLVCharacteristic { - static var encoder: TLVEncoder { return .millerBluetooth } + static var encoder: TLVEncoder { return .bluetoothAccessory } - static var decoder: TLVDecoder { return .millerBluetooth } + static var decoder: TLVDecoder { return .bluetoothAccessory } } public extension TLVCharacteristic where Self: Codable { diff --git a/Sources/MillerBluetooth/TLVEncoder.swift b/Sources/BluetoothAccessory/TLVEncoder.swift similarity index 86% rename from Sources/MillerBluetooth/TLVEncoder.swift rename to Sources/BluetoothAccessory/TLVEncoder.swift index 2d1372f..96304c6 100644 --- a/Sources/MillerBluetooth/TLVEncoder.swift +++ b/Sources/BluetoothAccessory/TLVEncoder.swift @@ -10,7 +10,7 @@ import TLVCoding public extension TLVEncoder { - static var millerBluetooth: TLVEncoder { + static var bluetoothAccessory: TLVEncoder { var encoder = TLVEncoder() encoder.numericFormatting = .littleEndian encoder.uuidFormatting = .bytes @@ -21,7 +21,7 @@ public extension TLVEncoder { public extension TLVDecoder { - static var millerBluetooth: TLVDecoder { + static var bluetoothAccessory: TLVDecoder { var decoder = TLVDecoder() decoder.numericFormatting = .littleEndian decoder.uuidFormatting = .bytes diff --git a/Sources/MillerBluetooth/MillerBluetooth.swift b/Sources/MillerBluetooth/MillerBluetooth.swift deleted file mode 100644 index 8b13789..0000000 --- a/Sources/MillerBluetooth/MillerBluetooth.swift +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Tests/BluetoothAccessoryTests/BluetoothAccessoryTests.swift b/Tests/BluetoothAccessoryTests/BluetoothAccessoryTests.swift new file mode 100644 index 0000000..49c3a58 --- /dev/null +++ b/Tests/BluetoothAccessoryTests/BluetoothAccessoryTests.swift @@ -0,0 +1,7 @@ +import XCTest +@testable import BluetoothAccessory + +final class BluetoothAccessoryTests: XCTestCase { + + +} diff --git a/Tests/MillerBluetoothTests/MillerBluetoothTests.swift b/Tests/MillerBluetoothTests/MillerBluetoothTests.swift deleted file mode 100644 index 1712c37..0000000 --- a/Tests/MillerBluetoothTests/MillerBluetoothTests.swift +++ /dev/null @@ -1,7 +0,0 @@ -import XCTest -@testable import MillerBluetooth - -final class MillerBluetoothTests: XCTestCase { - - -}