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

# CoreAPI

Use the CoreAPI to create an IDevice. IDevice, which is the basis 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 <a href="#id-3.1_createcmsdevice" id="id-3.1_createcmsdevice"></a>

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

The API’s of MagTek Universal SDK do not apply. See <mark style="color:red;">**MagTek Common Message Structure (MTCMS)**</mark> for the MTCMS API.

```
MTDevice CoreAPI.createCMSDevice();
```

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 CoreAPI.createDevice( 
        DeviceType deviceType, 
        ConnectionType connectionType, 
        string address,
        string model, 
        string name, 
        string serial,
        CertificateInfo certificateInfo = null);
```

<table data-header-hidden><thead><tr><th width="187.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">deviceType</td><td valign="top">Enumerated device type.</td></tr><tr><td valign="top">connectionType</td><td valign="top">Enumerated connection type.</td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="155.66668701171875" 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> </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></tbody></table>

<table data-header-hidden><thead><tr><th width="167.66668701171875" 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>certificateInfo</p></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: <mark style="color:red;"><strong>DynaFlex II PED Using Wireless LAN Guide</strong></mark>.</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 <a href="#id-3.3_createmmsdevice" id="id-3.3_createmmsdevice"></a>

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

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

Return Value:

Returns an MMXDevice.

### createPPSCRA <a href="#id-3.4_createppscra" id="id-3.4_createppscra"></a>

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

The API’s of MagTek Universal SDK do not apply. See <mark style="color:red;">**IPAD, DynaPro, DynaPro Go, and DynaPro Mini PIN Encryption Devices Programmer’s Reference**</mark> for the MTPPSCRA API.

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

Return Value:

Returns an MTPPSCRA.

### createSCRA <a href="#id-3.5_createscra" id="id-3.5_createscra"></a>

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

The API’s of MagTek Universal SDK do not apply. See <mark style="color:red;">**uDynamo, Dynamag, DynaMAX, eDynamo, mDynamo, Insert, DynaWave, iDynamo 6**</mark> for the MTSCRA API.

```
MTSCRA CoreAPI.createSCRA();
```

Return Value:

Returns an MTSCRA.

### getDeviceList <a href="#id-3.6_getdevicelist" id="id-3.6_getdevicelist"></a>

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

```
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="176.33331298828125" 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 <a href="#id-3.7_getapiversion" id="id-3.7_getapiversion"></a>

This function returns the API version.

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

Return Value:

Returns an integer representing the API version.

### setMQTTBrokerInfo <a href="#id-3.8_setmqttbrokerinfo" id="id-3.8_setmqttbrokerinfo"></a>

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

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

<table data-header-hidden><thead><tr><th width="149" 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 <a href="#id-3.9_setmqttclientid" id="id-3.9_setmqttclientid"></a>

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

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

<table data-header-hidden><thead><tr><th width="147" 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 <a href="#id-3.10_setmqttclientcertificateinfo" id="id-3.10_setmqttclientcertificateinfo"></a>

This function sets the MQTT certificate information.

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

<table data-header-hidden><thead><tr><th width="179" 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 <a href="#id-3.11_setmqttdevicediscoverytimeout" id="id-3.11_setmqttdevicediscoverytimeout"></a>

This function sets the MQTTDeviceDiscoveryTimeout value.

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

<table data-header-hidden><thead><tr><th width="128.33331298828125" 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 <a href="#id-3.12_startmqttdevicestatusmonitoring" id="id-3.12_startmqttdevicestatusmonitoring"></a>

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.

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

<table data-header-hidden><thead><tr><th width="137" 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 IMQTTDeviceStatusCallback interface events. Call after calling getDeviceList().</td></tr></tbody></table>

Return Value: None

### setMQTTPublishTopic <a href="#id-3.13_setmqttpublishtopic" id="id-3.13_setmqttpublishtopic"></a>

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”

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

<table data-header-hidden><thead><tr><th width="141.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 <a href="#id-3.14_setmqttqos" id="id-3.14_setmqttqos"></a>

This function sets the MQTTQoS value.

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

<table data-header-hidden><thead><tr><th width="122.33334350585938" 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 <a href="#id-3.15_setmqttsubscribetopic" id="id-3.15_setmqttsubscribetopic"></a>

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”

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

<table data-header-hidden><thead><tr><th width="145" 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 <a href="#id-3.16_stopmqttdevicestatusmonitoring" id="id-3.16_stopmqttdevicestatusmonitoring"></a>

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.

```
void stopMQTTDeviceStatusMonitoring();
```

Return Value: None

### setSystemStatusCallback <a href="#id-3.17_setsystemstatuscallback" id="id-3.17_setsystemstatuscallback"></a>

This function sets the SystemStatusCallback global value.

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

<table data-header-hidden><thead><tr><th width="143" 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/.net-windows/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.
