Pelle
Posts: 26
Joined: Tue Nov 15, 2005 12:46 am

Saving RemoteService object

Fri Sep 01, 2006 5:56 pm

Hi,

I have a problem that should be easy but I do not find the solution to it.

My program connects to another Bluetooth device and I do:

//CurrentService is of type RemoteService
Stream connectedStream = currentService.Stream;
connectedStream.BeginRead(m_buffer, 0, m_buffer.Length, new AsyncCallback(readCallback), connectedStream);

The currentService has been received after a normal inquiry/service search and this works witout any problem. However the next time I start the program I want to be able to skip the search and go directly to the connect. So my question is how to get the Stream?

My first thought was to try to serialize the RemoteService or the ServiceStream but the objects do not support serialization.

/Pelle

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

RE: Saving RemoteService object

Fri Sep 01, 2006 6:53 pm

You can use the Network.ConnectDevice and RemoteDevice.ConnectService if you know all the necessary data to connect directly to a service.

Regards,
Jonas
Franson Support

Pelle
Posts: 26
Joined: Tue Nov 15, 2005 12:46 am

RE: Saving RemoteService object

Sat Sep 02, 2006 2:31 am

Thank you for the quick support! Your solution works perfect!

/Pelle

sinag3
Posts: 2
Joined: Thu Oct 09, 2008 2:04 pm

RE: Saving RemoteService object

Thu Oct 09, 2008 2:15 pm

I have a similar problem. I'm sending a file to another bluetooth device. During a device search, a RemoteDevice object is returned. I want to be able to serialize that somewhere, so I don't to do a search the next time. But I can't serialize it because it gas no defined constructor.

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

RE: Saving RemoteService object

Thu Oct 09, 2008 2:50 pm

If you read above:
Network.ConnectDevice

Regards,
Jonas

sinag3
Posts: 2
Joined: Thu Oct 09, 2008 2:04 pm

RE: Saving RemoteService object

Fri Oct 10, 2008 6:46 am

Better test your code:

RemoteDevice selectedDevice = _network.ConnectDevice(<address>, <name>);

works for WIDCOMM, but for the MS stack, sending files via obex to this device fails, with no error status returned.

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

RE: Saving RemoteService object

Fri Oct 10, 2008 9:17 pm

It's not a general problem though.
I just tried connecting from my computer to my mobile phone by using ConnectDevice and it worked fine.

Regards,
Jonas

Return to “BlueTools”