.NET Components for Mobility

Communication with Bluetooth adapter

Last post 07-18-2007 3:47 PM by duluca. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-17-2007 5:09 PM

    • duluca
    • Top 200 Contributor
    • Joined on 07-09-2007
    • Posts 3

    Communication with Bluetooth adapter

    Hello,

    I'm trying to communicate with a custom built device that uses this bluetooth adapter: http://www.lintech.de/index.php?index=19&pc=4&p=13

    Using the 32feet.Net library I can sucessfully establish a connection and setup a NetworkStream. The device I'm working with should respond to commands that is being sent to it. Such as, sending ?T would return !T25.05, which then I would have to parse and use the 25.05 value.

    I try to do this by writing to the network stream and then I read from the network stream until the read timeout kicks in. I tried writing in ?T as binary and hex, but none of it worked.

    You can check out a manual for the commands on: http://www.deceivingarts.com/commands_long.pdf

    I'd be glad if some can give me an insight about how I could make this work.

    Doug

     

    Filed under: , ,
  • 07-18-2007 6:06 AM In reply to

    Re: Communication with Bluetooth adapter

    The commands PDF is 404, is it the correct URL?  The website seems to be for a film called Hush, and the homepage hangs my IE! :-,(

    To send, for now build the bytes to send by hand, e.g.

            byte[] request = { (byte)'?', (byte)'?', 0x0D, 0x0A };

    And write that buffer to the NetworkStream.  How is the end of the command signalled?  I assumed with CRLF there.  You can later use a StreamWriter, or use Encoding.GetBytes(string) to send a string.

    Try the receive loop:

                while (true) {
                    int bi = netStrm.ReadByte();
                    if (bi == -1) {
                        Console.WriteLine("end of stream");
                    }
                    byte b = (byte)bi;
                    Console.Write("{0:X2} ", b);
                }

    How is the end of a response signalled?

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 07-18-2007 8:28 AM In reply to

    • duluca
    • Top 200 Contributor
    • Joined on 07-09-2007
    • Posts 3

    Re: Communication with Bluetooth adapter

    Thanks for your reply. Sorry, I misspelled the name of the PDF file. The correct link should be:

    http://www.deceivingarts.com/Command_long.pdf

    The website is for my short movie :) But I'm sorry that it hangs your IE. It tries to load the DivX web player plug-in, that may be the problem. 

     I think you are right about a command ending with CRLF. Now it makes sense to me that the response signal also ends with a CRLF.

    Another concern I have are the connection settings. Such as the baudrate, data bits, parity, stop bits and protocol. I know how to set these in a SerialPort class. But I couldn't find such settings in 32feet.Net library. How crucial is to get these settings right? And how can it be done withinin 32feet.Net?

    I basically setup my computer as a Bluetooth client, then I connect to my device with an endpoint(device.address, serialport guid). Then I get the NetworkStream of the connection. Is this enough, or should I configuring the connection settings?

    Thanks,

     Doug

  • 07-18-2007 3:33 PM In reply to

    Re: Communication with Bluetooth adapter

    I was going to say maybe it uses modem-like new-lines: DTE <CR>, and DCE <CR><LF>.  But I see in your PDF in section 1.2 that both ends use CRLF.

    I think the serial-port settings will be ignored by all parties.  There's no hardware at the BluetoothClient end, the serial cable is all software, and presumably the settings at "custom built device" to "bluetooth adapter" interface are configured locally.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 07-18-2007 3:47 PM In reply to

    • duluca
    • Top 200 Contributor
    • Joined on 07-09-2007
    • Posts 3

    Re: Communication with Bluetooth adapter

    I was able to change the baudrate of the device through a software provided by the manufacturer of the bluetooth adapter.

    As mentioned in the documentation, I set the baudrate to 9600 and using your code I was able to get response from the device.

    The only change I made to your code was how the reading stopped. If I saw a CR followed by an LF, I break from the while loop. Otherwise, it gets stuck on read byte command.

    Thank you for your help.

Page 1 of 1 (5 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.