Class NXTCommDevice


  • public abstract class NXTCommDevice
    extends java.lang.Object
    Base class for nxt communications devices. Provides a common address/name, plus utility functions.
    Author:
    andy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ADDRESS_LEN  
      protected static char[] cs  
      static java.lang.String NAME  
      static int NAME_LEN  
      static java.lang.String SERIAL_NO  
    • Constructor Summary

      Constructors 
      Constructor Description
      NXTCommDevice()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String addressToString​(byte[] addr)
      Helper method to convert address byte array to String.
      static java.lang.String getAddress()
      Return the current USB serial number.
      static java.lang.String getName()
      Return the current USB devName.
      static boolean isAddress​(java.lang.String s)
      Determine if a string contains a Bluetooth style address.
      static void loadSettings()
      Load the current system settings associated with this class.
      static java.lang.String nameToString​(byte[] name)
      Return a string version of a device devName held as a byte array
      static void setAddress​(java.lang.String sn)
      Set the USB serial number.
      static void setName​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NXTCommDevice

        public NXTCommDevice()
    • 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.