com.neurosky.thinkgear
Class TGDevice

java.lang.Object
  extended by com.neurosky.thinkgear.TGDevice

public class TGDevice
extends java.lang.Object

Class to connect and receive data from a ThinkGear device.

Author:
Tin Nguyen

Field Summary
static boolean ekgPersonalizationEnabled
           
 com.neurosky.thinkgear.TGDevice.EkgSenseManager ekgSenseMan
           
 int inputAge
           
static boolean L
           
static int MSG_ATTENTION
           
static int MSG_BLINK
           
static int MSG_DIFFICULTY
           
static int MSG_EEG_POWER
           
static int MSG_EGO_TRIM
           
static int MSG_EKG_IDENTIFIED
           
static int MSG_EKG_RRINT
           
static int MSG_EKG_TRAIN_STEP
           
static int MSG_EKG_TRAINED
           
static int MSG_FAMILIARITY
           
static int MSG_HEART_AGE
           
static int MSG_HEART_AGE_5MIN
           
static int MSG_HEART_RATE
           
static int MSG_LOW_BATTERY
           
static int MSG_MEDITATION
           
static int MSG_MULTI_SIGNAL_STATUS
           
static int MSG_POOR_SIGNAL
           
static int MSG_POSITIVITY
           
static int MSG_RAW_COUNT
           
static int MSG_RAW_DATA
           
static int MSG_RAW_MULTI
           
static int MSG_RELAXATION
           
static int MSG_RESPIRATION
           
static int MSG_SLEEP_STAGE
           
static int MSG_STATE_CHANGE
           
static int MSG_THINKCAP_RAW
           
static int MSG_THINKCAPBETA_RAW
           
static int MSG_ZONE
           
 int pass_seconds
           
static int STATE_CONNECTED
           
static int STATE_CONNECTING
           
static int STATE_DISCONNECTED
           
static int STATE_ERR_BT_OFF
           
static int STATE_ERR_NO_DEVICE
           
static int STATE_IDLE
           
static int STATE_NOT_FOUND
           
 
Constructor Summary
TGDevice(BluetoothAdapter btAdapter, Handler handler)
          Initializes a new TGDevice that will connect to a ThinkGear hardware device via Bluetooth.
TGDevice(java.io.InputStream s, java.io.OutputStream o, Handler handler)
          Initializes a new TGDevice that will read from a ThinkGear hardware device via @c s and write to the ThinkGear hardware device via @c o.
 
Method Summary
 void close()
          Closes the connection to the device.
 void connect(BluetoothDevice btDevice)
          Connects to the specified Bluetooth device with raw EEG disabled.
 void connect(BluetoothDevice btDevice, boolean rawEnabled)
          Connects to the specified Bluetooth device with configurable raw output.
 void connectStream(boolean rawEnabled)
          Connects to InputStream specified by constructor with configurable raw output.
 void connectUart(boolean rawEnabled)
          Deprecated.  
 boolean EKGdeleteUser(java.lang.String name)
           
 int EKGloadParams(java.lang.String name)
           
 void EKGstartDetection()
           
 void EKGstartLongTraining(java.lang.String userName)
           
 void EKGstartTraining(java.lang.String userName)
          Deprecated.  
 void EKGstopDetection()
           
 void EKGstopTraining()
           
 BluetoothDevice getConnectedDevice()
          Returns the currently connected device
 double getHeartAge()
           
 int getHeartRisk()
           
 int getState()
          Gets the state of the TGDevice
 int getVersion()
          Returns the version number of the TGDevice driver
 void start()
          Starts the data stream.
 boolean startByteLog(java.lang.String path, java.lang.String fileName)
           
 boolean startLog(java.lang.String path, java.lang.String fileName)
          Enables logging of the stream
 void stop()
          Stops the data stream.
 void stopLog()
          Disables logging of stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_IDLE

public static final int STATE_IDLE
See Also:
Constant Field Values

STATE_CONNECTING

public static final int STATE_CONNECTING
See Also:
Constant Field Values

STATE_CONNECTED

public static final int STATE_CONNECTED
See Also:
Constant Field Values

STATE_DISCONNECTED

public static final int STATE_DISCONNECTED
See Also:
Constant Field Values

STATE_NOT_FOUND

public static final int STATE_NOT_FOUND
See Also:
Constant Field Values

STATE_ERR_NO_DEVICE

public static final int STATE_ERR_NO_DEVICE
See Also:
Constant Field Values

STATE_ERR_BT_OFF

public static final int STATE_ERR_BT_OFF
See Also:
Constant Field Values

MSG_STATE_CHANGE

public static final int MSG_STATE_CHANGE
See Also:
Constant Field Values

MSG_POOR_SIGNAL

public static final int MSG_POOR_SIGNAL
See Also:
Constant Field Values

MSG_HEART_RATE

public static final int MSG_HEART_RATE
See Also:
Constant Field Values

MSG_ATTENTION

public static final int MSG_ATTENTION
See Also:
Constant Field Values

MSG_MEDITATION

public static final int MSG_MEDITATION
See Also:
Constant Field Values

MSG_EGO_TRIM

public static final int MSG_EGO_TRIM
See Also:
Constant Field Values

MSG_ZONE

public static final int MSG_ZONE
See Also:
Constant Field Values

MSG_BLINK

public static final int MSG_BLINK
See Also:
Constant Field Values

MSG_RELAXATION

public static final int MSG_RELAXATION
See Also:
Constant Field Values

MSG_RESPIRATION

public static final int MSG_RESPIRATION
See Also:
Constant Field Values

MSG_POSITIVITY

public static final int MSG_POSITIVITY
See Also:
Constant Field Values

MSG_FAMILIARITY

public static final int MSG_FAMILIARITY
See Also:
Constant Field Values

