Exemple #1
0
        public void Main(Spi spi, SpiPayAtTable pat, Int32 cBTxStatePtr, Int32 cBPairingFlowStatePtr, Int32 cBsecretsPtr, Int32 cBStatusPtr, Int32 cBPayAtTableGetBillDetailsPtr, Int32 cBPayAtTableBillPaymentReceivedPtr)
        {
            _spi = spi; // It is ok to not have the secrets yet to start with.
            _pat = pat;

            ptr             = new IntPtr(cBTxStatePtr);
            callBackTxState = (CBTxFlowStateChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBTxFlowStateChanged));

            ptr = new IntPtr(cBPairingFlowStatePtr);
            callBackPairingFlowState = (CBPairingFlowStateChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPairingFlowStateChanged));

            ptr             = new IntPtr(cBsecretsPtr);
            callBackSecrets = (CBSecretsChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBSecretsChanged));

            ptr            = new IntPtr(cBStatusPtr);
            callBackStatus = (CBSpiStatusChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBSpiStatusChanged));

            ptr = new IntPtr(cBPayAtTableGetBillDetailsPtr);
            callBackPayAtTableGetBillStatus = (CBPayAtTableGetBillStatus)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableGetBillStatus));

            ptr = new IntPtr(cBPayAtTableBillPaymentReceivedPtr);
            callBackPayAtTableBillPaymentReceived = (CBPayAtTableBillPaymentReceived)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableBillPaymentReceived));

            _spi.StatusChanged           += OnSpiStatusChanged;
            _spi.PairingFlowStateChanged += OnPairingFlowStateChanged;
            _spi.SecretsChanged          += OnSecretsChanged;
            _spi.TxFlowStateChanged      += OnTxFlowStateChanged;

            _pat.GetBillStatus       = OnPayAtTableGetBillStatus;
            _pat.BillPaymentReceived = OnPayAtTableBillPaymentReceived;
        }
Exemple #2
0
        public void Main(Spi spi, SpiPayAtTable pat, DelegationPointers delegationPointers)
        {
            _spi = spi; // It is ok to not have the secrets yet to start with.
            _pat = pat;

            ptr = new IntPtr(delegationPointers.CBTransactionStatePtr);
            callBackTransactionState = (CBTransactionFlowStateChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBTransactionFlowStateChanged));

            ptr = new IntPtr(delegationPointers.CBPairingFlowStatePtr);
            callBackPairingFlowState = (CBPairingFlowStateChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPairingFlowStateChanged));

            ptr             = new IntPtr(delegationPointers.CBSecretsPtr);
            callBackSecrets = (CBSecretsChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBSecretsChanged));

            ptr            = new IntPtr(delegationPointers.CBStatusPtr);
            callBackStatus = (CBSpiStatusChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBSpiStatusChanged));

            if (delegationPointers.CBDeviceAddressChangedPtr > 0)
            {
                ptr = new IntPtr(delegationPointers.CBDeviceAddressChangedPtr);
                callBackDeviceAddressStatus = (CBDeviceAddressStatusChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBDeviceAddressStatusChanged));
            }

            #region PayAtTable Delegetions

            ptr = new IntPtr(delegationPointers.CBPayAtTableGetBillDetailsPtr);
            callBackPayAtTableGetBillStatus = (CBPayAtTableGetBillStatus)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableGetBillStatus));

            ptr = new IntPtr(delegationPointers.CBPayAtTableBillPaymentReceivedPtr);
            callBackPayAtTableBillPaymentReceived = (CBPayAtTableBillPaymentReceived)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableBillPaymentReceived));

            ptr = new IntPtr(delegationPointers.CBPayAtTableBillPaymentFlowEndedResponsePtr);
            callBackPayAtTableBillPaymentFlowEndedResponse = (CBPayAtTableBillPaymentFlowEndedResponse)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableBillPaymentFlowEndedResponse));

            ptr = new IntPtr(delegationPointers.CBPayAtTableGetOpenTablesPtr);
            callBackPayAtTableGetOpenTables = (CBPayAtTableGetOpenTables)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPayAtTableGetOpenTables));

            #endregion

            #region Battery and Printing Delegetions

            if (delegationPointers.CBPrintingResponsePtr > 0)
            {
                ptr = new IntPtr(delegationPointers.CBPrintingResponsePtr);
                callBackPrintingResponse = (CBPrintingResponse)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBPrintingResponse));
            }

            if (delegationPointers.CBTerminalStatusResponsePtr > 0)
            {
                ptr = new IntPtr(delegationPointers.CBTerminalStatusResponsePtr);
                callBackTerminalStatusResponse = (CBTerminalStatusResponse)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBTerminalStatusResponse));
            }

            if (delegationPointers.CBTerminalConfigurationResponsePtr > 0)
            {
                ptr = new IntPtr(delegationPointers.CBTerminalConfigurationResponsePtr);
                callBackTerminalConfigurationResponse = (CBTerminalConfigurationResponse)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBTerminalConfigurationResponse));
            }

            if (delegationPointers.CBBatteryLevelChangedPtr > 0)
            {
                ptr = new IntPtr(delegationPointers.CBBatteryLevelChangedPtr);
                callBackBatteryLevelChanged = (CBBatteryLevelChanged)Marshal.GetDelegateForFunctionPointer(ptr, typeof(CBBatteryLevelChanged));
            }

            #endregion

            _spi.StatusChanged           += OnSpiStatusChanged;
            _spi.PairingFlowStateChanged += OnPairingFlowStateChanged;
            _spi.SecretsChanged          += OnSecretsChanged;
            _spi.TxFlowStateChanged      += OnTxFlowStateChanged;
            _spi.DeviceAddressChanged    += OnDeviceAddressStatusChanged;

            _spi.BatteryLevelChanged           = OnBatteryLevelChanged;
            _spi.PrintingResponse              = OnPrintingResponse;
            _spi.TerminalConfigurationResponse = OnTerminalConfigurationResponse;
            _spi.TerminalStatusResponse        = OnTerminalStatusResponse;

            _pat.GetBillStatus        = OnPayAtTableGetBillStatus;
            _pat.BillPaymentReceived  = OnPayAtTableBillPaymentReceived;
            _pat.BillPaymentFlowEnded = OnPayAtTableBillPaymentFlowEnded;
            _pat.GetOpenTables        = OnPayAtTableGetOpenTables;
        }