.NET Components for Mobility

BluetoothListener working for Widcomm?

Last post 02-28-2010 3:12 PM by alanjmcf. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-07-2010 3:15 AM

    BluetoothListener working for Widcomm?

    Hi, I have to listen for incoming bluetooth data from sensors (weight scale, blood pressure monitor etc). I have the following code that works fine for a Microsoft stack on a HTC phone. I tested the same on a HTC HD2 (Widcomm stack) and it seems not to work. Where do i go off the track? .......

    // Start a listener and wait for incoming serial port connection
    bluetoothListener = new BluetoothListener(sppService);
    bluetoothListener.Start();

    Thread t = new Thread(new ThreadStart(ListenLoop));
    t.Start();
    .....

    private void ListenLoop()
    {
    BluetoothClient btClient = null;
    while (listening)
    {
    try
    {
    // This call blocks till we get an incoming connection
    btClient = bluetoothListener.AcceptBluetoothClient();

    .........
    }
    catch
    {
    }
    }

    if (btClient != null)
    btClient.Close();
    }
  • 02-07-2010 7:22 AM In reply to

    Re: BluetoothListener working for Widcomm?

    I did some more testing and the code works okay for a Microsoft Bluetooth stack phone but not for the HTC HD2 (Widcomm stack). I made sure that no other part of the application is using bluetooth. I also installed the BluetoothChatPPC on both the Widcommand Microsoft HTC phones. Sending from Widcomm Phone to Microsoft stack Phone works okay but the other way around doesn't. If I try to send from Microsoft Bluetooth phone to Widcomm phone the Widcomm phone wants to pair first with the Microsoft phone and even after successful pairing it does not receive the text. It seems that the bluetoothListener is not working for widcom HTC Hd2 phone? peter
  • 02-07-2010 2:41 PM In reply to

    Re: BluetoothListener working for Widcomm?

    BluetoothListener should be ok on Widcomm.  It's much improved in 2.5 but even in 2.4 it worked ok (in 2.4 we needed the caller to call Accept before it started working for instance).

    If the BluetoothChat app is listening and connecting ok, but not receiving the message, then that's a known problem.  From the Widcomm doc in our release:

    Note Widcomm appears to have a bug with receiving data immediately followed by the sender closing the connection.

    BluetoothChat immediately closes the connection after sending the message, so we hit that problem and the Widcomm stack never passes the data up to us. :-(

  • 02-28-2010 4:26 AM In reply to

    Re: BluetoothListener working for Widcomm?

    Hi I am using your latest dlls to run my application but it seems that the Bluetoothlistener code is not working anymore for the widcom stack. I have uploaded a simple project (with dlls etc) where i listen for incoming connections and a message popup shows if we have an incoming connection. This code works fine for Microsoft stack but nothing happens on a widcomm phone (HTC HD2 and an old Asus p735). Can you please test it and see what is going on? I might have mixed the wrong 32FeetWidcomm dll and the latest inthehand.net.personal


    http://personalheartmonitor.com/download/WidcomListener.zip

    Thanks

    Peter
  • 02-28-2010 2:39 PM In reply to

    Re: BluetoothListener working for Widcomm?

    Works for me in my test app.  I'll try your code when I get a moment...
    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.
  • 02-28-2010 3:12 PM In reply to

    Re: BluetoothListener working for Widcomm?

    Your server (listener) is using the SerialPort Service Class Id.  Widcomm has built-in support for serial ports and thus it is getting the incoming connection.  Either change to using a personal unique Service Class Id (e.g. from Guid.NewGuid), or maybe you can disable the Widcomm virtual COM port.  But that latter might interfere with other things?

    When your application is running we see the two SDP records:

    recordCount: 2
    1)
    AttrId: 0x0000 -- ServiceRecordHandle
    UInt32: 0x10000

    AttrId: 0x0001 -- ServiceClassIdList
    ElementSequence
        Uuid16: 0x1101 -- SerialPort

    AttrId: 0x0004 -- ProtocolDescriptorList
    ElementSequence
        ElementSequence
            Uuid16: 0x100 -- L2CapProtocol
        ElementSequence
            Uuid16: 0x3 -- RFCommProtocol
            UInt8: 0x1
    ( ( L2Cap ), ( Rfcomm, ChannelNumber=1 ) )

    AttrId: 0x0005 -- BrowseGroupList
    ElementSequence
        Uuid16: 0x1002 -- PublicBrowseGroup

    AttrId: 0x0006 -- LanguageBaseAttributeIdList
    ElementSequence
        UInt16: 0x656E
        UInt16: 0x6A
        UInt16: 0x100

    AttrId: 0x0008 -- ServiceAvailability
    UInt8: 0xFF

    AttrId: 0x0009 -- BluetoothProfileDescriptorList
    ElementSequence
        ElementSequence
            Uuid16: 0x1101 -- SerialPort
            UInt16: 0x100

    AttrId: 0x0100 -- ServiceName
    TextString: [en] 'Bluetooth Serial Port'

    ----
    2)
    AttrId: 0x0000 -- ServiceRecordHandle
    UInt32: 0x10009

    AttrId: 0x0001 -- ServiceClassIdList
    ElementSequence
        Uuid16: 0x1101 -- SerialPort

    AttrId: 0x0004 -- ProtocolDescriptorList
    ElementSequence
        ElementSequence
            Uuid16: 0x100 -- L2CapProtocol
            UInt16: 0x3
        ElementSequence
            Uuid16: 0x3 -- RFCommProtocol
            UInt8: 0x1
    ( ( L2Cap, PSM=Rfcomm ), ( Rfcomm, ChannelNumber=1 ) )

    AttrId: 0x0100
    TextString (guessing UTF-8): 'PWAccessP'

    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.
Page 1 of 1 (6 items)
Copyright © 2001-2010 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.