{"id":22556573,"url":"https://github.com/property404/lionchief-controller","last_synced_at":"2025-04-10T05:34:00.023Z","repository":{"id":37558007,"uuid":"323206967","full_name":"Property404/lionchief-controller","owner":"Property404","description":"Python script to control LionChief model train through Bluetooth","archived":false,"fork":false,"pushed_at":"2023-12-15T14:23:48.000Z","size":13,"stargazers_count":26,"open_issues_count":1,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T06:51:45.844Z","etag":null,"topics":["bluetooth","bluetooth-low-energy","iot","lionel","trains"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Property404.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}},"created_at":"2020-12-21T02:06:16.000Z","updated_at":"2025-02-25T03:00:14.000Z","dependencies_parsed_at":"2022-08-27T14:06:13.377Z","dependency_job_id":null,"html_url":"https://github.com/Property404/lionchief-controller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Property404%2Flionchief-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Property404%2Flionchief-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Property404%2Flionchief-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Property404%2Flionchief-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Property404","download_url":"https://codeload.github.com/Property404/lionchief-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248163211,"owners_count":21057889,"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","iot","lionel","trains"],"created_at":"2024-12-07T19:13:20.192Z","updated_at":"2025-04-10T05:33:59.925Z","avatar_url":"https://github.com/Property404.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LionChief Controller\n\nScript for controlling a LionChief train via Bluetooth\n\n## About\n\nLionChief trains can be controlled via Bluetooth(BLE, not classic) from a smart phone\nusing the LionChief app.  \n\nAndroid has a bluetooth snooping feature. Using this with Wireshark, I was able\nto figure out which GATT/ATT handle and value pairs to use to change speed,\nmake noise, and more.  \n\nAll basic commands use handle 0x25 (UUID 08590f7e-db05-467e-8757-72f6faeb13d4).\nEach command starts with 0x00, and ends with a checksum. Interestingly, the\ntrain doesn't seem to actually -check- the checksum, but it's possibly logged\nsomewhere? I included the checksum calculation in the `LionChief` class, anyway.  \n\n### Commands (excluding checksum and leading zero)\n\nHorn start: `48 01`  \nHorn stop : `48 00`  \nBell start: `47 01`  \nBell stop : `47 00`  \nSpeech    : `4d XX 00`  \nSet speed : `45 \u003c00-1f\u003e`  \nForward   : `46 01`  \nReverse   : `46 02`  \nDisconnect: `4b 0 0`  \nSet master volume: `4b \u003c00-07\u003e`  \nSet steam chuff volume: `4c \u003c00-07\u003e`  \nSet horn volume/pitch:  `44 01 \u003c00-0f\u003e \u003cfe-02\u003e`  \nSet bell volume/pitch: `44 02 \u003c00-0f\u003e \u003cfe-02\u003e`  \nSet speech volume/pitch: `44 03 \u003c00-0f\u003e \u003cfe-02\u003e`  \nSet engine volume/pitch: `44 04 \u003c00-0f\u003e \u003cfe-02\u003e`  \nSet lights off: `51 00`  \nSet lights on: `51 01`  \n\nIf the first parameter of the speech command is 0, the saying will be random.\nOtherwise each value corresponds to a specific saying. Not sure what the\nsecond parameter does.\n\n\n## Troubleshooting\n\n* Note that the speaker for at least some (if not all) Lionel trains is in the\ntender; if it's not hooked up, the train will not make any sounds\n* Some values like pitch are signed. Negative values are represented in 2's\ncompliment\n\n## Usage\n\nDemo usage can be found in `demo.py`. Make sure to change the MAC address\n\n## Requirements\n\nTested with Python 3.9. Not expected to work outside Linux  \n`pygatt`  \n`pybluez`  \n\n## Helpful Links for Future Projects\n\n[The Practical Guide to Hacking BLE](https://blog.attify.com/the-practical-guide-to-hacking-bluetooth-low-energy/)  \n[How to sniff Bluetooth traffic on Andorid](https://stackoverflow.com/questions/23877761/sniffing-logging-your-own-android-bluetooth-traffic)  \n[About ATT and GATT](https://epxx.co/artigos/bluetooth_gatt.html)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproperty404%2Flionchief-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproperty404%2Flionchief-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproperty404%2Flionchief-controller/lists"}