{"id":13872311,"url":"https://github.com/PureSwift/GATT","last_synced_at":"2025-07-16T02:30:37.005Z","repository":{"id":7900550,"uuid":"55267957","full_name":"PureSwift/GATT","owner":"PureSwift","description":"Bluetooth Generic Attribute Profile (GATT) for Swift","archived":false,"fork":false,"pushed_at":"2024-11-18T09:53:09.000Z","size":1767,"stargazers_count":64,"open_issues_count":2,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-18T10:58:51.123Z","etag":null,"topics":["bluetooth","bluetooth-low-energy","corebluetooth","embedded","gatt","iot","linux","swift"],"latest_commit_sha":null,"homepage":"http://pureswift.github.io/GATT/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PureSwift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-01T23:20:46.000Z","updated_at":"2024-11-18T09:53:13.000Z","dependencies_parsed_at":"2022-11-28T10:34:08.793Z","dependency_job_id":"b078ba2f-b399-4000-9978-a421801816ce","html_url":"https://github.com/PureSwift/GATT","commit_stats":{"total_commits":707,"total_committers":4,"mean_commits":176.75,"dds":0.004243281471004279,"last_synced_commit":"aec59a4c95f3653b8db32cf0181625eab9f4978f"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PureSwift%2FGATT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PureSwift%2FGATT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PureSwift%2FGATT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PureSwift%2FGATT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PureSwift","download_url":"https://codeload.github.com/PureSwift/GATT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226095664,"owners_count":17572970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","bluetooth-low-energy","corebluetooth","embedded","gatt","iot","linux","swift"],"created_at":"2024-08-05T23:00:39.382Z","updated_at":"2024-11-23T20:30:53.610Z","avatar_url":"https://github.com/PureSwift.png","language":"Swift","readme":"# GATT\n\n[![Swift][swift-badge]][swift-url]\n[![Platform][platform-badge]][platform-url]\n[![Release][release-badge]][release-url]\n[![License][mit-badge]][mit-url]\n\nBluetooth Generic Attribute Profile (GATT) for Swift\n\n## Installation \n\nGATT is available as a Swift Package Manager package. To use it, add the following dependency in your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/PureSwift/GATT.git\", branch: \"master\"),\n```\n\nand to your target, add `GATT` to your dependencies. You can then `import GATT` to get access to GATT functionality.\n\n## Platforms\n\n| Platform | Roles | Backend | Library |\n| ---- | -------- | --- | ----------- | \n| macOS, iOS, watchOS, tvOS, visionOS | Central, Peripheral | [CoreBluetooth](https://developer.apple.com/documentation/corebluetooth) | [DarwinGATT](https://github.com/PureSwift/GATT) |\n| Linux | Central, Peripheral | [BlueZ](https://www.bluez.org) | [BluetoothLinux](https://github.com/PureSwift/BluetoothLinux), [GATT](https://github.com/PureSwift/GATT)\n| Android | Central | [Java Native Interface](https://developer.android.com/training/articles/perf-jni) | [AndroidBluetooth](https://github.com/PureSwift/AndroidBluetooth)\n| WebAssembly | Central | [Bluetooth Web API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API) | [BluetoothWeb](https://github.com/PureSwift/BluetoothWeb)\n| Pi Pico W | Peripheral | [BlueKitchen BTStack](https://bluekitchen-gmbh.com/btstack/#quick_start/index.html) | [BTStack](https://github.com/MillerTechnologyPeru/BTStack)\n| ESP32 | Peripheral | [Apache NimBLE](https://mynewt.apache.org/latest/network/index.html) | [NimBLE](https://github.com/MillerTechnologyPeru/NimBLE)\n| nRF52840 | Peripheral | [Zephyr SDK](https://zephyrproject.org) | [Zephyr](https://github.com/MillerTechnologyPeru/Zephyr-Swift)\n\n## Usage\n\n### Peripheral\n\n```swift\nimport Bluetooth\n#if canImport(Darwin)\nimport DarwinGATT\n#elseif os(Linux)\nimport BluetoothLinux\n#endif\n\n#if os(Linux)\ntypealias LinuxPeripheral = GATTPeripheral\u003cBluetoothLinux.HostController, BluetoothLinux.L2CAPSocket\u003e\nguard let hostController = await HostController.default else {\n    fatalError(\"No Bluetooth hardware connected\")\n}\nlet serverOptions = GATTPeripheralOptions(\n    maximumTransmissionUnit: .max,\n    maximumPreparedWrites: 1000\n)\nlet peripheral = LinuxPeripheral(\n    hostController: hostController,\n    options: serverOptions,\n    socket: BluetoothLinux.L2CAPSocket.self\n)\n#elseif canImport(Darwin)\nlet peripheral = DarwinPeripheral()\n#else\n#error(\"Unsupported platform\")\n#endif\n\n// start advertising\ntry await peripheral.start()\n\n```\n\n### Central\n\n```swift\nimport Bluetooth\n#if canImport(Darwin)\nimport DarwinGATT\n#elseif os(Linux)\nimport BluetoothLinux\n#endif\n\n#if os(Linux)\ntypealias LinuxCentral = GATTCentral\u003cBluetoothLinux.HostController, BluetoothLinux.L2CAPSocket\u003e\nlet hostController = await HostController.default\nlet central = LinuxCentral(\n    hostController: hostController,\n    socket: BluetoothLinux.L2CAPSocket.self\n)\n#elseif canImport(Darwin)\nlet central = DarwinCentral()\n#else\n#error(\"Unsupported platform\")\n#endif\n\n// start scanning\nlet stream = try await central.scan(filterDuplicates: true)\nfor try await scanData in stream {\n    print(scanData)\n    stream.stop()\n}\n\n```\n\n## Documentation\n\nRead the documentation [here](http://pureswift.github.io/GATT/documentation/gatt/).\nDocumentation can be generated with [DocC](https://github.com/apple/swift-docc).\n\nLicense\n-------\n\n**GATT** is released under the MIT license. See LICENSE for details.\n\n[swift-badge]: https://img.shields.io/badge/swift-6.0-F05138.svg \"Swift 6.0\"\n[swift-url]: https://swift.org\n[platform-badge]: https://img.shields.io/badge/platform-macOS%20%7C%20iOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20Linux%20%7C%20Android-lightgrey.svg\n[platform-url]: https://swift.org\n[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[mit-url]: https://tldrlegal.com/license/mit-license\n[build-status-badge]: https://github.com/PureSwift/GATT/workflows/Swift/badge.svg\n[build-status-url]: https://github.com/PureSwift/GATT/actions\n[release-badge]: https://img.shields.io/github/release/PureSwift/GATT.svg\n[release-url]: https://github.com/PureSwift/GATT/releases\n[docs-url]: http://pureswift.github.io/GATT/documentation/GATT/\n","funding_links":[],"categories":["Swift"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPureSwift%2FGATT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPureSwift%2FGATT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPureSwift%2FGATT/lists"}