Need some clarification.
When I connect it for second time, the Authentification messages disappear. - which message is disappearing?
You have kept bonding - yes, but did you called CyBle_StoreBondingData() API for store bonding? I suggest you to go through our Bonding example project for better understanding. https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day015_Bonding
What I would like is to know how I can know if one already-authentified Central is in range of my PRoC. - Once after connecting and bonding, you can keep whitelist only that particular device. Please refer the following project :https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day014_Whitelist
Thanks for your kind comments and examples. They help me but however don't solve my problem totally...
- With the command CyBle_GapAddDeviceToWhiteList, I can avoid scan requests from devices out of this list. However, what I need is to know when a scan request message (SCAN_REQ) of such whitelist arrives (this would mean the user of the whitelist is in range). Is there any BLE Event to know when a user of the whitelist is in range (by checking for example SCAN_REQ message)?
Thanks in advance,
Upon receiving a scan request from a Central, peripheral will trigger an event CYBLE_EVT_GAP_SCAN_REQ_RECVD (go through BLE component datasheet for details). But it will not tell you which central send the scan request. But if you have only one Central and it is added to whitelist , and keep the filter policy as scan request whitelist. This may help you.
There is no other way to do the same.
Thanks & Regards,
Hi Anjana, thanks for the answer. This was what I was looking for!! And it is working perfectly.
I can not select the filter policy as scan request whitelist because somebody else (another central) might want to authentify so I need to check is the Central is in the Whitelist already.
How can I read the BD Address in the scan_req message? Knowing this I can compare it with all the devices in the whitelist using GapGetDevicesFromWhiteList. There must be a way to know the DB Address in the scan_req message as you need this information in the stack when selecting filter policy scan request whitelist.
Thanks in advance,
I found out I can change the filter policy dynamically in code so it should solve my issue. The idea is:
- Scan/Connect Request Any in *.cysch
- When CYBLE_EVT_GAP_DEVICE_CONNECTED event happens, I get my Peer Bd Address calling CyBle_GapGetPeerBdAddr and add it to the Whitelist with the command CyBle_GapAddDeviceToWhiteList.
- I change the FilterPolicy in CYBLE_EVT_GAP_DEVICE_DISCONNECTED event to CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY. When I disconnect I can see return value is ERROR_OK, so it should be added correctly to the WhiteList.
- I can see my Peer BD Address when calling CyBle_GapGetDevicesFromWhiteList in CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP. So everything looks fine.
Looking at my Smartphone Bluetooth Address, it doesn't match the returned peer Bluetooth Address (surrounded in red in the log.png). Am I reading out incorrectly the Peer Bluetooth Address? Or in a incorrect place? Is there any any other function to read out the Bluetooth Address of my peer device? Or is it maybe because I am not reading out the static/random public address?
Attached you can see the log and the source code.
Most mobile phones use, what is called, Resolvable Private Address or RPA. RPA is derived from an IRK; new address is generated over time. This is the reason you are seeing different addresses.
How can I read the real Bluetooth Address?
You can access the real address( ID address ) by calling CyBle_GapGetDevSecurityKeyInfo( uint8 *keyFlags,
CYBLE_GAP_SMP_KEY_DIST_T *keys) API. The parameter 'keys' is a pointer to a structure of type CYBLE_GAP_SMP_KEY_DIST_T which contains the real address.
For peer device use below API instead of mentioned in the previous post.
CyBle_GapGetPeerDevSecurityKeyInfo (uint8 bdHandle, uint8 *keysFlag,
Thanks for your comment. However, it is not working, I only see 00000000 as return. I have even used your Authentication project from Github https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day016_Authentication and I get the same result. See attached the UART Screenshot. Is there any possibility to get a correct Bluetooth Address? Should I maybe configure my Android Smartphone in another way? I assume as your FilterPolicy is working fine, you should have a way to read correctly the Bluetooth Address.
Authentication.PNG 12.3 K
You can get your bluetooth public address here.
Update your stack handler code by adding this event.
/*Key Information exchange completed */
KEY = *(CYBLE_GAP_SMP_KEY_DIST_T *)eventParam;
for( j = 1; j < CYBLE_GAP_SMP_IDADDR_DATA_SIZE; j++ )