Equipment access method and device and Internet of Things system
By generating a protocol conversion file of the target data protocol, the messages of the device to be accessed are converted into messages under the specified data protocol, which solves the problem of rapid and efficient access of devices in the Internet of Things system and improves the convenience and scalability of the system.
Patent Information
- Application Number
- CN202411801332.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-18
AI Technical Summary
In IoT systems, devices use different network protocols and data protocols to access, resulting in the need to support multiple protocols. It is difficult for the existing technology to achieve fast and efficient access to devices, especially when new devices are accessed, it is necessary to customize the development protocol conversion file, resulting in poor convenience and scalability.
By generating a protocol conversion file corresponding to the target data protocol, based on the configuration information of the target data protocol, the message of the device to be accessed is converted into messages under the specified data protocol, thereby realizing fast access to the device.
There is no need to customize the development of protocol conversion files for each device, avoid downtime release, improve convenience and scalability, and achieve fast and efficient access to different types of devices.
Smart Images

Figure CN119652982A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a device access method, apparatus and Internet of Things system. Background Art
[0002] In the IoT system, there are many types of devices that need to be dealt with. These devices usually use different network protocols and data protocols to access the application end. Therefore, the IoT system needs to support each network protocol and data protocol to support the access of different devices.
[0003] Data protocols are usually customized by equipment manufacturers and there is no universal standard. Therefore, when a new type of device is connected, it is necessary to customize the protocol conversion file corresponding to the device and publish it offline. The convenience and scalability are poor, making it difficult to achieve fast and effective access to the device. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a device access method, device and Internet of Things system to solve the problem that it is difficult to achieve fast and effective access to devices in the prior art.
[0005] To achieve the above technical objectives, the present application provides the following technical solutions:
[0006] In a first aspect, an embodiment of the present specification provides a device access method, which is applied to a device access layer, including:
[0007] When the target data protocol corresponding to the device to be connected is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol is generated based on the configuration information corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes the configuration information required when converting a message under the target data protocol to a message under the specified data protocol;
[0008] Based on the protocol conversion file corresponding to the target data protocol, the message sent by the device to be connected is converted into a message under the specified data protocol, and the message under the specified data protocol is sent to the application end.
[0009] In one implementation, the configuration information corresponding to the target data protocol includes a message type, first information of a first attribute, second information of a second attribute, and a numerical conversion relationship between the first attribute and the second attribute; the first attribute includes an attribute in the target data protocol, the second attribute includes an attribute in the specified data protocol corresponding to the first attribute, and the message type represents a type of a message under the target data protocol;
[0010] The generating, based on the configuration information corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol, comprises:
[0011] Determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type;
[0012] Substitute the first information, the second information and the numerical conversion relationship into the target protocol conversion template to obtain a protocol conversion file corresponding to the target data protocol.
[0013] In one embodiment, the configuration information corresponding to the target data protocol also includes a target generation language of the protocol conversion file;
[0014] The determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type comprises:
[0015] Based on the message type and a predetermined correspondence between the protocol conversion template and the message type, determining the target protocol conversion template from the candidate protocol conversion templates under the target generation language;
[0016] The device access layer is used to execute protocol conversion files in different generation languages.
[0017] In one implementation, the configuration information corresponding to the target data protocol also includes a target value interval;
[0018] After obtaining the protocol conversion file corresponding to the target data protocol, the method further includes:
[0019] Based on the target value range, the value range of the second attribute is configured in the protocol conversion file corresponding to the target data protocol, and the value range of the second attribute is used to identify abnormalities of the target message; the target message includes a message under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol.
[0020] In one implementation, the configuration information corresponding to the target data protocol is obtained by:
[0021] In response to an input operation on the configuration information, configuration information corresponding to the target data protocol is obtained.
[0022] In one implementation, before converting the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes:
[0023] An execution resource is allocated to the protocol conversion file corresponding to the target data protocol, and the execution resource is used to execute the protocol conversion file corresponding to the target data protocol; wherein the execution resource is independent of the execution resource in the device access layer.
[0024] In one embodiment, each protocol conversion file in the device access layer includes device identification information;
[0025] Determining whether there is a protocol conversion file corresponding to the target data protocol includes:
[0026] Based on the matching result of the device identification information of the device to be accessed and the device identification information corresponding to each protocol conversion file in the device access layer, it is determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer.
[0027] In one implementation, before converting the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes:
[0028] Obtaining the target network protocol configured by the device to be accessed;
[0029] Based on the matching results of the target network protocol and the predetermined candidate network protocols, the access port of the device to be connected is determined; the access port is used to send and receive messages transmitted between the device to be connected and the application end based on the target network protocol.
[0030] In a second aspect, an embodiment of the present specification provides a device access apparatus, which is applied to a device access layer, including:
[0031] A first processing module is used for generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol when the target data protocol corresponding to the device to be connected is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes the configuration information required when converting a message under the target data protocol to a message under the specified data protocol;
[0032] The second processing module is used to convert the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, and send the message under the specified data protocol to the application end.
[0033] In a third aspect, an implementation of this specification provides an Internet of Things system, including a device access layer and an application end, wherein the device access layer is used to connect a device to be connected to the application end based on a device access method as described in any one of the above items.
[0034] In a fourth aspect, an embodiment of the present specification provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the device access method as described in any one of the above items is implemented.
[0035] In a fifth aspect, an embodiment of this specification provides a computer program product or a computer program, wherein the computer program product includes a computer program, and the computer program is stored in a computer-readable storage medium; the processor of the computer device reads the computer program from the computer-readable storage medium, and when the processor executes the computer program, it implements the device access method as described in any one of the above items.
[0036] It can be seen from the above technical scheme that the embodiment of the present application provides a device access method, device and Internet of Things system. When the target data protocol corresponding to the device to be accessed is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol, the method generates a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol, so as to convert the message sent by the device to be accessed into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol and then send it to the application end, wherein the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol, and the configuration information corresponding to the target data protocol includes the configuration information required for converting the message under the target data protocol into the message under the specified data protocol. Therefore, when a new type of device is accessed, a protocol conversion file can be automatically generated according to the configuration information corresponding to the target data protocol configured by the device, and the message sent by the device to be accessed can be converted into a message under the specified data protocol using the protocol conversion file. There is no need to customize and develop the protocol conversion file corresponding to the device, nor is there any need to shut down the protocol conversion file corresponding to the device for publishing. The convenience and scalability are significantly improved, thereby realizing fast and effective access of different types of devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0038] Figure 1 A flowchart of a device access method provided for an implementation of this specification.
[0039] Figure 2 A schematic diagram of the structure of a device access apparatus provided for an implementation manner of this specification.
[0040] Figure 3 A schematic diagram of the structure of an Internet of Things system provided for the implementation of this specification.
[0041] Figure 4 A schematic diagram of the structure of another Internet of Things system provided for the implementation of this specification. DETAILED DESCRIPTION
[0042] Unless otherwise defined, the technical terms or scientific terms used in the embodiments of this specification shall have the common meanings understood by persons with ordinary skills in the field to which this specification belongs. The words "first", "second" and similar words used in the embodiments of this specification do not indicate any order, quantity or importance, but are only used to avoid confusion of constituent elements.
[0043] Unless the context requires otherwise, throughout the specification, "plurality" means "at least two", and "including" is interpreted as an open, inclusive meaning, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples" are intended to indicate that a particular feature, structure, material or characteristic associated with the embodiment or example is included in at least one embodiment or example of the specification. The schematic representation of the above terms does not necessarily refer to the same embodiment or example.
[0044] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0045] Overview
[0046] As described in the background technology, in the Internet of Things system, it is necessary to deal with various types of devices. These devices usually use different network protocols and data protocols to access application terminals such as cloud platforms. Therefore, the Internet of Things system needs to support each network protocol and data protocol to support the access of different devices.
[0047] As for data protocols, they are usually customized by equipment manufacturers and there is no universal standard. Therefore, when a new type of device is connected, the cloud usually needs to develop and customize the corresponding protocol conversion file of the device through hard-coded iterative development, and the service is shut down and re-released online. In addition, in order to reduce the probability of downtime, the prior art also uploads the protocol conversion file to the protocol library. When a new type of device is connected, the required protocol conversion file is obtained from the protocol library and loaded into the current operating environment of the service in the form of a plug-in. However, due to the large number of device types, when the protocol conversion file corresponding to the device does not exist in the protocol library, the service still needs to be shut down and re-released online, which is less convenient and scalable, making it difficult to achieve fast and effective access to the device.
[0048] In order to solve the problem that it is difficult to achieve fast and effective access to devices in traditional methods, in the technical solution of the present application, when the target data protocol corresponding to the device to be accessed is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol is generated based on the configuration information corresponding to the target data protocol, so as to convert the message sent by the device to be accessed into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol and then send it to the application end, wherein the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol, and the configuration information corresponding to the target data protocol includes the configuration information required for converting the message under the target data protocol into the message under the specified data protocol. Therefore, when a new type of device is accessed, a protocol conversion file can be automatically generated according to the configuration information corresponding to the target data protocol configured by the device, and the message sent by the device to be accessed can be converted into a message under the specified data protocol using the protocol conversion file. There is no need to customize and develop the protocol conversion file corresponding to the device, nor is there any need to shut down and publish the protocol conversion file corresponding to the device. The convenience and scalability are significantly improved, thereby achieving fast and effective access to different types of devices.
[0049] Based on the above inventive concept, the device access method provided in the implementation manner of this specification is exemplarily described below.
[0050] Exemplary Methods
[0051] The embodiments of this specification provide a device access method, which is applied to the device access layer, such as Figure 1 As shown, including:
[0052] S101. When a target data protocol corresponding to the device to be connected is different from a specified data protocol and there is no protocol conversion file corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol is generated based on configuration information corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes configuration information required when converting a message under the target data protocol into a message under the specified data protocol.
[0053] Specifically, the device to be connected is the device of the application end (such as the cloud platform) in the IoT system to be connected. The target data protocol corresponding to the device to be connected is the data protocol used by the device to be connected. The specified data protocol is the data protocol used by the application end.
[0054] When a new device needs to be connected, it can be determined whether the target data protocol corresponding to the device to be connected is the same as the specified data protocol. If the target data protocol corresponding to the device to be connected is the same as the specified data protocol, the message sent by the device to be connected can be directly sent to the application end without converting the data protocol of the message sent by the device to be connected, thereby enabling the device to be connected to the application end quickly and effectively.
[0055] If the target data protocol corresponding to the device to be accessed is different from the specified data protocol, it can be further determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer. The protocol conversion file corresponding to the target data protocol may include a protocol conversion file between the target data protocol and the specified data protocol, that is, the protocol conversion file corresponding to the target data protocol can be used to convert messages under the target data protocol to messages under the specified data protocol. In implementation, the device access layer may include a data protocol layer, and the data protocol layer may store protocol conversion files corresponding to different data protocols. At the same time, the data protocol layer can also allocate execution resources to each protocol conversion file to execute the corresponding protocol conversion file through the allocated execution resources.
[0056] As a preferred implementation, each protocol conversion file in the device access layer includes device identification information;
[0057] Determining whether there is a protocol conversion file corresponding to the target data protocol includes:
[0058] Based on the matching result of the device identification information of the device to be accessed and the device identification information corresponding to each protocol conversion file in the device access layer, it is determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer.
[0059] Specifically, each protocol conversion file in the device access layer may be configured with device identification information, and the device identification information may be used to characterize the device type to which the protocol conversion file is applicable. That is, the data protocol may correspond to the device type, and devices of the same device type may use the same data protocol.
[0060] In the process of determining whether there is a protocol conversion file corresponding to the target data protocol, the device identification information of the device to be accessed can be obtained, and the device identification information of the device to be accessed can be matched with the device identification information configured by each protocol conversion file in the device access layer, and based on the matching result, it is determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer. If the match is successful, it is determined that there is a protocol conversion file corresponding to the target data protocol in the device access layer, and the successfully matched protocol conversion file is used as the protocol conversion file corresponding to the target data protocol; if the match fails, it is determined that there is no protocol conversion file corresponding to the target data protocol in the device access layer. As a result, it is possible to quickly and effectively determine whether there is a protocol conversion file corresponding to the target data protocol from each protocol conversion file in the device access layer, and thus efficiently perform device access.
[0061] Among them, if there is a protocol conversion file corresponding to the target data protocol, the message sent by the device to be connected can be converted into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol and then sent to the application end, so that the device to be connected can be connected to the application end quickly and effectively.
[0062] If there is no protocol conversion file corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol can be generated based on the configuration information corresponding to the target data protocol. The configuration information corresponding to the target data protocol may include the configuration information required when converting messages under the target data protocol to messages under the specified data protocol.
[0063] As a preferred implementation, the configuration information corresponding to the target data protocol includes a message type, first information of a first attribute, second information of a second attribute, and a numerical conversion relationship between the first attribute and the second attribute; the first attribute includes an attribute in the target data protocol, the second attribute includes an attribute in the specified data protocol corresponding to the first attribute, and the message type represents a type of a message under the target data protocol;
[0064] The generating, based on the configuration information corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol, comprises:
[0065] Determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type;
[0066] Substitute the first information, the second information and the numerical conversion relationship into the target protocol conversion template to obtain a protocol conversion file corresponding to the target data protocol.
[0067] Specifically, the configuration information corresponding to the target data protocol may include a message type, first information of a first attribute, second information of a second attribute, and a numerical conversion relationship between the first attribute and the second attribute.
[0068] The message type may be used to characterize the type of the message under the target data protocol, for example, a binary type, an integer type, a string type, and the like.
[0069] The first attribute may include an attribute in the target data protocol, for example, an attribute in a message under the target data protocol that needs to be extracted and sent to the application. The first information of the first attribute may be used to characterize the position information of the first attribute in the target data protocol. For example, taking the type of the message under the target data protocol as a binary type, the first information may characterize the data bits occupied by the first attribute in the target data protocol.
[0070] The second attribute may include an attribute corresponding to the first attribute in the specified data protocol, that is, the second attribute has the same meaning as the first attribute. The second information of the second attribute may be used to represent the position information of the second attribute in the target data protocol and / or the identification information of the second attribute. The identification information of the second attribute may be used to uniquely identify the second attribute, for example, may include the name of the second attribute, etc.
[0071] The numerical conversion relationship between the first attribute and the second attribute can be the conversion relationship between the value of the first attribute and the value of the second attribute in the process of converting the message under the target data protocol into the message under the specified data protocol. For example, the value of the second attribute can be twice the value of the first attribute.
[0072] In implementation, the device access layer may further include a file generation module, which may be used to generate a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol. Protocol conversion templates under different message types may be pre-configured in the file generation module and used as candidate protocol conversion modules so that they can be called in real time during the process of generating the protocol conversion file corresponding to the target data protocol, thereby enabling the protocol conversion file corresponding to the target data protocol to be generated quickly and accurately.
[0073] In the process of generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol, the target protocol conversion template can be determined from multiple candidate protocol conversion templates based on the message type in the configuration information and the predetermined correspondence between the protocol conversion template and the message type, and the first information of the first attribute, the second information of the second attribute and the numerical conversion relationship in the configuration information are substituted into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol.
[0074] Among them, for any message type, the protocol conversion template under the message type can be a function expression or data processing script including the first information of the first attribute, the second information of the second attribute, and the numerical conversion relationship between the first attribute and the second attribute. For example, taking the message type as a binary type, the protocol conversion template can be V(A)=[(value>>bitPosition)&1]*N, where V(A) is the value of the second attribute A in the message under the specified data protocol, value is the message under the target data protocol, that is, the binary type message, bitPosition is the data bit occupied by the first attribute in the target data protocol, N is the numerical conversion coefficient between the first attribute and the second attribute, ">>" is a right shift operator, and "&" is a bitwise AND operator. In implementation, the first information of the first attribute can be substituted into "bitPosition" in the formula, the second information of the second attribute can be substituted into "A" in the formula, and the numerical conversion relationship between the first attribute and the second attribute can be substituted into "N" in the formula, and the protocol conversion file corresponding to the target data protocol can be obtained.
[0075] It can be understood that the number of candidate protocol conversion templates corresponding to the same message type can be one or more. When the number of candidate protocol conversion templates corresponding to the message type in the configuration information corresponding to the target data protocol is more than one, the target protocol conversion template can be determined from the corresponding multiple candidate protocol conversion templates according to predetermined rules. The predetermined rules may include sorting information of the priorities of the candidate protocol conversion templates, etc. The target protocol conversion template can also be determined from the corresponding multiple candidate protocol conversion templates according to target parameters. The target parameters may include selection information for the generation language of the protocol conversion file, etc.
[0076] Therefore, the protocol conversion file corresponding to the target data protocol can be generated quickly and accurately through the target protocol conversion template, and the flexibility of the generation process of the protocol conversion file corresponding to the target data protocol is guaranteed, thereby being able to meet the access requirements of different types of devices.
[0077] As a preferred implementation, the configuration information corresponding to the target data protocol also includes a target generation language of the protocol conversion file;
[0078] The determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type comprises:
[0079] Based on the message type and the predetermined correspondence between the protocol conversion template and the message type, the target protocol conversion template is determined from the candidate protocol conversion templates under the target generation language; wherein the device access layer is used to execute protocol conversion files under different generation languages.
[0080] Specifically, the configuration information corresponding to the target data protocol may also include the target generation language of the protocol conversion file. The target generation language of the protocol conversion file may include the language required to generate the protocol conversion file corresponding to the target data protocol, such as Java, JavaScript, Go, Python, etc.
[0081] In implementation, candidate protocol conversion templates corresponding to different message types in each predetermined language can be pre-constructed. Thus, in the process of determining the target protocol conversion template, the target protocol conversion template can be determined from the candidate protocol conversion templates in the target generation language based on the message type and the predetermined correspondence between the protocol conversion template and the message type, so that the generation language of the protocol conversion file can be flexibly selected according to the functional and / or performance requirements of the protocol conversion file. It can be understood that the data protocol layer can be used to execute protocol conversion files in different languages, thereby meeting different device access requirements.
[0082] As a preferred implementation, the data protocol layer may use a Function computing framework to execute the protocol conversion file to support the execution of protocol conversion files in different languages. For example, the Function computing framework may use a pulsar function computing framework, etc.
[0083] Among them, in the prior art, the method of loading the protocol conversion file in the protocol library into the current operating environment of the service in the form of a plug-in requires that the generation language of the protocol conversion file be consistent with the plug-in service language run by the system, thereby failing to meet the diverse functional and / or performance requirements for the protocol conversion file, and further failing to ensure the flexibility and effectiveness of device access. However, the present application supports the execution of protocol conversion files in different languages, thereby being able to meet the diverse functional and / or performance requirements for the protocol conversion file, and further improving the flexibility and effectiveness of device access.
[0084] As a preferred implementation, the configuration information corresponding to the target data protocol also includes a target value range;
[0085] After obtaining the protocol conversion file corresponding to the target data protocol, the method further includes:
[0086] Based on the target value range, the value range of the second attribute is configured in the protocol conversion file corresponding to the target data protocol, and the value range of the second attribute is used to identify abnormalities of the target message; the target message includes a message under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol.
[0087] Specifically, the configuration information corresponding to the target data protocol may further include a target value range. The target value range may include a value range of the second attribute in the message under the specified data protocol after the message under the target data protocol is converted into a message under the specified data protocol.
[0088] In implementation, after generating a protocol conversion file corresponding to the target data protocol, the value range of the second attribute can also be configured in the protocol conversion file corresponding to the target data protocol based on the target value range. The value range of the second attribute can be used to identify abnormalities in the target message, and the target message may include a message under the specified data protocol obtained after the protocol conversion file corresponding to the target data protocol performs protocol conversion on the message under the target data protocol. For example, after converting the message under the target data protocol to a message under the specified data protocol through the protocol conversion file corresponding to the target data protocol, the value of the second attribute in the message under the specified data protocol can be identified as abnormal through the value range of the second attribute configured in the protocol conversion file. If the value of the second attribute is within the value range, the target message is normal. If the value of the second attribute is not within the value range, the target message is abnormal. At this time, the message under the target data protocol sent by the access device can be intercepted, thereby effectively ensuring the security and reliability of device access.
[0089] As a preferred implementation, the configuration information corresponding to the target data protocol is obtained by the following method:
[0090] In response to an input operation on the configuration information, configuration information corresponding to the target data protocol is obtained.
[0091] Specifically, the device access layer may be configured with an interactive interface, and the interactive interface may be set on a remote client or control device, etc., or may be set on the device access layer, and may be specifically set according to actual needs.
[0092] During implementation, when a new type of device needs to be accessed, the user can input the configuration information corresponding to the target data protocol through the interactive interface. Thus, the configuration information corresponding to the target data protocol can be obtained in response to the input operation of the configuration information, so that the protocol conversion file corresponding to the target data protocol can be generated efficiently and flexibly, thereby meeting the access requirements of different types of devices.
[0093] It can be understood that for any type of device, during the first access to the application end, the configuration information corresponding to the target data protocol can also be sent to the device access layer through the device to be accessed, and the user can also input the configuration information corresponding to the target data protocol into the device access layer by copying, etc., which can be set specifically according to actual needs.
[0094] S102: Convert the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, and send the message under the specified data protocol to the application end.
[0095] Specifically, after generating a protocol conversion file corresponding to the target data protocol, the message sent by the device to be connected can be converted into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, and the message under the specified data protocol obtained after conversion is sent to the application end to achieve effective access of the device to be connected. It can be understood that the message sent by the device to be connected is the message under the target data protocol.
[0096] Therefore, when a new type of device is connected, a protocol conversion file can be automatically generated according to the configuration information corresponding to the target data protocol configured for the device, and the protocol conversion file can be used to convert the message sent by the device to be connected into a message under the specified data protocol. There is no need to customize and develop the protocol conversion file corresponding to the device, nor is there any need to shut down and publish the protocol conversion file corresponding to the device. The convenience and scalability are significantly improved, thereby realizing the fast and effective access of different types of devices.
[0097] As a preferred implementation manner, before converting the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes:
[0098] An execution resource is allocated to the protocol conversion file corresponding to the target data protocol, and the execution resource is used to execute the protocol conversion file corresponding to the target data protocol; wherein the execution resource is independent of the execution resource in the device access layer.
[0099] Specifically, before converting the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, execution resources can also be allocated to the protocol conversion file corresponding to the target data protocol to execute the protocol conversion file corresponding to the target data protocol through the allocated execution resources. Thus, by executing the protocol conversion file corresponding to the target data protocol, the message sent by the device to be connected is converted into a message under the specified data protocol.
[0100] Among them, the execution resources allocated to the protocol conversion file corresponding to the target data protocol are independent of other execution resources in the data protocol layer. The execution resources are the execution resources in the data protocol layer that are in operation, that is, the execution resources allocated by the data protocol layer to other devices accessing the application end. Therefore, when there is an abnormally executed protocol conversion file, it will not affect the execution process of other executed protocol conversion files, thereby avoiding the impact on the access of other devices, thereby ensuring reliable access to the device.
[0101] In a feasible implementation manner, before converting the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes:
[0102] Obtaining the target network protocol configured by the device to be accessed;
[0103] Based on the matching results of the target network protocol and the predetermined candidate network protocols, the access port of the device to be connected is determined; the access port is used to send and receive messages transmitted between the device to be connected and the application end based on the target network protocol.
[0104] Specifically, the device access layer may also include a network protocol layer, in which a variety of candidate network protocols and candidate access ports corresponding to each candidate network protocol may be pre-configured, such as MQTT (Message Queuing Telemetry Transportation) protocol, TCP (Transmission Control Protocol), UDP (User Datagram Protocol), COAP (Constrained Application Protocol), HTTP (Hyper Text Transfer Protocol), etc.
[0105] When there is a device to be connected, the target network protocol configured by the device to be connected can be obtained. For example, the target network protocol configured by the device to be connected can be obtained according to an access request sent by the device to be connected.
[0106] After obtaining the target network protocol, the target network protocol can be matched with each candidate network protocol, and the access port of the device to be connected can be determined according to the matching result. For example, any idle access port among the candidate ports corresponding to the successfully matched candidate network protocol can be used as the access port of the device to be connected, so that the access port of the device to be connected can be configured quickly and effectively, thereby realizing efficient access of the device.
[0107] During implementation, the access port of the device to be accessed can be used to send and receive messages transmitted between the device to be accessed and the application end, wherein the access port of the device to be accessed can send and receive messages transmitted between the device to be accessed and the application end based on the target network protocol.
[0108] For example, after receiving a message sent by the device to be accessed, the network protocol layer can forward the message to the data protocol layer with the device identification information of the device to be accessed. After receiving the message forwarded by the network protocol layer, the data protocol layer can route the message to the corresponding execution resource according to the carried device identification information, so as to convert the message into a message under a specified data protocol and then forward it to the application end. After receiving the message under the specified data protocol, the application end can use it for business.
[0109] It is understandable that the protocol conversion file corresponding to the target data protocol can also be used to convert messages under the specified data protocol into messages under the target data protocol. When the application sends instructions to the device connected to the application, the instructions under the specified data protocol carrying the device identification information can be sent to the data protocol layer. The data protocol layer can route the instructions to the corresponding execution resources according to the carried device identification information, so as to convert the instructions into instructions under the target data protocol and then forward them to the network protocol layer carrying the device identification information. The network protocol layer determines the access port of the corresponding device according to the carried device identification information, and forwards the instructions under the target data protocol to the corresponding device through the access port.
[0110] Exemplary Devices
[0111] In an exemplary embodiment of the present specification, a device access apparatus is also provided, which is applied to a device access layer, such as Figure 2 As shown, including:
[0112] The first processing module 201 is used to generate a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol when the target data protocol corresponding to the device to be connected is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes the configuration information required when converting a message under the target data protocol to a message under the specified data protocol;
[0113] The second processing module 202 is used to convert the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, and send the message under the specified data protocol to the application end.
[0114] In a feasible implementation manner, the configuration information corresponding to the target data protocol includes a message type, first information of a first attribute, second information of a second attribute, and a numerical conversion relationship between the first attribute and the second attribute; the first attribute includes an attribute in the target data protocol, the second attribute includes an attribute corresponding to the first attribute in the specified data protocol, and the message type represents a type of a message under the target data protocol;
[0115] The first processing module 201 is specifically used for:
[0116] Determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type;
[0117] Substitute the first information, the second information and the numerical conversion relationship into the target protocol conversion template to obtain a protocol conversion file corresponding to the target data protocol.
[0118] In a feasible implementation manner, the configuration information corresponding to the target data protocol also includes a target generation language of the protocol conversion file;
[0119] The first processing module 201 is specifically used for:
[0120] Based on the message type and a predetermined correspondence between the protocol conversion template and the message type, determining the target protocol conversion template from the candidate protocol conversion templates under the target generation language;
[0121] The device access layer is used to execute protocol conversion files in different generation languages.
[0122] In a feasible implementation manner, the configuration information corresponding to the target data protocol further includes a target value interval;
[0123] After obtaining the protocol conversion file corresponding to the target data protocol, the first processing module 201 is further used to:
[0124] Based on the target value range, the value range of the second attribute is configured in the protocol conversion file corresponding to the target data protocol, and the value range of the second attribute is used to identify abnormalities of the target message; the target message includes a message under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol.
[0125] In a feasible implementation manner, the first processing module 201 is further configured to:
[0126] In response to an input operation on the configuration information, configuration information corresponding to the target data protocol is obtained.
[0127] In a feasible implementation manner, before the second processing module 202 converts the message sent by the to-be-connected device into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, it is further configured to:
[0128] An execution resource is allocated to the protocol conversion file corresponding to the target data protocol, and the execution resource is used to execute the protocol conversion file corresponding to the target data protocol; wherein the execution resource is independent of the execution resource in the device access layer.
[0129] In a feasible implementation manner, each protocol conversion file in the device access layer includes device identification information; the first processing module 201 is specifically used to:
[0130] Based on the matching result of the device identification information of the device to be accessed and the device identification information corresponding to each protocol conversion file in the device access layer, it is determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer.
[0131] In a feasible embodiment, a third processing module is further included, wherein the third processing module is used to:
[0132] Obtaining the target network protocol configured by the device to be accessed;
[0133] Based on the matching results of the target network protocol and the predetermined candidate network protocols, the access port of the device to be connected is determined; the access port is used to send and receive messages transmitted between the device to be connected and the application end based on the target network protocol.
[0134] The device access device provided in this embodiment belongs to the same application concept as the device access method provided in the above embodiments of this application, can execute the device access method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the device access method. For technical details not fully described in this embodiment, please refer to the specific processing content of the device access method provided in the above embodiments of this application, and will not be repeated here.
[0135] Exemplary Devices
[0136] In an exemplary embodiment of the present specification, an electronic device is also provided, the electronic device comprising at least one processor and at least one memory, the memory storing a computer program, and the computer program, when executed by the processor, implements the device access method as described in any of the above embodiments.
[0137] Exemplary Systems
[0138] In an exemplary embodiment of the present specification, an Internet of Things is also provided, such as Figure 3 As shown, it includes a device access layer 301 and an application end 302, and the device access layer 301 is used to connect the device to be connected to the application end 302 based on the device access method described in any of the above implementation modes.
[0139] In one possible implementation, Figure 4 As shown, the device access layer 301 includes a network protocol layer 401, a data protocol layer 402 and a file generation module 403; the network protocol layer 401, the data protocol layer 402 and the application end 302 are connected in sequence, the file generation module 403 is connected to the data protocol layer 402, and the network protocol layer 401 is connected to the device to be accessed 404.
[0140] The network protocol layer 401 is pre-configured with a plurality of candidate network protocols and candidate access ports corresponding to the candidate network protocols, which are used to configure access ports for the access device 404 and forward messages transmitted between the access device 404 and the application end 302 through the access ports.
[0141] The data protocol layer 402 can store protocol conversion files for different device types, and is used to determine the protocol conversion file corresponding to the target data protocol based on the device identification information carried in the received messages and / or instructions, and allocate execution resources for it, as well as route the received messages and / or instructions to the corresponding execution resources, perform protocol conversion on them, and forward them to the application end 302 or the network protocol layer 401.
[0142] The file generation module 403 may be used to generate a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol, and store the file in the data protocol layer 402 .
[0143] Exemplary computer program products and storage media
[0144] In addition to the above-mentioned methods and devices, the device access method provided in the embodiments of this specification may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the device access method according to various embodiments of this specification described in the above "Exemplary Method" section of this specification.
[0145] The computer program product can be written in any combination of one or more programming languages to write program codes for executing the operations of the embodiments of this specification, and the programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as "C" language or similar programming languages.
[0146] In addition, an embodiment of the present specification also provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to execute the steps of the device access method according to various embodiments of the present specification described in the above "Exemplary Method" section of the present specification.
[0147] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this specification can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0148] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] The above-mentioned embodiments only express several implementation methods of this specification, and the descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the solutions provided by the embodiments of this specification. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of this specification, which all belong to the protection scope of this specification. Therefore, the protection scope of the patent of this specification shall be based on the attached claims.
Claims
1. A device access method, characterized in that: Applied to the device access layer, including: When the target data protocol corresponding to the device to be connected is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol is generated based on the configuration information corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes the configuration information required when converting a message under the target data protocol to a message under the specified data protocol; Based on the protocol conversion file corresponding to the target data protocol, the message sent by the device to be connected is converted into a message under the specified data protocol, and the message under the specified data protocol is sent to the application end.
2. The method according to claim 1, characterized in that The configuration information corresponding to the target data protocol includes a message type, first information of a first attribute, second information of a second attribute, and a numerical conversion relationship between the first attribute and the second attribute; the first attribute includes an attribute in the target data protocol, the second attribute includes an attribute in the specified data protocol corresponding to the first attribute, and the message type represents a type of message under the target data protocol; The generating, based on the configuration information corresponding to the target data protocol, a protocol conversion file corresponding to the target data protocol, comprises: Determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type; Substitute the first information, the second information and the numerical conversion relationship into the target protocol conversion template to obtain a protocol conversion file corresponding to the target data protocol.
3. The method according to claim 2, characterized in that The configuration information corresponding to the target data protocol also includes a target generation language of the protocol conversion file; The determining a target protocol conversion template from a plurality of candidate protocol conversion templates based on the message type and a predetermined correspondence between the protocol conversion template and the message type comprises: Based on the message type and a predetermined correspondence between the protocol conversion template and the message type, determining the target protocol conversion template from the candidate protocol conversion templates under the target generation language; The device access layer is used to execute protocol conversion files in different generation languages.
4. The method according to claim 2, characterized in that: The configuration information corresponding to the target data protocol also includes a target value interval; After obtaining the protocol conversion file corresponding to the target data protocol, the method further includes: Based on the target value range, the value range of the second attribute is configured in the protocol conversion file corresponding to the target data protocol, and the value range of the second attribute is used to identify abnormalities of the target message; the target message includes a message under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol.
5. The method according to claim 1, characterized in that The configuration information corresponding to the target data protocol is obtained by the following method: In response to an input operation on the configuration information, configuration information corresponding to the target data protocol is obtained.
6. The method according to claim 1, characterized in that Before converting the message sent by the to-be-connected device into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes: An execution resource is allocated to the protocol conversion file corresponding to the target data protocol, and the execution resource is used to execute the protocol conversion file corresponding to the target data protocol; wherein the execution resource is independent of the execution resource in the device access layer.
7. The method according to claim 1, characterized in that Each protocol conversion file in the device access layer includes device identification information; Determining whether there is a protocol conversion file corresponding to the target data protocol includes: Based on the matching result of the device identification information of the device to be accessed and the device identification information corresponding to each protocol conversion file in the device access layer, it is determined whether there is a protocol conversion file corresponding to the target data protocol in the device access layer.
8. The method according to any one of claims 1 to 7, characterized in that: Before converting the message sent by the to-be-connected device into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, the method further includes: Obtaining the target network protocol configured by the device to be accessed; Based on the matching results of the target network protocol and the predetermined candidate network protocols, the access port of the device to be connected is determined; the access port is used to send and receive messages transmitted between the device to be connected and the application end based on the target network protocol.
9. A device access apparatus, characterized in that: Applied to the device access layer, including: A first processing module is used for generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol when the target data protocol corresponding to the device to be connected is different from the specified data protocol and there is no protocol conversion file corresponding to the target data protocol; the protocol conversion file corresponding to the target data protocol includes a protocol conversion file between the target data protocol and the specified data protocol; the configuration information corresponding to the target data protocol includes the configuration information required when converting a message under the target data protocol to a message under the specified data protocol; The second processing module is used to convert the message sent by the device to be connected into a message under the specified data protocol based on the protocol conversion file corresponding to the target data protocol, and send the message under the specified data protocol to the application end.
10. An Internet of Things system, characterized in that: It comprises a device access layer and an application end, wherein the device access layer is used to connect the device to be connected to the application end based on the device access method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and system supporting access of sensors of different types
CN104010005A
Protocol conversion method and system, and gateway equipment
CN113595961A
Automatic docking method, system and device of Internet of Things equipment and medium
CN118827648A