lejos.nxt.comm
Class NXTCommDevice

java.lang.Object
  extended by lejos.nxt.comm.NXTCommDevice
Direct Known Subclasses:
Bluetooth, RS485, USB

public abstract class NXTCommDevice
extends Object

Base class for nxt communications devices. Provides a common address/name, plus utility functions.

Author:
andy

Field Summary
static int ADDRESS_LEN
           
protected static char[] cs
           
static String NAME
           
static int NAME_LEN
           
static String SERIAL_NO
           
 
Constructor Summary
NXTCommDevice()
           
 
Method Summary
static String addressToString(byte[] addr)
          Helper method to convert address byte array to String.
static String getAddress()
          Return the current USB serial number.
static String getName()
          Return the current USB devName.
static boolean isAddress(String s)
          Determine if a string contains a Bluetooth style address.
static void loadSettings()
          Load the current system settings associated with this class.
static String nameToString(byte[] name)
          Return a string version of a device devName held as a byte array
static void setAddress(String sn)
          Set the USB serial number.
static void setName(String nam)
          Set the USB devName.
static byte[] stringToAddress(String strAddress)
          Convert a string version of a Bluetooth address into a byte array address.
static byte[] stringToName(String strName)
          Convert the string version of a devName into a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADDRESS_LEN

public static final int ADDRESS_LEN
See Also:
Constant Field Values

NAME_LEN

public static final int NAME_LEN
See Also:
Constant Field Values

SERIAL_NO

public static final String SERIAL_NO
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values

cs

protected static final char[] cs
Constructor Detail

NXTCommDevice

public NXTCommDevice()
Method Detail

isAddress

public static boolean isAddress(String s)
Determine if a string contains a Bluetooth style address.

Parameters:
s - String to test
Returns:
true if the string is an address

stringToAddress

public static byte[] stringToAddress(String strAddress)
Convert a string version of a Bluetooth address into a byte array address.

Parameters:
strAddress - The string version of the address
Returns:
a byte array version of the address

stringToName

public static byte[] stringToName(String strName)
Convert the string version of a devName into a byte array.

Parameters:
strName - string version of the devName
Returns:
byte array containing the devName.

addressToString

public static String addressToString(byte[] addr)
Helper method to convert address byte array to String.

Parameters:
addr - A byte array of bytes containing the address.
Returns:
String representation of Bluetooth address.

nameToString

public static String nameToString(byte[] name)
Return a string version of a device devName held as a byte array

Parameters:
name -
Returns:
string version of devName

setAddress

public static void setAddress(String sn)
Set the USB serial number. Should be a unique 12 character String

Parameters:
sn -

getAddress

public static String getAddress()
Return the current USB serial number.

Returns:
the serial number

setName

public static void setName(String nam)
Set the USB devName. Can be up to 16 character String

Parameters:
nam - the mame

getName

public static String getName()
Return the current USB devName.

Returns:
the devName

loadSettings

public static void loadSettings()
Load the current system settings associated with this class. Called automatically to initialize the class. May be called if it is required to reload any settings.