How to read data from Leica DISTO via bluetooth?

Viewed 3976

I have a Leica DISTO D3a BT. It is a measuring device and it send the measure via bluetooth.

I wrote some code to get the bluetooth stream, I receive the data but I always got the "Error 240" message.

It means (from the user manual) that I do not confirm the succesfulness of the data transmission.

How can I do it?

Here is my code:

int bytesRead = 0;
System.IO.Stream stream = client_.GetStream();
byte[] buffer = new byte[k_BUFFER_BYTES];  
while(true)
{
    Task.Delay(100);
    if (client_.Available > 0) // Available contains the available bytes
    {
        int counter = 0;
        string output = "";

        while (counter < client_.Available)
        {
            bytesRead = stream.Read(buffer, 0, k_BUFFER_BYTES);
            counter += bytesRead ;

            output += System.Text.Encoding.ASCII.GetString(buffer, 0, bytesRead);
        }
        stream.Write(Encoding.ASCII.GetBytes("\r\n"), 0, 2);
        stream.Flush();

        Console.WriteLine(output + " - " + counter + " - " + client_.Available);
    }
}

Thanks in advance for any help!

3 Answers
Related