完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
由于某种原因,下面的代码不会返回特定的Android设备的预期BLE ID。我已经在Android“状态”屏幕中查看了ID应该是什么:A0:Cb:FD:7B:CA:67,我收到了65∶67∶09:96:B4:95,但似乎在编译期间,它返回的值有时是变化的,我得到63:C9:63:01:EE:5D用于同一个设备。它确实为不同的设备提供了不同的BLE ID,并且它似乎对于每个设备都是静态的。只是不可靠。
使用以下代码: CyByLyEvtggpAPI DeVice连接:/*设备连接*/ /*启用服务器端的通知*/ { 挥发性UIT88T ADDR〔CybulyGAPB-BdAd大小〕; CyBLY-GATCKWRIGEXYMCMDREQUT写服务器; CyBLY-GATHEXELSYCODET GATTALCODE; UtiN 32×T连接件BLYADADR〔2〕; 如果(CyBelyErrrOrthok!= CyByLyGAPGETPEBDADDR(CONANDANLIE.BDHARAD,和CONDATED ADDR) { (不能检索对等地址\rn); } ADDR〔0〕=CelpDeldAdD.BDADDR〔0〕; ADDR〔1〕=CelpDeldAdD.BDADDR〔1〕; ADDR〔2〕=CelpDeldAdD.BDADDR〔2〕; ADDR〔3〕=CelpDeldAdD.BDADDR〔3〕; ADDR〔4〕=CelpDeldAdD.BDADDR〔4〕; ADDR〔5〕=CelpDeldAdD.BDADDR〔5〕; CeldTyBlay-AdDr〔0〕=ADDR〔5〕& lt;8<ADDR〔4〕; CeldTyBlay-AdDr〔1〕=ADDR〔3〕& lt;& 24;ADDR〔2〕& lt;lt;16〕ADDR〔1〕& lt;8; PrTNF(“对等地址-%02x:%02x:%02x:%02x:%02x:%02xrn”, ADDR〔5〕,ADDR〔4〕, ADDR〔3〕,ADDR〔2〕, ADDR〔1〕,ADDR〔0〕; } 以上来自于百度翻译 以下为原文 For some reason the following code does not return the expected BLE ID from a specific android device. I've checked in the android "status" screen to find out what the ID should be: A0:CB:FD:7B:CA:67 I'm receiving 65:67:09:96:b4:95 though it seems that between compiles sometimes the value it returns changes I just got 63:c9:63:01:ee:5d for the same device. It does provide different BLE IDs for different devices and it does seem to be static per device for some set of time. It's just unreliable. Following code is used: case CYBLE_EVT_GAP_DEVICE_CONNECTED:/*Device connected*/ /* Enable notifications on the server side */ { volatile uint8_t addr[CYBLE_GAP_BD_ADDR_SIZE]; CYBLE_GATTC_WRITE_CMD_REQ_T write_server; CYBLE_GATT_ERR_CODE_T gattErrCode; uint32_t connected_ble_addr[2]; if(CYBLE_ERROR_OK != CyBle_GapGetPeerBdAddr(connHandle.bdHandle, &connected_addr)) { printf("Couldn't retrieve peer address.rn"); } addr[0] = connected_addr.bdAddr[0]; addr[1] = connected_addr.bdAddr[1]; addr[2] = connected_addr.bdAddr[2]; addr[3] = connected_addr.bdAddr[3]; addr[4] = connected_addr.bdAddr[4]; addr[5] = connected_addr.bdAddr[5]; connected_ble_addr[0] = addr[5] << 8 | addr[4]; connected_ble_addr[1] = addr[3] << 24 | addr[2] << 16 | addr[1] << 8 | addr[0]; printf("peer address - %02x:%02x:%02x:%02x:%02x:%02x rn", addr[5], addr[4], addr[3], addr[2], addr[1], addr[0]); } |
|
相关推荐
4个回答
|
|
在代码中是否声明了“CelpTydAdDR”?(我假定是)
为什么不通过“ADDR”数组指针来代替调试目的,以确保值被复制到传递的数组? 否则,在没有看到整个项目的情况下,我唯一能想到的是,你正在传递一个指向地址数组的指针,在那里你想要存储地址,而不是传递指向数组的指针。(指针抽象级别的数目与地址存储位置的不匹配) 以上来自于百度翻译 以下为原文 Is "connected_addr" declared somewhere in code? (I will assume yes) Why not pass the "addr" array pointer instead for debug purposes to ensure the value is being copied to the passed array? Otherwise, the only thing I can think of without seeing the whole project is that you are passing a pointer to a pointer to the address array where you want the address stored rather than passing the pointer to the array. (mismatch in the number of pointer abstraction levels to the address memory location) |
|
|
|
你好,
我认为“问题”是,最新的Android版本和所有的iOS设备在连接到外围设备时使用随机可解析的地址,这就是为什么在连接之间接收不同地址的原因。我自己有一些问题,但反过来,当我尝试使用我的PSoC一个私人的随机可解析的地址。 希望这有帮助。 以上来自于百度翻译 以下为原文 Hello, I think the "problem" is the fact that newest Android versions and all iOS devices use a random resolvable address when they connect to a peripheral device and that is why you receive different addresses between connections. I myself have some problems with this but the other way around, when I try to use for my PSoC a private random resolvable address. Hope this is helpful. |
|
|
|
gzjiuwang 发表于 2018-11-9 08:10 “随机”地址是随机可解析地址的一部分,用于在新的手机上实现隐私(否则,您可以跟踪设备的移动和连接/使用)。 这是一个覆盖随机可解析地址的线程(如果来自iOS/Android的地址是不可解析的,那么您就不能单独处理基于该地址的设备认证)。 白名单,绑定,随机地址 这是一个有类似信息的线程: 具有可解析随机地址的白名单 以上来自于百度翻译 以下为原文 The "random" addresses are part of the random resolveable addresses to implement privacy on newer phones (Otherwise you can track device movement and connections/usage). Here's a thread that covers working with random resolveable addresses (if the address from the iOS/Android is not resolveable, then there is nothing you can do to deal with authenticating the device based on the address alone) Whitelist, bonding, random addresses Here's a thread with some similar information: Whitelisting with resolvable random address |
|
|
|
你好,
请找到一个示例代码示例来获取Android /iOS ID地址。 -吉安 PSOC4BL 697.2 K 以上来自于百度翻译 以下为原文 Hello, Please find a sample code example to get the Android/iOS ID address. -Gyan |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2100 浏览 1 评论
1846 浏览 1 评论
3665 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1782 浏览 6 评论
1532 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
560浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
412浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
433浏览 2评论
379浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
905浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 22:48 , Processed in 0.852411 second(s), Total 54, Slave 48 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号