Chapter 2Extensions to LabVIEWLabVIEW LEGO MINDSTORMS NXT Module2-64ni.comBluetooth Communication MethodsUse the Bluetooth communication methods to send packets of information to other devices connected to the NXT brick through Bluetooth. You also use these methods to access the messaging queue system of the NXT firmware.The NXT firmware uses a master/slave serial port system for Bluetooth communication. You must designate one Bluetooth device as the master device before you run a program using Bluetooth. If the master device is the NXT brick, you can configure up to three slave devices using serial ports 1, 2, and 3 on the NXT brick. If the slave device is an NXT brick, port 0 on the NXT brick is reserved for the master device.Programs running on the master NXT brick can send packets of data to any connected slave devices using the NXTCommBTWrite method. However, programs on slave devices cannot send packets to master devices. The firmware of slave NXT bricks automatically handles responses sent by programs on master devices.Refer to the LEGO MINDSTORMS Web site at actionURI(http://mindstorms.lego.com/):mindstorms.lego.comactionURI(http://mindstorms.lego.com/): for the communications protocol documentation for Bluetooth. This section also includes descriptions of the system call methods for accessing the mailboxes, or message queues, on the NXT brick. By using the direct command protocol, a master device can send messages to slave NXT bricks in the form of text strings addressed to a particular mailbox. Each mailbox on the slave NXT brick is a circular message queue holding up to five messages. Each message can be up to 58 bytes long.To send messages from a master NXT brick to a slave device, use NXTCommBTWrite on the master device to send a MessageWrite protocol packet to the slave. Then, use NXTMessageRead on the slave device to read the message. The slave NXT brick must be running a program when an incoming message packet is received. If no program is running, the slave NXT brick ignores the message, and the message is lost.To exchange numeric data using the message system, use the OP_FLATTEN and OP_UNFLATTEN instructions to convert data to and from text strings.