public static BluetoothState ToBluetoothState(this CBManagerState state)
        {
            switch (state)
            {
            case CBManagerState.Unknown:
                return(BluetoothState.Unknown);

            case CBManagerState.Resetting:
                return(BluetoothState.Unknown);

            case CBManagerState.Unsupported:
                return(BluetoothState.Unavailable);

            case CBManagerState.Unauthorized:
                return(BluetoothState.Unauthorized);

            case CBManagerState.PoweredOff:
                return(BluetoothState.Off);

            case CBManagerState.PoweredOn:
                return(BluetoothState.On);

            default:
                return(BluetoothState.Unknown);
            }
        }
Esempio n. 2
0
        private async Task WaitForState(CBManagerState state, CancellationToken cancellationToken, bool configureAwait = false)
        {
            Trace.Message("Adapter: Waiting for state: " + state);

            while (_centralManager.State != state && !cancellationToken.IsCancellationRequested)
            {
                await Task.Run(() => _stateChanged.WaitOne(2000), cancellationToken).ConfigureAwait(configureAwait);
            }
        }