Author Topic: Handling device moving in and out of range.  (Read 20684 times)

Ray

  • Guest
Handling device moving in and out of range.
« 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?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Handling device moving in and out of range.
« Reply #1 on: September 18, 2008, 10:32:31 PM »
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

  • Guest
Re: Handling device moving in and out of range.
« Reply #2 on: September 19, 2008, 12:12:17 AM »
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."

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Handling device moving in and out of range.
« Reply #3 on: September 19, 2008, 10:50:21 AM »
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

  • Guest
Re: Handling device moving in and out of range.
« Reply #4 on: September 19, 2008, 08:04:05 PM »
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?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Handling device moving in and out of range.
« Reply #5 on: September 19, 2008, 09:44:23 PM »
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

Ray

  • Guest
Re: Handling device moving in and out of range.
« Reply #6 on: September 19, 2008, 10:56:58 PM »
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.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Handling device moving in and out of range.
« Reply #7 on: September 20, 2008, 11:31:23 AM »
reconnection speed is hard depends on hardware you use, target device, driver and lots of other things.

 

Sitemap 1 2 3 4 5 6 7