Gateway command conversion methods, devices, and electronic equipment
By converting gateway instructions in the intelligent control platform, converting control instructions into unified data packets based on the identification information of the equipment manufacturer, the problem of inconsistent instruction system when multiple manufacturers use equipment in combination is solved, and efficient instruction adaptation is achieved and stability.
Patent Information
- Application Number
- CN202211732257.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2042-12-30
AI Technical Summary
In the existing technology, each intelligent control manufacturer formulates its own gateway docking protocol and equipment instruction system, which makes it impossible to achieve unified management of the instruction system when multiple manufacturers use equipment in combination, increasing the workload of development and docking.
By obtaining the control instructions sent by the terminal device from the message cluster, determining the corresponding message template based on the identification information in the command, and converting the control instructions into target data packets, adapting to the data format supported by gateway devices of different equipment manufacturers. Achieve unified management of the instruction system of each equipment manufacturer.
It realizes the system management of instruction body of different equipment manufacturers, reduces docking costs, saves development workload, and provides unified control services through the platform, supports the adaptation and link monitoring of multiple data exchange protocols, ensuring application requests stability.
Smart Images

Figure CN116170254B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent device control, and more specifically, to a gateway instruction conversion method, device and electronic device. Background Art
[0002] Currently, the mainstream intelligent guest control manufacturers and industry integrators in the hotel accommodation industry are all operating independently to expand the market and have not formed standardized products. Each intelligent control manufacturer has developed its own gateway docking protocol and equipment command system. When introducing multiple equipment manufacturers as a guest control platform, it is necessary to carry out full-process docking and development with each manufacturer, which is a large workload and it is impossible to achieve unified management of the command systems of different devices.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a gateway command conversion method, device and electronic device to at least solve the technical problem in the prior art that each intelligent control manufacturer has formulated its own gateway docking protocol and device command system, and when using devices produced by multiple manufacturers, it is impossible to achieve unified management of the command systems of different devices.
[0005] According to one aspect of an embodiment of the present application, a method for converting a gateway instruction is provided, comprising: obtaining a control instruction sent by a target account through a terminal device from a message cluster, wherein the control instruction is used to control a smart device; determining a message template corresponding to the identification information based on identification information in the control instruction, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; converting the control instruction into a target data message based on the message template, wherein the target data message is a message in a data format supported by a gateway device corresponding to the device manufacturer; and sending the target data message to the gateway device corresponding to the identification information.
[0006] Optionally, before obtaining the control instructions sent by the target account through the terminal device from the message cluster, the method also includes: verifying the permission information of the target account to log in to the terminal device to obtain a verification result; if the verification result indicates that the target account has control authority, storing the control instructions in the message cluster; if the verification result indicates that the target account does not have control authority, refusing to store the control instructions in the message cluster.
[0007] Optionally, after obtaining the control instructions sent by the target account through the terminal device from the message cluster, the method also includes: generating a target channel for receiving control instructions, and distributing an instruction interface for each control instruction, wherein the instruction interface is used to trigger an operation event for the control instruction; calling the target interface to convert the control instructions in the target channel to obtain a conversion result; listening to the conversion result by listening to the event, and returning the conversion result.
[0008] Optionally, converting a control instruction into a target data message includes: initializing multiple types of instruction systems, wherein each type of instruction system corresponds to a type of identification information; obtaining the identification information in the control instruction; determining a target instruction system to be converted from the multiple types of instruction systems based on the identification information, wherein the target instruction system includes a message template corresponding to the identification information; and converting the control instruction into a target data message based on the target instruction system.
[0009] Optionally, sending the target data message to the gateway device corresponding to the identification information includes: obtaining the target data message and the identification information, wherein the target data message includes at least one of the following: device ID, instruction type, device manufacturer, instruction system; determining the data exchange protocol based on the identification information; and sending the target data message to the gateway device corresponding to the identification information through the data exchange protocol.
[0010] Optionally, the method also includes: the server is connected to multiple types of gateway devices through a device access cluster, wherein the device access cluster is used to receive and send messages from the gateway device, the device access cluster supports multiple data transmission protocols, and each type of gateway device uses a different data transmission protocol.
[0011] Optionally, the method further includes: in the process of converting the control instruction into the target data message, the server monitors all converted links and returns the link that fails to be converted to the target account.
[0012] According to another aspect of an embodiment of the present application, a gateway instruction conversion device is also provided, including: an acquisition module, used to obtain a control instruction sent by a target account through a terminal device from a message cluster, wherein the control instruction is used to control a smart device; a determination module, used to determine a message template corresponding to the identification information based on the identification information in the control instruction, wherein the identification information is used to indicate the device manufacturer of the device to be controlled; a conversion module, used to convert the control instruction into a target data message based on the message template, wherein the target data message is a message in a data format supported by the gateway device corresponding to the device manufacturer; and a sending module, used to send the target data message to the gateway device corresponding to the identification information.
[0013] According to another aspect of the embodiment of the present application, an electronic device is also provided, including: a memory for storing program instructions; a processor, connected to the memory, for executing program instructions to implement the following functions: obtaining control instructions sent by a target account through a terminal device from a message cluster, wherein the control instructions are used to control smart devices; determining a message template corresponding to the identification information based on identification information in the control instructions, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; converting the control instructions into a target data message based on the message template, wherein the target data message is a message in a data format supported by a gateway device corresponding to the device manufacturer; and sending the target data message to the gateway device corresponding to the identification information.
[0014] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned gateway instruction conversion method by running the computer program.
[0015] In an embodiment of the present application, control instructions sent by a target account through a terminal device are obtained from a message cluster, wherein the control instructions are used to control smart devices; based on identification information in the control instructions, a message template corresponding to the identification information is determined, wherein the identification information is used to indicate the device manufacturer of the device to be controlled; based on the message template, the control instructions are converted into a target data message, wherein the target data message is a message in a data format supported by a gateway device corresponding to the device manufacturer; the target data message is sent to a gateway device corresponding to the identification information, thereby achieving the purpose of unified management of the instruction systems corresponding to each device manufacturer, thereby achieving the technical effect of converting device control instructions into data messages that can be recognized by the gateway devices corresponding to each device manufacturer, thereby solving the technical problem in the prior art that each smart control manufacturer has formulated its own gateway docking protocol and device instruction system, and when using devices produced by multiple manufacturers, it is impossible to achieve unified management of the instruction systems of different devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1a It is a schematic diagram of a command exchange in the prior art;
[0018] Figure 1b It is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a method for converting a gateway instruction according to an embodiment of the present application;
[0019] Figure 2 is a flow chart of a gateway instruction conversion method according to an embodiment of the present application;
[0020] Figure 3a This is a flow chart of instruction conversion of a smart device according to an embodiment of the present application;
[0021] Figure 3b is a flow chart of an instruction translator according to an embodiment of the present application;
[0022] Figure 3c is a flow chart of an instruction conversion process according to an embodiment of the present application;
[0023] Figure 4 It is a structural diagram of a gateway instruction conversion device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] In related technologies, such as Figure 1a As shown in the figure, the control end exchanges commands with different manufacturers (i.e., equipment manufacturers) through various methods such as WEB, APP, and mini-programs. Different manufacturers use different data exchange protocols (JSON, XML, TOML), and different manufacturers use different gateway command systems. Figure 1aFor example, the gateway of manufacturer A uses the TOML data exchange protocol to realize the intelligent control of air conditioners, televisions, lights, and curtains; the gateway of manufacturer B uses the XML data exchange protocol to realize the intelligent control of air conditioners, televisions, lights, and curtains; the gateway of manufacturer C uses the JSON data exchange protocol to realize the intelligent control of air conditioners, televisions, lights, curtains, etc. The problem existing in the related art is that it is impossible to realize the unified management of the command system of different device gateways. Therefore, in order to form a unified gateway device command system, provide a unified control service to the control end, and facilitate the rapid access of device manufacturers to the platform, the embodiment of the present application uses a platform-based gateway command translation technology. This technology is based on the self-developed gateway command translator of the Spring Cloud microservice architecture. The gateway command translator realizes high-concurrency command distribution, multiple data exchange protocol (JSON, XML, TOML) adapters, and command translation functions on the platform side. The service processing adopts the highly available and scalable asynchronous event-driven network application framework Netty. The efficient network model improves the processing capability, and adopts fuses and link monitoring to ensure the stability of application requests. The following is a detailed description.
[0027] The gateway instruction conversion method embodiment provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1b The hardware structure block diagram of a computer terminal (or electronic device) for implementing a gateway instruction conversion method is shown. Figure 1b As shown, the computer terminal 10 (or electronic device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1b The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1b More or fewer components as shown, or with Figure 1b Different configurations shown.
[0028] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or electronic device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0029] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the conversion method of the gateway instruction in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the conversion method of the gateway instruction described above is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0030] The transmission module 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or electronic device).
[0032] It should be noted that, in some optional embodiments, the above Figure 1b The computer device (or electronic device) shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 1bThis is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the above-described computer device (or electronic device).
[0033] In the above operating environment, an embodiment of the present application provides an embodiment of a method for converting a gateway instruction. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] Figure 2 is a flow chart of a method for converting a gateway instruction according to an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:
[0035] Step S202, obtaining a control instruction sent by the target account through the terminal device from the message cluster, wherein the control instruction is used to control the smart device;
[0036] Step S204, determining a message template corresponding to the identification information according to the identification information in the control instruction, wherein the identification information is used to indicate the device manufacturer of the device to be controlled;
[0037] Step S206, converting the control instruction into a target data message according to the message template, wherein the target data message is a message in a data format supported by the gateway device corresponding to the device manufacturer;
[0038] Step S208: Send the target data message to the gateway device corresponding to the identification information.
[0039] In the above steps S202 to S208, the platform side uniformly manages different data exchange protocols (JSON, XML, TOML) of the gateway devices of each equipment manufacturer and the message templates carrying different equipment instruction systems, thereby achieving the technical effect of converting the equipment control instructions into data messages that can be recognized by the gateway devices corresponding to each equipment manufacturer, thereby solving the technical problem in the prior art that each intelligent control manufacturer has formulated a set of its own gateway docking protocols and equipment instruction systems, and when using equipment produced by multiple manufacturers, it is impossible to achieve unified management of the instruction systems of different devices.
[0040] In order to make the intelligent control platform compatible with the command systems of different equipment manufacturers and adapt to different gateway data exchange protocols (JSON, XML, TOML), the command translator (used to convert commands) is developed based on the Spring Cloud microservice architecture, using Nginx + self-developed gateway to receive high-concurrency http command issuance requests, and using the high-throughput distributed publish-subscribe messaging system Kafka to cache command messages in the message queue for business decoupling. The highly available, scalable, asynchronous, event-driven network application framework Netty based on the JAVA NIO model is used to achieve efficient and stable protocol adaptation and command translation. SpringCloud Sleuth + Twitter Zipkin are used for link monitoring to ensure the stability of application requests.
[0041] like Figure 3a In the command conversion flow chart of the smart device shown, when the customer control platform exchanges data with gateways of multiple manufacturers, for example, the customer control platform exchanges data or commands with manufacturers A, B, C, etc., wherein the gateway of manufacturer A uses the TOML data exchange protocol to realize intelligent control of air conditioners, televisions, lights, and curtains; the gateway of manufacturer B uses the XML data exchange protocol to realize intelligent control of air conditioners, televisions, lights, and curtains; the gateway of manufacturer C uses the JSON data exchange protocol to realize intelligent control of air conditioners, televisions, lights, and curtains, etc. The command exchange process is all carried out through the smart device command translator (or converter) to realize protocol adaptation and command conversion between different manufacturers, which can save docking costs, form a unified device command system, and provide unified control services to the control end.
[0042] In step S202 of the above-mentioned gateway instruction conversion method, before obtaining the control instruction sent by the target account through the terminal device from the message cluster, the method also includes the following steps: verifying the authority information of the target account to log in to the terminal device to obtain a verification result; if the verification result indicates that the target account has control authority, storing the control instruction in the message cluster; if the verification result indicates that the target account does not have control authority, refusing to store the control instruction in the message cluster.
[0043] In the embodiment of the present application, the user issues unified device instructions such as device switches (i.e., the above-mentioned control instructions) by logging into a web page or WeChat applet account, and after the system authentication distribution service, the message is stored in the Kafka cluster (i.e., the above-mentioned message cluster). Specifically, when the verification result obtained by the system through authentication indicates that the account logged in by the user does not have control authority, the above-mentioned control instructions will not be stored in the Kafka cluster. When the verification result obtained by the system through authentication indicates that the account logged in by the user has control authority, the above-mentioned control instructions will be stored in the Kafka cluster. The messageHandler of the device instruction translator reads messages from the Kafka message queue, translates the instructions into corresponding instructions according to different device manufacturers, and then converts the instructions into corresponding data exchange messages according to the data exchange protocols of different manufacturers, and sends the device instruction messages to the corresponding gateway devices of the device manufacturers through the device access cluster.
[0044] like Figure 3b In the flowchart of the command translator shown in Figure 1, users interact with the Nginx cluster through the client on their computers or mobile phones. The Nginx cluster is a high-performance HTTP and reverse proxy web server that is mainly responsible for front-end load balancing. The Nginx cluster uses authentication and distribution services to identify the legitimacy of the caller, authenticate the front-end messages, and store the verified messages or commands in the Kafka cluster. The Kafka cluster is used to decouple services from the command translator, provide message forwarding services, and reduce traffic peaks. The device command translator reads messages from the Kafka message queue and sends them to multiple Netty services (such as Figure 3b Netty service 1, Netty service 2, and Netty service 3) in the cluster realize efficient command translation and complete protocol adaptation. Through device access to the cluster, the device command message is sent to gateway devices of different manufacturers through different communication protocols, such as data interaction with gateway devices of manufacturer A through HTTP protocol, data interaction with gateway devices of manufacturer B through MQTT protocol, and data interaction with gateway devices of manufacturer C through TCP protocol. In addition, in the above process, link monitoring is always performed through Zipkin to ensure the stability of application requests.
[0045] It should be noted that Figure 3b The device access cluster in the system maintains a long link with gateway devices from different manufacturers to send and receive device messages, supporting TCP, HTTP, MQTT and other protocols. The device command translator is based on the JAVA NIO model, with a highly available, scalable, asynchronous, event-driven network application framework Netty, to achieve efficient and stable data exchange protocol adaptation and command translation.
[0046] In step S202 of the above-mentioned gateway instruction conversion method, after obtaining the control instructions sent by the target account through the terminal device from the message cluster, the method also includes the following steps: generating a target channel for receiving control instructions, and distributing an instruction interface for each control instruction, wherein the instruction interface is used to trigger an operation event for the control instruction; calling the target interface to convert the control instructions in the target channel to obtain a conversion result; monitoring the conversion result by monitoring the event, and returning the conversion result.
[0047] Figure 3c is a flowchart of an instruction conversion process according to an embodiment of the present application. Figure 3c In the process, the NioChannel of the device instruction translator obtains the pending messages or instructions from the message queue in the Kafka cluster, distributes the messages to the processor, such as performing message processing through multiple MessageHandlers in EventLoop, obtains the instruction configuration template according to the manufacturer of the device, generates the device instruction, translates the device instruction into instructions recognizable by different manufacturers (such as manufacturer A, manufacturer B, manufacturer C) through the instruction translator, obtains the data message template according to the device manufacturer of the device to be controlled, generates the data message, and encapsulates the data message. For example, the message can be encapsulated into XML format, CSON format, JSON format, etc., and establishes a connection according to the communication protocol of different devices, and issues instructions. For example, the device instruction can be issued through the HTTP protocol, the MQTT protocol, or the TCP protocol.
[0048] In the embodiment of the present application, the core of the instruction translator is based on the platform side to distribute and process instruction messages, translate instructions for different manufacturers, and encapsulate messages for different data exchange protocols (JSON, XML, TOML). In the above message distribution process, the message distribution is implemented using the open source architecture Netty, and a Channel (i.e., the above target channel) is generated through NioServerSocketChannel (channel-based socket listener) to receive device instructions (i.e., the above control instructions). NioEventLoop distributes tasks to ChannelPipeline for the received messages, and then calls a specific ChannelHandler for instruction translation processing. ChannelFuture will register monitoring events through ChannelFutureListener. When the operation is executed successfully or failed, the monitoring will automatically trigger the return result.
[0049] In step S206 of the above-mentioned gateway instruction conversion method, the control instruction is converted into a target data message, which specifically includes the following steps: initializing multiple types of instruction systems, wherein each type of instruction system corresponds to a type of identification information; obtaining the identification information in the control instruction; based on the identification information, determining the target instruction system to be converted from the multiple types of instruction systems, wherein the target instruction system includes a message template corresponding to the identification information; based on the target instruction system, converting the control instruction into a target data message.
[0050] In the embodiment of the present application, the instruction translation is implemented based on Netty's ChannelHandler. When the service module is started, the instruction system information of various equipment manufacturers is initialized. When the device is issued, the type of controlled device is first determined to obtain the corresponding FactoryCommand (such as lights, televisions, air conditioners), and then the instruction system information FactoryConfig (that is, the system corresponding to different manufacturers) is obtained through the equipment manufacturer. During translation, the Handler dynamically converts the instruction system information such as FactoryCommand and FactoryConfig to generate device instructions related to specific manufacturers.
[0051] The above process is explained through the following example:
[0052] Example: Unified Command System - Lights - On
[0053] Input (the content of the input is the above-mentioned control instruction, which can also be called the control instruction system):
[0054] Bean.deviceId = 539a3364e3ac68a06c4a5bd10dd077d0 / / device id
[0055] Bean.deviceType = 4 / / Device type: 1-air conditioner, 2-curtain, 3-TV, 4-light / switch, 5-door lock, 6-background music, 7-service request, 8-virtual scene, 9-adjustable light
[0056] Bean.deviceSource = 1 / / Device source (i.e. the above identification information)
[0057] Bean.operationType = 1 / / Operation instruction: open 1, close 2
[0058] If the identification information indicates manufacturer A, the device of manufacturer A will output:
[0059] Bean.deviceId = 539a3364e3ac68a06c4a5bd10dd077d0 / / device id
[0060] Bean.command = switch / / instruction type
[0061] Bean.params.power=on / / operation instruction
[0062] It can be seen from the message template corresponding to the above manufacturer A that the instruction system corresponding to the manufacturer A includes device ID, instruction type, and operation instruction.
[0063] If the identification information indicates manufacturer B, the device of manufacturer B will output:
[0064] Bean.id = 539a3364e3ac68a06c4a5bd10dd077d0 / / device id
[0065] Bean.operation=0100 / / operation instruction type
[0066] Bean.value=01001 / / operation instruction
[0067] It can be seen from the message template corresponding to the manufacturer B that the instruction system corresponding to the manufacturer B includes the device ID, the operation instruction type, and the operation instruction, and it can be seen from the content of the template that the instruction language or instruction format used by the manufacturer B is different from that of the manufacturer A. It should be noted that the message templates corresponding to the manufacturers A and B are only for illustration and are not intended to be limiting, and the specific content of the message templates can be adjusted according to actual conditions.
[0068] In step S208 of the above-mentioned gateway instruction conversion method, the target data message is sent to the gateway device corresponding to the identification information, which specifically includes the following steps: obtaining the target data message and the identification information, wherein the target data message includes at least one of the following: device ID, instruction type, device manufacturer, instruction system; determining the data exchange protocol based on the identification information; and sending the target data message to the gateway device corresponding to the identification information through the data exchange protocol.
[0069] In the embodiment of the present application, the message encapsulation implementation refers to message encapsulation for different data exchange protocols (JSON, XML, TOML). By obtaining the result after Handler processing, it is passed to the message processing class RequestMessageHandler, and the processing class calls the message generator MessageGenerate to generate an instruction sending message message. The message generator MessageGenerate generates instruction sending messages for different data exchange protocols (JSON, XML, TOML) according to information data such as equipment manufacturer, instruction type, and instruction system.
[0070] The following is an introduction to different data exchange protocols:
[0071] JSON: JSON (JavaScript Object Notation) is a lightweight data exchange format that is easy to read and write. It can exchange data between multiple languages and is easy for machines to parse and generate.
[0072] TOML: Allows you to define deeply nested data structures in a fairly quick and concise way. Compared to JSON, TOML supports more data types, such as multi-line strings, automatic escaping of reserved characters, dates, times, integers, floating-point numbers, scientific notation, and "table extensions".
[0073] XML: XML generally refers to Extensible Markup Language, a subset of Standard Generalized Markup Language, referred to as XML, which is a markup language used to mark electronic files to make them structured. In electronic computers, tags refer to information symbols that can be understood by computers. Through such tags, computers can process various information, such as articles.
[0074] For example, input for equipment from manufacturer A:
[0075] Bean.deviceId = 539a3364e3ac68a06c4a5bd10dd077d0 / / device id
[0076] Bean.command = switch / / instruction type
[0077] Bean.params.power=on / / operation instruction
[0078] A manufacturer's equipment - output (JSON data exchange protocol):
[0079]
[0080] B Manufacturer Equipment - Input:
[0081] Bean.id = 539a3364e3ac68a06c4a5bd10dd077d0 / / device id
[0082] Bean.operation=0100 / / operation instruction type
[0083] Bean.value=01001 / / operation instruction
[0084] B manufacturer's equipment - output (XML data exchange protocol):
[0085]
[0086] After converting the instructions into data packets corresponding to different data exchange protocols, the converted instructions or data packets are sent to the corresponding gateway device of the device manufacturer. The instruction sending is implemented based on Netty's NioServerChannel. When the service module is started or the device is powered on, a communication connection will be established between each other. The connection is initialized according to different communication protocols (HTTP, MQTT, TCP) and saved to the connection pool NioEventLoop. When the instruction needs to be sent, the Handler is obtained from NioEventLoop to send the instruction to the device, thereby achieving the effect of decoupling device connection and message processing service, message transfer service, message sending and traffic peak shaving.
[0087] In the above-mentioned gateway instruction conversion method, the method also includes the following steps: the server is connected to multiple types of gateway devices through a device access cluster, wherein the device access cluster is used to receive and send messages from the gateway device, and the device access cluster supports multiple data transmission protocols, and each type of gateway device uses a different data transmission protocol.
[0088] In the above gateway instruction conversion method, the method also includes the following steps: in the process of converting the control instruction into the target data message, the server monitors all converted links and returns the links that failed to be converted to the target account. Specifically, link monitoring is performed through Zipkin to ensure the stability of application requests.
[0089] The gateway command conversion method provided in the embodiment of the present application has the following advantages: 1. The command translator unifies the command systems of all equipment manufacturers, and there is no need for the control end (app, mini-program, web end, third-party operator) to adapt to various manufacturer command systems; 2. For different interface data exchange protocols, automatic conversion is performed according to the command system information; 3. It is convenient for equipment manufacturers to quickly access.
[0090] The gateway command conversion method provided in the embodiment of the present application can be applied to the customer control platform. The customer control platform is based on a device command translator, and provides a unified command control system to the upper side (app, mini-program, web side, third-party operators). It has been connected to multiple device manufacturers downward, and can achieve rapid access through a small amount of development, import configuration information and modules.
[0091] Figure 4 is a structural diagram of a gateway instruction conversion device according to an embodiment of the present application, such as Figure 4 As shown, the device comprises:
[0092] The acquisition module 402 is used to acquire the control instruction sent by the target account through the terminal device from the message cluster, wherein the control instruction is used to control the smart device;
[0093] The determination module 404 is used to determine a message template corresponding to the identification information according to the identification information in the control instruction, wherein the identification information is used to indicate the device manufacturer of the device to be controlled;
[0094] The conversion module 406 is used to convert the control instruction into a target data message according to the message template, wherein the target data message is a message in a data format supported by the gateway device corresponding to the device manufacturer;
[0095] The sending module 408 is used to send the target data message to the gateway device corresponding to the identification information.
[0096] In the acquisition module in the conversion device of the above-mentioned gateway instruction, before obtaining the control instruction sent by the target account through the terminal device from the message cluster, the acquisition module is also used to verify the authority information of the target account to log in to the terminal device to obtain a verification result; when the verification result indicates that the target account has control authority, the control instruction is stored in the message cluster; when the verification result indicates that the target account does not have control authority, the control instruction is refused to be stored in the message cluster.
[0097] In the acquisition module in the conversion device of the above-mentioned gateway instructions, after obtaining the control instructions sent by the target account through the terminal device from the message cluster, the acquisition module is also used to generate a target channel for receiving the control instructions, and distribute an instruction interface for each control instruction, wherein the instruction interface is used to trigger an operation event for the control instruction; call the target interface to convert the control instructions in the target channel to obtain a conversion result; listen to the conversion result by listening to the event, and return the conversion result.
[0098] In the conversion module in the conversion device of the above-mentioned gateway instruction, the control instruction is converted into a target data message, which specifically includes the following processes: initializing multiple types of instruction systems, wherein each type of instruction system corresponds to a type of identification information; obtaining the identification information in the control instruction; based on the identification information, determining the target instruction system to be converted from the multiple types of instruction systems, wherein the target instruction system contains a message template corresponding to the identification information; based on the target instruction system, converting the control instruction into a target data message.
[0099] In the sending module in the conversion device of the above-mentioned gateway instruction, the target data message is sent to the gateway device corresponding to the identification information, which specifically includes the following process: obtaining the target data message and the identification information, wherein the target data message includes at least one of the following: device ID, instruction type, device manufacturer, instruction system; determining the data exchange protocol based on the identification information; and sending the target data message to the gateway device corresponding to the identification information through the data exchange protocol.
[0100] In the conversion device of the above-mentioned gateway instructions, the conversion device also includes a processing module 410, which is used to connect to multiple types of gateway devices through a device access cluster, wherein the device access cluster is used to receive and send messages from the gateway device, and the device access cluster supports multiple data transmission protocols, and each type of gateway device uses a different data transmission protocol.
[0101] In the processing module in the above-mentioned gateway instruction conversion device, the processing module is also used to monitor all converted links during the process of converting the control instruction into the target data message, and return the link that failed to be converted to the target account.
[0102] It should be noted that Figure 4 The gateway instruction conversion device shown is used to execute Figure 2 The conversion method of the gateway instruction shown in the figure, therefore the relevant explanations in the above-mentioned conversion method of the gateway instruction are also applicable to the conversion device of the gateway instruction, and will not be repeated here.
[0103] An embodiment of the present application also provides a non-volatile storage medium, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the following gateway instruction conversion method by running the computer program: obtaining a control instruction sent by a target account through a terminal device from a message cluster, wherein the control instruction is used to control a smart device; determining a message template corresponding to the identification information based on identification information in the control instruction, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; converting the control instruction into a target data message based on the message template, wherein the target data message is a message in a data format supported by a gateway device corresponding to the device manufacturer; and sending the target data message to a gateway device corresponding to the identification information.
[0104] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0105] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0106] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0107] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0108] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0109] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0110] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A gateway instruction conversion method, characterized in that: include: Obtaining a control instruction sent by a target account through a terminal device from a message cluster, wherein the control instruction is used to control a smart device; Determine, according to the identification information in the control instruction, a message template corresponding to the identification information, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; According to the message template, converting the control instruction into a target data message, wherein the target data message is a message in a data format supported by the gateway device corresponding to the device manufacturer; Sending the target data message to the gateway device corresponding to the identification information; After obtaining the control instructions sent by the target account through the terminal device from the message cluster, the method also includes: generating a target channel for receiving the control instructions, and distributing an instruction interface for each control instruction, wherein the instruction interface is used to trigger an operation event for the control instruction; calling the target interface to convert the control instructions in the target channel to obtain a conversion result; monitoring the conversion result by monitoring events, and returning the conversion result.
2. The method according to claim 1, characterized in that: Before obtaining the control instruction sent by the target account through the terminal device from the message cluster, the method further includes: Verify the target account's permission information for logging into the terminal device, and obtain a verification result; If the verification result indicates that the target account has control authority, storing the control instruction in the message cluster; When the verification result indicates that the target account does not have the control authority, the control instruction is refused to be stored in the message cluster.
3. The method according to claim 1, characterized in that Converting the control instruction into a target data message includes: Initialize multiple types of instruction systems, where each type of instruction system corresponds to a type of identification information; Obtaining identification information in the control instruction; According to the identification information, determining a target instruction system to be converted from the multiple instruction systems, wherein the target instruction system includes a message template corresponding to the identification information; According to the target instruction system, the control instruction is converted into the target data message.
4. The method according to claim 3, characterized in that Sending the target data message to a gateway device corresponding to the identification information includes: Acquire the target data message and the identification information, wherein the target data message includes at least one of the following: device ID, instruction type, device manufacturer, and instruction system; Determining a data exchange protocol based on the identification information; The target data message is sent to the gateway device corresponding to the identification information through the data exchange protocol.
5. The method according to claim 1, characterized in that The method also includes: the server is connected to multiple types of gateway devices through a device access cluster, wherein the device access cluster is used to receive and send messages from the gateway devices, the device access cluster supports multiple data transmission protocols, and each type of gateway device uses a different data transmission protocol.
6. The method according to claim 1, characterized in that The method further includes: in the process of converting the control instruction into the target data message, the server monitors all converted links and returns the links that fail to be converted to the target account.
7. A gateway instruction conversion device, characterized in that: include: An acquisition module, used to acquire a control instruction sent by a target account through a terminal device from a message cluster, wherein the control instruction is used to control a smart device; A determination module, configured to determine a message template corresponding to the identification information according to the identification information in the control instruction, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; A conversion module, used to convert the control instruction into a target data message according to the message template, wherein the target data message is a message in a data format supported by the gateway device corresponding to the device manufacturer; A sending module, used for sending the target data message to a gateway device corresponding to the identification information; The acquisition module is also used to generate a target channel for receiving the control instruction, and distribute an instruction interface for each control instruction, wherein the instruction interface is used to trigger an operation event for the control instruction; call the target interface to convert the control instruction in the target channel to obtain a conversion result; monitor the conversion result through a monitoring event, and return the conversion result.
8. An electronic device, characterized in that: include: A memory for storing program instructions; A processor, connected to the memory, is used to execute program instructions that implement the following functions: obtaining control instructions sent by a target account through a terminal device from a message cluster, wherein the control instructions are used to control smart devices; determining a message template corresponding to the identification information based on identification information in the control instructions, wherein the identification information is used to indicate a device manufacturer of the device to be controlled; converting the control instructions into a target data message based on the message template, wherein the target data message is a message in a data format supported by a gateway device corresponding to the device manufacturer; sending the target data message to a gateway device corresponding to the identification information; after obtaining the control instructions sent by a target account through a terminal device from a message cluster, it also includes: generating a target channel for receiving the control instructions, and distributing a command interface for each control instruction, wherein the command interface is used to trigger an operation event for the control instruction; calling a target interface to convert the control instructions in the target channel to obtain a conversion result; monitoring the conversion result by monitoring events, and returning the conversion result.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the gateway instruction conversion method described in any one of claims 1 to 6 by running the computer program.
Citation Information
Patent Citations
Configurable internet of things gateway protocol conversion method
CN108040051A
Configuration management method, apparatus and device
CN109391500A
Gateway resource updating method and device and Internet of Things control platform
CN111835842A
Gateway equipment and information transmission method and device
CN113259231A
Equipment control method and device, storage medium and electronic device
CN115356937A
