Example #1
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult res)
        {
            base.OnScanResult(callbackType, res);
            BES.beacon      dad = new BES.beacon();
            BluetoothDevice btd = res.Device;
            ScanRecord      rec = res.ScanRecord;

            string mac = btd.Address;
            string nom = btd.Name;
            string cla = btd.BluetoothClass.ToString();
            string bon = btd.BondState.ToString();
            int    rss = res.Rssi;
            string uui = "";
            int    tax = 3;

            IDictionary <ParcelUuid, byte[]> sda;

            if (nom == "OnyxBeacon")
            {
                sda = rec.ServiceData;
                uui = Retorna_UUID(sda).ToString();
            }
            tax           = rec.TxPowerLevel;
            dad.distancia = Calcula_Dist(rss, tax);
            dad.btd       = btd;
            dad.nome      = nom;
            dad.mac       = mac;
            dad.rssi      = rss;
            dad.taxa      = tax.ToString();
            dad.uuid      = uui;
            dad.classe    = cla;
            dad.bond      = bon;
            bec[mac]      = dad;
        }
 public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
 {
     OnScanResultChanged?.Invoke(this, new BluetoothScanCallbackEventArgs {
         CallbackType = callbackType,
         Result       = result
     });
 }
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            if (iBeaconUtility.IsIBeacon(result.ScanRecord))
            {
                Guid   uuid  = iBeaconUtility.GetUuidFromRecord(result.ScanRecord);
                ushort major = iBeaconUtility.GetMajorFromRecord(result.ScanRecord);
                ushort minor = iBeaconUtility.GetMinorFromRecord(result.ScanRecord);

                string beaconIdentifier = iBeaconEventHolder.GenerateBeaconIdentifyStr(uuid, major, minor);

                if (!BeaconEventHolderDict.ContainsKey(beaconIdentifier))
                {
                    return;
                }

                var eventHolder = BeaconEventHolderDict[beaconIdentifier];
                foreach (var eventDetail in eventHolder.EventList)
                {
                    if (eventDetail.ThresholdRssi < result.Rssi &&
                        eventDetail.LastTriggeredDateTime < DateTime.Now.AddMilliseconds(-1 * eventDetail.EventTriggerIntervalMilliSec))
                    {
                        eventDetail.LastTriggeredDateTime = DateTime.Now;
                        eventDetail.Function();
                    }
                }
            }
        }
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            var devicesDataNormalized = from c in ListOfSavedDevices
                                        where c.Address == result.Device.Address
                                        select new { c.Name, c.Address, c.DeviceType, c.DeviceManufacturer };

            if (!devicesDataNormalized.Any())
            {
                return;
            }
            switch (devicesDataNormalized.FirstOrDefault().DeviceManufacturer)
            {
            case SupportedManufacturers.Medisana:
                result.Device.ConnectGatt(Context, true,
                                          ((GlucoseDeviceActivity)Context).MedisanaGattCallback, BluetoothTransports.Le);
                ((GlucoseDeviceActivity)Context).BluetoothScanner.StopScan(
                    ((GlucoseDeviceActivity)Context).ScanCallback);
                break;

            case SupportedManufacturers.Caresens:
                result.Device.ConnectGatt(Context, true,
                                          ((GlucoseDeviceActivity)Context).GattCallback, BluetoothTransports.Le);
                ((GlucoseDeviceActivity)Context).BluetoothScanner.StopScan(
                    ((GlucoseDeviceActivity)Context).ScanCallback);
                break;
            }
        }
