/// <summary> /// 从用户接口收到数据 /// </summary> /// <param name="Ptype"></param> /// <param name="topic"></param> /// <param name="message"></param> private void _userPorts_UserPortMsgRvSetEvent(IotTopic topic, JObject message) { nlogger.Trace("the message topic is " + topic.ToString() + ", and the message is: " + message); switch (topic) { case IotTopic.ParamT: nlogger.Trace("Receive message from mqtt with topic Topic.ParamT"); break; case IotTopic.Relay: nlogger.Trace("Receive message from mqtt with topic Topic.Relay"); break; case IotTopic.DeviceCmd: iotPublishMessage(IotTopic.Relay); iotPublishMessage(IotTopic.DeviceState); iotPublishMessage(IotTopic.Error); iotPublishMessage(IotTopic.SampleState); iotPublishMessage(IotTopic.InstState); break; default: Console.WriteLine("Unknown message receieved."); break; } }
/// receive message from the mqtt cloud private void _mqttCloud_MessageReceievedEvent(IotTopic topic, string message) { // 初步解析 message,并根据 d_s 标志位判断是显示类型的消息,还是设置类型的消息 // 分别调用各自的事件函数 JObject jMsg = (JObject)JsonConvert.DeserializeObject(message); IotPortReceiveMessageEvent?.Invoke(topic, jMsg); nlogger.Debug("收到来自 mqttCloud 的数据: SubTopic - " + topic.ToString() + " message - " + message); }