Sending data between Arduino and Bluetooth the right way

Hey Guys,

I'm currently quite desperate because I don't receive proper data on my Java program.

The problem is:
I'm receiving data from a u-Blox GPS-receiver via Bluetooth Modul (BTM-182) using the UBX Protocol.
The Arduino should just pass the data right on to the BTM-182 and the BTM-182 should just pass it on to a Java program which sends it to a Server via TCP/IP.
I'm receiving the data on the Server but sometimes its not the right data...I think between all that passing there must be a leak so the data gets cut off or something like that...

Could you guys tell me what I'm doing wrong?
On Arduino I'm using AltSoftSerial because I read that NewSoftSerial doesn't work properly on 19200 Baud.

Arduino Code:

#include <AltSoftSerial.h>

AltSoftSerial GPS;
#define BT Serial

byte bytes;         

void setup()
{
  BT.begin(19200); 
  GPS.begin(19200);
  delay(2000);
}

void loop()
{
  if (GPS.available()) {
    bytes = GPS.read();
    BT.write(bytes);
  }
}

The BTM-182 is already configured to 19200 Baud!

Hier is the Java Code:

if (inputBt.available() > 0) {
	bytesRead = inputBt.read(buffer);
	clientIn.write(buffer, 0, bytesRead);
}

If data comes in from the BTM I just pass it to the server without touching it.
I think its rather the Arduinos code which doesn't work properly...

Should there be any delays? The frequency of the GPS-receiver is 1Hz.

I'd really appreciate a quick answer...all this is for my bachelors thesis and it really HAS to work....

Thank you guys really much in advance!!!!

regards GeoySurveyor

On Arduino I'm using AltSoftSerial because I read that NewSoftSerial doesn't work properly on 19200 Baud.

I don't know where you read that, but it was wrong.

byte bytes;

The name implies that you can store multiple things in the variable. Not true. Why is the name plural?

I'm receiving the data on the Server but sometimes its not the right data...I think between all that passing there must be a leak so the data gets cut off or something like that...

You haven't shown anything that illustrates that point.

19200 is a rather strange baud rate for a GPS.

or is it about the Buffer Size?
The GPS receiver doesnt send me always the same amount of data.
Is there a way to wait till the hole message is there and as soon as I have the hole message I send it to the Bluetooth Modul?

ok so should I try to set up the baud to 38400?
Sorry i have nothing todo with electronics but I really need this converter to work ... :cold_sweat:

or is it about the Buffer Size?

Which buffer are you referring to?

The GPS receiver doesnt send me always the same amount of data.

Smack it around, and tell it to behave.

First thing I'd do is throw the bluetooth module back in the drawer until you have the process working using wires. (That is a USB cable connecting the Arduino to the PC.)

Is there a way to wait till the hole message is there and as soon as I have the hole message I send it to the Bluetooth Modul?

There is, but that won't speed things up, recover lost data, etc. That is, it isn't a solution.