MQTT protocol-based direct acquisition data transmission method, system and device, and medium

By adopting the direct acquisition data transmission method based on the MQTT protocol in the household distributed photovoltaic project, the problem of inconsistent data transmission is solved, the data access efficiency and security are improved, and the needs of operation and maintenance monitoring and data analysis and calculation are met.

CN119728269APending Publication Date: 2025-03-28HUANENG NINGXIA ENERGY CO LTD LINGWULONGQIAO BRANCH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411929043.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the prior art, the data transmission methods and formats of household distributed photovoltaic projects are not uniform, resulting in low data access efficiency and inability to meet scenarios such as operation and maintenance monitoring and data analysis and calculation.

Method used

Using the direct data transmission method based on the MQTT protocol, the client encrypts the data by obtaining the secret key information, and sends the encrypted data to the specified topic, and the server receives and decrypts the data and sends it to production.

Benefits of technology

It improves data access efficiency, meets the needs of operation and maintenance monitoring and data analysis and calculation, and ensures data security through encryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728269A_ABST
    Figure CN119728269A_ABST
Patent Text Reader

Abstract

The invention discloses a direct acquisition data transmission method, system and device based on an MQTT protocol, and a medium, and the method comprises the steps: when a client side transmits data, the client side obtains secret key information from a local cache, encrypts the data to be transmitted through employing a preset encryption rule, and transmits the encrypted data to top: real Data according to a standard code specification; the server is connected with a subscription: real Data, receives the real-time data, decrypts the real-time data by using the secret key, and then sends the decrypted real-time data to the production, and the method, the system, the equipment and the medium improve the data access efficiency, and meet the requirements of operation and maintenance monitoring and data analysis and calculation scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data acquisition and relates to a method, system, device and medium for direct data transmission based on the MQTT protocol. Background Art

[0002] In the entire power generation system, power data runs through all aspects of the power industry, accelerating the green and low-carbon development of urban and rural construction, and the rapid development of household distributed photovoltaic industry in new rural construction. Household distributed photovoltaic projects have problems such as inconsistent construction standards, functional consistency and low degree of standardization under different construction manufacturers. Among them, the problem of inconsistent data transmission methods and formats is particularly serious, resulting in low data access efficiency and cannot meet scenarios such as operation and maintenance monitoring and data analysis and calculation. Summary of the invention

[0003] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a direct data transmission method, system, device and medium based on the MQTT protocol. The method, system, device and medium improve the data access efficiency and meet the needs of operation and maintenance monitoring and data analysis and computing scenarios.

[0004] To achieve the above object, the present invention discloses a direct data transmission method based on the MQTT protocol, comprising:

[0005] When the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rules to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification;

[0006] The server subscribes to topic:realData, receives real-time data, decrypts the real-time data using the secret key, and then sends it to production.

[0007] The further improvement of the direct data transmission method based on the MQTT protocol of the present invention is:

[0008] Furthermore, when the client sends data, before obtaining the key information from the local cache, it also includes:

[0009] Establish the connection between the client and the server, and agree on the rules for constructing client_id;

[0010] When the server detects a connection request, it parses the client_id according to the connection request and generates a random key, then uses the preset encryption rule to encrypt the request body to be sent and sends it to topic:In, and caches the generated random key on the server;

[0011] The server encrypts the random key and sends the encrypted key to topic: In;

[0012] The client subscribes to topic:In, uses the preset encryption rule to parse the response body corresponding to the request body, and then caches the secret key in the parsing result locally.

[0013] Furthermore, the rule for constructing client_id is: Client_id is a timestamp generated by version_owner_sn_client.

[0014] Furthermore, the preset encryption rule is: converting the timestamp into a byte array, and taking the first 8 bytes of the byte array to encrypt the information to be encrypted.

[0015] The present invention discloses a direct data transmission system based on the MQTT protocol, comprising:

[0016] The sending module is used for when the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rule to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification;

[0017] The receiving module is used for the server to subscribe to topic:realData, receive real-time data, decrypt the real-time data using the secret key, and then send it to the production.

[0018] The further improvement of the direct data transmission system based on the MQTT protocol of the present invention is:

[0019] Furthermore, it also includes:

[0020] Create a module to establish the connection between the client and the server, and agree on the rules for constructing client_id;

[0021] The first encryption module is used for parsing the client_id according to the connection request and generating a random key when the server detects a connection request, and then encrypting the request body to be sent using the preset encryption rule and sending it to topic:In, and caching the generated random key on the server;

[0022] The second encryption module is used for the server to encrypt the random key and send the encrypted key to topic: In;

