I'm developing a Bluetooth peer2peer Application on Windows Mobile for my thesis.
The first attempt was to open/close the connection between the Devices before/after it's usage.
Because of slow Connect mechanism i've decided to let the connections open. But the max 7 active connections are a problem to do it like that.
Because the Function to enter the parkmode are not implemented yesterday i've downloaded the source code and added some lines to the SocketOptionHelper and to the BluetoothClient.
The lines of Code i've added:
SocketOptionHelper
private bool parkmode = false;
public bool Parkmode
{
set
{
if(value != parkmode)
{
parkmode = value;
if(parkmode)
{
//enter parkmode
byte[] pmbt = new byte[6];
uint beacon_max = 0xffff;
uint beacon_min = 0x0001;
uint interval = 1200; //0.75s
BitConverter.GetBytes(beacon_max).CopyTo(pmbt, 0);
BitConverter.GetBytes(beacon_min).CopyTo(pmbt, 2);
BitConverter.GetBytes(interval).CopyTo(pmbt, 4);
m_socket.SetSocketOption(BluetoothSocketOptionLevel.RFComm,
BluetoothSocketOptionName.EnterParkMode, pmbt);
} else {
//exit parmode
m_socket.SetSocketOption(BluetoothSocketOptionLevel.RFComm,
BluetoothSocketOptionName.ExitParkMode ,
((BluetoothEndpoint)m_socket.RemoteEndPoint).Address.ToByteArray());
}
}
}
get
{
return parkmode;
}
}
BluetoothClient
public bool Parkmode
{
set
{
m_optionHelper.Parkmode = value;
}
get
{
return m_optionHelper.Parkmode;
}
}
I've tried the Code in Windows Vista (I know its just documented to Work under Windows CE and under WM 5.0) and in Windows Mobile 6.0.
In both cases I get an InvalidArgumentException.
Has anyone tried something similar? I'm not seeing any Bugs in the code.