Package: upyble
uPybleCommand line tool for Bluetooth Low Energy  devicesuPybleis intended to be a command line toolupydev-liketo make easier the development, prototyping and testing process of devices based on boards running *MicroPython withBluetooth Low Energycapabilities.*( 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/controlCommand line autocompletionTerminal 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 orcata big file will freeze the BLE SHELL-REPL and possibly the device, which makes a reset almost inevitable.Getting StartedFor Terminal BLE SHELL-REPL :First be sure that theBLE REPL daemon is enabledand running:Putble_advertising.py,ble_uart_peripheral.pyandble_uart_repl.pyin the deviceAdd these lines tomain.py:importble_uart_replble_uart_repl.start()These scripts are in upybleutils directory. (Originals fromMicroPython repo bluetooth examples)Installing :$ pip install upybleor$ pip install --upgrade upybleto update to the last version availableFinding BLE devices:Use$ upyble scanor$ upyble tscanfor 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-goption.To save configuration in working directory:$ upyble config -t [UPYDEVICE UUID]e.g:$ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9To 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 deviceHelp:$ upyble -huPyble 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 needsble_batt_temp.pyin the device. (Seeupybleutils)​	In the device REPL do:>>>importble_batt_temp>>>ble_batt_temp.ble_batt.start_batt_bg()Now in local Shell/Terminal:Scan and configure device:$upyblescan
Scanning...
Scanning...
BLEdevice/sfound:1NAME:esp32-batt-temp,UUID:9998175F-9A91-4CA2-B5EA-482AFC3453B9,RSSI:-59.0dBm,Services:EnvironmentalSensing

$upybleconfig-t9998175F-9A91-4CA2-B5EA-482AFC3453B9-g
upybledevicesettingssavedglobally!Follow services$upyblefollow-sall
Followingservice:all[Service]180A:DeviceInformation[Characteristic]2A01:(read)|Name:Appearance[Characteristic]2A29:(read)|Name:ManufacturerNameString[Service]180F:BatteryService[Characteristic]2A19:(read,notify)|Name:BatteryLevel[Descriptor]2902:(Handle:19)[Service]181A:EnvironmentalSensing[Characteristic]2A6E:(read,notify)|Name:Temperature[Descriptor]2902:(Handle:23)15:35:28,813[upyble@esp32-batt-temp]BatteryService[BatteryLevel]:77.0%15:35:28,843[upyble@esp32-batt-temp]EnvironmentalSensing[Temperature]:56.67°C15:35:33,883[upyble@esp32-batt-temp]BatteryService[BatteryLevel]:76.0%15:35:33,913[upyble@esp32-batt-temp]EnvironmentalSensing[Temperature]:56.67°C15:35:38,954[upyble@esp32-batt-temp]BatteryService[BatteryLevel]:76.0%15:35:38,983[upyble@esp32-batt-temp]EnvironmentalSensing[Temperature]:56.67°C15:35:44,024[upyble@esp32-batt-temp]BatteryService[BatteryLevel]:71.0%15:35:44,053[upyble@esp32-batt-temp]EnvironmentalSensing[Temperature]:56.67°C
^CDisconnectedsuccessfullySee more usage examples atEXAMPLESdoc.ABOUTTo see more information about upyble dependencies, requirements, tested devices, etc seeABOUTdoc.