jtskaggs
Posts: 2
Joined: Wed Feb 01, 2006 6:35 pm
Location: USA

Obex Push

Wed Feb 01, 2006 6:45 pm

I'm writing an unattended client to push files to a server using ObexObjextPush. I want to store the name and address of the last used RemoteDevice in the registry to bypass DeviceDiscovery on the next attempt.

I use Network.ConnectDevice(addr,name) to verify the device is present before starting the ObexObjectPush. It errors out with Connection already present.

1) Is there a way to disconnect the device to avoid the error?
or
2) How can I create a RemoteDevice from an addr and name?

Thanks in advance! BTW, Great Product!!

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

RE: Obex Push

Wed Feb 01, 2006 8:15 pm

If you download the BlueTools 1.10 beta version, there is an example of how to store and connect to devices in the ObexFTPClient sample. We used an xml-file instead of the registry but the basic idea is the same.

As for the error with a Connection already present, have you tried closing the Stream to the RemoteService before attempting to connect again?


Regards,
Jonas
Franson Support

jtskaggs
Posts: 2
Joined: Wed Feb 01, 2006 6:35 pm
Location: USA

RE: Obex Push

Thu Feb 02, 2006 1:43 am

Thanks for the quick response to my question! As is commonplace, it was 'operator' error that caused the problem. I neglected to cast the RemoteService.Stream as a ServiceStream. Once I did this, it worked like a champ. BTW, the RemoteDevice can be connected, I assume that you already knew this.

On another note, I wanted to post that the FileStream object passed to the ObexObjectPush.PushFile method must be closed after the completion if you are planning on accessing it (i.e. File.Delete).

Lastly, I failed to mention that this app is being written for the compact framework.

Thanks again for your help!

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

RE: Obex Push

Thu Feb 02, 2006 3:17 pm

Good that you got it working, although I am not quite sure what a casting of the Obex Stream would do. The Obex component is not in any way dependent on BlueTools. You can pass any Stream (and not just a ServiceStream), as long as there is an Obex server responding over it.

What exactly was the error message you were getting when you didn't cast the Stream?

As for the need of closing the FileStream before e.g. File.Delete that is expected, since you pass the FileStream to Obex in PushFile and you are supposed to close it on PutFileEnd. A file cannot be deleted while the .NET framework is accessing it. I will add a remark to this in the documentation so it is not forgotten.

Regards,
Jonas
Franson Support

Return to “BlueTools”