2640配对 绑定中的问题
您好。
2640做从设备和手机连接,遇到了网上很多人问的不用配对绑定,手机直接就能连的问题,现在在根据这篇博客http://www.cnblogs.com/heiyue/p/6109583.html在试,博客中bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role )函数指到了gapbondmgr.c下的函数原型,而我在试的过程中发现在gapbondmgr.c和icallbleapi.c中都有该函数定义并且不一样。
问题一,这两个不一样有影响吗?
问题二,跟踪调试发现总是指向icallbleapi.c中的定义,怎样才能让其指向peripheral.c。我把ICallBleAPI.c中的定义删掉,rebuild时又提示peripheral.c中调用的该函数未定义,而我在peripheral.c写了#include “gapbondmgr.h”,在gapbondmgr.h也定义了extern VOID GAPBondMgr_LinkEst(...)。
以下是icallbleapi.c中的定义,
/*********************************************************************
* @brief Notify the Bond Manager that a connection has been made.
*
* Public function defined in gapbondmgr.h.
*/
bStatus_t GAPBondMgr_LinkEst(uint8 addrType, uint8 *pDevAddr,
uint16 connHandle, uint8 role)
{
/* Allocate message buffer space */
ICall_BondMgrLinkEst *msg =
(ICall_BondMgrLinkEst *)ICall_allocMsg(sizeof(ICall_BondMgrLinkEst));
if (msg)
{
setDispatchCmdEvtHdr(&msg->hdr, DISPATCH_GAP_PROFILE,
DISPATCH_GAP_BOND_LINK_EST);
// Set service change parameters
msg->addrType = addrType;
msg->pDevAddr = pDevAddr;
msg->connHandle = connHandle;
msg->role = role;
// Send the message
return sendWaitMatchCS(ICall_getEntityId(), msg, matchGapLinkEstCS);
}
return MSG_BUFFER_NOT_AVAIL;
}
以下是gapbondmgr.c中的函数定义原型
/*********************************************************************
* @brief Notify the Bond Manager that a connection has been made.
*
* Public function defined in gapbondmgr.h.
*/
bStatus_t GAPBondMgr_LinkEst( uint8 addrType, uint8 *pDevAddr, uint16 connHandle, uint8 role )
{
uint8 idx; // NV Index
uint8 publicAddr[B_ADDR_LEN] // Place to put the public address
= {0, 0, 0, 0, 0, 0};
idx = GAPBondMgr_ResolveAddr( addrType, pDevAddr, publicAddr );
if ( idx < GAP_BONDINGS_MAX )
{
uint8 stateFlags = gapBondMgrGetStateFlags( idx );
smSigningInfo_t signingInfo;
gapBondCharCfg_t charCfg[GAP_CHAR_CFG_MAX]; // Space to read a char cfg record from NV
// On peripheral, load the key information for the bonding
// On central and initiaiting security, load key to initiate encyption
gapBondMgrBondReq( connHandle, idx, stateFlags, role,
((gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE ) ? TRUE : FALSE) );
// Load the Signing Key
VOID osal_memset( &signingInfo, 0, sizeof ( smSigningInfo_t ) );
if ( osal_snv_read( devCSRKNvID(idx), KEYLEN, signingInfo.srk ) == SUCCESS )
{
if ( osal_isbufset( signingInfo.srk, 0xFF, KEYLEN ) == FALSE )
{
// Load the signing information for this connection
VOID osal_snv_read( devSignCounterNvID(idx), sizeof ( uint32 ), &(signingInfo.signCounter) );
VOID GAP_Signable( connHandle,
((stateFlags & GAP_BONDED_STATE_AUTHENTICATED) ? TRUE : FALSE),
&signingInfo );
}
}
// Load the characteristic configuration
if ( osal_snv_read( gattCfgNvID(idx), sizeof ( charCfg ), charCfg ) == SUCCESS )
{
uint8 i;
gapBondMgrInvertCharCfgItem( charCfg );
for ( i = 0; i < GAP_CHAR_CFG_MAX; i++ )
{
gapBondCharCfg_t *pItem = &(charCfg[i]);
// Apply the characteristic configuration for this connection
if ( pItem->attrHandle != GATT_INVALID_HANDLE )
{
VOID GATTServApp_UpdateCharCfg( connHandle, pItem->attrHandle,
(uint16)(pItem->value) );
}
}
}
#ifndef GATT_NO_SERVICE_CHANGED
// Has there been a service change?
if ( stateFlags & GAP_BONDED_STATE_SERVICE_CHANGED )
{
VOID GATTServApp_SendServiceChangedInd( connHandle, gapBondMgr_TaskID );
}
#endif // GATT_NO_SERVICE_CHANGED
}
#if ( HOST_CONFIG & CENTRAL_CFG )
else if ( role == GAP_PROFILE_CENTRAL &&
gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE )
{
// If Central and initiating and not bonded, then initiate pairing
gapBondMgrAuthenticate( connHandle, addrType, NULL );
// Call app state callback
if ( pGapBondCB && pGapBondCB->pairStateCB )
{
pGapBondCB->pairStateCB( connHandle, GAPBOND_PAIRING_STATE_STARTED, SUCCESS );
}
}
#endif
#if ( HOST_CONFIG & PERIPHERAL_CFG )
// If Peripheral and initiating, send a slave security request to
// initiate either pairing or encryption
if ( role == GAP_PROFILE_PERIPHERAL &&
gapBond_PairingMode == GAPBOND_PAIRING_MODE_INITIATE )
{
gapBondMgrSlaveSecurityReq( connHandle );
}
#endif
return ( SUCCESS );
}
请问你用的是什么版本的BLE STACK及哪个例程?
抱歉,前边有个文件名写错了。
是peripheral.c中调用,在gapbondmgr.c和icallbleapi.c中都有函数定义。
IAR 73.40.3.8938;ble_cc36xx_2_01_00_44423;smipleBLEPeripheral例程,但该例程默认的passcode和pair的回调函数是NULL,所以我试的时候是参考Bloodpressure加的。