Smart device communication system and method

By combining the MCP and MQTT protocols in a smart device communication system, and utilizing a large language model to achieve natural language control, the system solves the problems of semantic understanding barriers and poor cross-platform compatibility in the interconnection of smart devices, and realizes seamless collaboration and real-time status feedback between devices.

CN121486465APending Publication Date: 2026-02-06CHENGDU BOSS INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511683906.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

Existing smart devices use their own independent communication protocols and control systems, which prevents them from effectively interconnecting with each other. This results in problems such as semantic understanding barriers between devices, high complexity of human-computer interaction, and poor cross-platform compatibility.

Method used

By combining the MCP and MQTT protocols and using a large language model to achieve natural language control, an intelligent device communication system is constructed, including a user interaction layer, an MCP server, a large language model, an MQTT broker server, and hardware devices, realizing the intelligent conversion of natural language commands into device control commands.

Benefits of technology

It solves the problems of semantic understanding barriers between devices, high complexity of human-computer interaction, and poor cross-platform compatibility, realizes the interconnection and interoperability of smart devices and natural language control, and provides real-time monitoring and feedback of device status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121486465A_ABST
    Figure CN121486465A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent device communication system and method. The intelligent device communication system comprises a user interaction layer, an MCP server, a large language model, an MQTT proxy server and a hardware device. In the mode, a set of complete mechanism for converting the MCP protocol to the MQTT protocol is constructed, so that a large language model can understand a natural language instruction of a user and convert the natural language instruction into specific operation which can be executed by equipment, and meanwhile, real-time monitoring and feedback of the state of the equipment are realized. By means of the mode, the problems that in the prior art, semantic understanding between devices is impaired, man-machine interaction complexity is high, the intelligent degree of the devices is limited, and cross-platform compatibility is poor are solved, and a brand new solution is provided for interconnection and intercommunication of the intelligent devices.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of large language models, and in particular to a smart device communication system and method. BACKGROUND

[0002] With the rapid development of Internet of Things technology, smart devices have been widely used in home, industrial and commercial environments. However, most of the smart devices on the market currently use independent communication protocols and control systems, which leads to the inability to effectively interconnect and interoperate between devices. Although the MQTT (Message Queuing Telemetry Transport) protocol, as a lightweight publish-subscribe message transmission protocol, has been widely used in the Internet of Things field, there are still problems such as semantic understanding barriers between devices, high complexity of human-computer interaction, and poor cross-platform compatibility. SUMMARY

[0003] Therefore, the purpose of the present application is to provide a smart device communication system and method to effectively combine the MCP (Model Context Protocol) protocol with existing Internet of Things communication protocols (such as MQTT) to achieve the interconnection and natural language control of smart devices.

[0004] In a first aspect, an embodiment of the present application provides a smart device communication system, the smart device communication system comprising: a user interaction layer, a model context MCP server, a large language model, a message queue telemetry transport MQTT proxy server and a hardware device; the user interaction layer is configured to obtain a natural language instruction input by a user, generate an MCP protocol message based on the natural language instruction, and send the MCP protocol message to the MCP server; the MCP server is configured to receive the MCP protocol message, authenticate and parse the MCP protocol message to obtain the natural language instruction, and send the natural language instruction to the large language model; receive the analysis result sent by the large language model, generate an MQTT instruction based on the analysis result, and send the MQTT instruction to the MQTT proxy server; the large language model is configured to receive the natural language instruction, understand and process the natural language instruction to obtain an analysis result, and send the analysis result to the MCP server; the analysis result is used to represent an operation instruction executable by the hardware device; the MQTT proxy server is configured to receive the MQTT instruction and send the MQTT instruction to the hardware device; and the hardware device is configured to receive the MQTT instruction and execute the MQTT instruction to obtain state feedback information.

[0005] In an optional embodiment of the present application, the hardware device is further configured to send the state feedback information to an MQTT broker server; the MQTT broker server is further configured to receive the state feedback information and send the state feedback information to an MCP server; the MCP server is further configured to receive the state feedback information and send the state feedback information to a user interaction layer; and the user interaction layer is further configured to display the state feedback information.

