简体   繁体   English

如果BLE无法强制断开连接,我们如何认证连接?

[英]If a BLE can't force a disconnect, how can we authenticate a connection?

I believe I read that the peripheral side cannot terminate a connection? 我相信我读到外围设备不能终止连接吗?

terminate a connection CBPeripheralManager side 终止连接CBPeripheralManager端

How then, can we authenticate a connection at the application level? 那么,我们如何才能在应用程序级别验证连接? We are making an iOS app connect to another iOS app, we only want them to connect to each other. 我们正在使一个iOS应用连接到另一个iOS应用,我们只希望它们彼此连接。 After connection they exchange private-key-based challenge/response questions, and a failure should result in a refusal of the connection. 连接后,他们交换基于私钥的质询/响应问题,失败将导致连接被拒绝。 This of course works fine on the central side, if it doesn't get the correct reply it closes the connection. 当然,这在中央方面效果很好,如果没有得到正确的答复,则会关闭连接。 But if the peripheral cant cancel the connection, then how do we prevent a different central from connecting, and staying connected to the peripheral? 但是,如果外围设备无法取消连接,那么我们如何防止其他中央设备连接并保持与外围设备的连接呢?

When a central connects but does not authenticate correctly, do not respond to requests from it. 当中央连接但未正确验证身份时,请勿响应来自中央的请求。 Every CBATTRequest includes the requesting central, and updateValue(_for:onSubscribedCentrals:) lets you control which centrals you respond to. 每个CBATTRequest都包含请求的中心,而updateValue(_for:onSubscribedCentrals:)可让您控制要响应的中心。

If they're not authenticated. 如果未通过身份验证。 Don't talk to them. 不要跟他们说话 Or more correctly, send them .insufficientAuthentication to all their requests. 或更正确地说,将.insufficientAuthentication发送给他们的所有请求。 If they are well behaved, they will disconnect. 如果他们表现良好,他们将断开连接。 If they are badly behaved, there is nothing you can do about that (this is always true; even if you could disconnect them, they could still flood you with connection requests). 如果它们表现不佳,则您无能为力(这始终是事实;即使您断开它们的连接,它们仍然可能向您发送连接请求)。

You cannot force them to disconnect, however. 但是,您不能强迫它们断开连接。 They may be communicating with another app, and you are not allowed to stop that. 他们可能正在与其他应用进行通信,因此您不能停止该应用。 You can only refuse to talk to them yourself or send them errors. 您只能拒绝自己与他们交谈或向他们发送错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM