public class TgStreamReader
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
TgStreamReader.ChampionData |
static class |
TgStreamReader.ParserType |
Modifier and Type | Field and Description |
---|---|
static int |
RECORD_ERROR_FILE_PATH_NOT_READY |
static int |
RECORD_ERROR_READ_THREAD_NOT_WORKING |
static int |
RECORD_ERROR_RECORD_IS_ALREADY_WORKING |
static int |
RECORD_ERROR_RECORD_OPEN_FILE_FAILED |
Constructor and Description |
---|
TgStreamReader(BluetoothAdapter ba,
TgStreamHandler tgStreamHandler)
This method is used to connect NeuroSky's hardware with Android phone via Bluetooth, get the stream and parse the data.
|
TgStreamReader(BluetoothDevice mBluetoothDevice,
TgStreamHandler tgStreamHandler)
This method is used to connect NeuroSky's hardware with given BluetoothDevice
|
TgStreamReader(java.io.InputStream is,
TgStreamHandler tgStreamHandler)
This method is used to read back raw data from file and parse them.
|
Modifier and Type | Method and Description |
---|---|
void |
changeBluetoothDevice(BluetoothDevice bluetoothDevice)
Change a Bluetooth device for current TgStreamReader
|
void |
close()
Close the connect thread, if it has not finished.
|
void |
connect()
Connect to the target.
|
void |
connectAndStart()
The process of connect will take several seconds or more , if you don't want to handle the waiting time, use this method instead.
|
static java.lang.String |
getVersion()
Return the SDK version
|
boolean |
isBTConnected()
Check the connected states
|
static void |
redirectConsoleLogToDocumentFolder()
Redirect the console log to file under /sdcard/neruosky/Console_log/yyyyMMdd_HH_mm_ss.txt
|
void |
sendCommandtoDevice(byte[] command)
Send command to device
|
void |
setGetDataTimeOutTime(int seconds)
set the timeout time for read thread, the default time is 5s
|
void |
setParser(TgStreamReader.ParserType parserType,
int sampleRate)
Set parser for stream reader.
|
void |
setReadFileBlockSize(int size)
Set the block size for reading file thread, the default size is 8.
|
void |
setReadFileDelay(int delayTime)
If the working thread read file too fast, give a tiny delay after reading once, the default delay is 2ms
|
void |
setRecordStreamFilePath(java.lang.String filePath)
Set the file path for recording the stream data, the default path is /sdcard /neurosky/year-month-day-hour-minute-second-RawPackageRecording.txt
|
void |
setTgStreamHandler(TgStreamHandler cb)
Set the TgStreamHandler for TgStreamReader
|
void |
start()
Start the reading thread.
|
void |
startLog()
Enable the debug log.
|
void |
startRecordRawData()
Set the record flag for reading thread.
|
void |
stop()
Stop the read thread.
|
static void |
stopConsoleLog()
Stop the console log process.
|
void |
stopLog()
Disable the debug log.
|
void |
stopRecordRawData()
Stop record the stream data and flush the store file.
|
public static final int RECORD_ERROR_FILE_PATH_NOT_READY
public static final int RECORD_ERROR_READ_THREAD_NOT_WORKING
public static final int RECORD_ERROR_RECORD_IS_ALREADY_WORKING
public static final int RECORD_ERROR_RECORD_OPEN_FILE_FAILED
public TgStreamReader(java.io.InputStream is, TgStreamHandler tgStreamHandler)
is
- InputStream from the filetgStreamHandler
- callback for TgStreamReaderpublic TgStreamReader(BluetoothAdapter ba, TgStreamHandler tgStreamHandler)
ba
- BluetoothAdaptertgStreamHandler
- callback for TgStreamReaderpublic TgStreamReader(BluetoothDevice mBluetoothDevice, TgStreamHandler tgStreamHandler)
mBluetoothDevice
- tgStreamHandler
- callback for TgStreamReaderpublic static java.lang.String getVersion()
public void setParser(TgStreamReader.ParserType parserType, int sampleRate)
parserType
- ParserType enumsampleRate
- current support sample rate include 1024, 2048public void changeBluetoothDevice(BluetoothDevice bluetoothDevice)
bluetoothDevice
- public void startLog()
public void stopLog()
public void setTgStreamHandler(TgStreamHandler cb)
cb
- TgStreamHandlerpublic void setRecordStreamFilePath(java.lang.String filePath)
filePath
- file pathpublic void startRecordRawData()
public void stopRecordRawData()
public void connect()
public void start()
public void connectAndStart()
public void sendCommandtoDevice(byte[] command)
command
- public void setGetDataTimeOutTime(int seconds)
seconds
- time for timeoutpublic void setReadFileBlockSize(int size)
size
- bytes numberpublic void setReadFileDelay(int delayTime)
delayTime
- time in mspublic void stop()
public void close()
public boolean isBTConnected()
public static void redirectConsoleLogToDocumentFolder()
public static void stopConsoleLog()