How to use Raspberry Pi scan bluetooth devices All In One
How to use Raspberry Pi scan bluetooth devices All In One
蓝牙
$ sudo pip3 install pybluez
https://pypi.org/project/PyBluez/
#!/usr/bin/env python3
# coding: utf8
from time import sleep
import bluetooth
try:
nearby_devices = bluetooth.discover_devices(lookup_names=True)
print("Found {} devices.".format(len(nearby_devices)))
for addr, name in nearby_devices:
print("address = {}, name = {}".format(addr, name))
except KeyboardInterrupt:
print("Ctrl + C ✅")
finally:
sleep(1)
print("clear ✅")
# bluetooth low energy scan
from bluetooth.ble import DiscoveryService
service = DiscoveryService()
devices = service.discover(2)
for address, name in devices.items():
print("name: {}, address: {}".format(name, address))
https://github.com/pybluez/pybluez
https://pypi.org/project/pybluez2/
https://github.com/airgproducts/pybluez2
docs
https://pybluez.readthedocs.io/en/latest/install.html
#!/usr/bin/env python3
import bluetooth
def scan():
print("Scanning for bluetooth devices:")
devices = bluetooth.discover_devices(lookup_names = True, lookup_class = True)
number_of_devices = len(devices)
print(number_of_devices,"devices found")
for addr, name, device_class in devices:
print("\n")
print("Device:")
print("Device Name: %s" % (name))
print("Device MAC Address: %s" % (addr))
print("Device Class: %s" % (device_class))
print("\n")
return
https://forums.raspberrypi.com/viewtopic.php?t=329762
from bluetooth import *
print "performing inquiry..."
nearby_devices = discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)
https://stackoverflow.com/questions/21000680/how-to-find-visible-bluetooth-devices-in-python
http://www.robertprice.co.uk/robblog/2007/01/programming_bluetooth_using_python-shtml/
https://github.com/karulis/pybluez
http://karulis.github.io/pybluez/
https://github.com/EnableTech/raspberry-bluetooth-demo
demos
bugs
install error
??? 不支持 Python 3
??? 缺少 C++ 依赖
https://github.com/pybluez/pybluez/issues/476
refs
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17410677.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
2022-05-17 Xcode sets default tab indent equal to 2 spaces All In One
2022-05-17 MacBook Pro 外接显示器的音箱没声音解决方案 All In One
2021-05-17 $forceUpdate All In One
2021-05-17 vue button disabled tooltip All In One
2020-05-17 Deno 1.0 & Node.js All In One
2020-05-17 App Store Previewer
2020-05-17 how to create one single-file Web Component just using the HTML, CSS, JavaScript All In One