All pages
Powered by GitBook
1 of 1

Loading...

Appendix A Code Examples

Connect to Device

Send Command String to Device

Send Command Bytes to Device

Send MTCMSMessage to Device

Receiving Connection State Updates from Device

Receiving Response Message from Device

Receiving Notification Message from Device

Close Device

openDevice();
const char* dataString = β€œC00101C10100C20114”; 
sendDataString(dataString);
unsigned char* dataBytes =
{0xC0,0x01,0x01,0xC1,0x01,0x00,0xC2,0x01,0x14};

sendDataBytes(dataBytes,9);
MTCMSMessage* message = CreateMTCMSMessage(0x01,0x00,0x14, NULL,0, 
false);
sendMTCMSMessage(message); 
ReleaseMTCMSMessage(message);
void _stdcall OnDeviceConnectionStateChanged(void* sender, 
MTConnectionState state)
{
        switch (state)
        {
        case MTConnectionState::Connected: 
                Log(_T("[Connected]")); 
                break;
        case MTConnectionState::Connecting: 
                Log(_T("[Connecting...]")); 
                break;
        case MTConnectionState::Disconnecting: 
                Log(_T("[Disconnecting...]")); 
                break;
        case MTConnectionState::Disconnected: 
                Log(_T("[Disconnected]")); 
                break;
        }
}
void  stdcall OnDeviceResponseMessage(void* sender, const 
MTCMSMessage* response)
{
    processResponseMessage(response);
}
void  stdcall OnDeviceNotificationMessage(void* sender, const 
MTCMSMessage* notification)
{
    processNotificationMessage(notification);
}
closeDevice();