请参考以下这个API函数:
CYBLE_API_RESULT_T CyBle_GapGenerateKeys ( uint8 keysFlag,
CYBLE_GAP_SMP_KEY_DIST_T * keyInfo
)
This function generates and sets the security keys into BLE Stack that are to be exchanged with peer device during key exchange stage of authentication procedure. This is a blocking function. No event is generated on calling this function. This API does not generate identity address (keyInfo->idAddrInfo)
Parameters
keysFlag This parameter indicates which keys get exchanged with peer device. The following is the bit field mapping for the keys.
•Bit 0: Local Encryption information
•Bit 1: Local Identity information
•Bit 2: Local Signature Key
•Bit 3: Reserved
•Bit 4: Remote Encryption information
•Bit 5: Remote Identity information
•Bit 6: Remote Signature Key
•Bit 7: Reserved
keyInfo Pointer to a variable containing the returned keys, of type 'CYBLE_GAP_SMP_KEY_DIST_T'
Returns
CYBLE_API_RESULT_T : Return value indicates if the function succeeded or failed. Following are the possible error codes.
Errors codes Description
CYBLE_ERROR_OK On successful operation.
CYBLE_ERROR_INVALID_PARAMETER On specifying NULL as input parameter for 'keyInfo'