The LEGO® Mindstorms NXT Intelligent Brick can communicate with external Bluetooth devices that use the Serial Port Profile (SPP) and can be programmed to use the LEGO® Mindstorms NXT Communication Protocol. A short description of the protocol can be found in the Communication Protocol section. For more details see the official LEGO® Mindstorms NXT Bluetooth Developer Kit document. It's also possible to send direct commands to the NXT Intelligent Brick from an external Bluetooth device such as a computer, mobile phone or PDA.
The LEGO® Mindstorms Communcation Protocol is placed in the overall architecture above the Bluetooth communication ports. This layer handles the data that will be the payload within the Bluetooth communication layers.
Byte 0: Telegram type. The 7th lowest bit of this byte is used for identifying the command type. Currently the system has the following command types that need to be identified. Bit 7 (MSB) is used for identifying wheter the command should give a reply message or not.
0x00: Direct command, reply required
0x01: System command, reply required
0x02: Reply command
0x80: Direct command, reply not required
0x81: System command, reply not required
Byte 1: Command byte. Used by the loader module to identify what should happen with the data. Open, Read, Write, Delete data, Direct communication with NXT
Byte 2-N: These bytes offer additional information.
The above figure shows the LEGO® Mindstorms NXT Communication Protocol standard. This protocol will be wrapped into the Bluetooth serial profile.
Maximum Command Length
The total direct command telegram size is limited to 64 bytes, including the command type byte as listed above. The Bluetooth packets have an additional two bytes for size tacked onto the front, but these are no included in this limit.
Bluetooth Messages
As explained above all Bluetooth messages need to have two bytes in front of the messages itself which indicates how many bytes the message includes. The length of the package is counted without the two length bytes.
The figure below shows a Bluetooth message:
Testing during development has shown that the Bluetooth Serial Port communication has some disadvantages when it comes to streaming data. These disadvantages stem from two problems: bigger data packages can be received with small timing differences from the ARM processor; and ther is a time penalty (of around 30 ms) within the Bluecore chip when switching from receive-mode to transmit-mode.
"To handle the problem of the time penalty within the Bluecore chip, users should send data using Bluetooth without requesting a reply package. This will mean that the Bluecore chip won't have to switch direction for every received package and will not incur a 30 ms penalty for every data package."
Example 1: PLAYTONE
Byte 0: 0x00 or 0x80 (0x80 would be pointless however, since it does not request a reply)
Byte 1: 0x03
Byte 2-3: Frequency for the tone in Hz (Range: 200 - 14000 Hz)
Byte 4-5: Duration of the tone in ms
The NXT Intelligent Brick supports wireless communication using Bluetooth communication, V2.0 with EDR by including a CSR BlueCore 4 version 2 chip. It supports the Serial Port Profile (SPP), which can be considered a wireless serial port. The NXT Brick can communicate wih Bluetooth devices that can be programmed to communicate using the LEGO® Mindstorms NXT Communication Protocol commands and that support the Serial Port Profile (SPP). It's possible to send and receive information to the Brick during program execution. To reduce the power consumption used by Bluetooth, the technology has been implemented by a Bluetooth Class II device, which means that it can communicate up to a distance of approximately 10 meters.
PC Bluetooth Adapter
For a Bluetooth communication between computer and the NXT Brick the computer needs a Bluetooth 2.0 adapter. Older versions like Bluetooth 1.2 are not supported by the NXT Brick.
USB Communication
The NXT Intelligent Brick can also communicate via the USB interface and can also be programmed to use the LEGO® Mindstorms NXT Communication Protocol. The communication possibilities through the USB device should be the same through the Bluetooth device. The USB communication V2.0 is supported. A short description of the protocol can be found above in the Communication Protocol section. For more details see the official LEGO® Mindstorms NXT Bluetooth Developer Kit document.