Not able to pair using BLE with Mobile phone

cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to pair using BLE with Mobile phone

1,697 Views
chintan
Contributor III

Hello,

Currently I am working with FRDM KW36 EVM module which is BLE 5 compliant. I have uploaded the Heart Rate sensor code into it from SDK examples. And tried to see the functionality on NXP's Android IOT application. Up to this it works fine. Then I tried to pair with module using authentication. So, for this I reviewed the process from below link:

Lesson 5: Creating a Bluetooth Low Energy Heart Rate Sensor with Pairing & Bonding | NXP 

and do same thing for pairing and bonding. But when I tried to pair module with Sony Xperia C3 Dual mobile phone, instead of asking the Passkey application directly shows the notification of Invalid passkey. Sony Xperia C3 Dual mobile phone has Bluetooth version 4.0 and Android OS version is 5.1.1.

Then I tried with other mobile devices which has Bluetooth version 4.1, 4.2 and 5.0 with LE. The results are as below:

Function with Bluetooth v4.1:

Able to pair the KW36 evm module with mobile device. IOT Application ask for Passkey when try to connect the module.

Function with Bluetooth v4.2:

Able to pair the KW36 evm module with mobile device. IOT Application ask for Passkey when try to connect the module.

Function with Bluetooth v5.0:

With this mobile devices, IOT application does not show the module even the advertising is ON. The module name is shown in Bluetooth settings and able to pair with EVM from Bluetooth settings but not able to connect from IOT application.

Kindly guide is there any settings I have to do in module or in mobile to connect with Bluetooth 4.0 and 5?

Thank you.

0 Kudos
21 Replies

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

Could you please provide your security set up?

Could you please confirm the SDK version that you are working on and the example that you modify?

I will try to run some tests by my side.

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for reply.

For which security setup you are asking - in mobile or in example code?

The SDK version is 2.2.1 of "SDK_2.2.1_MKW36A512xxx4"

The example code is for Heart Rate Sensor.

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

The example code.

Did you modify the SMP Data structure?

    .securityModeAndLevel = gSecurityMode_1_Level_3_c,
    .maxEncryptionKeySize = mcEncryptionKeySize_c,
    .localIoCapabilities = gIoDisplayOnly_c,
    .oobAvailable = FALSE,
    .centralKeys = gIrk_c, 
    .peripheralKeys = (gapSmpKeyFlags_t)(gLtk_c | gIrk_c),
    .leSecureConnectionSupported = TRUE,

Are you working with Secure connections? Did you define the use of privacy? gAppUsePrivacy_d

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply.

Current SMP Data structure in example code is as below:

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

I didn't change the SMP Data structure value before.

I have set value for Paring and Bonding as:

#define gAppUseBonding_d   1

#define gAppUsePairing_d   1

Value of gAppUsePrivacy_d as 0.

Should I have to change the value of gAppUsePrivacy_d and SMP Data structure?

Which values I have to set if there is anything need to be changed?

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

I ran some tests by my side, I have the same configuration that you have. 

Could you please disable the power down for testing purposes?

#define cPWR_UsePowerDownMode           0

Did you defined the #define gAppUseNvm_d  1?

Could you please erase all the flash memory and try it again?

I am not sure if you reach the maximum bonding devices, by default is 8.

However, just to confirm, you are trying to bond and pair the Sony phone device, but if you try to connect again, the connection is not a success. is it correct?

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply.

I have already disabled the power down mode. The value of cPWR_UsePowerDownMode is 0.

The value of gAppUseNVM_d is 0.

Should I have to set it as 1?

The maximum number of supported connection for this application is 1 as the value of gAppMaxConnections_c is 1.

As per my original question, when I am trying to connect with my Sony Xperia C3 Dual mobile device, without bond and pair it works fine.

If I Turn On the functionality of Bonding and Pairing by setting value of gAppUseBonding_d and gAppUsePairing_d as 1, I am not able to connect the KW36 EVM module using Bluetooth. Instead of asking to enter the passkey, it shows the notification that "Invalid passkey". In mobile device there is no settings I have done.

For Mobile Device with Bluetooth version 5.0, IOT application does not show the NXP_HRS, even advertising is running on EVM module.

I refer the the IOT application user guide from below link and now it's working fine.

