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; }
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; }
public BluetoothConnector(BluetoothConnectionManager man, BluetoothAdapter adapter) { manager = man; if (adapter == null) { bluetoothAdapter = BluetoothAdapter.DefaultAdapter; } else { bluetoothAdapter = adapter; } }
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; }