public BluetoothController() { mDeviceUUID = Java.Util.UUID.FromString("00001101-0000-1000-8000-00805F9B34FB"); bluetoothAdapter = BluetoothAdapter.DefaultAdapter; BluetoothDevices = new List <BluetoothDevice>(); ICollection <BluetoothDevice> devices = bluetoothAdapter.BondedDevices; foreach (var device in devices) { BluetoothDevices.Add(device); } conncetionState = ConncetionSate.failed; }
public async Task ConnectAsync(int TargetId) { ReconectId = TargetId; socket = BluetoothDevices[TargetId].CreateRfcommSocketToServiceRecord(mDeviceUUID); try { await socket.ConnectAsync(); if (socket != null && socket.IsConnected) { outStream = (OutputStreamInvoker)socket.OutputStream; conncetionState = ConncetionSate.sucsesful; inStream = (InputStreamInvoker)socket.InputStream; } else { conncetionState = ConncetionSate.failed; } } catch (Java.IO.IOException) { conncetionState = ConncetionSate.failed; } }