Wireless Communication Library Support Forum

Frameworks => Bluetooth Framework => Topic started by: Emran on January 28, 2013, 11:41:04 AM

Title: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 11:41:04 AM
hello
in receiving state, most time we must send 2 time or 3 time to connect and receive with wcl component, also most time connecting time may very long about 2-3min and again send will faild...., i think this problem is for my code, i test this with BluetoothOPPServer sample, and i see this sample is also have this problem, whay?
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 12:08:03 PM
hello,

It may appear because BT stack needs time to initialize/reinitialize. However it would be great to know what BT driver and OS you use.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 12:18:42 PM
my OS is Win7 x64, but i use x86 version of wcl, and how can we find BT driver? if in device manager it is show to item in bluetooth Microsoft Bluetooth Enumerator
and ALPS-UGPZ9-BCM2046
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 12:32:52 PM
It's MS BT driver. If you are trying to connect more than 1 device at the same time to PC you have to use more than 1 instance of wclServer. It looks like you are trying to connect few devices to one instance of WCL server.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 01:09:36 PM
i create 7 instance of wclServer, and not receive, some time receive my be 5% of all sending will receive, i test with single device...
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 01:22:22 PM
The only reason it appears that the BT dongle is busy with other connection. I have just tested OPPServer with cell phones - works as expected. But i'll check it more.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 01:38:41 PM
ok, thank you, i think i have mistake, i have create 7 wclServer and all things work fine, thank you
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 01:44:48 PM
how many instance can we create for wclServer, what it's better?
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 02:12:23 PM
wclOPPServer is for OBEX service by default. So yes, it can be a problem if your device doesn't use OBEX or use OBEX in unusual way. wclServer is for any custom RFCOMM based service (or for SPP).

Old BT standard limits it to max 7. New one (since BT 2.0) has no such limit. However, different dongles may have own limitation. Also it somehow limited internaly in MS drivers. By my experience it is usualy about 4-5 max.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 02:41:22 PM
if we create more than instance that dongle not support is it my conflict with other prior instance, for example if i always create 7 instance and some bluetooth device can support 4-5, is all things work fine, or i must create minimum instance of  wclServer to support all device?
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 03:02:19 PM
You will get error message if try to creare more instances than supported. Or (for some stacks) you will not be able to connect.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on January 28, 2013, 03:10:40 PM
then how can i find current dongle how many wclServer instance support?
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on January 28, 2013, 03:13:42 PM
There is no way to know that from application.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 05, 2013, 07:56:15 AM
my problem still not solved!
i create 7 instance it work fine but an hour again not work, and hour again work very fine, ....!
when it is not work with WCL, also windows can not receive file, i test this issue problem with 3-4 system that they  have winxp and win7, and with they own bluetooth device.

i change code that can maximum instance create for device, but it is same problem that i say :
Code: [Select]
                        List<wclOPPServer> servers = new List<wclOPPServer>();
                        while (true) {
                            wclOPPServer morc = new wclOPPServer();
                            morc.BluetoothParams.Radio = mainBluetoothRadio;
                            morc.Transport = wclServerTransport.stBluetooth;
                            if (InitGet(morc)) {
                                servers.Add(morc);
                                morCCount++;
                            }
                            else {
                                morc.Dispose();
                                break;
                            }
                        }

