Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

PSOC6_dev
Level 4
Level 4
25 sign-ins 25 replies posted First like given

Hi community,

I need your help on something. For information I use mtb2.4 and bless lib and ble is configured in peripheral mode.

How we can allow gatt connexion only for paired/bonded devices ?

Another question, If multiple devices are paired and connect to the system what is the way to recognize if one device was previously conected to the system ?

 

Thank you for your support,

Kind regards,

0 Likes
6 Replies
Yugandhar
Moderator
Moderator
Moderator
1000 replies posted 5 likes given First comment on blog

Hello @PSOC6_dev ,

We would recommend using MTB 3.0 with new AIROC BT Stack. If you want to use the old BLESS Stack, then you can use the PSoC Creator.

Q1) How we can allow gatt connexion only for paired/bonded devices?

Ans: After devices are bonded, they do not have to go through the pairing process again when reconnected.
You can add the paired/bonded devices to the whitelist data, and in the Filter Policy(in BLE Component) set to Connect request: whitelist. This will allow Connect Requests only from White List devices. 

Q2) Another question, if multiple devices are paired and connect to the system what is the way to recognize if one device was previously connected to the system?

Ans: You can use the function Cy_BLE_GAP_GetBondList() which returns the count of bonded devices and the list of bonded devices with their BD address and bdHandle.

Thanks,
P Yugandhar.

0 Likes
PSOC6_dev
Level 4
Level 4
25 sign-ins 25 replies posted First like given

Hi @Yugandhar ,

Sorry for my late answer,

Thank you for your feedback!

Q1 -> Yes, i do this. But on a "fresh" device i need to add an extra step.

I want to allow connection and read/write char only for paired/bonded devices.

When pairing is done i activate white list and all is fine but I don't know how to do at the very first connection.

 

Do you have any idea ?

 

Thank you for your support,

Regards

0 Likes
PSOC6_dev
Level 4
Level 4
25 sign-ins 25 replies posted First like given

Anyone has the same use than mine ?

 

Regards

0 Likes
Yugandhar
Moderator
Moderator
Moderator
1000 replies posted 5 likes given First comment on blog

Hello @PSOC6_dev , 

During first connection, once the device is paired and bonded then you can add the device to whitelist using Cy_BLE_AddDeviceToWhiteList() API.

Thanks,

P Yugandhar.  

0 Likes

Hi @Yugandhar 

Thank you for your feedback.

I'm already doing this. My problem is when my device is in "pairing mode" it accept connection from all ble central devices that connect to it.

If the ble central just connect and do not try to pair after it use one "connection slot" for nothing and block connection for others ble central devices (I set max conn to 1).

I have an issue on windows because after I unpair the device on Windows one process continuously connect to the unpaired device and do not let some other devices to pair...

 

Regards,

0 Likes
Yugandhar
Moderator
Moderator
Moderator
1000 replies posted 5 likes given First comment on blog

Hello @PSOC6_dev , 

Once the device is paired/bonded then after disconnection, in the code, you can set the Advertiement filter policy to Scan request: Any | Connect request: White List (which Process scan requests from all devices and connect requests only from devices in the White List).

During second connection, this will allow connection from only whitelist devices.

***************************************************

cy_ble_discoveryModeInfo[CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX].advParam->advFilterPolicy = CY_BLE_GAPP_SCAN_ANY_CONN_WHITELIST;

Cy_BLE_GAPP_StartAdvertisement(CY_BLE_ADVERTISING_FAST, CY_BLE_PERIPHERAL_CONFIGURATION_0_INDEX);

***************************************************

Please let me know if I'm missing something. 

Thanks,

P Yugandhar. 

0 Likes