示例#1
0
        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;
            }
        }
示例#2
0
        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));
        });
示例#3
0
        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;
            }
        }
示例#4
0
        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
        });
示例#5
0
 // TODO: scanfilter?
 protected virtual void StartPreLollipopScan()
 {
     this.oldCallback = new PreLollipopScanCallback(args => this.Scanned?.Invoke(this, args));
     this.manager.Adapter.StartLeScan(this.oldCallback);
 }