Skip to content

Commit

Permalink
updated GATT test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 29, 2016
1 parent fd0e79d commit 2a5ca1a
Showing 1 changed file with 16 additions and 54 deletions.
70 changes: 16 additions & 54 deletions Sources/GATTServerTest/GATTServerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,69 +71,31 @@ private func generateDB() -> GATTDatabase {

var database = GATTDatabase()

for service in TestData.services {
for service in TestProfile.services {

database.add(service: service)
}

return database
}

public struct TestData {
public struct TestProfile {

public static var testService: Service {

return TestData.services[0]
}
public static let services = [TestProfile.TestService]

public static let services: [Service] = {

var services = [Service]()

do {

let characteristic = Characteristic(UUID: .Bit128(UUID(rawValue: "E77D264C-F96F-11E5-80E0-23E070D5A8C7")!), value: "Test Service".toUTF8Data(), permissions: [.Read], properties: [.Read])

let service = Service(UUID: .Bit128(UUID(rawValue: "60F14FE2-F972-11E5-B84F-23E070D5A8C7")!), primary: true, characteristics: [characteristic])

services.append(service)
}

do {

let characteristic = Characteristic(UUID: .Bit128(UUID(rawValue: "135BA27C-F96E-11E5-A76B-23E070D5A8C7")!), value: "Hey".toUTF8Data(), permissions: [.Read, .Write], properties: [.Read, .Write])

let characteristic2 = Characteristic(UUID: .Bit128(UUID(rawValue: "088CAF7A-F96F-11E5-9C9A-23E070D5A8C7")!), value: "Hola".toUTF8Data(), permissions: [.Read, .Write], properties: [.Read, .Write])

let service = Service(UUID: .Bit128(UUID(rawValue: "11030276-F96F-11E5-AA7B-23E070D5A8C7")!), characteristics: [characteristic, characteristic2])

services.append(service)
}

do {

let characteristic = Characteristic(UUID: .Bit128(UUID(rawValue: "16D3B8A8-F96F-11E5-AE5E-23E070D5A8C7")!), value: "Bye".toUTF8Data(), permissions: [.Read, .Write], properties: [.Read, .Write])

let characteristic2 = Characteristic(UUID: .Bit128(UUID(rawValue: "1C9BE9CC-F96F-11E5-A558-23E070D5A8C7")!), value: "Chau".toUTF8Data(), permissions: [.Read, .Write], properties: [.Read, .Write])

let service = Service(UUID: .Bit128(UUID(rawValue: "21C39E9A-F96F-11E5-8CB2-23E070D5A8C7")!), characteristics: [characteristic, characteristic2])

services.append(service)
}

do {

let characteristic = Characteristic(UUID: .Bit128(UUID(rawValue: "2FDDB448-F96F-11E5-A891-23E070D5A8C7")!), value: "Read Only".toUTF8Data(), permissions: [.Read], properties: [.Read])

let characteristic2 = Characteristic(UUID: .Bit128(UUID(rawValue: "37BBD7D0-F96F-11E5-8EC1-23E070D5A8C7")!), value: "Write Only".toUTF8Data(), permissions: [.Write], properties: [.Write])

let service = Service(UUID: .Bit128(UUID(rawValue: "3D1F4D7E-F96F-11E5-8647-23E070D5A8C7")!), characteristics: [characteristic, characteristic2])

services.append(service)
}

return services
}()
public static let TestService = Service(UUID: .Bit128(UUID(rawValue: "60F14FE2-F972-11E5-B84F-23E070D5A8C7")!), primary: true, characteristics: [TestProfile.Read, TestProfile.ReadBlob, TestProfile.Write, TestProfile.WriteBlob])

public static let Read = Characteristic(UUID: .Bit128(UUID(rawValue: "E77D264C-F96F-11E5-80E0-23E070D5A8C7")!), value: "Test Read-Only".toUTF8Data(), permissions: [.Read], properties: [.Read])

public static let ReadBlob = Characteristic(UUID: .Bit128(UUID(rawValue: "0615FF6C-0E37-11E6-9E58-75D7DC50F6B1")!), value: Data(byteValue: [UInt8](repeating: UInt8.max, count: 512)), permissions: [.Read], properties: [.Read])

public static let Write = Characteristic(UUID: .Bit128(UUID(rawValue: "37BBD7D0-F96F-11E5-8EC1-23E070D5A8C7")!), value: Data(), permissions: [.Write], properties: [.Write])

public static let WriteValue = "Test Write".toUTF8Data()

public static let WriteBlob = Characteristic(UUID: .Bit128(UUID(rawValue: "2FDDB448-F96F-11E5-A891-23E070D5A8C7")!), value: Data(), permissions: [.Write], properties: [.Write])

public static let WriteBlobValue = Data(byteValue: [UInt8](repeating: 1, count: 512))
}

public typealias Service = GATT.Service
Expand Down

0 comments on commit 2a5ca1a

Please sign in to comment.