Frameworks > Bluetooth Framework
VB.Net 2008 - Invalid Bluetooth API Specified ?
Glider:
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: ---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
--- End code ---
how do i set the bluetooth api? Or do i somthing totally wrong?
sry, im a newbe
see ya :)
Mike Petrichenko:
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:
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
[attachment deleted by admin]
Mike Petrichenko:
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:
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
[attachment deleted by admin]
Navigation
[0] Message Index
[#] Next page
Go to full version