[0006] In an optional embodiment of the present application, the MCP server is configured to perform message parsing and verification based on the MCP protocol message to obtain a natural language instruction, perform user authentication and authorization based on the MCP protocol message, and send the natural language instruction to a large language model if the user authentication and authorization are successful.

[0007] In an optional embodiment of the present application, the large language model is configured to perform semantic parsing on the natural language instruction to extract key information, and process the key information to obtain a parsing result.

[0008] In an optional embodiment of the present application, the MCP server is configured to perform device mapping, instruction mapping, parameter conversion, and MQTT message construction on the parsing result to obtain an MQTT instruction.

[0009] In an optional embodiment of the present application, the device mapping includes mapping an abstract device description in the parsed result to an actual hardware device identifier.

[0010] In an optional embodiment of the present application, the instruction mapping includes mapping an abstract operation intention to an MQTT topic and an instruction format supported by the hardware device.

[0011] In an optional embodiment of the present application, the parameter conversion includes converting a fuzzy parameter in the natural language into a numerical value executable by the hardware device.

[0012] In an optional embodiment of the present application, the MQTT message construction includes constructing an MQTT message as the MQTT instruction based on the processing results of the device mapping, the instruction mapping, and the parameter conversion.

[0013] In a second aspect, the embodiments of the present application also provide a smart device communication method applied to the smart device communication system. The smart device communication method comprises the following steps: a user interaction layer acquires a natural language instruction input by a user, generates an MCP protocol message based on the natural language instruction, and sends the MCP protocol message to an MCP server; the MCP server receives the MCP protocol message, authenticates and parses the MCP protocol message to obtain the natural language instruction, and sends the natural language instruction to a large language model; the large language model receives the natural language instruction, understands and processes the natural language instruction to obtain a parsing result, and sends the parsing result to the MCP server; the parsing result is used to represent an operation instruction executable by a hardware device; the MCP server receives the parsing result sent by the large language model, generates an MQTT instruction based on the parsing result, and sends the MQTT instruction to an MQTT proxy server; the MQTT proxy server receives the MQTT instruction and sends the MQTT instruction to the hardware device; and the hardware device receives the MQTT instruction and executes the MQTT instruction to obtain state feedback information.

[0014] The embodiments of the present application bring the following beneficial effects: The embodiments of the present application provide a smart device communication system and method, construct a complete MCP protocol to MQTT protocol conversion mechanism, enable the large language model to understand the natural language instruction of the user and convert it into a specific operation executable by the device, and realize real-time monitoring and feedback of the device state. In this way, the problems of semantic understanding barrier between devices, high human-computer interaction complexity, limited device intelligence, and poor cross-platform compatibility in the prior art are solved, and a new solution is provided for the interconnection and intercommunication of smart devices.

[0015] Other features and advantages of the present disclosure will be described in the following description, or can be inferred or determined without doubt from the description, or can be known by implementing the above-mentioned technologies of the present disclosure.

[0016] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following preferred embodiments are described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0018] Figure 1A structural schematic diagram of a smart device communication system provided by an embodiment of the present application is provided. Figure 2 A system architecture schematic diagram of a smart device communication system provided by an embodiment of the present application is provided. Figure 3 An interaction flow schematic diagram of a smart device communication system provided by an embodiment of the present application is provided. Figure 4 A schematic diagram of a conversion mechanism from MCP protocol to MQTT protocol provided by an embodiment of the present application is provided. Figure 5 A flowchart of a smart device communication method provided by an embodiment of the present application is provided. DETAILED DESCRIPTION

[0019] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be described below in detail with reference to the drawings. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0020] At present, with the rapid development of Internet of Things technology, smart devices have been widely used in home, industrial and commercial environments. However, most of the smart devices on the market currently use independent communication protocols and control systems, which leads to the inability to achieve effective interconnection and intercommunication between devices. Although MQTT protocol, as a lightweight publish-subscribe message transmission protocol, has been widely used in the field of Internet of Things, there are still the following problems: 1. Semantic understanding barrier between devices: traditional MQTT message transmission only transmits simple data and instructions, lacking semantic understanding ability, leading to the inability of complex interaction and cooperation between devices.

[0021] 2. High complexity of human-computer interaction: users need to learn specific commands or use special application programs to control different devices, and cannot perform intuitive and simple operations through natural language.

