Author Topic: Connection - Error 0x50041  (Read 29548 times)

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Connection - Error 0x50041
« on: June 30, 2021, 07:44:51 AM »
Hi all,

I have a lot of difficulties to connect to a BT devices. Behavior is not regular. Sometime I was able to connect but today for example doesn't work anymore and Connect return error 0x50041.

I really don't know the reason of that. The same code is used to connect with other devices without any single issue.

Can you give me some hint to help to solve this problem ?

Thank you in advance. Best regards.

Keven Corazza

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #1 on: June 30, 2021, 07:49:18 AM »
Hi,

The error 0x00050041 (WCL_E_BLUETOOTH_RFCOMM_DOWN) means: "The RFCOMM received DM response" (https://www.btframework.com/errors.htm)

This error usually appears in case of Authentication (pairing) and/or Encription was failed. Make sure your device has been paired correctly and the link key has not been reset on both sides.

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #2 on: June 30, 2021, 09:45:44 AM »
Hi Milke,

thank you for the quick reply.

When you say "pair" what do you mean exactly ?

1. Pair the device with Windows
2. Pair the device with RemotePair method ? In this case pairing has to be done before or after the connect ?

I didn't do any pairing because I understood that there is an autopairing process available.

Waiting for your kind reply. Thank you.

Regards. Keven.


Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #3 on: June 30, 2021, 10:05:17 AM »
Me again,

I found this workaround that of course I don't like but that works and maybe allow you to understand more:

* I pair the device using Windows
* when pairing is completed in Windows I found two devices paired:

1. Bluetooth LE Device <address>
2. ZN0666210001

* I have to remove the first from Windows ("Bluetooth LE Device")

If I do the above steps then Connect is working properly.

Question is how to make this process automatic within the application without to require to pair with Windows.

Thanks. Regards.

Keven Corazza

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #4 on: June 30, 2021, 10:06:51 AM »
Hi

It looks your device is mixed one (supports both BLE and RFCOMM). So you shoudl discover your device as classic and then call RemotePair method. Or you can simple try to connect and if authentication is required it will be done automatically. Take a look on RfCommClient demo to find out how to do that.

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #5 on: June 30, 2021, 10:14:23 AM »
Thanks,

If I run Connect directly it doesn't work and so I suppose that I have to use RemotePair.

What is the right command sequence ? Connect and then RemovePair or RemotePair and then Connect ?

Thanks. Regards.

Keven Corazza

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #6 on: June 30, 2021, 10:18:50 AM »
Pairing first. Any way, Connect to Classic device's MAC will force pairing if it is required by the device. Of course you must handle all pairing events.

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #7 on: June 30, 2021, 10:32:54 AM »
Sorry to bother you.

I am trying to Pair and then Connect:

Code: [Select]
            try
            {
                wclBluetoothRadio Radio = GetSelectedRadio();
                if (Radio != null)
                {
                    m_BTClient.Address = Convert.ToInt64(sAddress, 16);
                    m_BTClient.Authentication = false;
                    m_BTClient.Encryption = false;
                    m_BTClient.Channel = iChannel;
                    m_BTClient.Service = wclUUIDs.SerialPortServiceClass_UUID;

                    //-
                   
                    iResult = Radio.RemotePair(m_BTClient.Address);
                   
                    //-

                    m_bConnecting = true;
                    iResult = m_BTClient.Connect(Radio);
                    if (iResult == wclErrors.WCL_E_SUCCESS)
                    {
                        System.Threading.Thread.Sleep(500);

                        while (m_bConnecting)
                        {
                            Application.DoEvents();
                        }

                        bool bConnected2;
                        Radio.GetRemoteConnectedStatus(m_BTClient.Address, out bConnected2);

                        bConnected2 = (m_BTClient.State == wclClientState.csConnected);
                        bRes = bConnected2;
                    }
                    else
                        bRes = false;
                }
            }
            catch (Exception e)
            {
                bRes = false;
            }

            return bRes;


I also subscribed all the events:

Code: [Select]
                BTManager = new wclBluetoothManager();
                BTManager.OnPinRequest += BTManager_OnPinRequest;
                BTManager.OnAuthenticationCompleted += BTManager_OnAuthenticationCompleted;
                BTManager.OnConfirm += BTManager_OnConfirm;
                BTManager.OnPasskeyNotification += BTManager_OnPasskeyNotification;
                BTManager.OnPasskeyRequest += BTManager_OnPasskeyRequest;
                BTManager.OnProtectionLevelRequest += BTManager_OnProtectionLevelRequest;
                BTManager.OnStatusChanged += BTManager_OnStatusChanged;
                BTManager.Open();

But the only event received is OnAuthenticationCompleted with error 327722 (0x5002A) and then connect return again 327702 (0x50016).

I really don't know how to proceed and how to fix this. Your help is very much appreciated.

Thanks. regards.

Keven Corazza

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #8 on: June 30, 2021, 10:46:54 AM »
m_BTClient.Authentication = true;

If you set it to false the authentication on the client side will be disabled. Also, unpair your device first.

If you want to use RemotePair() it is always good idea to call RemoteUnpair() first (without analizing returning code) to make sure device is unpaired. If a device was paired - it unpairs a device. If it was not paired the method simple returns error (and you can ignore it).

Next call to RemotePair().

Also you may leave it all to auto pairing during connect. However if device was paired and the link key was lost on any side you will get the connection (and authentication) error. In this case calling unpair may also help.

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #9 on: June 30, 2021, 11:30:06 AM »
Thank you.

I set Authentication to true but behavior is the same as before. I also called RemoteUnpair before the RemotePair but no success.

Event OnAuthenticationCompleted is fired with error 327722 (0x5002A) and then event OnConnect with error 327702 (0x50016).


Other suggestions ?

I am sorry, should be easy and straightforward but for some reason this BT device is really different from all the others...


Thanks again. Regards.

Keven Corazza



Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #10 on: June 30, 2021, 11:35:33 AM »
Are you sure the device supports RFCOMM connection? Can you try to check its services using BluetoothManager demo?

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #11 on: June 30, 2021, 11:47:32 AM »
Here in attach a PDF with the list of services.

As said before, if I do a manual pairing with Windows and I remove from the list of associate devices the "Bluetooth LE Device" and I keep only the main one, then it works.

Thanks. Keven.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Connection - Error 0x50041
« Reply #12 on: June 30, 2021, 11:54:29 AM »
All looks OK. Can you pair through this demo app?

Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #13 on: June 30, 2021, 12:02:17 PM »
I did an additional test on another PC. Previous tests have been done in my notebook with integrated BT.

On a desktop PC, without BT, I have used an external BT adapter (SENA SD100) and with that one the RemotePair it works.

My feeling is that the problem is related somehow to the fact that this device looks to be used as a classic device but also as a LE.

I hope that above info could help you...

Thanks.

Keven Corazza


Offline KCorazza

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
Re: Connection - Error 0x50041
« Reply #14 on: June 30, 2021, 12:03:48 PM »
Yes, I am able to Pair with the demo app; I press Refresh button to have the status updated.

But when I have to Unpair two times and not just one.

This demo app, doesn't do any Connect, so I don't know if Connect works or not.

Thanks.

Keven Corazza

 

Sitemap 1 2 3 4 5 6 7