Example #5
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                base.OnScanResult(callbackType, result);

                /* Might want to transition to parsing the API21+ ScanResult, but sort of a pain for now
                 * List<AdvertisementRecord> records = new List<AdvertisementRecord>();
                 * records.Add(new AdvertisementRecord(AdvertisementRecordType.Flags, BitConverter.GetBytes(result.ScanRecord.AdvertiseFlags)));
                 * if (!string.IsNullOrEmpty(result.ScanRecord.DeviceName))
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.CompleteLocalName, Encoding.UTF8.GetBytes(result.ScanRecord.DeviceName)));
                 * }
                 * for (int i = 0; i < result.ScanRecord.ManufacturerSpecificData.Size(); i++)
                 * {
                 *  int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(i);
                 *  var arr = result.ScanRecord.GetManufacturerSpecificData(key);
                 *  byte[] data = new byte[arr.Length + 2];
                 *  BitConverter.GetBytes((ushort)key).CopyTo(data,0);
                 *  arr.CopyTo(data, 2);
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.ManufacturerSpecificData, data));
                 * }
                 *
                 * foreach(var uuid in result.ScanRecord.ServiceUuids)
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.UuidsIncomplete128Bit, uuid.Uuid.));
                 * }
                 *
                 * foreach(var key in result.ScanRecord.ServiceData.Keys)
                 * {
                 *  records.Add(new AdvertisementRecord(AdvertisementRecordType.ServiceData, result.ScanRecord.ServiceData));
                 * }*/

                var device = new Device(result.Device, null, null, result.Rssi, result.ScanRecord.GetBytes());

                //Device device;
                //if (result.ScanRecord.ManufacturerSpecificData.Size() > 0)
                //{
                //    int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(0);
                //    byte[] mdata = result.ScanRecord.GetManufacturerSpecificData(key);
                //    byte[] mdataWithKey = new byte[mdata.Length + 2];
                //    BitConverter.GetBytes((ushort)key).CopyTo(mdataWithKey, 0);
                //    mdata.CopyTo(mdataWithKey, 2);
                //    device = new Device(result.Device, null, null, result.Rssi, mdataWithKey);
                //}
                //else
                //{
                //    device = new Device(result.Device, null, null, result.Rssi, new byte[0]);
                //}

                _adapter.DeviceAdvertised(this, new DeviceDiscoveredEventArgs {
                    Device = device
                });

                if (!_adapter._discoveredDevices.Contains(device))
                {
                    _adapter._discoveredDevices.Add(device);
                    _adapter.DeviceDiscovered(this, new DeviceDiscoveredEventArgs {
                        Device = device
                    });
                }
            }
            public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
            {
                base.OnScanResult(callbackType, result);
                BluetoothDevice device = result.Device;

                Console.WriteLine(result);
            }
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     if (onBluetoothDeviceFound != null)
     {
         onBluetoothDeviceFound(result.Device, result.ScanRecord.GetBytes());
     }
 }
Example #8
0
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     base.OnScanResult(callbackType, result);
     if (result.ScanRecord != null && result.ScanRecord.ServiceData != null)
     {
         service.DotDiscovered(result);
     }
 }
Example #9
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            var device = result.Device;

            //if (device.Type != BluetoothDeviceType.Le) return;
            Console.WriteLine("OnScanResult : " + result.Rssi + " " + device.Name + " " + device + " " + device.Address + " " + device.BondState + " " + device.Type + " " + callbackType + " " + device.PeerReference);
            BluetoothLEManager.Instance.DiscoveredDevices.Add(device.ToString());
        }
Example #10
0
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     base.OnScanResult(callbackType, result);
     if (result != null)
     {
         ProcessResult(result);
     }
 }
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     lock (_scanResults)
     {
         SensusServiceHelper.Get().Logger.Log("Discovered peripheral:  " + result.Device.Address, LoggingLevel.Normal, GetType());
         _scanResults.Add(result);
     }
 }
Example #12
0
        // Overridden from ScanCallback
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            Log.D(this, "Found device");

            if (onDeviceFound != null)
            {
                onDeviceFound(result.Device, result.ScanRecord.GetBytes());
            }
        }
Example #13
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            if (result.Device.Address == "C8:0F:10:33:9D:41")
            {
                MainActivity.Device = result.Device;
                OnSuccess?.Invoke(result.Device);
            }
        }
