> 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/hardware/oem-readers-and-components/oem-readers/odynamo/documentation/programmers-manuals/common-message-structure-mtcms-programmers-reference-manual-c++/mtdevice-events.md).

# MTDevice Events

#### OnDeviceList

The library will call this function when device information is available.

```
typedef void ( stdcall * OnDeviceListEvent)( 
void* sender,
MTConnectionType connectionType, 
int deviceCount, 
MTDeviceInformation* deviceList);
```

<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">sender</td><td valign="top">Object representing the publisher of the event.</td></tr><tr><td valign="top">connectionType</td><td valign="top">MTConnectionType value: MTConnectionType.USB, MTConnectionType.IP, MTConnectionType.Serial</td></tr><tr><td valign="top">deviceCount</td><td valign="top">Number of devices in deviceList.</td></tr><tr><td valign="top">deviceList</td><td valign="top">A list of MTDeviceInformation objects.</td></tr></tbody></table>

Return Value: None

#### OnDeviceConnectionStateChanged <a href="#id-7.2_ondeviceconnectionstatechanged" id="id-7.2_ondeviceconnectionstatechanged"></a>

This event occurs when the connection state of the device is changed.

```
typedef void ( stdcall * OnDeviceConnectionStateChangedEvent)( 
void* sender,
MTConnectionState state);
```

<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">sender</td><td valign="top">Object representing the publisher of the event.</td></tr><tr><td valign="top">state</td><td valign="top">MTConnectionState value indicating the state of the device: MTConnectionState.Disconnected MTConnectionState.Connecting MTConnectionState.Error MTConnectionState.Connected MTConnectionState.Disconnecting</td></tr></tbody></table>

#### OnDeviceDataString

This event occurs when a response is received from the device.

```
typedef void ( stdcall * OnDeviceDataStringEvent)( 
void* sender, 
const char* dataString);
```

<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">sender</td><td valign="top">Object representing the publisher of the event.</td></tr><tr><td valign="top">dataString</td><td valign="top">String representing data received.</td></tr></tbody></table>

Return Value: None

#### OnDeviceResponseMessage

This event occurs when a response is received from the device.

```
typedef void ( stdcall * OnDeviceResponseMessageEvent)( void* sender,
const MTCMSMessage* response);
```

<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">sender</td><td valign="top">Object representing the publisher of the event.</td></tr><tr><td valign="top">response</td><td valign="top">MTCMSMessage representing data received.</td></tr></tbody></table>

#### OnDeviceNotificationMessage

This event occurs when a response is received from the device.

```
typedef void ( stdcall * OnDeviceNotificationMessageEvent)( 
void* sender,
const MTCMSMessage* notification);
```

<table data-header-hidden><thead><tr><th width="202.18182373046875" 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">sender</td><td valign="top">Object representing the publisher of the event.</td></tr><tr><td valign="top">notification</td><td valign="top">MTCMSMessage representing data received.</td></tr></tbody></table>


---

# 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/hardware/oem-readers-and-components/oem-readers/odynamo/documentation/programmers-manuals/common-message-structure-mtcms-programmers-reference-manual-c++/mtdevice-events.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.
