> For the complete documentation index, see [llms.txt](https://developer.magtek.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/ios/coreapi.md).

# CoreAPI

&#x20;

## CoreAPI <a href="#id-3_coreapi" id="id-3_coreapi"></a>

Use the CoreAPI to create an IDevice. IDevice, which is the bases for the MagTek Universal SDK.

If accessing a device specific API outside of MagTek Universal SDK, use the various functions in this section to create an instance of that device’s API. Once a device specific API is referenced, the associated library will need to be added into the application’s development project.

## createCMSDevice

This function creates an instance of a CMS type of device.

The API’s of MagTek Universal SDK do not apply. See *D998200160 MagTek Common Message Structure (MTCMS)* for the MTCMS API.

```java
MTDevice CoreAPI.createCMSDevice(Context context, Handler handler);
```

Return Value:

Returns an MTDevice

## createDevice

This function creates an instance of IDevice. All API’s of MagTek Universal SDK can but utilized from.

{% code overflow="wrap" %}

```java
IDevice CoreAPI.createDevice( 
    DeviceType deviceType, 
    ConnectionType connectionType, 
    string address,
    string model, 
    string name, 
    string serial,
    CertificateInfo certificateInfo = null);
```

{% endcode %}

**Parameter**

<table data-header-hidden><thead><tr><th width="167.79998779296875" 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">deviceType</td><td valign="top">Enumerated device type.</td></tr><tr><td valign="top">connectionType</td><td valign="top">Enumerated connection type.</td></tr><tr><td valign="top"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>address</p></td><td valign="top"><p>Address for the device.</p><p> </p><p>For USB devices, address may be an empty string when only one device is attached. Otherwise, address should be in the form:</p><p>USB://DEVICESERIALNUMBER</p><p>for example, USB://99261829170E0810</p><p> </p><p>For Ethernet devices, address should be in the form:</p><p>IP://IP-Address:PORT</p><p>for example, IP://10.57.10.180:26</p><p> </p><p>For Wireless DynaPro Go devices, address should be in the form: TLS12://TLSDEVICESERIALNUMBER TLS12TRUST://TLSDEVICESERIALNUMBER</p><p>for example, TLS12://TLS99261829170E0810 TLS12TRUST://TLS99261829170E0810</p><p> </p><p>For Bluetooth LE devices, address should be in the form:</p><p>BLEEMV://DEVICENAME</p><p>for example, BLEEMV://DynaPro Go-EB66</p><p>For WebSocket or Secure WebSocket devices, address should be in the form:</p><p>ws://IP-Address or DEVICEADDRESS wss://IP-Address or DEVICEADDRESS</p><p>for example, ws://10.57.10.1 or ws://b512345.magtek.com wss://192.168.1.150 or wss://b512345.magtek.com</p><p>The client private key certificate (client.p12) must be accessible to the custom software that makes a secure WebSocket (wss://) connection to the DynaFlex II PED.</p><p> </p><p> </p><p>For Serial devices, address should be in the form: PORT=[PORT],</p><p>BAUDRATE=[BAUDRATE], DATABITS=[DATABITS], PARITY=[PARITY], STOPBITS=[STOPBITS], HANDSHAKE=[HANDSHAKE], STARTINGBYTE=[STARTINGBYTE], ENDINGBYTE=[ENDINGBYTE], CRCMODE=[CRCMODE]</p></td></tr><tr><td valign="top">model</td><td valign="top">Model name for the device.</td></tr><tr><td valign="top">name</td><td valign="top">Unique name for the device to distinguish between multiple devices of the same model.</td></tr><tr><td valign="top">serial</td><td valign="top">Serial number for the device.</td></tr><tr><td valign="top">certificateInfo</td><td valign="top"><p>Certificate information for TLS Trust and WebSocket WSS connection. Optional. See the following for details on installing a certificate chain: <em>D998200550 DynaFlex II PED Using Wireless LAN Guide</em>.</p><p> </p><p>The client private key certificate (client.p12) must be accessible to the custom software that makes a secure WebSocket (wss://) connection to the DynaFlex II PED.</p><p> </p><p>The client.p12 certificate is not needed if the connection type is not secure WebSocket (ws://)</p></td></tr></tbody></table>

**Return Value:**

Returns an IDevice.

#### createMMSDevice

This function creates an instance of an MMS type of device, DynaFlex Family.

```java
MMXDevice CoreAPI.createMMSDevice();
```

Return Value:

Returns an MMXDevice.

## createPPSCRA

This function creates an instance of an MTPPSCRA type of device.

The API’s of MagTek Universal SDK do not apply. See *D998200078 IPAD, DynaPro, DynaPro Go, and DynaPro Mini PIN Encryption Devices Programmer’s Reference* for the MTPPSCRA API.

```java
MTPPSCRA CoreAPI.createPPSCRA();
```

Return Value:

Returns an MTPPSCRA.

## createSCRA

This function creates an instance of a MTSCRA type of device.

The API’s of MagTek Universal SDK do not apply. See *uDynamo, Dynamag, DynaMAX, eDynamo, mDynamo, Insert, DynaWave, iDynamo 6* for the MTSCRA API.

```java
MTSCRA CoreAPI.createPPSCRA(Context context, Handler handler);
```

**Return Value:**

Returns an MTSCRA.

## getDeviceList

This function returns a list of IDevice. IDevice is the base for utilizing the MagTek Universal SDK interface.

```java
List<IDevice> CoreAPI.getDeviceList();
List<IDevice> CoreAPI.getDeviceList(DeviceType deviceType);
List<IDevice> CoreAPI.getDeviceList(List<DeviceType> deviceTypes);
```

<table data-header-hidden><thead><tr><th width="132.066650390625" 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">deviceType</td><td valign="top">An enum for the type of MagTek readers which the SDK will control.</td></tr><tr><td valign="top">deviceTypes</td><td valign="top">An enum list for the type of MagTek readers which the SDK will control.</td></tr></tbody></table>

Return Value:

Returns a list of IDevice.

## getAPIVersion

This function returns the API version.

```java
int CoreAPI.getAPIVersion();
```

**Return Value:**

Returns an integer representing the API version.

## setMQTTBrokerInfo

This function sets the MQTT (Message Queuing Telemetry Transport) broker information. Call prior to device discovery.

```java
void setMQTTBrokerInfo( 
    string uri,
    string username = null, 
    string password = null);
```

<table data-header-hidden><thead><tr><th width="137.39999389648438" 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"><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>uri</p></td><td valign="top"><p>URI included the port. Support URIs:</p><ul><li>TCP: “test.mosquitto.org”, “test.mosquitto.org:1883”, “mqtt://test.mosquitto.org:1883”, “mqtt://broker.emqx.io:1883”</li><li>TCP (Authenticated): “test.mosquitto.org:1884”, “mqtt://test.mosquitto.org:1884”</li><li>TCP (Encrypted): “mqtts://test.mosquitto.org:8886”, “mqtts://broker.emqx.io:8883”</li><li>TCP (Encrypted &#x26; Authenticated): “mqtts://test.mosquitto.org:8885”</li><li>WebSocket: “ws://test.mosquitto.org:8080”, “ws://broker.emqx.io:8083”</li><li>WebSocket (Encrypted): “wss://test.mosquitto.org:8081” , “wss://broker.emqx.io:8084”</li><li>WebSocket (Authenticated): “ws://test.mosquitto.org:8090”</li><li>WebSocket, (Encrypted &#x26; Authenticated): “wss://test.mosquitto.org:8091”</li></ul></td></tr><tr><td valign="top">username</td><td valign="top">Username</td></tr><tr><td valign="top">password</td><td valign="top">Password</td></tr></tbody></table>

Return Value: None

## setMQTTClientID

This function sets the MQTT client ID to establish a connection.

```java
void setMQTTClientID(string clientID);
```

<table data-header-hidden><thead><tr><th width="150.19998168945312" 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">clientID</td><td valign="top">Client ID. If not set, the default value is [HostName]-[RandomUUID]</td></tr></tbody></table>

**Return Value:** None

## setMQTTClientCertificateInfo

This function sets the MQTT certificate information.

```java
void setMQTTClientCertificateInfo(CertificateInfo certificateInfo);
```

**Parameter**

<table data-header-hidden><thead><tr><th width="168.86666870117188" 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"><p> </p><p>certificateInfo</p></td><td valign="top">If client certificate is required when initiating a connection to the MQTT broker, this shall be used to establish the connection. If not set, the default value is NULL.</td></tr></tbody></table>

**Return Value:** None

## setMQTTDeviceDiscoveryTimeout

This function sets the MQTTDeviceDiscoveryTimeout value.

```java
void setMQTTDeviceDiscoveryTimeout(int timeout);
```

<table data-header-hidden><thead><tr><th width="146.46664428710938" 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">timeout</td><td valign="top">Time out in milliseconds. Default value = 5000 if not set. A call to getDeviceList() does not return the list until this time has expired.</td></tr></tbody></table>

**Return Value:** None

## startMQTTDeviceStatusMonitoring

This function sets the MQTT callback interface instance.

After connecting to the MQTT broker, the MQTT Device Status Monitoring subscribes to “\<MQTTSubscribeTopic>/#”. The wildcard “/#” is automatically appended.

Example:

{% code overflow="wrap" %}

```
subscribe topic = “MagTek/Server/DynaFlexIIPED” monitored subscription = “MagTek/Server/DynaFlexIIPED/#”.
```

{% endcode %}

When a device status updates to “connected” or “disconnected”, OnConnected() and OnDisconnected() are invoked respectively.

This method can be called whether or not there is an active connection to an MQTT device.

{% code overflow="wrap" %}

```
void startMQTTDeviceStatusMonitoring( 
    IMQTTDeviceStatusCallback callback);
```

{% endcode %}

Return Value: None

## setMQTTPublishTopic

This function sets the base value for MQTTPublishTopic.. When connected to the MQTT broker, the composed topic is in the format:

```
“<basetopic>/<DeviceID>/MMSMessage”.
```

Example:

* Base topic         = “MagTek/Device/DynaFlexIIPED/”
* Full topic          = “MagTek/Device/DynaFlexIIPED/B51E72D/MMSMessage”

```java
void setMQTTPublishTopic(string topic);
```

<table data-header-hidden><thead><tr><th width="149.6666259765625" 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">topic</td><td valign="top">Base topic for which to publish messages. Full topic is composed by the SDK.</td></tr></tbody></table>

**Return Value:** None

## setMQTTQos

This function sets the MQTTQoS value.

```java
void setMQTTQos(int qos);
```

**Parameter**

<table data-header-hidden><thead><tr><th width="140.5999755859375" 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"><p> </p><p> </p><p>qos</p></td><td valign="top"><p>The quality of service level for publishing messages. Range:</p><p>0 = At most once (default)</p><p>1 = At least once</p><p>2 = Exactly once</p></td></tr></tbody></table>

**Return Value:** None

## setMQTTSubscribeTopic

This function sets the base value for MQTTSubscribeTopic. When connected to the device, the composed topic is in the format:

“\<basetopic>/\<DeviceID>//MMSMessage”.

Example:

* Base topic         = “MagTek/Server/DynaFlexIIPED/”
* Full topic          = “MagTek/Server/DynaFlexIIPED/B51E72D/MMSMessage”

```java
void setMQTTSubscribeTopic(string topic);
```

**Parameter**

<table data-header-hidden><thead><tr><th width="147.53329467773438" 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">topic</td><td valign="top">Base topic for which to subscribe for messages. Full topic is composed by the SDK.</td></tr></tbody></table>

**Return Value:** None

## stopMQTTDeviceStatusMonitoring

This function stops the MQTT device status monitoring process. If called when already running, the process shall be stopped immediately. This method can be called whether or not there is an active connection to an MQTT device.

```java
void stopMQTTDeviceStatusMonitoring();
```

**Return Value:** None

## setSystemStatusCallback

This function sets the SystemStatusCallback global value.

```java
void setSystemStatusCallback(ISystemStatusCallback callback);
```

**Parameter**

<table data-header-hidden><thead><tr><th width="114.99993896484375" 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"><p> </p><p>callback</p></td><td valign="top">Name of a class or structure that implements the ISystemStatusCallback interface event. Call before starting any MQTT communication. When there is an error, the interface’s OnError() event is invoked.</td></tr></tbody></table>

**Return Value:** None


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.magtek.com/sdks-and-tools/universal-sdk-documentation/ios/coreapi.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
