Wireless Communication Library Support Forum
Frameworks => Bluetooth Framework => Topic started by: Ray on September 18, 2008, 08:25:23 PM
-
I was wondering how your library handles disconnections (say for example if the bluetooth device goes out of range). I am trying to connect to a device with the serial port profile using the Microsoft serial port class, but whenever the device disconnects, I can not re-open the com port right away (it usually takes 20 to 30 seconds). I would like for this process to be much quicker (like how bluetooth headphones keep streaming data, and it doesn't matter if you go in and out of range - the connection is not lost).
Can your library handle this kind of scenario?
-
Good day!
You can download and try. The demo is availbale. Headphone use different connection. BT has 2 types of connections: SCO (synchroniouse) and ACL (Asynchronious). Streaming data uses SCO, RFCOMM based - ACL.
-
So I've got a little client program going, and I'm trying to connect to my device. Except that it can't resolve the address of the device.
BFBluetoothDiscoveryX discover = new BFBluetoothDiscoveryX();
BFBluetoothRadioX BRadio = discover.EnumRadios().get_Radio(0);
BluetoothFrameworkX.BFBluetoothDeviceX Device = null; ;
BluetoothFrameworkX.BFBluetoothDevicesX m_Devices = discover.Discovery(BRadio, true, true, true);
for (int i = 0; i < m_Devices.Count; i++)
{
Device = m_Devices.get_Device(i);
if (Device.Name.Contains("Number 4")) break;
}
//I Do get a device here
BFClientX client = new BFClientX();
client.Transport = BFAPITransportX.atBluetooth;
client.BluetoothTransport.Device = Device;
client.Open();
When I run this code, I get an error "Code 10049 - the requrested address is not valid in its context."
-
This error means that the device does not support service which is setted by default for BFClient. Set the service to which you want connect to
-
I have a couple of questions.
Is the OnDisconnect mechanism supported? When I try and use it I get an exception HRESULT: 0x80040202.
Is there any way to prevent the client from dropping the connection if the device goes out of range, so that it picks up the connection when it returns into range?
-
It hard depends on stack impleentation. usually if client is out of range the low-leve driver sends Disconnect command. The only way is when client disconnected start monitoring for the client and when it back - call connect once again.
P.S. HandsFree/HeadSet device also drops the connection if it is out of range - just checked
-
So would the speed of reconnecting be more dependent on the Microsoft Bluetooth Stack, or the driver, or the bluetooth device? I don't have any problem with detecting if the device is disconnected - its just that the connect function takes so long to call after it's been disconnected.
-
reconnection speed is hard depends on hardware you use, target device, driver and lots of other things.