# MTSCRA Function - 4.1 - 4.10

#### 4.1 getSDKVersion

This function retrieves the SDK revision number.&#x20;

```
(NSString *) getSDKVersion 
```

Parameters: None

Return Value: String containing the SDK revision number.

#### 4.2 startScanningForPeripherals <a href="#id-4.2_startscanningforperipherals" id="id-4.2_startscanningforperipherals"></a>

This function retrieves a list of available Bluetooth LE devices. After calling this function to locate the device you wish to connect to, use setAddress to tell the library which device you want to connect to. Use stopScanningForPeripherals to stop the scan.

```
(void)startScanningForPeripherals
```

Parameters: None

Return Value: An array of peripherals

#### 4.3 stopScanningForPeripherals <a href="#id-4.3_stopscanningforperipherals" id="id-4.3_stopscanningforperipherals"></a>

This function stops the scanning of available Bluetooth LE devices.

```
(void)stopScanningForPeripherals
```

Parameters: None Return Value: None

#### 4.4 setAddress <a href="#id-4.4_setaddress" id="id-4.4_setaddress"></a>

This function sets device’s address for Bluetooth LE devices.&#x20;

```
(void)setAddress:(NSString *)address 
```

&#x20;Parameters:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">address</td><td valign="top">Address of the Bluetooth LE device to communicate with</td></tr></tbody></table>

Return Value: None

#### 4.5 openDevice <a href="#id-4.5_opendevice" id="id-4.5_opendevice"></a>

This function opens a connection to the device.

To use this function to connect to a Bluetooth LE device, the app should follow these steps:

1. Call startScanningForPeripherals to find the device you want to connect to.&#x20;
2. Call setAddress to tell the library which device you want to connect to.
3. Make sure your app’s bleReaderStateUpdated function most recent status is was OK .
4. Call openDevice.

After calling this function, call isDeviceOpened to make sure the device was successfully opened.

```
(BOOL) openDevice
```

Parameters: None&#x20;

Return Value:&#x20;

* YES = Success
* NO = Error

#### 4.6 closeDevice <a href="#id-4.6_closedevice" id="id-4.6_closedevice"></a>

This function closes the connection to the currently opened device. After calling this function, call isDeviceOpened to make sure the device was successfully closed.&#x20;

```
(BOOL) closeDevice
```

Parameters: None&#x20;

Return Value:

* YES = Success
* NO = Error

#### 4.7 isDeviceConnected <a href="#id-4.7_isdeviceconnected" id="id-4.7_isdeviceconnected"></a>

This function reports whether any compatible devices are connected to the host.

```
(BOOL) isDeviceConnected
```

Parameters: None&#x20;

Return Value:

* YES = host is connected to a device&#x20;
* NO = host is not connected to a device

#### 4.8 isDeviceOpened <a href="#id-4.8_isdeviceopened" id="id-4.8_isdeviceopened"></a>

This function retrieves device opened status, which changes on successful completion of a call to **startScanningForPeripherals or closeDevice.**

```
(BOOL) isDeviceOpened
```

Parameters: None&#x20;

Return Value:

* YES = Device is opened
* NO = Device is not opened

#### 4.9 sendCommandToDevice

This function sends a direct command to device. See *MagneSafe V5 Programmer’s Reference (Commands)* for details about available commands and syntax.&#x20;

```
(int) sendCommandToDevice:(NSString *)pData Parameters:
```

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td></tr><tr><td valign="top">pData</td><td valign="top"><p>Command to send to the device. For example, pass command string</p><p>“C10206C20503C30100” to call the Discovery command.</p></td></tr></tbody></table>

Return Value:

* 0 = Success
* 9 = Error
* 15 = Busy

#### 1.10      getResponseData <a href="#id-4.10_getresponsedata" id="id-4.10_getresponsedata"></a>

This function retrieves card data from a string separated by ‘|’ after a cardholder swipes a card. The host software should call it in response to the trackDataReadyNotification callback.

```
(NSString *) getResponseData
```

Parameters: None&#x20;

Return Value:

A null terminated hex string for Card Data, Field separated by ‘|’.NULL value for failed.

Fields:

Device ID, Device Serial Number, Card Swipe Status, CardEncode Type, Track 1 Decode Status, Track 2 Decode Status, Track 3 Decode Status, MagnePrint Status, Track 1 Length, Track 2 Length, Track 3 Length, Masked Track 1 Length, Masked Track 2 Length, Masked Track 3 Length, MagnePrint Length, Card Data, Masked Card Data, DUKPT Session ID, DUKPT Key Serial Number, First Name, Last Name, PAN, Month, Year, Track 1 Data, Track 2 Data, Track 3 Data, Masked Track 1 Data, Masked Track 2 Data, Masked Track 3 Data, MagnePrint Data


---

# 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/mtscra-functions/mtscra-function-4.1-4.10.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.
