Main Content

bluetoothlist

Scan nearby Bluetooth Classic devices

Since R2020b

Description

devlist = bluetoothlist scans nearby Bluetooth® Classic devices. Use bluetooth to connect to a device.

example

devlist = bluetoothlist("Timeout",time) scans for up to time seconds. The default timeout period is 35 seconds for Windows® and 20 seconds for macOS. The value of time must be 5 or greater.

example

Examples

collapse all

Scan nearby Bluetooth Classic devices and check their connection status.

Use bluetoothlist to list all nearby devices. If your device is already connected to another device or application, it might not appear in this list. Disconnect your device from any other devices or applications first for MATLAB® to discover it.

devlist = bluetoothlist
devlist=5×4 table
        Name            Address        Channel          Status      
    _____________    ______________    _______    __________________

    "Pixel 3"        "3C286DD533CA"    8          "Ready to connect"         
    "HC-06"          "98D331FB3B77"    1          "Requires pairing"
    "mjin-maci"      "A886DDA44062"    3          "Requires pairing"
    "DMTDevice"      "B0B448F47A4C"    Unknown    "Unknown"         

The Name and Address columns identify the device. The Channel column indicates the device SPP channel. The Status column describes the current device connection status.

You can also specify a timeout value less than the default 35 seconds on Windows and 20 seconds on macOS.

devlist = bluetoothlist("Timeout",10)
devlist=3×4 table
        Name            Address        Channel          Status      
    _____________    ______________    _______    __________________

    "Pixel 3"        "3C286DD533CA"    8          "Ready to connect"         
    "mjin-maci"      "A886DDA44062"    3          "Requires pairing"

Output Arguments

collapse all

List of nearby Bluetooth devices, returned as a table. The table has the following columns.

Device name, returned as a string scalar. Multiple devices can share the same name.

Data Types: string

Device identifier, returned as a string scalar.

Data Types: string

Device SPP channel, returned as a categorical scalar. If the channel is unknown, the value in this column is Unknown.

Data Types: categorical

Device connection status, returned as a string. You can connect to a Bluetooth device using bluetooth only if its status is "Ready to connect". Possible values follow.

ValueDescription
"Ready to connect"Device supports SPP, is paired, and not connected anywhere.
"Requires pairing"Device supports SPP and is not paired.
"Connected"Device supports SPP and is connected.
"Unsupported"Device does not support SPP.
"Unknown"Unknown if device supports SPP. Device is turned off or fails to respond to scanning request.

Data Types: string

Version History

Introduced in R2020b

See Also