Instrument Control Toolbox™ can communicate with Bluetooth® devices via an adaptor. In this example, a USB Bluetooth adaptor is plugged into the computer. It can identify Bluetooth devices within range when queried. In order to communicate with instruments, you need to perform a pairing in the adaptor software. Note that some devices, such as many laptop computers, do not need to use an adaptor since they have one built in.
The following shows the software interface of an adaptor where
two of the devices in range have been paired – a smart phone
with Bluetooth enabled, and a Lego Mindstorm NXT robot. As you
can see, the “friendly name” or display name of the
smart phone is simply
iPhone and the name of the
NXT robot is
C3PO. In the Instrument
Control Toolbox this
friendly name is the Bluetooth
To see the devices in the Instrument
Control Toolbox, use
instrhwinfo function on the Bluetooth interface,
instrhwinfo returned a cell array of five Bluetooth devices
that are in the range of the adaptor on the computer running Instrument
Then indexing into the
RemoteNames property shows
the five devices. You can see that
shown in the list.
Notice that one of the other devices shows an empty character
RemoteName. That means that device does
not have a friendly name associated with it. To communicate with that
device, you need to use the
RemoteIDs are shown in the same order
RemoteNames, so the fourth ID in the list,
could be used for the device that shows no
You can use either
communicate with a device.
Examples of communicating with a device are in Transmitting Data Over the Bluetooth Interface.
This example looks at the NXT robot discovered in the previous
section. Using the
instrhwinfo function on the
specific device using
RemoteName shows this:
If you use the
instrhwinfo function on the
specific device using the
RemoteID, it shows the
In the case using the
RemoteID, you can see
ObjectConstructorName is actually the
device’s Uniform Resource Identifier (URI).
Whether you use the
RemoteName or the
see the device’s properties, you can see that the device has
only one channel. Create a Bluetooth object
Then display the state of that object using the
The status is
closed because you have not
yet opened the connection to the object.
get function to see the device properties.
BLUETOOTH specific properties section
shows properties that are specific to the Bluetooth interface.
You can see it is using channel
which is the Serial Port Profile – that is the Bluetooth profile
Control Toolbox supports.
are the names that are used to communicate with the device, as shown
are the same as the Serial Port properties of the same name. For details,
see the properties documentation.
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB® command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.