示例#1
0
        public ConnectedThread(BluetoothService service, BluetoothSocket socket)
        {
            this.service = service;
            this.socket  = socket;
            Stream tempIn  = null;
            Stream tempOut = null;

            this.handler = this.service.MessageHandler;

            try
            {
                tempIn = this.socket.InputStream;
            }
            catch (IOException e)
            {
                Logger.Log("Error occurred when creating input stream " + e.Message);
            }

            try
            {
                tempOut = this.socket.OutputStream;
            }
            catch (IOException e)
            {
                Logger.Log("Error occurred when creating output  stream " + e.Message);
            }

            InStream = tempIn;
            InStream.Flush();
            OutStream = tempOut;
            OutStream.Flush();
        }
示例#2
0
        public AcceptThread(BluetoothService service)
        {
            this.service = service;
            BluetoothServerSocket tempSocket = null;

            try
            {
                BluetoothAdapter adapter = this.service.BtAdapter;
                tempSocket = adapter.ListenUsingInsecureRfcommWithServiceRecord(service.BtName, service.MyUUID);
            }
            catch (IOException e)
            {
                Logger.Log("Socket's listen() method failed " + e.Message);
            }

            serverSocket = tempSocket;
        }
示例#3
0
        public ConnectThread(BluetoothService service, BluetoothDevice device)
        {
            this.service = service;
            this.device  = device;
            BtAdapter    = this.service.BtAdapter;

            BluetoothSocket tempSocket = null;

            try
            {
                tempSocket = device.CreateInsecureRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805F9B34FB"));
                //tempSocket = device.CreateRfcommSocketToServiceRecord(service.BtUUID);
            }
            catch (IOException e)
            {
                Logger.Log("Socket's create() method failed " + e.Message);
            }

            socket = tempSocket;
        }