CH579 CH573 CH582 BLE从机获取连接主机MAC地址和类型
以同用外设为例,在状态回调函数中
/*********************************************************************
* @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;
获取这个地址,可以用于设置白名单,定向广播等功能