cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox Bluetooth SDK

Karoline
Employee

Hello!

I am working on the CYW920721B2EVK-02 where I have set up a Bluetooth connection, where I can bond with up to 8 devices. I now want to make an automatic connection with the first bonded device available, but I can't get it to work. 

Can anyone tell me if there is a way to make this possible, and if so, how?

Thank you!

Karoline

0 Likes
11 Replies
BragadeeshV
Moderator
Moderator

Hi @Karoline ,

Yes, this is possible. Please take a look at the following example project. Please let us know if you have any questions.

https://github.com/cypresssemiconductorco/mtb-example-btsdk-peripheral-privacy

Regards,
Bragadeesh
Karoline
Employee

That is wonderful to hear! I will look at the example 🙂

Thank you! 

Karoline

0 Likes
Karoline
Employee

This may be a stupid question, but the functions in the example looks like it is for Bluetooth LE. Do they also work with Bluetooth classic, which is what I am working with? 

0 Likes
BragadeeshV
Moderator
Moderator

Hi @Karoline ,

Yes, that example project is for bluetooth LE. 

For pairing and bonding example in BT Classic, you can refer the following example project:

https://github.com/cypresssemiconductorco/CypressAcademy_BT101_Files/tree/master/Projects/ch06a/key_...

Related PDF: https://github.com/cypresssemiconductorco/CypressAcademy_BT101_Files/blob/master/PDFs/WBT101-06A-Cla...

Regards,
Bragadeesh
0 Likes
Karoline
Employee

Hi,

I'm still not sure how I can make an automatic connection with a bonded device on boot. Can you help me with that?

 

Kind regards 

Karoline

PREVIEW
 
0 Likes
BragadeeshV
Moderator
Moderator

Hi @Karoline ,

Sorry, the bonding process is not showcased in the previous example. But you can do the following:

1. My assumption from your question is you already have the peer device's link keys and addr keys stored in the NVRAM (bonding process). If you are not there in this step, you can follow the BLE peripheral privacy example to do this as the process of pairing and storing/ retrieving of link keys is the same in both BR/EDR and BLE. You can also check the audio watch example where this is done. (paring and bonding)

https://github.com/cypresssemiconductorco/mtb-example-btsdk-audio-watch

2. After reset, in the BTM_ENABLED_EVT event, you need to add the link keys and peer device address to the address resolution database so that the device need not undergo the pairing process again. Use API wiced_bt_dev_add_device_to_address_resolution_db() to do this.

 

 

Regards,
Bragadeesh
0 Likes
Karoline
Employee

Hello again,

I have done the bonding process and added wiced_bt_dev_add_device_to_address_resolution_db() in the BTM_ENABLED_EVT event along with the function wiced_bt_connect(). I am able to get an automatic connection to a Windows computer, but not to an Android or an iPhone. Is there another function I have to use to get an automatic connection after reset?

 

Regards

Karoline

0 Likes
BragadeeshV
Moderator
Moderator

Hi @Karoline ,

The application is expected to reinitiate the connection with the previously paired Bluetooth address. When the reconnection process happens, the bluetooth stack will reuse the paired information by querying it from the application. Can you please let us know if you are initiating connection?

Regards,
Bragadeesh
0 Likes
Karoline
Employee

Hi Bragadeesh,

I would think I am initiating connection? Or at least that is what I am trying to do in order to get a connection on reset. 

 

Regards 

Karoline

0 Likes
BragadeeshV
Moderator
Moderator

Hi @Karoline ,

After reset are you entering the discoverable mode or are you sending paging request to the previously connected device. If you are in discoverable mode, ie waiting for a inquiry packet or a paging request then it is expected that the peer device (the phone) to send the connection request. Nothing can be done from our device side. But if you can put the phone in discoverable state, you can send the inquiry packet and the connection request from our device side and perform the reconnection process.

If you send a connection request from the phone (manually), does it automatically connect without the pairing process or do you have to go through the entire process again?

Regards,
Bragadeesh
0 Likes
Karoline
Employee

Hi Bragadeesh,

When phone is bonded to the cypress board, I don't have to go through the bonding process again, when sending a connection request. Then It finds the key and connects. 

I will try to find how to set the phone in discoverable state, like you said 🙂 

 

Regards 

Karoline

0 Likes