-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d2d629
commit e459f76
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// swift-tools-version: 5.10 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Gattlib", | ||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "Gattlib", | ||
targets: ["Gattlib"]), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.target(name: "Gattlib", path: "swift/Gattlib"), | ||
.executableTarget( | ||
name: "GattlibExample", | ||
dependencies: [ "Gattlib" ], | ||
path: "swift/GattlibExample"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import Foundation | ||
|
||
public typealias dispatch_queue_t = Any | ||
|
||
public let CBCentralManagerScanOptionAllowDuplicatesKey = "CBCentralManagerScanOptionAllowDuplicatesKey" | ||
public let CBAdvertisementDataLocalNameKey = "CBAdvertisementDataLocalNameKey" | ||
|
||
public enum CBCharacteristicWriteType { | ||
case withResponse | ||
case withoutResponse | ||
} | ||
|
||
public class CBUUID : Equatable { | ||
let uuid: UUID? | ||
|
||
public init(string: String) { | ||
self.uuid = UUID(uuidString: string) | ||
} | ||
|
||
public static func == (left: CBUUID, right: CBUUID) -> Bool { | ||
return left.uuid == right.uuid | ||
} | ||
} | ||
|
||
public class CBManager { | ||
public enum CBManagerState { | ||
case poweredOn | ||
case poweredOff | ||
case unsupported | ||
case resetting | ||
case unauthorized | ||
case unknown | ||
} | ||
public var state: CBManagerState | ||
|
||
init(state: CBManagerState) { | ||
self.state = state | ||
} | ||
} | ||
|
||
public class CBPeer : Equatable { | ||
public var identifier: UUID | ||
|
||
init(identifier: UUID) { | ||
self.identifier = identifier | ||
} | ||
|
||
public static func == (left: CBPeer, right: CBPeer) -> Bool { | ||
return left.identifier == right.identifier | ||
} | ||
} | ||
|
||
public class CBAttribute { | ||
public var uuid: CBUUID | ||
|
||
init(uuid: CBUUID) { | ||
self.uuid = uuid | ||
} | ||
} | ||
|
||
public class CBMutableService { | ||
|
||
} | ||
|
||
public class CBCentralManager : CBManager { | ||
init(delegate: (any CBCentralManagerDelegate)?, queue: dispatch_queue_t?, options: [String : Any]?) { | ||
super.init(state: .unknown) | ||
} | ||
|
||
func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil) { | ||
|
||
} | ||
|
||
func stopScan() { | ||
|
||
} | ||
|
||
func connect(_ peripheral: CBPeripheral, options: [String : Any]? = nil) { | ||
|
||
} | ||
} | ||
|
||
public protocol CBCentralManagerDelegate { | ||
|
||
} | ||
|
||
public class CBService : CBAttribute { | ||
var characteristics: [CBCharacteristic]? | ||
} | ||
|
||
public protocol CBPeripheralDelegate { | ||
|
||
} | ||
|
||
public class CBCharacteristic : CBAttribute { | ||
var service: CBService? | ||
var value: Data? | ||
} | ||
|
||
public class CBPeripheral : CBPeer { | ||
var name: String? | ||
var delegate: (any CBPeripheralDelegate)? | ||
var services: [CBService]? | ||
|
||
func discoverServices(_ serviceUUIDs: [CBUUID]?) { | ||
|
||
} | ||
|
||
func discoverCharacteristics(_ characteristicUUIDs: [CBUUID]?, for service: CBService) { | ||
|
||
} | ||
|
||
func setNotifyValue(_ enabled: Bool, for characteristic: CBCharacteristic) { | ||
|
||
} | ||
|
||
func writeValue(_ data: Data, for: CBCharacteristic, type: CBCharacteristicWriteType) { | ||
|
||
} | ||
|
||
func maximumWriteValueLength(for type: CBCharacteristicWriteType) -> Int { | ||
assert(false) | ||
return -1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Hello World!") |