Esempio n. 1
0
        public void Reset()
        {
            if (_connectThread != null)
            {
                _connectThread.Cancel();
                _connectThread = null;
            }

            for (int i = 0; i < _writeThread.Count; i++)
            {
                _writeThread [i].Cancel();
                _writeThread.RemoveAt(i);
            }

            for (int i = 0; i < _readThread.Count; i++)
            {
                _readThread [i].Cancel();
                _readThread.RemoveAt(i);
            }

            if (_listenThread != null)
            {
                _listenThread.Cancel();
                _listenThread = null;
            }

            _state = EnConnectionState.STATE_NONE;
        }
Esempio n. 2
0
        public void ConnectAsSlave(BluetoothDevice device)
        {
            //stops all existing thread
            Reset();

            //sets the state to CONNECTING and send message to indicate this change
            _state = EnConnectionState.STATE_CONNECTING;
            this.ObtainMessage((int)EnLocalMessageType.MESSAGE_STATE_CHANGE, (int)EnConnectionState.STATE_CONNECTING, -1).SendToTarget();

            // Start the thread to connect with the given device
            _connectThread = new BTConnectThread(device, MY_UUID);
        }