public void Disconnect() { Debug.Log("Disconnect"); _peripheralList = null; BluetoothLEHardwareInterface.DisconnectAll(); StateChange(States.Disconnect); }
private void OnApplicationQuit() { BluetoothLEHardwareInterface.StopScan(); BluetoothLEHardwareInterface.DisconnectAll(); BluetoothLEHardwareInterface.DeInitialize(() => { Debug.Log("Bluetooth has shut down on application quit."); }); }
public override void DisconnectDevice() { //need to disconnect and deinitialize and then finish it otherwise it won't be disconnected the right way. BluetoothLEHardwareInterface.DisconnectAll(); ConnectDevice(adressFinal); BluetoothLEHardwareInterface.DeInitialize(() => { }); BluetoothLEHardwareInterface.FinishDeInitialize(); isConnected = false; }
IEnumerator disConnectProcess() { BluetoothLEHardwareInterface.StopScan(); yield return(new WaitForSeconds(0.2f)); BluetoothLEHardwareInterface.DisconnectAll(); yield return(new WaitForSeconds(0.2f)); BluetoothLEHardwareInterface.DeInitialize(() => { SetState(BtStates.None); }); }
public void DisconnectAllDice() { foreach (var die in GetComponentsInChildren <Die>()) { die.Disconnect(); } BluetoothLEHardwareInterface.DisconnectAll(); if (virtualBluetooth != null) { virtualBluetooth.DisconnectAll(); } }
private void ConnectDevice(string addr) { BluetoothLEHardwareInterface.ConnectToPeripheral(addr, (address) => { }, (address, serviceUUID) => { }, (address, serviceUUID, characteristicUUID) => { if (IsEqual(serviceUUID, _serviceUUID)) { _connectedID = address; isConnected = true; if (IsEqual(characteristicUUID, _readCharacteristicUUID)) { _readFound = true; } if (IsEqual(characteristicUUID, _writeCharacteristicUUID)) { _writeFound = true; } adressFinal = addr; Debug.Log("BLE Spiro Connected"); BluetoothLEHardwareInterface.StopScan(); } }, (address) => { // this will get called when the device disconnects // be aware that this will also get called when the disconnect // is called above. both methods get call for the same action // this is for backwards compatibility Debug.Log("Connection Lost"); isConnected = false; //we first need to disconnect and deinitialize before we can connect again to the Air next otherwise we can't reconnect. BluetoothLEHardwareInterface.DisconnectAll(); BluetoothLEHardwareInterface.DeInitialize(() => { }); BluetoothLEHardwareInterface.FinishDeInitialize(); DeviceManager.Instance.MakeSpiroControllerNull(); }); }
private void OnDestroy() { Debug.Log("BluetoothManager - OnDestroy()"); if (Instance == this) { try { BluetoothLEHardwareInterface.StopScan(); BluetoothLEHardwareInterface.DisconnectAll(); BluetoothLEHardwareInterface.DeInitialize(() => { Debug.Log("Bluetooth has shut down on destroy."); }); } catch (Exception e) { Debug.Log("Bluetooth has already shut down: " + e.Message); } } }