private void Probe_DataChanged(object sender, GenericEventArgs <float> e)
        {
            var data = e.Data.ToString();

            ProbePublisher?.Publish(HelenApi.CreateDataMessage(Settings.ApiId, data));
            ConsoleExtensions.WriteDebugLocation(data, 0);
            Messenger.PrintDebugInfo();
        }
 public void Connect()
 {
     if (!IsConnected && !connectInProgress)
     {
         Task.Run(() =>
         {
             connectInProgress = true;
             try
             {
                 Client.Connect(Guid.ToString());
             }
             catch (Exception)
             {
                 ConsoleExtensions.WriteDebugLocation($"Connected to broker: failed", 1);
             }
             finally
             {
                 connectInProgress = false;
                 OnConnectionStatusChanged();
             }
         });
     }
 }
 public void PrintDebugInfo()
 {
     ConsoleExtensions.WriteDebugLocation($"Connected to broker: {IsConnected}", 1);
 }
        private static bool HandleInput(AppSettings settings, SensorManager manager)
        {
            string input = Console.ReadLine();

            if (input.Equals("exit", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }
            else if (input.Equals("help", StringComparison.InvariantCultureIgnoreCase))
            {
                PrintOptions(settings);
            }
            else if (input.Equals("clear", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.Clear();
            }
            else if (input.Equals("reset", StringComparison.InvariantCultureIgnoreCase))
            {
                ConsoleExtensions.WriteLine("Please confirm this action by typing 'yes please'");
                if (Console.ReadLine() == "yes please")
                {
                    settings.ResetToDefaults();
                    manager.UpdateFromSettings(settings);
                    settings.SaveSettings();
                }
            }
            else if (input.StartsWith("msg: "))
            {
                var msg = input.Substring(4).Trim();
                manager.ProbePublisher.Publish(msg);
            }
            else if (input.Equals("stop", StringComparison.InvariantCultureIgnoreCase))
            {
                manager.Probe.Stop();
                ConsoleExtensions.WriteDebugLocation("       ", 0);
            }
            else if (input.Equals("start", StringComparison.InvariantCultureIgnoreCase))
            {
                manager.Probe.Start();
            }
            else if (input.Equals("list probes", StringComparison.InvariantCultureIgnoreCase) && manager.Probe is Probes.LinuxTempProbe)
            {
                var lprobe = manager.Probe as Probes.LinuxTempProbe;
                foreach (var name in lprobe.GetOneWireDeviceNames())
                {
                    ConsoleExtensions.WriteLine("  " + name);
                }
            }
            else
            {
                if (ReadProperty(settings, input))
                {
                    manager.UpdateFromSettings(settings);
                    settings.SaveSettings();
                }
                else
                {
                    ConsoleExtensions.WriteLine("Unrecognized command");
                }
            }
            return(true);
        }