- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I try to get MAC adres of device ( example laptop) that want connect to Bluetooth mouse that is implemented from cypress example on CYPROTO-06-BLE kit. When I get MAC I would like compare it form one that is in memory and if its match allow to connect. I think some code should be add in event:
case CY_BLE_EVT_GAP_AUTH_REQ:
But I don't know how to read MAC of device that want to connect and how to allow or disallow for connection.
Does anyone know how to do it ? I will be very thankful.
Regards,
Bartek
Solved! Go to Solution.
- Labels:
-
PSoC 6 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bartek,
You can find the MAC address of the peer device in the CY_BLE_EVT_GAP_DEVICE_CONNECTED event itself. The event parameter for the CY_BLE_EVT_GAP_DEVICE_CONNECTED event is of type cy_stc_ble_gap_connected_param_t which has the peer device's address. So you can use some local flag to identify if the connected device is unwanted and then reject the authentication.
Hope this information helps. Please update if you need more information.
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bartek,
On the peripheral side, you can set the Filter policy as Scan request: Any, Connect Request: Whitelist
Once this setting is set, you can add the Laptop address to Whitelist using the API Cy_BLE_AddDeviceToWhiteList () so that the peripheral accepts connection only from those devices added to the whitelist. Please refer to peripheral driver library BLE API documentation for more information.
Thanks and regards
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. It is very helpful.
Do you know if there is possibility to have "black list". It means to allow to connect every one, but only reject connection from some devices ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry. The blacklist is not directly possible to implement in the BLE application. You need to manually create it. Also, you do not have any control over the connection with "blacklisted" devices. You can only reject the authentication by not calling the API CyBle_AuthReqReply() when the event CY_BLE_EVT_GAP_AUTH_REQ triggers.
Thanks and regards
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Do you know if it is possible and how to check peer device mac adres or name in event CY_BLE_EVT_GAP_AUTH_REQ in order to compare with ma custom black list ?
Regards,
Bartek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bartek,
You can find the MAC address of the peer device in the CY_BLE_EVT_GAP_DEVICE_CONNECTED event itself. The event parameter for the CY_BLE_EVT_GAP_DEVICE_CONNECTED event is of type cy_stc_ble_gap_connected_param_t which has the peer device's address. So you can use some local flag to identify if the connected device is unwanted and then reject the authentication.
Hope this information helps. Please update if you need more information.
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works ! Thank you 🙂 You help me a lot.
I add lines in event to check :
.......
case CY_BLE_EVT_GAP_DEVICE_CONNECTED:
DBG_PRINTF("MAC = %d %d %d %d %d %d\r\n",
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[0],
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[1],
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[2],
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[3],
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[4],
(*(cy_stc_ble_gap_connected_param_t *)eventParam).peerAddr[5]);
......