public void Initialize(string brokerIp, AddToLogDelegate addToLog) { MqttBrokerIp = brokerIp; _hostDevice = DeviceFactory.CreateHostDevice("si7020", "Si7020 on ESP32"); _hostDevice.UpdateNodeInfo("general", "General information and properties", "no-type"); _temperature = _hostDevice.CreateHostNumberProperty(PropertyType.State, "general", "temperature", "Measured temperature", 0.00f, "°C"); _humidity = _hostDevice.CreateHostNumberProperty(PropertyType.State, "general", "humidity", "Measured humidity", 0.00f, "%"); _broker.Initialize(MqttBrokerIp, (severity, message) => addToLog(severity, "Broker:" + message)); _hostDevice.Initialize(_broker, (severity, message) => addToLog(severity, message)); var gettingValues = new Thread(GetTemperatureAndHumidityValues); gettingValues.Start(); }
private void AddToLog(string message) { if (this.InvokeRequired) { var d = new AddToLogDelegate(AddToLog); this.Invoke(d, message); return; } txtLog.Text += message + Environment.NewLine; txtLog.SelectionStart = txtLog.Text.Length - 1; txtLog.SelectionLength = 0; txtLog.ScrollToCaret(); }