How to ask for authentication before connect to devices using bluetooth?

蓝咒 提交于 2019-12-08 01:18:26

问题


I want to make demo application, which contains following features.

  1. search and show device list in my device Bluetooth range.
  2. connect(pair) selected devices.
  3. then share string data.

For doing that I am using core Bluetooth framework(Central and peripheral classes). using that I am able to search devices, connect devices and transfer string data also.

but I am not able to authenticate devices before pairing(when I call connect method it is directly shown me connected status). how is it handled in ios?

also please suggest me I am on the right path or I need to use another library to implement this functionality.


回答1:


For anyone else beating their head against a wall, I have the solution to this issue. It's as simple as setting the AUTHENTICATION required flag for a characteristic on your BLE device. Once that flag is set, you need to attempt a READ from that service / characteristic using the iOS device. Once the read is requested, the BLE device will send back a failure message which then prompts iOS to display the PAIRING / BONDING popup. After that, you're golden.

Here is an example of a Cypress BLE device permission group. The settings are similar for most BLE embedded devices out there.




回答2:


yes it is possible to ask pairing request from BLE device to ios.

I followed below steps to make ios app to ask for pairing.

  1. edited my ble app to return error code 'RBLE_ATT_ERR_INSUFF_AUTHEN' using gatt write response function.
  2. attempted a write from ios app then i got a prompt to enter pairing key.
  3. used the randomly generated pairing key by BLE device to pair.

Paulw11's comment also helped me to solve that problem,

Regards Bharath GK



来源:https://stackoverflow.com/questions/43567569/how-to-ask-for-authentication-before-connect-to-devices-using-bluetooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!