com.NeuroSky.ThinkGear.IO
Class DummyConnection

java.lang.Object
  extended by com.NeuroSky.ThinkGear.IO.Connection
      extended by com.NeuroSky.ThinkGear.IO.DummyConnection

public class DummyConnection
extends Connection

This class implements a dummy ThinkGear driver. You can use an instance of this class as a live swap-in to perform testing and validation of your application code without requiring a Bluetooth connection. Refer to the documentation for the abstract Connection class for method details.


Constructor Summary
DummyConnection()
           
 
Method Summary
 boolean closeConnection()
          Closes the connection to the ThinkGear headset.
 void flush()
          Flushes data in the output buffer directly to the headset.
 boolean isConnected()
          Check whether the driver is connected to a ThinkGear headset.
 boolean openConnection(java.lang.String deviceID)
          Open a connection to the ThinkGear headset using a unique device identifier.
 boolean openConnection(java.lang.String deviceID, int channel)
          Open a connection to the ThinkGear headset using a unique device identifier and a channel number.
 int read(byte[] byteArray)
          Reads data from the headset into a byte array reference passed in as a parameter.
 void write(byte[] values, int off, int len)
          Writes a value to the headset.
 void write(int value)
          Writes a value to the headset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DummyConnection

public DummyConnection()
Method Detail

isConnected

public boolean isConnected()
Description copied from class: Connection
Check whether the driver is connected to a ThinkGear headset.

Specified by:
isConnected in class Connection
Returns:
true if the headset is connect, false otherwise.

openConnection

public boolean openConnection(java.lang.String deviceID,
                              int channel)
                       throws java.io.IOException
Description copied from class: Connection
Open a connection to the ThinkGear headset using a unique device identifier and a channel number. The identifier takes the form of 12 hexadecimal digits with no delimiters.

Specified by:
openConnection in class Connection
Parameters:
deviceID - a 12-digit hexadecimal value representing the unique device identifier
channel - an integer representing the desired channel to connect on
Returns:
true if the connection attempt was successful, false otherwise
Throws:
java.io.IOException

openConnection

public boolean openConnection(java.lang.String deviceID)
                       throws java.io.IOException
Description copied from class: Connection
Open a connection to the ThinkGear headset using a unique device identifier. The identifier takes the form of 12 hexadecimal digits with no delimiters. Implementations of this method assume that the serial IO communications are performed on channel 1.

Specified by:
openConnection in class Connection
Parameters:
deviceID - a 12-digit hexadecimal value representing the unique device identifier
Returns:
true if the connection attempt was successful, false otherwise
Throws:
java.io.IOException

read

public int read(byte[] byteArray)
         throws java.io.IOException
Description copied from class: Connection
Reads data from the headset into a byte array reference passed in as a parameter.

Specified by:
read in class Connection
Parameters:
byteArray - the byte array that is to be written to
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException

write

public void write(int value)
           throws java.io.IOException
Description copied from class: Connection
Writes a value to the headset.

Specified by:
write in class Connection
Throws:
java.io.IOException

write

public void write(byte[] values,
                  int off,
                  int len)
           throws java.io.IOException
Description copied from class: Connection
Writes a value to the headset.

Specified by:
write in class Connection
Parameters:
values - the value to be written to the headset
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from class: Connection
Flushes data in the output buffer directly to the headset. Use this after a Connection.write(int) to perform an immediate write.

Specified by:
flush in class Connection
Throws:
java.io.IOException

closeConnection

public boolean closeConnection()
                        throws java.io.IOException
Description copied from class: Connection
Closes the connection to the ThinkGear headset.

Specified by:
closeConnection in class Connection
Returns:
true if the connection was successfully closed, false otherwise
Throws:
java.io.IOException