[0022] 3. Poor cross-platform compatibility: different manufacturers' devices use different protocols and standards, making it difficult to achieve seamless cooperation between cross-platform devices.

[0023] In recent years, the rapid development of Large Language Model (LLM) technology has offered new possibilities for solving the aforementioned problems. The MCP protocol, as an emerging contextual protocol, enables AI (Artificial Intelligence) models to understand and process complex contextual information. However, how to effectively combine the MCP protocol with existing IoT communication protocols (such as MQTT) to achieve interconnectivity and natural language control of smart devices remains a pressing technical challenge.

[0024] Based on this, the present invention provides a smart device communication system and method, specifically a smart device interconnection system based on the MCP protocol, which can solve the problem of semantic understanding barriers between devices and realize semantic-level interconnection between devices through the MCP protocol; it can solve the problem of high complexity of human-computer interaction, enabling users to directly control smart devices through natural language; and it can also solve the problem of poor cross-platform compatibility, achieving seamless collaboration between devices on different platforms through a unified protocol conversion mechanism.

[0025] To facilitate understanding of this embodiment, a smart device communication system disclosed in this embodiment of the invention will first be described in detail.

[0026] Example 1: This invention provides a smart device communication system, see [link to relevant documentation]. Figure 1 The diagram shows the structure of a smart device communication system, which includes: a user interaction layer, a Model Context (MCP) server, a large language model, a Message Queue Telemetry Transmission (MQTT) broker server, and hardware devices. The user interaction layer is used to obtain natural language commands input by the user, generate MCP protocol messages based on the natural language commands, and send the MCP protocol messages to the MCP server. The MCP server is used to receive MCP protocol messages, authenticate and parse the MCP protocol messages to obtain natural language instructions, and send the natural language instructions to the large language model; it also receives the parsing results sent by the large language model, generates MQTT instructions based on the parsing results, and sends the MQTT instructions to the MQTT broker server. The large language model is used to receive natural language instructions, understand and process them to obtain parsing results, and send the parsing results to the MCP server; the parsing results are used to characterize the operation instructions that the hardware device can execute. An MQTT broker server is used to receive MQTT commands and send them to hardware devices. Hardware devices used to receive MQTT commands, execute MQTT commands, and obtain status feedback information.

[0027] Referring to Figure 2 The system architecture diagram of an intelligent device communication system is shown, which mainly includes the following key components: (1) User interaction layer: including various client applications such as mobile applications, web applications and voice assistants, used to receive user natural language instructions and display execution results.

[0028] (2) MCP server: the core component of the system, responsible for receiving client MCP protocol messages, interacting with large language models, and converting processing results into MQTT instructions and sending them to devices.

[0029] The MCP server in this embodiment is the core component of the intelligent device communication system, which realizes the conversion between the MCP protocol and the MQTT protocol, enabling the large language model to effectively communicate with hardware devices (such as Internet of Things devices). The MCP server can be designed with a modular architecture, with each functional module working together to form a complete intelligent device control link.

[0030] (3) Large language model: responsible for understanding and processing user natural language instructions, generating device executable operation instructions.

[0031] (4) MQTT Broker: responsible for managing MQTT message publishing and subscribing, connecting MCP servers and hardware devices.

[0032] (5) Hardware device: executes instructions received from the MCP server and feeds back status information to the system.

[0033] As Figure 2 shown, an intelligent device interconnection and intercommunication system based on MCP protocol and MQTT protocol is provided in this embodiment. The system connects the user interaction layer, the large language model and the hardware device by building the MCP server as an intermediate layer, realizing the functions of natural language control of hardware devices, AI real-time response and adjustment of physical parameters, device understanding and execution of complex instructions, and interconnection and intercommunication between devices.

[0034] Also refer to Figure 3An interaction flow diagram of an intelligent device communication system is shown. In the entire interaction flow, the user first inputs natural language instructions to the user interaction layer of the system through the client. The user interaction layer can package the natural language instructions as MCP protocol messages and send them to the MCP server. After receiving the messages, the MCP server performs authentication and message parsing, and then sends the natural language instructions obtained by authentication and message parsing to the large language model for understanding and processing. After the large language model returns the parsing result, the MCP server converts it into MQTT instructions and sends it to the corresponding hardware device through the MQTT Broker.

