.NET Components for Mobility

Why Ports class is no available under Desktop Windows Library?

Last post 06-21-2009 1:27 AM by enocturno. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-18-2009 7:47 PM

    Why Ports class is no available under Desktop Windows Library?

     Hi all,

         I just wonder why ports class is no available under desktop windows library? I am experimenting with this amazing library, but i have this problem now, i'm trying to create a custom enumerator utility for my GPS RBT-2300, but this utility requires the serial port to be registere.

     

     

    I found this information... http://www.alanjmcf.me.uk/comms/bluetooth/32feet.NET%20--%20User%20Guide.html

     ----------------------------------------------------------------------------------------------------------------

    Bluetooth Serial Ports

    By far the easiest and best way to use a serial port connection is to use BluetoothClient with service class BluetoothService.SerialPort, i.e. using code very much like shown above.  Both BluetoothClient and virtual serial ports use the RFCOMM protocol so the two are equivalent.  This method is much easier to set-up that a virtual serial port, there is no global state to configure etc; and is also more robust, for instance if the peer device is taken out of range or turned-off one learns this directly soon after, whereas with a serial port one has to use timeouts and retries to detect it.

    However there are cases where a virtual serial port is required, for instance where another program needs to access the connection — a common case is where your program is configuring a connection that will be used by a printer driver utility.  Two methods for creating a Bluetooth virtual serial port exist in the library, the first is class BluetoothSerialPort, this creates a connection immediately but the underlying API it uses is rather unreliable, and it seems not to work at all on various device types.  The second is BluetoothDeviceInfo.SetServiceState passing in service class SerialPort, this configures the necessary Registry settings and is reliable but requires a reboot before the port becomes available.  A difficulty, as with the same method on desktop Windows, is that the name of the COM port created is not returned.

    On the Microsoft stack on CE/WM both methods are supported, on the Microsoft stack on desktop Windows we support only SetServiceState, and on Widcomm on both platforms we currently support neither.

     ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    Clearly says that the class BluetoothSerialPort and available for desktop windows.  Even unreliable as it says it would be nice to experiment with it.

    Thanks in advance for any comment on this matter.

     Eduardo

     

  • 06-19-2009 7:08 AM In reply to

    Re: Why Ports class is no available under Desktop Windows Library?

    SetServiceState is supported on both platforms.  BluetoothSerialPort uses an API that exist *only* on CE/WM.

    If you want *your* application to connect to the device, just use

       BluetoothAddress addr = ...
       BluetoothClient cli = new BluetoothClient();
       cli.Connect(addr, BluetoothService.SerialPort);
       ... as shown in the user guide...

     If you want another application then you'll need the virtual serial port to be created for it to use.

    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.
  • 06-19-2009 11:11 PM In reply to

    Re: Why Ports class is no available under Desktop Windows Library?

     Thanks for your quick answer Alan, now i will try to find a quick way to create the virtual serial port and link it to this channel.

     Regards. 

  • 06-20-2009 7:09 AM In reply to

    Re: Why Ports class is no available under Desktop Windows Library?

    If you use BluetoothClient **no** virtual serial port is required.

     

    If you want to programmatically createa virtual serial port do:

        Dim device As BluetoothDeviceInfo = ... from discovery / or: New BluetoothDeviceInfo(addr) / etc
        Dim ret As Boolean = device.SetServiceState(BluetoothService.SerialPort, true)

    A virtual serial port will be created. :-)  It doesn't tell the name (e.g. COM23) however. :-(

    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.
  • 06-21-2009 1:27 AM In reply to

    Re: Why Ports class is no available under Desktop Windows Library?

    WoW nice, that makes things a lot easier. I solved the name problem comparing the created ports before the creation and 10 sec after. Then you will get the last port created. Not the best solution but for now very useful.

     Regards,

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