Package lejos.remote.nxt
Class NXTCommDevice
- java.lang.Object
-
- lejos.remote.nxt.NXTCommDevice
-
public abstract class NXTCommDevice extends java.lang.ObjectBase class for nxt communications devices. Provides a common address/name, plus utility functions.- Author:
- andy
-
-
Field Summary
Fields Modifier and Type Field Description static intADDRESS_LENprotected static char[]csstatic java.lang.StringNAMEstatic intNAME_LENstatic java.lang.StringSERIAL_NO
-
Constructor Summary
Constructors Constructor Description NXTCommDevice()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringaddressToString(byte[] addr)Helper method to convert address byte array to String.static java.lang.StringgetAddress()Return the current USB serial number.static java.lang.StringgetName()Return the current USB devName.static booleanisAddress(java.lang.String s)Determine if a string contains a Bluetooth style address.static voidloadSettings()Load the current system settings associated with this class.static java.lang.StringnameToString(byte[] name)Return a string version of a device devName held as a byte arraystatic voidsetAddress(java.lang.String sn)Set the USB serial number.static voidsetName(java.lang.String nam)Set the USB devName.static byte[]stringToAddress(java.lang.String strAddress)Convert a string version of a Bluetooth address into a byte array address.static byte[]stringToName(java.lang.String strName)Convert the string version of a devName into a byte array.
-
-
-
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 java.lang.String SERIAL_NO
- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
cs
protected static final char[] cs
-
-
Method Detail
-
isAddress
public static boolean isAddress(java.lang.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(java.lang.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(java.lang.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 java.lang.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 java.lang.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(java.lang.String sn)
Set the USB serial number. Should be a unique 12 character String- Parameters:
sn-
-
getAddress
public static java.lang.String getAddress()
Return the current USB serial number.- Returns:
- the serial number
-
setName
public static void setName(java.lang.String nam)
Set the USB devName. Can be up to 16 character String- Parameters:
nam- the mame
-
getName
public static java.lang.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.
-
-