[0035] In some embodiments, the hardware device is further configured to send the state feedback information to the MQTT Broker server. The MQTT Broker server is further configured to receive the state feedback information and send the state feedback information to the MCP server. The MCP server is further configured to receive the state feedback information and send the state feedback information to the user interaction layer. The user interaction layer is further configured to display the state feedback information.

[0036] As shown in Figure 3 After the hardware device executes the MQTT instructions, it sends the state feedback information back to the MCP server through the MQTT Broker, and the MCP server returns the execution result to the user interaction layer, which is finally displayed to the user.

[0037] The embodiment of the application provides an intelligent device communication system, which constructs a complete conversion mechanism from MCP protocol to MQTT protocol, so that the large language model can understand the natural language instructions of the user and convert them into specific operations executable by the device, and realizes real-time monitoring and feedback of the device state. Through this way, the problems of semantic understanding barrier between devices, high complexity of human-computer interaction, limited intelligent degree of devices and poor cross-platform compatibility in the prior art are solved, and a new solution for the interconnection and intercommunication of intelligent devices is provided.

[0038] Embodiment two The embodiment provides another intelligent device communication system, which is realized on the basis of the above-mentioned embodiment, and mainly describes the specific implementation manner of the intelligent device communication system.

[0039] In some embodiments, the MCP server is configured to perform message parsing verification based on the MCP protocol messages to obtain the natural language instructions, and perform user authentication and authorization based on the MCP protocol messages. If the user authentication and authorization are successful, the natural language instructions are sent to the large language model.

[0040] As shown in Figure 3As shown, the MCP server in this embodiment can receive MCP protocol messages from the user interaction layer, perform message parsing and verification on the MCP protocol messages, thereby ensuring that the message format conforms to the protocol specification. Its code can be as follows: class MCPMessageProcessor: def process_message(self, raw_message): """Processing MCP protocol messages""" message = json.loads(raw_message) # Verify message format if not self.validate_format(message): raise ValueError("Invalid MCP message format") return { 'method': message['method'], 'params': message.get('params', {}), 'user_token': message.get('user_token') } like Figure 3 As shown, the MCP server in this embodiment can also perform user authentication and authorization based on MCP protocol messages, verify user identity, and ensure that only authorized users can control specific devices, thereby achieving fine-grained access control. The code can be shown below: class AuthenticationManager: def authenticate_and_authorize(self, token, device_id, action): "Authenticate users and check permissions" user = self.verify_jwt_token(token) if not user: return False # Check device operation permissions return self.check_permission(user['id'], device_id, action) In this embodiment, the MCP server can send the parsed natural language instructions to the large language model, which then understands and processes the results, thereby achieving intelligent conversion from natural language to device instructions. The code for this can be shown below: class LLMInterface: async def process_natural_language(self, user_input, device_context): Processing natural language commands. prompt = f"User command: {user_input}\nDevice status: {device_context}" response = await self.llm_client.generate( prompt=prompt, max_tokens=200, temperature=0.1 ) In this embodiment, the MCP server can also convert the processing results of the large language model into standard MQTT commands and send them to the hardware device via the MQTT protocol. The code is as follows: class MQTTCommandConverter: async def convert_and_publish(self, llm_result): """Convert and publish MQTT commands"" topic = f"devices / {llm_result['device_id']} / commands" command = { 'action': llm_result['action'], 'parameters': llm_result['parameters'], 'timestamp': int(time.time()) } Real-time state information of the device can also be maintained in the embodiment, for context understanding and state feedback, to ensure that the system accurately masters the state of the device, and the code can be as follows: class DeviceStateManager: def __init__(self): self.device_states = {} def update_state(self, device_id, state_data): """Update device state""" self.device_states[device_id] = { **self.device_states.get(device_id, {}), **state_data, 'last_update': time.time() } def get_device_context(self): """Get device context""" return {k: v for k, v in self.device_states.items() if time.time() - v.get('last_update', 0)<300} The MCP protocol is a "sessionized request-response", and the MQTT protocol is a "publish-subscribe topic routing". Therefore, the MCP protocol and the MQTT protocol are naturally not aligned in terms of key semantics such as session boundary, response association, cancellation and error, order and consistency, capability and version governance, security and audit, etc. Bridging them is not to transfer messages from A to B, but to supplement the MCP protocol with a complete set of "alignment rules and control mechanisms" required for the MQTT protocol, otherwise there will be systematic problems such as not matching, out-of-order / repetition, inability to negotiate capabilities, unclear authority boundaries, uncontrollable errors, etc. Therefore, the MCP protocol and the MQTT protocol cannot be directly bridged in the prior art, and users need to learn complex device operation instructions to control the device.

