Create Bluetooth object
creates a Bluetooth® object associated with the
B = Bluetooth(
RemoteName is a friendly way
to identify the
RemoteID. If not specified, the default
The Instrument Control Toolbox™ Bluetooth interface lets you connect to devices over the Bluetooth interface, and to transmit and receive ASCII and binary data. Instrument Control Toolbox supports the Bluetooth Serial Port Profile (SPP). You can identify any SPP Bluetooth device and establish a two-way connection with that device.
To connect with the Bluetooth device, use the
fopen function. When the
Bluetooth object is created, its
status property is
closed. When the object is connected to the remote device
fopen function, the
property is set to
For information on other functions that can be used with
Bluetooth, a full example using the Bluetooth interface, events and callbacks, and usage guidelines see Bluetooth Interface Overview.
This example shows how to identify and connect to a Bluetooth device, send a message, and read data.
Find available Bluetooth devices.
Create a Bluetooth object called
b using channel
3 of a Lego Mindstorm robot with a
b = Bluetooth('NXT',3);
Connect to the remote device.
Send a message to the remote device.
Read data from the remote device.
name = fread(b,35);
Disconnect the device.
Clean up by deleting and clearing the object.
delete(b) clear b
RemoteName— Name for Bluetooth device
"Friendly name" for the Bluetooth device, specified as a character
vector or string. For example, in the case of an iPhone, it might be
'iPhone' or a name like
'Zor'. If it is empty, use the
RemoteID to communicate with the device.
RemoteID— Internal ID of Bluetooth device
Internal ID of the Bluetooth device, equivalent to the Device ID,
specified as a character vector or string. Every device has a device ID,
which is usually a 12-digit character vector that starts with
'btspp://'. You can use this or the
RemoteName to communicate with the device.
Channel— Device channel
Device channel, specified as a numeric value, if the device has
channels. If no channel is specified, it defaults to
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'Name'— Name of interface object
Name of interface object, specified as a character vector or string.
'Timeout'— Time limit for communication
Time limit in seconds for communication, specified as a numeric value.
B— Bluetooth device interface
Bluetooth device interface, returned as an interface object.