[0023] The parsing module is used for the client to subscribe to topic:In, parse the response body corresponding to the request body using the preset encryption rule, and then cache the secret key in the parsing result locally.

[0024] Furthermore, the rule for constructing client_id is: Client_id is a timestamp generated by version_owner_sn_client.

[0025] Furthermore, the preset encryption rule is: converting the timestamp into a byte array, and taking the first 8 bytes of the byte array to encrypt the information to be encrypted.

[0026] The present invention discloses a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the direct data transmission method based on the MQTT protocol are implemented.

[0027] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the direct data transmission method based on the MQTT protocol are implemented.

[0028] The present invention has the following beneficial effects:

[0029] In the specific operation of the direct data transmission method, system, device and medium based on the MQTT protocol described in the present invention, the server subscribes to topic:realData, receives real-time data, decrypts the real-time data with a secret key, and then sends it to production, that is, based on the MQTT client-server message publishing / subscription transmission protocol, the data access efficiency is improved to meet the needs of operation and maintenance monitoring and data analysis and computing scenarios. In addition, the message is transmitted in an encrypted manner to ensure the security of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:

[0031] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] In the description of the present invention, it should be understood that the terms “include” and “comprises” indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.

[0034] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0035] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects are in an "or" relationship.

[0036] It should be understood that, although the terms first, second, third, etc. may be used to describe preset ranges, etc. in the embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are only used to distinguish preset ranges from each other. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.

[0037] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can usually be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0039] Various structural schematic diagrams of the embodiments disclosed in the present invention are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.

[0040] Embodiment 1

[0041] refer to Figure 1 The MQTT protocol-based direct data transmission method of the present invention comprises the following steps:

[0042] 1) Establish a connection between the client and the server. When establishing the connection, agree on the rules for constructing the client_id, where the client_id is a timestamp generated by the version_owner_sn_client;

[0043] 2) When the server detects a connection request, it parses the client_id according to the connection request, generates a random key locally, encrypts the request body to be sent according to the preset encryption rules, sends the decrypted request body to topic:In, and caches the generated random key on the server;

[0044] The preset encryption rule is: convert the timestamp into a byte array, and take the first 8 bytes of the byte array to encrypt the request body to be sent to topic:In;

[0045] 3) The server encrypts the random key and then sends the encrypted key to topic: In;

[0046] 4) The client subscribes to topic:In, uses the preset encryption rules to parse the response body corresponding to the request body, and then caches the secret key in the parsed result locally;

[0047] 5) When the client sends data, it obtains the key information from the local cache, and uses the preset encryption rules to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification;

[0048] 6) The server subscribes to topic:realData, receives real-time data, decrypts the real-time data using the secret key, and then sends it to production for business use and power indicator analysis and prediction scenarios.

[0049] It should be noted that the present invention transmits distributed photovoltaic data of different construction manufacturers in a standard transmission format according to a standard transmission protocol to improve data access efficiency and data access quality to meet scenarios such as data monitoring and analysis and calculation. Technically, the present invention is based on the MQTT client-server message publishing / subscription transmission protocol, and transmits messages in an encrypted manner to ensure data security.

[0050] Embodiment 2

[0051] The MQTT protocol-based direct data transmission system of the present invention includes:

[0052] Create a module to establish the connection between the client and the server, and agree on the rules for constructing client_id;

[0053] The first encryption module is used for parsing the client_id according to the connection request and generating a random key when the server detects a connection request, and then encrypting the request body to be sent using the preset encryption rule and sending it to topic:In, and caching the generated random key on the server;

[0054] The second encryption module is used for the server to encrypt the random key and send the encrypted key to topic: In;

[0055] The parsing module is used for the client to subscribe to topic:In, parse the response body corresponding to the request body using the preset encryption rule, and then cache the secret key in the parsing result locally;

[0056] The sending module is used for when the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rule to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification;

[0057] The receiving module is used for the server to subscribe to topic:realData, receive real-time data, decrypt the real-time data using the secret key, and then send it to the production.

[0058] In this embodiment, the rule for constructing client_id is: Client_id is a timestamp generated by version_owner_sn_client.

[0059] In this embodiment, the preset encryption rule is: converting the timestamp into a byte array, and taking the first 8 bytes of the byte array to encrypt the information to be encrypted.

[0060] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0061] Embodiment 3

