{"id":13801223,"url":"https://github.com/Carglglz/upyble","last_synced_at":"2025-05-13T11:31:01.625Z","repository":{"id":57477319,"uuid":"265602315","full_name":"Carglglz/upyble","owner":"Carglglz","description":"Command line tool for Bluetooth Low Energy MicroPython devices","archived":false,"fork":false,"pushed_at":"2020-08-20T18:22:34.000Z","size":4918,"stargazers_count":20,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T09:52:05.150Z","etag":null,"topics":["ble","bluetooth-low-energy","cli","embedded","micropython","python","repl","shell","terminal"],"latest_commit_sha":null,"homepage":null,"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/Carglglz.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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-05-20T15:07:44.000Z","updated_at":"2025-01-09T11:40:11.000Z","dependencies_parsed_at":"2022-09-26T17:41:05.832Z","dependency_job_id":null,"html_url":"https://github.com/Carglglz/upyble","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupyble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupyble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupyble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Carglglz%2Fupyble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Carglglz","download_url":"https://codeload.github.com/Carglglz/upyble/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932786,"owners_count":21986448,"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":["ble","bluetooth-low-energy","cli","embedded","micropython","python","repl","shell","terminal"],"created_at":"2024-08-04T00:01:20.685Z","updated_at":"2025-05-13T11:30:56.613Z","avatar_url":"https://github.com/Carglglz.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"\u003cimg align=\"right\" width=\"200\" height=\"100\" src=\"https://raw.githubusercontent.com/Carglglz/upyble/master/uPyblelogo.png\"\u003e\n\n# uPyble\n\n[![PyPI version](https://badge.fury.io/py/upyble.svg)](https://badge.fury.io/py/upyble)[![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/)\n\n### Command line tool for Bluetooth Low Energy  devices\n\n**uPyble** is intended to be a command line tool [upydev-like](https://github.com/Carglglz/upydev/) to make easier the development, prototyping and testing process of devices based on boards running *MicroPython with **Bluetooth Low Energy** capabilities.\n\n\\*( Any other BLE device should work as well)\n\n⚠️ ***Keep in mind that this project is in ALPHA state, sometimes, some commands may not work/return anything*** ⚠️\n\n### Features:\n\n* Command line wireless communication/control of MicroPython/other devices.\n* Custom commands to automate communication/control\n* Command line autocompletion\n* Terminal BLE SHELL-REPL 🔸🔺\n* Custom DFU Profile (`dfu_target.py` in profiles) and dfu commands to send scripts through BLE.\n\n\n\n🔸 (REPL works,  but some SHELL commands are still under development)\n\n🔺 There is a limit in the amount of output it can produce, so long lists or `cat` a big file will freeze the BLE SHELL-REPL and possibly the device, which makes a reset almost inevitable.\n\n------\n\n### Getting Started\n\nTo use Terminal BLE SHELL-REPL :\n\nFirst be sure that the **BLE REPL daemon is enabled** and running:\n\n* 1) Put `ble_advertising.py` ,`ble_uart_peripheral.py` and `ble_uart_repl.py` in the device\n\n* 2) Add these lines to `main.py`:\n  \n     ```python\n     import ble_uart_repl\n     ble_uart_repl.start()\n     ```\n\n*These scripts are in upybleutils directory. (Originals from [MicroPython repo bluetooth examples](https://github.com/micropython/micropython/tree/master/examples/bluetooth))*\n\n#### Installing :\n\n`$ pip install upyble` or ``$ pip install --upgrade upyble`` to update to the last version available\n\n#### Finding BLE devices:\n\nUse `$ upyble scan` or `$ upyble tscan` for table output format.\n\n```\n$ upyble tscan\nScanning...\nScanning...\nBLE device/s found: 1\n==============================================================================\n        NAME         |                   UUID                   | RSSI (dBm) |\n esp32-30aea4233564  |   9998175F-9A91-4CA2-B5EA-482AFC3453B9   |   -68.0    |\n```\n\n#### Create a configuration file:\n\n\\*upyble will use local working directory configuration unless it does not find any or manually indicated with `-g` option.\n\n- To save configuration in working directory: `$ upyble config -t [UPYDEVICE UUID]`\n  \n  e.g:\n  \n  `$ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 `\n* To save configuration globally use -g flag: `$ upyble config -t [UPYDEVICE UUID]  -g`\n  \n  e.g.\n  \n  `$ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 -g `\n  \n  \\* Be aware that some devices may generate random UUID every a couple of minutes, so this won't be useful in those cases.\n\n------\n\n### uPyble Usage:\n\nUsage:\n\n`$ upyble [Mode] [options]`\n\nThis means that if the first argument is not a Mode keyword it assumes it is a 'raw' upy command to send to the upy device\n\n##### Help: `$ upyble -h`\n\n------\n\n#### uPyble Mode/Tools:\n\n- **`upyble check`**: to check local machine Bluetooth characterisctics\n- **`upyble config`**: save upy device settings (*see `-t`, `-g`)*, so the target uuid argument wont be required any more\n- **`upyble scan`**: to scan for BLE devices (*see `-n` for max number of scans)*\n- **`upyble tscan`**: to scan for BLE devices, results with table format\n- **`upyble sconf`**: to scan and configure a device that matches a name *`-d [NAME]`*\n- **`upyble get_services`**: to get services of a device, use *`-r`* to read them and *`-mdata`* to see available metadata\n- **`upyble get_stag`**: to get service tag from a service code, use *`-scode`* to indicate the code\n- **`upyble get_scode`**: to get service code from a service tag, use *`-stag`* to indicate the tag\n- **`upyble get_ctag`**: to get characteristic tag from characteristic code, use *`-ccode`* to indicate the code\n- **`upyble get_ccode`**: to get characteristic code from a characteristic tag, use *`-ctag`* to indicate the tag\n- **`upyble get_aptag`**: to get appearance tag from an appearance code, use *`-apcode`* to indicate the code\n- **`upyble get_apcode`**: to get appearance code from an appearance tag, use *`-aptag`* to indicate the tag\n- **`upyble get_mtag`:** to get manufacturer tag from manufacturer code, use *`-mcode`* to indicate the code\n- **`upyble get_mcode`**: to get manufacturer code from a manufacturer tag, use *`-mtag`* to indicate the tag\n- **`upyble cmdata`**: to get characteristic metadata (name, type, uuid, unit, format, notes...). (Not all characteristics are available yet), Use *`-c`* option to indicate characteristic or *`-c all`* to see all that are available. Use *`-xml`* to see the xml file instead.\n- **`upyble cmdata_t`**: get_cmdata in table format.\n- **`upyble dmdata `**:  to get descriptor metadata (Name, uuid, format...). Use *`-desc`* option to indicate a descriptor or  *`-desc all`* to see all that are available.\n- **`upyble follow`**:   to read from a service (see *`-s`,* *` -c`* , *` -tm`*) , e.g : `upyble follow -s \"Battery Service\" `, will read all readable characteristics, or use  *` -c`*  to indicate a specific one/group. e.g:  `upyble follow -s \"Battery Service\" -c \"Battery Level\"`. This mode autodetects format and unit from characteristic metadata\n- **`upyble rfollow`**:   to read from a service (see *`-s`,* *` -c`* , *` -tm`*, *`-u`* , *`fmt`* and  *`-x`*) , e.g : `upyble follow -s \"Battery Service\" `, will read all readable characteristics, or use  *` -c`*  to indicate a specific one/group. e.g:  `upyble follow -s \"Battery Service\" -c \"Battery Level\"`\n- **`upyble see`**: to get specific info about a devices group use `-G` option as `see -G [GROUP NAME]`\n- **`upyble brepl`**: to enter the BLE SHELL-REPL\n- **`upyble ble@[DEVICE]`**: to access brepl in a 'ssh' style command if a device is stored in a global group called `UPYBLE_G` (this needs to be created first doing e.g. `$ upyble make_group -g -f UPYBLE_G -devs foo_device UUID`) The device can be accessed as `$ upyble ble@foo_device` or redirect any command as e.g. `$ upyble get_services -@foo_device`.\n- **`upyble make_group`**: to make a group of boards to send commands to. Use -f for the name  of the group and -devs option to indicate a name and uuid of each board. (To store the group settings globally use -g option)\n- **`upyble mg_group`**: to manage a group of boards to send commands to. Use -G for the name of the group and -add option to add devices (indicate a name and uuid of each board) or -rm to remove devices (indicated by name)\n\n____\n\n#### Examples: \n\n##### \tFollow the Battery Level and Temperature (cpu) of an Esp32.\n\n​\tThis needs `ble_batt_temp.py` in the device. (See [upybleutils](https://github.com/Carglglz/upyble/tree/master/upybleutils))\n\n​\tIn the device REPL do:\n\n```python\n\u003e\u003e\u003e import ble_batt_temp\n\u003e\u003e\u003e ble_batt_temp.ble_batt.start_batt_bg()\n```\n\nNow in local Shell/Terminal:\n\n1. Scan and configure device:\n\n   ```bash\n   $ upyble scan\n   Scanning...\n   Scanning...\n   BLE device/s found: 1\n   NAME: esp32-batt-temp, UUID: 9998175F-9A91-4CA2-B5EA-482AFC3453B9, RSSI: -59.0 dBm, Services: Environmental Sensing\n   \n   $ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 -g\n   upyble device settings saved globally!\n   ```\n\n   \n\n2. Follow services\n\n```bash\n$ upyble follow -s all\nFollowing service: all\n[Service] 180A: Device Information\n\t[Characteristic] 2A01: (read) | Name: Appearance\n\t[Characteristic] 2A29: (read) | Name: Manufacturer Name String\n[Service] 180F: Battery Service\n\t[Characteristic] 2A19: (read,notify) | Name: Battery Level\n\t\t[Descriptor] 2902: (Handle: 19)\n[Service] 181A: Environmental Sensing\n\t[Characteristic] 2A6E: (read,notify) | Name: Temperature\n\t\t[Descriptor] 2902: (Handle: 23)\n15:35:28,813 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 77.0 %\n15:35:28,843 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C\n15:35:33,883 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %\n15:35:33,913 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C\n15:35:38,954 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %\n15:35:38,983 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C\n15:35:44,024 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 71.0 %\n15:35:44,053 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C\n^CDisconnected successfully\n```\n\nSee more usage examples at [EXAMPLES](https://github.com/Carglglz/upyble/blob/master/DOCS/EXAMPLES.md) doc.\n\n___\n\n### ABOUT\n\nTo see more information about upyble dependencies, requirements, tested devices, etc see [ABOUT](https://github.com/Carglglz/upyble/blob/master/DOCS/ABOUT.md) doc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCarglglz%2Fupyble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCarglglz%2Fupyble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCarglglz%2Fupyble/lists"}