"Join A Personal Area Network" programmatically

  • Thread starter Thread starter Colmde
  • Start date Start date
C

Colmde

Guest
I have files shared on a PC that I want my bluetooth tablet to be able to access. I can do this by clicking on the bluetooth icon on the tablet, clicking "Join A Personal Area Network" and then "Connect Using", "Direct Connection".

Then I'm (or more importantly, my application is) able to access the shared folder on the PC.

However, the problem is that if the PC is turned off and on again, this connection is lost, and I have to go in and do this again.

Is there any way of doing this programmatically? I need it so users of my application don't need to do this every time they turn either the tablet or the PC off and on again. If not in C#, is there a way of doing it from the command prompt (so I could add it to a script or something?) Even a setting that would make it try and connect whenever it's disconnected again would do at this stage.

I'm using that "InTheHand" (aka 32feet.net) library, but I can't find any documentation on how to do this there. I've tried:

public static bool ConnectEndPoint(BluetoothDeviceInfo device)
{

device.SetServiceState(BluetoothService.Panu, true);

Guid servClass = BluetoothService.Panu;
var ep = new BluetoothEndPoint(device.DeviceAddress, servClass);
var cli = new BluetoothClient();
cli.Connect(ep);

return cli.Connected;


}



...but I get an exception saying


"A socket operation failed because the destination host was down" at the cli.Connect() line

Continue reading...
 
Back
Top