uPyble
Command line tool for Bluetooth Low Energy devices
uPyble is intended to be a command line tool upydev-like to make easier the development, prototyping and testing process of devices based on boards running *MicroPython with Bluetooth Low Energy capabilities.
*( Any other BLE device should work as well)
⚠️ Keep in mind that this project is in ALPHA state, sometimes, some commands may not work/return anything ⚠️
Features:
- Command line wireless communication/control of MicroPython/other devices.
- Custom commands to automate communication/control
- Command line autocompletion
- Terminal BLE SHELL-REPL 🔸🔺
🔸 (REPL works, but some SHELL commands are still under development)
🔺 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.
Getting Started
For Terminal BLE SHELL-REPL :
First be sure that the BLE REPL daemon is enabled and running:
-
- Put
ble_advertising.py,ble_uart_peripheral.pyandble_uart_repl.pyin the device
- Put
-
-
Add these lines to
main.py:import ble_uart_repl ble_uart_repl.start()
-
These scripts are in upybleutils directory. (Originals from MicroPython repo bluetooth examples)
Installing :
$ pip install upyble or $ pip install --upgrade upyble to update to the last version available
Finding BLE devices:
Use $ upyble scan or $ upyble tscan for table output format.
$ upyble tscan
Scanning...
Scanning...
BLE device/s found: 1
==============================================================================
NAME | UUID | RSSI (dBm) |
esp32-30aea4233564 | 9998175F-9A91-4CA2-B5EA-482AFC3453B9 | -68.0 |
Create a configuration file:
*upyble will use local working directory configuration unless it does not find any or manually indicated with -g option.
-
To save configuration in working directory:
$ upyble config -t [UPYDEVICE UUID]e.g:
$ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9
-
To save configuration globally use -g flag:
$ upyble config -t [UPYDEVICE UUID] -ge.g.
$ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 -g* Be aware that some devices may generate random UUID every a couple of minutes, so this won't be useful in those cases.
uPyble Usage:
Usage:
$ upyble [Mode] [options]
This 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
Help: $ upyble -h
uPyble Mode/Tools:
upyble check: to check local machine Bluetooth characteriscticsupyble config: save upy device settings (see-t,-g), so the target uuid argument wont be required any moreupyble scan: to scan for BLE devices (see-nfor max number of scans)upyble tscan: to scan for BLE devices, results with table formatupyble sconf: to scan and configure a device that matches a name-d [NAME]upyble get_services: to get services of a device, use-rto read them and-mdatato see available metadataupyble get_stag: to get service tag from a service code, use-scodeto indicate the codeupyble get_scode: to get service code from a service tag, use-stagto indicate the tagupyble get_ctag: to get characteristic tag from characteristic code, use-ccodeto indicate the codeupyble get_ccode: to get characteristic code from a characteristic tag, use-ctagto indicate the tagupyble get_aptag: to get appearance tag from an appearance code, use-apcodeto indicate the codeupyble get_apcode: to get appearance code from an appearance tag, use-aptagto indicate the tagupyble get_mtag: to get manufacturer tag from manufacturer code, use-mcodeto indicate the codeupyble get_mcode: to get manufacturer code from a manufacturer tag, use-mtagto indicate the tagupyble cmdata: to get characteristic metadata (name, type, uuid, unit, format, notes...). (Not all characteristics are available yet), Use-coption to indicate characteristic or-c allto see all that are available. Use-xmlto see the xml file instead.upyble cmdata_t: get_cmdata in table format.upyble dmdata: to get descriptor metadata (Name, uuid, format...). Use-descoption to indicate a descriptor or-desc allto see all that are available.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-cto indicate a specific one/group. e.g:upyble follow -s "Battery Service" -c "Battery Level". This mode autodetects format and unit from characteristic metadataupyble rfollow: to read from a service (see-s,-c,-tm,-u,fmtand-x) , e.g :upyble follow -s "Battery Service", will read all readable characteristics, or use-cto indicate a specific one/group. e.g:upyble follow -s "Battery Service" -c "Battery Level"upyble see: to get specific info about a devices group use-Goption assee -G [GROUP NAME]upyble brepl: to enter the BLE SHELL-REPLupyble ble@[DEVICE]: to access brepl in a 'ssh' style command if a device is stored in a global group calledUPYBLE_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_deviceor redirect any command as e.g.$ upyble get_services -@foo_device.
Examples:
Follow the Battery Level and Temperature (cpu) of an Esp32.
This needs ble_batt_temp.py in the device. (See upybleutils)
In the device REPL do:
>>> import ble_batt_temp
>>> ble_batt_temp.ble_batt.start_batt_bg()
Now in local Shell/Terminal:
-
Scan and configure device:
$ upyble scan Scanning... Scanning... BLE device/s found: 1 NAME: esp32-batt-temp, UUID: 9998175F-9A91-4CA2-B5EA-482AFC3453B9, RSSI: -59.0 dBm, Services: Environmental Sensing $ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 -g upyble device settings saved globally!
-
Follow services
$ upyble follow -s all
Following service: all
[Service] 180A: Device Information
[Characteristic] 2A01: (read) | Name: Appearance
[Characteristic] 2A29: (read) | Name: Manufacturer Name String
[Service] 180F: Battery Service
[Characteristic] 2A19: (read,notify) | Name: Battery Level
[Descriptor] 2902: (Handle: 19)
[Service] 181A: Environmental Sensing
[Characteristic] 2A6E: (read,notify) | Name: Temperature
[Descriptor] 2902: (Handle: 23)
15:35:28,813 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 77.0 %
15:35:28,843 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:33,883 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %
15:35:33,913 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:38,954 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %
15:35:38,983 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:44,024 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 71.0 %
15:35:44,053 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
^CDisconnected successfully
See more usage examples at EXAMPLES doc.
ABOUT
To see more information about upyble dependencies, requirements, tested devices, etc see ABOUT doc.
Metadata
Release files for upyble 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| upyble-0.0.3.tar.gz | 570.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| upyble-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / upyble-0.0.3.tar.gz
| Download URL | upyble-0.0.3.tar.gz |
|---|---|
| Size | 570.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
911235437fdd151be5a96fe29ab8c6a7b9531bfdc2cabb66a4285b571d4fa1ee
|
|
BLAKE2b-256 checksum How to use checksums |
0ea932daf759b8132d2367f2dc42553ee8f59db3f143cb11ec788e28cb3eaf74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
|
Release files / upyble-0.0.3-py3-none-any.whl
| Download URL | upyble-0.0.3-py3-none-any.whl |
|---|---|
| Size | 725.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08238bdf0f9d95040dee88832d1ee105ae804d556c13eb19769a5f1abc1ab687
|
|
BLAKE2b-256 checksum How to use checksums |
4ccdd04a38c9879cda9017be270cc73af0f88f77d97b2b1c4e1f9d6fb0294a27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
|
Security for upyble 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.