Terminal remote control method and system based on MQTT Internet of Things communication
The terminal remote control method using MQTT IoT communication solves the problems of limited functionality, low protocol efficiency, and fragmented hardware control in remote management solutions for payment terminal devices. It achieves efficient, low-latency unified control of multiple hardware components, improving device manageability and system compatibility.
Patent Information
- Application Number
- CN202511019917.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-11-07
AI Technical Summary
Existing remote management solutions for payment terminal equipment have limited functionality, low protocol efficiency, and fragmented hardware control, resulting in high system complexity and high maintenance costs.
It adopts a terminal remote control method based on MQTT IoT communication, and realizes a unified command system through MQTT connection establishment, command parsing and execution. It integrates device management, voice broadcast and printing functions, supports millisecond-level command issuance and feedback, and is compatible with low-performance IoT devices.
It enables unified control of multiple hardware components, improves device manageability and response speed, reduces system complexity and maintenance costs, and supports cross-platform remote transaction control.
Smart Images

Figure CN120912199A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to Internet of Things communication technology, and in particular to a terminal remote control method and system based on MQTT Internet of Things communication. BACKGROUND
[0002] There are defective payment terminal device remote management solutions on the current market, specifically including:
[0003] (1) Traditional mPOS / SoftPOS solution:
[0004] Early mPOS and SoftPOS (such as payment solutions based on smart phones) usually only support basic payment functions and cannot control hardware modules such as voice broadcasting and printing through a unified instruction system, with single functions. In addition, they rely on Bluetooth or HTTP polling to communicate with the phone, with low protocol efficiency, obvious transaction delay, and scattered hardware control (such as external devices for printing), with complex maintenance.
[0005] (2) Traditional NFC terminal solution:
[0006] Some NFC payment solutions (such as early full-terminal solutions or dual-interface card solutions) cannot achieve remote unified management because the application is not stored on the SIM card, and lack of standardized protocol support, resulting in scattered hardware control (such as external antennas that are easily damaged), with high maintenance costs.
[0007] (3) Traditional cloud POS management platform:
[0008] Some early cloud POS systems (such as simple HTTP polling or custom TCP protocol management platforms) have weak concurrent processing capabilities and high response delays, and hardware functions (such as voice and printing) need to be controlled independently, with high system complexity.
[0009] The current payment terminal device remote management solutions on the market have the following limitations:
[0010] 1. Single function:
[0011] Traditional remote management solutions only support payment or device management and cannot control hardware functions such as transactions, voice broadcasting, and printing through a unified instruction system.
[0012] 2. Low protocol efficiency:
[0013] Traditional solutions such as HTTP polling or custom TCP protocol have poor concurrent processing capabilities, resulting in response delays, resource waste, and inefficient operation and maintenance.
[0014] 3. Scattered hardware control:
[0015] Each hardware function (such as voice, printing, etc.) requires an independent communication channel, resulting in increased system complexity and higher maintenance costs. SUMMARY
[0016] The following presents a simplified summary of one or more aspects in order to provide a basic understanding of such aspects. This summary is not an extensive overview of all contemplated aspects, and is intended to neither identify key or critical elements of all aspects nor delineate the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form as a prelude to the more detailed description that is presented later.
[0017] The present application aims to solve the above problems, and provides a terminal remote control method and system based on MQTT Internet of Things communication, which realizes remote control of payment terminals and improves the manageability, response speed and operation and maintenance automation level of the equipment, and is particularly suitable for terminal deployment in Internet of Things scenarios.
[0018] The technical scheme of the present application is: the present application discloses a terminal remote control method based on MQTT Internet of Things communication, the method comprising:
[0019] Step 1: establishing an MQTT connection between the terminal and the server;
[0020] Step 2: the server issues MQTT instruction messages of different functions to the terminal;
[0021] Step 3: the terminal parses and executes the MQTT instructions of different functions issued by the server;
[0022] Step 4: the terminal returns the execution result to the server through MQTT.
[0023] According to an embodiment of the terminal remote control method based on MQTT Internet of Things communication of the present application, in step 2, the MQTT instructions of different functions include a business function instruction set, a monitoring function instruction set and a control function instruction set.
[0024] According to an embodiment of the terminal remote control method based on MQTT Internet of Things communication of the present application, in step 2, the instructions are encapsulated in lightweight formats such as JSON, XML and Protobuf.
[0025] According to an embodiment of the terminal remote control method based on MQTT Internet of Things communication of the present application, in step 3, the terminal adopts a registered instruction routing mechanism for modular distribution and processing of remote instructions.
[0026] According to an embodiment of the terminal remote control method based on MQTT Internet of Things communication, in step 3, a globally unified instruction distribution center is built inside the terminal, for managing all identifiable MQTT control instructions, and each business module inside the terminal maps the instruction type supported by the business module to the processing method of the business module in the application initialization stage through registration, and when the terminal receives the MQTT instruction message from the server, the cmd field in the instruction is first parsed, and the instruction distribution center is matched and routed to the corresponding business module for execution.
[0027] According to an embodiment of the terminal remote control method based on MQTT Internet of Things communication, the method further comprises:
[0028] Step 5: The server implements hardware state monitoring on the terminal, and the monitoring mode is divided into active reporting and on-demand query, the active reporting refers to that the terminal regularly reports the hardware state to the server, and the on-demand query refers to that the server queries the hardware state by issuing a command.
[0029] The application further discloses a terminal remote control system based on MQTT Internet of Things communication, and the system comprises:
[0030] The communication layer module comprises an MQTT connection management unit and a message encoding and decoding unit, wherein the MQTT connection management unit is used for establishing and maintaining an MQTT long connection with the server, realizing terminal online authentication, heartbeat keep-alive, and disconnection reconnection, the message encoding and decoding unit is used for receiving and sending MQTT messages, supports multiple data encoding formats, and converts the messages into a data structure recognizable by the terminal inside;
[0031] The instruction distribution layer module comprises an analysis routing unit, wherein the analysis routing unit is used for performing structural analysis on the control instruction issued by the server, identifying the cmd field, and routing the cmd field to the corresponding business module for processing; and
[0032] The function execution layer module analyzes and executes the MQTT instructions of different functions issued by the server.
[0033] According to an embodiment of the terminal remote control system based on MQTT Internet of Things communication, the instruction distribution layer module further comprises a white list unit, an instruction legality verification mechanism is built in, only registered or authorized instruction types are allowed to be distributed, and execution of illegal control instructions is prevented.
[0034] According to an embodiment of the terminal remote control system based on MQTT Internet of Things communication, the function execution layer module comprises a device management unit, a voice broadcast unit, a printing unit, and a payment unit, wherein:
[0035] A device management unit is configured to perform device-level control operations, and to change the terminal state at the physical level by calling a system-level API.
[0036] A voice broadcast unit is configured to integrate a text-to-speech engine or a three-party voice SDK, synthesize voice according to instruction content, and broadcast the voice through a terminal audio output interface.
[0037] A printing unit is configured to convert text, a two-dimensional code, and other information into ESC / POS instructions, and control a thermal printer to print transaction credentials or other information through a serial port or a USB interface.
[0038] A payment unit is configured to interface with a third-party payment SDK or a local transaction service, and support the initiation of payment tasks such as code scanning payment and bank card payment.
[0039] The present application has the following beneficial effects compared with the prior art: The present application centrally manages device operations (such as rebooting, voice broadcasting, printing, etc.) through classified instructions, and realizes unified control of multiple hardware. The present application is based on a publish / subscribe mode, supports millisecond-level instruction issuance and feedback, ensures efficient and low-latency remote control, and realizes high real-time communication. The present application is adapted to low-performance Internet of Things devices, reduces memory and network bandwidth occupation, realizes more efficient resource management, and optimizes resources. The present application supports the initiation of payment instructions to heterogeneous terminals through a cloud interface, realizes unified transaction control of multiple platforms such as Android POS, embedded payment devices, and lightweight IoT terminals, enhances the compatibility and deployment flexibility of the system, and supports cross-platform remote transaction triggering.
[0040] Specific innovative design is that the present application adopts a modular instruction system, realizes unified instruction format and type-specific processing mechanism, adopts an MQTT protocol to replace a traditional HTTP polling mode, saves resources, and improves communication efficiency, and realizes real-time control and problem tracking of the cloud over the terminal state through an execution result and log linkage feedback mechanism. BRIEF DESCRIPTION OF DRAWINGS
[0041] The above features and advantages of the present application can be better understood after reading the detailed description of embodiments of the present application in conjunction with the following drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related properties or features can have the same or similar reference numerals.
[0042] Figure 1 A flowchart of an embodiment of a terminal remote control method based on MQTT Internet of Things communication of the present application is shown.
[0043] Figure 2 A schematic diagram of an embodiment of a terminal remote control system based on MQTT Internet of Things communication of the present application is shown. DETAILED DESCRIPTION
[0044] The application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. Note that the aspects described below in conjunction with the accompanying drawings and specific embodiments are only exemplary and should not be understood as limiting the scope of protection of the application in any way.
[0045] Figure 1 The flow of an embodiment of the terminal remote control method based on MQTT Internet of Things communication of the application is shown. Please see Figure 1 The implementation steps of the method of the embodiment are described in detail as follows.
[0046] Step 1: Establish MQTT connection between terminal and server.
[0047] MQTT (Message Queuing Telemetry Transport) is a lightweight message transmission protocol based on the publish / subscribe mode, commonly used for communication between devices with limited resources, low bandwidth and high latency. In this embodiment, the Aliyun Internet of Things platform (through Link SDK, version 1.7.3.4) is used as a message middleware to realize low-latency instruction communication and execution result feedback between the terminal and the server.
[0048] The terminal initializes the MQTT client through the Aliyun Link SDK, completes device authentication and subscribes to the server instruction Topic (such as / ${productKey} / ${deviceId} / terminal).
[0049] Step 2: The server issues MQTT instruction messages of different functions to the terminal.
[0050] The MQTT instructions of different functions are divided into multiple types:
[0051] Business function instruction set: such as starting bank card payment (payment_card), starting scan code payment (payment_scan), invoice printing (print), voice broadcasting (speak), etc.
[0052] Monitoring function instruction set: such as reporting device status (update_status), uploading log information (upload_log), etc. Log uploading can be real-time uploading, scheduled uploading or uploading when an error occurs.
[0053] Control function instruction set: such as remote installation application (remote_install), remote uninstall application (remote_uninstall), forced update (force_upgrade), suggest update (suggest_upgrade), lock (lock), reboot (reboot), shutdown (shutdown) and the like.
[0054] Each instruction is encapsulated in JSON format, for example: {"cmd":"reboot","data":{}} (wherein cmd represents the name of the instruction, and data represents the specific content of the print or transaction instruction.) The instruction encoding format can also be other lightweight formats such as XML, Protobuf, etc.
[0055] Step 3: The terminal parses and executes the different function MQTT instructions issued by the server.
[0056] At the terminal function implementation level, a registered instruction routing mechanism based on the Android platform is used to realize the modular distribution and processing of remote instructions.
[0057] The specific technical solutions are as follows:
[0058] A globally unified instruction distribution center is built inside the terminal, which is used to manage all identifiable MQTT control instructions. Each business module (such as the print module, voice broadcast module, payment module, device management module, etc.) inside the terminal maps the instruction types (such as "print", "speak", "reboot", "payment_*", etc.) supported by the business module to the processing method of the business module through registration during the application initialization phase. When the terminal receives the MQTT instruction message from the server, it first parses the cmd field in the instruction and automatically matches and routes it to the corresponding business module for execution by the instruction distribution center. The typical instruction routing relationship is as follows:
[0059] cmd="reboot"→route to the device management module to execute the device reboot process;
[0060] cmd="speak"→route to the voice broadcast module to call the TTS engine or third-party voice SDK to synthesize voice broadcast;
[0061] cmd="print"→route to the print module to encapsulate as ESC (Escape Command, i.e. escape command) / POS instruction to control the thermal printer;
[0062] cmd="payment_*"→route to the payment module to call the transaction SDK to complete the payment operation.
[0063] The registration type instruction routing mechanism has the following technical advantages:
[0064] Strong decoupling: the instruction distribution logic is independent of the business module, supporting independent development, upgrade and maintenance of each business module;
[0065] High expansibility: adding or modifying instructions does not require modifying the main flow code, and only needs to be registered to achieve rapid expansion;
[0066] Efficient operation: fast matching is performed through a memory mapping table, the instruction processing response time is low, and the performance is stable;
[0067] Strong adaptability: lightweight deployment on low-resource IoT terminals, suitable for multiple platforms such as Android POS and embedded devices.
[0068] In summary, the registration type instruction routing mechanism not only realizes the standardization and modularization of the instruction distribution logic, but also enhances the adaptability and execution efficiency of the terminal to the control ability of multiple types of hardware.
[0069] Step 4: The terminal returns the execution result to the server through MQTT.
[0070] The execution result structure is a data result containing state information, for example, in Aliyun, the execution result is returned by using {"code": 200, "data": "print_success"}.
[0071] Step 5: The server implements hardware state monitoring on the terminal.
[0072] The monitoring method is divided into active reporting and on-demand query. Active reporting refers to that the terminal regularly reports the hardware state (such as printer paper shortage, voice module failure, etc.) to the server. On-demand query refers to that the server can query the hardware state by issuing a command, such as obtaining the printer state: {"cmd": "get_status", "data": {"target": "printer"}}.
[0073] All instructions are implemented through the Aliyun MQTT channel for issuing and receiving, and the terminal processes them through a unified instruction analysis module.
[0074] Figure 2 An embodiment of the principle of the terminal remote control system based on MQTT Internet of Things communication of the application is shown. Please refer to Figure 2 The system of the embodiment includes a communication layer module, an instruction distribution layer module and a function execution layer module.
[0075] Figure 1 Steps 1 and 2 in the method embodiment are implemented by the communication layer module in the system of the embodiment,Figure 1 Step 3 in the method embodiment is jointly completed by the instruction dispatch layer module and the function execution layer module in the system of this embodiment. Figure 1 In the method embodiment, steps 4 and 5 are completed by the function execution layer module and communication layer module of the system in this embodiment sending response data to the cloud through a predefined result Topic. The execution result can be uniformly returned to a Topic and the instructions can be distinguished by fields.
[0076] The communication layer module includes an MQTT connection management unit and a message encoding / decoding unit. The MQTT connection management unit establishes and maintains long-lived MQTT connections with the server (e.g., Alibaba Cloud IoT platform), enabling functions such as terminal online authentication, heartbeat keep-alive, and reconnection after disconnection, ensuring the reliability and stability of communication. The message encoding / decoding unit receives and sends MQTT messages, supports various data encoding formats (such as JSON and Protobuf), and converts messages into data structures recognizable by the terminal for subsequent processing by subsequent modules.
[0077] The instruction distribution layer module includes a parsing and routing unit and a whitelisting unit. The parsing and routing unit is used by the terminal to parse the structure of control instructions issued by the server, identify the cmd field, and route it to the corresponding business module for processing.
[0078] The whitelist unit has a built-in instruction whitelist mechanism with an instruction legality verification mechanism. It only allows registered or authorized instruction types to be distributed, preventing unauthorized control of instruction execution and enhancing system security.
[0079] The functional execution layer module includes a device management unit, a voice broadcasting unit, a printing unit, and a payment unit. The device management unit performs device-level control operations, such as remote restart, shutdown, and locking, and implements physical-level terminal state changes by calling system-level APIs. The voice broadcasting unit integrates a TTS (text-to-speech) engine or a third-party voice SDK, synthesizing speech based on instructions and broadcasting it through the terminal's audio output interface for scenarios such as transaction prompts and system alarms. The printing unit converts text, QR codes, and other information into ESC / POS commands and controls a thermal printer to print transaction receipts or other information via a serial port or USB interface. The payment unit interfaces with third-party payment SDKs or local transaction services, supporting the initiation of payment tasks such as QR code payments and bank card payments.
[0080] In the present embodiment, the MQTT client implementation can be any library or SDK conforming to the MQTT standard protocol (such as v3.1.1 or v5.0), and is not specific to a certain developer version SDK (such as the Ali Cloud Link SDK). The present application can also implement the terminal and cloud instruction interaction logic through other existing MQTT client frameworks (such as Eclipse Paho, EMQ X SDK, HiveMQ Client, Mosquitto, etc.), thereby realizing the same remote control method function.
[0081] Although the above methods are illustrated and described as a series of acts, it will be understood and appreciated that the methods are not limited by the order of acts, as some acts may, in accordance with one or more embodiments, occur simultaneously or in different order than shown and described herein, or can be omitted entirely, depending on the embodiment.
[0082] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality, without limitation. Depending on the embodiment, implementation of the functional described above can be achieved with differing levels of complexity depending on the
[0083] The various illustrative logical blocks, modules, and circuits described in connection with the embodiments disclosed herein can be implemented or performed with a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor can be a microprocessor, but in the alternative, the processor can be any conventional processor, controller, microcontroller, or state machine. A processor can also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
[0084] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium can be integral to the processor. The processor and the storage medium can reside in an ASIC. The ASIC can reside in a user terminal. In the alternative, the processor and the storage medium can reside as discrete components in a user terminal.
[0085] In one or more exemplary embodiments, the functions described can be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functions can be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media can be any available media that can be accessed by a computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray® disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0086] The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A terminal remote control method based on MQTT Internet of Things communication, characterized by, The method comprises: Step 1: Establishing an MQTT connection between the terminal and the server; Step 2: The server issuing MQTT instruction messages of different functions to the terminal; Step 3: The terminal parsing and executing the MQTT instructions of different functions issued by the server; Step 4: The terminal returning the execution results to the server through MQTT. 2.The terminal remote control method based on MQTT Internet of Things communication according to claim 1, wherein, In step 2, the MQTT instructions of different functions include a business function instruction set, a monitoring function instruction set, and a control function instruction set.
3. The method of claim 3, wherein the method further comprises: In step 2, the instructions are encapsulated in lightweight formats such as JSON, XML, and Protobuf. 4.The terminal remote control method of MQTT IoT communication of claim 1, wherein, In step 3, the terminal uses a registered instruction routing mechanism to realize the modular distribution and processing of remote instructions. 5.The terminal remote control method of MQTT IoT communication of claim 4, wherein, In step 3, a globally unified instruction distribution center is built inside the terminal to manage all identifiable MQTT control instructions. Each business module inside the terminal maps the instruction types supported by the business module to the processing method of the business module through registration during the application initialization phase. When the terminal receives an MQTT instruction message from the server, the cmd field in the instruction is first parsed, and the instruction distribution center automatically matches and routes the instruction to the corresponding business module for execution. 6.The terminal remote control method based on MQTT Internet of Things communication according to claim 1, wherein, The method further comprises: Step 5: The server implementing hardware state monitoring on the terminal, which includes active reporting and on-demand querying. Active reporting refers to the terminal regularly reporting hardware states to the server, and on-demand querying refers to the server querying hardware states by issuing commands.
7. A terminal remote control system based on MQTT Internet of Things communication, characterized in that the system It comprises: A communication layer module, including an MQTT connection management unit and a message encoding and decoding unit. The MQTT connection management unit is used to establish and maintain an MQTT long connection with the server, realize terminal online authentication, heartbeat keep-alive, and disconnection reconnection. The message encoding and decoding unit is used to receive and send MQTT messages, supports multiple data encoding formats, and converts messages into a data structure recognizable by the terminal. An instruction distribution layer module, including an analysis and routing unit. The analysis and routing unit is used to structurally analyze the control instructions issued by the server, identify the cmd field, and route it to the corresponding business module for processing. And A function execution layer module that parses and executes the MQTT instructions of different functions issued by the server.
8. The terminal remote control system based on MQTT Internet of Things communication according to claim 7, characterized in that, The instruction distribution layer module further comprises a white list unit, which has an instruction white list mechanism and a legal instruction verification mechanism. Only registered or authorized instruction types are allowed to be distributed to prevent the execution of illegal control instructions.
9. The terminal remote control system based on MQTT Internet of Things communication according to claim 7, characterized in that, The function execution layer module includes a device management unit, a voice broadcast unit, a printing unit, and a payment unit. The device management unit is used to execute device-level control operations by calling system-level APIs to change the terminal state at the physical level. The voice broadcast unit is used to integrate a text-to-speech engine or a third-party voice SDK to synthesize voice according to instruction content and broadcast it through the terminal audio output interface. The printing unit is used to convert information such as text and QR codes into ESC / POS instructions and control a thermal printer through a serial or USB interface to print transaction receipts or other information. A payment unit is configured to connect to a third-party payment SDK or a local transaction service, and support initiation of a payment task, including a code scanning payment and a bank card payment.