Once, you have bonded with the expected device, you can simple set the cyBle_authInfo.bonding = CYBLE_GAP_BONDING_NONE;
- Madhu Sudhan
Thanks again Madhu.
However I note that this is not documented in the API help file.
I took the following alternative approach in the end:
In configuration/GAP Settings/Advertisement settings set Filter Policy: 'Scan request: Any | Connect request: White list'.
In CYBLE_EVT_GAP_AUTH_COMPLETE: and CYBLE_EVT_STACK_ON: Used CyBle_GapGetBondedDevicesList and CyBle_GapAddDeviceToWhiteList to copy the device address from the bond list to the white list.
Copied the API function CyBle_GappStartAdvertisement into my own version and modified it as follows:
uint8 blegcp_advFilterPolicy = 0xFFu;
CYBLE_API_RESULT_T blegcp_GappStartAdvertisement(uint8 advertisingIntervalType, uint8 bypassFilter)
// JH: Added these lines to version copied from the API:
if (blegcp_advFilterPolicy == 0xFFu) blegcp_advFilterPolicy = cyBle_discoveryModeInfo.advParam->advFilterPolicy;
cyBle_discoveryModeInfo.advParam->advFilterPolicy = (bypassFilter)? CYBLE_GAPP_SCAN_ANY_CONN_ANY : blegcp_advFilterPolicy;
if(advertisingIntervalType > CYBLE_ADVERTISING_CUSTOM)
apiResult = CYBLE_ERROR_INVALID_PARAMETER;
else if((CYBLE_STATE_DISCONNECTED == CyBle_GetState()) && ((cyBle_eventHandlerFlag & CYBLE_START_FLAG) == 0u))
if(advertisingIntervalType == CYBLE_ADVERTISING_FAST)
cyBle_discoveryModeInfo.advTo = CYBLE_FAST_ADV_TIMEOUT;
cyBle_discoveryModeInfo.advParam->advIntvMin = CYBLE_FAST_ADV_INT_MIN;
cyBle_discoveryModeInfo.advParam->advIntvMax = CYBLE_FAST_ADV_INT_MAX;
else if(advertisingIntervalType == CYBLE_ADVERTISING_SLOW)
cyBle_discoveryModeInfo.advTo = CYBLE_SLOW_ADV_TIMEOUT;
cyBle_discoveryModeInfo.advParam->advIntvMin = CYBLE_SLOW_ADV_INT_MIN;
cyBle_discoveryModeInfo.advParam->advIntvMax = CYBLE_SLOW_ADV_INT_MAX;
else /* Do not update advertising intervals */
cyBle_advertisingIntervalType = advertisingIntervalType;
apiResult = CyBle_GappEnterDiscoveryMode(&cyBle_discoveryModeInfo);
if(CYBLE_ERROR_OK == apiResult)
cyBle_eventHandlerFlag |= CYBLE_START_FLAG;
apiResult = CYBLE_ERROR_INVALID_STATE;
Now I can override the filter when the bond list is empty and apply it as set in configuration when the bond has already been made, preventing any other device from connecting and therefore from bonding.
It is irritating though that one cannot do this sort of stuff through the published API. I found (the hard way) that you have to set a Filter policy using the white list in configuration otherwise CyBle_GapAddDeviceToWhiteList fails, so you cannot start without a filter policy and then set one once bonded, which would have been more natural.