Link: https://www.nxp.com/files-static/32bit/doc/user_guide/KBLETMAUG.pdf?&fsrch=1&sr=2&pageNum=1

For your information, I am using "Bluetooth Heart Rate Sensor Baremetal" example code. Sony mobile device works on Bluetooth version 4.0.

All the setting are defined as per shown in video. Lesson 5: Creating a Bluetooth Low Energy Heart Rate Sensor with Pairing & Bonding | NXP 

This example code works properly with Bluetooth version 4.1, 4.2 and 5.0. Also, IOT application works properly with this devices. So, now only need help to run application with Bluetooth version 4.0.

Kindly also let me know, which Bluetooth versions are supported with NXP IOT application??

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

The value of gAppUseNVM_d is 0. Should I have to set it as 1?

The NVM is used, in this case, to save all the bonding information there, not in the RAM memory.

So, now only need help to run the application with Bluetooth version 4.0.

Kindly also let me know, which Bluetooth versions are supported with NXP IOT application??

I tested with Bluetooth LE 4.0 and the device is able to connect successfully. The APP supports 4.0

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply.

Yes, not able to pair with Bluetooth version 4.0.

Currently IOT application works with Bluetooth versions 4.1, 4.2 and 5.0.

For Bluetooth version 4.1 and 4.2, when EVM module is advertising, it will show directly to the IOT application and pair with it.

For Bluetooth version 5.0, I have to Turn ON Location service in mobile device to catch the advertising module in IOT application and then I can connect to module.

For example code "Bluetooth Heart Rate Sensor Baremetal", able to pair and connect with mobile device with Bluetooth version 4.1, 4.2, and 5.0 and it works fine.

Today I do same thing with "Bluetooth Wireless UART Baremetal" example code and found that for all Bluetooth versions 4.1, 4.2 and 5.0, EVM module is able to pair and connect. But IOT application is not able to transfer data to KW36 module via Bluetooth.

Kindly guide which settings need to do to transfer data?

Also, guide IOT application connection with Bluetooth version 4.0.

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

But IOT application is not able to transfer data to the KW36 module via Bluetooth.

Are you trying to transfer by console or by UART? I tested by my side and it works.

What is the SDK version that you are working on?

Could you please describe step by step the process that you are following?

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply. Your query's answers are as below:

Are you trying to transfer by console or by UART? I tested by my side and it works.

>> I am sending data by console.

What is the SDK version that you are working on?

>> I am using SDK version 2.2.1

Could you please describe step by step the process that you are following?

>> Steps:

1. Import "Bluetooth Wireless UART Baremetal" example code.

2. Set value of "gAppUseBonding_d" and "gAppUsePairing_d" as 1.

3. Build Project. And Upload to KW36 EVM module.

4. Set EVM module as Peripheral.

5. Open IOT application in mobile device and click on Wireless UART.

6. Start advertising on EVM module. IOT application shows bluetooth device on mobile device.

7. Click on it. Application ask for pairing.

8. Enter passkey to pair with EVM module.

9. After successful pairing try to transfer data.

I tried again by importing same example code as per above steps. And I am able to transfer and receive data using console and UART both with Bluetooth versions 4.0, 4.1, 4.2 and 5.0. It means there is no problem right now.

Then we have changed code to run as GAP Peripheral only and it works fine.

Till now we have done basic testing and found no issue. We do more testing on it as per our requirement. And will contact you if found any other problem.

But wants to ask you one thing that, in my previous example code of "Bluetooth Wireless UART Baremetal" I have made some changes as below:

>> Commented SecLib_Init(), RNG_Init(), RNG_SetPseudoRandomNoSeed(NULL) in main_task() of AppMain.c file.

>> Excluded DCDC framework from compilation.

>> Excluded I2C driver file from compilation.

Do these changes will effect on connection?

Kindly give suggestion on this.

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

Yes, some of the functions depend on the connection. SecLib is for the hardware encryption, also for the DCDC configuration will affect the voltages reference of the MCU.

What is the reason for comment these lines?

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply and support.

The reason of commenting lines is to reduce the size of code as we are thinking to make two parts of memory of 256KB. But now no need to make two parts, as we are using external memory for our other data storage.

