Frameworks > Bluetooth Framework

Handling device moving in and out of range.

(1/2) > >>

Ray:
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?

Mike Petrichenko:
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.

Ray:
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."

Mike Petrichenko:
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

Ray:
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?

Navigation

[0] Message Index

[#] Next page

Sitemap 1 2 3 4 5 6 7 
Go to full version