bluetooth
Description
A bluetooth
object represents a connection to a Bluetooth® Classic device from your computer using Bluetooth Serial Port Profile (SPP). Identify nearby devices to connect to by the
"Ready to connect"
status in the bluetoothlist
output. You must pair the device with
your computer first before connecting to it from MATLAB®.
Creation
Syntax
Description
creates a connection to
the last successfully connected Bluetooth Classic device.device
= bluetooth
creates a connection to a Bluetooth Classic device using its name. The channel is the default SPP channel 1. The
input device
= bluetooth(name
)name
sets the Name
property.
creates a connection to the specified SPP channel device
= bluetooth(name
,channel
)channel
of a
Bluetooth Classic device. The input channel
sets the
Channel
property.
creates a connection to a Bluetooth Classic device using its address. The input device
= bluetooth(address
)address
sets the Address
property.
creates a connection to the specified SPP channel device
= bluetooth(address
,channel
)channel
of a
Bluetooth Classic device.
creates a connection and sets additional Properties using one or more
name-value pair arguments. Set the device
= bluetooth(address
,channel
,Name,Value
)ByteOrder
and Timeout
properties using name-value pair arguments. Enclose each
property name in quotes, followed by the desired property value.
Example: device =
bluetooth("23E16522A7C0",2,"ByteOrder","little-endian","Timeout",10)
connects
to a Bluetooth device with little-endian byte order and a timeout period of 10
seconds.
Properties
Object Functions
read | Read data from Bluetooth device |
readline | Read line of ASCII string data from Bluetooth device |
write | Write data to Bluetooth device |
writeline | Write line of ASCII data to Bluetooth device |
configureTerminator | Set terminator for ASCII string communication with Bluetooth device |
configureCallback | Set callback function and trigger condition for communication with Bluetooth device |
flush | Clear Bluetooth device buffers |
Examples
Version History
Introduced in R2020b