QN908x device Bonded count

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QN908x device Bonded count

1,938 Views
ankur_rathi
Contributor IV

Hi,
I am using QN908x Development board and Qn908x_SDK2.2.0 .
I am using HID device example code and I have enabled Pairing and Bonding.
In app_preinclude header file,

/*! Enable/disable use of bonding capability */
#define gAppUseBonding_d   1

/*! Enable/disable use of pairing procedure */
#define gAppUsePairing_d   1

and I am sending some command via BLE to Get the number of Bonded devices. For this, I am using "Gap_GetBondedDevicesCount" API.
While in the same power ON cycle, I am getting number of Bonded devices count correctly.

But, when I reset the card and then connect to some other device, bonded devices count reset to zero.
As I debug more,I saw that when Bonding is enabled, the code is adding the device to Whitelist. Whitelist just stored the data in RAM and not in Flash, so reset cycle again reset the Bonded devices.
Is their any API to save the Bonded device in Flash.

In "gap_interface" header file, I am able to see the API's "Gap_RemoveAllBonds" and "Gap_RemoveBond" but not "Gap_AddBond" api.
Is their any other way to save bonded data of the device between Reset cycle.

Labels (1)
  • QN

10 Replies

1,742 Views
ankur_rathi
Contributor IV

Hi Sebastian,
One more thing found:

There are two macro's "gAppUseNvm_d" in "AppMain.h" and "app_preinclude.h" files.

Setting both or any one of them results in different behavior.Got very confused exactly whats happening.

0 Kudos

1,742 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ankur,

 

The flag in the ApplMain.h header file should not be changed. It has to be overridden by the flag in the app_preinclude.h header file instead.

 

Could you please try reimporting a fresh copy of the HID device example, and only change the pairing, bonding and NVM flags in the app_preinclude.h header file?

 

Could you please let me know if the example connect, bond and pair succesfully in this case?

 

Best regards,

Sebastian

0 Kudos

1,742 Views
ankur_rathi
Contributor IV

Hi Sebastian,

I tried again importing the new code and make those changes as per you.

Currently, It is working as expected but I will try multiple times and will let you know the final result.

0 Kudos

1,742 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ankur,

 

Please let me know if you have any further issues.

 

Best regards,

Sebastian

0 Kudos

1,742 Views
ankur_rathi
Contributor IV

Hi Sebastian,

I will try that on my Monday and will let you know the result as right now I don't have development board with me.

The main issue is that its getting paired and bonded for sometime and then maybe after 10-15 mins, it needs to be paired and bonded again. This is first time I ever faced any issue of this kind.
Now,I am just curious what can be the reason for such behavior.

0 Kudos

1,742 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ankur, I hope you're doing well!

 

There's another flag in the app_preinclude.h header file that configures the application to save a bound device's information to Non-Volatile Memory.

 

To configure this, could you please try setting the following macro like so:

/* enable NVM to be used as non volatile storage management by the host stack */
#define gAppUseNvm_d                    1

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

1,742 Views
ankur_rathi
Contributor IV

Hi Sebastian,

Strange, but when I enable nvds flag I am not able to connect again to any of the device.
But, when I disable nvds flag, I am atleast able to connect to any other device but pairing and bonding has to be done again.

I tried with different BLE Mode and Level, NVDS flag, IO capabilities and Passkey value.
But to no success.

But, when I disable NVDS flag, maybe after 15 minutes I am not able to see the device as a Bonded on QN908x device.

Can you please let me know if I am doing something wrong or help me out on this.

0 Kudos

1,741 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Ankur, I hope you're doing well!

 

I tried to replicate your issue, but was able to connect an Android device to the QN9080 successfully.

Were any other changes done to the coed or the configuration?

 

I used the default parameters for Pairing in the app_config.c source file:

 

gapPairingParameters_t gPairingParameters = {
    .withBonding = (bool_t)gAppUseBonding_d,
    .securityModeAndLevel = gSecurityMode_1_Level_3_c,
    .maxEncryptionKeySize = mcEncryptionKeySize_c,
    .localIoCapabilities = gIoDisplayOnly_c,
    .oobAvailable = FALSE,
    .centralKeys = (gapSmpKeyFlags_t) (gLtk_c | gIrk_c),
    .peripheralKeys = (gapSmpKeyFlags_t) (gLtk_c | gIrk_c),
    .leSecureConnectionSupported = TRUE,
    .useKeypressNotifications = FALSE,
};

 

Please let me know if you continue to have issues.

 

Best regards,

Sebastian

0 Kudos

1,742 Views
ankur_rathi
Contributor IV

Hi Sebastian,

I have tried many changes, but here I will simplify the steps, what I am trying to get rid of this issue:
1. I took HID device example code, in that as I need  pairing and bonding feature, I enabled Pairing and Bonding macros in ''pre_include" header file.
2. Till this point, I am able to pair and Bond the QN908x device with Android device.
3. I am able to connect and saw the cursor move on the display (HID device example code).
4. Now, at this point say I switch OFF the QN908x dev board and then I tried to connect to my already paired Android device after 20-30 min. I am not able to connect again.

So, to just understand the problem, I tried changing BLE Security Mode and Level, IO capabilities NVM flag what you mentioned in the last comment. But, not to my success.
I tried restarting the Android device as well as unpaired all the previous BLE paired device.

Right now, I am also somewhat clueless exactly what is happening.
I am suspecting the device is not getting bonded properly or reset cycle is clearing the bonded device data somehow. I not exactly sure as of now.

0 Kudos

1,742 Views
ankur_rathi
Contributor IV

Thanks Sebastian for the response.

But some strange behavior I have noticed after .
1. "gAppUseNvm_d" macro is set to "0" :
 - I am able to see in the mobile setting device gets connected and next time also I am able to connect.
 - But, if I switch OFF my device say for 15 mins and then try to connect again, it does not connect.
2. "gAppUseNvm_d" macro is set to "1" :

 - I am not able to connect after 1st time.
 - Data transfer is also not happening.

There are more parameter which is causing issue:
1. BLE Security level and Mode.

2. BLE Passkey value.

The behavior is not consistent. I will post the update when I am able to get more through data.
Thanks for pointing out "gAppUseNvm_d" flag.

Btw, I am using HID device Free RTOS source code.

MCUXpresso IDE version:    MCUXpresso IDE v11.1.0 [Build 3209] [2019-12-12]
SDK version:                         SDK_SDK_2.2.1_QN908XCDK

Do let me know if you need any further information.

0 Kudos