Stirls
Posts: 6
Joined: Fri Oct 17, 2008 6:12 pm
Location: Australia

Connection Recovery

Sun Mar 22, 2009 8:48 am

Hi All
I am using GPSTools and BlueTools to connect to a GPS.
Steps I am using are
DiscoverDeviceAsync
DiscoverServiesAsync
Connect to stream (device.stream)
Using ReadCallBack routines as per Find and Connect example and passing the result to Gpstools inbuilt Nmeaparser using nmeaparser.parse and then reacting to the events raised eg OnFIX.


The setup works really well (Albeit I sometimes get Connection Failed - Unknown error which I wish I could be more informed about) but to make the application robust I need to automate(from users perspective) reconnection if stream is lost.


I notice that GPStools used in conjunction with any existing PC onboard Bluetooth software apppears to automatically initiate a re-connect if stream(device) is lost.

I wish to replicate this behaviour in the GPSTools/Bluetools environment.

My question is which events best describe the type of loss egDeviceLost and how do I automate the recovery for each.

Do I need to restart all the discovery events or do I need to simply try to re-connect to the steam vis stream.begin read statement using the previously identified Device/service detail which I stored within global variables (ie gpsdevice as remote_device and GPsservice as remote_service).
Regards
Peter

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

RE: Connection Recovery

Sun Mar 22, 2009 3:01 pm

DeviceLost is simply triggered when you run a device discovery and a previously detected device is no longer found.
If you know the device is still present, simply try to retrieve the Stream again and Bluetools will attempt to re-connect.

Regards,
Jonas

Stirls
Posts: 6
Joined: Fri Oct 17, 2008 6:12 pm
Location: Australia

RE: Connection Recovery

Sun Mar 22, 2009 3:28 pm

Thanks Jonas for your prompt reply - how do I trap within the application the fact that the connection is broken.
Regards
Peter

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

RE: Connection Recovery

Sun Mar 22, 2009 6:28 pm

If the Stream throws an ObjectDisposedException, the connections is broken.

Regards,
Jonas

Return to “BlueTools”