MSG_DIFFICULTY

public static final int MSG_DIFFICULTY
See Also:
Constant Field Values

MSG_RAW_DATA

public static final int MSG_RAW_DATA
See Also:
Constant Field Values

MSG_EEG_POWER

public static final int MSG_EEG_POWER
See Also:
Constant Field Values

MSG_RAW_MULTI

public static final int MSG_RAW_MULTI
See Also:
Constant Field Values

MSG_THINKCAPBETA_RAW

public static final int MSG_THINKCAPBETA_RAW
See Also:
Constant Field Values

MSG_THINKCAP_RAW

public static final int MSG_THINKCAP_RAW
See Also:
Constant Field Values

MSG_SLEEP_STAGE

public static final int MSG_SLEEP_STAGE
See Also:
Constant Field Values

MSG_MULTI_SIGNAL_STATUS

public static final int MSG_MULTI_SIGNAL_STATUS
See Also:
Constant Field Values

MSG_RAW_COUNT

public static final int MSG_RAW_COUNT
See Also:
Constant Field Values

MSG_LOW_BATTERY

public static final int MSG_LOW_BATTERY
See Also:
Constant Field Values

MSG_EKG_IDENTIFIED

public static final int MSG_EKG_IDENTIFIED
See Also:
Constant Field Values

MSG_EKG_TRAINED

public static final int MSG_EKG_TRAINED
See Also:
Constant Field Values

MSG_EKG_TRAIN_STEP

public static final int MSG_EKG_TRAIN_STEP
See Also:
Constant Field Values

MSG_EKG_RRINT

public static final int MSG_EKG_RRINT
See Also:
Constant Field Values

MSG_HEART_AGE

public static final int MSG_HEART_AGE
See Also:
Constant Field Values

MSG_HEART_AGE_5MIN

public static final int MSG_HEART_AGE_5MIN
See Also:
Constant Field Values

L

public static final boolean L
See Also:
Constant Field Values

ekgPersonalizationEnabled

public static final boolean ekgPersonalizationEnabled
See Also:
Constant Field Values

ekgSenseMan

public com.neurosky.thinkgear.TGDevice.EkgSenseManager ekgSenseMan

inputAge

public int inputAge

pass_seconds

public int pass_seconds
Constructor Detail

TGDevice

public TGDevice(BluetoothAdapter btAdapter,
                Handler handler)
Initializes a new TGDevice that will connect to a ThinkGear hardware device via Bluetooth. The state of the TGDevice will start as STATE_IDLE. If the Android device's Bluetooth adapter is turned off, a STATE_ERR_BT_OFF message will be sent to the @c handler.

Parameters:
btAdapter - BluetoothAdapter of the device.
handler - A Handler to accept and process messages from this TGDevice. Refer to the "Android Development Guide for ThinkGear" for details.

TGDevice

public TGDevice(java.io.InputStream s,
                java.io.OutputStream o,
                Handler handler)
Initializes a new TGDevice that will read from a ThinkGear hardware device via @c s and write to the ThinkGear hardware device via @c o. The state of the TGDevice will start as STATE_IDLE.

Parameters:
s - An InputStream reading from a ThinkGear hardware device.
o - An (@link OutputStream} writing to a ThinkGear hardware device.
handler - A Handler to accept and process messages from this TGDevice. Refer to the "Android Development Guide for ThinkGear" for details.
Method Detail

getVersion

public int getVersion()
Returns the version number of the TGDevice driver

Returns:
int Version number

connect

public void connect(BluetoothDevice btDevice)
Connects to the specified Bluetooth device with raw EEG disabled.

Parameters:
btDevice - Desired BluetoothDevice

connect

public void connect(BluetoothDevice btDevice,
                    boolean rawEnabled)
Connects to the specified Bluetooth device with configurable raw output.

Parameters:
btDevice - Desired BluetoothDevice
rawEnabled - Enable or disable raw EEG output.

connectUart

public void connectUart(boolean rawEnabled)
Deprecated. 

Scans and connects to a UART device with configurable raw output.

Parameters:
rawEnabled - Enable or disable raw EEG output.

connectStream

public void connectStream(boolean rawEnabled)
Connects to InputStream specified by constructor with configurable raw output.

Parameters:
rawEnabled - Enable or disable raw EEG output.

close

public void close()
Closes the connection to the device.


start

public void start()
Starts the data stream.


stop

public void stop()
Stops the data stream.


getConnectedDevice

public BluetoothDevice getConnectedDevice()
Returns the currently connected device

Returns:
BluetoothDevice

getState

public int getState()
Gets the state of the TGDevice

Returns:
the state of the device as defined in the constants

startLog

public boolean startLog(java.lang.String path,
                        java.lang.String fileName)
Enables logging of the stream

Parameters:
path - Location of desired log file. Pass in empty string for default location [external storage]/Android/data/com.neurosky.thinkgear/
fileName - Filename of desired log file. Pass in empty string for default filename yyyy-MM-dd-hhmmss.txt (current timestamp)
Returns:
True if successful. False if no external storage available or logging is already enabled.

startByteLog

public boolean startByteLog(java.lang.String path,
                            java.lang.String fileName)

stopLog

public void stopLog()
Disables logging of stream.


getHeartAge

public double getHeartAge()

getHeartRisk

public int getHeartRisk()

EKGloadParams

public int EKGloadParams(java.lang.String name)

EKGstartDetection

public void EKGstartDetection()

EKGstopDetection

public void EKGstopDetection()

EKGstartTraining

public void EKGstartTraining(java.lang.String userName)
Deprecated. 


EKGstartLongTraining

public void EKGstartLongTraining(java.lang.String userName)

EKGstopTraining

public void EKGstopTraining()

EKGdeleteUser

public boolean EKGdeleteUser(java.lang.String name)