Package: btmgmt
btmgmt: a Python Wrapper for the BlueZ management APIseehttps://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/mgmt-api.txtfor details on how to use the API:tested on:Raspberry Pi 3B+Raspberry Pi 4Built with Python 3.7, Python 2 is untested. The package can be built with bdist-wheels, but is served as a source distribution, meaning the C wrapper is compiled locally when runningpip install. This is slightly slower, but makes the library more portable.Dependencies:libbluetooth-dev: the headers and source code for this extension are entirely contained
within this repo, but the python module is dynamically linked againstlbluetooth.soon the Linux machine.libreadline-dev: thelreadline.soshared library is usually installed by default, but
C header files are required to build this module from source.Install Process:$ sudo apt-get install libbluetooth-dev libreadline-dev

$ sudo pip3 install btmgmt

# most of the BTMGMT commands require root privileges, so the library should be
# installed to the root python environment.Usage:# Demonstrative only: see example scripts for more information

import btmgmt

btmgmt.command("command", "parameter1", "parameter2")

# Variable number of arguments allowed depending on the command (see below).Permissions:If you do not want to run as root, simply set the capabilities of the process (in this case, Python) to haveCAP_NET_ADMIN.sudo setcap cap_net_admin+eip $(readlink -f $(which python3))You can verify that this isOKby running the above command with verify flag:sudo setcap -v cap_net_admin+eip $(readlink -f $(which python3))Available Commands:select <index>                                    Select a different indexversion                                           Get the MGMT Versioncommands                                          List supported commandsconfig                                            Show configuration infoinfo                                              Show controller infoextinfo                                           Show extended controller infoauto-power                                        Power all available featurespower <on/off>                                    Toggle powered statediscov <yes/no/limited> [timeout]                 Toggle discoverable stateconnectable <on/off>                              Toggle connectable statefast-conn <on/off>                                Toggle fast connectable statebondable <on/off>                                 Toggle bondable statelinksec <on/off>                                  Toggle link level securityssp <on/off>                                      Toggle SSP modesc <on/off/only>                                  Toogle SC supporths <on/off>                                       Toggle HS supportle <on/off>                                       Toggle LE supportadvertising <on/off>                              Toggle LE advertisingbredr <on/off>                                    Toggle BR/EDR supportprivacy <on/off>                                  Toggle privacy supportclass <major> <minor>                             Set device major/minor classdisconnect [-t type] <remote address>             Disconnect devicecon                                               List connectionsfind [-l|-b] [-L]                                 Discover nearby devicesfind-service [-u UUID] [-r RSSI_Threshold] [-l|-b] Discover nearby servicestop-find [-l|-b]                                 Stop discoveryname <name> [shortname]                           Set local namepair [-c cap] [-t type] <remote address>          Pair with a remote devicecancelpair [-t type] <remote address>             Cancel pairingunpair [-t type] <remote address>                 Unpair devicekeys                                              Load Link Keysltks                                              Load Long Term Keysirks [--local <index>] [--file <file path>]       Load Identity Resolving Keysblock [-t type] <remote address>                  Block Deviceunblock [-t type] <remote address>                Unblock Deviceadd-uuid <UUID> <service class hint>              Add UUIDrm-uuid <UUID>                                    Remove UUIDclr-uuids                                         Clear UUIDslocal-oob                                         Local OOB dataremote-oob [-t <addr_type>] [-r <rand192>] [-h <hash192>] [-R <rand256>] [-H <hash256>] <addr> Remote OOB datadid <source>:<vendor>:<product>:<version>         Set Device IDstatic-addr <address>                             Set static addresspublic-addr <address>                             Set public addressext-config <on/off>                               External configurationdebug-keys <on/off>                               Toogle debug keysconn-info [-t type] <remote address>              Get connection informationio-cap <cap>                                      Set IO Capabilityscan-params <interval> <window>                   Set Scan Parametersget-clock [address]                               Get Clock Informationadd-device [-a action] [-t type] <address>        Add Devicedel-device [-t type] <address>                    Remove Deviceclr-devices                                       Clear Devicesbredr-oob                                         Local OOB data (BR/EDR)le-oob                                            Local OOB data (LE)advinfo                                           Show advertising featuresadvsize [options] <instance_id>                   Show advertising size infoadd-adv [options] <instance_id>                   Add advertising instancerm-adv <instance_id>                              Remove advertising instanceclr-adv                                           Clear advertising instancesappearance <appearance>                           Set appearanceversion                                           Display versionquit                                              Quit programexit                                              Quit programhelp                                              Display help about this programexport                                            Print evironment variables