Skip to content

Commit

Permalink
Merge pull request #33 from PureSwift/feature/embedded
Browse files Browse the repository at this point in the history
Add Embedded Swift support
  • Loading branch information
colemancda authored Nov 15, 2024
2 parents 113a71d + 198bf60 commit 38225c4
Show file tree
Hide file tree
Showing 33 changed files with 1,089 additions and 954 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Choice] Swift version: 5.6-focal, 5.5, 5.4, 5.3, 5.2, 5.1, 4.2
ARG VARIANT=5.7.1-jammy
ARG VARIANT=6.0.2-jammy
FROM swift:${VARIANT}

# [Option] Install zsh
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a Swift version
"VARIANT": "5.7.1-jammy",
"VARIANT": "6.0.2-jammy",
// Options
"NODE_VERSION": "lts/*",
"UPGRADE_PACKAGES": "true"
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/buildroot.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/swift-arm.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/swift-wasm.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Swift
uses: slashmo/[email protected]
with:
version: 5.8
version: 6.0.2
- name: Checkout
uses: actions/checkout@v2
- name: Swift Version
Expand All @@ -25,7 +25,7 @@ jobs:
name: Linux
strategy:
matrix:
swift: [5.6.3, 5.7.3, 5.8]
swift: [6.0.2]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
Expand Down
19 changes: 8 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:6.0
import PackageDescription
import class Foundation.ProcessInfo

Expand All @@ -8,12 +8,6 @@ let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrar

var package = Package(
name: "GATT",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(
name: "GATT",
Expand All @@ -22,13 +16,14 @@ var package = Package(
),
.library(
name: "DarwinGATT",
type: libraryType,
targets: ["DarwinGATT"]
)
],
dependencies: [
.package(
url: "https://github.com/PureSwift/Bluetooth.git",
.upToNextMajor(from: "6.0.0")
branch: "master"
)
],
targets: [
Expand All @@ -53,7 +48,7 @@ var package = Package(
name: "BluetoothHCI",
package: "Bluetooth",
condition: .when(platforms: [.macOS, .linux])
),
)
]
),
.target(
Expand All @@ -65,7 +60,8 @@ var package = Package(
package: "Bluetooth",
condition: .when(platforms: [.macOS])
)
]
],
swiftSettings: [.swiftLanguageMode(.v5)]
),
.testTarget(
name: "GATTTests",
Expand All @@ -90,7 +86,8 @@ var package = Package(
package: "Bluetooth",
condition: .when(platforms: [.macOS, .linux])
)
]
],
swiftSettings: [.swiftLanguageMode(.v5)]
)
]
)
Expand Down
9 changes: 5 additions & 4 deletions Sources/DarwinGATT/DarwinAdvertisementData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
// Created by Alsey Coleman Miller on 7/15/18.
//

import Foundation
@preconcurrency import Foundation
import Bluetooth
import GATT

#if canImport(CoreBluetooth)

import CoreBluetooth

/// CoreBluetooth Adverisement Data
public struct DarwinAdvertisementData: AdvertisementData {

public typealias Data = Foundation.Data

// MARK: - Properties

internal let data: [String: NSObject]
Expand Down Expand Up @@ -69,10 +70,10 @@ public extension DarwinAdvertisementData {
}

/// The Manufacturer data of a peripheral.
var manufacturerData: ManufacturerSpecificData? {
var manufacturerData: ManufacturerSpecificData<Foundation.Data>? {

guard let manufacturerDataBytes = data[CBAdvertisementDataManufacturerDataKey] as? Data,
let manufacturerData = ManufacturerSpecificData(data: manufacturerDataBytes)
let manufacturerData = ManufacturerSpecificData<Data>(data: manufacturerDataBytes)
else { return nil }

return manufacturerData
Expand Down
8 changes: 4 additions & 4 deletions Sources/DarwinGATT/DarwinAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ internal protocol CoreBluetoothAttributeConvertible {
func toCoreBluetooth() -> CoreBluetoothPeripheralType
}

extension GATTAttribute.Service: CoreBluetoothAttributeConvertible {
extension GATTAttribute.Service: CoreBluetoothAttributeConvertible where Data == Foundation.Data {

func toCoreBluetooth() -> CBMutableService {

let service = CBMutableService(type: CBUUID(uuid), primary: primary)
let service = CBMutableService(type: CBUUID(uuid), primary: isPrimary)
service.characteristics = characteristics.map { $0.toCoreBluetooth() }
return service
}
}

extension GATTAttribute.Characteristic: CoreBluetoothAttributeConvertible {
extension GATTAttribute.Characteristic: CoreBluetoothAttributeConvertible where Data == Foundation.Data {

func toCoreBluetooth() -> CBMutableCharacteristic {

Expand All @@ -53,7 +53,7 @@ extension GATTAttribute.Characteristic: CoreBluetoothAttributeConvertible {
}
}

extension GATTAttribute.Descriptor: CoreBluetoothAttributeConvertible {
extension GATTAttribute.Descriptor: CoreBluetoothAttributeConvertible where Data == Foundation.Data {

func toCoreBluetooth() -> CBMutableDescriptor {

Expand Down
2 changes: 1 addition & 1 deletion Sources/DarwinGATT/DarwinBluetoothState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CoreBluetooth
/// Darwin Bluetooth State
///
/// - SeeAlso: [CBManagerState](https://developer.apple.com/documentation/corebluetooth/cbmanagerstate).
@objc public enum DarwinBluetoothState: Int {
@objc public enum DarwinBluetoothState: Int, Sendable, CaseIterable {

case unknown
case resetting
Expand Down
Loading

0 comments on commit 38225c4

Please sign in to comment.