{"id":19691219,"url":"https://github.com/wideopensource/pygatttool","last_synced_at":"2025-09-04T16:37:38.123Z","repository":{"id":182756448,"uuid":"619238875","full_name":"wideopensource/pygatttool","owner":"wideopensource","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-26T17:18:57.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T17:43:54.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wideopensource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-26T17:10:13.000Z","updated_at":"2023-03-26T17:19:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9a93564-249f-4b50-8c29-ca2bd7bfc717","html_url":"https://github.com/wideopensource/pygatttool","commit_stats":null,"previous_names":["wideopensource/pygatttool"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fpygatttool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fpygatttool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fpygatttool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wideopensource%2Fpygatttool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wideopensource","download_url":"https://codeload.github.com/wideopensource/pygatttool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240996886,"owners_count":19891063,"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":[],"created_at":"2024-11-11T19:08:25.757Z","updated_at":"2025-02-27T08:59:28.535Z","avatar_url":"https://github.com/wideopensource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyGatttool\n\nA wrapper around `gatttool` and `pexpect`, intended to be used as a simple BLE development tool for interacting with peripheral devices.\n\n## Requirements\n\nA working `gatttool` install. \n\nIf installing from the repo you need `pexpect` (`pip install pexpect`).\n\n## Installation\n\n```\npip install pygatttool\n```\n\n## Usage\n\nThe following code (from [polarpy](https://github.com/wideopensource/polarpy)) starts the raw PPG stream on a Polar OH1. The address and attribute handles for your particular device can be found using `gatttool` or another BLE tool such as nRF Connect.\n\n```\nfrom pygatttool import PyGatttool\n\nOH1_ADDR = \"XX:XX:XX:XX:XX:XX\"\nOH1_CONTROL_ATTRIBUTE_HANDLE = 0xXX\nOH1_DATA_ATTRIBUTE_HANDLE = 0xXX\n\nif '__main__' == __name__:\n    ble = PyGatttool(address=OH1_ADDR)\n\n    ble.connect()\n    ble.mtu(232)\n    ble.char_write_req(handle=OH1_CONTROL_ATTRIBUTE_HANDLE + 1, value=0x200)\n    ble.char_write_req(handle=OH1_DATA_ATTRIBUTE_HANDLE + 1, value=0x100)\n    ble.char_write_cmd(handle=OH1_CONTROL_ATTRIBUTE_HANDLE, b'\\x02\\x01\\x00\\x01\\x82\\x00\\x01\\x01\\x16\\x00')\n\n    while True:\n        print(ble.wait_for_notification(handle=OH1_DATA_ATTRIBUTE_HANDLE))\n```\n\nthe output will look something like this:\n\n```\n01 00 b2 92 28 f4 52 82 07 00 ce ff 03 71 54 05 f3 60 05 a8 f2 ff 30 00 04 c6 54 05 07 60 05 8a f2 ff 3a ff 03 8c 54 05 88 5f 05 65 f2 ff 97 ff 03 e4 54 05 04 5f 05 41 f2 ff 17 ff 03 d6 54 05 70 5e 05 18 f2 ff a7 ff 03 6d 54 05 4f 5e 05 4b f2 ff 78 ff 03 8b 54 05 5b 5e 05 0b f2 ff 3f 00 04 48 54 05 a0 5e 05 08 f2 ff 18 00 04 f3 54 05 ca 5e 05 13 f2 ff 93 ff 03 84 54 05 67 5f 05 08 f2 ff 26 00 04 66 55 05 f1 5e 05 34 f2 ff e0 ff 03 be 55 05 81 5f 05 0b f2 ff dc ff 03 b2 55 05 c1 5f 05 0b f2 ff 75 00 04 b5 56 05 2b 60 05 2c f2 ff a8 ff 03 a5 56 05 6b 60 05 d6 f1 ff 89 00 04 57 57 05 88 60 05 3a f2 ff d9 00 04 55 57 05 33 61 05 3b f2 ff 45 01 04 7f 57 05 a0 61 05 38 f2 ff \n01 00 b2 72 30 f4 52 82 07 00 4e 01 04 a0 58 05 f2 60 05 49 f1 ff a2 01 04 a6 58 05 28 62 05 3e f2 ff 5f 02 04 41 59 05 9a 62 05 37 f2 ff 16 02 04 1a 5a 05 34 63 05 4e f2 ff 43 02 04 1d 5a 05 1e 63 05 47 f2 ff 05 03 04 ea 5a 05 ba 63 05 3f f2 ff 18 03 04 aa 5a 05 93 64 05 4a f2 ff a7 03 04 b1 5b 05 82 64 05 e6 f1 ff 6f 03 04 ff 5b 05 47 65 05 0d f2 ff e3 03 04 3c 5c 05 47 65 05 51 f2 ff 7b 04 04 db 5c 05 d7 65 05 8d f2 ff 98 04 04 d6 5c 05 3a 66 05 45 f2 ff 38 05 04 d3 5d 05 b3 66 05 5b f2 ff 72 05 04 7d 5d 05 ea 66 05 9d f2 ff b4 05 04 b2 5e 05 3d 67 05 4c f2 ff 8f 05 04 4b 5e 05 57 67 05 61 f2 ff 3c 06 04 ca 5e 05 66 67 05 2d f2 ff fe 05 04 2e 5f 05 93 67 05 16 f2 ff \n\n...\n```\n\n## Issues\n\n- While readily available, `gatttool` is long deprecated.\n\n- It is somewhat unfortunate that `gatttool` does not appear report a version number. The `pexpect` code is looking for specific response strings, so if those strings change even slightly between versions it will break PyGatttool. That being said, it has been tested on several versions of Ubuntu 20+ without any issues, and given the deprecation it is probably unlikely that it will change. \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwideopensource%2Fpygatttool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwideopensource%2Fpygatttool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwideopensource%2Fpygatttool/lists"}