[0062] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for direct data transmission based on the MQTT protocol are implemented, for example, including: establishing a connection between a client and a server, and agreeing on a rule for constructing a client_id; when the server detects a connection request, parsing the client_id according to the connection request, generating a random key, and then using the preset encryption rule to encrypt the request body to be sent and send it to topic:In, while caching the generated random key on the server; the server The client encrypts the random key and sends the encrypted key to topic: In; the client subscribes to topic: In, uses the preset encryption rule to parse the response body corresponding to the request body, and then caches the key in the parsing result locally; when the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rule to encrypt the data to be sent, and then sends the encrypted data to topic: realData according to the standard code specification; the server subscribes to topic: realData, receives real-time data, and uses the key to decrypt the real-time data, and then sends it to production. Among them, the memory may include memory, such as high-speed random access memory, and may also include non-volatile memory, such as at least one disk memory, etc.; the processor, network interface, and memory are interconnected through an internal bus, and the internal bus can be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard structure bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory is used to store programs. Specifically, the program can include program code, and the program code includes computer operation instructions. The memory can include memory and non-volatile memory, and provide instructions and data to the processor.

[0063] Embodiment 4

[0064] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the direct data transmission method based on the MQTT protocol, for example, including: establishing a connection between a client and a server, and agreeing on a rule for constructing a client_id; when the server detects a connection request, parsing the client_id according to the connection request, generating a random key, and then encrypting the request body to be sent by using the preset encryption rule and sending it to topic:In, while caching the generated random key on the server; the server encrypts the random key and sends the encrypted key to topic:In; the client subscribes to topic:In, parses the response body corresponding to the request body by using the preset encryption rule, and then caches the key in the parsing result locally; when the client sends data, the client obtains the key information from the local cache, encrypts the data to be sent by using the preset encryption rule, and then sends the encrypted data to topic:realData according to the standard code specification; the server subscribes to topic:realData, receives real-time data, decrypts the real-time data by using the key, and then sends it to production. Specifically, the computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. The volatile memory may include random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include read-only memory (ROM), hard disk, flash memory, optical disk, magnetic disk, etc.

[0065] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0066] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0067] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0068] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0069] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and disclosure of the invention. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0070] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

[0071] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A direct data transmission method based on the MQTT protocol, characterized in that: include: When the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rules to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification; The server subscribes to topic:realData, receives real-time data, decrypts the real-time data using the secret key, and then sends it to production.

2. The method for direct data transmission based on the MQTT protocol according to claim 1 is characterized in that: When the client sends data, before obtaining the key information from the local cache, it also includes: Establish the connection between the client and the server, and agree on the rules for constructing client_id; When the server detects a connection request, it parses the client_id according to the connection request and generates a random key, then encrypts the request body to be sent using the preset encryption rule and sends it to topic:In, and caches the generated random key on the server; The server encrypts the random key and sends the encrypted key to topic: In; The client subscribes to topic:In, uses the preset encryption rule to parse the response body corresponding to the request body, and then caches the secret key in the parsing result locally.

3. The method for direct data transmission based on the MQTT protocol according to claim 1 is characterized in that: The rule for constructing client_id is: Client_id is a timestamp generated by version_owner_sn_client.

4. The method for direct data transmission based on the MQTT protocol according to claim 1, characterized in that: The preset encryption rule is: convert the timestamp into a byte array, and take the first 8 bytes of the byte array to encrypt the information to be encrypted.

5. A direct data transmission system based on the MQTT protocol, characterized in that: include: The sending module is used for when the client sends data, the client obtains the key information from the local cache, and uses the preset encryption rule to encrypt the data to be sent, and then sends the encrypted data to topic:realData according to the standard code specification; The receiving module is used for the server to subscribe to topic:realData, receive real-time data, decrypt the real-time data using the secret key, and then send it to the production.

6. The MQTT protocol-based direct data transmission system according to claim 5 is characterized in that: Also includes: Create a module to establish the connection between the client and the server, and agree on the rules for constructing client_id; The first encryption module is used for parsing the client_id according to the connection request and generating a random key when the server detects a connection request, and then encrypting the request body to be sent using the preset encryption rule and sending it to topic:In, and caching the generated random key on the server; The second encryption module is used for the server to encrypt the random key and send the encrypted key to topic: In; The parsing module is used for the client to subscribe to topic:In, parse the response body corresponding to the request body using the preset encryption rule, and then cache the secret key in the parsing result locally.

7. The MQTT protocol-based direct data transmission system according to claim 5 is characterized in that: The rule for constructing client_id is: Client_id is a timestamp generated by version_owner_sn_client.

8. The MQTT protocol-based direct data transmission system according to claim 5 is characterized in that: The preset encryption rule is: convert the timestamp into a byte array, and take the first 8 bytes of the byte array to encrypt the information to be encrypted.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the direct data transmission method based on the MQTT protocol are implemented as described in any one of claims 1 to 4.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, the steps of the direct data transmission method based on the MQTT protocol as described in any one of claims 1 to 4 are implemented.