cparkinson
Posts: 2
Joined: Fri Mar 20, 2009 10:45 pm

Low data rate with SPP and BlueTools

Thu Apr 02, 2009 9:18 pm

We are writing a streaming data service using C# on Windows Vista, with the latest BlueTools API 1.21. This service is effectively a Serial Port Service that allows a client to connect over Bluetooth. Once the client has connected the service streams out data as fast as it can. The client is another Vista machine. Both machines are using a Broadcomm USB BT Dongle, and the standard Microsoft BT Stack as supplied for Vista Serive Pack 1.

When we use BlueTools API to perform the streaming server work we are getting maximum data rates of approximately 40 Kbytes/sec.
When we change our code to use a virtual serial port as supplied by the Windows Bluetooth Stack, and stream data out over the correct serial port we are achieving rates as high as 250Kbytes/sec.

In both cases the Client connecting in and receiving the data is the same Vista box.

We know that Bluetooth 2.0 EDR has a maximum theoretical throughput of 3MBits/s, and with the overhead of packetizing, guaranteed delivery etc… we typically expect 2MBits/s of data transfer. 2MBit/s corresponds to 250Kbytes/sec. So with a virtual com port we are seeing the maximum throughput as we’d expect it.
But in using your tools we get much lower data rates. Are we doing something wrong or its there a problem with your libraries?

Here’s the pseudo code for what we are doing:

Case 1: using virtual serial port via MS Bluetooth Stack

Bluetooth pairing is done with client machine, PINs are exchanged and MS reports that outgoing data can be sent to COM3.
<font face="Courier New"><font color="green">SerialPort serialPort = new SerialPort();
serialPort.PortName= “COM3”;
inside separate thread:

byte[] buffer = new byte[20000];
do{
serialPort.Write(buffer, 0, buffer.Length); //Returns when data has been sent
}while(!exit);</font id="green"></font id="Courier New">

Case 2: Using BlueTools API

<font face="Courier New"><font color="green">localService = new LocalService(ServiceType.SerialPort, “MySerialPortService”, "");
localService.ClientConnected += new BlueToolsEventHandler(ClientConnected);
network.Server.Advertise(localService);

private void ClientConnected(object sender, BlueToolsEventArgs eventArgs)
{
ConnectionEventArgs connectionEvent = (ConnectionEventArgs) eventArgs;
connectedSession = connectionEvent.Session;
stream = connectedSession.Stream;
byte[] buffer = new byte[20000];
do {
stream.Write(buffer, 0, buffer.Length);
stream.Flush();
}while(!exit);
}
</font id="green"> </font id="Courier New">

Does anyone have similar experience. Has anyone gots BlueTools streaming data out faster than 40KBytes/sec.

What are we doing wrong?

Thanks

Chris

Return to “BlueTools”