Wireless Communication Library Support Forum

Frameworks => Bluetooth Framework => Topic started by: briandunham on February 09, 2022, 11:33:42 PM

Title: Connecting GATT Client After Pairing
Post by: briandunham on February 09, 2022, 11:33:42 PM
Hi,

I've been referencing the GattClient Demo project. I first pair the device successfully then I try connecting the GATT client, but I get error code 0x005105C (WCL_E_BLUETOOTH_LE_DEVICE_NOT_FOUND). However, if I skip the pairing step and just directly connect the GATT client, that it works fine. Is there something about pairing before connecting the GATT client that breaks it? Is pairing first necessary?
Title: Re: Connecting GATT Client After Pairing
Post by: Mike Petrichenko on February 10, 2022, 12:28:11 AM
Hi,

It is known issue(s). Theer are 2 reasons:

1. If your device is mixed (supports both Classic and LE) pairing may be executed with it as with Classic instead of LE.
2. Device changes MAC after pairing.

Any ways. The solution is to pair after connecting: https://github.com/btframework/GattAuth

And of course if yuor device does not require pairing it is better to do not pair with it.
Title: Re: Connecting GATT Client After Pairing
Post by: Mike Petrichenko on February 10, 2022, 12:36:14 AM
Sorry, I forgot to ask, if possible, send more details about your device and how you pair/connect with it to support@btframework.com so we can check it on our side and provide more detailed answer (or fix the problem if it is a bug).

Thank you.
Title: Re: Connecting GATT Client After Pairing
Post by: briandunham on February 10, 2022, 09:50:47 PM
Thank you, pairing after connecting is the solution. But that was hidden by an additional problem of the device changing it's MAC I believe.

So for this current stage of development, I'm using a smartphone app to test with while the development on our hardware device catches up. I'm using a Galaxy S9 smartphone with the nRF Connect app. The app allows for building advertisements and has a configurable GATT server. However, the app uses random addresses and it likes to change it's MAC after certain events. I think this is causing issues in addition to your solution of pairing after connecting.

But I'm now aware of the problem and I can figure out a workaround. Thanks!
Title: Re: Connecting GATT Client After Pairing
Post by: Mike Petrichenko on February 10, 2022, 09:55:58 PM
You are very welcome. Great that you got it working.