> 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/android/coreapi.md).

# CoreAPI

Use the CoreAPI to create an IDevice. IDevice 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);
```

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `handler` — An instance of `android.os.Handler` to allow SDK access to application-specific message queues.

**Return Value:**

Returns an MTDevice.

## createDevice

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

```java
IDevice CoreAPI.createDevice( 
    Context context, 
    DeviceType deviceType,
    ConnectionType connectionType, 
    String address,
String model, String name, String serial,
CertificateInfo certificateInfo);
```

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `deviceType` — Enumerated device type.
* `connectionType` — Enumerated connection type.
* `address` — Address for the device.

  For USB devices, address may be an empty string when only one device is attached. Otherwise address should be in the form:

  `USB://DEVICESERIALNUMBER`

  for example, `USB://99261829170E0810`

  For Ethernet devices, address should be in the form:

  `IP://IP-Address:PORT`

  for example, `IP://10.57.10.180:26`

  For Wireless devices, address should be in the form:

  `TLS12://TLSDEVICESERIALNUMBER TLS12TRUST://TLSDEVICESERIALNUMBER`

  for example, `TLS12://TLS99261829170E0810 TLS12TRUST://TLS99261829170E0810`

  For Bluetooth LE devices, address should be in the form:

  `BLEEMV://DEVICENAME`

  for example, `BLEEMV://DynaPro Go-EB66`

  For WebSocket or Secure WebSocket devices, address should be in the form:

  `ws://IP-Address`\
  `wss://IP-Address`

  for example:

  `ws://192.168.1.150` or `serialnumber.xx`\
  `wss://serialnumber.xx` (where xx is domain name)

  Place the client private key certificate (`client.p12`) into a folder accessible by the custom software.

  For Serial devices, address should be in the form:

  `PORT=[PORT], BAUDRATE=[BAUDRATE], DATABITS=[DATABITS], PARITY=[PARITY], STOPBITS=[STOPBITS], HANDSHAKE=[HANDSHAKE], STARTINGBYTE=[STARTINGBYTE], ENDINGBYTE=[ENDINGBYTE], CRCMODE=[CRCMODE]`
* `model` — Model name for the device.
* `name` — Unique name for the device to distinguish between multiple devices of the same model.
* `serial` — Serial number for the device.
* `certificateInfo` — The client private key certificate (`client.p12`) into a folder accessible by the custom software. See Certificate Requirements.

**Return Value:**

Returns an IDevice.

## createMMSDevice

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

```java
MMXDevice CoreAPI.createMMSDevice( Context context, IMMXDeviceAdapter deviceAdapter);
```

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `deviceAdapter` — Callback interface for MMS device messages.

**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(Context context, Handler handler);
```

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `handler` — An instance of `android.os.Handler` to allow SDK access to application-specific message queues.

**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 *D99875723 uDynamo, Dynamag, DynaMAX, eDynamo, mDynamo, Insert, DynaWave, iDynamo 6* for the MTSCRA API.

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

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `handler` — An instance of `android.os.Handler` to allow SDK access to application-specific message queues.

**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( 
    Context context,
    IDeviceListCallback deviceListCallback);

List<IDevice> CoreAPI.getDeviceList( 
    Context context,
    DeviceType deviceType, 
    IDeviceListCallback deviceListCallback);

List<IDevice> CoreAPI.getDeviceList( 
    Context context, 
    List<DeviceType> deviceTypes,
    IDeviceListCallback deviceListCallback);
```

**Parameter**

* `context` — An instance of `android.content.Context` to allow SDK access to application-specific resources.
* `deviceType` — An enum for the type of MagTek readers which the SDK will control.
* `deviceTypes` — An enum list for the type of MagTek readers which the SDK will control.
* `deviceListCallback` — Callback interface for SDK to provide a list of device information in the system.

**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);

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

**Parameter**

* `uri` — URI included the port. Support URIs:

  3. TCP: `test.mosquitto.org`, `test.mosquitto.org:1883`, `mqtt://test.mosquitto.org:1883`, `mqtt://broker.emqx.io:1883`
  4. TCP (Authenticated): `test.mosquitto.org:1884`, `mqtt://test.mosquitto.org:1884`
  5. TCP (Encrypted): `mqtts://test.mosquitto.org:8886`, `mqtts://broker.emqx.io:8883`
  6. TCP (Encrypted & Authenticated): `mqtts://test.mosquitto.org:8885`
  7. WebSocket: `ws://test.mosquitto.org:8080`, `ws://broker.emqx.io:8083`
  8. WebSocket (Encrypted): `wss://test.mosquitto.org:8081`, `wss://broker.emqx.io:8084`
  9. WebSocket (Authenticated): `ws://test.mosquitto.org:8090`
  10. WebSocket, (Encrypted & Authenticated):

  `wss://test.mosquitto.org:8091`
* `username` — Username
* `password` — Password

**Return Value:** None

## setMQTTClientID

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

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

**Parameter**

* `clientID` — Client ID. If not set, the default value is `[HostName]-[RandomUUID]`

**Return Value:** None

## setMQTTClientCertificateInfo

This function sets the MQTT certificate information.

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

**Parameter**

* `certificateInfo` — 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.

**Return Value:** None

## setMQTTDeviceDiscoveryTimeout

This function sets the MQTTDeviceDiscoveryTimeout value.

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

**Parameter**

* `timeout` — Time out in milliseconds. Default value = 5000 if not set. A call to getDeviceList() does not return the list until this time has expired.

**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:

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

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.

Devices reporting with `"/Status/connected"` are added to the device list as follows:

```
<DeviceAddress>=“MagTek/Server/DynaFlexIIPED/B51E72D”
```

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

**Parameter**

* `callback` — Name of a class or structure that implements the IMQTTDeviceStatusCallback interface events. Call after calling getDeviceList().

**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);
```

**Parameter**

* `topic` — Base topic for which to publish messages. Full topic is composed by the SDK.

**Return Value:** None

## setMQTTQos

This function sets the MQTTQoS value.

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

**Parameter**

* `qos` — The quality of service level for publishing messages. Range:
  * 0 = At most once (default)
  * 1 = At least once
  * 2 = Exactly once

**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**

* `topic` — Base topic for which to subscribe for messages.

**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**

* `callback` — 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.

**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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
