How pureswift/bluetooth works
Project Type and Purpose
• This is a Swift Package Manager library (“Bluetooth”) providing a multi‐layer implementation of Bluetooth SIG protocols (HCI, L2CAP, GAP, GATT) and utilities (UUIDs, metadata, code‐generation).
• It is a foundation library on which platform‐specific adapters depend (e.g., CoreBluetooth, BlueZ, Web API).
File Structure Analysis
• Top‐level:
• Configuration: .devcontainer, .github/workflows, swiftlint, swift-format.
• Package.swift: SPM manifest defining library targets.
• Assets, LICENSE, README.md.
• Plugins/GenerateBluetoothDefinitions: A Swift‐based code‐generation plugin for Bluetooth identifiers.
• Sources/: Each subfolder is an independent Swift target/module:
• Bluetooth: Core types (Address, UUID, Data), Streams, Extensions.
• BluetoothGAP: Generic Access Profile (advertising, scanning).
• BluetoothGATT: Generic Attribute Profile (services, characteristics, client/server logic).
• BluetoothHCI: Host‐Controller Interface (commands, events, low‐energy primitives).
• BluetoothMacros, BluetoothMetadata: Compile‐time helpers and JSON‐based metadata resources.
• GenerateBluetooth: A command‐line tool for code generation (alternative path to Plugins).
• Tests/: Unit tests for each layer.
README Insights
• Describes core library use (import Bluetooth) and lists supported platforms via external adapter libraries.
Detailed Capturing
• Every SPM target as a distinct component.
• That BluetoothMacros and BluetoothMetadata support the main modules.
• “Package.swift” as orchestrating these modules.