private void btnSend_Click(object sender, EventArgs e) { MqttMessage msg; if (!MqttMessage.TryParse(tbMessage.Text, out msg)) { msg = new MqttMessage { Topic = tbMessage.Text } } ; string txt = $"---> {msg.ToMessageString()}\r\n"; AppendWatchLog(tbResponse, txt); BcSerialPort port = cbCom.SelectedItem as BcSerialPort; if (port != null) { port.SendMessage(msg); } }