How to use Raspberry Pi scan bluetooth devices All In One

xgqfrms / 2023-05-18 / 原文

How to use Raspberry Pi scan bluetooth devices All In One

蓝牙

$ sudo pip3 install pybluez

#!/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://geektechstuff.com/2020/06/01/python-and-bluetooth-part-1-scanning-for-devices-and-services-python/

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


refs



©xgqfrms 2012-2021

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!