Example #14
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                var device = result.Device;

                if (_parent.Devices.FirstOrDefault(d => ((DeviceHolder)d).Device.Address == device.Address) == null)
                {
                    _parent.Devices.Add(new DeviceHolder {
                        Device = device
                    });
                }
            }
Example #15
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            String name = (result.Device.Name == null ? "null" : result.Device.Name);

            Console.WriteLine("Lollipop: Device Discovered: " + name);

            if (this.deviceFoundEvent != null)
            {
                this.deviceFoundEvent(result.Device, result.Rssi, null);
            }
        }
Example #16
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            var device = new BLEDevice(result.Device);

            if (_discoveredDevices.All(x => x.Guid != device.Guid))
            {
                _discoveredDevices.Add(device);
            }
        }
		public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
		{
			String name = (result.Device.Name == null ? "null" : result.Device.Name);

			Console.WriteLine("Lollipop: Device Discovered: " + name);

			if (this.deviceFoundEvent != null)
			{
				this.deviceFoundEvent(result.Device, result.Rssi, null);
			}
		}
Example #18
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            if (string.IsNullOrEmpty(result?.Device?.Name) || string.IsNullOrEmpty(result?.Device?.Address))
            {
                return;
            }

            var advertismentData = ScanRecordProcessor.GetAdvertismentData(result.ScanRecord.GetBytes());

            _scanCallback(new BrickController2.PlatformServices.BluetoothLE.ScanResult(result.Device.Name, result.Device.Address, advertismentData));
        }
Example #19
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            var device = result.Device;

            if (!string.IsNullOrEmpty(device.Name))
            {
                //_textView.Text += result.Device.Address + result.Device.Name;
                Console.WriteLine(result.Device.Address + result.Device.Name);
            }
            //base.OnScanResult(callbackType, result);
        }
Example #20
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                System.Diagnostics.Debug.WriteLine("OnScanResult");

                devices.Add(result.Device);
                if (callbackType == ScanCallbackType.AllMatches)
                {
                    handle.Set();
                }

                base.OnScanResult(callbackType, result);
            }
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            if (IsWatchdogDevice(result.Device.Name))
            {
                log.Debug("Watchdog detected.");

                service.ConnectGatt(result.Device);
                service.StopScan();
            }
        }
Example #22
0
 public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
 {
     try
     {
         DeviceDiscovered?.Invoke(result);
         base.OnScanResult(callbackType, result);
     }
     catch (System.Exception ex)
     {
         string title = this.GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name;
         BalizaFacil.App.Instance.UnhandledException(title, ex);
     }
 }
Example #23
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            logger.TraceInformation(String.Format("onScanResult: found {0} - {1}", result.Device.Name, result.Device.Address));
            base.OnScanResult(callbackType, result);

            var resultDevice = new Device(result.Device.Name, result.Device.Address);

            if (!devicesList.Exists(x => x.Address.Equals(resultDevice.Address)))
            {
                devicesList.Add(resultDevice);
                scannerViewModel.Devices.Add(new DeviceViewModel(resultDevice.Name, resultDevice.Address));
            }
        }
Example #24
0
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     System.Diagnostics.Debug.WriteLine("ScanResult");
     if (result != null)
     {
         if (!client.deviceAddresses.Contains(result.Device.Address))
         {
             client.devices.Add(result.Device);
             client.deviceAddresses.Add(result.Device.Address);
         }
         client.callback.onDeviceDiscovered(result.Device.Address.ToUpper(), result.Device.Name, result.Rssi);
     }
 }
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                Debug.WriteLine("OnScanResult");

                var board = new OWBaseBoard()
                {
                    ID               = result.Device.Address,
                    Name             = result.Device.Name ?? "Onewheel",
                    IsAvailable      = true,
                    NativePeripheral = result.Device,
                };

                _owble.BoardDiscovered?.Invoke(board);
            }
