diff --git a/Package.swift b/Package.swift index 698a9e8..4c1ea9f 100644 --- a/Package.swift +++ b/Package.swift @@ -62,6 +62,10 @@ var package = Package( name: "BluetoothGATT", package: "Bluetooth" ), + .product( + name: "BluetoothGAP", + package: "Bluetooth" + ) ] ) ] diff --git a/Tests/BluetoothLinuxTests/L2CAPTests.swift b/Tests/BluetoothLinuxTests/L2CAPTests.swift index 437e139..98093d9 100644 --- a/Tests/BluetoothLinuxTests/L2CAPTests.swift +++ b/Tests/BluetoothLinuxTests/L2CAPTests.swift @@ -10,6 +10,7 @@ import XCTest import Bluetooth import BluetoothHCI import BluetoothGATT +import BluetoothGAP @testable import BluetoothLinux final class L2CAPTests: XCTestCase { @@ -22,6 +23,23 @@ final class L2CAPTests: XCTestCase { XCTFail() return } + do { + do { try await controller.enableLowEnergyAdvertising(false) } + catch HCIError.commandDisallowed { /* ignore */ } + + let encoder = GAPDataEncoder() + let advertisingData = try encoder.encodeAdvertisingData([ + GAPShortLocalName(name: "Test") + ]) + try await controller.setLowEnergyAdvertisingData(advertisingData) + + do { try await controller.enableLowEnergyAdvertising() } + catch HCIError.commandDisallowed { /* ignore */ } + } + catch { + NSLog("Unable to enable advertising. \(error)") + } + NSLog("Enabled advertising") let address = try await controller.readDeviceAddress() NSLog("Will create server socket \(address)") let serverSocket = try await BluetoothLinux.L2CAPSocket.lowEnergyServer(