Tried increasing timer interval to 400 milliseconds -- resulted in total packet loss.
I basically am reinventing the wheel here -- NeuroSky provides Android developers with a nice little .jar to add to Android projects that handles all the stream reading and parsing, but unfortunately not compatible with App Inventor as far as I can tell. Other than that, my app is working great -- it uses the voice recognizer to associate speech and EEG patterns which are then referenced in the future to output speech (I look at a computer and it says "computer" etc.)
The MindWave also outputs a smaller packet for raw EEG data 512 times per second -- I am able to receive and parse a greater percentage of those. However, the ThinkGear chip in Mindwave automatically removes artifacts and performs Fourier transformation on raw EEG to produce the 1 second power spectrum packets, which is why I really would like to decrease my packet loss!
Questions:
1. Even though I have a buffer, is it possible that other procedures may be interfering with the execution of "receive byte"?
2. If I got rid of the timer altogether and looped "receive byte," could that allow my app to sample at a rate faster than the timer allows? (would require rewriting a lot of code, but would definitely be worth it if it has a chance of success).
3. If neither of the above solve the problem, would it be possible to implement something like this with Activity Starter: (Java ignoramus here)
public void run() {
byte[] buffer = new byte[1024];
int bytes; while (true) { try {
bytes = mmInStream.read(buffer);
mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
break;
}
}
}