public AcceptThread(BluetoothService service, Boolean secure)
            {
                BluetoothServerSocket tmp = null;

                _socketType   = secure ? "Secure" : "Insecure";
                this._service = service;

                try
                {
                    if (secure)
                    {
                        tmp = service._btAdapter.ListenUsingRfcommWithServiceRecord(Constants.NAME_SECURE,
                                                                                    Constants.MY_UUID_SECURE);
                    }
                    else
                    {
                        tmp = service._btAdapter.ListenUsingInsecureRfcommWithServiceRecord(Constants.NAME_INSECURE,
                                                                                            Constants.MY_UUID_INSECURE);
                    }
                }
                catch (IOException e)
                {
                    Log.Error(Constants.TAG, "listen() failed", e);
                }
                _serverSocket  = tmp;
                service._state = Constants.STATE_LISTEN;
            }
Exemplo n.º 2
0
        private void InitializeFragments()
        {
            _chatFrag = new ChatFragment(_writeListener, _shared, _localeProvider);

            var languageFrag = new LanguageSelectorFragment(_shared);

            SupportFragmentManager.BeginTransaction()
            .Add(Resource.Id.language_selector_container, languageFrag)
            .Add(Resource.Id.sample_content_fragment, _chatFrag)
            .Commit();

            _handler            = new BluetoothMessageHandler();
            _handler.OnHandled += OnHandled;
            _service            = new BluetoothService.BluetoothService(_handler);

            _chatFrag.OnSend         += OnSendHandler;
            _chatFrag.OnMessageClick += OnClickHandler;
        }
            public ConnectThread(BluetoothDevice device, BluetoothService service, Boolean secure)
            {
                this._device  = device;
                this._service = service;
                BluetoothSocket tmp = null;

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

                try
                {
                    tmp = secure
                        ? device.CreateRfcommSocketToServiceRecord(Constants.MY_UUID_SECURE)
                        : device.CreateInsecureRfcommSocketToServiceRecord(Constants.MY_UUID_INSECURE);
                }
                catch (IOException e)
                {
                    Log.Error(Constants.TAG, "create() failed", e);
                }
                _socket        = tmp;
                service._state = Constants.STATE_CONNECTING;
            }
Exemplo n.º 4
0
            public ConnectedThread(BluetoothSocket socket, BluetoothService service, BluetoothDevice device, String socketType)
            {
                Log.Debug(Constants.TAG, $"create ConnectedThread: {socketType}");
                _socket          = socket;
                _bluetoothDevice = device;
                _service         = service;
                Stream tmpIn  = null;
                Stream tmpOut = null;

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

                _inStream      = tmpIn;
                _outStream     = tmpOut;
                service._state = Constants.STATE_CONNECTED;
            }