none
Bluetooth problem without a solution RRS feed

  • Question

  • Hi

    in the device handler, when a BT unit is active, you can see the it has 2 ports, one OUT and one IN. The OUT port is for the VB program to use when accessing the BT slave. BUT, I can't find anywhere in Windows7 where that OUT port name and its associated Bluetooth Service Name is hidden. I can find both ports without any distinction between them, but that will not make an automated connect and open of that channel. If you try the wrong port, it will give an error.

    In the Bluetooth device I can see "COM26 (SPP) "SBI", where COM26 is the output port, SPP is the port profile and SBI is the name of this service (which is unique, to make it differ from BT units from other companies.

    How / Where do I find this?

    Does anyone know or is that just for the big companies to use?

    Appreciate all your help since I've trying to find this for abt 3 months now.


    developer of embedded apps using VB as complement

    Tuesday, September 19, 2017 1:45 PM

All replies

  • When connecting a Bluetooth via virtual COM port, it gives me two ports, input and output. Only the output can be used by my Sw to talk to the slave. How can I automatically (in my VB SW) find the output port only. When searching I always get both ports but without any info on which in In or OUT.

    Appreciate any help.


    developer of embedded apps using VB as complement

    Sunday, September 17, 2017 10:45 AM
  • ... When searching I always get both ports but without any info on which in In or OUT.

    Appreciate any help.


    developer of embedded apps using VB as complement

     How are you "searching" for the ports?  Have you tested to see if maybe the OUT port is always the 1st one found,  or maybe always the 2nd one found?

    If you say it can`t be done then i`ll try it

    Sunday, September 17, 2017 11:25 AM
  • I thought IN and OUT referred to the connection initiator...

    I do not understand what you are asking. 


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    Tuesday, September 19, 2017 4:57 PM
  • I can find both ports without any distinction between them, but that will not make an automated connect and open of that channel. If you try the wrong port, it will give an error.

    You can test for that error and use the other port.  If your equipment supplier does not confirm the names that will be used for the ports (they usually don't) then the only option is to test each one until the connection succeeds.   That's what commercial software does, although it sometimes uses a special connection protocol to shorten the test period and ensure that failure is graceful.  Sometimes that's documented, sometimes not.

    Tuesday, September 19, 2017 11:11 PM
  •  You did not need to create a new question for this,  you have already asked this in This Thread the other day.  You did not reply back or answer the questions that i asked you in that thread.  I asked how you where searching and finding the 2 ports. 

     Maybe the below might help???  Test it in a new form project with 1 Button and 1 RichTextBox on it.  You will also need to add a reference to (System.Management).

     See the Win32_SerialPort class to view all the properties,  their meanings,  and their data types.  Note that not all the properties are always valid on every system so,  using a Try/Catch would be a good idea.

    'You must add a reference to (System.Management). On the vs menu go to -> (Project) -> (Add Reference) -> (.Net Assemblies tab)
    Imports System.Management
    
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Using mos As New ManagementObjectSearcher("SELECT * FROM Win32_SerialPort")
                Dim sb As New System.Text.StringBuilder
                For Each mo As ManagementObject In mos.Get
                    sb.AppendLine("DeviceID: " & mo.GetPropertyValue("DeviceID").ToString)
                    sb.AppendLine("Name: " & mo.GetPropertyValue("Name").ToString)
                    sb.AppendLine("Caption: " & mo.GetPropertyValue("Caption").ToString)
                    sb.AppendLine("Description: " & mo.GetPropertyValue("Description").ToString)
                    sb.AppendLine("ProviderType: " & mo.GetPropertyValue("ProviderType").ToString)
                    sb.AppendLine("StatusInfo: " & CType(mo.GetPropertyValue("StatusInfo"), StatusInfoTypes).ToString)
                    sb.AppendLine("PNPDeviceID: " & mo.GetPropertyValue("PNPDeviceID").ToString)
                    sb.AppendLine("###############################")
                Next
                RichTextBox1.Text = sb.ToString
            End Using
        End Sub
    
        Private Enum StatusInfoTypes As Short
            Other = 1
            Unknown = 2
            Enabled = 3
            Disabled = 4
            NotApplicable = 5
        End Enum
    End Class
    

     

     I only have COM3 on my laptop.

     

     

     Also,  you said that trying to connect to the wrong port throws an exception.  Perhaps you can just try connecting to one of the ports in the Try part of a Try/Catch.  If an exception is thrown,  it will jump to the Catch part where you can attempt to connect to the second port.


    If you say it can`t be done then i`ll try it

    Wednesday, September 20, 2017 12:02 AM
  • Hi, thanks for trying to help me. Yes, I've tried this approach, but as Acamar pointed out, probably the only option is to try one after the other and see which one works. I little bit amateurish...... Since the info is there somewhere (the info is displayed in the device info), then it should be able to be read out.

    Also, I can't find the BT Service Name anywhere even though it is also displayed in the Device Info with the correct

    COM port to use.

    If I have 3 different BTs connected, I wish to select the proper one from start, not access them and send questions, wait for reply or not (who knows what that illegal questions does to the BT unit I'm not interested in?).

    Thanks and I hope for more input from MS who did write those things.


    developer of embedded apps using VB as complement

    Thursday, September 21, 2017 8:54 PM
  • If I have 3 different BTs connected, I wish to select the proper one from start

    That's a different problem than the one you stated.  The original problem was that you need to distinguish between the IN and OUT ports of one serial I/O BT device.  Now you want to pick one BT device out of three.    What are you using to identify the 'proper' one?

    Thursday, September 21, 2017 9:28 PM