- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I cannot connect to more than 4 devices by using CyBle_GapRemoveOldestDevice. When the fifth BLE central tries to connect, the device reject the connection by returning "CYBLE_HCI_CONNECTION_TERMINATED_LOCAL_HOST_ERROR" in disconnect event.
This problem only occur occasionally, I tested on serval devices and only 1 of them has this issue. For the others, I repeat the testing many time but they can connect to more than 4 devices. And after I reprogram the device, sometimes it can connect to more than 5 devices but sometimes do not.
After calling "CyBle_GapRemoveOldestDevice", I then call "CyBle_StoreBondingData" to update the bonding list in flash.
However, I put the "CyBLe_GapRemoveOldestDevice" in event "CYBLE_EVT_GAP_AUTH_REQ", would it be the reason that the device rejects connection and returns "CYBLE_HCI_CONNECTION_TERMINATED_LOCAL_HOST_ERROR"?
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
It is not recommended to call the CyBle_GapRemoveOldestDeviceFromBondedList() API in CYBLE_EVT_GAP_AUTH_REQ event. Please call this API in Disconnection event as shown in below code.
**********************************
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
CyBle_GapGetBondedDevicesList(&bonddevlist);
if(bonddevlist.count==CYBLE_GAP_MAX_BONDED_DEVICE)
{
/*Removes the oldest device from the bonded and white lists.*/
apiResult =CyBle_GapRemoveOldestDeviceFromBondedList();
/* CyBle_StoreBondingData should be called to clear the Bonding info from flash */
while(CYBLE_ERROR_OK != CyBle_StoreBondingData(1));
/* Restart the advertisement */
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
else
{
/* Restart the advertisement */
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
break;
**********************************
Please let me know if you have any questions.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello juyu_1538976 ,
1. It is recommended to remove the bonded devices during Disconnection state. The API CyBle_GapRemoveOldestDeviceFromBondedList() will removes the oldest device from the bonded and white lists. This API should not be called while in connected state. If device is connected to the oldest device, and this API is called, it will remove the device which is next oldest and not connected.
2. Please refer to the Day15_Bonding example project in the GitHub for more information on storing and removing of the bonded devices.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Yugandhar,
Thank you very much for the reply.
If we call the API during connected state, will it make the device unable to pair with more new BLE centrals?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello juyu_1538976 ,
If you call this API in connected state then each time it will remove the device which is next oldest and not connected. At my end, I tested the project pairing with more new BLE central devices where I'm able to pair successfully. Could you please share your project, so that we can check at our end ? Please refer to the attached sample project for your reference and let me know if you have any issues.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi PY_21
On my side not all device have this issue. It happen on some devices only. But when it happen, that device can no longer connect to a new device anymore. Only erase the whole flash can solve the problem.
How do I share the project with you?
Best Regards
Jun Yung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello juyu_1538976 ,
In PSoC Creator, go to File ->Create Workspace Bundle -> Select minimal. Please attach the generated file.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi PY_21
sorry for my late reply.
Please find my workspace in below link. The issue does not always happen, but it would be good if you can give me some suggestion on what's wrong in my BLE implementation.
https://drive.google.com/open?id=1NtczaUWLLTRXZgcCVw5KI1kI8Du7XZm2
Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi PY_21
Can you think of any other reason that the BLE would reject the connection of fifth device?
I found that when this happen, the peripheral disconnect immediately after "CYBLE_EVT_GAP_DEVICE_CONNECTED", without going through "CYBLE_EVT_GAP_AUTH_REQ" and "CYBLE_EVT_GAP_AUTH_COMPLETE".
Thanks
Jun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
It is not recommended to call the CyBle_GapRemoveOldestDeviceFromBondedList() API in CYBLE_EVT_GAP_AUTH_REQ event. Please call this API in Disconnection event as shown in below code.
**********************************
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
CyBle_GapGetBondedDevicesList(&bonddevlist);
if(bonddevlist.count==CYBLE_GAP_MAX_BONDED_DEVICE)
{
/*Removes the oldest device from the bonded and white lists.*/
apiResult =CyBle_GapRemoveOldestDeviceFromBondedList();
/* CyBle_StoreBondingData should be called to clear the Bonding info from flash */
while(CYBLE_ERROR_OK != CyBle_StoreBondingData(1));
/* Restart the advertisement */
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
else
{
/* Restart the advertisement */
apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
}
break;
**********************************
Please let me know if you have any questions.
Thanks,
P Yugandhar.