以同用外設為例,在狀態回調函數中
/*********************************************************************
* @fn peripheralStateNotificationCB
*
* @brief Notification from the profile of a state change.
*
* @param newState - new state
*
* @return none
*/
static void peripheralStateNotificationCB( gapRole_States_t newState, gapRoleEvent_t * pEvent )
連接狀態里面
case GAPROLE_CONNECTED:
if( pEvent->gap.opcode == GAP_LINK_ESTABLISHED_EVENT )
{
Peripheral_LinkEstablished( pEvent );
PRINT( "Connected..\n" );
int i,j;
// Increment index of current result (with wraparound)
PRINT ( "directAddressType=%x ",pEvent->linkCmpl.devAddrType ); //獲取地址類型
PRINT ( "Device %d : ", j );
for( i=0; i<6; i++)
{
PRINT ( "%x ",pEvent->linkCmpl.devAddr[i]);//打印地址
}
PRINT ("\n");
}
break;
獲取這個地址,可以用於設置白名單,定向廣播等功能