[0041] The intelligent device communication system provided in this embodiment of the invention offers an intelligent protocol conversion mechanism: it innovatively bridges the MCP and MQTT protocols, achieving intelligent conversion from natural language commands to device control commands through a large language model. Users can directly control IoT devices using natural language without needing to learn complex device operation commands.

[0042] Example 3: This embodiment provides another intelligent device communication system, which is implemented based on the above embodiment, and focuses on describing the conversion mechanism from MCP protocol to MQTT protocol.

[0043] The MCP to MQTT protocol conversion mechanism described in this embodiment is one of the core technologies of intelligent device communication systems. It realizes intelligent conversion from natural language commands to device control commands. (See also...) Figure 4 This diagram illustrates a conversion mechanism from the MCP protocol to the MQTT protocol. Figure 4 As shown, the MCP to MQTT protocol conversion mechanism in this embodiment adopts a five-stage pipeline processing architecture to ensure the accuracy and reliability of the conversion.

[0044] In some embodiments, a large language model is used to perform semantic parsing on natural language instructions to extract key information, and to process the key information to obtain the parsing result.

[0045] like Figure 4 As shown, this embodiment can use a large language model to perform deep semantic parsing of the user's natural language commands during the semantic parsing stage, extracting key information. The code is as follows: class SemanticParser: def __init__(self, llm_client): self.llm_client = llm_client self.intent_patterns = { 'temperature_control': ['temperature', 'adjust', 'increase', 'decrease', 'set'], 'light_control': ['light', 'turn on light', 'turn off light', 'brighten', 'dimen'], 'device_query': ['status', 'view', 'check', 'how'] } async def parse_natural_language(self, user_input): Parsing Natural Language Commands prompt = f""" Parse the following user commands and extract key information: User command: "{user_input}" Please return in JSON format: {{ "intent": "operational intent", "location": "Location information", "device_type": "device type", "action": "Specific action", "parameters": {{"parameter name": "parameter value"}} }} """ response = await self.llm_client.generate(prompt) return json.loads(response.content) In some embodiments, the MCP server is used to perform device mapping, instruction mapping, parameter conversion, and MQTT message construction on the parsed results to obtain MQTT instructions.

[0046] like Figure 4 As shown, the device mapping stage, instruction mapping stage, parameter conversion stage, and MQTT message construction stage can all be executed through the MCP server, ultimately constructing an MQTT message as an MQTT instruction.

[0047] In some embodiments, device mapping includes mapping abstract device descriptions in the parsed results to actual hardware device identifiers.

[0048] like Figure 4 As shown, in this embodiment, the abstract device description in the semantic parsing result can be mapped to the actual IoT device identifier during the device mapping stage. The code is as follows: def map_device(self, location, device_type): """Mapping Device Identifier""" # Location Standardization standard_location = self.location_mapping.get(location) if not standard_location: raise ValueError(f"Unknown location: {location}") # Device lookup location_devices = self.device_registry.get(standard_location, {}) device_id = location_devices.get(device_type) if not device_id: raise ValueError(f"Location {location} does not have a {device_type} device") # Device status verification if not self.is_device_online(device_id): raise ValueError(f"Device {device_id} is offline") return device_id def is_device_online(self, device_id): """Check if a device is online""" # Actual implementation would query device status cache return True In some embodiments, the instruction mapping includes mapping abstract operation intents to specific MQTT topics and instruction formats supported by the hardware devices.

