Wireless Communication Library Support Forum

Frameworks => Bluetooth Framework => Topic started by: roadhouse on February 21, 2010, 06:10:27 PM

Title: getname()
Post by: roadhouse on February 21, 2010, 06:10:27 PM
Hi Guys,

How do I use the 'e.Devices(I).GetName()' function from within an event handler ?

For example, In the OnDevicesFound event within the wclProximitySender I would like to pull the discovered devices BLuetooth name out from this event and store it in a database.

I just cant seem to get my head around the synatax it needs within the brackets. It calls for '(Radio as wcl.bluetoothradio, byref value as string)as integer'

I can see that e.Devices(I) represents the list of devices found by the discovery process. And that 'I' is an index integer used to identify individual devices in the list. But I cant quite understand what parameters should be in the GetName() function to get the name back so I can use it in variables and so on.

Any help, as always, gratley appreciated.

Cheers




Title: Re: getname()
Post by: Mike Petrichenko on February 21, 2010, 06:44:58 PM
Hi,

It is easy. Take a look on BluetoothDiscovery demo application to find out how to use Device.GetName method.
Title: Re: getname()
Post by: roadhouse on February 21, 2010, 07:12:07 PM
Hi Mike,

Thanks for the reply.

I'm not sure where I'm going wrong here. I have looked at the bluetoothdiscovery demo and I have been able to get that working fine.

The problem I have is getting it working from within the wclProximitySender_OnDevicesFound event.

If I do....

Private Sub wclProximitySender_OnDevicesFound(ByVal sender As Object, ByVal e As wcl.wclDevicesFoundEventArgs) Handles wclProximitySender.OnDevicesFound
        
            For I = 0 To e.Devices.Count - 1
                    'Dim arrg As wcl.wclBluetoothRadio = radiox
                qclog.AppendText("Device found: " + e.Devices(I).Address + vbCrLf)
                query2 = "'" + e.Devices(I).Address + "'"
                Dim btdevname As String = ""
                Dim btdevval As Integer = 0
                btdevval = e.Devices(I).GetName(arrg, btdevname).ToString
                MessageBox.Show(btdevname)

              Next I

all I get is a blank in the messagebox.


I know it has something to do with the arrg variable (wcl.wclbluetoothradio), which I have defined globaly.  I think thats why its blank. I cant understand how I get the radio ref to the event.

Title: Re: getname()
Post by: roadhouse on February 21, 2010, 07:19:43 PM
Sorry,

forgot to mention, the DIM arrg line isnt remarked out in my code. Its just the way i copied it into the message.

Sorry for any confusion.

Cheers
Title: Re: getname()
Post by: Mike Petrichenko on February 21, 2010, 07:39:05 PM
Please, take a look on this topic: http://forum.btframework.com/index.php/topic,935.0.html
Title: Re: getname()
Post by: roadhouse on February 21, 2010, 07:48:02 PM
Hi Mike,

Thanks for the quick replies and the link.

I have fixed it.

I changed the code so that it read the content of 'btdevval' to the message box and it shows a the value '14' which I assumed was an error message. I looked that up and it is 'API Not Available'. I have some code in my form load sub which sets the API and I thought that would be a global kind of thing. Seems my event handler sub cant see that so I had to include the line

'Radio.API = wcl.wclBluetoothAPI.baWidComm'

as the first line in the event handler, it now works.

Do I need to do that whenever I need to  use 'get' and 'set' type properties from within event handlers or should I be setting the Radio.API in global space somehow ?

Cheers


Title: Re: getname()
Post by: Mike Petrichenko on February 21, 2010, 08:06:53 PM
Hi

GetName method requeres valid Radio object as first parameter. So you have to find it somehow. I do recomend to use ProximitySender.DiscoveryRadio as first parameter for the GetName method.