{"id":20183294,"url":"https://github.com/sorz/gattkt","last_synced_at":"2025-08-10T04:41:26.598Z","repository":{"id":145451522,"uuid":"252687339","full_name":"sorz/gattkt","owner":"sorz","description":"Android library that convert `BluetoothGattCallback` to ergonomic Kotlin coroutines API.","archived":false,"fork":false,"pushed_at":"2020-06-05T09:33:12.000Z","size":77,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T14:19:34.691Z","etag":null,"topics":["android-bluetooth","android-library"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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/sorz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-04-03T09:25:53.000Z","updated_at":"2023-07-03T10:18:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"ebb6c1b3-cdb4-47ea-aa63-b1c9a512bf8c","html_url":"https://github.com/sorz/gattkt","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sorz/gattkt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fgattkt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fgattkt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fgattkt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fgattkt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorz","download_url":"https://codeload.github.com/sorz/gattkt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorz%2Fgattkt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269677505,"owners_count":24457857,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["android-bluetooth","android-library"],"created_at":"2024-11-14T02:45:03.623Z","updated_at":"2025-08-10T04:41:26.558Z","avatar_url":"https://github.com/sorz.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GattKt\n\nAndroid library that convert `BluetoothGattCallback` to ergonomic Kotlin\ncoroutines API.\n\nSee also [sorz/blescanner](https://github.com/sorz/blescanner) for library\nthat scan BLE device with Kotlin coroutines.\n\nCurrent support:\n\n- [x] Connect to GATT server and discovery GATT services\n- [x] Write an characteristic\n- [x] Enable/disable notification/indication (with necessary descriptor set)\n- [x] Read notification/indication value\n\nPR is welcome if you need more functions.\n\n## Install\n\n- Add [JitPack](https://jitpack.io/) to your build file.\n- Add `implementation 'com.github.sorz:gattkt:{VERSION}`\n\n## Example\n\n```kotlin\nsuspend fun handleAwesomeDevice(context: Context, device: BluetoothDevice) {\n    val gattIo = device.connectGattIo(context)\n    val char = gattIo.requireCharacteristic(UUID_SOME_SERVICE, UUID_SOME_CHAR)\n\n    gattIo.enableNotification(char)\n    gattIo.writeCharacteristic(char, byteArrayOf(...))\n    val resp = gattIo.readCharacteristicChange(char)\n    println(\"response: ${resp.contentToString()}\")\n    gattIo.disableNotificationOrIndication(char)\n\n    gattIo.gatt.close()\n}\n```\n\nReal-world example:\n[MiBand.kt](https://github.com/sorz/miband4-export/blob/master/app/src/main/java/cn/edu/sustech/cse/miband/MiBand.kt)\n\n## Debugging\nLogs don't get printed by default. To enable logging, execute:\n\n```bash\nadb shell setprop log.tag.GattIo debug\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorz%2Fgattkt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorz%2Fgattkt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorz%2Fgattkt/lists"}