[0049] As shown in Figure 4 , in the instruction mapping phase, the abstract operation intents can be mapped to specific MQTT topics and instruction formats supported by the devices. The code can be as follows: class CommandMapper: def __init__(self): self.command_mapping = { 'temperature_control': { 'mqtt_action':'set_temperature', 'topic_template': 'devices / {device_id} / commands', 'supported_actions': ['increase', 'decrease','set'] }, 'light_control': { 'mqtt_action': 'control_light', 'topic_template': 'devices / {device_id} / commands', 'supported_actions': ['on', 'off', 'dim'] } } def map_command(self, intent, device_id, action): """Map MQTT commands""" command_config = self.command_mapping.get(intent) if not command_config: raise ValueError(f"Unsupported operation intent: {intent}") if action not in command_config['supported_actions']: raise ValueError(f"Device does not support the operation: {action}") return { 'device_id': device_id, 'mqtt_topic': command_config['topic_template'].format(device_id=device_id), 'mqtt_action': command_config['mqtt_action'], 'action': action } In some embodiments, parameter conversion includes converting fuzzy parameters in natural language into numerical values ​​that can be executed by a hardware device.

[0050] like Figure 4 As shown, this embodiment can convert fuzzy parameters in natural language into precise numerical values ​​that can be executed by the device during the parameter conversion stage. The code can be as follows: class ParameterConverter: def __init__(self): self.fuzzy_mappings = { 'temperature': { 'A little': 2, 'Some': 3, 'Many': 5, 'Slightly': 1 }, 'brightness': { 'One point': 10 'Some': 20, 'Many': 50, 'Slightly': 5 } } self.device_limits = { 'thermostat': {'min': 16, 'max': 30, 'unit': '°C'}, 'light': {'min': 0, 'max': 100, 'unit': '%'} } def convert_parameters(self, device_type, action, parameters,current_state): """Conversion parameter value""" if device_type == 'thermostat': return self._convert_temperature_params(action, parameters, current_state) elif device_type == 'light': return self._convert_light_params(action, parameters, current_state) else: raise ValueError(f"Unsupported device type: {device_type}") def _convert_temperature_params(self, action, parameters, current_state): """Convert temperature parameters""" current_temp = current_state.get('temperature', 22) degree = parameters.get('degree', 'a little') # Fuzzy value conversion temp_change = self.fuzzy_mappings['temperature'].get(degree, 2) if action == 'increase': target_temp = current_temp + temp_change elif action == 'decrease': target_temp = current_temp - temp_change else: target_temp = int(parameters.get('value', current_temp)) # Range validation limits = self.device_limits['thermostat'] target_temp = max(limits['min'], min(limits['max'], target_temp)) return { 'action':'set_temperature', 'value': target_temp, 'unit': limits['unit'], 'previous_value': current_temp } In some embodiments, MQTT message construction includes: constructing an MQTT message as an MQTT instruction based on the processing results of device mapping, instruction mapping, and parameter conversion.

