How to permit only one client to connect to a server

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

cross mob
DeCo_1926091
Level 4
Level 4
First like received

I have a PSoC4 BLE acting as a peripheral server to an iPad client central device.  I want to bond the two devices and permit only one iPad to connect to the peripheral.

The file BLE_1_StackGap.h contains the following #defines:

/* Maximum number of Remote Devices */

#define CYBLE_GAP_MAX_BONDED_DEVICE             0x04u

#define CYBLE_GAP_SIZE_OF_WHITELIST 0x08u

#define CYBLE_GAP_SIZE_OF_RESOLVING_LIST        0x08u

/* This is kept for backward compatibility, will be obsolete in future */

#define CYBLE_MAX_WHITELIST_ENTRIES 0x04u

My questions:

1.  Is what I have described in the first paragraph workable?

2.  In order to accomplish what I want is it sufficient to change

#define CYBLE_GAP_MAX_BONDED_DEVICE   to  0x01u,

#define CYBLE_MAX_WHITELIST_ENTRIES       to  0x01u and

#define CYBLE_GAP_SIZE_OF_WHITELIST        to  0x02u?

3. Is there anything else that must be done, or am I barking up the wrong tree entirely?

Thanks for any help you can offer.

Dennis

0 Likes
1 Solution
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Dennis,

1. In order to connect only one particular central device to the peripheral, Add the central device address to the whitelist of the peripheral device and in the "Advertisement settings" change the Filter policy to "Scan request: Any | Connect request: White list" which allows the link layer to process connection requests only from devices in the whitelist.

Most of the smart phones use RPA(Random Private Address) as their Bluetooth device address. So, adding the smartphone device address in the White list only, will not resolve this issue and you have to use the Resolving List as well. That means, you have to add the central device address to the Resolving list as well as to the White list in your peripheral device. Please refer the PSoC Creator Code Example 'BLE_4.2_Datalength_Security_Privacy' ( PSoC Creator-> File-> Code Example) for more information on this.

2. Or, if you want to allow only one central device to bond with the peripheral then before storing the bonding data check for the bonded devices count. If the count is 0 then store that central device keys else don't store the bonding data (in this case only first device bonding data will be stored).

Please let me know if I'm missing anything.

Thanks,

P Yugandhar.

View solution in original post

2 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Dennis,

1. In order to connect only one particular central device to the peripheral, Add the central device address to the whitelist of the peripheral device and in the "Advertisement settings" change the Filter policy to "Scan request: Any | Connect request: White list" which allows the link layer to process connection requests only from devices in the whitelist.

Most of the smart phones use RPA(Random Private Address) as their Bluetooth device address. So, adding the smartphone device address in the White list only, will not resolve this issue and you have to use the Resolving List as well. That means, you have to add the central device address to the Resolving list as well as to the White list in your peripheral device. Please refer the PSoC Creator Code Example 'BLE_4.2_Datalength_Security_Privacy' ( PSoC Creator-> File-> Code Example) for more information on this.

2. Or, if you want to allow only one central device to bond with the peripheral then before storing the bonding data check for the bonded devices count. If the count is 0 then store that central device keys else don't store the bonding data (in this case only first device bonding data will be stored).

Please let me know if I'm missing anything.

Thanks,

P Yugandhar.

Thanks. I think I understand. We'll see when I try it.

Dennis

0 Likes