From 43be2d5bcfeca8b86dc293c9e578aabcf7cd9261 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 18 Sep 2023 00:12:25 -0400 Subject: [PATCH] Updated unit tests --- Tests/BluetoothLinuxTests/L2CAPTests.swift | 66 +++++++++++++++++++--- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/Tests/BluetoothLinuxTests/L2CAPTests.swift b/Tests/BluetoothLinuxTests/L2CAPTests.swift index cacdaab..437e139 100644 --- a/Tests/BluetoothLinuxTests/L2CAPTests.swift +++ b/Tests/BluetoothLinuxTests/L2CAPTests.swift @@ -30,19 +30,67 @@ final class L2CAPTests: XCTestCase { NSLog("Created server socket") let newConnection = try await serverSocket.accept() NSLog("Server Connected") - let characteristic = GATTAttribute.Characteristic( - uuid: GATTManufacturerNameString.uuid, - value: GATTManufacturerNameString(rawValue: "PureSwift").data, - permissions: [.read], - properties: [.read], - descriptors: [] - ) let service = GATTAttribute.Service( uuid: .deviceInformation, primary: true, - characteristics: [characteristic] + characteristics: [ + GATTAttribute.Characteristic( + uuid: GATTManufacturerNameString.uuid, + value: GATTManufacturerNameString(rawValue: "PureSwift").data, + permissions: [.read], + properties: [.read], + descriptors: [] + ), + GATTAttribute.Characteristic( + uuid: GATTModelNumber.uuid, + value: GATTModelNumber(rawValue: "SolarInverter1,1").data, + permissions: [.read], + properties: [.read], + descriptors: [] + ), + GATTAttribute.Characteristic( + uuid: GATTHardwareRevisionString.uuid, + value: GATTHardwareRevisionString(rawValue: "1.0.0").data, + permissions: [.read], + properties: [.read], + descriptors: [] + ), + GATTAttribute.Characteristic( + uuid: GATTFirmwareRevisionString.uuid, + value: GATTFirmwareRevisionString(rawValue: "1.0.1").data, + permissions: [.read], + properties: [.read], + descriptors: [] + ), + ] + ) + let service2 = GATTAttribute.Service( + uuid: .savantSystems, + primary: true, + characteristics: [ + GATTAttribute.Characteristic( + uuid: .savantSystems2, + value: GATTManufacturerNameString(rawValue: "PureSwift").data, + permissions: [.read, .write], + properties: [.read, .write], + descriptors: [] + ) + ] + ) + let batteryService = GATTAttribute.Service( + uuid: .batteryService, + primary: true, + characteristics: [ + GATTAttribute.Characteristic( + uuid: .batteryService, + value: GATTBatteryLevel(level: .init(rawValue: 95)!).data, + permissions: [.read], + properties: [.read], + descriptors: [] + ) + ] ) - let database = GATTDatabase(services: [service]) + let database = GATTDatabase(services: [service, service2, batteryService]) var logs = [String]() let server = await GATTServer( socket: newConnection,