.NET Components for Mobility

Waiting for connection

Last post 09-05-2010 6:38 AM by alanjmcf. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-30-2010 10:40 AM

    Waiting for connection

    Hallo everybody!

    I need some help with a problem I have:

    I want to wait via Smartphone for a bluetooth- connection. After successful connection a stream should be open and a data transmition can start. 

    I tried the Bluetoothlistener but wasn't successful.

    Can anybody give me a link, a code that helps me?

    I am hoping for answers :)

    Kind regads

    Alex

     

  • 08-30-2010 11:10 AM In reply to

    Re: Waiting for connection

    Don't know whether you've read the User Guide (in the release and at http://www.alanjmcf.me.uk/comms/bluetooth/32feet.NET -- User Guide.html).  There's a code sample there.  You can also just run the SdpBrowserXxxx sample and you can start a bluetooth listener using it (on any standard Service Class Id).

    What does the client program do?  Connect to Service Class "Serial Port"?  Or something different?

  • 08-31-2010 8:01 AM In reply to

    Re: Waiting for connection

    The Client program should wait for an connection request from a blood pressure metre. After the connection the measurements should be transmitted.

    I have tried the follow code

    public NetworkStream WaitForConnection()
            {       
                BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
                Guid g = BTServices.Instance.GetServiceValue("SerialPort");
                BluetoothListener listener = new BluetoothListener(g);
                listener.Start();
                BluetoothClient c=listener.AcceptBluetoothClient();
                return c.GetStream();
            }

     If  I am right, this is the moment where the listener is waiting for a connection!?!? My device worked and should have searched for my "Bluetoothname" In the underline line, the program stops and nothing happens (So it still doesn't work). Is the listener waiting for a connection there?

    What should normaly happens I there is a pairing request?

    I know this are stupid questions :D but I am a beginner!

  • 09-01-2010 3:15 AM In reply to

    Re: Waiting for connection

    I would call that code "server", its hosting a Bluetooth RFCOMM service.  That code looks fine (assuming the correct Guid is being used), so it would just seem that the other device is not connecting.  How does the " blood pressure meter" know what device to connect to?  Does your smartphone have to be given a special Bluetooth Device Name perhaps?  Is there documentation somewhere online for the meter?
  • 09-01-2010 9:48 AM In reply to

    Re: Waiting for connection

    I've tried an test application to connect to my Smartphone. This worked. So the problem is at the blood pressure meter!

     The device has two different modes:

    Active and passive

    In the passive mode it does an measurement and establish a connection after doing.

    So you can connect to the device and request the result.

    This worked pretty good. I have done this in a short time.

     But I need this in an active mode.

    In this mode the device searches after each measurement for an established bluetooth connection.

    You have to set a filter on the device.

    The filter seaches for special name ,special DIAC and special service.

    The thing I am knowing for 100% sure is the name of the device, the DIAC!

    But I am not sure for the name of the service: If I establish a connection with the Guid "SerialPort" do you think that the blood meter finds this as "SerialPort"? How can I find out which Service a device establish? Does it work with the Class DeviceInfo?

     

  • 09-03-2010 9:52 AM In reply to

    Re: Waiting for connection

    Ok! I have solved the problem!

     There were many reasons why it didn't work

    • old version of library
    • wrong COD
    • wrong servicename

    :D

     At least one question... Is it possible to use Bluetooth as well as server as well as client?

     

  • 09-05-2010 6:38 AM In reply to

    Re: Waiting for connection

    Glad to hear you solved it.

    In this case where you are using BluetoothListener you are acting as a server, the meter device is "active" and is thus a client.
Page 1 of 1 (7 items)
Copyright © 2001-2012 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting