完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,
我试图实现以下场景:使用PSoC 4 BLE外围设备,我更新了隐私示例,并尝试在我的项目中使用它。我用一个公共地址启动外围设备,然后用一个Android智能手机连接到设备上,用固定的密钥配对,绑定设备,然后电话断开。在断开事件之后,我的外围设备的地址变成私有随机可解析,这是我想要的,甚至在没有连接或每次连接/断开事件到达时,即使在几分钟内它也会再次改变。一切都是好的,但我的问题是,在我与智能手机从外围设备断开,地址变为私有之后,我再也无法与我的智能手机重新连接。有没有人知道Android本身可以解决一个地址,或者应用程序应该每次扫描一个设备,并试图解决自己的地址?我想重新连接到一个保税设备没有扫描,但我不知道这是可能的。 如果有人经历过这一点,那么暗示不仅仅是受欢迎的。 谢谢您, 玛丽安 更新信息:我的设备的安全性被设置为模式1,认证加密配对,严格配对,显示为IO能力(即使这不是完全正确的,该设备没有I/O能力,但我想使用一个固定的密钥)。我观察到,由智能手机发起的绑定和密钥交换是可以的。在断开事件和地址变为私有之后,我可以扫描所有设备,找到我需要的定向地址,并且可以在没有任何绑定的情况下连接到它。现在的问题是:在连接和访问一个服务(例如电池级别)之后,我就不能再做任何事情了。如果我尝试阅读比配对WiNoW将再次弹出,无论我进入什么设备断开连接。 更新信息2: 这里是一个新的更新和项目附加。除了处理两个状态机来处理这些绑定和隐私任务之外,我消除了所有代码。请注意在BuffHordL.C中有些代码是注释的,因为它在这个测试项目中没有意义,尤其是通过按下一个按钮来完成绑定的事实,而在项目中它是在重置时完成的。 SIG中的电池级别在读时已经加密和认证。因此,这可能再次触发配对窗口。我不是Android或IOS将如何处理这个问题的专家,但如果我删除加密,认证比一切都好。但我不想修改这个,而且我仍然希望在其他自定义特性上有一些隐私,即使在绑定之后,只有电话才能解决这个地址。 其他信息:与CyPress软件和CyScript在PC上,当重新连接到私人地址,它会弹出配对,但OK后说,完成没有输入引脚完成。 我的另一个问题是:我在外围处理这个过程有什么不对吗?Android上的应用程序有问题吗?我应该投资一些时间吗? 如果有人能给我指出一个更正确的方向,那就太好了。谢谢您! 消息编辑:Marian Emanuel Ionascu 原型A2Test.Cyrj.CaseVo.01.Zip 767 K 以上来自于百度翻译 以下为原文 Hello everybody, I am trying to implement the following scenario: using a PSoC 4 BLE peripheral I updated the privacy example and I am trying to use it in my project. I start the peripheral using a public address; then I connect with an android smartphone to the device, pair it using a fixed passkey, bond the device and afterwards the phone disconnects. After the disconnecting event, the address of my peripheral becomes private random resolvable which is what I want, it even changes ones at a couple of minutes again if there is no connection or every time a connection/disconnection event arrived. Everything is good, but my problem is the following, after I disconnect with the smartphone from the peripheral and the address become private I am not able to reconnect with my smartphone again. Does anyone know if android itself can resolve an address or if the application should scan every time for a device and try to resolve itself the address? I would like to reconnect to a bonded device without scanning, but I do not know if this is possible. If anyone experienced this, a hint is more than welcomed. Thank you, Marian Update info: The security of my device is set to Mode 1, authenticated pairing with encryption, Strict pairing, Display as IO capability(even if this is not entirely correct, the device has no i/o capabilities but I want to use a fixed passkey for this). I observe that the bonding initiated by the smartphone and the exchange of keys is ok. After disconnect event and the address become private I can scan all devices, find the one I need with the orivate address and can connect to it without any bonding. The problem is now the following: after connection and accessing a service(ex. battery level) I am no longer able to do anything. If I try a read than the pairing winodw will pop up again and no matter what I enter the device disconnects. Update info 2: Here is a new Update and the project attached. I eliminate all the code except my two state machines that handle this bonding and privacy tasks. Please note in BLEHandler.c that some code is commented since it makes no sense in this test project, especially the fact that remove bonding is done by pressing a button and in the project it is done at reset. The battery level as it is in SIG has encryption and authenticated on Read. Therefore indeed that may trigger the pairing window again. I am not an expert in how Android or iOS will treat this but if I remove the encryption an authentication than everything is fine. But I do not want to modify this, and I still want some privacy on other custom characteristics, even if after a bonding only that phone can resolve the address. Other Info: with the cypress dongle and cysmart on PC, when reconnect to the private address, it will pop up the pairing but after ok it says paring completed without the entering pin. One of my other questions will be: Is there something wrong in how I handle this process in the peripheral? Is there a problem with the application on android and there I should invest some time? It would be great if someone can point me in a more correct direction. Thank you! Message was edited by: Marian-Emanuel Ionascu |
|
相关推荐
11个回答
|
|
在更新之前:外设应该吐出一个可以通过电话解决的随机地址;我不确定地址解析过程是如何工作的,但是需要被动地或主动地扫描来寻找外围设备的新随机地址对我来说是最有意义的。亲自
更新后:您可以仔细检查访问的服务/属性设置(加密、身份验证等),如果您有需要访问加密的单元,那么在外围设备允许的情况下,您需要通过连接上的配对过程来加密通信。要读或写的贡品。我倾向于认为这是一个可能的问题来源。 如果设备在读取属性后崩溃,那么您可能有运行代码的无效代码来处理破坏设备的属性访问,或者导致虚假行为?由于配对窗口再次弹出,所以我猜想外围设备不是加密的/配对的或是某种东西。当你说“不管怎样”,用一个代码输入成功的配对时,如果不使用正确的数字代码,你将是幸运的: 以上来自于百度翻译 以下为原文 Before update: The peripheral should be spitting out a random address that is resolveable by the phone; I'm not sure how the address resolution process works exactly, but requiring scanning either passively or actively to find the new random address of the peripheral would make the most sense to me personally After update: You could double check the service/attributes settings for access (either encryption, authentication, etc.) If you have the unit requiring encryption for access, then you will need to go through the pairing process on connection to encrypt communication before the peripheral allows attributes to be read or written. I would lean towards that as being a possible problem source.
|
|
|
|
yuhe82 发表于 2018-11-1 07:07 你好, 你上次的更新和我昨晚遇到的一样。回答你可能的问题提示: 1)设备没有崩溃,但它会再次请求密钥。代码运行没有处理读取请求,因为我相信这是自动完成的,也不写和通知在这一刻。 2)外围设备确实有加密,它只有SIG电池服务而无需修改。 3)代码仍然是默认的一个,123456,但外围设备绑定到电话时,它有一个公共地址之后,它不应该要求密钥。我不完全清楚为什么它不会再次接受密钥,它断开连接。请注意,外围设备已检查链路层隐私。 我将更新测试文本和一些信息在一秒钟的主要文本。 玛丽安 以上来自于百度翻译 以下为原文 Hello, Your last update is similar with what I encountered last night. To answer to your possible problem hints: 1) the device is not crashing but it will ask for passkey again. The code running does nothing to handle read request as I believe this is automatically done, nor writes and notification in this moment. 2) the peripheral indeed has encryption, it has only the SIG battery service without modifications. 3) the code is still the default one, 123456, but the peripheral is bonded to the phone when it has a public address after that it should not ask for passkey. I am not completely sure why it will not accept again the passkey and it disconnects. Please note that peripheral has Link layer privacy checked. I will update the main text with the test project and some info in a sec. Marian |
|
|
|
gzjiuwang 发表于 2018-11-1 07:25 嗯,从外观看,问题在于认证/加密握手/步骤。 我不确定它是外围设备还是Android端,但是当你请求读取电池级服务并且需要加密时,手机会得到一个错误/响应,指示它需要与外围设备配对。外围设备应该要么启动配对请求本身,要么等待电话启动配对过程(注意:配对过程与绑定过程不一样)。 一般来说,我相信中央设备是用来请求/确保加密/配对握手启动的,并且外围设备尽可能哑。 一些检查/处理的事件可能在Buffer-Fr.C中有所帮助: CysLyEvtStaysCyBeLyEvtggcCyErrRoRyScCyByLyEvtGAPHSMPPY协商第一个两个是错误事件,第三个是加密通知的更改。并不是说我希望这三个人中的任何一个可以开枪,但这可能对他们有帮助。 最后一个事件是各种原因的通用超时… 为什么在电话试图访问电池服务后设备断开:可能是手机没有正确地重新使用密码密钥,或者外围设备不正确地比较/运行比较代码来检查电话响应和崩溃/断开连接。DS。 此外,检查所有CyLype函数调用的返回值,因为它们基于它们的成功/失败返回代码。如果您试图调用CyByLyGAPAuthReqReq()函数,并且它返回一个失败,那么很明显,加密/认证将失败,并且电话可能由于Android行为响应于故障而断开连接,反之亦然。 以上来自于百度翻译 以下为原文 Hmmm, from the looks of it the issue lies in the authentication/encryption handshake/steps. I'm not sure if it is peripheral or android-side, but when you request read of the battery-level service and it requires encryption, then the phone will get an error/response indicating it needs to pair with the peripheral. The peripheral should then either initiate the pairing request itself, or wait for the phone to initiate the pairing process (note: The pairing process is not the same as the bonding process). Generally I believe the central device is setup to request/ensure encryption/pairing handshake initiation, and the peripheral acts as dumb as possible. Some events to check/handle that might help in the BLEHandler.c:
The last event is a generic timeout for various causes... For why the device disconnects after the phone tries to access the battery service: It could be that either the phone isn't reusing the password key from before correctly, or the peripheral is incorrectly comparing/running comparison code to check the phone response and crashes/disconnects afterwards. Also, check the return value from all of your CyBle_ function calls, as they return codes based on their success/failure. If you are trying to call the CyBle_GappAuthReqReply() function and it returns a failure for example, then obviously the encryption/authentication would fail, and the phone might be disconnecting due to android behavior in response to the failure, or vice versa. |
|
|
|
yuhe82 发表于 2018-11-1 07:39 好啊。我已经按照你的建议去做了。我没有得到CyLay-EvttHiCiStand和CyblieEvtgGATCKErrRoRyrSP是一个客户端事件,而我没有生成它,我的外围设备是一个服务器。每次收到CyByLyEvtggpAuthAuthReq时,我确实收到了CyByLyEvtGAPHSMPPQualdAuthAuthiFig信息,因此我首先在公共地址上获得它,并且当我尝试从绑定后的电池特性读取时。在广告开始后,我也立即收到代码70的CyByLyEvtTimeOutt,但我认为这是一个普通的超时,因为如果我不做任何事情,我就定期得到它。 我也接受了你的建议,我打印了所有的东西,因此我遇到了以下问题:函数CyByLyGAPAuthReqQueRead返回一个错误代码2,它是CyByryRoRoEnguliDyx操作。这很有趣,因为在描述中,这个函数只能返回0,1,3,4和7。 作为错误代码,但每次调用它都返回2。我还打印了CyByLyGAPHAuthAuthIfFoT变量的CyBlyGAPAuthAuthFieldEff推理,它有一个失败的代码1 -gt;它是CyByLyGAPHAuthAuthRoRoR.PaskKyEngyIyA失败。现在我陷入了困境,因为我不知道为什么会出现这种情况,可能是因为我试图通过设置一个固定传递键来模拟显示器,这会导致所有的问题,或者我错误地调用这个函数,等等。 谢谢您! 以上来自于百度翻译 以下为原文 Ok. I have tried what you suggested. I do not get CYBLE_EVT_HCI_STATUS and CYBLE_EVT_GATTC_ERROR_RSP is a client event and I do not have it generated, my peripheral is a server. I do receive the CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO every time I got the CYBLE_EVT_GAP_AUTH_REQ, therefore I got it first with public address and also when I try to read from battery characteristic after bonding. I also receive CYBLE_EVT_TIMEOUT with code 70 immediately after advertising starts but I think this is a general timeout, since I got it regularly if I do not do anything. I also took your advise and I print everything, therefore I got the following problem: the function CyBle_GappAuthReqReply returns an error code 2 which is CYBLE_ERROR_INVALID_OPERATION. This is interesting since in the description this function can only return 0,1,3,4 and 7 as error codes, but it returns 2 every time I call it. I also printed the field CYBLE_GAP_AUTH_FAILED_REASON_T of CYBLE_GAP_AUTH_INFO_T variable and it has a failed code 1 -> which is CYBLE_GAP_AUTH_ERROR_PASSKEY_ENTRY_FAILED. Now I am stuck as I have no idea why this is the case for that field, maybe it is linked to the fact that I try to simulate the display by setting a fix pass key and this cause all the problem, or maybe I call the function wrongly, etc. Thank you! |
|
|
|
gzjiuwang 发表于 2018-11-1 07:49 哎呀! 向前移动: 查看你的FLE组件设置,看起来你有严格的配对。如果手机也没有严格的安全性,这会导致这个问题吗?(基于这里的文档:HTTP://wwwyCysP.COM/FIL/224826/下载寻找短语“严格配对”) 可能是CybulaUnthFor结构使用了错误的值吗?我就是这样称呼个人的: 结果= CyLabyGAPAuthReqQue答复(CyByLyCon Health.BD句柄,和CyByAuthAuthNIFO);/ /接受请求 但这看起来与您的呼叫相同,但我的I/O功能设置为“没有显示,没有输入”,并且严格的配对被关闭(但当我重新连接时,我手动检查配对)。 例子100在100天内的项目可能会帮助你弄清你做错了什么: PSOC-4-BLU/100IX项目在Suth.CyPress半导体公司/PSOC-4-BLE·Github的100100天/Day014i白名单上 PSOC-4-BLU/100IX项目在Suth.CyPress半导体公司/PSOC-4-BLE·GITHUB中的100100天/Day015x键合 PSOC-4-BLU/100IX项目,在100-100天/Day016i认证,在Master·CyPress半导体公司/PSOC-4-BLE·GITHUB 从外观上看,白名单/绑定正在正确设置和工作,但是查看他们的身份验证示例,您可能缺少一个或两个步骤来进行身份验证。 以上来自于百度翻译 以下为原文 Yay! Moving onwards: Looking at your BLE component settings, it looks like you have strict pairing on. If the phone is not being strict with the security as well, could that cause the issue? (Based on the documentation here: http://www.cypress.com/file/224826/download look for the phrase "strict pairing") Could it be that the cyBle_authInfo structure is using the wrong values? This is how I'm calling the function personally: result = CyBle_GappAuthReqReply(cyBle_connHandle.bdHandle, &cyBle_authInfo);//Accept request But that looks the same as your call, but I have the I/O functionality set to "No Display, No Input" and strict pairing is turned off (but I manually check pairing when I reconnect). The example 100 projects in 100 days might help you figure out what you are doing wrong: PSoC-4-BLE/100_Projects_in_100_Days/Day014_Whitelist at master · cypresssemiconductorco/PSoC-4-BLE · GitHub PSoC-4-BLE/100_Projects_in_100_Days/Day015_Bonding at master · cypresssemiconductorco/PSoC-4-BLE · GitHub PSoC-4-BLE/100_Projects_in_100_Days/Day016_Authentication at master · cypresssemiconductorco/PSoC-4-BLE · GitHub From the looks of it, the whitelist/bonding is being setup correctly and working, but looking at their Authentication example, you might be missing a step or two for authenticating. |
|
|
|
yuhe82 发表于 2018-11-1 07:57 你好, 严格的配对没有影响行为,我尝试过没有它,但从iPhone 6和7,和Android 5.1的角度来看,这没有任何影响。代码的行为就像严格的配对。我还通过认证示例再次添加,并从那里添加另一个打印和事件,但行为是相同的。与CyPress软件狗的一切都可以,但与iOS或Android,它不是。我需要更多的调查,但在这一刻我无法找到答案。我会跟其他信息,只要我有一些。这是我的最后一个项目,所有的打印和未配对的按钮按下(P2.7,因为我现在在DEV板上测试,而不是在我们的定制板上)。 原型A2Test.Cyrj.CaseVo.01.Zip 791.9 K 以上来自于百度翻译 以下为原文 Hello, The strict paring did not affect the behavior, I tried without it but from an Iphone 6 and 7, and android 5.1 perspectives this does not have any impact. The code just behaves like with strict pairing. I also go again through authentication example and add another prints and events from there but the behavior is the same. With cypress dongle everything is ok but with ios or android it is not. I need to investigate more, but in this moment I am unable to figure it ou. I will come with other info as soon as I have some. This is my last project with all the printing and the unpair at press of a button (P2.7 since I am testing now on the dev board and not on our custom board). |
|
|
|
gzjiuwang 发表于 2018-11-1 08:04 从我所记得的,对iOS和Android有独特的要求。可能是这些要求中的一个导致行为差异(CySmith-Gile并没有非常严格的行为)。 苹果的信息:HTTPS://ExcRe.Apple Android的信息:蓝牙低能Android开发者 Android接口的例子:Android的东西-与蓝牙低能量设备通信 以上来自于百度翻译 以下为原文 There are unique BLE requirements for iOS and Android from what I remember. It could be that one of those requirements is causing the behavioral difference (CySmart Dongle doesn't have very strict behavior). Apple's information: https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf Android's information: Bluetooth Low Energy | Android Developers Android example for interfacing: Android Things - Communicating with Bluetooth Low Energy devices |
|
|
|
yuhe82 发表于 2018-11-1 08:17 谢谢你的帮助。我发现这是一个HTTP://wwwyCysP.COM/FIL/224826/Access,它指向了一个隐私的例子。这个例子似乎很好用iPhone设备,我仍然有麻烦的LeaGigy 4.1设备,但我将分析更多的这一个,希望它能解决这个问题。在分析这份文件后,我会带着其他的发现回来。 以上来自于百度翻译 以下为原文 Thank you for help. I found this AN http://www.cypress.com/file/224826/download which point to an example for privacy. It seems that this example works fine with Iphone devices, I still have trouble with a lecagy 4.1 device but I will analyze more this AN and hopefully it will solve the problem. I will come back with other findings after an analyze of this document. |
|
|
|
gzjiuwang 发表于 2018-11-1 08:27 好吧,如果你发现其他问题,请告诉我。 以上来自于百度翻译 以下为原文 Alright, let me know if you find anything else you have questions on |
|
|
|
这方面的一个小更新: 在我的最后一篇文章中附带的AN确实非常有帮助,并且适应于我的场景,它似乎很好地使用了具有4.2和LE安全性的设备作为安全(模式1级4)。然而,我仍然存在一些问题: 1)当我遇到具有安全模式1级3的设备(通过加密验证)时,我能够按照预期连接和重新连接,但由于验证信息不足,无法执行操作。这很奇怪,但也许我错过了什么。如果我在创建者中设置模式为3级,那么这个问题就解决了。是否有任何方法可以在配对过程中从代码中更新级别,以便保持级别4的级别,并且只有当同级有3级才能降级?我尝试了CyByLyEvtGAPHSMPP.TraceTyAdAuthiFig信息,将CysLuAuthIfO更改为3级,但未成功。 2)将安全设置为3级,我尝试了使用BLE 4的旧设备。在这种情况下,接收到的对等IRK仅为0,因此智能手机无法解析地址,直到未配对为止,我找不到我的外设。有人知道我为什么收到00吗? 测试1:附加代码可以在DEV板上加载成对,并从3级的设备中读取电池的电平,不应该接收电平。 测试2:将创建者的级别设置为模式1级3认证,连接到4个BLE设备(我使用飞利浦智能手机)。一切都好,然后断开。该设备将启动私人广告。电话将无法解析地址。 再次感谢! 原型A2Test.Zip 795.3 K 以上来自于百度翻译 以下为原文 A small update on this: The AN attached on my last post is indeed very helpful and adapting this to my scenario seems to work very good with devices that have 4.2 and LE secure as security(mode 1 level 4). However I still have some problems: 1) when I encounter a device with security mode 1 level 3(authenticated with encryption) I am able to connect and reconnect as expected but I cannot perform operation due to insufficient authenticated information. This is strange but maybe I miss something. If I set the mode to level 3 in the creator then this problem is resolved. Is there any way I can update the level from code during a pairing in order to keep the level on level 4 and only when the peer have level 3 to downgrade? I tried in CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO to changed the cyBle_authInfo to level 3 but unsuccessfully. 2) Setting the security to level 3 I tried a older device with ble 4.0. In this case the peer irk received is only 0's therefore the smartphone is unable to resolve the address and I cannot find my peripheral anymore until unpair. Do someone know why I receive 00? Test for 1: the attach code can be load in the dev board after pair and bond from a device with level 3 read the battery level, it should not receive the level. Test for 2: setting the level in creator to mode 1 level 3 authenticated, connect to a 4.0 ble device(I used a philips smartphone). Everything is ok, then disconnect. The device will start the private advertising. The phone will be unable to resolve the address. Thanks again!
|
|
|
|
gzjiuwang 发表于 2018-11-1 08:57 “3级”和“4级”是两种不同的加密/配对方法,因此它们是不同的选择。如果你使用它,它将不能与另一个工作。 您可能会将安全级别更改为3,但只有当BLE电台不活跃时,我才会猜测。因此,您必须停止活动,更改为3级,重新启动,然后重试与具有3级设置的设备的连接。 以上来自于百度翻译 以下为原文 The "level 3" and the "level 4" are two different encryption/pairing methods, hence why they are different selections. If you use one it will not work with the other afaik. You can probably change the security level to 3, but only if the BLE radio is not active I would guess. So you would have to stop activity, change to level 3, restart, and then retry connection with the device that has level 3 set. |
|
|
|
只有小组成员才能发言,加入小组>>
716个成员聚集在这个小组
加入小组1901 浏览 1 评论
1653 浏览 1 评论
3406 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1568 浏览 6 评论
1380 浏览 1 评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
188浏览 2评论
184浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
324浏览 2评论
352浏览 1评论
63浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-25 09:44 , Processed in 0.815485 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号