Hi,

I've created a midlet that reads data from a bluetooth GPS. It works perfectly on for example Nokia 6600, but gives the error message below on nokia 9500:

Reason code: E32USER-CBase
Number Code:40

I googled on this and found the issue below:

KIJ000109
Another issue is that the InputStream cannot use a bigger byte array than 512 bytes when reading stream. A bigger byte array may crash the MIDlet.
Solution to the stream size issue: Do not use a bigger byte array than 512 bytes. Read the input stream in a loop or keep the whole length of the stream under 512 bytes.(http://forum.nokia.com/document/Forum_Nokia_Technical_Library/contents/FNTL/Using_Bluetooth_serial_port_in_MIDlets.htm)

I consider this a very likely reason, because my midlet gets data continously from the GPS so it may happen that this limit is exceeded.

My question is: how should I modify my code to avoid this error? The data is coming continously from the GPS so I guess I can't limit the input. I'm thinking about reseting regularly somehow the inputstream, but couldn't figure out how to do this.
I would greatly appreciate any suggestions on this.
Here is my code to modify:

// connecting to BT GPS device
public void connect()
{
state = CONNECTING;
try
{
// kapcsolodas
connection = (StreamConnection) Connector.ope(serviceURL, Connector.READ);
reader = new InputStreamReader(connection.openInputStream());

}
catch (IOException ex)
{
ex.printStackTrace();
midlet.Dump(StrErrorConnFailed);
}

}

// continous reading from BT GPS device
public void run()
{

// folyamatos adatolvasas
try
{
String data="";
int c;

while((c=reader.read())!= LINE_DELIMITER)
{
data += (char)c;
}

btm.appendRawData(data);

}

catch (IOException ex)
{
midlet.Dump(ex.getMessage());
}


}

Thanks a lot!
Örs