Author Topic: VB.Net 2008 - Invalid Bluetooth API Specified ?  (Read 10794 times)

Glider

  • Guest
VB.Net 2008 - Invalid Bluetooth API Specified ?
« on: August 22, 2008, 04:38:47 PM »
Hi,

im new in programming bluetooth apps.

Im using vb.net 2008 and then Wireless Communication Library for .NET.
So far so good ;)

i want to get a list of avaible devices, but i get the exeption "Invalid Bluetooth API Specified"

source :

Code: [Select]
Private Function GetSelectedRadio() As wclBluetoothRadio
        Dim Result As wclBluetoothRadio = Nothing

        If lstRadios.SelectedItems.Count = 0 Then
            MessageBox.Show("Select radio", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        Else
            Result = New wclBluetoothRadio()

            Try

                Result.API = WclBluetoothDiscovery1.StringToBluetoothAPI(lstRadios.Items(0))  ' Here i ge then message Invalid Bluetooth API Specified
            Catch exep As Exception
                MsgBox(exep.Message)
                Result = Nothing

            End Try
        End If

        Return Result
    End Function

how do i set the bluetooth api? Or do i somthing totally wrong?

sry, im a newbe

see ya :)

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #1 on: August 22, 2008, 04:44:10 PM »
Use this code to enumerate availbale bluetooth radio

Dim Radio as wclBluetoothRadio = wclBluetoothDiscovery1.EnumRadios()

After that use one of the radio (if Radio.Coun > 0) to call discovery function

wclBluetoothDiscovery1.Discovery(Radios.Items(0))

wclBluetoothDiscovery1 is the wclBluetoothDiscovery component you must have on the form.

Also, you must have wclAPI component on the form and call is Load() method before any other functions (good idea is to call it in FormLoad event) and then unload it using Unload() method when yu appplication closed.

Glider

  • Guest
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #2 on: August 22, 2008, 07:04:34 PM »
i dont have problem to select an availbe radio,  ich mean, i could not any bluetooth mobile phones for example

i want to scan for availbe bluetooth devices with an selected radio

i attached my current project, maybe u got an idea :(

 i didnt have one

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #3 on: August 23, 2008, 12:43:47 AM »
Very interesting code

  Private Sub cmdRadioScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRadioScan.Click
        lstRadios.Items.Clear()
        Try
            Dim Radios As wclBluetoothRadios = WclBluetoothDiscovery1.EnumRadios()
            Try
                For i As Integer = 0 To Radios.Count - 1
                    Dim radio As wclBluetoothRadio
                    radio = Radios(i)
                    Dim Address As String = ""
                    Try
                        Address = radio.Address
                    Catch es As Exception
                        Address = es.Message
                    End Try
                    lstRadios.Items.Add(Address)

                Next
            Finally
                Radios = Nothing
            End Try
        Finally
        End Try
    End Sub

===================================

    Private Function GetSelectedRadio() As wclBluetoothRadio
        Dim Result As wclBluetoothRadio = Nothing
        If lstRadios.SelectedItems.Count = 0 Then
            MessageBox.Show("Select radio", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        Else
            Result = New wclBluetoothRadio()
            Try
                WclBluetoothDiscovery1.Discovery(lstRadios.Items(0))
                Result.API = WclBluetoothDiscovery1.StringToBluetoothAPI(lstRadios.Items(0))
            Catch exep As Exception
                MsgBox(exep.Message)
                Result = Nothing
            End Try
        End If
        Return Result
    End Function

Please, look at the selected (bold text) code lines and think, what is the difference between bluetooth address and bluetooth API name.

Glider

  • Guest
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #4 on: August 23, 2008, 04:31:01 PM »
so i changed some things in the project,

now im trying to find devices via bluetooth and list dem in a listbox.

i watched the c# sample, but i dont know how to do it like that in vb.net

which calls i have to do  after   "WclBluetoothDiscovery1.Discovery(Radio)" ?  ???

my test project is attached

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #5 on: August 24, 2008, 01:59:15 AM »
Good day!

Discovery is an asynchronous method. When it will done the component fires OnDiscoveryComplete event.

Glider

  • Guest
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #6 on: August 25, 2008, 07:46:24 PM »
i tried two days to get it work with the event, but wont work :(

is there a simple vb.net example availble?

can i contact u via icq ?

see ya

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3053
  • Karma: 1000
    • Soft Service Company
Re: VB.Net 2008 - Invalid Bluetooth API Specified ?
« Reply #7 on: August 25, 2008, 09:16:46 PM »
Good day!

You may convert C# to VB.NET easy with using any NET disassembler.

Of course, you can contact me by MSN or ICQ or e-mail or any other way discribed on the contacts page.

 

Sitemap 1 2 3 4 5 6 7 8 9