Blog

Blog

PHODAL

raspberry pi python bluetooth,用pybluez控制蓝牙

安装pybluez

直接安装pybluez的时候报错了

In file included from bluez/btmodule.c:20:0:

bluez/btmodule.h:5:33: fatal error: bluetooth/bluetooth.h: No such file or directory

google后的结果是没有安装libbluetooth-dev

安装libbluetooth-dev

 sudo apt-get install libbluetooth-dev

安装pybluez

 sudo pip install pybluez

直到看到Successfully installed pybluez,安装成功

pybluez 查询蓝牙

官方的示例inquiry.py

import bluetooth
print("performing inquiry...")
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print("found %d devices" % len(nearby_devices))
for addr, name in nearby_devices:
    print("  %s - %s" % (addr, name))

查找了手机的蓝牙

 ⚙ ubuntu@ubuntu  ~  python findblue.py
performing inquiry...
found 1 devices
  28:CF:E9:1C:42:2A - phodal

或许您还需要下面的文章:

关于我

Github: @phodal     微博:@phodal     知乎:@phodal    

微信公众号(Phodal)

围观我的Github Idea墙, 也许,你会遇到心仪的项目

QQ技术交流群: 321689806
comment

Feeds

RSS / Atom

最近文章

关于作者

Phodal Huang

Engineer, Consultant, Writer, Designer

ThoughtWorks 技术专家

工程师 / 咨询师 / 作家 / 设计学徒

开源深度爱好者

出版有《前端架构:从入门到微前端》、《自己动手设计物联网》、《全栈应用开发:精益实践》

联系我: h@phodal.com

微信公众号: 最新技术分享

标签