There are currently two callback functions defined, one for button press callback, and another universal callback for all other requirements. The universal callback uses DeviceState to determine which action to take. For IP connected devices, the last parameter is provided for instance where multiple IP connected devices may be sending data back to this callback.
private void MessageCallBack(
IDTechSDK.IDT_DEVICE_Types type, DeviceState state, byte[] data, IDTTransactionData cardData, EMV_Callback emvCallback, RETURN_CODE transactionResultCode,
string IP)
{
switch (state)
{
case DeviceState.ToConnect:
break;
case DeviceState.DefaultDeviceTypeChange:
break;
case DeviceState.Connected:
break;
case DeviceState.Disconnected:
break;
case DeviceState.ConnectionFailed:
break;
case DeviceState.TransactionData:
break;
case DeviceState.DataReceived:
break;
case DeviceState.DataSent:
break;
case DeviceState.CommandTimeout:
break;
case DeviceState.ToSwipe:
break;
case DeviceState.MSRDecodeError:
break;
case DeviceState.ToTap:
break;
case DeviceState.SwipeTimeout:
break;
case DeviceState.TransactionCancelled:
break;
case DeviceState.DeviceTimeout:
SetOutputText("Callback:DeviceTimeout\n");
break;
case DeviceState.TransactionFailed:
break;
case DeviceState.EMVCallback:
SetOutputText("EMV CAllback\n");
break;
case DeviceState.PINpadKeypress:
SetOutputText("PINPad Key was pressed\n");
break;
case DeviceState.PINTimeout:
SetOutputText("PINPad Timeout\n");
break;
case DeviceState.MenuTimeout:
SetOutputText("Menu Entry Timeout\n");
break;
case DeviceState.TransactionIdle:
SetOutputText("Ready For Transaction\n");
break;
case DeviceState.Signature:
SetOutputText("Signature Captured\n");
break;
case DeviceState.FirmwareUpdate:
SetOutputText("firmware update\n");
break;
case DeviceState.FileTransfer:
SetOutputText("File Transfer\n");
break;
case DeviceState.ConfigurationGroup:
SetOutputText("Config Group\n");
break;
case DeviceState.InvalidInterface:
SetOutputText("Invalid Interface\n");
break;
case DeviceState.FunctionKey:
SetOutputText("Function Key Pressed\n");
break;
case DeviceState.PINFail:
SetOutputText("PIN Fail\n");
break;
case DeviceState.SocketEstablished:
SetOutputText("Socket connection established to: " + IP + " \r\n");
break;
case DeviceState.SocketFailed:
SetOutputText("Socket connection failed to: " + IP + " \r\n");
break;
case DeviceState.ButtonEvent:
SetOutputText("Screen ID: " + screenID.ToString() + "\r\n");
SetOutputText("Button ID: " + ID.ToString() + "\r\n");
break;
default:
break;
}
}
When lcd_addButton is executed, a buttonCallback can be passed that will report all press events for that button. If buttonCallback is set to NULL, then all press events will be returned to the main callback as a DeviceState.ButtonEvent. The buttonCallback has the following signature, passing back the device type, the screen, the button ID, and the device IP address:
private void ButtonCallback(IDT_DEVICE_Types sender, uInt16 screenID, uInt16 itemID, string IP)
{
SetOutputText("BUTTON CALLBACK, IP : " + IP + "\n");
SetOutputText("Button Pressed, Screen ID: " + screenID.ToString() + "\n");
SetOutputText("Button Pressed, Button ID: " + itemID.ToString() + "\n");
}
For the universal callback, there is an OPTIONAL parameter to associate that callback with just a single IP address.
Setting button callback is established during lcd_addButton, in addition, there is another method to set the callback of any existing button.