You can download this code by clicking the button below.
This code is now available for download.
This function uses the `discover_devices` method from the PyBluez library to scan for nearby Bluetooth devices and returns a list containing the names and addresses of the devices.
Technology Stack : PyBluez
Code Type : Function
Code Difficulty : Intermediate
import random
from pybluez import bluetooth
def scan_for_devices():
nearby_devices = bluetooth.discover_devices(lookup_names=True)
return nearby_devices