private void OnBluetoothStateChanged(BluetoothLowEnergyState newstate) { switch (newstate) { case BluetoothLowEnergyState.POWERED_ON: iBeaconReceiver.Init(); blueOn = true; Debug.Log ("It is on, go searching"); break; case BluetoothLowEnergyState.POWERED_OFF: //iBeaconReceiver.EnableBluetooth(); mybeacons.Clear(); blueOn = false; Debug.Log ("It is off, switch it on"); break; case BluetoothLowEnergyState.UNAUTHORIZED: Debug.Log("User doesn't want this app to use Bluetooth, too bad"); break; case BluetoothLowEnergyState.UNSUPPORTED: Debug.Log ("This device doesn't support Bluetooth Low Energy, we should inform the user"); break; case BluetoothLowEnergyState.UNKNOWN: case BluetoothLowEnergyState.RESETTING: default: Debug.Log ("Nothing to do at the moment"); break; } }
public void CheckForBluetooth(BluetoothLowEnergyState newstate) { switch (newstate) { case BluetoothLowEnergyState.POWERED_ON: bluetoothOn = true; break; case BluetoothLowEnergyState.POWERED_OFF: bluetoothOn = false; break; } }
private void StateChangeEvent(BluetoothLowEnergyState state) { Diglbug.Log("State changed: " + state, PrintStream.SIGNALS); canSend = iBeaconServer.checkTransmissionSupported(); validateReady = state == BluetoothLowEnergyState.POWERED_ON; if (state == BluetoothLowEnergyState.POWERED_OFF) { if (!hasAsked) { Diglbug.Log("BLE OFF. Asking the user to switch it back on.", PrintStream.SIGNALS); BluetoothState.EnableBluetooth(); hasAsked = true; } } if (state != BluetoothLowEnergyState.POWERED_ON && state != BluetoothLowEnergyState.TURNING_ON) { Diglbug.Log("BLE OFF. Asking the user to switch it back on.", PrintStream.SIGNALS); if (validating == false) { StartCoroutine(ValidateBluetooth()); } } }