Esempio n. 1
0
        /// <summary>
        /// Raises the le scan event.
        /// </summary>
        /// <param name="bleDevice">The BLE device that was discovered.</param>
        /// <param name="rssi">Rssi.</param>
        /// <param name="scanRecord">Scan record.</param>
        public void OnLeScan(BluetoothDevice bleDevice, int rssi, byte[] scanRecord)
        {
            var deviceId = Device.DeviceIdFromAddress(bleDevice.Address);

            if (DiscoveredDevices.All(x => x.Id != deviceId))
            {
                var device = new Device(bleDevice, null, null, rssi, scanRecord);
                DiscoveredDevices.Add(device);
                DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device));
            }
        }
Esempio n. 2
0
        private void DiscoveredPeripheral(object sender, CBDiscoveredPeripheralEventArgs e)
        {
            var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier);

            if (DiscoveredDevices.All(x => x.Id != deviceId))
            {
                var device = new Device(e.Peripheral);
                DiscoveredDevices.Add(device);
                DeviceDiscovered(this, new DeviceDiscoveredEventArgs(device));
            }
        }