Пример #1
0
        public static async Task SyncBandWithCloud(CancellationTokenSource token_for_logic)
        {
            IBluetoothService ibs = DependencyService.Get <IBluetoothService>().CreateBluetoothService();
            int bt = ibs.EnableBluetooth();

            if (bt > 0) // if we actually turned on the bluetooth
            {
                await Task.Delay(90000, token_for_logic.Token);
            }
            else // if bluetooth was already turned on
            {
                ibs.DisableBluetooth();
                await Task.Delay(30000, token_for_logic.Token); // wait for 30 seconds

                bt = ibs.EnableBluetooth();
                await Task.Delay(90000, token_for_logic.Token); // wait for 90 seconds
            }
            ibs.DisableBluetooth();
            await Task.Delay(30000, token_for_logic.Token); // wait for 30 seconds

            bt = ibs.EnableBluetooth();                     // enable bluetooth for the second time
            await Task.Delay(90000, token_for_logic.Token); // wait for 90 seconds

            ibs.DisableBluetooth();                         // disable bluetooth at the end
            return;
        }