Exemplo n.º 1
0
        public BluetoothService()
        {
            Bluetooth = CrossBluetoothLE.Current;
            Adapter   = CrossBluetoothLE.Current.Adapter;

            Adapter.DeviceDiscovered += (s, e) =>
            {
                OnDeviceLoaded?.Invoke(this, new BluetoothEventArgs(e.Device));
            };

            Bluetooth.StateChanged += (s, e) =>
            {
                OnStatusChanged?.Invoke(this, new StatusBluetoothEventArgs(e.NewState));
            };
        }
        public async Task LoadDevice(Guid deviceId)
        {
            if (!deviceSetupService.IsNew)
            {
                var device = await GetDevice(deviceId);

                if (device == null)
                {
                    OnDeviceLoadFail.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    deviceSetupService.CurrentDeviceModel = device;
                    OnDeviceLoaded.Invoke(this, new OnDeviceLoadedEventArgs(device));
                }
            }
        }