Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

NXT C++ Bluetooth Library
Class Brick

   in brick.h
   in brick.cpp

class Brick

Class to get/set brick name, get/set battery level, R/W to mailbox, start/stop programs, play sound, stop sound ect...


Constructor Summary
Brick( Connection* connection )
          
 
Method Summary
 void beep( unsigned int time, bool reply = false )
          Make the NXT beep
 unsigned int get_battery_level()
          Get the battery level
 string get_bt_address()
          Get the Bluetooth address of the NXT
 string get_current_program()
          Get the current executing program
 void get_device_info( Device_info& info )
          Retrieve BT-address, brick name and free flash memory with a single call
 void get_device_version( Device_version& version )
          Retrieve Firmware version and Protrocol version with a single call
 string get_firmware_version()
          Get the firmware version currently running on the NXT
 unsigned int get_flash_memory()
          Get free flash memory
 string get_name()
          Get the name of the NXT
 string get_protocol_version()
          Get the protocol version currently running on the NXT
 void keep_alive( bool reply = false )
          Keep the NXT alive
 void play_soundfile( string file, bool loop, bool reply = false )
          Play a soundfile from the NXT's flash
 void play_tone( unsigned int freq, unsigned int time, bool reply = false )
          Make the NXT play a tone
 string read_msg( int inbox, bool remove )
          Read a message from the NXT's mailbox
 void set_name( string name, bool reply = false )
          Set the name of the NXT
 void start_program( string file, bool reply = false )
          Start executing a program from the NXT's flash
 void stop_programs( bool reply = false )
          Stop executing program
 void stop_soundplayback( bool reply = false )
          Stop all sound playback
 void write_msg( string message, int inbox, bool reply = false )
          Write a message to the NXT's mailbox
 

Constructor Detail

Brick

public Brick( Connection* connection );
Parameters:
*connection - [attach a connection]


Method Detail

beep

public void beep( unsigned int time, bool reply = false );
Make the NXT beep
Parameters:
time - [duration in ms]
reply - [true = require reply from NXT; false = no reply from NXT]

get_battery_level

public unsigned int get_battery_level();
Get the battery level
Returns:
the the battery level in mVolts

get_bt_address

public string get_bt_address();
Get the Bluetooth address of the NXT
Returns:
the BT address on the form XX:XX:XX:XX:XX:XX:XX

get_current_program

public string get_current_program();
Get the current executing program
Returns:
the current executing program (maximum 19 characters)

get_device_info

public void get_device_info( Device_info& info );
Retrieve BT-address, brick name and free flash memory with a single call
Parameters:
info - [used to store the return values]

get_device_version

public void get_device_version( Device_version& version );
Retrieve Firmware version and Protrocol version with a single call
Parameters:
version - [used to store the return values]

get_firmware_version

public string get_firmware_version();
Get the firmware version currently running on the NXT
Returns:
the firmware version on the form x.xx

get_flash_memory

public unsigned int get_flash_memory();
Get free flash memory
Returns:
the remaining free flash memory in bytes

get_name

public string get_name();
Get the name of the NXT
Returns:
the brick name (maximum 15 characters)

get_protocol_version

public string get_protocol_version();
Get the protocol version currently running on the NXT
Returns:
the protocol version as on the form x.xxx

keep_alive

public void keep_alive( bool reply = false );
Keep the NXT alive
Parameters:
reply - [true = require reply from NXT; false = no reply from NXT]

play_soundfile

public void play_soundfile( string file, bool loop, bool reply = false );
Play a soundfile from the NXT's flash
Parameters:
file - [file name *.rso (sound file) (maximum 19 characters)]
loop - [true = loop sound file indefinitely; false = play file once]
reply - [true = require reply from NXT; false = no reply from NXT]

play_tone

public void play_tone( unsigned int freq, unsigned int time, bool reply = false );
Make the NXT play a tone
Parameters:
freq - [frequency in Hz (200-14000 Hz)]
time - [duration in ms]
reply - [true = require reply from NXT; false = no reply from NXT]

read_msg

public string read_msg( int inbox, bool remove );
Read a message from the NXT's mailbox
Parameters:
inbox - [specifies the inbox on the NXT(0-9)]
remove - [true = remove the string from the inbox; false = leave the string in the inbox]
Returns:
returns a string from the inbox specified by inbox (maximum 57 characters)

set_name

public void set_name( string name, bool reply = false );
Set the name of the NXT
Parameters:
name - [new name of the NXT (maximum 15 characters)]
reply - [true = require reply from NXT; false = no reply from NXT]

start_program

public void start_program( string file, bool reply = false );
Start executing a program from the NXT's flash
Parameters:
file - [file name *.rxe (downloaded program), *.rpg (On brick programs), *.rtm (Try me programs) (maximum 19 characters)]
reply - [true = require reply from NXT; false = no reply from NXT]

stop_programs

public void stop_programs( bool reply = false );
Stop executing program
Parameters:
reply - [true = require reply from NXT; false = no reply from NXT]

stop_soundplayback

public void stop_soundplayback( bool reply = false );
Stop all sound playback
Parameters:
reply - [true = require reply from NXT; false = no reply from NXT]

write_msg

public void write_msg( string message, int inbox, bool reply = false );
Write a message to the NXT's mailbox
Parameters:
message - [string to be send to the inbox (maximum 57 characters)]
inbox - [specifies the inbox on the NXT(0-9)]
reply - [true = require reply from NXT; false = no reply from NXT]

 Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD