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;

 

獲取這個地址,可以用於設置白名單,定向廣播等功能


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM