Linux上bluezbtmgmt工具的简单python包装器

btmgmt的Python项目详细描述


btmgmt:BlueZ管理API的Python包装器

有关如何使用API的详细信息,请参见https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/mgmt-api.txt

测试时间:

  • 树莓皮3B+
  • 树莓皮4

Python2是用Python3.7构建的,尚未经过测试。这个包可以用bdistwheels构建,但是作为源代码分发,这意味着在运行pip install时,C包装器是在本地编译的。这会稍微慢一点,但会使库更具可移植性。在

依赖项:

  • libbluetooth dev:此扩展的头和源代码全部包含在内 在这个repo中,但是python模块是动态链接的 lbluetooth公司在Linux机器上。在
  • libreadline dev:这个lreadline.so共享库通常默认安装,但是 从源代码构建此模块需要C头文件。在

安装过程:

$ 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.

用法:

^{pr2}$

权限:

如果不想以root用户身份运行,只需将进程(在本例中是Python)的功能设置为具有CAP_NET_ADMIN。在

sudo setcap cap_net_admin+eip $(readlink -f $(which python3))

您可以通过运行上面带有verify标志的命令来验证这是OK

sudo setcap -v cap_net_admin+eip $(readlink -f $(which python3))

可用命令:

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
运行ClassSpy java时发生反射错误   java Android ContextWrapper fileList()看不到我的文件   java使用JAXWS构建大型MTOM/XOP消息   eclipse如何使用ACM库(控制台程序)编写Java程序?   java m2eclipse插件搜索在配置为Nexus时不会给出结果   java Scanner只识别文本文件中的某些行,而不识别其他行   java如何从smartwatch启动活动或服务   java检查数组是否至少有两个具有特定值的元素   JAVA网URL编码器/解码器替代方案   Java中通过引用传递对象   spring如何在使用JavaJSON修补程序进行修补时禁止更新字段   使用java将海量数据存储到mysql的最佳方法   java字符串作为不可变对象   java我无法访问tomcat服务器(localhost),甚至无法访问mysql   java While循环条件未给出预期结果   java如何启动传递图像uri的新活动   Java中类定义在方法中的使用   Java程序在Ubuntu中运行我的另一个程序