Terminal communication method, service environment generation method, system, device and equipment
By creating integration instances and data conversion scripts on the IoT platform, the problem of complexity in communication between terminal devices and the IoT platform is solved, efficient access and adaptation of multi-protocol and multi-format terminal devices is achieved, and the IoT platform is improved. adaptability and development efficiency.
Patent Information
- Application Number
- CN202310339553.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
AI Technical Summary
Existing technology is difficult to effectively manage the communication between terminal devices produced by different hardware manufacturers and the IoT platform, resulting in complex and inefficient device access.
By creating integration instances and data conversion scripts, the communication protocol and data format conversion between the terminal device and the IoT platform is realized, supporting multiple communication protocols and data formats, reducing development complexity and improving access efficiency.
It realizes efficient communication between terminal equipment of different hardware manufacturers and the Internet of Things platform, simplifies the access process, and improves adaptability and development efficiency.
Smart Images

Figure CN118740951A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communication technology, and in particular to a terminal communication method, a method for generating a service environment, a system, a device and equipment. Background Art
[0002] With the continuous development of mobile communications, smart devices have become an indispensable part of people's daily lives. With the increase of smart devices and the development of network technology, we have entered the era of the Internet of Things, and the Internet of Things platform has emerged. The Internet of Things platform can manage a large number of terminal devices to support the communication service needs of terminal devices; however, these terminal devices are produced by different hardware manufacturers, and in practice, the Internet of Things platform needs to be able to establish communication with terminals produced by different hardware manufacturers. Summary of the invention
[0003] Based on the content of the background technology, in a first aspect, the present disclosure proposes a terminal communication method, the method comprising:
[0004] In response to the access of the terminal, calling the integration instance corresponding to the terminal, the integration instance is used to support the communication of multiple terminals using the same communication protocol;
[0005] The interactive data related to the terminal is converted and processed by the integration instance, and the conversion process includes: according to the attribute of the destination end to which the interactive data is to be sent, the communication protocol of the interactive data and / or the data format of the interactive data is converted; wherein the destination end is the terminal or the Internet of Things platform;
[0006] The target data obtained after the conversion process is sent to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform.
[0007] In a second aspect, the present disclosure proposes a method for generating a service environment, wherein the service environment is used to implement the terminal communication method described in the first aspect, and the method includes:
[0008] In response to the creation of the integration instance, a plurality of integration instances are generated; wherein the plurality of integration instances include a first integration instance of a first type;
[0009] Receiving a data conversion script uploaded for the first integration instance;
[0010] Starting the data conversion script to form at least two converters bound to the first integration instance to obtain a service environment supporting the terminal;
[0011] The first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform the conversion processing on the interaction data related to the first type of terminal in the communication.
[0012] In a third aspect, the present disclosure provides an Internet of Things system, including an Internet of Things platform and a service environment deployed on the Internet of Things platform;
[0013] Among them, the service environment is generated based on the service environment generation method described in the second aspect, and is used to implement the terminal communication method described in the first aspect between the terminal and the Internet of Things platform.
[0014] In a fourth aspect, the present disclosure provides a terminal communication device, the device comprising:
[0015] A calling module, configured to call an integrated instance corresponding to the terminal in response to access of the terminal, wherein the integrated instance is configured to support communication between multiple terminals using the same communication protocol;
[0016] A conversion module, configured to perform conversion processing on the interactive data related to the terminal through the integration instance, wherein the conversion processing includes: converting the communication protocol of the interactive data and / or the data format of the interactive data according to the attributes of the destination end to which the interactive data is to be delivered; wherein the destination end is the terminal or an Internet of Things platform;
[0017] The sending module is used to send the target data obtained after the conversion process to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform.
[0018] In a fifth aspect, the present disclosure provides a device for generating a service environment, wherein the service environment is used to implement the terminal communication method described in the first aspect, and the device includes:
[0019] An instance generation module, configured to generate a plurality of integration instances in response to creation of the integration instance; wherein the plurality of integration instances include a first integration instance of a first type;
[0020] A script receiving module, used for receiving a data conversion script uploaded for the first integration instance;
[0021] A script starting module, used for starting the data conversion script to form at least two converters bound to the first integration instance to obtain a service environment supporting the terminal;
[0022] The first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform the conversion processing on the interaction data related to the first type of terminal in the communication.
[0023] The embodiment of the present disclosure also discloses an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes, the terminal communication method as described in the first aspect is implemented, or the method for generating a service environment as described in the second aspect is implemented.
[0024] The embodiment of the present disclosure also discloses a computer-readable storage medium, which stores a computer program that enables a processor to execute the terminal communication method as described in the first aspect of the present disclosure, or implement the method for generating a service environment as described in the second aspect.
[0025] In an embodiment of the first aspect of the present disclosure, in response to the access of a terminal, an integration instance corresponding to the terminal can be called, and the interactive data related to the terminal can be converted and processed through the integration instance, and the conversion processing includes: according to the attributes of the destination end to which the interactive data is to be delivered, the communication protocol of the interactive data and / or the data format of the interactive data are converted; and the target data obtained after the conversion processing is sent to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform. The destination end based on the above conversion can be a terminal or an Internet of Things platform.
[0026] By adopting the above embodiment, since the terminals that are connected to communicate with the Internet of Things platform can undertake data conversion and data forwarding between the terminals and the Internet of Things platform through the integrated instance, even if there are a large number of terminals, they can still communicate through their corresponding integrated instances, so that the Internet of Things platform can establish communication with terminals produced by different hardware manufacturers.
[0027] In an embodiment of the second aspect of the present disclosure, a method for generating a service environment that supports terminal communication of the first aspect is provided. Specifically, multiple integration instances can be generated in response to the creation of an integration instance; wherein the multiple integration instances include a first integration instance of a first type; when receiving a data conversion script uploaded for the first integration instance; the data conversion script is started to form at least two converters bound to the first integration instance to obtain a service environment that supports the terminal; wherein the first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform conversion processing on interactive data related to the first type of terminal during communication.
[0028] By adopting the above-mentioned embodiment, when creating the above-mentioned service environment, developers only need to create an integrated instance that adapts the communication protocol and upload a data conversion script to obtain a service environment for supporting the first type of terminal communication. In other words, developers only need to write data conversion scripts for the access of different protocol devices, and pass the conversion scripts to the integrated instance through interface injection. In this way, low-code device access can be supported, thereby improving the access development efficiency of terminals produced by different hardware manufacturers. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments of the present disclosure will be briefly introduced below. Obviously, the drawings described below are only some implementation methods of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor.
[0030] Figure 1 A schematic diagram of a communication scenario of terminal communication in an embodiment of the present disclosure is shown;
[0031] Figure 2 A schematic diagram showing the steps of a method for generating a service environment in an embodiment of the present disclosure is shown;
[0032] Figure 3 A communication connection diagram provided by a second integration example in an embodiment of the present disclosure is shown;
[0033] Figure 4a A communication connection diagram of a first integrated instance corresponding to the TCP protocol in an embodiment of the present disclosure is shown;
[0034] Figure 4b A communication connection diagram of a first integration instance corresponding to the MQTT protocol in an embodiment of the present disclosure is shown;
[0035] Figure 4c A communication connection diagram of a first integration instance corresponding to the HTTP protocol in an embodiment of the present disclosure is shown;
[0036] Figure 4d A communication connection diagram of a first integrated instance corresponding to the UDP protocol in an embodiment of the present disclosure is shown;
[0037] Figure 4e A communication connection diagram of a first integration instance corresponding to the CoAP protocol in an embodiment of the present disclosure is shown;
[0038] Figure 5a A schematic diagram showing the deployment of an embedded converter in an embodiment of the present disclosure is shown;
[0039] Figure 5bA schematic diagram of distributed converter deployment in an embodiment of the present disclosure is shown;
[0040] Figure 6 A schematic diagram of the steps of the terminal communication method in an embodiment of the present disclosure is shown;
[0041] Figure 7 A schematic diagram of a process for developers to create a service environment in an embodiment of the present disclosure is shown;
[0042] Figure 8 A schematic diagram of the process of creating a service environment and performing terminal communication in an embodiment of the present disclosure is shown;
[0043] Fig. 9 A schematic diagram of a framework of a service environment created in an embodiment of the present disclosure is shown;
[0044] Fig.10 A schematic diagram of the framework structure of a terminal communication device in an embodiment of the present disclosure is shown;
[0045] Fig.11 A schematic diagram of the framework structure of a device for generating a service environment in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0046] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0047] As described in the background technology, the Internet of Things platform needs to be able to establish communication with terminals produced by different hardware manufacturers. In the related technology, the hardware manufacturers of terminal devices are different, resulting in large differences in the access of devices to the Internet of Things platform, which often requires customized development and a relatively large workload. For example, for an access terminal that uses the TCP protocol, it is necessary to customize the development of a proxy protocol corresponding to the TCP protocol, and then run the communication protocol of the terminal on the platform and use the proxy protocol to manage the TCP protocol. Then, it is necessary to develop a client corresponding to the communication protocol to establish a connection between the terminal and the Internet of Things platform through the client. In this way, more complex development is required, the workload is large, and it is impossible to efficiently respond to the access needs of a large number of various Internet of Things devices.
[0048] The technical terms in this disclosure are explained as follows:
[0049] TCP protocol: Transmission Control Protocol (TCP) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol defined by IETF RFC 793[1]. TCP is designed to adapt to the layered protocol hierarchy that supports multiple network applications. TCP provides reliable communication services between pairs of processes in host computers connected to different but interconnected computer communication networks.
[0050] UDP protocol: User Datagram Protocol (UDP). UDP provides a method for applications to send encapsulated IP data packets without establishing a connection. It is a connectionless transport layer protocol that provides simple, transaction-oriented, unreliable information transmission services. IETF RFC 768[1] is the official specification of UDP; the protocol number of UDP in IP packets is 17.
[0051] MQTT protocol: Message Queuing Telemetry Transport, is a message protocol based on the publish / subscribe paradigm under the ISO standard (ISO / IEC PRF 20922). It works on the TCP / IP protocol family and is a publish / subscribe message protocol designed for remote devices with low hardware performance and poor network conditions. It is widely used in sensors communicating via satellite links, medical devices that occasionally dial up, smart homes, and some miniaturized devices.
[0052] HTTP Protocol: Hyper Text Transfer Protocol (HTTP) is a simple request-response protocol that usually runs on top of TCP. It specifies what kind of messages a client may send to a server and what kind of responses it may get. The headers of request and response messages are given in ASCII form; the message content has a MIME-like format.
[0053] CoAP protocol: Constrained Application Protocol (CoAP), applied to the Internet of Things, is a dedicated Web transmission protocol used to constrain the communication between networks and nodes.
[0054] Reference Figure 1 As shown, a schematic diagram of a communication scenario of terminal communication of the present disclosure is shown, such as Figure 1 As shown, it includes various types of terminals and an Internet of Things platform. The Internet of Things platform needs to communicate with various types of terminals to receive data sent by the terminals and send data to the terminals.
[0055] The various types of terminals may refer to terminals that communicate using different data formats and terminals that communicate using different communication protocols. Various types of terminals may communicate with the Internet of Things platform by accessing the integration instance.
[0056] Some examples include Figure 1 As shown, the communication protocol may include some common protocols such as TCP, MQTT, UDP, HTTP, CoAP, etc. Of course, in some embodiments, the communication protocol may also include customized protocols, such as custom communication protocols. Among them, TCP, MQTT, UDP, HTTP, CoAP and other common protocols are referred to as the first type of communication protocols in this embodiment, corresponding to the first type of integration instance, and the custom communication protocol is referred to as the second type of communication protocol in this embodiment, corresponding to the second type of integration instance. Among them, in the present disclosure, different data processing mechanisms and management mechanisms are used for common communication protocols and custom communication protocols to support communication between different types of terminals (terminals of common protocols and terminals of custom protocols).
[0057] The terminal communication method and the service environment generation method of the present disclosure are introduced respectively below.
[0058] To facilitate understanding of the solution of the present disclosure, how to generate a service environment supporting terminal communication is first described in order.
[0059] <Method of creating a service environment>
[0060] In this embodiment, it is described how to generate a service environment on the platform to serve the communication between the terminal and the Internet of Things platform. The service environment can run on the server or cloud where the Internet of Things platform is located to help the terminal access the Internet of Things platform and provide the communication services required between the Internet of Things platform and the terminal. In the creation of the service environment, the present disclosure adopts the access of low-code devices. The developer only needs to create the first integration instance of the first type and compile the data conversion script corresponding to the first integration instance to build a service environment for a communication protocol.
[0061] Reference Figure 2 As shown, a schematic diagram of the steps of the method for generating a service environment disclosed in the present invention is shown. Figure 2 As shown, the method can be executed by an electronic device to generate the service environment in the cloud, and specifically can include the following steps:
[0062] Step S201: in response to the creation of the integration instance, generate multiple integration instances;
[0063] The multiple integration instances include a first integration instance of the first type.
[0064] In this embodiment, the first integration instance of the first type may refer to an integration instance of a general communication protocol type, such as some general protocols including TCP, MQTT, UDP, HTTP, CoAP, etc., wherein different general communication protocols correspond to different first integration instances, such as the TCP protocol corresponds to the first integration instance of the TCP type, and the MQTT protocol corresponds to the first integration instance of the MQTT type. In other words, each general communication protocol corresponds to an independent first integration instance to provide communication services to terminals using the general communication protocol.
[0065] Among them, the creation operation of the integrated instance may refer to the instance creation operation performed by the developer on the platform. Specifically, after the developer configures the setting parameters of the instance in the compilation interface, when clicking on instance creation, the integrated instance can be generated based on the setting parameters compiled by the developer in response to the instance creation, and after the integrated instance is generated, the integrated instance can be run in response to the running operation performed by the developer.
[0066] The setting parameters may include the instance name of the integration instance, the communication protocol type and other configuration parameters related to the operation of the integration instance.
[0067] Step S202: receiving a data conversion script uploaded for the first integration instance.
[0068] Among them, since the first integration instance is aimed at the general communication protocol, in practice, in order to achieve low-code device access, developers can be allowed to compile simple data conversion scripts, that is, the data conversion script can only compile programs related to data format conversion, and communication services not related to data conversion can be implemented by running the integration instance. In this way, it can reduce the program development of developers, save time, and quickly deploy a service environment for devices with general communication protocols.
[0069] The data conversion script may be associated with the integration instance, and when the integration instance is run, the data conversion script may be run together with the integration instance.
[0070] Step S203: configuring the data conversion script into at least two converters bound to the first integration instance to obtain a service environment supporting the terminal.
[0071] The first integrated instance is used to support communication between a first type of terminal and an Internet of Things platform, and the converter is used to perform conversion processing on interactive data related to the first type of terminal during communication.
[0072] In this embodiment, starting the data conversion script may refer to mapping the data conversion script to a method that can be called by the first integration instance, for example, mapping it to a golong method, and then directly calling the golang method to convert the data that needs to be converted (such as interactive data).
[0073] Among them, the data conversion script can include at least an uplink data conversion script and a downlink data conversion script. The uplink data conversion script is used to perform conversion processing on the data that needs to be uplinked to the Internet of Things platform, and the downlink data conversion script is used to perform conversion processing on the data that the Internet of Things platform needs to send down to the terminal.
[0074] In practice, the data conversion script can be started to configure it as a converter bound to the first instance. When the data conversion script is started, the upstream data conversion script and the downstream data conversion script can be started at the same time. After being started, the upstream data conversion script and the downstream data conversion script can be called converters of the first integration instance. In this way, a first integration instance includes at least two converters, corresponding to the conversion of upstream data and the conversion of downstream data, respectively.
[0075] Of course, in some embodiments, a first integration instance may also include more than two converters, for example, multiple groups of converters, one group of converters includes corresponding uplink converters and downlink converters, and different groups of converters correspond to different data format conversion requirements. This is because, among multiple terminals using the same general communication protocol, the data formats required by different terminals may be different. For example, among multiple terminals using the TCP protocol, some terminals have a data format of text, some terminals have a data format of JSON, and some terminals have a data format of Binary. In this way, for the same first integration instance, it needs to deal with data conversion of multiple data formats. Therefore, a group of converters can be configured for each data format to perform conversion processing on the terminal that uses the data format for communication.
[0076] For example, for the first integrated instance of the TCP protocol, two groups of converters can be configured, one group of converters is used to convert between the JSON format and the data format required by the Internet of Things platform, that is, between the terminal that uses the JSON format for data encapsulation and the Internet of Things platform, the reorganization converter is enabled to perform conversion processing; the other group of converters is used to convert between the text format and the data format required by the Internet of Things platform, that is, between the terminal that uses the text format for data encapsulation and the Internet of Things platform, the reorganization converter is enabled to perform conversion processing.
[0077] In this way, the generated service environment can provide more complete communication services for the communication between various terminals and the IoT platform, so that terminals with different protocols and different data formats can be compatible with the IoT platform, thereby increasing the versatility of the IoT platform. For example, the terminal is connected to the port opened by the first integration instance, and the first integration instance sends the data sent by the terminal to the IoT platform to the upstream converter. After the upstream converter performs the conversion process, the first integration instance sends the converted data (i.e., the target data) to the IoT platform; the data fed back by the IoT platform to the terminal can also be received by the first integration instance and sent to the downstream converter. After conversion, it is sent to the terminal by the first integration instance.
[0078] By adopting the technical solution of the embodiment of the present disclosure, multiple first integrated instances can be used to access terminals of most common communication protocols to the Internet of Things platform, and the bound converter can be used to perform conversion processing on the interactive data related to the first type of terminal during communication. In this way, a communication bridge between the terminal and the Internet of Things platform can be built through the first integrated instance and the bound multiple converters, and access services that can connect to the Internet of Things are provided for terminals that have different communication protocols and data formats from the Internet of Things platform. Moreover, since the creation of data conversion scripts and integration instances can be carried out independently, program development is reduced, allowing developers to quickly build service environments for different communication protocols, realize low-code device access, and improve the efficiency of service environment construction.
[0079] As described above, in some embodiments, the terminals that need to access the Internet of Things platform may also include terminals with custom communication protocols, and the service environment required by the terminals with custom communication protocols may also be deployed. Specifically, a second integrated instance may be constructed, and the program package of the terminal's custom communication protocol may be uploaded to the service environment and run in the form of a plug-in, which may be controlled by the second integrated instance.
[0080] In a specific implementation, at least one custom program corresponding to the second integration instance may be obtained, and the at least one custom program may be used as a plug-in associated with the second integration instance; and the plug-in may be started to form a service environment supporting the second type of terminal;
[0081] The plug-in is used to perform conversion processing on the interactive data of the second type of terminal during communication.
[0082] In this embodiment, the customized program is different from the general communication protocol, and may be a program uploaded by the manufacturer of the terminal. The program may be understood as a customized communication protocol of the terminal, which is used for communication between the terminal and other devices.
[0083] In some embodiments, the platform can open a port to a terminal of a custom communication protocol so that the manufacturer can upload a custom program to the platform through the open port, wherein the custom program can be stored in the platform, and after the second integration instance and the agent program are created, the agent program can download the custom program to the container for execution.
[0084] The plug-in may refer to: an access application for a terminal to access the Internet of Things. In the present disclosure, different plug-ins may match terminals of different models.
[0085] In this embodiment, a second integration instance can correspond to a custom program, that is, it can correspond to an independent custom communication protocol, or a second integration instance can correspond to multiple custom programs, that is, it can correspond to multiple custom communication protocols, and multiple custom communication protocols can be managed. This disclosure does not impose any special restrictions.
[0086] Among them, the creation process of the second integration instance can be similar to the creation process of the first integration instance. For example, the developer sets the setting parameters of the second integration instance. These setting parameters include: instance name, communication protocol type (such as Custom), whether to enable (Enable), uploaded agent package, running instruction configuration parameters (such as . / main|java-jar main.jar, etc.), configuration items (json format, ultimately injected into the plug-in program by the host program), instance description and other parameters; when the second integration instance is started, the plug-in is started at the same time, and a communication connection is established between the second integration instance and the plug-in, wherein the second integration instance and the plug-in can communicate through the gRPC protocol.
[0087] After the second integration instance and the plug-in have finished running, the second integration instance can provide a port for the terminal to access the IoT platform, and the plug-in can provide the required data conversion service and communication protocol conversion service for the terminal, so as to establish communication between the terminal and the IoT platform through the plug-in and the second integration instance. For example, the terminal accesses the port opened by the second integration instance, and the second integration instance sends the data sent by the terminal to the IoT platform to the plug-in, and after the plug-in performs the conversion process, the converted data (i.e., the target data) is sent to the IoT platform via the plug-in; the data fed back by the IoT platform to the terminal can also be converted by the plug-in and sent to the terminal by the second integration instance.
[0088] As described above, in some embodiments, before starting the plug-in, an agent program can be created to manage each plug-in. In this way, a management architecture of the second integration instance-agent program-plug-in can be built to perform lifecycle management of the plug-in through the agent program by controlling the second integration instance.
[0089] In a specific implementation, an agent program for the second integration instance may be received, and a connection between the agent program and the second integration instance may be established; then, when starting the plug-in, the second integration instance may be started to instruct the agent program to download at least one plug-in to a container, and call a preset command to start the at least one plug-in.
[0090] Among them, the second integration instance can manage corresponding multiple plug-ins, that is to say, the custom program packages corresponding to the terminals using custom communication protocols will be uniformly called by the second integration instance, and the terminals with different custom communication protocols will be connected to the service environment by connecting to the port where the second integration instance is located to communicate with the Internet of Things platform.
[0091] Reference Figure 3 As shown, a schematic diagram of the communication connection provided by the second integration example is shown. Figure 3 The second integration instance communicates with the agent program through the gRPC protocol, and the agent program communicates with multiple plug-ins through the gRPC protocol, wherein the plug-ins may include plug-ins called by Golang methods and plug-ins called by Java methods, and there are interface definition specifications between the plug-ins and the agent program, such as communicating with the agent program through a unified interface, wherein the communication protocol adopted between the plug-in and the Internet of Things platform, and between the agent program and the Internet of Things platform is the MQTT protocol.
[0092] Among them, both the agent program and the plug-in can communicate with the Internet of Things platform. During the communication between the terminal and the Internet of Things platform, the terminal data first reaches the port of the second integration instance, and then the second integration instance dispatches the data to the plug-in, which is sent to the Internet of Things platform after conversion. The data sent to the terminal by the Internet of Things platform is also converted by the plug-in and sent to the terminal by the second integration instance.
[0093] When the agent program is running, it can monitor the running status of the plug-in, such as sending a heartbeat packet to the plug-in, and determining the running status of the plug-in based on the heartbeat data fed back by the plug-in. The agent program can feed back the results of the monitored running status of the plug-in to the second integration instance and the Internet of Things platform, which will be fed back to the management platform by the second integration instance, or published on the corresponding interface by the Internet of Things platform, so that developers can debug, restart or stop the plug-in based on the feedback results.
[0094] The second integrated instance can also provide agent management, such as agent package upload, agent run / stop, agent status monitoring, etc. In this way, the service environment of the terminal of the custom communication protocol can be maintained by monitoring the agent.
[0095] The second integration instance can also manage the agent program in a plug-in manner, and the agent program can dynamically load plug-ins during operation, such as dynamically loading newly uploaded plug-ins, or mirroring plug-in logs / errors. It should be noted that when there is a fault in the running state of the plug-in, the agent program may not be affected by the plug-in fault.
[0096] Exemplarily, the creation process of the second integration instance and the agent program may be:
[0097] First, set the configuration parameters of the second integration instance, including the following:
[0098] Name – name, Type – Custom; Enable – whether to enable, PluginPackageUri – upload the agent package (compiled executable file), PluginExeCmd – configure the run command, such as . / main|java-jarmain.jar, etc., PluginConfigJson – configuration item, json format, which is finally injected into the plug-in program by the host program, Description – description information.
[0099] Next, create an integration instance of the Custom type. When creating a Custom integration instance, you need to configure the above setting parameters. When the Enable state is set to true, the second integration instance will be automatically started after the creation is successful.
[0100] When starting the second integration instance, the platform can obtain the custom package storage address, CMD, Config and other parameter information. The agent downloads the plug-in to its own docker container and calls the CMD command to pull up the plug-in. At this time, a child process will be replicated to execute the plug-in. After the plug-in is started, the agent starts, listens to the connection with the plug-in, and responds to requests.
[0101] As described above, in some embodiments, after obtaining the second integration instance and establishing the connection between the second integration instance and the agent program, the life cycle of the plug-in can be managed through the second integration instance and the agent program. The life cycle can be understood as the operation cycle of the plug-in, or it can be understood as the survival cycle of the plug-in. For example, the period from the start of the plug-in operation to the end of the plug-in operation can be called a life cycle.
[0102] In specific implementation, a stop instruction can be sent to the agent program through the second integration instance, and the agent program is used to stop running the corresponding target plug-in in response to the stop instruction to release the service environment of the terminal corresponding to the target plug-in; and a restart instruction can be sent to the agent program through the second integration instance, and the agent program is used to restart the corresponding target plug-in in response to the restart instruction to restore the service environment of the terminal corresponding to the target plug-in.
[0103] As described above, after the second integration instance is created, the agent program can monitor the running status of multiple plug-ins. In some cases, the agent program can also respond to external instructions to control the operation of the plug-in, such as stopping the plug-in, pausing the plug-in, etc. The second integration instance can also accept external instructions to control the plug-in, and send the instructions to the agent program, so that the agent program executes the control corresponding to the instructions.
[0104] In a specific implementation, the instruction received by the second integration instance may include a stop instruction and a restart instruction;
[0105] The stop instruction is used to instruct the agent to stop running the target plug-in, and the restart instruction is used to instruct the agent to rerun the stopped target plug-in. The target plug-in can be a plug-in that has a fault in its running state, or a plug-in that is running normally but needs to be stopped. For example, if the terminal served by the plug-in has been removed from the management of the IoT platform, it is necessary to stop running the plug-in that serves such a terminal.
[0106] The stop instruction and restart instruction can be sent by the developer via a unified external interface, that is, the service environment can be provided with a unified external interface, and the developer can use the external interface to send instructions to the second integration instance to control the operation of the plug-in. Of course, the external interface can also be shared by the first integration instance, so that the developer can use the external interface to send instructions to the first integration instance to stop the operation of the first integration instance.
[0107] Among them, when the target plug-in is stopped through the second integration instance, all terminals connected to the second integration instance and served by the target plug-in are in an offline state. At this time, the MQTT connection between the plug-in and the Internet of Things platform can also be released to avoid occupying connection resources.
[0108] Below, the creation process of the first integration instance is described in detail, wherein the first integration instance corresponds to a terminal of a universal communication protocol, wherein different communication protocols can create different first integration instances, and the creation process of the first integration instance for each communication protocol can be: receiving setting parameters uploaded by the developer when creating the first integration instance, the setting parameters may include parameters necessary for creating an integration instance of the communication protocol, such as whether to enable, protocol type, API address, instance description, metadata, auxiliary information and other parameters, to generate an integration instance based on the setting parameters.
[0109] Among them, a data conversion script compiled for the first integration instance can be received. The data conversion script can be compiled by the developer and uploaded to the platform before creating the first integration instance. After receiving the data conversion script, the data conversion script can be tested. After the test is successful, it is bound to the first integration instance. In this case, the setting parameters can also include the setting parameters of the data conversion script, so that when the first integration instance is generated, the corresponding data conversion script can be synchronously associated and started.
[0110] As described above, the data conversion script may include an uplink data conversion script and a downlink data conversion script, wherein the uplink data conversion script is used to convert the interactive data sent by the terminal to the Internet of Things platform into a data format adapted to the Internet of Things platform, and the uplink data conversion script is used to convert the interactive data sent by the Internet of Things platform to the terminal into a data format adapted to the terminal.
[0111] Among them, a first integration instance can be associated with one or more groups of converters, and a group of converters corresponds to the conversion between the data format required by the Internet of Things platform and a data format of the terminal, which includes an uplink converter and a downlink converter.
[0112] When testing data conversion scripts, each data conversion script supports separate testing, and the script execution results can be viewed on the web page, helping developers to quickly develop and debug conversion scripts.
[0113] The execution result output by the upstream converter can be verified. Specifically, it can be verified whether the returned result is a map structure and contains necessary attributes such as sn, category, msgType, authentication result, etc. The execution result output by the downstream converter does not need to be verified, and the execution result (target data) can be directly returned to the terminal.
[0114] Among them, a timeout process can be added when executing a data conversion script to avoid execution errors or excessive use of server resources.
[0115] For example, the data conversion scripts for the data formats of several terminals are described. It is assumed that the terminal can send data in three different payload types, that is, three different data formats, namely Text, JSON and Binary.
[0116] Among them, for the Text format, the payload format of the interactive data sent by the terminal is as follows:
[0117] SN-002,default,temperature,25.7\n\rSN-002,default,humidity,69;
[0118] The data conversion script for the above line is as follows:
[0119]
[0120]
[0121] Among them, for the JSON format, the payload format of the interactive data sent by the terminal is as follows:
[0122]
[0123] The data conversion script for the above line is as follows:
[0124]
[0125]
[0126] Among them, for the Binary format, the payload format of the interactive data sent by the terminal is as follows:
[0127] \x30\x30\x30\x30\x11\x53\x4e\x2d\x30\x30\x32\x64\x65\x66\x61\x75\x6c\x74\x32\x35\x2e\x37\x00\x00\x00(hexadecimal string);
[0128] Among them, for the Binary format, bytes 0-3 - \x30\x30\x30\x30 are blank bytes, used to show that specific prefix bytes can be skipped in the payload. These bytes are for example purposes;
[0129] 4 bytes - \x11 is the payload length, which is converted to decimal 17. Therefore, the incoming TCP frame payload length is 17 bytes;
[0130] Bytes 5-10 - \x53\x4e\x2d\x30\x30\x32 is deviceName, which is converted to text as SN-002;
[0131] Bytes 11-17 - \x64\x65\x66\x61\x75\x6c\x74 is deviceType. Converted to text, it is default;
[0132] Bytes 18-21 - \x32\x35\x2e\x37 is the content. If the content involves temperature, the converted text value is 25.7.
[0133] Bytes 22-24 - \x00\x00\x00 are blank bytes and can be ignored because the effective length of the payload is 17, i.e., bytes 5-21;
[0134] The data conversion script for the above line is as follows:
[0135]
[0136]
[0137] It should be noted that the role of the above decoder function is to parse the incoming message payload and auxiliary information metadata into the data format required by the IoT platform. Sn and category are required attributes, and the others are optional.
[0138] Among them, for the downstream converter, it converts the received interactive data sent by the Internet of Things platform into the data format required by the terminal. The data conversion script for the following line can be as follows:
[0139]
[0140] The downstream data converter setting can be: function Encoder(msg,msgType,metadata);
[0141] Among them, msg refers to the data format to be converted, such as json message, and msgType refers to the message type of the IoT message; metadata refers to metadata, which is a custom key-value pair in the first integration instance.
[0142] In some embodiments, when deploying the converter, for multiple different first integration instances, the converter may be deployed in a distributed engine deployment manner, or the converter may be deployed in an independent engine manner.
[0143] Specifically, a first engine service may be allocated to the plurality of first integration instances, and the data conversion scripts corresponding to the plurality of first integration instances may be associated with the first engine service;
[0144] or,
[0145] A second engine service is allocated to each first integration instance, a data conversion script corresponding to the first integration instance is associated with the second engine service, and the data conversion script is mapped to a golang method.
[0146] In this implementation, each first integration instance can correspond to a second engine service. This deployment method can be called an embedded implementation. Specifically, a JS Engine VM can be assigned to each first integration instance. The VM is used to bind the upstream data conversion script and the downstream data conversion script. In this case, the data conversion script method can be mapped to a golang method, and the golang method can be directly called later to implement the conversion processing of the interactive data. When the data conversion script changes, the VM and method mapping can be updated.
[0147] Embedded implementation can refer to Figure 5a As shown, it can be seen that the converter corresponding to each first integration instance is embedded and deployed in the first integration instance, and the first integration instance realizes the conversion processing of the interactive data by calling the golang method.
[0148] In this implementation, multiple first integration instances may correspond to one first engine service. This deployment method may be called distributed implementation. Specifically, the first engine service may be an independent JS Engine service, which receives execution requests for calling converters (i.e., data conversion scripts) through MQ (Message Queue). The request may include the integration instance ID, script ID, converterType (converter type), etc. The first engine service has a work pool. After the converter processes the request, it will throw the execution result (i.e., target data) back to MQ. The requester (corresponding first integration instance) can receive the execution result after subscribing to the specified topic. The specific process is as follows: Figure 5b As shown, Figure 5b The data conversion flow chart when the converter is implemented in a distributed manner is shown.
[0149] In a distributed implementation, the data conversion scripts associated with multiple first integration instances can be stored in a database. When the data conversion script is needed to perform data conversion processing, the corresponding data conversion script can be obtained through the first engine service, and the execution result of the data conversion script can be stored. The first integration instance then obtains the execution result from the storage address.
[0150] Specifically, Figure 5b As shown, when the interactive data sent by the terminal to the Internet of Things platform arrives at the first integration instance, the first integration instance generates an execution request and sends it to the message queue. The execution request includes the integration instance ID, script ID, converterType (converter type) and carries the interactive data. The first engine service schedules the data conversion script corresponding to the integration instance ID according to the integration instance ID included in the self-request. The scheduling can be implemented through Redis. Redis stores the execution result of the data conversion script executing the conversion on the interactive data. At the same time, the first engine service notifies the first integration instance of the execution result through kafka. The first integration instance reads the execution result from the message queue of Redis according to the notification, and then extracts the useful data from the execution result and encapsulates it into data that complies with the communication protocol of the Internet of Things platform and sends it to the Internet of Things platform.
[0151] The first integration instance and the first engine service are connected via Kafka, the first engine service is connected to a database via Redis, and the database stores multiple converters associated with the first integration instance.
[0152] Among them, Kafka is a high-throughput distributed publish-subscribe messaging system that can process all action stream data of consumers on the website, Redis (Remote Dictionary Server), that is, Figure 5b The remote dictionary service in is an open source log-type, Key-Value database written in ANSI C language, supporting the network, memory-based or persistent, and providing APIs in multiple languages.
[0153] When the above-mentioned embedded implementation method is adopted, each first integration instance has an independent engine service to assist in data conversion. In this way, when the engine service of a certain integration instance fails, it can be avoided that the conversion of other integration instances is affected; when the distributed implementation method is adopted, multiple first integration instances all perform data conversion through one engine service, thereby realizing the decoupling of the converter and the integration instance, improving the management effectiveness of the converters associated with each first integration instance, and allowing the server to develop independent resources for running and storing the converters of each first integration instance.
[0154] As described above, the creation of the first integrated instance of several general communication protocols is exemplarily described below:
[0155] First, the first integration instance corresponding to the TCP protocol
[0156] Reference Figure 4a As shown, a communication connection diagram of the first integrated instance corresponding to the TCP protocol is shown, such as Figure 4a As shown, in the service environment, the first integration instance of the TCP type needs to open a port to the terminal to communicate with the terminal using the TCP protocol, and needs to associate an upstream converter and a downstream converter, and can communicate with the IoT platform using the MQTT protocol. The creation process is:
[0157] First, compile the upstream data conversion script and the downstream data conversion script. For example, compile the upstream data conversion script and the downstream data conversion script for the Text format, and the upstream data conversion script and the downstream data conversion script for the JSON format. The platform receives the compiled data conversion script.
[0158] Next, create the first integration instance for TCP and configure the setting parameters of the first integration instance. The setting parameters are as follows:
[0159] Name—name;
[0160] Type—TCP;
[0161] Enable—Whether to enable;
[0162] Uplink data converter—uplink converter, which is created when the integration is created and can only be edited on the integration instance page;
[0163] Downlink data converter—a downlink converter that is created when the integration is created and can only be edited through the integration instance page.
[0164] Port-port number, can be random or fixed;
[0165] Max num of pending connects on the socket—the maximum request length of the connection queue. When the queue is full, new connection requests will be rejected. The default value is 128.
[0166] Size of the buffer for inbound socket—size of the socket data receiving buffer, in KB;
[0167] SiSe of the buffer for outbound socket—the size of the socket data sending buffer, in KB;
[0168] Description—integration description;
[0169] Metadata—integrated metadata, auxiliary information;
[0170] Next, when you set the Enable status to true, the integration instance will be automatically started after successful creation;
[0171] After the integration instance is started, a TCP server will be created. A port will be selected from the provided port pool and fixed as the port provided by the first integration instance. The address, port and other information of the instance can be viewed on the details page of the integration instance.
[0172] When the integration instance is running, a TCP Integration object is created in the memory, the upstream converter and the downstream converter are associated, and the terminal connected to the first integration instance is managed through the device list. It should be noted that the terminal is generally connected to the port provided by the first integration instance to the outside.
[0173] Among them, TCP Integration can be called TCP integration, and its full name is transmission control integration. Through the transmission control integration object, the first integration instance of TCP type is run.
[0174] After the first integration instance is created, it can include a DMA module, which maintains an MQTT connection. The MQTT connection is responsible for bidirectional communication with the IoT platform to maintain an online state.
[0175] After the first integration instance is created, it can be responsible for managing all logical devices. The logical device can be understood as a virtual module corresponding to the terminal and connected to the IoT platform. An MQTT connection is created for each logical device. The clientId format and access rules are followed. Each MQTT connection subscribes to the topic (dma / cma / {sn}) of the corresponding terminal to receive data sent by the IoT platform to the terminal.
[0176] Among them, the MQTT connection is used for two-way communication with the IoT platform.
[0177] like Figure 4a As shown, when the first integration instance of the TCP type is created and runs, the communication service it provides is specifically as follows: the first integration instance receives the interactive data (also called uplink data) sent by the terminal to the Internet of Things platform. The logical device then sends a message to the TCP server, and the interactive data is converted by the uplink converter. Specifically, the uplink converter parses the interactive data into metadata through the parser, such as extracting useful data from the interactive data, and converting it into the data format required by the Internet of Things platform, such as the form of topic+payload, to obtain the target data, and then sends it to the Internet of Things platform through MQTT, such as Figure 4a As shown, the target data is sent to the IoT platform in the form of MQTT messages;
[0178] Among them, the first integration instance subscribes to the cmd command topic of the corresponding terminal through the MQTT connection of each device, receives the interactive data (also known as downlink data) sent by the IoT platform to the terminal, extracts useful data through the downlink converter, converts it into the data required by the terminal, and sends it to the terminal.
[0179] Among them, in the service environment, the running status of the first integrated instance can be monitored, whether it is running normally online, whether the TCP server is normal, etc. The first integrated instance needs to monitor the status of the connected terminal, check whether the terminal is working normally, and actively take the terminal offline when the health check fails.
[0180] Second, the first integration instance corresponding to the MQTT protocol
[0181] Reference Figure 4b As shown, a communication connection diagram of the first integration instance corresponding to the MQTT protocol is shown, such as Figure 4b As shown in the figure, the MQTT integration instance is associated with an uplink data converter and a downlink data converter. Figure 4a It can be seen that for the first integration instance of the MQTT type, it can communicate with the external terminal through the MQTT broker, while the integration instance of the TCP type generally communicates with the external terminal through the external port.
[0182] In the service environment, the first integration instance of the MQTT type needs to associate the upstream converter and the downstream converter, and can communicate with the IoT platform using the MQTT protocol. The creation process is:
[0183] First, compile the upstream data conversion script and the downstream data conversion script. For example, compile the upstream data conversion script and the downstream data conversion script for the Text format, and the upstream data conversion script and the downstream data conversion script for the JSON format. The platform receives the compiled data conversion script.
[0184] Next, create the first integration instance for MQTT and configure the settings of the first integration instance. The settings are as follows:
[0185] Name—name;
[0186] Type—MQTT;
[0187] Enable—Whether to enable;
[0188] Uplink data converter—Uplink converter, which is created when the integration is created and can only be edited through the integration instance page;
[0189] Downlink data converter—Downlink data converter, which is created when the integration is created and can only be edited through the integration instance page;
[0190] Host—MQTT broker host address;
[0191] Port-MQTT broker port number;
[0192] Connection timeout—connection timeout duration, in seconds;
[0193] Topic filters—topic filters—{“#”:0,”dma / #”,1};
[0194] Description—integration description;
[0195] Metadata—integrated metadata, auxiliary information;
[0196] Next, when you set the Enable status to true, the integration instance will be automatically started after successful creation;
[0197] After the integration instance is started, it will connect to the configured MQTT broker and subscribe to topics according to topic filters. The MQTT broker can share the broker of the IoT platform or a third-party broker.
[0198] When the integration instance is running, it corresponds to an MQTT Integration object in the memory, associates the upstream converter and the downstream converter, manages the terminals connected to the integration instance, and generates logical devices; the converter is responsible for data conversion, the logical device maintains basic information and includes a DMA module, the DMA module maintains an MQTT connection, and the MQTT connection is responsible for two-way communication with the IoT platform to maintain an online state;
[0199] Similarly, the MQTT Integration object can also be called MQTT integration, that is, message queue telemetry transmission integration, through which the first integration instance of the MQTT type is run.
[0200] As in the first integration instance of the TCP type described above, the MQTT connection in the first integration instance of the MQTT type is used for bidirectional communication with the Internet of Things platform.
[0201] like Figure 4b As shown, when the first integration instance of the MQTT type is created and runs, the communication services it provides are specifically:
[0202] The first integration instance connects to the MQTT broker, subscribes to the topic, receives the interaction data (also called uplink data) sent by the terminal to the IoT platform, extracts the useful data in the payload through the uplink converter, converts it into the data format required by the IoT platform, such as topic+payload, and sends the converted target data to the IoT platform through the MQTT connection to a logical device;
[0203] Among them, the first integrated instance subscribes to the cmd command topic of the corresponding terminal through the MQTT connection of each logical device, receives the interactive data (also known as downlink data) sent to the terminal by the Internet of Things platform, extracts useful data through the downlink converter, converts it into the data required by the terminal, and sends it to the terminal.
[0204] Among them, in the service environment, the running status of the first integration instance can be monitored, whether it is running normally online, whether the MQTT broker connection is normal, etc. The first integration instance needs to monitor the status of the connected terminal, check whether the terminal is working normally, and actively take the terminal offline when the health check fails.
[0205] Third, for the first integration instance corresponding to the HTTP protocol
[0206] Reference Figure 4c As shown, a communication connection diagram of the first integration instance corresponding to the HTTP protocol is shown, such as Figure 4c As shown, in the service environment, the first integration instance of HTTP type needs to open a port to the terminal to communicate with the terminal using the HTTP protocol. The first integration instance of HTTP type may be accessed by a terminal, an application, or a third-party platform, and the first integration instance of HTTP type needs to be associated with an upstream converter and a downstream converter, and may communicate with the IoT platform using the MQTT protocol. The creation process is:
[0207] First, compile the upstream data conversion script and the downstream data conversion script. For example, compile the upstream data conversion script and the downstream data conversion script for the Text format, and the upstream data conversion script and the downstream data conversion script for the JSON format. The platform receives the compiled data conversion script.
[0208] Next, create the first integration instance for HTTP and configure the setting parameters of the first integration instance. The setting parameters are as follows:
[0209] Name–name;
[0210] Type–HTTP;
[0211] Enable – whether to enable;
[0212] Uplinkdataconverter – The converter for the upstream link, which is created when the integration is created and can only be edited through the integration instance page;
[0213] Downlinkdataconverter – a downlink converter, which is created when the integration is created and can only be edited through the integration instance page;
[0214] BaseURL – the base address of the device management service interface API;
[0215] Description – description of the integration;
[0216] Metadata – integrated metadata, auxiliary information;
[0217] Next, when you set the Enable status to true, the integration instance will be automatically started after successful creation;
[0218] Among them, when the first integrated instance of HTTP is started, it communicates with the external terminal through the device management service interface api. When the integrated instance is running, corresponding to an HTTP Integration object in the memory, the developer can create a timer to poll the device management service api interface, associate the upstream converter and the downstream converter, and manage the terminal connected to the first integrated instance through the device list. It should be noted that the terminal is generally connected to the first integrated instance through the device management service api interface;
[0219] Among them, HTTP Integration can also be called HTTP integration, and its full name is hypertext transfer integration. Through the hypertext transfer integration object, the first integration instance of HTTP type is run.
[0220] After the first integration instance is created, it may include a DMA module, which maintains an MQTT connection. The MQTT connection is responsible for bidirectional communication with the IoT platform to maintain an online state.
[0221] Similarly, after the first integration instance is created, it can be responsible for managing all logical devices, which can be understood as virtual modules corresponding to the terminal and connected to the Internet of Things platform. An MQTT connection is created for each logical device, following the clientId format and access rules. Each MQTT connection subscribes to the topic (dma / cma / {sn}) of its corresponding terminal to receive data sent by the Internet of Things platform to the terminal.
[0222] like Figure 4aAs shown, when the first integration instance of HTTP type is created and runs, the communication service it provides is specifically: HTTP; the first integration instance of type calls the device management service API to obtain the interactive data sent by the terminal to the Internet of Things platform, and extracts the useful data in the load through the upstream converter, converts it into the data format required by the Internet of Things platform, such as the form of topic+payload, and sends it to the Internet of Things platform through MQTT;
[0223] Among them, the first integration instance subscribes to the cmd command topic of the corresponding terminal through the MQTT connection of each logical device, receives the interactive data (also known as downlink data) sent by the Internet of Things platform to the terminal, extracts useful data through the downlink converter, converts it into the data required by the terminal, and sends it to the terminal.
[0224] In the service environment, the running status of the first integrated instance can be monitored to see whether it is running normally online. The first integrated instance needs to monitor the status of the connected terminal to check whether the terminal is working normally. When the health check fails, the terminal will be actively taken offline.
[0225] Fourth, the first integration instance corresponding to the UDP protocol
[0226] Reference Figure 4d As shown, a communication connection diagram of the first integrated instance corresponding to the UDP protocol is shown, such as Figure 4d As shown, in the service environment, the first integration instance of UDP type needs to open a port to the terminal to communicate with the terminal using the UDP protocol, and needs to associate an upstream converter and a downstream converter, and can communicate with the IoT platform using the MQTT protocol. The creation process is:
[0227] First, compile the upstream data conversion script and the downstream data conversion script. For example, compile the upstream data conversion script and the downstream data conversion script for the Text format, and the upstream data conversion script and the downstream data conversion script for the JSON format. The platform receives the compiled data conversion script.
[0228] Next, create the first integration instance for UDP and configure the setting parameters of the first integration instance. The setting parameters are as follows:
[0229] Name—Name
[0230] Type—UDP;
[0231] Enable—Whether to enable;
[0232] Uplink data converter—uplink converter, created when creating an integration, edited on the integration instance page;
[0233] Downlink data converter—a downlink data converter, which is created when the integration is created and edited on the integration instance page;
[0234] Port-port number, can be random or fixed;
[0235] Size of the buffer for inbound socket—size of the socket data receiving buffer, in KB;
[0236] Description—integration description;
[0237] Metadata—integrated metadata, auxiliary information;
[0238] Next, when you set the Enable status to true, the integration instance will be automatically started after successful creation;
[0239] After the integration instance is started, a UDP server will be created. A port will be selected from the provided port pool and fixed as the port provided by the first integration instance. The address, port and other information of the instance can be viewed on the details page of the integration instance.
[0240] When the integration instance is running, a UDP Integration object is created in the memory, the upstream converter and the downstream converter are associated, and the terminal connected to the first integration instance is managed through the device list. It should be noted that the terminal is generally connected to the port provided by the first integration instance to the outside.
[0241] After the first integration instance is created, it may include a DMA module, which maintains an MQTT connection. The MQTT connection is responsible for bidirectional communication with the IoT platform to maintain an online state.
[0242] After the first integration instance is created, it can be responsible for managing all logical devices. The logical device can be understood as a virtual module corresponding to the terminal and connected to the Internet of Things platform. An MQTT connection is created for each logical device, following the clientId format and access rules. Each MQTT connection subscribes to the topic (dma / cma / {sn}) of the corresponding terminal to receive data sent by the Internet of Things platform to the terminal;
[0243] Among them, the MQTT connection is used for two-way communication with the IoT platform.
[0244] Among them, the first integrated instance of the UDP type needs to record the address of the terminal when sending a message to the terminal. Generally, the address of the terminal can be recorded when the terminal sends the first data packet, so as to subsequently feed back the data sent by the Internet of Things platform to the terminal.
[0245] like Figure 4d As shown, when the first integration instance of the UDP type is created and runs, the communication service it provides is specifically as follows: the first integration instance receives the interactive data (also called uplink data) sent by the terminal to the IoT platform, wherein the logical device sends a message to the UDP server at this time, and the uplink converter converts the interactive data, extracts the useful data in the interactive data, converts it into the data format required by the IoT platform, such as the form of topic+payload, and sends it to the IoT platform through MQTT;
[0246] Among them, the first integration instance subscribes to the cmd command topic of the corresponding terminal through the MQTT connection of each device, receives the interactive data (also known as downlink data) sent by the IoT platform to the terminal, extracts useful data through the downlink converter, converts it into the data required by the terminal, and sends it to the terminal.
[0247] Among them, in the service environment, the running status of the first integrated instance can be monitored, whether it is running normally online, whether the UDP server is normal, etc. The first integrated instance should monitor the status of the connected terminal, check whether the terminal is working normally, and actively take the terminal offline when the health check fails.
[0248] Fifth, the first integration instance corresponding to the CoAP protocol.
[0249] Reference Figure 4e As shown, a communication connection diagram of the first integration instance corresponding to the CoAP protocol is shown, such as Figure 4e As shown, the first integrated instance of the CoAP protocol can be used to access the NB-IoT terminal to the Internet of Things platform. The NB-IoT terminal may include a processor MCU, an Internet of Things platform SDK, an NB-IoT module and a SIM card. It uses the CoAP protocol to communicate externally and uses the NB-IoT network after registering and logging in to the operator management platform. The SIM (Subscriber Identity Module) is an IC card held by a mobile user of the GSM (Global System for Mobile Communications). The data processed by the MCU in the terminal is handed over to the SIM card through the Internet of Things platform SDK or the NB-IoT module, and the SIM card accesses the first integrated instance through the NB-IoT network.
[0250] Specifically, the terminal communicates with the first integration instance through the NB-IoT network, and the first integration instance and the Internet of Things platform can communicate using the MQTT protocol. The creation process is:
[0251] First, compile the upstream data conversion script and the downstream data conversion script. For example, compile the upstream data conversion script and the downstream data conversion script for the Text format, and the upstream data conversion script and the downstream data conversion script for the JSON format. The platform receives the compiled data conversion script.
[0252] Next, create the first integration instance for CoAP and configure the setting parameters of the first integration instance. The setting parameters are as follows:
[0253] Name—name;
[0254] Type—CoAP;
[0255] Enable—Whether to enable;
[0256] Uplink data converter—uplink converter, selected from the created list;
[0257] Downlink data converter—Downlink converter, select from the created list
[0258] Security mode—security mode;
[0259] NO SECURE;
[0260] Base URL / Path;
[0261] DTLS;
[0262] Base URL / Path;
[0263] MIMED;
[0264] Base URL / Path;
[0265] DTLS Base URL / Path;
[0266] Description—integration description;
[0267] Metadata—integrated metadata, auxiliary information;
[0268] Next, when you set the Enable status to true, the integration instance will be automatically started after successful creation;
[0269] Among them, when the integration instance is running, it corresponds to a CoAP Integration object in the memory, associates the upstream converter and the downstream converter, and manages the terminal connected to the first integration instance through the device list. It should be noted that the first integration instance of the CoAP type can create a CoAP server, provide a basic POST interface, and the terminal calls the interface of the CoAPserver to report data;
[0270] After the first integration instance is created, it can include a DMA module, which maintains an MQTT connection. The MQTT connection is responsible for bidirectional communication with the IoT platform and maintaining an online state; it manages the list of connected devices. The converter is responsible for data conversion. The device maintains basic information and includes a DMA module. The DMA module maintains an MQTT connection. The MQTT connection is responsible for bidirectional communication with the IoT platform and maintaining an online state;
[0271] Similarly, after the first integration instance is created, it can be responsible for managing all logical devices. The logical device can be understood as a virtual module corresponding to the terminal and connected to the Internet of Things platform. An MQTT connection is created for each logical device, following the clientId format and access rules. Each MQTT connection subscribes to the topic (dma / cma / {sn}) of its corresponding terminal to receive data sent to the terminal by the Internet of Things platform.
[0272] like Figure 4e As shown, when the first integration instance of the CoAP type is created and runs, the communication service it provides is specifically as follows: the first integration instance receives the interaction data (also called uplink data) sent to the IoT platform by calling the CoAP server, and the uplink converter converts the interaction data, extracts useful data from the interaction data, converts it into the data format required by the IoT platform, such as the form of topic+payload, and sends it to the IoT platform through MQTT;
[0273] Among them, the first integration instance subscribes to the cmd command topic of the corresponding terminal through the MQTT connection of each device, receives the interactive data (also known as downlink data) sent by the Internet of Things platform to the terminal, extracts useful data through the downlink converter, converts it into the data required by the terminal, and sends it to the terminal.
[0274] In the service environment, the running status of the first integrated instance can be monitored to see whether it is running normally online. The first integrated instance needs to monitor the status of the connected terminal to check whether the terminal is working normally. When the health check fails, the terminal will be taken offline actively.
[0275] In some embodiments, after the first integration instance and the second integration instance are generated, multiple integration instances can be obtained. In some embodiments, different integration instances can correspond to different objects in memory. In practice, the life cycle of the integration instance can be managed by managing the memory objects. As mentioned above, the life cycle can refer to the period from the start to the end of the operation of the integration instance. In other words, the integration instance can be started or stopped.
[0276] In some embodiments, in response to a stop instruction for an integration instance to be stopped among the multiple integration instances, the operation of the integration instance to be stopped may be stopped to release the communication environment of the corresponding terminal;
[0277] It is also possible to respond to a recovery instruction for an integration instance to be recovered among the multiple integration instances by restarting the operation of the integration instance to be recovered to recover the communication environment of the corresponding terminal.
[0278] In this implementation, the multiple first integration instances may include a first integration instance and a second integration instance. As described in the process of creating each first integration instance and the second integration instance, the operation status of the integration instance may be monitored to determine whether it is operating normally online. Specifically, a heartbeat packet may be sent to the integration instance, and the data packet fed back by the integration instance may be used to determine whether the integration instance is operating normally online. Among them, the integration instance that is not operating normally online may be stopped, and then restarted after stopping. When stopping the integration instance, its enable state Enable may be set to false, and when restarting the integration instance, its enable state Enable may be set to true.
[0279] Among them, when the operation of the integration instance is stopped, the MQTT connection between the integration instance and the Internet of Things platform can be disconnected at the same time. For example, if the first integration instance is stopped, the MQTT connection between the logical device and the Internet of Things platform can be disconnected. In this way, the disabled integration instance is prevented from occupying the MQTT connection resources of the Internet of Things platform, which is equivalent to releasing the terminal communication environment of a certain communication type. For example, if the first integration instance of the TCP type is stopped, the service environment lacks an environment to provide services for TCP type terminals, and this type of terminal cannot interact with the Internet of Things platform.
[0280] When the integration instance is stopped, the port of the stopped integration instance can be released so that the port can be used by other new integration instances. When the stopped integration instance is restored, a new port can be reassigned to the integration instance.
[0281] Of course, when restoring a stopped integration instance, you can also restore the MQTT connection between the logical device and the IoT platform. In this way, you can restore the terminal communication environment of a certain communication type, so that this type of terminal can access the IoT platform again.
[0282] In some embodiments, both the first integration instance and the second integration instance can be run in a memory object. In specific implementation, a memory object can be allocated from the memory for the integration instance, and the integration instance can be run in the memory object.
[0283] As described above, when you need to stop the operation of a certain integration instance, you can stop the integration instance through the corresponding memory object. For example, if you need to stop the first integration instance of TCP type, you can find the TCP Integration in the memory, stop the TCP server, and then stop the operation of the first integration instance. It should be noted that for integration instances corresponding to different communication protocols, they correspond to different objects in the memory.
[0284] In some embodiments, if the number of terminals connected is huge, it is necessary to improve the demand for responding to the large number of terminals accessing the Internet of Things platform. In this way, in order to provide efficient communication services for a large number of terminals, when generating an integration instance corresponding to each communication protocol, multiple candidate integration instances can be mirrored, that is, multiple integration instances for the communication protocol are copied, and the multiple candidate integration instances are deployed to different operating environments for operation. Different operating environments can be different memory blocks in the server memory, or can refer to different servers. When a large number of terminals using the same communication protocol need to communicate with the Internet of Things platform, the requests of these terminals can be called to multiple candidate integration instances, so as to support the communication needs of multiple terminals in a distributed manner through multiple candidate integration instances.
[0285] In specific implementation, multiple candidate integration instances corresponding to the integration instance can be mirrored, and the corresponding converters of the multiple candidate integration instances can be mirrored; and the multiple candidate integration instances and the corresponding converters can be deployed in multiple different operating environments respectively to provide a distributed communication environment for multiple terminals using the same communication protocol.
[0286] In this embodiment, whether it is the first integration instance or the second integration instance, multiple candidate integration instances can be mirrored for one integration instance; or, multiple candidate integration instances can be mirrored only for the first integration instance, or, multiple candidate integration instances can be mirrored only for the second integration instance; or, multiple candidate integration instances can be mirrored for an integration instance with a large access traffic. The different candidate integration instances mirrored can run in different hardware and software environments, such as including multiple servers, and different candidate integration instances can run in different servers.
[0287] Among them, for each candidate integration instance, the corresponding converter can be mirrored, that is, for a communication protocol, there are multiple communication environments to provide services, with a certain large traffic access requirement. Specifically, the converter mirrored by each candidate integration instance can be implemented in a distributed manner, that is, multiple candidate integration instances mirrored by the same integration instance correspond to the same conversion engine, and the requests sent by different candidate integration instances are sent to their corresponding converters through the same conversion engine. Specifically, refer to the first engine service of the above-mentioned integration instance, which will not be repeated here.
[0288] Among them, when multiple candidate integration instances are mirrored, a scheduling module can be configured for the multiple candidate integration instances. The scheduling module provides a unified external interface to respond to the connection of the terminal. Then the scheduling module can be used to schedule the terminal to one of the candidate integration instances according to the operating parameters of the current operating environment of the multiple candidate integration instances, so as to provide communication services for the terminal through the scheduled candidate integration instance.
[0289] For example, for the first integration instance of TCP type, its access volume is relatively high, and three candidate integration instances and converters corresponding to the three candidate integration instances can be mirrored. Each candidate integration instance corresponds to three groups of converters, with a total of 9 converters. Among the three candidate integration instances, candidate integration instance 1 runs on server 1, candidate integration instance 2 runs on server 2, and candidate integration instance 3 runs on server 3; these 9 converters are uniformly stored in the database and called by the three candidate integration instances through the same first engine service to cope with the larger access traffic.
[0290] Below, refer to Figure 7 and Figure 8 The flowchart shown, Figure 7 A flow chart for creating a service environment. Figure 8 To create a service environment and a schematic diagram of the process of performing terminal communication, the method for generating the service environment proposed in the present disclosure is exemplarily and completely described:
[0291] Among them, the IoT platform needs to access devices with several different communication protocols, including TCP, UDP, and MQTT protocols; developers need to quickly develop a service environment to meet communication needs, so developers log in to electronic devices and use infrastructure software such as EMQM (infrastructure software used for IoT application development and IoT platform construction) to build a service environment, including the following steps:
[0292] S1: Before creating an integration instance, the developer first compiles a data conversion script corresponding to each communication protocol. When compiling the data conversion script, the script can be specifically compiled according to the data format of the data sent by the terminal corresponding to the communication protocol.
[0293] It can be understood that the data conversion script may include an uplink data conversion script and a downlink data conversion script. The uplink data conversion script is used to convert the interactive data sent by the terminal to the Internet of Things platform into the data format required by the Internet of Things platform, and the downlink data conversion script is used to convert the interactive data sent by the Internet of Things platform to the terminal into the data format required by the terminal.
[0294] Among them, if the data format required by the terminal can include Text type, JSON (JavaScript Object Notation) type, then the compiled upstream data conversion script is as described above.
[0295] S2: Create an integration instance that adapts to the communication protocol type, such as Figure 8 As described in 1.1 and 1.2, when creating a TCP-type integration instance, a UDP-type integration instance, and an MQTT-type integration instance, the developer also sets the setting parameters of the integration instance. These setting parameters include: instance name, communication protocol type (such as TCP / UDP), whether to enable (Enable), upstream data conversion script, downstream data conversion script, port address, connection queue maximum request length, data receive buffer size, data send buffer size, instance description, integration instance metadata, and auxiliary information.
[0296] S3: After setting, set the status of whether to enable to the start status. That is, when Enable is set to true, the instance is automatically started after successful creation. When the integration instance is automatically started, the data conversion script (including the upstream data conversion script and the downstream data conversion script) is passed to the integration instance through interface injection, and the two converters associated with the integration instance are formed.
[0297] When starting an integration instance, a JS Engine VM can be automatically allocated to each integration instance, and the upstream data conversion script and the downstream data conversion script can be bound. In this way, the script method is mapped to the golang method, and when providing communication services to the terminal later, the golang method is directly called to convert the interactive data.
[0298] S4: After the integration instance is started, a TCP server is created for the TCP communication protocol. A port is selected from the port pool and fixed as the port of the integration instance. The address of the port can be viewed on the details page of the integration instance.
[0299] For the UDP communication protocol, a UDP server will be created, and a port will be selected from the port pool and fixed as the port of the integration instance. The address of the port can be viewed on the details page of the integration instance.
[0300] For the MQTT communication protocol, after starting the integration instance of the MQTT type, the integration instance connects to the configured MQTT borker and subscribes to topics according to topic filters;
[0301] Among them, the above integration instance corresponds to an object in the memory during runtime, such as the TCP type integration instance corresponds to the TCP Integration object in the memory, the MQTT type integration instance corresponds to the MQTT Integration object in the memory, and the UDP type integration instance corresponds to the UDPIntegration object in the memory.
[0302] S5: Associate a device maintenance module and a DMA module with each integration instance, wherein the device maintenance module is used to maintain basic information of devices connected to the integration instance, and the DMA module is used to maintain the MQTT connection between the integration instance and the IoT platform, wherein the MQTT connection is responsible for bidirectional communication with the IoT platform and maintaining an online state.
[0303] S6: Developers can stop the integration instance by finding the memory object corresponding to the integration instance in the memory. For example, for TCP type communication protocols, developers can find TCP Integration in the memory and stop the TCP server. In this case, all devices connected to the integration instance are offline, and the MQTT connection between the integration instance and the IoT platform is released at the same time, finally ending the integration instance.
[0304] For UDP type integration instance, you can stop it by referring to the TCP type integration instance.
[0305] For MQTT type integration instances, developers can find the MQTT Integration in memory and disconnect the MQTT broker connection. In this case, all devices connected to the integration instance are offline, and the MQTT connection between the integration instance and the IoT platform is released at the same time, eventually ending the integration instance.
[0306] S7: Developers can develop a health monitoring program that can monitor the running status of all integration instances and whether they are online, and restart the integration instances that are offline or have a faulty running status.
[0307] S8: For integration instances that require changes to data conversion scripts, developers map script methods to golang methods after compiling new data conversion scripts, and directly change the VM of JS Engine to bind the new data conversion script to the integration instance. This change can take effect when the integration instance is running. There is no need to redeploy the integration instance and code. Only the VM of JS Engine needs to be changed, thus realizing low-code device access.
[0308] Among them, VM is a component that supports program runtime and provides the API environment required for code execution. Engine is a processing abstraction that is responsible for converting code into underlying executable code. In the present disclosure, both VM and Engine are used as components that run as converters of integrated instances.
[0309] S9: If the IoT platform needs to connect to a third-party platform or application, it is necessary to create an integration instance corresponding to the communication protocol of the third-party platform and application, such as the HTTP communication protocol. The process can refer to the above steps S1-S4. It should be noted that in step S4, the HTTP type integration instance runs an HTTPIntegration object in the memory, and an HTTP connection is established between it and the third-party platform and application.
[0310] S10. If the IoT platform needs to connect to devices with custom communication protocols, it is necessary to create integration instances for these devices with custom communication protocols, i.e., the second integration instance. For the specific process, refer to Figure 8 4.1 to 5.3, specifically:
[0311] S10-1: Before creating the second integration instance, you can compile the agent package (the agent described above), such as Figure 8 As shown in 4.1, the agent package is used to manage the custom communication program corresponding to the device with the custom communication protocol, and the custom communication program is generally uploaded by the device manufacturer;
[0312] S10-2: Create a second integration instance of the Custom type, and the developer sets the setting parameters of the second integration instance at the same time, such as Figure 8 As shown in 4.2, these setting parameters include: instance name, communication protocol type (such as Custom), whether to enable (Enable), uploaded agent package, running instruction configuration parameters (such as . / main|java-jarmain.jar, etc.), configuration items (json format, which are eventually injected into the plug-in program by the host program), instance description and other parameters;
[0313] S10-3: Enable the second integration instance, such as Figure 8As shown in 5.1, specifically, the state of whether to enable is set to the start state, that is, when Enable is set to true, the second integration instance is automatically started. When the second integration instance is started, the storage address, CMD, Config and other parameter information of the agent package are obtained. In this case, the agent is officially running. When it is officially running, it can download the custom communication program uploaded by the user, and download and run it in the corresponding docker container in the form of a plug-in. The CMD command is called to pull up the plug-in program. At this time, a child process will be replicated to execute the plug-in program.
[0314] At this point, the creation of the service environment is completed. Fig. 9 As shown, a schematic diagram of the framework of the service environment created by it is shown.
[0315] The CMD command starts a new instance of the command interpreter, usually Cmd.exe. If used without parameters, CMD will display the operating system version and copyright information;
[0316] After the plug-in is started, the second integration instance is started, and the second integration instance monitors the connection with the plug-in through the proxy program, and responds to requests from the plug-in and requests from the terminal of the custom communication protocol;
[0317] The plug-in communicates with the agent through gRPC. Specifically, gRPC can be called, such as Figure 8 As shown in 5.2 and 5.3, the second integration instance communicates with the agent program via gRPC;
[0318] Among them, the second integration instance corresponds to the CustomIntegration (custom integration) in the memory when it is running.
[0319] S10-4: If you want to stop the second integration instance, you can find the CustomIntegration in the memory. The second integration instance sends instructions to the agent program. The agent stops the plug-in. All devices corresponding to the plug-in are offline, that is, the communication of all devices served by the plug-in is stopped, and the MQTT connection between the plug-in and the IoT platform is released, finally ending the second integration instance.
[0320] Among them, one second integration instance can manage multiple plug-ins of different custom communication protocols, so that when the second integration instance is stopped, all plug-ins stop running. Alternatively, one second integration instance can manage a plug-in of a custom communication protocol, so that when one second integration instance is stopped, the plug-in managed by the second integration instance stops running, while the plug-ins managed by the remaining second integration instances that are not stopped continue to run.
[0321] The method for generating a service environment according to the embodiment of the present disclosure is adopted. When creating the above-mentioned service environment, developers only need to create an integrated instance that adapts to the communication protocol and upload a data conversion script to obtain a service environment for supporting the first type of terminal communication. In other words, developers only need to write data conversion scripts for the access of different protocol devices, and pass the conversion scripts to the integrated instance through interface injection. In this way, low-code device access can be supported, thereby improving the access development efficiency of terminals produced by different hardware manufacturers.
[0322] Specifically, it has the following advantages:
[0323] Advantage 1: The integration instance can be an independent microservice, supports distributed deployment of converters, and can communicate with microservices in the form of service registration / discovery; supports horizontal expansion and supports expansion and contraction of the number of access devices.
[0324] Advantage 2: When creating an integration instance, you only need to write a data conversion script for the access of terminals with different protocols, and pass the conversion script to the integration instance through interface injection. Therefore, it can support low-code terminal access. When the data conversion script is changed, it can take effect when the integration instance is running, without the need to redeploy the integration instance and code.
[0325] Advantage 3: Various first integration instances can support multiple common transmission protocols, including TCP, MQTT, HTTP, UDP, CoAP, etc.
[0326] Advantage 4: Integration instances and converters can be created and modified at runtime. Each integration instance corresponds to a memory object, which occupies little resources. It can also support the management of the life cycle of integration instances to adapt to the needs of the IoT platform.
[0327] Advantage 5: For custom communication protocols, it can support hosting custom programs in the form of plug-ins, and create custom integration instances (second integration instances) at runtime, change configurations through agent programs and inject them into plug-in programs, and monitor and manage the life cycle of plug-ins.
[0328] Advantage 6: For custom communication protocols, the plug-in uses PB (protobuf) as IDL (interface definition language), communicates in gRPC mode, and supports plug-ins in multiple development languages (as long as the gRPC interface can be implemented).
[0329] Advantage 7: For custom communication protocols, the agent and the second integration instance can manage all plug-ins, can be deployed as independent microservices, support horizontal expansion, and build a communication bridge for IoT platform management plug-ins in the role of an intermediary.
[0330] Advantage 8: When deploying the converter, you can deploy it through the JS Engine architecture to improve flexibility. It can be implemented in an embedded or distributed manner, and can support larger service traffic.
[0331] <Terminal Communication Method>
[0332] After obtaining the above service environment, a communication bridge between the terminal and the IoT platform is created, through which the IoT platform can be provided with efficient communication services for interacting with the terminal.
[0333] Among them, the terminal communication method based on the above service environment is introduced, referring to Figure 6 As shown, a schematic diagram of the step flow of a terminal communication method is shown, such as Figure 6 As shown, the method can be run in a server or a cloud, and can specifically include the following steps:
[0334] Step S601: In response to the access of a terminal, an integration instance corresponding to the terminal is called, where the integration instance is used to support communication between multiple terminals using the same communication protocol;
[0335] Step S602: performing conversion processing on the interactive data related to the terminal through the integrated instance, the conversion processing comprising: converting the communication protocol of the interactive data and / or the data format of the interactive data according to the attributes of the destination end to which the interactive data is to be delivered; wherein the destination end is the terminal or the Internet of Things platform;
[0336] Step S603: Send the target data obtained after the conversion process to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform.
[0337] In this embodiment, terminal access may refer to: the terminal accesses the port provided by the integration instance. As described in the above service environment generation embodiment, if it is a first integration instance of the TCP type, the first integration instance provides a port for the terminal to access. When the terminal accesses the port, the first integration instance can be called to provide communication services for the terminal. Specifically, the first integration instance can allocate a logical device to the terminal, establish an MQTT connection between the logical device and the Internet of Things platform, and add the terminal to the maintained device list.
[0338] It can be understood that an integration instance is generally used to provide communication services for multiple terminals that adopt a communication protocol. For example, the first integration instance of TCP type can provide communication services for multiple terminals that communicate using the TCP communication protocol; that is, all terminals that communicate using the TCP communication protocol need to access the first integration instance of TCP type to communicate with the Internet of Things platform.
[0339] In step S602, the called integration instance acts as a communication bridge between the terminal and the Internet of Things platform. It is necessary to convert the interactive data uploaded by the terminal to the Internet of Things platform according to the data format required by the Internet of Things platform, and to convert the interactive data sent by the Internet of Things platform to the terminal according to the data format required by the terminal, and send the converted data out (to the terminal or to the Internet of Things platform).
[0340] In the present disclosure, interactive data is a general term, which includes data uploaded by the terminal to the IoT platform, and may also include data sent by the IoT platform to the terminal; in practice, the integrated instance needs to convert and process the interactive data according to the destination it is to reach.
[0341] Among them, the conversion process in the present disclosure may include: conversion of communication protocols and conversion of data formats, or may only refer to conversion of communication protocols, or only include conversion of data formats. Specifically, when the data format used by the terminal is consistent with the data format required by the IoT platform, only the communication protocol conversion is required; when the data format used by the terminal is inconsistent with the data format required by the IoT platform, but the communication protocol is consistent (such as both using the MQTT protocol), only the data format conversion is required; when the data format used by the terminal is inconsistent with the data format required by the IoT platform and the communication protocol is inconsistent, the data format and communication protocol conversion are required.
[0342] Among them, the conversion of the communication protocol can be performed by the integration instance, and the conversion of the data format can be performed by the converter. As described in the above service environment generation embodiment, each integration instance is associated with a converter, wherein the integration instance can complete the conversion of the data format of the interactive data by calling the converter (data conversion script).
[0343] Among them, when the destination of the interactive data is the IoT platform, after the interactive data is converted, the target data adapted to the IoT platform can be obtained, that is, the data format and communication protocol of the target data are adapted to the data format and communication protocol required by the IoT platform, so that the target data can be sent to the IoT platform through the integration instance. Specifically, the integration instance can call the logical device and upload the target data to the IoT platform through the MQTT connection between the logical device and the IoT platform.
[0344] In the case where the destination of the interactive data is a terminal, after the interactive data is converted, the target data adapted to the terminal can be obtained, that is, the data format and communication protocol of the target data are adapted to the data format and communication protocol required by the terminal, so that the target data can be sent to the terminal through the integration instance. Specifically, the integration instance can send the target data to the terminal through the provided port.
[0345] Among them, the process of how the integrated instances of different communication protocols forward data between the terminal and the Internet of Things platform can be found in detail in the process described in the above-mentioned service environment generation embodiment, which will not be repeated here.
[0346] By adopting the technical solution of this embodiment, since the terminals that are connected to communicate with the Internet of Things platform can undertake data conversion and data forwarding between the terminals and the Internet of Things platform through the integrated instance, even if there are a large number of terminals, they can still communicate through their corresponding integrated instances, so that the Internet of Things platform can establish communication with terminals produced by different hardware manufacturers, thereby improving the adaptability of the Internet of Things platform to different terminals, so that the Internet of Things platform can be deeply deployed in various application fields.
[0347] In some embodiments, the stability of the connection between the terminal and the integration instance can be monitored. If it is unstable, the calling relationship between the integration instance and the terminal can be terminated to prevent the disconnected terminal from occupying the port resources of the integration instance.
[0348] During specific implementation, the connection status between the terminal and the integration instance can be monitored, and when the connection status is offline, the call of the terminal to the integration instance is released.
[0349] Among them, the terminal can be connected to the integration instance through the port corresponding to the integration instance, and the integration instance can determine whether the terminal is offline by monitoring the port to which the terminal is connected. If the terminal is offline, the terminal's call to the integration instance can be released. Specifically, the integration instance can stop the communication service to the terminal, for example, power off the terminal, and at the same time stop the operation of the logical device corresponding to the terminal, and disconnect the MQTT connection between the logical device and the Internet of Things platform. When the terminal is connected to the port again, the terminal's call to the integration instance can be restored, specifically, the operation of the logical device corresponding to the terminal can be restored, and the MQTT connection between the logical device and the Internet of Things platform can be restored.
[0350] In some embodiments, as described in the above-mentioned service environment generation method embodiment, multiple candidate integration instances can be mirrored for the integration instance of the same communication protocol, and the multiple candidate integration instances can be deployed in different operating environments, that is, deployed in multiple physical spaces, so as to provide distributed integration instances for multiple terminals using the same communication protocol to meet their massive access volume.
[0351] In a specific implementation, when a terminal access is detected, a candidate integration instance can be selected from multiple candidate integration instances corresponding to the terminal and called to the terminal. Specifically, in response to the terminal access, multiple candidate integration instances adapted to the terminal can be determined; and based on the operating environment parameters of each of the multiple candidate integration instances and / or the access frequency of the terminal, the integration instance corresponding to the terminal is called.
[0352] In this embodiment, for the same communication protocol, there will be multiple candidate integration instances for calling, where different candidate integration instances are located in different operating environments. Multiple candidate integration instances can be connected to a scheduling module, which provides a unified external interface to respond to the connection of the terminal. Then the scheduling module needs to schedule the terminal to one of the candidate integration instances to provide communication services to the terminal through the scheduled candidate integration instance.
[0353] Specifically, the candidate integration instance to be scheduled can be determined based on the operating environment parameters of each of the multiple candidate integration instances. The operating environment parameters can be used to characterize the current hardware and software performance of the operating environment in which the candidate integration instance runs, such as the remaining computing resources of the hardware, the version of the software, the operating rate, etc. In this way, the candidate integration instance running in the operating environment with better performance can be determined based on the operating environment parameters, and the candidate integration instance can be used as the integration instance for providing communication services to the terminal, so that the terminal can be scheduled to the integration instance.
[0354] When the terminal is dispatched to the integration instance, the terminal can be connected to the port provided by the integration instance, so that the terminal can subsequently communicate with the IoT platform through the port. It should be noted that different candidate integration instances can provide different ports for terminal access.
[0355] The candidate integration instance to be scheduled may also be determined according to the access frequency of the terminal, and the access frequency may be used to characterize the frequency of the terminal accessing the IoT platform, wherein the access frequency may be determined by the frequency of the terminal accessing the IoT platform within a preset period before the current time;
[0356] The higher the access frequency, the more it is necessary to schedule the terminal to a candidate integration instance with a higher performance configuration of the operating environment. For example, if the access frequency exceeds a certain threshold, the terminal is scheduled to a candidate integration instance with a performance configuration of the operating environment exceeding a preset performance configuration.
[0357] Alternatively, the higher the access frequency, the more the terminal needs to be scheduled to a candidate integration instance with fewer external terminals. For example, if the access frequency exceeds a certain threshold, the terminal is scheduled to a candidate integration instance with fewer access terminals than a preset number.
[0358] Among them, the candidate integration instance to be scheduled can also be jointly determined according to the access frequency and operating environment parameters of the terminal. Specifically, different levels of access frequency can be pre-divided, such as high level, medium level and low level, and the lower the level, the lower the access frequency; different levels of operating environment parameters can also be pre-divided to determine the level of the candidate integration instance according to the operating environment parameters of the candidate integration instance. For example, the candidate integration instances are also divided into high level, medium level and low level. The lower the level, the lower the performance of the current operating environment.
[0359] Therefore, when the terminal accesses, the level of the terminal can be determined according to the access frequency of the terminal. Then, the candidate integration instance to be scheduled for the terminal can be determined according to the level of the terminal and the current level of the operating environment of the candidate integration instance. Specifically, the candidate integration instance at the same level as the terminal can be used as the integration instance to be scheduled by the terminal. For example, if the access frequency of the terminal is at a high level, the terminal can be scheduled to the candidate integration instance that is also at a high level. If the access frequency of the terminal is at a low level, the terminal can be scheduled to the candidate integration instance that is also at a low level.
[0360] When this implementation is adopted, the candidate integration instance with matching performance can be used to provide communication services for the terminal. In this way, for multiple terminals using the same communication protocol, matching communication services can be provided for multiple terminals by scheduling multiple candidate integration instances. For example, for a TCP type communication protocol, there are 10,000 terminals that need to communicate with the Internet of Things platform. At this time, 5 candidate integration instances are mirrored. According to the operating environment parameters corresponding to each of the 5 candidate integration instances and the access frequency of each of the 10,000 terminals, 5 candidate integration instance services can be scheduled in real time for the 10,000 terminals, thereby achieving reasonable utilization of resources. This can quickly respond to the communication requests of 10,000 terminals and avoid the problem of service paralysis caused by a large number of request congestion.
[0361] In some embodiments, as shown in the above-mentioned service environment, the integration instance may include a first integration instance of a first type and a second integration instance of a second type, wherein the first integration instance is associated with a converter, and the second integration instance manages a custom program running as a plug-in, thereby, when the interactive data related to the terminal is converted and processed through the integration instance, different types of integration instances may adopt different conversion processing logic.
[0362] In specific implementation, when the integration instance is the first integration instance, the interaction data can be sent to the target converter to instruct the target converter to perform conversion processing on the interaction data; wherein the target converter is a converter corresponding to the destination end among at least two converters associated with the first integration instance; and, when the integration instance is the second integration instance, the interaction data is sent to the plug-in corresponding to the terminal to instruct the plug-in to perform conversion processing on the interaction data.
[0363] In this implementation, the first integration instance is an integration instance of a general communication protocol type. Since it adopts a low-code device access method, when it is created, the developer only needs to compile the data conversion script, and inject it into the interface of the first integration instance after debugging. Therefore, when the terminal is connected to the first integration instance, the interactive data uploaded by the terminal to the Internet of Things platform and the interactive data sent to the terminal by the Internet of Things platform need to be converted by the corresponding converter.
[0364] As described in the above embodiment, the first integrated instance can schedule the target converter among the associated converters according to the destination end to which the interactive data is to be delivered, and use the target converter to convert the interactive data, wherein if the interactive data is to be delivered to the Internet of Things platform, the target converter is an upstream converter, and if the interactive data is to be delivered to the terminal, the target converter is a downstream converter.
[0365] Among them, since the second integration instance is an integration instance of a custom communication protocol type, it performs data conversion by a custom program package uploaded by the manufacturer. Therefore, when the terminal is connected to the second integration instance, the interactive data uploaded by the terminal to the Internet of Things platform and the interactive data sent by the Internet of Things platform to the terminal can be converted and processed by the plug-in.
[0366] Accordingly, in some embodiments, in order to improve communication accuracy and avoid data errors on the Internet of Things platform that may cause node congestion on the Internet of Things platform and affect subsequent processing, the target data that needs to be uploaded to the Internet of Things platform after conversion can be verified and sent to the Internet of Things platform after passing the verification, so as to reduce the number of erroneous target data on the Internet of Things platform and ensure the efficient operation of the Internet of Things platform.
[0367] In specific implementation, when the target converter is the converter corresponding to the Internet of Things platform, the target data fed back by the target converter is verified to verify whether the data structure of the target data conforms to the preset structure; accordingly, if the verification passes, the target data can be sent to the Internet of Things platform through the first integration instance.
[0368] Among them, the converter corresponding to the Internet of Things platform is the uplink converter mentioned above. The target data fed back by the target converter needs to be uploaded to the Internet of Things platform. Therefore, it can be verified. The verification is specifically used to verify whether the data structure of the target data conforms to the preset structure, wherein the preset structure can refer to a map structure (graph structure) and includes necessary attributes such as sn, category, msgType, and authentication results.
[0369] Among them, the map structure is a collection that maps key objects and value objects, and each of its elements contains a pair of key objects and value objects. Secondly, Map does not inherit the Collection interface. When retrieving elements from the Map collection, as long as the key object is given, the corresponding value object will be returned.
[0370] Among them, Collection is the most basic collection interface. A Collection represents a group of Objects, namely, the elements of the Collection. Some Collections allow the same elements while others do not.
[0371] Among them, sn (serial number), category (category) and msgType (message type) are required attributes. After the data structure of the target data is verified, the target data is sent to the Internet of Things platform.
[0372] Therein, the target data fed back by the downstream converter does not need to be verified and can be directly returned to the terminal.
[0373] When this implementation is adopted, a timeout process can also be added to the upstream converter to avoid execution errors or excessive occupation of server resources, thereby preventing erroneous data or timed data from being congested on the IoT platform and affecting the communication of other terminals.
[0374] In which case, in which the conversion processing of interactive data can be performed by the target converter, as described in the above-mentioned service environment generation method embodiment, the converters corresponding to each first integration instance can be associated with the first integration instance through embedded deployment and distributed deployment. In which, the embedded deployment can be that a first integration instance calls the converter through a corresponding engine service, and the distributed deployment can be that one engine service calls the converters of multiple first integration instances. In this regard, when performing the conversion processing of interactive data, for the distributed deployment method, the interactive data can be sent to the first engine service to instruct the first engine service to send the interactive data to the target converter based on the identifier of the first integration instance; wherein the first engine service corresponds to the converters associated with multiple different first set instances;
[0375] For the embedded deployment mode, the interaction data may be sent to the second engine service corresponding to the first integration instance to instruct the second engine service to send the interaction data to the target converter; wherein different second engine services correspond to different first integration instances.
[0376] In specific implementation, when the converter is deployed in a distributed manner, the first integration instance can send the interaction data to MQ
[0377] In the process, after the first engine service retrieves the interaction data from MQ, it sends it to the corresponding converter according to the identifier of its integration instance, and then throws the execution result output by the converter back to MQ. The first integration instance can obtain the execution result from MQ, and then extract the useful data in the execution result, encapsulate it into MQTT protocol data, and send it to the Internet of Things platform.
[0378] As described above, the first engine service corresponds to converters associated with multiple different first set instances. These converters can be stored in a database, and the first engine service is called through a Redis method.
[0379] In specific implementation, when the converter is deployed in an embedded manner, the first integration instance can send the interaction data to the second engine service, the second engine service sends it to the corresponding converter, and then throws the execution result output by the converter back to the first integration instance. The first integration instance then extracts the useful data from the execution result, encapsulates it into MQTT protocol data, and sends it to the Internet of Things platform.
[0380] Both of the above two deployment methods can realize the conversion of interactive data using converters.
[0381] Next, how to maintain the integration instance mentioned in this disclosure is described.
[0382] In some embodiments, since multiple integration instances may be included, the multiple integration instances may include a first integration instance corresponding to multiple different general communication protocols, and a second integration instance corresponding to multiple custom protocols. In practice, the faulty integration instance can be restarted by listening to the port of the integration instance to maintain each integration instance.
[0383] In a specific implementation, the ports bound to the multiple integration instances may be monitored, and according to the monitoring result, the integration instance with the fault may be determined; and the integration instance with the fault may be restarted.
[0384] In this implementation, when monitoring the ports bound to multiple integration instances, heartbeat packets can be sent to the multiple integration instances, and the status of the multiple integration instances can be determined based on the data packets fed back by the multiple integration instances, and then the faulty integration instances can be restarted.
[0385] Accordingly, in some examples, after restarting the failed integration instance, the state of the terminal connected to the integration instance before the failure can be restored. In specific implementation, multiple target terminals previously connected to the failed integration instance can be reconnected to the restarted integration instance; and for each target terminal, the most recent historical interaction data from the current moment is obtained; and the historical interaction data is converted and processed by the restarted integration instance to restore the communication state of each target terminal before the failure.
[0386] In this implementation, the multiple target terminals previously connected to the failed integration instance may refer to the terminals connected to the port of the integration instance before the integration instance is stopped. When the integration instance is stopped, the target terminal is offline because the terminal access is stopped. In this case, when the integration instance is restored, the connection between the target terminal and the integration instance needs to be restored. When the connection between the target terminal and the integration instance is restored, the business previously performed by the target terminal can be restored, and the historical interaction data of the last interaction between the target terminal and the Internet of Things platform can be obtained.
[0387] Specifically, the integrated instance can store the interaction data between the terminal and the IoT platform before being stopped. In this way, the historical interaction data can be the stored interaction data, which can be the data uploaded by the terminal to the IoT platform or the data sent by the IoT platform to the terminal. When storing the historical interaction data, the integrated instance can send the interaction data to the database for storage and add the identifier of the target terminal. It should be noted that the stored interaction data can be the last interaction data before being stopped, so as to avoid excessive occupation of server resources by the interaction data storage.
[0388] After the integration instance is restored, the integration instance can convert the interactive data using the corresponding target converter or plug-in according to the above conversion processing method, and then send the converted data to the destination it should reach. For example, if the historical interactive data is data sent from the IoT platform to the terminal, the restored integration instance will send the converted data to the terminal; if the historical interactive data is data uploaded to the IoT platform, the restored integration instance will send the converted data to the IoT platform. In this way, the business of the target terminal before the integration instance was stopped can be restored, so that the user of the target terminal can continue the business that was suspended due to the restart of the integration instance.
[0389] Below, through several specific implementation scenarios and Figure 8 As shown, the terminal communication method proposed in the present disclosure is described:
[0390] Scenario 1: Monitoring the server room, which requires monitoring the temperature, humidity, and dust of the server room. Generally, various sensors and control devices are configured in the server room. These sensors are used to collect temperature, humidity, and dust information of the server room, and the control devices are used to cool down, heat up, dehumidify, humidify, and remove dust from the server room. Among them, various sensors and control devices are required to communicate with the IoT platform. The sensors send the collected information to the IoT platform, and the IoT platform sends control information to the control devices.
[0391] In actual scenarios, various sensors and control devices are generally purchased from different manufacturers, resulting in different communication protocols. You can first build a service environment according to the above service environment generation method, and then deploy the service environment to the IoT platform to support the communication between various sensors and control devices and the IoT platform. The process is as follows:
[0392] S1: Multiple sensors T1 using the TCP protocol are connected to the port where the first integration instance of the TCP type (hereinafter referred to as integration instance A) is located. At this time, the data transmitted by the sensor T1 is the humidity data of the service room, which is transmitted to the port using the TCP protocol;
[0393] S2: Integration instance A receives humidity data uploaded by sensor T1, such as Figure 8 As shown in 2.1-2.5, the humidity data is sent to the upstream converter (upstream data conversion script) corresponding to the integration instance A, and the humidity data in text format is converted into the data format required by the Internet of Things platform through the upstream converter;
[0394] S3: Integration instance A obtains the execution result fed back by the upstream converter, that is, the target data obtained after conversion; Figure 8 As shown in 2.2 and 2.3.
[0395] S4: Integration instance A extracts and encapsulates the target data into topic+payload format and sends it to the IoT platform via the MQTT protocol; Figure 8 As shown in 2.4 and 2.5.
[0396] S5: Multiple sensors T2 using a custom communication protocol are connected to the port of a second integration instance of a custom type (hereinafter referred to as integration instance B). At this time, the data transmitted by the sensor T2 is the temperature data of the service room, which is transmitted to the port provided by the integration instance B using the custom communication protocol; Figure 8 As shown in 6.1.
[0397] S6: Integration instance B receives the temperature data uploaded by sensor T2 and sends the temperature data to the agent corresponding to integration instance B, such as Figure 8 As shown in 6.2, and sent to the plug-in through the agent program, the plug-in is a custom degree package uploaded by the manufacturer of sensor T2, which runs in plug-in mode, and the plug-in converts the temperature data into the data format required by the Internet of Things platform;
[0398] S7: Integration instance B obtains the execution result fed back by the plug-in, that is, the target data obtained after conversion;
[0399] S8: Integration instance B extracts and encapsulates the target data into topic+payload format and sends it to the IoT platform via the MQTT protocol. Figure 8 As shown in 6.3.
[0400] The above steps S1-S8 are the process of how to send the data collected by the sensor to the Internet of Things platform. The process of sending the data collected by the sensor using other general communication protocols to the Internet of Things platform can refer to the above process.
[0401] In this case, the IoT platform will determine whether the server room needs to be cooled, heated, or dehumidified based on the temperature data and humidity data and according to the internal logic. If cooling, heating, or dehumidification is required, it will generate operation data for the control device and send the operation data as downlink data to the corresponding integration instance, such as Figure 8 The integration instance is the integration instance corresponding to the port to which the control device is connected;
[0402] S9: When one of the TCP-type integration instances A receives the downlink data fed back by the IoT platform to a certain control device, the downlink data is sent to the downlink converter (downlink data conversion script), and the downlink converter converts the downlink data into a data format corresponding to the control device; Figure 8 As shown in 7.1 and 7.2.
[0403] S10: The integrated instance A sends the converted target data to the control device through the TCP protocol, so that the control device performs temperature control operations on the server, such as cooling, heating, etc. Figure 8 7.3 is combined with 7.4.
[0404] Scenario 2: In the student management system, it is necessary to manage the student cards worn by students, such as swiping cards to enter the library, school gate, and make payments, and it is necessary to push notification messages to students. Generally, student cards are low-performance devices, such as electronic ink screens. Student cards communicate with the school's IoT platform to swipe cards to enter the library, school gate, and make payments, and the IoT platform pushes notification messages to student cards.
[0405] S1: Multiple student cards C using UDP protocol are connected to the port of the first integration instance of UDP type (hereinafter referred to as integration instance C). At this time, the data transmitted by the student card C includes payment data and card swiping request data according to different functions; the data transmitted by the student card C can be text format data;
[0406] S2: Integration instance C receives the data uploaded by student card C, and sends the data to the upstream converter (upstream data conversion script) corresponding to integration instance C. The upstream converter converts the text format data into the data format required by the IoT platform;
[0407] S3: The integrated instance C obtains the execution result fed back by the upstream converter, that is, the target data obtained after conversion;
[0408] S4: Integration instance C extracts and encapsulates the target data into topic+payload format and sends it to the IoT platform through the MQTT protocol;
[0409] S5: When the integration instance C receives the downlink data fed back to the student card C by the IoT platform, it sends the downlink data to the downlink converter (downlink data conversion script), and the downlink converter converts the downlink data into a data format corresponding to the student card C;
[0410] S6: The integration instance C sends the converted target data to the student card C through the UDP protocol, so that the student card C completes the payment operation and the card swiping operation.
[0411] The terminal communication method proposed in this embodiment can be used to connect the terminal to communicate with the Internet of Things platform, and it can undertake the data conversion and data forwarding between the terminal and the Internet of Things platform through the integrated instance. Therefore, even if there are a large number of terminals, they can still communicate through their corresponding integrated instances, so that the Internet of Things platform can establish communication with terminals produced by different hardware manufacturers. Specifically, it has the following advantages:
[0412] Advantage 1: Whether it is a general communication protocol or a custom communication protocol, there are corresponding integrated instances for communication services, so that terminals produced by different hardware manufacturers can establish communication with the IoT platform.
[0413] Advantage 2: For general communication protocols, the converter can be called in a distributed manner and an embedded manner, thereby increasing the flexibility of the converter call and saving server resources.
[0414] Advantage 3: For each terminal, the performance-adapted candidate integration instance can be called to provide communication services according to the terminal's access frequency, which can not only make full use of server resources, but also quickly respond to terminal communications and improve service efficiency.
[0415] Advantage 4: When restoring a stopped integration instance, the target terminal's services before being stopped can be restored based on the target terminal's historical interaction data, thereby avoiding the user from restarting the services and optimizing the user's experience.
[0416] Based on the same inventive concept, the present disclosure also provides an Internet of Things system, including an Internet of Things platform and a service environment deployed on the Internet of Things platform, wherein the service environment is generated based on the above-mentioned service environment generation method embodiment, and is used to support communication between a terminal and the Internet of Things platform.
[0417] In some optional embodiments, the system may further include an instance management module, which communicates with multiple integration instances to provide a unified external interface for the service environment; wherein the instance management module is specifically used to receive control instructions for the integration instance and execute control corresponding to the control instructions on the integration instance;
[0418] The control includes at least one of the following: stopping the integration instance, restarting the integration instance, and monitoring the integration instance.
[0419] In this embodiment, the instance management module can provide a visual interface, which is used to provide developers with management of multiple integration instances. For example, the visual interface can display the instance names of multiple integration instances and at least one control corresponding to each integration instance. Developers can stop running the integration instance, restart the integration instance, and monitor the integration instance by operating the control. Exemplarily, when the developer touches the "stop running" control for the first integration instance of the TCP type, the instance management module will stop running the first integration instance of the TCP type according to the operation.
[0420] By adopting the Internet of Things system provided by the present disclosure, communication services adapted to the terminals and the Internet of Things platform can be provided to terminals produced by different hardware manufacturers, thereby enabling the Internet of Things platform to be deeply implemented in various application fields.
[0421] Based on the same inventive concept, the present disclosure also provides a terminal communication device, referring to Fig.10 As shown, a schematic diagram of the framework structure of the device is shown. Specifically, the device may include the following modules:
[0422] A calling module 1001, configured to call an integrated instance corresponding to a terminal in response to access by the terminal, wherein the integrated instance is configured to support communication between multiple terminals using the same communication protocol;
[0423] The conversion module 1002 is used to convert the interactive data related to the terminal through the integration instance, wherein the conversion process includes: converting the communication protocol of the interactive data and / or the data format of the interactive data according to the attribute of the destination end to which the interactive data is to be sent; wherein the destination end is the terminal or the Internet of Things platform;
[0424] The sending module 1003 is used to send the target data obtained after the conversion process to the destination end through the integration instance, so as to realize the communication between the terminal and the Internet of Things platform.
[0425] Optionally, the integration instance includes a first integration instance of a first type and a second integration instance of a second type, and the conversion module includes:
[0426] a first conversion unit, configured to send the interaction data to a target converter to instruct the target converter to perform the conversion process on the interaction data when the integration instance is the first integration instance; wherein the target converter is a converter corresponding to the destination end among at least two converters associated with the first integration instance;
[0427] The second conversion unit is used to send the interaction data to a plug-in corresponding to the terminal when the integration instance is the second integration instance, so as to instruct the plug-in to perform the conversion process on the interaction data.
[0428] Optionally, the device further comprises:
[0429] A verification module, used to verify the target data fed back by the target converter when the target converter is a converter corresponding to the Internet of Things platform, so as to verify whether the data structure of the target data conforms to a preset structure;
[0430] The sending module is specifically configured to send the target data to the Internet of Things platform through the first integration instance when the verification passes.
[0431] Optionally, the first conversion unit is specifically configured to:
[0432] Sending the interaction data to a first engine service to instruct the first engine service to send the interaction data to the target converter based on the identifier of the first integration instance; wherein the first engine service corresponds to converters associated with multiple different first set instances;
[0433] or,
[0434] The interaction data is sent to a second engine service corresponding to the first integration instance, so as to instruct the second engine service to send the interaction data to the target converter; wherein different second engine services correspond to different first integration instances.
[0435] Optionally, including a plurality of the integration instances, the apparatus further comprises:
[0436] A first monitoring module, used for monitoring the ports bound to the multiple integration instances;
[0437] A determination module, used to determine the integrated instance with a fault according to the monitoring result;
[0438] The restart module is used to restart the integration instance with the fault.
[0439] Optionally, the restart module includes:
[0440] An access module is used to reconnect multiple target terminals previously connected to the failed integration instance to the restarted integration instance;
[0441] A historical data acquisition module, used to acquire the historical interaction data closest to the current moment for each target terminal;
[0442] A recovery module is used to perform the conversion process on the historical interaction data through the restarted integration instance to restore the communication state of each target terminal before the failure occurs.
[0443] Optionally, the device further comprises:
[0444] A second monitoring module, used to monitor the connection status between the terminal and the integration instance;
[0445] The release module is used to release the call of the terminal to the integration instance when the connection state is a disconnected state.
[0446] Optionally, the calling module includes:
[0447] A screening unit, configured to determine, in response to access of the terminal, a plurality of candidate integration instances adapted to the terminal;
[0448] The scheduling unit is used to call the integration instance corresponding to the terminal based on the operating environment parameters of each of the plurality of candidate integration instances and / or the access frequency of the terminal.
[0449] Based on the same inventive concept, the present disclosure also provides a device for generating a service environment. Fig.11 As shown, a schematic diagram of the framework structure of the device is shown. Specifically, the device may include the following modules:
[0450] The instance generation module 1101 is used to generate a plurality of integration instances in response to the creation of the integration instance; wherein the plurality of integration instances include a first integration instance of a first type;
[0451] A script receiving module 1102, configured to receive a data conversion script uploaded for the first integration instance;
[0452] A script starting module 1103, configured to configure the data conversion script into at least two converters bound to the first integration instance, so as to obtain a service environment supporting the terminal;
[0453] The first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform the conversion processing on the interaction data related to the first type of terminal in the communication.
[0454] Optionally, the plurality of integration instances further include a second integration instance of a second type; and the apparatus further includes:
[0455] A custom program acquisition module, used to acquire at least one custom program corresponding to the second integration instance;
[0456] A running module, configured to use the at least one custom program as a plug-in associated with the second integration instance;
[0457] A plug-in startup module, used for starting the plug-in to form a service environment supporting the second type of terminal;
[0458] The plug-in is used to perform the conversion process on the interactive data of the second type of terminal in the communication.
[0459] Optionally, the device further comprises:
[0460] An agent program acquisition module, used for receiving an agent program for the second integration instance, and establishing a connection between the agent program and the second integration instance;
[0461] The plug-in startup module includes:
[0462] an instance starting unit, configured to start the second integration instance to instruct the agent program to download the at least one plug-in to a container;
[0463] The calling unit is used to call a preset command to start the at least one plug-in.
[0464] Optionally, the device further comprises:
[0465] A stop module, used for sending a stop instruction to the agent program through the second integration instance, and the agent program is used for stopping the corresponding target plug-in in response to the stop instruction to release the service environment of the terminal corresponding to the target plug-in;
[0466] A restart module is used to send a restart instruction to the agent program through the second integration instance, and the agent program is used to restart the corresponding target plug-in in response to the restart instruction to restore the service environment of the terminal corresponding to the target plug-in.
[0467] Optionally, the device further comprises:
[0468] A first configuration module, configured to allocate a first engine service to the plurality of first integration instances, and associate the data conversion scripts corresponding to the plurality of first integration instances with the first engine service;
[0469] or,
[0470] The second configuration module is used to allocate a second engine service to each of the first integration instances, associate a data conversion script corresponding to the first integration instance with the second engine service, and map the data conversion script to a golang method.
[0471] Optionally, the device further comprises at least one of the following:
[0472] A stop response module, configured to, in response to a stop instruction for an integration instance to be stopped among the plurality of integration instances, stop the operation of the integration instance to be stopped, so as to release the communication environment of the corresponding terminal;
[0473] The recovery response module is used to respond to the recovery instruction of the integration instance to be recovered among the multiple integration instances, restart the operation of the integration instance to be recovered, so as to recover the communication environment of the corresponding terminal.
[0474] Optionally, the device further comprises:
[0475] A mirroring module, used for mirroring multiple candidate integration instances corresponding to the integration instance, and mirroring the converters corresponding to the multiple candidate integration instances;
[0476] The deployment module is used to deploy the plurality of candidate integration instances and the corresponding converters to a plurality of different operating environments, respectively, so as to provide a distributed communication environment for a plurality of terminals using the same communication protocol.
[0477] Optionally, the device further comprises:
[0478] An allocation module, used for allocating a memory object for the integration instance from a memory;
[0479] A running module is used to run the integration instance in the memory object.
[0480] The embodiment of the present disclosure also provides an electronic device, the computer program stored in the electronic device enables a processor to execute the terminal communication method as described in the embodiment of the present disclosure.
[0481] The embodiment of the present disclosure further provides a computer-readable storage medium, which stores a computer program that enables a processor to execute the terminal communication method as described in the embodiment of the present disclosure.
[0482] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0483] Those skilled in the art will appreciate that the embodiments of the disclosed embodiments may be provided as methods, devices, or computer program products. Therefore, the disclosed embodiments may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the disclosed embodiments may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0484] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0485] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0486] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0487] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure.
[0488] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0489] The above is a detailed introduction to a terminal communication method, a service environment generation method, an apparatus, a system and equipment provided by the present disclosure. Specific examples are used in this article to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method of the present disclosure and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present disclosure, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A terminal communication method, characterized in that: The method comprises: In response to the access of the terminal, calling the integration instance corresponding to the terminal, the integration instance is used to support the communication of multiple terminals using the same communication protocol; The interactive data related to the terminal is converted and processed by the integration instance, and the conversion process includes: according to the attribute of the destination end to which the interactive data is to be sent, the communication protocol of the interactive data and / or the data format of the interactive data is converted; wherein the destination end is the terminal or the Internet of Things platform; The target data obtained after the conversion process is sent to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform.
2. The method according to claim 1, characterized in that The integration instance includes a first integration instance of a first type and a second integration instance of a second type, and the conversion processing of the interaction data related to the terminal by using the integration instance includes: In the case where the integration instance is the first integration instance, the interaction data is sent to a target converter to instruct the target converter to perform the conversion process on the interaction data; wherein the target converter is a converter corresponding to the destination end among at least two converters associated with the first integration instance; In a case where the integration instance is the second integration instance, the interaction data is sent to a plug-in corresponding to the terminal to instruct the plug-in to perform the conversion process on the interaction data.
3. The method according to claim 2, characterized in that After sending the interactive data to the target converter, the method further includes: In the case where the target converter is a converter corresponding to the Internet of Things platform, verifying the target data fed back by the target converter to verify whether the data structure of the target data conforms to a preset structure; Sending the target data obtained after the conversion process to the destination end through the integration instance includes: When the verification passes, the target data is sent to the Internet of Things platform through the first integration instance.
4. The method according to claim 2, characterized in that: The step of sending the interactive data to the target converter comprises: Sending the interaction data to a first engine service to instruct the first engine service to send the interaction data to the target converter based on the identifier of the first integration instance; wherein the first engine service corresponds to converters associated with multiple different first set instances; or, The interaction data is sent to a second engine service corresponding to the first integration instance, so as to instruct the second engine service to send the interaction data to the target converter; wherein different second engine services correspond to different first integration instances.
5. The method according to claim 1, characterized in that Including a plurality of the integration instances, the method further comprises: Monitoring the ports bound to the multiple integration instances; According to the monitoring result, determining the integrated instance having a fault; Restart the faulty integration instance.
6. The method according to claim 5, characterized in that The restarting of the faulty integration instance includes: Reconnect multiple target terminals that were previously connected to the failed integration instance to the restarted integration instance; For each of the target terminals, obtaining the most recent historical interaction data from the current moment; The historical interaction data is converted by the restarted integration instance to restore the communication state of each target terminal before the failure occurs.
7. The method according to claim 1, characterized in that After calling the integration instance corresponding to the terminal, the method further includes: Monitoring the connection status between the terminal and the integration instance; When the connection state is an offline state, the call of the terminal to the integration instance is released.
8. The method according to claim 1, characterized in that In response to the access of the terminal, calling the integration instance corresponding to the terminal includes: In response to access of the terminal, determining a plurality of candidate integration instances adapted to the terminal; Based on the operating environment parameters of each of the plurality of candidate integration instances and / or the access frequency of the terminal, the integration instance corresponding to the terminal is called.
9. A method for generating a service environment, characterized in that: The service environment is used to implement the terminal communication method according to any one of claims 1 to 8, the method comprising: In response to the creation of the integration instance, a plurality of integration instances are generated; wherein the plurality of integration instances include a first integration instance of a first type; Receiving a data conversion script uploaded for the first integration instance; configuring the data conversion script to be at least two converters bound to the first integration instance to obtain a service environment supporting the terminal; The first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform the conversion processing on the interaction data related to the first type of terminal in the communication.
10. The generation method according to claim 9, characterized in that: The plurality of integration instances also include a second integration instance of a second type; and the method further includes: Obtaining at least one custom program corresponding to the second integration instance; using the at least one custom program as a plug-in associated with the second integration instance; Starting the plug-in to form a service environment supporting the second type of terminal; The plug-in is used to perform the conversion process on the interactive data of the second type of terminal in the communication.
11. The generation method according to claim 10, characterized in that: Before starting the plug-in, the method further includes: receiving an agent program for the second integration instance, and establishing a connection between the agent program and the second integration instance; Starting the plug-in includes: Starting the second integration instance to instruct the agent program to download the at least one plug-in to the container; Calling a preset command to start the at least one plug-in.
12. The generation method according to claim 11, characterized in that: The method further comprises any of the following: Sending a stop instruction to the agent program through the second integration instance, wherein the agent program is used to stop running the corresponding target plug-in in response to the stop instruction to release the service environment of the terminal corresponding to the target plug-in; A restart instruction is sent to the agent program through the second integration instance, and the agent program is used to restart the corresponding target plug-in in response to the restart instruction to restore the service environment of the terminal corresponding to the target plug-in.
13. The generation method according to claim 9, characterized in that: The method comprises a plurality of different first integration instances, and before starting the data conversion script, the method further comprises: Allocating a first engine service to the plurality of first integration instances, and associating the data conversion scripts corresponding to the plurality of first integration instances with the first engine service; or, A second engine service is allocated to each of the first integration instances, a data conversion script corresponding to the first integration instance is associated with the second engine service, and the data conversion script is mapped to a preset calling method.
14. The generation method according to claim 9, characterized in that: The method includes a plurality of integration instances. After generating the integration instance, the method further includes at least one of the following: In response to a stop instruction for an integration instance to be stopped among the plurality of integration instances, stopping the operation of the integration instance to be stopped to release a communication environment of a corresponding terminal; In response to a recovery instruction for an integration instance to be recovered among the multiple integration instances, the operation of the integration instance to be recovered is restarted to recover the communication environment of the corresponding terminal.
15. The generation method according to claim 9, characterized in that: After generating the integration instance, the method further includes: Mirroring multiple candidate integration instances corresponding to the integration instance, and mirroring the converters corresponding to the multiple candidate integration instances; The plurality of candidate integration instances and the corresponding converters are respectively deployed in a plurality of different operating environments to provide a distributed communication environment for a plurality of terminals using the same communication protocol.
16. An Internet of Things system, characterized in that: including an Internet of Things platform and a service environment deployed on the Internet of Things platform; Wherein, the service environment is generated based on the service environment generation method described in any one of claims 9-15, and is used to implement the terminal communication method described in any one of claims 1-8 between the terminal and the Internet of Things platform.
17. The system according to claim 16, characterized in that The system further comprises: an instance management module, the instance management module communicating with a plurality of integrated instances to provide a unified external interface for the service environment; Among them, the instance management module is specifically used to receive control instructions for the integration instance, and execute control corresponding to the control instructions on the integration instance, and the control includes at least one of the following: stopping the integration instance, restarting the integration instance, and monitoring the integration instance.
18. A terminal communication device, characterized in that: The device comprises: A calling module, configured to call an integrated instance corresponding to the terminal in response to access of the terminal, wherein the integrated instance is configured to support communication between multiple terminals using the same communication protocol; A conversion module, configured to perform conversion processing on the interactive data related to the terminal through the integration instance, wherein the conversion processing includes: converting the communication protocol of the interactive data and / or the data format of the interactive data according to the attributes of the destination end to which the interactive data is to be delivered; wherein the destination end is the terminal or an Internet of Things platform; The sending module is used to send the target data obtained after the conversion process to the destination end through the integration instance to realize the communication between the terminal and the Internet of Things platform.
19. A device for generating a service environment, characterized in that: The service environment is used to implement the terminal communication method according to any one of claims 1 to 8, and the device includes: An instance generation module, configured to generate a plurality of integration instances in response to creation of the integration instance; wherein the plurality of integration instances include a first integration instance of a first type; A script receiving module, used for receiving a data conversion script uploaded for the first integration instance; A script starting module, used for starting the data conversion script to form at least two converters bound to the first integration instance to obtain a service environment supporting the terminal; The first integration instance is used to support communication between the first type of terminal and the Internet of Things platform, and the converter is used to perform the conversion processing on the interaction data related to the first type of terminal in the communication.
20. An electronic device, characterized in that: include: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor is executed, it implements the terminal communication method as described in any one of claims 1 to 8, or implements the method for generating a service environment as described in any one of claims 9 to 15.
