Exemple #1
0
        public IBluetoothSocket Connect(RoomVoiceControl.Bluetooth.BluetoothDevice device)
        {
            IBluetoothSocket socket = null;

            Android.Bluetooth.BluetoothDevice bluetoothDevice = mBluetoothAdapter.GetRemoteDevice(device.Address);
            UserDialogs.Instance.Toast("Connecting to " + bluetoothDevice);

            try
            {
                btSocket = bluetoothDevice.CreateRfcommSocketToServiceRecord(UUID.FromString(MY_UUID));

                btSocket.Connect();

                socket = new AndroidBluetoothSocket()
                {
                    BTSocket = btSocket
                };

                UserDialogs.Instance.Toast("Connected to Bluetooth!");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                try
                {
                    btSocket.Close();
                }
                catch (System.Exception)
                {
                    UserDialogs.Instance.Alert("Connection Error!");
                }
            }

            return(socket);
        }
 internal JicaiQ2ThermalPrinterBluetooth(IBluetoothSocket socket)
 {
     this.socket = socket;
 }