Device access method, apparatus and internet of things system
Patent Information
- Application Number
- CN202411801332.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2044-12-09
AI Technical Summary
[0004]为解决上述技术问题,本申请提供了一种设备接入方法、装置及物联网系统,以解决现有技术中难以实现设备的快速有效接入的问题
[0036]从上述技术方案可以看出,本申请实施例提供了一种设备接入方法、装置及物联网系统,所述方法当待接入设备对应的目标数据协议与指定数据协议不同,且不存在目标数据协议对应的协议转换文件时,基于目标数据协议对应的配置信息,生成目标数据协议对应的协议转换文件,以基于目标数据协议对应的协议转换文件将待接入设备发送的消息转换成指定数据协议下的消息后发送至应用端,其中,目标数据协议对应的协议转换文件包括目标数据协议与指定数据协议之间的协议转换文件,目标数据协议对应的配置信息包括将目标数据协议下的消息转换为指定数据协议下的消息时所需要的配置信息,由此,在有新的类型的设备接入时,能够根据该设备所配置的目标数据协议对应的配置信息,自动生成协议转换文件,并利用该协议转换文件将待接入设备发送的消息转换成指定数据协议下的消息,无需定制开发该设备对应的协议转换文件,也无需对该设备对应的协议转换文件进行停机发布,便利性以及可扩展性得到明显提升,从而实现了不同类型的设备的快速有效接入。
Smart Images

