zoukankan      html  css  js  c++  java
  • BLE获取iphone mac地址的方法--【原创】

    本人用的BLE是TIcc2541,1.3.2协议栈

    1、首先要说明的是,iphone手机将信息保护了,BLE设备读到的iphone地址是随机的,每次连接都会不同

    2、下面我就具体说明如何查看手机的mac地址

    首先我的程序是作为从机的,从机配好开始广播,事件SBP_START_DEVICE_EVT ---> GAPRole_StartDevice( &simpleBLEPeripheral_PeripheralCBs );

    然后进入peripheral.c中的GAPRole_ProcessEvent函数(关于回调函数我就不提了),

    由事件SYS_EVENT_MSG --->gapRole_ProcessOSALMsg( (osal_event_hdr_t *)pMsg );  

    ---> GAP_MSG_EVENT ---> gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );

    ---> GAP_LINK_ESTABLISHED_EVENT ---> 

    #define GAP_LINK_ESTABLISHED_EVENT            0x05

    //!< 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) ", 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

  • 相关阅读:
    ulimit -a
    nginx check_http_send type=http 查检测不到后端TOM的存活
    通过ip查找能应机器的MAC
    错误状态码URL重定向
    error_page 改变状态码为新的状态码,并显示指定内容
    使用 CefSharp 在 C# App 中嵌入 Chrome 浏览器
    C#客户端嵌入Chrome浏览器的实现
    Task.Run c#启动线程
    C#利用webBrowser怎么去掉网页中不想显示的部分
    InDesign CC 2019安装包+破解
  • 原文地址:https://www.cnblogs.com/sky-heaven/p/4317034.html
Copyright © 2011-2022 走看看