Wireless Communication Library Support Forum
Frameworks => Bluetooth Framework => Topic started by: Glider 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 :
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 :)
-
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.
-
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]
-
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.
-
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]
-
Good day!
Discovery is an asynchronous method. When it will done the component fires OnDiscoveryComplete event.
-
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
-
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.