예제 #1
0
        public AcceptThread(BluetoothConnectionManager manager, bool secure)
        {
            BluetoothServerSocket tmp = null;

            socketType   = secure ? "Secure" : "Insecure";
            this.manager = manager;

            try
            {
                if (secure)
                {
                    tmp = manager.btAdapter.ListenUsingRfcommWithServiceRecord(BluetoothConnectionManager.NAME_SECURE, BluetoothConnectionManager.MY_UUID_SECURE);
                }
                else
                {
                    tmp = manager.btAdapter.ListenUsingInsecureRfcommWithServiceRecord(BluetoothConnectionManager.NAME_INSECURE, BluetoothConnectionManager.MY_UUID_INSECURE);
                }
            }
            catch (Java.IO.IOException e)
            {
                Log.Error(BluetoothConnectionManager.TAG, "listen() failed", e);
            }
            serverSocket  = tmp;
            manager.state = STATE_LISTEN;
        }
예제 #2
0
        public ConnectThread(BluetoothDevice device, BluetoothConnectionManager manager, bool secure)
        {
            this.device  = device;
            this.manager = manager;
            BluetoothSocket tmp = null;

            socketType = secure ? "Secure" : "Insecure";

            try
            {
                if (secure)
                {
                    tmp = device.CreateRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_UUID_SECURE);
                }
                else
                {
                    tmp = device.CreateInsecureRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_UUID_INSECURE);
                }
            }
            catch (Java.IO.IOException e)
            {
                Log.Error(BluetoothConnectionManager.TAG, "create() failed", e);
            }
            socket        = tmp;
            manager.state = STATE_CONNECTING;
        }
예제 #3
0
 public BluetoothConnector(BluetoothConnectionManager man, BluetoothAdapter adapter)
 {
     manager = man;
     if (adapter == null)
     {
         bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
     }
     else
     {
         bluetoothAdapter = adapter;
     }
 }
예제 #4
0
        public ConnectedThread(BluetoothSocket socket, BluetoothConnectionManager manager, string socketType)
        {
            Log.Debug(BluetoothConnectionManager.TAG, $"create ConnectedThread: {socketType}");
            this.socket  = socket;
            this.manager = manager;
            Stream tmpIn  = null;
            Stream tmpOut = null;

            // Get the BluetoothSocket input and output streams
            try
            {
                tmpIn  = socket.InputStream;
                tmpOut = socket.OutputStream;
            }
            catch (Java.IO.IOException e)
            {
                Log.Error(BluetoothConnectionManager.TAG, "temp sockets not created", e);
            }

            inStream      = tmpIn;
            outStream     = tmpOut;
            manager.state = STATE_CONNECTED;
        }