poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

how to abort service discovery?

Sat Apr 25, 2009 3:12 am

have question

what to do when last to long searching of devices' services?

// re-enable the device list
deviceList.Enabled = true;

// set error event handler for the device
RemoteDevice device = (RemoteDevice)sender;
device.Error += new BlueToolsEventHandler(device_Error1);

// get all services found
Service[] services = (Service[])((DiscoveryEventArgs)eventArgs).Discovery;


can i put it into new thread and after lets say 5 seconds of doing nothing can i abort it? how to do that?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Sun Apr 26, 2009 11:44 pm

You cannot abort a service discovery...but you can do as you suggest and simply ignore the thread after five seconds I suppose?

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 3:22 am

Originally posted by Jonas

You cannot abort a service discovery...but you can do as you suggest and simply ignore the thread after five seconds I suppose?

Regards,
Jonas


Ignore mean what? ABORT?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Mon Apr 27, 2009 10:30 am

No, I meant that you just let it run until it's finished and then let it end gracefully. However, I thought more about it and the stack will probably be busy running the service discovery so that's not a good idea either.

You simply have to wait until the service discovery is complete.

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 12:33 pm

ok, but it's possible that it never stop searching for services or it will be searching very long time. It's possible not to search for services if I want to send file? How to do that?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Mon Apr 27, 2009 12:37 pm

You can connect directly to a service if you know the address. The ObexFTPClient shows how to do that.

A service discovery will time out after a while if no more services are found.

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 12:43 pm

Originally posted by Jonas

You can connect directly to a service if you know the address. The ObexFTPClient shows how to do that.

A service discovery will time out after a while if no more services are found.

Regards,
Jonas


so what happen if there will NOT be such a service in phone? it terminate or it stuck forever??

how to change time of service discovery? there are some possibilities of do that?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Mon Apr 27, 2009 1:02 pm

If there isn't such a service you won't be able to connect to it. The Stream will not connect.

It's not possible to change the timeout value.

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 1:14 pm

Originally posted by Jonas

If there isn't such a service you won't be able to connect to it. The Stream will not connect.

It's not possible to change the timeout value.

Regards,
Jonas


ok, so it save me time of discovering services. Why using service discoovery when we can simply assume being such a service in device? it save a lot of time...

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Mon Apr 27, 2009 2:43 pm

It depends on the purpose of your application of course. When you use a service discovery you only determine that the device is capable of performing the service, where the connection actually sets up a connection between the two.

Your application perhaps wants to show devices that you actually can connect to. In that case you need to use a service discovery.

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 3:14 pm

Originally posted by Jonas

It depends on the purpose of your application of course. When you use a service discovery you only determine that the device is capable of performing the service, where the connection actually sets up a connection between the two.

Your application perhaps wants to show devices that you actually can connect to. In that case you need to use a service discovery.

Regards,
Jonas



I build app for bluetooth marketing. I need connect to many devices, but in crowded places there are some problems to discover services, so it takies a long time. If would be grate if there wont be eccessary to discover this services but to assume that every device have discovery services:)

I look into OBEXFTPsample as you said.

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 3:37 pm

Eventually, how to assign to this:
services[0]
service like this: "Obex Object Push" ?? It will be all that I need. [B)]

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 3:39 pm

I have such a error:
Unable to cast object of type 'System.String' to type 'Franson.BlueTools.RemoteService'.

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: how to abort service discovery?

Mon Apr 27, 2009 5:55 pm

Look at the ObexFTPClient sample, it contains all the information you need.

Regards,
Jonas

poland
Posts: 24
Joined: Thu Apr 02, 2009 6:22 pm

RE: how to abort service discovery?

Mon Apr 27, 2009 6:22 pm

Originally posted by Jonas

Look at the ObexFTPClient sample, it contains all the information you need.

Regards,
Jonas


I am looking for this example but i nothing found:( where can i search for this? please help me

Return to “BlueTools”