Figure CN119652982B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet of Things (IoT) technology, and in particular to a device access method, apparatus, and IoT system. Background Technology
[0002] In IoT systems, there are various types of devices that typically use different network and data protocols to connect to the application. Therefore, IoT systems need to support each network and data protocol to enable different devices to connect.
[0003] Data protocols are typically defined by equipment manufacturers and lack universal standards. Consequently, when new types of devices are connected, it is necessary to develop custom protocol conversion files for those devices and then shut down the system to release them. This results in poor convenience and scalability, making it difficult to achieve rapid and effective device access. Summary of the Invention
[0004] To address the aforementioned technical problems, this application provides a device access method, apparatus, and Internet of Things (IoT) system to solve the problem of difficulty in achieving fast and effective device access in the prior art.
[0005] To achieve the above technical objectives, the embodiments of this application provide the following technical solutions:
[0006] Firstly, this specification provides a device access method applied to a device access layer, comprising:
[0007] When the target data protocol of 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; 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 messages under the target data protocol to messages 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 accessed is converted into a message under the specified data protocol, and the message under the specified data protocol is sent to the application.
[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 attributes in the target data protocol, the second attribute includes attributes in the specified data protocol corresponding to the first attribute, and the message type represents the type of message under the target data protocol;
[0010] The step of generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol includes:
[0011] Based on the message type and the predetermined correspondence between the protocol conversion template and the message type, a target protocol conversion template is determined from multiple candidate protocol conversion templates;
[0012] Substitute the first information, the second information, and the numerical conversion relationship into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol.
[0013] In one implementation, the configuration information corresponding to the target data protocol further includes the target generation language of the protocol conversion file;
[0014] The step of determining the target protocol conversion template from multiple candidate protocol conversion templates based on the message type and the predetermined correspondence between the protocol conversion template and the message type includes:
[0015] 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 each of 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 further includes a target value range;
[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. The value range of the second attribute is used to identify anomalies in the target message. The target message includes messages 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 through the following method:
[0021] In response to the input operation of the configuration information, the configuration information corresponding to the target data protocol is obtained.
[0022] In one implementation, before converting 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, the method further includes:
[0023] Execution resources are allocated to the protocol conversion file corresponding to the target data protocol, and the execution resources are used to execute the protocol conversion file corresponding to the target data protocol; wherein, the execution resources are independent of the execution resources in the device access layer.
[0024] In one implementation, each protocol conversion file in the device access layer includes device identification information;
[0025] Determining whether a protocol conversion file corresponding to the target data protocol exists includes:
[0026] Based on the matching results between 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 accessed 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] Obtain the target network protocol configured for the device to be connected;
[0029] Based on the matching results between the target network protocol and the predetermined candidate network protocols, the access port of the device to be accessed is determined; the access port is used to send and receive messages transmitted between the device to be accessed and the application terminal based on the target network protocol.
[0030] Secondly, embodiments of this specification provide a device access apparatus applied to a device access layer, comprising:
[0031] The first processing module is configured 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 accessed 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 messages under the target data protocol into messages under the specified data protocol;
[0032] The second processing module is used 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 send the message under the specified data protocol to the application terminal.
[0033] Thirdly, embodiments of this specification provide an Internet of Things (IoT) system, including a device access layer and an application terminal, wherein the device access layer is used to connect a device to be accessed to the application terminal based on the device access method described in any of the above embodiments.
[0034] Fourthly, embodiments of this specification provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the device access method as described in any of the preceding claims.
[0035] Fifthly, embodiments of this specification provide a computer program product or computer program, the computer program product including a computer program 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 of the preceding claims.
[0036] As can be seen from the above technical solutions, the embodiments of this application provide a device access method, apparatus, and IoT system. When the target data protocol of the device to be accessed is different from the specified data protocol, and a protocol conversion file corresponding to the target data protocol does not exist, the method generates a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol. The method then converts the messages sent by the device to be accessed into messages under the specified data protocol based on the protocol conversion file and sends them to the application. 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 to convert messages under the target data protocol into messages under the specified data protocol. Therefore, when a new type of device is accessed, a protocol conversion file can be automatically generated based on the configuration information corresponding to the target data protocol configured for that device. This protocol conversion file is then used to convert the messages sent by the device to be accessed into messages under the specified data protocol. There is no need to customize and develop a protocol conversion file corresponding to the device, nor is it necessary to shut down and release the corresponding protocol conversion file. This significantly improves convenience and scalability, thereby enabling rapid and effective access for different types of devices. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0038] Figure 1 This is a flowchart illustrating a device access method provided for implementation of this specification.
[0039] Figure 2 This is a schematic diagram of a device access device provided for embodiments of this specification.
[0040] Figure 3 This is a schematic diagram of the structure of an Internet of Things (IoT) system provided for the implementation of this specification.
[0041] Figure 4 This is a schematic diagram of another Internet of Things (IoT) system provided for implementation of this specification. Detailed Implementation
[0042] Unless otherwise defined, the technical or scientific terms used in the embodiments of this specification shall have the ordinary meaning understood by one of ordinary skill in the art to which this specification pertains. The terms "first," "second," and similar terms used in the embodiments of this specification do not indicate any order, quantity, or importance, but are merely used to avoid confusion of constituent elements.
[0043] Unless the context otherwise requires, throughout this specification, "a plurality of" means "at least two," and "including" is interpreted as open-ended or encompassing, that is, "including, but not limited to." In the description of this specification, terms such as "one embodiment," "some embodiments," "exemplary embodiment," "example," "specific example," or "some examples" are intended to indicate that a particular feature, structure, material, or characteristic associated with that embodiment or example is included in at least one embodiment or example of this specification. The illustrative representations of the above terms do not necessarily refer to the same embodiment or example.
[0044] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0045] Overview
[0046] As described in the background section, IoT systems need to handle various types of devices that typically use different network and data protocols to access cloud platforms and other applications. Therefore, IoT systems need to support each network and data protocol to enable access for different devices.
[0047] For data protocols, they are usually customized by device manufacturers, and there is no universal standard. Therefore, when a new type of device is connected, it is usually necessary to develop a customized protocol conversion file for that device through hard-coded iterative development in the cloud, and then the service needs to be shut down and redeployed. In addition, to reduce the probability of downtime, existing technologies also upload the protocol conversion file to a protocol library. When a new type of device is connected, the required protocol conversion file is retrieved from the protocol library and loaded into the current runtime environment of the service as a plugin. However, due to the large number of device types, if the corresponding protocol conversion file for a device is not found in the protocol library, the service still needs to be shut down and redeployed. This has poor convenience and scalability, making it difficult to achieve rapid and effective device connection.
[0048] To address the challenge of achieving rapid and efficient device access using traditional methods, this application's technical solution addresses the issue of a target data protocol differing from a specified data protocol, and the absence of a corresponding protocol conversion file for the target data protocol. This is achieved by generating a protocol conversion file based on the target data protocol's configuration information. This file then converts messages sent by the device under the target data protocol into messages under the specified data protocol before sending them to the application. The target data protocol's protocol conversion file includes a conversion file between the target and specified data protocols, and the target data protocol's configuration information includes the necessary configuration information for converting messages from the target data protocol to the specified data protocol. Therefore, when a new type of device accesses the application, a protocol conversion file can be automatically generated based on the device's configuration information for the target data protocol. This file is then used to convert messages sent by the device under the target data protocol into messages under the specified data protocol, eliminating the need for custom development of a protocol conversion file for that device and avoiding system downtime for its release. This significantly improves convenience and scalability, enabling rapid and efficient access for different types of devices.
[0049] Based on the above inventive concept, the device access method provided in the embodiments of this specification will be described exemplarily below.
[0050] Exemplary methods
[0051] This specification provides a device access method applied to the device access layer, such as... Figure 1 As shown, it includes:
[0052] S101. 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; 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 messages under the target data protocol into messages under the specified data protocol.
[0053] Specifically, the device to be connected is the application terminal (e.g., cloud platform) in the IoT system to be connected. The target data protocol corresponding to the device to be connected is the data protocol adopted by the device. The specified data protocol is the data protocol adopted by the application terminal.
[0054] When a new device needs to be connected, it can be determined whether the target data protocol of the device to be connected is the same as the specified data protocol. If the target data protocol of the device to be connected is the same as the specified data protocol, the message sent by the device to be connected can be sent directly to the application without the need to convert the data protocol of the message sent by the device to be connected, thereby enabling the device to be connected to the application quickly and effectively.
[0055] If the target data protocol of the device to be accessed is different from the specified data protocol, it can be further determined whether the device access layer has a protocol conversion file corresponding to the target data protocol. The protocol conversion file corresponding to the target data protocol can 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 into messages under the specified data protocol. In implementation, the device access layer can include a data protocol layer, which can store protocol conversion files corresponding to different data protocols. Simultaneously, the data protocol layer can allocate execution resources to each protocol conversion file to execute the corresponding protocol conversion file using the allocated execution resources.
[0056] In a preferred embodiment, each protocol conversion file in the device access layer includes device identification information;
[0057] Determining whether a protocol conversion file corresponding to the target data protocol exists includes:
[0058] Based on the matching results between 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 can be configured with device identification information, which can be used to characterize the device type to which the protocol conversion file is applicable. That is, the data protocol can correspond to the device type, and devices under the same device type can use the same data protocol.
[0060] In determining whether a protocol conversion file corresponding to the target data protocol exists, the device identification information of the device to be accessed can be obtained. This device identification information is then matched with the device identification information configured in each protocol conversion file of the device access layer. Based on the matching result, it is determined whether a protocol conversion file corresponding to the target data protocol exists in the device access layer. If the match is successful, it is determined that a protocol conversion file corresponding to the target data protocol exists 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 a protocol conversion file corresponding to the target data protocol does not exist in the device access layer. In this way, it is possible to quickly and effectively determine whether a protocol conversion file corresponding to the target data protocol exists from each protocol conversion file of the device access layer, thereby enabling efficient device access.
[0061] If a protocol conversion file corresponding to the target data protocol exists, the message sent by the device to be accessed can be converted into a message under the specified data protocol based on the protocol conversion file and then sent to the application, thereby enabling the device to be accessed to be quickly and effectively connected to the application.
[0062] If a protocol conversion file corresponding to the target data protocol does not exist, it can be generated based on the configuration information corresponding to the target data protocol. The configuration information for the target data protocol can include the configuration information required to convert messages under the target data protocol to messages under the specified data protocol.
[0063] In a preferred embodiment, 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 attributes in the target data protocol, the second attribute includes attributes in the specified data protocol corresponding to the first attribute, and the message type represents the type of message under the target data protocol;
[0064] The step of generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol includes:
[0065] Based on the message type and the predetermined correspondence between the protocol conversion template and the message type, a target protocol conversion template is determined from multiple candidate protocol conversion templates;
[0066] Substitute the first information, the second information, and the numerical conversion relationship into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol.
[0067] Specifically, the configuration information corresponding to the target data protocol may include message type, first information of the first attribute, second information of the second attribute, and the numerical conversion relationship between the first attribute and the second attribute.
[0068] The message type can be used to characterize the type of message under the target data protocol, such as binary type, integer type, string type, etc.
[0069] The first attribute may include attributes from the target data protocol, such as attributes that need to be extracted and sent to the application from messages under the target data protocol. The first information of the first attribute can be used to characterize the position information of the first attribute in the target data protocol. For example, taking the message type under the target data protocol as binary, the first information can characterize the data bits occupied by the first attribute in the target data protocol.
[0070] The second attribute may include an attribute in the specified data protocol that corresponds to the first attribute; that is, the second attribute has the same meaning as the first attribute. The second information of the second attribute may be used to characterize the location 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, it may include the name of the second attribute.
[0071] The numerical conversion relationship between the first attribute and the second attribute can be described as the conversion relationship between the values of the first attribute and the second attribute during the process of converting a message under the target data protocol into a 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 also include a file generation module. This module can generate a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol. Specifically, different message type protocol conversion templates can be pre-configured in the file generation module as candidate protocol conversion modules. This allows for real-time invocation during the generation of the protocol conversion file corresponding to the target data protocol, thereby enabling the rapid and accurate generation of the target data protocol's corresponding protocol conversion file.
[0073] In the process of generating the 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. The first information of the first attribute, the second information of the second attribute, and the numerical conversion relationship in the configuration information are then substituted into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol.
[0074] For any message type, the protocol conversion template for that message type can be a function expression or data processing script that includes the first information of the first attribute, the second information of the second attribute, and the numerical conversion relationship between the first and second attributes. For example, taking a binary message type as an example, 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, i.e., a binary 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 and second attributes, ">>" is the right shift operator, and & is the 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 and second attributes can be substituted into "N" in the formula to obtain the protocol conversion file corresponding to the target data protocol.
[0075] It is understandable that the number of candidate protocol conversion templates corresponding to the same message type can be one or more. When there are multiple candidate protocol conversion templates corresponding to the message type in the configuration information of the target data protocol, the target protocol conversion template can be determined from the multiple candidate protocol conversion templates according to predetermined rules. The predetermined rules may include the priority sorting information of each candidate protocol conversion template, etc. The target protocol conversion template can also be determined from the multiple candidate protocol conversion templates according to target parameters. The target parameters may include the selection information of the generation language of the protocol conversion file, etc.
[0076] Therefore, the target protocol conversion template can quickly and accurately generate the protocol conversion file corresponding to the target data protocol, and ensure the flexibility of the generation process of the protocol conversion file corresponding to the target data protocol, thereby meeting the access needs of different types of devices.
[0077] In a preferred embodiment, the configuration information corresponding to the target data protocol also includes the target generation language of the protocol conversion file;
[0078] The step of determining the target protocol conversion template from multiple candidate protocol conversion templates based on the message type and the predetermined correspondence between the protocol conversion template and the message type includes:
[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 each of 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 when generating the protocol conversion file corresponding to the target data protocol, such as Java, JavaScript, Go, Python, etc.
[0081] In implementation, candidate protocol conversion templates for different message types under each predetermined language can be pre-built. Therefore, in determining the target protocol conversion template, based on the message type and the predetermined correspondence between the protocol conversion template and the message type, the target protocol conversion template can be selected from the candidate templates under the target generation language. This allows for flexible selection of the generation language of the protocol conversion file according to the functional and / or performance requirements of the protocol conversion file. It is understood that the data protocol layer can be used to execute protocol conversion files in different languages, thereby meeting the access needs of different devices.
[0082] As a preferred implementation, the data protocol layer can employ a function computation framework to execute protocol conversion files, thereby supporting the execution of protocol conversion files in different languages. For example, the function computation framework could be the Pulsar function computation framework.
[0083] Existing technologies that load protocol conversion files from a protocol library into the current runtime environment of a service via plugins require the language used to generate the protocol conversion files to match the language of the plugin service running on the system. This fails to meet diverse functional and / or performance requirements for the protocol conversion files, thus compromising the flexibility and effectiveness of device access. This application, however, supports the execution of protocol conversion files in different languages, thereby meeting diverse functional and / or performance requirements for the protocol conversion files and further improving the flexibility and effectiveness of device access.
[0084] In a preferred embodiment, the configuration information corresponding to the target data protocol further 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. The value range of the second attribute is used to identify anomalies in the target message. The target message includes messages 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 also include a target value range. The target value range may include the 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 the protocol conversion file corresponding to the target data protocol, a value range for the second attribute can be configured in the protocol conversion file based on the target value range. The value range of the second attribute can be used for anomaly detection of target messages. Target messages can include messages under a specified data protocol obtained after the protocol conversion file corresponding to the target data protocol performs protocol conversion on messages under the target data protocol. For example, after converting a message under the target data protocol to a message under a specified data protocol using the protocol conversion file, anomaly detection can be performed on the value of the second attribute in the message under the specified data protocol using the value range of the second attribute configured in the protocol conversion file. If the value of the second attribute is within the specified range, the target message is not abnormal; if the value of the second attribute is not within the specified range, the target message is abnormal. In this case, messages under the target data protocol sent by the device to be accessed 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 through the following method:
[0090] In response to the input operation of the configuration information, the configuration information corresponding to the target data protocol is obtained.
[0091] Specifically, the device access layer can be configured with an interactive interface, which can be set on a remote client or control device, or it can be set in the device access layer. The specific configuration can be made according to actual needs.
[0092] In practice, when a new type of device needs to be connected, the user can input the configuration information corresponding to the target data protocol through this interactive interface. In response to the input of the configuration information, the configuration information corresponding to the target data protocol can be obtained, thereby generating the protocol conversion file corresponding to the target data protocol efficiently and flexibly, and thus meeting the access needs of different types of devices.
[0093] Understandably, for any type of device, during the initial access process to the application, the device to be accessed can send the configuration information corresponding to the target data protocol to the device access layer, and the user can also input the configuration information corresponding to the target data protocol to the device access layer by means of copying, etc. The specific settings can be configured according to actual needs.
[0094] S102. Based on the protocol conversion file corresponding to the target data protocol, the message sent by the device to be accessed is converted into a message under the specified data protocol, and the message under the specified data protocol is sent to the application terminal.
[0095] Specifically, after generating the protocol conversion file corresponding to the target data protocol, the messages sent by the device to be accessed can be converted into messages under the specified data protocol based on the protocol conversion file, and then the converted messages under the specified data protocol can be sent to the application to achieve effective access for the device to be accessed. It can be understood that the messages sent by the device to be accessed are messages under the target data protocol.
[0096] Therefore, when a new type of device is connected, a protocol conversion file can be automatically generated based on the configuration information corresponding to the target data protocol configured for that device. This protocol conversion file is then used to convert the messages sent by the device to be connected into messages under the specified data protocol. There is no need to customize and develop a protocol conversion file for that device, nor is there a need to shut down the system to release the corresponding protocol conversion file. Convenience and scalability are significantly improved, thus enabling the rapid and effective access of different types of devices.
[0097] As a preferred embodiment, before converting 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, the method further includes:
[0098] Execution resources are allocated to the protocol conversion file corresponding to the target data protocol, and the execution resources are used to execute the protocol conversion file corresponding to the target data protocol; wherein, the execution resources are independent of the execution resources in the device access layer.
[0099] Specifically, before converting 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, execution resources can be allocated to the protocol conversion file corresponding to the target data protocol. The allocated execution resources are used to execute the protocol conversion file corresponding to the target data protocol. Thus, by executing the protocol conversion file corresponding to the target data protocol, the message sent by the device to be accessed is converted into a message under the specified data protocol.
[0100] 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. Execution resources are those currently in operation within the data protocol layer; that is, the execution resources allocated by the data protocol layer to other devices accessing the application. Therefore, when a protocol conversion file experiences execution errors, it will not affect the execution of other executing protocol conversion files, thus avoiding any impact on the access of other devices and ensuring reliable device access.
[0101] In one feasible implementation, before converting 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, the method further includes:
[0102] Obtain the target network protocol configured for the device to be connected;
[0103] Based on the matching results between the target network protocol and the predetermined candidate network protocols, the access port of the device to be accessed is determined; the access port is used to send and receive messages transmitted between the device to be accessed and the application terminal based on the target network protocol.
[0104] Specifically, the device access layer may also include a network protocol layer, in which multiple candidate network protocols and corresponding candidate access ports can be pre-configured. Candidate network protocols include MQTT (Message Queuing Telemetry Transportation), TCP (Transmission Control Protocol), UDP (User Datagram Protocol), COAP (Constrained Application Protocol), HTTP (Hypertext 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 based on the access request sent by the device to be connected.
[0106] After obtaining the target network protocol, it can be matched with various candidate network protocols, and the access port of the device to be connected can be determined based on the matching results. For example, any available access port among the candidate ports corresponding to the successfully matched candidate network protocols can be used as the access port of the device to be connected, thereby enabling quick and efficient configuration of the access port of the device to be connected, and thus achieving efficient device access.
[0107] In practice, the access port of the device to be accessed can be used to send and receive messages between the device to be accessed and the application. The access port of the device to be accessed can send and receive messages between the device to be accessed and the application based on the target network protocol.
[0108] For example, after receiving a message from a device to be accessed, the network protocol layer can forward the message to the data protocol layer, carrying 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 device identification information it carries, so as to convert the message into a message under the specified data protocol and forward it to the application. After receiving the message under the specified data protocol, the application can use it for business purposes.
[0109] Understandably, 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 an application sends a command to a device connected to that application, it can send a command under the specified data protocol carrying device identification information to the data protocol layer. The data protocol layer can route the command to the corresponding execution resource based on the device identification information, convert the command into a command under the target data protocol, and then forward it to the network protocol layer carrying the device identification information. The network protocol layer determines the access port of the corresponding device based on the device identification information and forwards the command under the target data protocol to the corresponding device through the access port.
[0110] Exemplary device
[0111] In one exemplary embodiment of this specification, a device access device is also provided, applied to a device access layer, such as... Figure 2 As shown, it includes:
[0112] The first processing module 201 is configured 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 accessed 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 messages under the target data protocol into messages under the specified data protocol;
[0113] The second processing module 202 is used 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 send the message under the specified data protocol to the application terminal.
[0114] In one feasible implementation, the configuration information corresponding to the target data protocol includes message type, first information of a first attribute, second information of a second attribute, and numerical conversion relationship between the first attribute and the second attribute; the first attribute includes attributes in the target data protocol, the second attribute includes attributes in the specified data protocol corresponding to the first attribute, and the message type represents the type of message under the target data protocol.
[0115] The first processing module 201 is specifically used for:
[0116] Based on the message type and the predetermined correspondence between the protocol conversion template and the message type, a target protocol conversion template is determined from multiple candidate protocol conversion templates;
[0117] Substitute the first information, the second information, and the numerical conversion relationship into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol.
[0118] In one feasible implementation, the configuration information corresponding to the target data protocol also includes the 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 the predetermined correspondence between the protocol conversion template and the message type, the target protocol conversion template is determined from each of 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 one feasible implementation, the configuration information corresponding to the target data protocol also includes a target value range;
[0123] After obtaining the protocol conversion file corresponding to the target data protocol, the first processing module 201 is further configured 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. The value range of the second attribute is used to identify anomalies in the target message. The target message includes messages under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol.
[0125] In one feasible implementation, the first processing module 201 is further configured to:
[0126] In response to the input operation of the configuration information, the configuration information corresponding to the target data protocol is obtained.
[0127] In one feasible implementation, before the second processing module 202 converts 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, it is further configured to:
[0128] Execution resources are allocated to the protocol conversion file corresponding to the target data protocol, and the execution resources are used to execute the protocol conversion file corresponding to the target data protocol; wherein, the execution resources are independent of the execution resources in the device access layer.
[0129] In one feasible implementation, each protocol conversion file in the device access layer includes device identification information; the first processing module 201 is specifically used for:
[0130] Based on the matching results between 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 one feasible implementation, a third processing module is further included, the third processing module being used for:
[0132] Obtain the target network protocol configured for the device to be connected;
[0133] Based on the matching results between the target network protocol and the predetermined candidate network protocols, the access port of the device to be accessed is determined; the access port is used to send and receive messages transmitted between the device to be accessed and the application terminal based on the target network protocol.
[0134] The device access apparatus provided in this embodiment belongs to the same application concept as the device access method provided in the above embodiments of this application. It 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 for executing the device access method. Technical details not described in detail in this embodiment can be found in 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 device
[0136] In one exemplary embodiment of this specification, an electronic device is also provided, the electronic device including at least one processor and at least one memory, the memory storing a computer program, which, when executed by the processor, implements the device access method as described in any of the above embodiments.
[0137] Exemplary System
[0138] In one exemplary embodiment of this specification, an Internet of Things (IoT) is also provided, such as Figure 3 As shown, it includes a device access layer 301 and an application terminal 302. The device access layer 301 is used to connect the device to be accessed to the application terminal 302 based on the device access method described in any of the above embodiments.
[0139] In one feasible implementation, such as 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 terminal 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 variety of candidate network protocols and candidate access ports corresponding to each candidate network protocol. It is used to configure access ports for the device to be accessed 404 and to forward messages transmitted between the device to be accessed 404 and the application terminal 302 through the access ports.
[0141] The data protocol layer 402 can store protocol conversion files for different device types. It 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, allocate execution resources to it, and route the received messages and / or instructions to the corresponding execution resources, convert them into protocols, and then forward them to the application terminal 302 or the network protocol layer 401.
[0142] The file generation module 403 can 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 it in the data protocol layer 402.
[0143] Exemplary computer program products and storage media
[0144] In addition to the methods and devices described above, the device access methods provided in the embodiments of this specification can also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the device access methods according to various embodiments of this specification as described in the "Exemplary Methods" section above.
[0145] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this specification. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages.
[0146] Furthermore, embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor of the steps in the device access methods according to various embodiments of this specification as described in the "Exemplary Methods" section above.
[0147] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, 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. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0148] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 embodiments described above are merely illustrative of several implementation methods outlined in this specification. While the descriptions are specific and detailed, they should not be construed as limiting the scope of the solutions provided in this specification. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this specification, and these all fall within the scope of protection of this specification. Therefore, the scope of protection for this patent should be determined by the appended claims.
Claims
1. A device access method, characterized in that, Applied to the device access layer, including: When the target data protocol of the device to be accessed is different from the specified data protocol, and a protocol conversion file corresponding to the target data protocol does not exist, 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 to convert messages under the target data protocol to messages under the specified data protocol. The configuration information corresponding to the target data protocol includes message type, target value range, first information of a first attribute, second information of a second attribute, the numerical conversion relationship between the first attribute and the second attribute, and the target generation language of the protocol conversion file. The device access layer is used to execute protocol conversion files in different generation languages. The first attribute includes attributes in the target data protocol, and the first information of the first attribute represents the position information of the first attribute in the target data protocol. The second attribute includes an attribute in the specified data protocol corresponding to the first attribute. The second information of the second attribute represents the identification information of the second attribute. The message type represents the type of message under the target data protocol. The step of generating a protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol includes: determining a target protocol conversion template from each candidate protocol conversion template under the target generation language based on the message type and a predetermined correspondence between the protocol conversion template and the message type; substituting 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; and configuring the value range of the second attribute in the protocol conversion file corresponding to the target data protocol based on the target value range. The value range of the second attribute is used to identify anomalies in 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. Based on the protocol conversion file corresponding to the target data protocol, the message sent by the device to be accessed is converted into a message under the specified data protocol, and the message under the specified data protocol is sent to the application.
2. The method according to claim 1, characterized in that, The configuration information corresponding to the target data protocol is obtained through the following method: In response to the input operation of the configuration information, the configuration information corresponding to the target data protocol is obtained.
3. The method according to claim 1, characterized in that, Before converting 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, the method further includes: Execution resources are allocated to the protocol conversion file corresponding to the target data protocol, and the execution resources are used to execute the protocol conversion file corresponding to the target data protocol; wherein, the execution resources are independent of the execution resources in the device access layer.
4. The method according to claim 1, characterized in that, Each protocol conversion file in the device access layer includes device identification information; Determining whether a protocol conversion file corresponding to the target data protocol exists includes: Based on the matching results between 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.
5. The method according to any one of claims 1 to 4, characterized in that, Before converting 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, the method further includes: Obtain the target network protocol configured for the device to be connected; Based on the matching results between the target network protocol and the predetermined candidate network protocols, the access port of the device to be accessed is determined; the access port is used to send and receive messages transmitted between the device to be accessed and the application terminal based on the target network protocol.
6. A device access device, characterized in that, Applied to the device access layer, including: The first processing module is configured 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 accessed is different from the specified data protocol and no protocol conversion file corresponding to the target data protocol exists. 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 to convert messages under the target data protocol to messages under the specified data protocol. The configuration information corresponding to the target data protocol includes message type, target value range, first information of a first attribute, second information of a second attribute, the numerical conversion relationship between the first attribute and the second attribute, and the target generation language of the protocol conversion file. The device access layer is used to execute protocol conversion files under different generation languages. The first attribute includes attributes in the target data protocol, and the first information of the first attribute characterizes the first attribute in the target data protocol. The location information, the second attribute including the attribute corresponding to the first attribute in the specified data protocol, the second information of the second attribute representing the identification information of the second attribute, the message type representing the type of message under the target data protocol; generating the protocol conversion file corresponding to the target data protocol based on the configuration information corresponding to the target data protocol includes: determining the target protocol conversion template from each candidate protocol conversion template under the target generation language based on the message type and the predetermined correspondence between the protocol conversion template and the message type; substituting the first information, the second information and the numerical conversion relationship into the target protocol conversion template to obtain the protocol conversion file corresponding to the target data protocol, and configuring the value range of the second attribute in the protocol conversion file corresponding to the target data protocol based on the target value range, the value range of the second attribute being used for anomaly identification of the target message, the target message including the message under the specified data protocol converted by the protocol conversion file corresponding to the target data protocol; The second processing module is used 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 send the message under the specified data protocol to the application terminal.
7. An Internet of Things (IoT) system, characterized in that, It includes a device access layer and an application terminal, wherein the device access layer is used to connect the device to be accessed to the application terminal based on the device access method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Protocol conversion method and system, and gateway equipment
CN113595961A
Automatic docking method, system and device of Internet of Things equipment and medium
CN118827648A