private async Task SearchBluetooth() { if (!(string.IsNullOrWhiteSpace(Storage.Address))) { bluetooth.CloseConnection(); Storage.Address = ""; //Storage.Car = null; //FlowManager.Instance.Reset(); } bluetooth.bluetoothActivate(); var waitingView = new WaitingSensorConnectionView(); waitingView.Cancelled += () => { BaseContentPage.Instance.PopModal(); }; BaseContentPage.Instance.PushModal(waitingView); bluetooth.DeviceDiscovered += OnDeviceDiscovered; //bluetooth.StartDiscoverDevices(); var ble = CrossBluetoothLE.Current; adapter = CrossBluetoothLE.Current.Adapter; adapter.ScanMode = Plugin.BLE.Abstractions.Contracts.ScanMode.LowLatency; adapter.DeviceDiscovered += Adapter_DeviceDiscovered; await adapter.StartScanningForDevicesAsync(); }
private void SearchQRCode() { ScanningView scanner = new ScanningView(); scanner.Scanned += (result) => { storage.Address = result; Device.BeginInvokeOnMainThread(() => { try { BaseContentPage.Instance.PopView(); var waitingView = new WaitingSensorConnectionView(); waitingView.Cancelled += BaseContentPage.Instance.PopModal; BaseContentPage.Instance.PushModal(waitingView); Sensor.Instance.StatusChanged += OnSensorStatusChangedQRCode; FlowManager.Instance.ConnectToSensor(); } catch (System.Exception ex) { string title = this.GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name; BalizaFacil.App.Instance.UnhandledException(title, ex); } }); }; BaseContentPage.Instance.PushView(scanner); }