private async void Cliente_MqttMsgPublishReceived(object sender, M2Mqtt.Messages.MqttMsgPublishEventArgs e) { var topic = e.Topic; string msg = Encoding.UTF8.GetString(e.Message); string[] ambiente = msg.Split(':'); ambiente = ambiente[0].Split('/'); string[] temperatura = ambiente[0].Split('-'); string[] CO2 = ambiente[1].Split('-'); string[] humedad_suelo = ambiente[2].Split('-'); string[] humedad_aire = ambiente[3].Split('-'); this.ambiente.Temperatura = temperatura[0]; this.ambiente.CO2 = CO2[0]; this.ambiente.Hum_Suel = humedad_suelo[0]; this.ambiente.Hum_Air = humedad_aire[0]; }
private static void IoTClient_MqttMsgPublishReceived(object sender, M2Mqtt.Messages.MqttMsgPublishEventArgs e) { Console.WriteLine("Message received: " + Encoding.UTF8.GetString(e.Message)); }