Exemplo n.º 1
0
        private void conexion()
        {
            var connectionInfo = new MposConnectionInformation();

            connectionInfo.BluetoohDeviceId = "SPP-R320";
            connectionInfo.MacAddress       = TextAddress.Text;
            connectionInfo.IntefaceType     = MPosInterfaceType.MPOS_INTERFACE_BLUETOOTH;
            _connectionInfo = connectionInfo;

            //if (connectionInfo != null)
            //{
            //

            //    switch (_connectionInfo.IntefaceType)
            //    {
            //        case MPosInterfaceType.MPOS_INTERFACE_BLUETOOTH:
            //        case MPosInterfaceType.MPOS_INTERFACE_WIFI:
            //        case MPosInterfaceType.MPOS_INTERFACE_ETHERNET:
            //            TextAddress.Text = connectionInfo.Address;
            //            btnOpenService.IsEnabled = true;
            //            break;
            //        default:
            //            return;
            //    }
            //}
        }
Exemplo n.º 2
0
        private void conexion()
        {
            var connectionInfo = new MposConnectionInformation();

            connectionInfo.BluetoohDeviceId = "SPP-R310";
            connectionInfo.MacAddress       = "74:F0:7D:E6:B6:38";
            connectionInfo.IntefaceType     = MPosInterfaceType.MPOS_INTERFACE_BLUETOOTH;
            _connectionInfo = connectionInfo;
        }
Exemplo n.º 3
0
        async Task <MPosControllerPrinter> OpenPrinterService(MposConnectionInformation connectionInfo)
        {
            if (connectionInfo == null)
            {
                return(null);
            }

            if (_printer != null)
            {
                return(_printer);
            }

            btnOpenService.IsEnabled = false;

            _printer = MPosDeviceFactory.Current.createDevice(MPosDeviceType.MPOS_DEVICE_PRINTER) as MPosControllerPrinter;

            switch (connectionInfo.IntefaceType)
            {
            case MPosInterfaceType.MPOS_INTERFACE_BLUETOOTH:
            case MPosInterfaceType.MPOS_INTERFACE_WIFI:
            case MPosInterfaceType.MPOS_INTERFACE_ETHERNET:
                _printer.selectInterface((int)connectionInfo.IntefaceType, connectionInfo.Address);
                _printer.selectCommandMode((int)MPosCommandMode.MPOS_COMMAND_MODE_BYPASS);
                break;

            default:
                await DisplayAlert("Connection Fail", "Not Supported Interface", "OK");

                return(null);
            }

            await _printSemaphore.WaitAsync();

            try
            {
                var result = await _printer.openService();

                if (result != (int)MPosResult.MPOS_SUCCESS)
                {
                    _printer = null;
                    await DisplayAlert("Connection Fail", "openService failed. (" + result.ToString() + ")", "OK");
                }
            }
            finally
            {
                _printSemaphore.Release();
            }

            return(_printer);
        }