MacSass
Posts: 58
Joined: Tue Feb 14, 2006 2:46 am
Location: Germany

Discover Names + Object Push help needed

Tue Feb 21, 2006 12:05 am

Hello,
first of all I need to say that I´m not a pro in .NET programming - so I need some help on using BT Tools with VB .NET 2005:

1.) When discovering devices with the MS stack I seem not to get the device names on first discovery. I´m using DiscoverDevicesAsync to find devices and store them in a variable field (not e.g. a drop down or similar). How can I get the device name using autodiscovery as the stack only seems to provide the full name on second discovery? As the device is already known without a name it does not trigger the device found event on the second run. I have to start and stop my application.

2.) I know I need to do a service discovery with the ObjectPush service ID as argument, in order to get a stream I can use for pushing something to a device.

How can I know the ObjectPush service ID for a device? Is the ID a constant value across all devices? I thought I have to do a service discovery in order to retrieve the service ID of the ObjectPush service.
If anyhow possible I would try to avoid to have to do a service discovery before pushing to a device (I would not mind if the push fails because the device does not support that service). I "know" the device address, etc. from a previous discovery (see above).

Would be great if you could help a VB .NET newbie on this - thanks in advance - MacSass

User avatar
johan
GpsGate
Posts: 15289
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Discover Names + Object Push help needed

Tue Feb 21, 2006 10:15 am

1. The property RemoteDevice.Name is indeed updated the second discovery. But if you have added the object to a drop down or similar you will first need to remove it and add it again.

Take a look at RemoteDevice.Name in the debugger after the second discovery and you will see the true name.

2. Yes, the ServiceType will always be the same for OBEXObjectPush services. Take a look at the ServiceType enum in the reference manual for different types of services.

You use the ServiceType value (e.g. ServiceType.OBEXObjectPush) as argument in RemoteDevice.DiscoverServices() or RemoteDevice.DiscoverServicesAsync()

In the FindAndConnect sample you can see that RFCOMM is used as argument for service discovery. RFCOMM will return all services. If you replace this with another ServiceType value like OBEXObjectPush, Only OBEX Push services will be returned.

RemoteService.ServiceType will also tell you the type of service.

Regards,
Johan

Franson Support

MacSass
Posts: 58
Joined: Tue Feb 14, 2006 2:46 am
Location: Germany

RE: Discover Names + Object Push help needed

Wed Feb 22, 2006 12:45 am

Hi Johan,
thanks for your fast reply.

On 1.) Still working on this. It´s not clear to me how to do that as I´m using DiscoverDevicesAsync with AutoDiscovery and only one event for the device is triggered - and then it does not have a name. Would I have to look up the name later on, even though I don´t have a discoveryevent happening?

On 2.) I managed to get it working, although I´m not sure I´m doing it in an effective way (and I´m not handling the exception that happens when the push fails - but this I´m aware of). Maybe you can look at the code and comment on it if you feel so:

Sub ObjectPusher(ByVal PushDevice As RemoteDevice)

Dim services() As Service
Dim remote_service As RemoteService
Dim m_stream As ServiceStream

' Let´s see if ObjectPush is supported
services = PushDevice.DiscoverServices(Franson.BlueTools.ServiceType.OBEXObjectPush)

' Now get a stream to the service
remote_service = services(0)
m_stream = remote_service.Stream

' Push TheFile
m_objectPush = New ObexObjectPush(10000)
fileStream = New FileStream(TheFile, FileMode.Open, FileAccess.Read)
m_objectPush.PushFileAsync(fileStream, Path.GetFileName(TheFile), m_stream)

End Sub

For me this still looks like a service discovery is happening - even though I only ask to discover the specific ObjectPush service - it still takes time. I came from 32feet API where you weren´t required to do that. Is there a more effective way to do it than I do?

Thanks again for your help - MacSass

User avatar
johan
GpsGate
Posts: 15289
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Discover Names + Object Push help needed

Wed Feb 22, 2006 12:04 pm

1. Yes, after the second discovery the property RemoteDevice.Name will be updated.

2. Yes, this is the way to do it. If you later on push to a known device with a known address+SCN for the push service, you can use Network.ConnectDevice() + RemoteDevice.ConnectSevice() for an even faster connection.

Regards,
Johan

Franson Support

SurferMatti
Posts: 27
Joined: Tue Mar 01, 2005 11:04 pm

RE: Discover Names + Object Push help needed

Wed Mar 22, 2006 11:59 pm

Johan,
Is there anyway to get the device name without having to discover a 2nd time?

Thanks

User avatar
johan
GpsGate
Posts: 15289
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Discover Names + Object Push help needed

Thu Mar 23, 2006 10:59 am

Not in BlueTools 1.10 I am afraid. However we have fixed this now, and the names will be discovered at first try in the next release of BlueTools scheduled for early April.

I will contact you off forum to have an early version of that release.

Regards,
Johan

Franson Support

Return to “BlueTools”