Example #26
0
 public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
 {
     try
     {
         if (!_Devices.Any(x => x.Address.Equals(result.Device.Address)))
         {
             _Devices.Add(result.Device);
             DeviceFound?.Invoke(result.Device.Name, result.Device.Address);
         }
     }
     catch (Exception ex)
     {
         BLE_ERR("generic scan result", ex);
     }
 }
Example #27
0
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            var devicesDataNormalized = from c in ListOfSavedDevices
                                        where c.Address == result.Device.Address
                                        select new { c.Name, c.Address, c.DeviceType };

            if (!devicesDataNormalized.Any())
            {
                return;
            }
            result.Device.ConnectGatt(_context, false,
                                      (_context as BloodPressureDeviceActivity)?.GattCallback);
            (_context as BloodPressureDeviceActivity)?.BluetoothScanner.StopScan(
                ((BloodPressureDeviceActivity)_context)?.ScanCallback);
        }
Example #28
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            if (iBeaconDroidUtility.IsIBeacon(result.ScanRecord))
            {
                Guid   uuid  = iBeaconDroidUtility.GetUuidFromRecord(result.ScanRecord);
                ushort major = iBeaconDroidUtility.GetMajorFromRecord(result.ScanRecord);
                ushort minor = iBeaconDroidUtility.GetMinorFromRecord(result.ScanRecord);

                string beaconIdentifier = iBeaconEventHolder.GenerateBeaconIdentifyStr(uuid, major, minor);

                if (!BeaconEventHolderDict.ContainsKey(beaconIdentifier))
                {
                    return;
                }

                iBeaconEventHolder eventHolder = BeaconEventHolderDict[beaconIdentifier];

                if (DetectedBeaconDict.ContainsKey(beaconIdentifier))
                {
                    iBeacon detectedBeaconPrev = DetectedBeaconDict[beaconIdentifier];
                    short?  rssiPrev           = detectedBeaconPrev.Rssi;

                    if (rssiPrev == null || ((short)rssiPrev < result.Rssi))
                    {
                        eventHolder.ibeacon.Rssi             = (short)result.Rssi;
                        DetectedBeaconDict[beaconIdentifier] = eventHolder.ibeacon;
                    }
                }
                else
                {
                    eventHolder.ibeacon.Rssi    = (short)result.Rssi;
                    eventHolder.ibeacon.TxPower = iBeaconDroidUtility.GetTxPowerFromRecord(result.ScanRecord);
                    DetectedBeaconDict.Add(beaconIdentifier, eventHolder.ibeacon);
                }

                foreach (var eventDetail in eventHolder.EventList)
                {
                    if (eventDetail.ThresholdRssi < result.Rssi &&
                        eventDetail.LastTriggeredDateTime < DateTime.Now.AddMilliseconds(-1 * eventDetail.EventTriggerIntervalMilliSec))
                    {
                        eventDetail.LastTriggeredDateTime = DateTime.Now;
                        eventDetail.Function();
                    }
                }
            }
        }
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);
            var device = new Device(result.Device, null, null, result.Rssi);

            if (result.ScanRecord != null)
            {
                device.AdvertismentData = ProcessData(result.ScanRecord);
                if (result.ScanRecord.ServiceUuids != null)
                {
                    device.AdvertisedServiceUuids = result.ScanRecord.ServiceUuids.Select(x => Guid.Parse(x.Uuid.ToString())).ToList();
                }
            }
            var eventArgs = new DeviceDiscoveredEventArgs(device);

            DeviceDiscovered?.Invoke(this, eventArgs);
        }
Example #30
0
        public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
        {
            base.OnScanResult(callbackType, result);

            if (result == null ||
                result.Device == null)
            {
                return;
            }
            Log.Info(TAG, $"AppScanCallBack " +
                     $" Address ({result.Device.Address})" +
                     $" DeviceBoundState({result.Device.BondState})" +
                     $" DeviceClass({result.Device.BluetoothClass.DeviceClass})" +
                     $" DeviceName({result.Device.Name})" +
                     $" DeviceType({result.Device.Type})" +
                     $" AdvertisingId({result.AdvertisingSid})" +
                     $" Rssi({result.Rssi})");
        }
