Can you pair a bluetooth LE device in an iOS app

2020-02-29 04:01发布

问题:

Can you pair a bluetooth LE device in an iOS app, i.e. not via Settings. Trying to make it easier on the user to pair with a specific device.

If so how?

回答1:

You don't pair Bluetooth LE devices through system settings. Generally you don't pair with Bluetooth Low Energy devices at all. The only time that pairing is required is when the device has an attribute that is marked as encryption required - attempting to read this attribute will trigger a pairing process, but before you can read you need to discover and connect to the device.

Discovery and connection is handled by the Core-Bluetooth framework.

The Core Bluetooth Programming Guide goes through the steps required to use a CBCentralManager to discover and connect to a BLE peripheral.



回答2:

According to the BT SIG Security Manager documentation you can pair/Bond ble devices if they respond to the message that is. You can also wait and do it as previously explained from the peripheral side. Some devices like HipKey does this automatically when connecting first time. Look at BTSIG Security Manager specifications. On Android this also works from BT settings menu IF the peripheral supports it.

Bonding and Authenticating are usually confused but om most platforms it means the same.

A good way to try this out is by buying the TI ble development kit. Its cheap. It comes with a USB dongle and SW which can be used to initiate pairing like from the settings menu.

To do it from iOS just connect and read a known encrypted characteristic.

Cases where you want to "pair" (remember a Bond) includes Pulse meters, hearing aid, keyboard and other private units.