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第三方库


热门话题
java何时可以运行。toString()是否有可能返回重复的字符串?   使用REST进行Java应用程序登录验证?   java测试onErrorResume()Spring Webflux   java设置一个单元格样式,使数字显示为百分比ApachePOI   java仅替换regex az09   java将字符串附加到文件   java Hibernate:如何在集合中查找对象   当独立客户端为Web服务实例化代理时,java WebSphere会生成ClassNotFoundException   java简单算法。我做不好   java我的代码有什么问题?我想用Android制作一个“cardflip”动画   java如何模拟Springbean及其自动连接的参数?   java在Android中将arraylist对象的某些参数显示到列表视图中   java setOnclickListener(此)错误   java自动连接未按类型连接bean   java如何禁止在Viewpager上滑动?   java代码检查每个if语句吗?   java NIO选择器OP_READ和OP_WRITE,关于处理它们的一些问题   java如何在不锁定文件的情况下获取文件大小   Oculus Rift的Java API?   java是一种选择。仍然需要fork来设置bootClasspath