Code: [Select]
        public bool InitGet(wclOPPServer wclServer) {

            wclServer.OnListen += (object sender, wclConnectEventArgs e) => {
                ShowErrorIfDebug(e.Error);
            };

            wclServer.OnOBEXProgress += (object sender, wclOBEXProgressEventArgs e) => {
                if (!address_RecevieID.ContainsKey(wclServer.ObjectName)) {
                    address_RecevieID.Add(wclServer.ObjectName, Guid.NewGuid());
                }
                Guid receiveID = address_RecevieID[wclServer.ObjectName];
                var value = (byte)((e.Position * 100) / e.Size);
                if (OnReceivedProgressChanged != null) {
                    OnReceivedProgressChanged(this, receiveID, value, wclServer.Address, wclServer.DeviceName);
                }
            };

            wclServer.OnOBEXObjectReceived += (object sender, wclOBEXObjectReceivedEventArgs e) => {
                if (OnReceivedFile != null) {
                    string filePath;
                    Guid receiveID = address_RecevieID[wclServer.ObjectName];
                    OnReceivedFile(this, receiveID, e.ObjectName, out filePath, wclServer.Address, wclServer.DeviceName);
                    if (!String.IsNullOrEmpty(filePath)) {
                        using (FileStream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) {
                            e.Stream.WriteTo(stream);
                        }

                        if (OnFileSaved != null) {
                            OnFileSaved(this, receiveID, e.ObjectName, filePath, wclServer.Address, wclServer.DeviceName);
                        }
                    }
                }
            };

            wclServer.OnConnected += (object sender, EventArgs e) => {
                if (BLL.BlackList.Any(q => q.DevieAddress == wclServer.Address)) {
                    wclServer.Close();
                    wclServer.Listen();
                }
                else {
                    address_RecevieID[wclServer.Address] = Guid.NewGuid();
                }
            };


            int result = wclServer.Listen();
           
            ShowErrorIfDebug(result);
           
            return result == 0;
        }
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on February 05, 2013, 08:00:58 AM
Hello,

If even windows can't accept connection than its something wrong in your system.

However I can;t see in your code how you opens servers (server.listen()).
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 05, 2013, 08:38:20 AM
in code part 2 in last 4 line i call wclServer.Listen();
i know this problem is not in my code or WCL component, it may be with our system, our device, or our device driver.
but why some time i receive fine, very good but some time no! and also i say that i test with 4-5 PC the same issue will occur.
how can i find this problem, why i have this problem in other PCs.
some time if i turn off device and again turn on it work...
some time if i restart PC it will work...
some time if i turn off device and also restart PC it will not work but an hour it will work!!!
i restart "bthserv" service but nothing corrected...
if i can restart bluetooth device in startup my application, my be it work!!?!?! can i restart bluetooth device with WCL?
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on February 05, 2013, 08:44:49 AM
I will check it out today and back to you with my result. May be found some workaround. We have faced such issue long time ago with old dongles but never seen same with modern dongles. Any way, i'll be in touch.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 05, 2013, 09:08:56 AM
thank you
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on February 06, 2013, 01:03:28 PM
Hello,

We did few tests and could reproduce the problem few times with 2 old dongles. We are keep working on this to try to resolve the problem. I'll be in touch.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 07, 2013, 02:15:32 PM
thank you may be it will correct if try resolve problem with old dongle, but i dont think my dongle is old, i dont know?!?! for example my Laptop released date is 2008, and it can 30 wclServer instance and each instance call Listen with out any problem and error, but i will happy if resolve this problem with old dongle.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 10, 2013, 02:42:44 PM
Hello
What happened?
when do you release new version of wcl that corrected with old dongle?
i am waiting, i need it....
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on February 11, 2013, 06:41:01 AM
Hello,

As I alreaqdy told it is not WCL bug but we are looking on possible workaround. If we can we will fix it and I let you know.
Title: Re: Receiving bluetooth with WCL
Post by: Emran on February 12, 2013, 08:55:01 AM
hello,
may be my problem is this :
my application always discover (discover time 5sec and time between each discover 15 sec) if user device try to connect in discover time (only in 5sec) device connecting is failed!!!
i write blow code on wclServer.OnConnected
Code: [Select]
      if (wclBluetoothDiscovery.Active) {
          wclBluetoothDiscovery.Terminate();
      }
some time device can connect while in discovering state and OnConnected will occor, but some time device cannot connect faild to connecting...
i dont know, but i think if wclServer have OnConnecting this problem will solve, what do yo think?
thank you.
Title: Re: Receiving bluetooth with WCL
Post by: Mike Petrichenko on February 12, 2013, 09:20:59 AM
Hello,

Connect operation is exclusive (from both sides) so it is impossible to do any other operations whle connection is established (it is by Bluetooth Specification). So when your dongle discovers devices no one device can connect (and dongle can't connect to other device).