本人用的BLE是TIcc2541,1.3.2協議棧ios
一、首先要說明的是,iphone手機將信息保護了,BLE設備讀到的iphone地址是隨機的,每次鏈接都會不一樣iphone
二、下面我就具體說明如何查看手機的mac地址函數
首先個人程序是做爲從機的,從機配好開始廣播,事件SBP_START_DEVICE_EVT ---> GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );ui
而後進入peripheral.c中的GAPRole_ProcessEvent函數(關於回調函數我就不提了),spa
由事件SYS_EVENT_MSG --->gapRole_ProcessOSALMsg( (osal_event_hdr_t *)pMsg ); code
---> GAP_MSG_EVENT ---> gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );blog
---> GAP_LINK_ESTABLISHED_EVENT ---> 事件
#define GAP_LINK_ESTABLISHED_EVENT 0x05 ip
//!< Sent when the Establish Link Request is complete. This event is sent as an OSAL message defined as gapEstLinkReqEvent_t.回調函數
uint8 devAddr[B_ADDR_LEN]; //!< Device address of link
typedef struct
{
osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
uint8 opcode; //!< GAP_LINK_ESTABLISHED_EVENT
uint8 devAddrType; //!< Device address type: @ref GAP_ADDR_TYPE_DEFINES
uint8 devAddr[B_ADDR_LEN]; //!< Device address of link
uint16 connectionHandle; //!< Connection Handle from controller used to ref the device
uint16 connInterval; //!< Connection Interval
uint16 connLatency; //!< Conenction Latency
uint16 connTimeout; //!< Connection Timeout
uint8 clockAccuracy; //!< Clock Accuracy
} gapEstLinkReqEvent_t;
gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg;
DEBUG_PRINT("address: %s(%d)\r\n", bdAddr2Str(pPkt->devAddr), __LINE__);
此時address就是你手機藍牙的mac地址了,安卓和ios均可以,親測
歡迎交流,若有轉載請註明出處
新浪博客:http://blog.sina.com.cn/u/2049150530博客園:http://www.cnblogs.com/sky-heaven/知乎:http://www.zhihu.com/people/zhang-bing-hua