[0051] like Figure 4 As shown, in this embodiment, a standard MQTT message can be constructed based on the processing results of the previous stages during the MQTT message construction phase. The code is as follows: class MQTTMessageBuilder: def __init__(self): self.qos_mapping = { 'critical': 2, # Critical operation, ensure delivery 'normal': 1,# Normal operation, delivery must be made at least once. 'status': 0# Status query, try your best to deliver } def build_mqtt_message(self, command_info, converted_params): """Building MQTT messages""" # Determine QoS level qos = self._determine_qos(command_info['mqtt_action']) # Construct message payload payload = { 'command_id': str(uuid.uuid4()), 'timestamp': int(time.time()), 'action': converted_params['action'], 'parameters': { 'value': converted_params['value'], 'unit': converted_params.get('unit', '') }, 'source': 'mcp_server', 'priority': self._get_priority(command_info['mqtt_action']) } return { 'topic': command_info['mqtt_topic'], 'payload': json.dumps(payload, ensure_ascii=False), 'qos': qos, 'retain': False } def _determine_qos(self, action): """Determine the QoS level""" critical_actions = ['emergency_stop', 'security_alarm'] if action in critical_actions: return self.qos_mapping['critical'] else: return self.qos_mapping['normal'] def _get_priority(self, action): """Get message priority""" high_priority = ['emergency_stop', 'security_alarm', 'fire_alarm'] return 'high' if action in high_priority else 'normal' # Complete conversion example async def complete_conversion_example(): "A complete conversion process example" user_input = "Turn the living room temperature up a bit" # 1. Semantic Analysis parser = SemanticParser(llm_client) semantic_result = await parser.parse_natural_language(user_input) # 2. Device Mapping mapper = DeviceMapper() device_id = mapper.map_device( semantic_result['location'], semantic_result['device_type'] ) # 3. Instruction Mapping cmd_mapper = CommandMapper() command_info = cmd_mapper.map_command( semantic_result['intent'], device_id, semantic_result['action'] ) # 4. Parameter Conversion converter = ParameterConverter() current_state = {'temperature': 22} # Retrieve from device state cache converted_params = converter.convert_parameters( semantic_result['device_type'], semantic_result['action'], semantic_result['parameters'], current_state ) # 5. MQTT Message Construction builder = MQTTMessageBuilder() mqtt_message = builder.build_mqtt_message(command_info, converted_params) return mqtt_message In summary, the above-mentioned intelligent device communication system provided by the embodiment of the application provides a five-stage pipeline processing architecture: a complete conversion link of semantic analysis, device mapping, instruction mapping, parameter conversion and message construction is established, and the accuracy and reliability of conversion are ensured. The unified protocol conversion interface supports different types of Internet of Things devices, and realizes unified management of devices across brands and protocols. Through the above-mentioned five-stage pipeline processing architecture, the "natural language of the user" can be stably and traceably converted into "executable control instructions of specific devices", and devices are uniformly managed across brands and protocols.

[0052] The above-mentioned intelligent device communication system provided by the embodiment of the application can be divided into five stages of pipeline to solve complex problems: each stage has clear responsibilities, is measurable, iterative, and extensible, and ensures consistency and reliability from end to end.

[0053] Compared with other commonly used pipelines in the prior art, the above-mentioned five-stage pipeline provided by the embodiment of the application has the following advantages: 1. Dependence on sequence to determine stage boundaries: "understanding" must be performed first, then "selecting a device", then "determining an instruction", then "converting parameters", and finally "building a message". Any merging or reordering will introduce ambiguity, backtracking and error costs.

[0054] 2. Clear responsibilities for easy management: each stage can be independently optimized and measured (analysis accuracy, capability coverage, instruction consistency, parameter legality, and message success rate), forming a quality closed loop that can be operated.

[0055] 3. Extensible and pluggable: adding a device / protocol only needs to be inserted and expanded at both ends of "device mapping / message building", the semantic and instruction layers remain stable, and the overall complexity is reduced.

[0056] 4. Avoiding single adaptation defects: mixing "analysis, mapping, conversion and delivery" together will result in strong coupling, untestable and difficult to locate problems.

[0057] Embodiment Four The embodiment of the application provides an intelligent device communication method applied to the intelligent device communication system provided in the foregoing embodiments, referring to a flowchart of an intelligent device communication method shown in Figure 5 The intelligent device communication method comprises the following steps: In step S502, the user interaction layer acquires the natural language instruction input by the user, generates an MCP protocol message based on the natural language instruction, and sends the MCP protocol message to the MCP server. In step S504, the MCP server receives the MCP protocol message, authenticates and parses the MCP protocol message to obtain the natural language instruction, and sends the natural language instruction to the large language model. In step S506, the large language model receives the natural language instruction, understands and processes the natural language instruction to obtain a parsing result, and sends the parsing result to the MCP server. The parsing result is used to represent an operation instruction executable by the hardware device. In step S508, the MCP server receives the parsing result sent by the large language model, generates an MQTT instruction based on the parsing result, and sends the MQTT instruction to the MQTT proxy server. In step S510, the MQTT proxy server receives the MQTT instruction and sends the MQTT instruction to the hardware device. In step S512, the hardware device receives the MQTT instruction and executes the MQTT instruction to obtain state feedback information.

[0058] The embodiment of the application provides an intelligent device communication method, and constructs a complete MCP protocol to MQTT protocol conversion mechanism, so that the large language model can understand the natural language instruction of the user and convert the natural language instruction into specific operation executable by the device, and realizes real-time monitoring and feedback of the device state. In this way, the problems of semantic understanding barrier between devices, high human-computer interaction complexity, limited intelligent degree of devices and poor cross-platform compatibility in the prior art are solved, and a new solution is provided for interconnection and intercommunication of intelligent devices.

[0059] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the intelligent device communication method described above can refer to the corresponding process in the foregoing embodiments, which will not be repeated here.

[0060] In addition, in the description of the embodiment of the application, unless otherwise explicitly specified and limited, the terms "mounting", "connection" and "connection" should be understood in a broad sense, for example, can be fixed connection, can also be detachable connection, or integral connection; can be mechanical connection, can also be electrical connection; can be directly connected, can also be indirectly connected through an intermediate medium, can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the application can be understood according to the specific circumstances.

[0061] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third" are only for the purpose of description, and cannot be understood as indicating or implying relative importance.

[0062] Finally, it should be noted that the above embodiments are only specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, and are not limiting. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features, within the technical scope disclosed by the present application. The modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An intelligent device communication system, characterized by The intelligent device communication system comprises a user interaction layer, a model context (MCP) server, a large language model, a message queue telemetry transport (MQTT) broker server and a hardware device. The user interaction layer is configured to obtain a natural language instruction input by a user, generate an MCP protocol message based on the natural language instruction, and send the MCP protocol message to the MCP server. The MCP server is configured to receive the MCP protocol message, authenticate and parse the MCP protocol message to obtain the natural language instruction, send the natural language instruction to the large language model, receive a parsing result sent by the large language model, generate an MQTT instruction based on the parsing result, and send the MQTT instruction to the MQTT broker server. The large language model is configured to receive the natural language instruction, understand and process the natural language instruction to obtain the parsing result, and send the parsing result to the MCP server. The parsing result is used to represent an operation instruction executable by the hardware device. The MQTT broker server is configured to receive the MQTT instruction and send the MQTT instruction to the hardware device.

2. The intelligent device communication system of claim 1, wherein, The hardware device is configured to receive the MQTT instruction and execute the MQTT instruction to obtain state feedback information. The hardware device is further configured to send the state feedback information to the MQTT broker server. The MQTT broker server is further configured to receive the state feedback information and send the state feedback information to the MCP server. The MCP server is further configured to receive the state feedback information and send the state feedback information to the user interaction layer.

3. The intelligent device communication system of claim 1, wherein, The user interaction layer is further configured to display the state feedback information.

4. The intelligent device communication system of claim 1, wherein, The MCP server is configured to verify the natural language instruction based on message parsing of the MCP protocol message, perform user authentication and authorization based on the MCP protocol message, and send the natural language instruction to the large language model if the user authentication and authorization are successful.

5. The intelligent device communication system of claim 1, wherein, The large language model is configured to perform semantic analysis on the natural language instruction to extract key information, and process the key information to obtain the parsing result.

6. The intelligent device communication system of claim 5, wherein, The MCP server is configured to perform device mapping, instruction mapping, parameter conversion and MQTT message construction on the parsing result to obtain the MQTT instruction.

7. The intelligent device communication system of claim 5, wherein, The device mapping comprises mapping an abstract device description in the parsing result to an actual hardware device identifier.

8. The intelligent device communication system of claim 5, wherein, The instruction mapping comprises mapping an abstract operation intention to an MQTT topic and an instruction format supported by the hardware device.

9. The intelligent device communication system of claim 5, wherein, The parameter conversion comprises converting a fuzzy parameter in the natural language into a numerical value executable by the hardware device.

10. A method of intelligent device communication, the method comprising: The MQTT message construction comprises constructing an MQTT message as the MQTT instruction based on processing results of the device mapping, the instruction mapping and the parameter conversion. The intelligent device communication method is applied to the intelligent device communication system of any one of claims 1-9. The user interaction layer obtains a natural language instruction input by a user, generates an MCP protocol message based on the natural language instruction, and sends the MCP protocol message to the MCP server; The MCP server receives the MCP protocol message, authenticates and parses the MCP protocol message to obtain the natural language instruction, and sends the natural language instruction to a large language model; The large language model receives the natural language instruction, understands and processes the natural language instruction to obtain a parsing result, and sends the parsing result to the MCP server; the parsing result is used to represent an operation instruction executable by the hardware device; The MCP server receives the parsing result sent by the large language model, generates an MQTT instruction based on the parsing result, and sends the MQTT instruction to an MQTT proxy server; The MQTT proxy server receives the MQTT instruction and sends the MQTT instruction to the hardware device; The hardware device receives the MQTT instruction and executes the MQTT instruction to obtain state feedback information.