Ejemplo n.º 1
0
        private void UpdateByConnectionStatusAndPublishEvent(BluetoothLEDevice sender, object args)
        {
            if (sender.ConnectionStatus == BluetoothConnectionStatus.Connected)
            {
                if (!_devices.ContainsKey(sender.DeviceId))
                {
                    _devices[sender.DeviceId] = sender;
                }
                DeviceConnected?.Invoke(this, new BleDeviceEventArgs(sender.ToDomainModel()));
                return;
            }

            if (sender.ConnectionStatus == BluetoothConnectionStatus.Disconnected)
            {
                if (_devices.ContainsKey(sender.DeviceId))
                {
                    var t = ClearDevice(sender.DeviceId).Result;
                }
                OnDeviceDisconnected(new BleDeviceEventArgs(sender.ToDomainModel()));
            }
        }