Now, I will only comment the lines to disable GAP Central functionality as we want use the KW36 module as GAP Peripheral only.

Also, we remove the functionality of RNG and I2C. Do these modules affect on connection?

If face any other problem after this, then I will contact you.

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

You can not commend the RNG,  because it is enabled the hardware for the encryption. You are working with pairing and bonding, so, you will need it.

Regards,

Mario

1,091 Views
chintan
Contributor III

Hello Mario,

We have done further testing with "Bluetooth Wireless UART_Baremetal" example code and found below observations.

When mobile is going to connect first time with KW36 module, it will ask for pairing request and to enter passkey notification on mobile. After successful pairing, I am able to transfer data both side - from Mobile to KW36 module and vice versa. After this I am disconnecting the mobile device.

Now, I try to connect KW36 module again. It will not ask for passkey because my mobile is already bonded with KW36 module previously. And this is OK.

But when I try to transfer data, I am able to transfer data from KW36 module to mobile device only. I am not able to transfer data from Mobile device to KW36 module. Also connection will terminate after 50 seconds when no data is transfer from both side or only KW36 module sends data to mobile device.

How can I transfer data from both sides if device is already bonded?

Another Query:

After first connection attempt, when I try to disconnect the mobile device, Connection establish automatically and I have to disconnect it again. What can be the reason for this?

Kindly suggest on both queries.

Thank you.

0 Kudos

1,091 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chitan,

Are you transferring data with the console or UART mode?, There is a known issue with the Console feature.

What is the return value that you are getting? Did you enable the NVM defined?

Regards,

Mario

0 Kudos

1,091 Views
chintan
Contributor III

Hello Mario,

Thanks for your reply.

I have tried to transfer data using both Console and UART mode. But not able to send the transfer data from Mobile device to KW36 module with second time connection. This will happens only with the bluetooth version 4.0. With other bluetooth versions (4.1, 4.2, 5.0), it works fine.

How would I know that NVM is enabled or not?

I found in app_preinclude.h file as below:

pastedImage_1.png

Is this correct location or anything else for NVM?

Thank you.

0 Kudos

1,090 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

I tested using an Andriod Phone Bluetooth 4.0, and it is working. it only works if you are working with the UART mode.

Is this the correct location or anything else for NVM?

Yes, that is the define for the NVM. If it is enabled, the bonding information will be saved in Flash memory, otherwise in RAM.

Regards,

Mario

1,090 Views
chintan
Contributor III

Hello Mario,

Happy New Year!!

Thanks for your reply.

I have enable "gAppUseNvm_d" macro by setting it as 1. And it stores the bluetooth device information to NVM successfully.

Kindly let me know the steps you followed with Bluetooth version 4.0. So, I will follow same steps to check whether it works with my phone or not. I am following below steps:

1. Power on the KW36 module in Peripheral mode.

2. Start advertising by pressing push button as per "Bluetooth Low Energy Demo Applications User's Guide" for Wireless UART example.

3. Turn ON Bluetooth on Mobile device and Start IOT application and Open Wireless UART.

4. Connect and Pair the mobile device with KW36 module.

5. After successful connection, transfer data two way.

6. Disconnect the mobile device.

(Up to this application works properly with my phone)

7. Now reconnect the mobile with KW36 module. This time it will not ask for pairing and bonding as it already bonded.

8. Try to transfer data two way.

I am only able to transfer data from KW36 module to Mobile device. But not able to transfer data from Mobile device to KW36 module.

Thank you.

0 Kudos

1,086 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Chintan,

I am only able to transfer data from KW36 module to Mobile device. But not able to transfer data from Mobile device to KW36 module.

I tested by my side, but I change the mode and it works.

Could you please try to change the UART mode to console and vice-versa?

There is an issue with the IoT  Toolbox, we are working on it.

Regards,

Mario

0 Kudos

1,086 Views
chintan
Contributor III

Hello Mario,

>> Could you please try to change the UART mode to console and vice-versa?

Ans:- I tried with both UART and Console mode, but not able to transfer data from Mobile to KW36 module using any mode.

As this is a known issue, so I think no need to spend more time on it.

 

As per my requirement, up till now module is working properly with Bluetooth version 4.1, 4.2 and 5.0. 

Thanks for your all efforts.

Thank you.