Пример #1
0
        private void ToggleScanning()
        {
            if (IsScanning)
            {
                scanTokenSource.Cancel();
                btn_scan.Text = "Start Scanning";
                IsScanning    = false;

                Log("Scanning stopped. Found " + lv_devices.Items.Count + " devices.");
            }
            else
            {
                if (SelectedDeviceType == "")
                {
                    Log("Please select a Device Type");
                    return;
                }

                Log("Scanning started.");
                IsScanning    = true;
                btn_scan.Text = "Stop Scanning";

                lv_devices.Items.Clear();
                scanTokenSource = new CancellationTokenSource();

                if (SelectedDeviceType == DeviceTypeUtils.GetText(DeviceType.Shelly))
                {
                    Task task = Shelly.Scan(scanTokenSource.Token, NewDeviceFound, ToggleScanning);
                }
                else if (SelectedDeviceType == DeviceTypeUtils.GetText(DeviceType.Tasmota))
                {
                    Task task = Tasmota.Scan(scanTokenSource.Token, NewDeviceFound, ToggleScanning);
                }
            }
        }
Пример #2
0
 public virtual async Task FlashAsync(string fileName, CancellationToken token, Action successCallback, Action <string> errorCallback)
 {
     if (Type == DeviceType.Tasmota)
     {
         await Tasmota.FlashAsync(this, fileName, token, successCallback, errorCallback);
     }
     else if (Type == DeviceType.Shelly)
     {
     }
 }