Example #31
0
        /// <summary>
        /// Process the discovery of a device during the scan.
        /// </summary>
        /// <param name="callbackType">ScanCallbackType.</param>
        /// <param name="result">The ScanResult containing device information.</param>
        public override void OnScanResult([GeneratedEnum] ScanCallbackType callbackType, ScanResult result)
        {
            switch (callbackType)
            {
            case ScanCallbackType.AllMatches:
                break;

            case ScanCallbackType.FirstMatch:
                break;

            case ScanCallbackType.MatchLost:
                break;

            default:
                break;
            }
            DeviceResult(result);
        }
 public override void OnScanResult(ScanCallbackType callbackType, Android.Bluetooth.LE.ScanResult result)
 {
     action(result);
 }
Example #33
0
            public override void OnScanResult(ScanCallbackType callbackType, ScanResult result)
            {
                base.OnScanResult(callbackType, result);

                /* Might want to transition to parsing the API21+ ScanResult, but sort of a pain for now 
                List<AdvertisementRecord> records = new List<AdvertisementRecord>();
                records.Add(new AdvertisementRecord(AdvertisementRecordType.Flags, BitConverter.GetBytes(result.ScanRecord.AdvertiseFlags)));
                if (!string.IsNullOrEmpty(result.ScanRecord.DeviceName))
                {
                    records.Add(new AdvertisementRecord(AdvertisementRecordType.CompleteLocalName, Encoding.UTF8.GetBytes(result.ScanRecord.DeviceName)));
                }
                for (int i = 0; i < result.ScanRecord.ManufacturerSpecificData.Size(); i++)
                {
                    int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(i);
                    var arr = result.ScanRecord.GetManufacturerSpecificData(key);
                    byte[] data = new byte[arr.Length + 2];
                    BitConverter.GetBytes((ushort)key).CopyTo(data,0);
                    arr.CopyTo(data, 2);
                    records.Add(new AdvertisementRecord(AdvertisementRecordType.ManufacturerSpecificData, data));
                }

                foreach(var uuid in result.ScanRecord.ServiceUuids)
                {
                    records.Add(new AdvertisementRecord(AdvertisementRecordType.UuidsIncomplete128Bit, uuid.Uuid.));
                }

                foreach(var key in result.ScanRecord.ServiceData.Keys)
                {
                    records.Add(new AdvertisementRecord(AdvertisementRecordType.ServiceData, result.ScanRecord.ServiceData));
                }*/

                var device = new Device(result.Device, null, null, result.Rssi, result.ScanRecord.GetBytes());

                //Device device;
                //if (result.ScanRecord.ManufacturerSpecificData.Size() > 0)
                //{
                //    int key = result.ScanRecord.ManufacturerSpecificData.KeyAt(0);
                //    byte[] mdata = result.ScanRecord.GetManufacturerSpecificData(key);
                //    byte[] mdataWithKey = new byte[mdata.Length + 2];
                //    BitConverter.GetBytes((ushort)key).CopyTo(mdataWithKey, 0);
                //    mdata.CopyTo(mdataWithKey, 2);
                //    device = new Device(result.Device, null, null, result.Rssi, mdataWithKey);
                //}
                //else
                //{
                //    device = new Device(result.Device, null, null, result.Rssi, new byte[0]);
                //}

                _adapter.DeviceAdvertised(this, new DeviceDiscoveredEventArgs { Device = device });

                if (!_adapter._discoveredDevices.Contains(device))
                {
                    _adapter._discoveredDevices.Add(device);
                    _adapter.DeviceDiscovered(this, new DeviceDiscoveredEventArgs { Device = device });
                }
            }