日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【BLE】CC2541获取设备的MAC地址实验

發布時間:2024/3/26 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【BLE】CC2541获取设备的MAC地址实验 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安卓調試工具掃描時直接顯示就是MAC地址。
蘋果設備是以UUID的方式顯示。
所以我們直接用安卓設備來測試。

我們連接時可以知道主機的地址。
變量是gapRole_ConnectedDevAddr,可以在peripherial.c里搜索GAP_LINK_ESTABLISHED_EVENT事件的處理。

static void gapRole_ProcessGAPMsg( gapEventHdr_t *pMsg ) {uint8 notify = FALSE; // State changed notify the app? (default no)switch ( pMsg->opcode ){case GAP_DEVICE_INIT_DONE_EVENT:{gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;bStatus_t stat = pPkt->hdr.status;if ( stat == SUCCESS ){// Save off the generated keysVOID osal_snv_write( BLE_NVID_IRK, KEYLEN, gapRole_IRK );VOID osal_snv_write( BLE_NVID_CSRK, KEYLEN, gapRole_SRK );// Save off the informationVOID osal_memcpy( gapRole_bdAddr, pPkt->devAddr, B_ADDR_LEN );gapRole_state = GAPROLE_STARTED;// Update the advertising datastat = GAP_UpdateAdvertisingData( gapRole_TaskID,TRUE, gapRole_AdvertDataLen, gapRole_AdvertData );}if ( stat != SUCCESS ){gapRole_state = GAPROLE_ERROR;}notify = TRUE;}break;case GAP_ADV_DATA_UPDATE_DONE_EVENT:{gapAdvDataUpdateEvent_t *pPkt = (gapAdvDataUpdateEvent_t *)pMsg;if ( pPkt->hdr.status == SUCCESS ){if ( pPkt->adType ){// Setup the Response DatapPkt->hdr.status = GAP_UpdateAdvertisingData( gapRole_TaskID,FALSE, gapRole_ScanRspDataLen, gapRole_ScanRspData );}else{// Start advertisingVOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );}}if ( pPkt->hdr.status != SUCCESS ){// Set into Error stategapRole_state = GAPROLE_ERROR;notify = TRUE;}}break;case GAP_MAKE_DISCOVERABLE_DONE_EVENT:case GAP_END_DISCOVERABLE_DONE_EVENT:{gapMakeDiscoverableRspEvent_t *pPkt = (gapMakeDiscoverableRspEvent_t *)pMsg;if ( pPkt->hdr.status == SUCCESS ){if ( pMsg->opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT ){gapRole_state = GAPROLE_ADVERTISING;}else // GAP_END_DISCOVERABLE_DONE_EVENT{if ( gapRole_AdvertOffTime != 0 ){if ( ( gapRole_AdvEnabled ) ){VOID osal_start_timerEx( gapRole_TaskID, START_ADVERTISING_EVT, gapRole_AdvertOffTime );}}else{// Since gapRole_AdvertOffTime is set to 0, the device should not// automatically become discoverable again after a period of time.// Set enabler to FALSE; device will become discoverable again when// this value gets set to TRUEgapRole_AdvEnabled = FALSE;}// In the Advertising Off periodgapRole_state = GAPROLE_WAITING;}}else{gapRole_state = GAPROLE_ERROR;}notify = TRUE;}break;case GAP_LINK_ESTABLISHED_EVENT:{gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg;if ( pPkt->hdr.status == SUCCESS ){VOID osal_memcpy( gapRole_ConnectedDevAddr, pPkt->devAddr, B_ADDR_LEN );gapRole_ConnectionHandle = pPkt->connectionHandle;gapRole_state = GAPROLE_CONNECTED;if ( gapRole_RSSIReadRate ){// Start the RSSI ReadsVOID osal_start_timerEx( gapRole_TaskID, RSSI_READ_EVT, gapRole_RSSIReadRate );}// Store connection informationgapRole_ConnInterval = pPkt->connInterval;gapRole_ConnSlaveLatency = pPkt->connLatency;gapRole_ConnTimeout = pPkt->connTimeout;// Check whether update parameter request is enabledif ( gapRole_ParamUpdateEnable == TRUE ){// Get the minimum time upon connection establishment before the // peripheral can start a connection update procedure.uint16 timeout = GAP_GetParamValue( TGAP_CONN_PAUSE_PERIPHERAL );osal_start_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT, timeout*1000 );}// Notify the Bond Manager to the connectionVOID GAPBondMgr_LinkEst( pPkt->devAddrType, pPkt->devAddr, pPkt->connectionHandle, GAP_PROFILE_PERIPHERAL );}else if ( pPkt->hdr.status == bleGAPConnNotAcceptable ){// Set enabler to FALSE; device will become discoverable again when// this value gets set to TRUEgapRole_AdvEnabled = FALSE;// Go to WAITING state, and then start advertisinggapRole_state = GAPROLE_WAITING;}else{gapRole_state = GAPROLE_ERROR;}notify = TRUE;}break;case GAP_LINK_TERMINATED_EVENT:{gapTerminateLinkEvent_t *pPkt = (gapTerminateLinkEvent_t *)pMsg;GAPBondMgr_ProcessGAPMsg( (gapEventHdr_t *)pMsg );osal_memset( gapRole_ConnectedDevAddr, 0, B_ADDR_LEN );// Erase connection informationgapRole_ConnInterval = 0;gapRole_ConnSlaveLatency = 0;gapRole_ConnTimeout = 0;// Cancel all connection parameter update timers (if any active)VOID osal_stop_timerEx( gapRole_TaskID, START_CONN_UPDATE_EVT );VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );// Go to WAITING state, and then start advertisingif( pPkt->reason == LL_SUPERVISION_TIMEOUT_TERM ){gapRole_state = GAPROLE_WAITING_AFTER_TIMEOUT;}else{gapRole_state = GAPROLE_WAITING;}notify = TRUE;VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT );gapRole_ConnectionHandle = INVALID_CONNHANDLE;}break;case GAP_LINK_PARAM_UPDATE_EVENT:{gapLinkUpdateEvent_t *pPkt = (gapLinkUpdateEvent_t *)pMsg;// Cancel connection param update timeout timer (if active)VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );if ( pPkt->hdr.status == SUCCESS ){// Store new connection parametersgapRole_ConnInterval = pPkt->connInterval;gapRole_ConnSlaveLatency = pPkt->connLatency;gapRole_ConnTimeout = pPkt->connTimeout;// Make sure there's no pending connection update procedureif ( osal_get_timeoutEx( gapRole_TaskID, START_CONN_UPDATE_EVT ) == 0 ){// Notify the application with the new connection parametersif ( pGapRoles_ParamUpdateCB != NULL ){(*pGapRoles_ParamUpdateCB)( gapRole_ConnInterval, gapRole_ConnSlaveLatency, gapRole_ConnTimeout );}}}}break;default:break;}if ( notify == TRUE ){// Notify the application with the new state changeif ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnStateChange ){pGapRoles_AppCGs->pfnStateChange( gapRole_state );}} }

應用場景:需要把mac地址通過藍牙傳輸上去的話,gapRole_ConnectedDevAddr可以使用的到。

總結

以上是生活随笔為你收集整理的【BLE】CC2541获取设备的MAC地址实验的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 特级做a爱片免费69 少妇第一次交换又紧又爽 亚洲大胆人体 | av福利院| 欧美性生交大片免费看app麻豆 | 上原亚衣在线观看 | 九九在线免费视频 | 永久av免费在线观看 | 私密spa按摩按到高潮 | 久久久久亚洲av无码麻豆 | 自拍偷拍99 | 国产特级黄色录像 | 超碰天堂| 欧美成人高清在线 | 亚洲高清在线看 | 男生捅女生肌肌 | 精品人妻一区二区三区四区在线 | 亚洲成人动漫在线观看 | 久久女女| 国内一级黄色片 | 在线播放av片 | 日韩高清一区二区 | 天堂网一区二区 | 免费a视频在线观看 | 伊人久久大香线蕉av一区 | 免费日本黄色 | 精东av在线| 成人午夜视频免费 | 亚洲精品成人区在线观看 | 91av观看| 丁香六月综合 | 琪琪色18 | 蜜桃精品久久久久久久免费影院 | 欧美精品一区二区在线观看 | 日韩精品一区二 | 91素人约啪 | 国产一卡二卡三卡 | 午夜aa| 日日麻批免费视频播放 | 日本一级理论片在线大全 | 久久网站免费看 | 久久久精品欧美 | 那个网站可以看毛片 | 岳睡了我中文字幕日本 | 久久国产视频网站 | 麻豆免费观看网站 | 日本高清免费aaaaa大片视频 | 精品无码人妻一区二区三区品 | 福利一区二区在线 | 超碰按摩| 最近最新中文字幕 | 免费看又黄又无码的网站 | 亚洲男人天堂2020 | 一区二区三区国产在线 | 欧美日本一区 | 日韩av高清 | 尤物网站在线观看 | 宝贝乖h调教灌尿穿环 | 国产成人精品亚洲日本在线观看 | 日本xxxx裸体xxxx | 日本人性爱视频 | xxx国产| 日韩成人在线观看 | 久久久777| 欧美一区二不卡视频 | 99精品欧美一区二区三区综合在线 | 自拍偷自拍亚洲精品播放 | 久久99国产精品成人 | 一二区免费视频 | 亚洲欧美91 | 亚洲色图20p | 国产精华一区二区三区 | 欧美深性狂猛ⅹxxx深喉 | 精品午夜一区二区三区 | 日韩网站在线播放 | 超碰天天 | 成人一级黄色 | 乌克兰做爰xxxⅹ性视频 | 日韩三级一区二区 | 欧美久久影院 | 男女做爰真人视频直播 | 天天做天天爱夜夜爽 | 日韩午夜视频在线观看 | 国产一区精品在线 | 国产日韩一级 | 国产欧美日本在线 | 性爱免费视频 | 无限资源日本好片 | 欧美高清在线观看 | 久久精品国产亚洲av麻豆 | 91禁在线动漫 | 日本一区二区精品 | 亚洲欧美视频在线观看 | 日韩一区二区在线播放 | 色狠av | 97中文字幕| 黄瓜视频在线观看 | 日本激情电影 | 欧美日韩一区二区三区在线观看 | www.999av| 91亚洲国产成人精品一区二三 |