public void StopScan() { if (this.callbacks != null) { this.manager.Adapter.BluetoothLeScanner?.StopScan(this.callbacks); this.callbacks = null; } if (this.oldCallbacks != null) { this.manager.Adapter.StopLeScan(this.oldCallbacks); this.oldCallbacks = null; } }
protected virtual IObservable <ScanResult> PreLollipopScan(ScanConfig config) => Observable.Create <ScanResult>(ob => { var cb = new PreLollipopScanCallback((native, rssi, sr) => { var ad = new AdvertisementData(sr); if (this.IsFiltered(ad, config)) { var scanResult = this.ToScanResult(native, rssi, ad); ob.OnNext(scanResult); } }); this.manager.Adapter.StartLeScan(cb); return(() => this.manager.Adapter.StopLeScan(cb)); });
public void StopScan() { if (this.callbacks != null) { this.manager.Adapter.BluetoothLeScanner?.StopScan(this.callbacks); this.callbacks = null; } if (this.oldCallbacks != null) { #pragma warning disable CS0618 // Type or member is obsolete this.manager.Adapter.StopLeScan(this.oldCallbacks); #pragma warning restore CS0618 // Type or member is obsolete this.oldCallbacks = null; } }
protected virtual IObservable <ScanResult> PreLollipopScan(ScanConfig config) => Observable.Create <ScanResult>(ob => { this.oldCallbacks = new PreLollipopScanCallback((native, rssi, sr) => { var ad = new AdvertisementData(sr); if (this.IsFiltered(ad, config)) { var scanResult = this.ToScanResult(native, rssi, ad); ob.OnNext(scanResult); } }); #pragma warning disable CS0618 // Type or member is obsolete this.manager.Adapter.StartLeScan(this.oldCallbacks); return(() => this.manager.Adapter.StopLeScan(this.oldCallbacks)); #pragma warning restore CS0618 // Type or member is obsolete });
// TODO: scanfilter? protected virtual void StartPreLollipopScan() { this.oldCallback = new PreLollipopScanCallback(args => this.Scanned?.Invoke(this, args)); this.manager.Adapter.StartLeScan(this.oldCallback); }