# Important Information About Bluetooth LE

## Important Information About Bluetooth LE

* When calling functions startScanningForPeripherals or openDevice, the application should make sure bleReaderStateUpdated has received a device status and that the most recent status was OK , otherwise the device will not be able to connect, and iOS will not throw any error if Bluetooth is not ready.
* Starting in iOS 13, app projects must specify the Privacy Usage Description for Bluetooth by NSBluetoothAlwaysUsageDescription in the info.plist file. file. Accessing Core Bluetooth without the usage descriptions will cause a runtime crash. For backward compatibility with older versions of iOS, define NSBluetoothAlwaysUsageDescription as well.

<figure><img src="/files/P28CnOuNoB5WTjxt0Hcy" alt=""><figcaption></figcaption></figure>

* Make sure device is in pairing mode. If not, press and hold the button for 3 seconds until the blue light blinks, and then release the button.&#x20;
* Set device type and connection type.

```
self.lib.setConnectionType(UInt(BLE_EMV)) 
self.lib.setDeviceType(UInt32(MAGTEKEDYNAMO))
```

* Wait for callback bleReaderStateUpdated(), and then call startScanningForPeripheral().

<pre><code>func bleReaderStateUpdated(_ state: MTSCRABLEState) { 
        print("readerStateUpdated - ", state)

        if (state == 0) {
                // dispatch in main queue is very important
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.1,
execute: {
                        self.lib.startScanningForPeripherals()
                })
<strong>        }
</strong>}

</code></pre>

* Wait for onDeviceList() callback. Here you can call getDiscoveredPeripherals().

```
func onDeviceList(_ instance: Any!, connectionType: UInt, deviceList: 
[Any]!) {
        let devices = deviceList as! [MTDeviceInfo] 
        devList.removeAll()

        let peripherals = self.lib.getDiscoveredPeripherals() 
        print(peripherals as Any)
        ...
}

```

* Select the device in the list.
* Open the device you want to connect.

```
lib.stopScanningForPeripherals()

lib.setAddress(devList[selected].address) 
lib.openDevice()
```

* &#x20;Library will pair the device. After inputting passcode, device is ready to use.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.magtek.com/hardware/card-readers/magnetic-stripe-readers/idynamo-5-gen-iii/documentation/developers-manuals/secure-card-reader-authenticators-sdk-programmers-manual-ios/important-information-about-bluetooth-le.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
