Protocol updating method and device, electronic equipment and storage medium

By encapsulating the data interaction protocol within components in the Internet of Things (IoT) and implementing component loading and unloading through dynamic loading, the connection interruption problem when the edge gateway updates the data interaction protocol is solved, enabling hot updates of the protocol and improving device availability and user experience.

CN115550461BActive Publication Date: 2026-06-19XIAOAN KEJI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAOAN KEJI
Filing Date
2022-09-15
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In the Internet of Things (IoT) field, when an edge gateway updates its data interaction protocol, it needs to be redeployed, which can cause the network connection between the device and the edge gateway to be interrupted, resulting in data loss and functional unavailability of the device.

Method used

By encapsulating the data interaction protocol in components and implementing component loading and unloading through dynamic loading, hot updates of the data interaction protocol components are achieved, avoiding redeployment.

🎯Benefits of technology

It enables data exchange protocols to be changed without requiring redeployment, avoiding data loss and functionality unavailability caused by device connection interruptions, and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550461B_ABST
    Figure CN115550461B_ABST
Patent Text Reader

Abstract

This invention provides a protocol update method, apparatus, electronic device, and storage medium. The method includes: responding to a protocol update event and downloading a modified data interaction protocol component to a specified path; determining the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component and applying the mapping relationship between the component name and component ID; stopping and uninstalling the currently running data interaction protocol component corresponding to the protocol component ID; and loading and starting the modified data interaction protocol component so that the communication service can use the protocol format in the modified data interaction protocol component to interact with the device. This achieves hot updating of the data interaction protocol component, thus eliminating the need for redeployment when the data interaction protocol changes. This avoids problems such as data loss due to device connection interruption and device malfunction due to device connection interruption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Internet of Things (IoT) technology, and in particular to a protocol update method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the Internet of Things (IoT) field, communication between devices and edge gateways involves devices reporting data to the edge gateway according to a certain data interaction protocol, and the edge gateway also issuing commands to the devices according to the same data interaction protocol.

[0003] However, on the device side, sometimes, based on actual business needs, it's necessary to add or modify individual data items to the original data interaction protocol, requiring the edge gateway's data interaction protocol components to be modified accordingly. Alternatively, on the edge gateway side, problems undetected during testing may surface when encoding and decoding messages according to the data interaction protocol. In both cases, the edge gateway needs to repackage and redeploy the application after fixing the data interaction protocol components, resulting in a temporary disconnection of the network connection between the device and the edge gateway, causing the edge gateway to lose device data. This is particularly problematic in the shared electric bicycle or shared bicycle industry, where a network disconnection renders all vehicles unusable, impacting user experience and causing economic losses for the companies operating the vehicles. Summary of the Invention

[0004] This invention provides a protocol update method, apparatus, electronic device, and storage medium to address the shortcomings of existing technologies where edge gateways need to be redeployed when updating data interaction protocols, leading to interruptions in device connections and data loss.

[0005] This invention provides a protocol update method, comprising:

[0006] Respond to the protocol update event and download the modified data interaction protocol component to the specified path;

[0007] Based on the component name of the modified data interaction protocol component, the mapping relationship between the application component name and the component ID is used to determine the protocol component ID of the modified data interaction protocol component, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device.

[0008] This invention provides a protocol update method, wherein responding to a protocol update event and downloading the modified data interaction protocol component to a specified path includes:

[0009] Respond to the protocol update event by subscription;

[0010] Based on the path of the modified data interaction protocol component in the storage service carried in the protocol update event, and the network address of the storage service obtained from the configuration center, the download address of the modified data interaction protocol component is determined.

[0011] Based on the download address, the modified data interaction protocol component is downloaded from the storage service and stored in the specified path; the specified path is obtained from the configuration center; the configuration center is used to store configuration information, which includes: the network address of the storage service and the specified path.

[0012] This invention provides a protocol update method, wherein the steps for determining the mapping relationship between component name and component ID are as follows:

[0013] Read the component list from the specified path, determine the component name of each component in the component list, load each component using the component manager, and obtain the component ID of each component;

[0014] Based on the component name and component ID of each component, the mapping relationship is determined and cached in local memory.

[0015] This invention provides a protocol update method, wherein stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID, and loading and starting the modified data interaction protocol component, includes:

[0016] Unbind the currently running data interaction protocol component from the communication service, and based on the component manager, use the protocol component ID to stop and uninstall the currently running data interaction protocol component;

[0017] Based on the specified path and the component name of the modified data interaction protocol component, determine the local path of the modified data interaction protocol component;

[0018] Based on the component manager, the modified data interaction protocol component is loaded and started using the local path, and the modified data interaction protocol component is bound to the communication service.

[0019] This invention provides a protocol update method. The data interaction protocol component includes a decoding interface and an encoding interface. After the data interaction protocol component is bound to the communication service, the decoding interface is used to decode the message data sent by the device after the communication service receives the message data to obtain structured data. The encoding interface is used to encode the structured data to be sent so that the communication service can send the encoded message data to the device.

[0020] This invention provides a protocol update method, which further includes:

[0021] During the period after the currently running data interaction protocol component and the communication service are unbound and before the modified data interaction protocol component and the communication service are bound together, the communication service caches the received message data in the local receive buffer queue and caches the structured data to be sent in the local send buffer queue.

[0022] After the modified data interaction protocol component and the communication service are bound together, the communication service calls the decoding interface in the modified data interaction protocol component to decode each message data in the local receive buffer queue; the communication service calls the encoding interface in the modified data interaction protocol component to encode each structured data in the local send buffer queue, and sends the encoded message data to the device.

[0023] This invention provides a protocol update method, wherein the data interaction protocol component is developed based on the PF4J framework.

[0024] The present invention also provides a protocol update apparatus, comprising:

[0025] The response module is used to respond to protocol update events and download the modified data interaction protocol components to the specified path;

[0026] The hot update module is used to determine the protocol component ID of the modified data interaction protocol component based on the mapping relationship between the component name, application component name and component ID of the modified data interaction protocol component, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, and load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device.

[0027] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the protocol update method as described above.

[0028] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the protocol update method as described above.

[0029] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the protocol update method as described above.

[0030] The protocol update method, apparatus, electronic device, and storage medium provided by this invention encapsulate the data interaction protocol in a component and implement the loading and unloading of the component through dynamic loading, thereby achieving hot updating of the data interaction protocol component. This eliminates the need for redeployment when the data interaction protocol changes, avoiding problems such as data loss due to device connection interruption and device malfunction due to device connection interruption, thus improving the user experience. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0032] Figure 1 This is a flowchart illustrating the protocol update method provided by the present invention;

[0033] Figure 2 This is a schematic diagram illustrating the development process of the data interaction protocol component provided by this invention;

[0034] Figure 3 This is a timing diagram of the protocol update system provided by the present invention;

[0035] Figure 4 This is a schematic diagram of the protocol update device provided by the present invention;

[0036] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0038] Currently, when an edge gateway needs to update its data exchange protocol, it is necessary to stop the edge gateway service, deploy a new edge gateway service, and then start the new edge gateway service. During this process, the network connection with the device will be interrupted, which may result in the loss of data reported by the device or even cause the device to malfunction.

[0039] Therefore, how to update the data exchange protocol without stopping the service of the edge gateway is a technical problem that urgently needs to be solved by those skilled in the art.

[0040] To address the aforementioned technical problems, embodiments of the present invention provide a protocol update method. Figure 1 This is a flowchart illustrating the protocol update method provided by the present invention. Figure 1 As shown, this method is applied in a JAVA environment, primarily for edge gateways, or for other network forwarding devices. The method includes:

[0041] Step 110: Respond to the protocol update event and download the modified data interaction protocol component to the specified path;

[0042] Step 120: Based on the mapping relationship between the component name, application component name and component ID of the modified data interaction protocol component, determine the protocol component ID of the modified data interaction protocol component, stop and uninstall the currently running data interaction protocol component corresponding to the protocol component ID, load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to interact with the device.

[0043] Considering that components can be dynamically loaded in a JAVA environment, meaning that the dynamically loaded components do not need to be redeployed or modified, this embodiment of the invention can achieve hot updates of the data interaction protocol components by partially componentizing the data interaction protocol and using the data interaction protocol components in a dynamic loading manner, thus enabling hot updates of the data interaction protocol.

[0044] Specifically, upon receiving a protocol update event, the modified data interaction protocol component is downloaded and stored in a specified local path. After downloading the modified data interaction protocol component, its component name is used to look up the component name and component ID mapping in memory to obtain the protocol component ID. The currently running data interaction protocol component corresponding to this protocol component ID is then stopped and unloaded. After the currently running data interaction protocol component is unloaded, the modified data interaction protocol component is loaded and started. Once started, the communication service uses the modified data interaction protocol component to interact with the device.

[0045] It should be noted that the response protocol update event can be sent by the server or platform through a communication connection with the server or platform, such as a TCP connection or a UDP connection. Alternatively, it can be sent by the server or platform through a distributed notification service such as Redis, subscribing to channel messages, and the server or platform publishing the update event in that channel. This embodiment of the invention does not impose any limitations on this. The mapping relationship between component names and component IDs can be obtained through configuration information in the configuration file, or it can be obtained by reading components from a specified path and generating component IDs based on the component names, or by reading component IDs from components and then forming a mapping between component names and component IDs. This embodiment of the invention does not impose any limitations on this. The specified path can be obtained from a local configuration file, or it can be configured on a remote server or platform and then obtained by requesting from the remote server or platform. This embodiment of the invention does not impose any limitations on this. The edge gateway communicates with the device via a TCP connection. The edge gateway binds a communication port, and the device connects to the edge gateway through this communication port and the edge gateway's IP address. The communication port can be agreed upon with the device or configured on a remote server or platform. In this case, the edge gateway requests and obtains the port from the server or platform when starting the communication service and binds it. The device requests and obtains the port from the server or platform before connecting to the edge gateway and then initiates a connection request. This embodiment of the invention does not impose any restrictions on this.

[0046] Furthermore, the data interaction protocol component can encapsulate the format of the data interaction protocol. In this case, the communication service can encode and decode the message data by reading the data interaction protocol format in the data interaction component. It can also encapsulate the encoding and decoding interface of the protocol message data. In this case, the communication service can call the encoding and decoding interface to encode and decode the message data. This embodiment of the invention does not limit this.

[0047] On the other hand, during the hot update process—that is, after stopping and unloading the currently running data interaction protocol component and before loading and starting the modified data interaction protocol component—message data received from the device can be cached locally. When the modified data interaction protocol component starts, it can be decoded, and a retransmission command can be sent back to the device, instructing the device to retransmit the message data after a specified time. This embodiment of the invention does not impose any limitations on this. During this time period, if data needs to be sent to the device, it can be cached first, and then encoded and sent after the modified data interaction protocol component starts.

[0048] The protocol update method provided in this invention encapsulates the data interaction protocol in a component and loads and unloads the component through dynamic loading, thereby achieving hot updates of the data interaction protocol component. This eliminates the need for redeployment when the data interaction protocol changes, avoiding problems such as data loss due to device connection interruption and device malfunction due to device connection interruption.

[0049] Based on the above embodiments, step 110 includes:

[0050] Step 111: Respond to protocol update events by subscription;

[0051] Step 112: Based on the path of the modified data interaction protocol component in the storage service carried in the protocol update event, and the network address of the storage service obtained from the configuration center, determine the download address of the modified data interaction protocol component.

[0052] Step 113: Based on the download address, download the modified data interaction protocol component from the storage service and store it in the specified path; the specified path is obtained from the configuration center; the configuration center is used to store configuration information, which includes: the network address of the storage service and the specified path.

[0053] Specifically, a distributed notification service is applied, and protocol update events are responded to through a subscription method. That is, by subscribing to a designated channel of the distributed notification service, the server or platform can respond to the protocol update event by publishing the protocol update event to the designated channel. The modified data interaction protocol component's path in the storage service is read from the protocol update event, and the storage service's network address is obtained from the configuration center. The storage service's network address and the modified data interaction protocol component's path in the storage service are concatenated to form the download address of the modified data interaction protocol component. The modified data interaction protocol component is then downloaded to the designated path in byte stream form from this download address. The designated path is obtained from the configuration center, which stores configuration information, including the storage service's network address and the designated path.

[0054] It should be noted that after a user uploads the modified data interaction protocol component to the server or platform, the server or platform will publish an update event to the designated channel of the distributed notification service, carrying the path information of the modified data interaction protocol component in the storage service. The designated channel can be agreed upon with the edge gateway, or it can be obtained from the configuration information stored in the configuration center. That is, the server or platform obtains the designated channel information from the configuration center, and the edge gateway also first obtains the designated channel information from the configuration center and then subscribes to the channel information from the distributed notification service. This embodiment of the invention does not impose any restrictions on this. The storage server is OSS (Object Storage Service).

[0055] Based on the above embodiments, the steps for determining the mapping relationship between component name and component ID in step 120 are as follows:

[0056] Step S1: Read the component list from the specified path, determine the component name of each component in the component list, and load each component using the component manager to obtain the component ID of each component;

[0057] Step S2: Determine the mapping relationship based on the component name and component ID of each component, and cache it in local memory.

[0058] Specifically, the system iterates through the specified path to obtain a list of components stored in that path, determines the component name of each component in the list, loads each component through the component manager, obtains the component ID after each component is loaded, and then obtains the mapping relationship between the component name and component ID based on the component name and component ID of each component, and caches the mapping relationship in local memory for use in subsequent component updates.

[0059] It's important to note that all components are located in this specified path and can share the same file extension, such as .jar or .zip. Traversing the specified path means sequentially reading the file types of the components by their respective extensions within that path to obtain detailed information about all components in that path. This information can include the complete local storage path, filename, and component size. The retrieved components are then stored in a component list. Component IDs can be obtained by reading information from the component through the component manager.

[0060] Based on the above embodiments, step 120, which involves stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID, and loading and starting the modified data interaction protocol component, includes:

[0061] Step S10: Unbind the currently running data interaction protocol component and communication service, and stop and uninstall the currently running data interaction protocol component based on the component manager and the application protocol component ID;

[0062] Step S20: Determine the local path of the modified data interaction protocol component based on the specified path and the component name of the modified data interaction protocol component;

[0063] Step S30: Based on the component manager, apply the local path, load and start the modified data interaction protocol component, and bind the modified data interaction protocol component and the communication service.

[0064] Specifically, after the modified data interaction protocol component is downloaded, the currently running data interaction protocol component corresponding to the communication service and protocol component ID is unbound first. Then, the component manager stops and uninstalls the currently running data interaction protocol component according to the protocol component ID. After uninstallation, the modified data interaction protocol component is loaded and started according to the local path of the modified data interaction protocol component determined by the specified path and the component name of the modified data interaction protocol component. Finally, the modified data interaction protocol component is bound to the data service, thus completing the hot update of the data interaction protocol component.

[0065] It should be noted that the binding between the data interaction protocol component and the data service can be achieved by constructing a member variable of the data interaction protocol component in the class of the data service, and binding the member variable to the data interaction protocol component. That is, when bound, the member variable is the data interaction protocol component, and when not bound, the member variable is empty. By checking whether the member variable is empty, it is determined whether the encoding and decoding interfaces in the data interaction protocol component can be called. Alternatively, binding can be achieved through a binding identifier. That is, after the data interaction protocol component and the data service are bound, the identifier is specified as the bound state. At this time, the encoding and decoding interfaces in the data interaction protocol component can be called. This embodiment of the invention does not impose any restrictions on this.

[0066] Based on the above embodiments, the present invention provides a preferred embodiment, in which the data interaction protocol component includes: a decoding interface and an encoding interface; after the data interaction protocol component and the communication service are bound, the decoding interface is used to decode the message data sent by the device after the communication service receives the message data sent by the device to obtain structured data; the encoding interface is used to encode the structured data to be sent so that the communication service can send the encoded message data to the device.

[0067] Considering that if the data interaction protocol component provides a data interaction protocol format, then when developing communication services for edge gateways, a general encoding / decoding interface capable of parsing the protocol format needs to be written. Since the protocol format content changes according to requirements, the general encoding / decoding interface may not fully cover future changes in requirements. Consequently, when the general encoding / decoding interface cannot support the protocol format content, adjustments to the general encoding / decoding interface are required, i.e., redeployment of the edge gateway. This still carries the risk of data loss due to disconnection from devices and potential device malfunctions. Furthermore, considering the universality of the encoding / decoding interface in the communication service increases development difficulty, leading to increased development costs and a higher probability of problems. Therefore, this embodiment of the invention reduces development difficulty and the probability of problems by constructing encoding and decoding interfaces within the data interaction protocol component. Moreover, since the encoding / decoding interface is encapsulated within the component, hot updates of the data interaction protocol's message data encoding and decoding can be achieved.

[0068] Specifically, after the data interaction protocol component and the communication service are bound, the communication service will call the decoding interface in the data interaction protocol component to decode the message data after receiving the message data sent by the device, and obtain structured data. When it needs to send structured data to the device, it will call the encoding interface in the data interaction protocol component to encode the structured data to be sent, obtain the message data corresponding to the structured data, and send the message data to the device.

[0069] Based on the above embodiments, the protocol update method provided in this embodiment of the invention further includes:

[0070] During the period between the unbinding of the currently running data interaction protocol component and the communication service and the binding of the modified data interaction protocol component and the communication service, the communication service will cache the received message data in the local receive buffer queue and cache the structured data to be sent in the local send buffer queue.

[0071] After the modified data interaction protocol component and communication service are bound together, the communication service calls the decoding interface in the modified data interaction protocol component to decode each message data in the local receive buffer queue; the communication service calls the encoding interface in the modified data interaction protocol component to encode each structured data in the local send buffer queue, and sends the encoded message data to the device.

[0072] Considering that during the period between the unbinding of the currently running data interaction protocol component and the communication service and the binding of the modified data interaction protocol component and the communication service, although there is no communication connection between the terminal and the device, the communication service cannot call the encoding and decoding interfaces in the modified data interaction protocol component because it is not bound to the modified data interaction protocol component at this time. Therefore, it is impossible to process the received message data or encode the structured data to be sent, which may result in data loss. Therefore, this embodiment of the invention constructs a local receive buffer queue and a local send buffer queue to solve the problem of data loss.

[0073] Specifically, during the period between the unbinding of the currently running data interaction protocol component and the communication service and the binding of the modified data interaction protocol component and the communication service, the received message data sent by the device is stored in the local receive buffer queue, and the structured data to be sent is stored in the local send buffer queue. After the modified data interaction protocol component and the communication service are bound, the message data stored in the local receive buffer queue is decoded through the decoding interface in the modified data interaction protocol component, and the structured data in the local send buffer queue is encoded through the encoding interface in the modified data interaction protocol component. Then, the encoded message data is sent to the device through the communication service.

[0074] Based on the above embodiments, the present invention provides a preferred embodiment in which the data interaction protocol component is developed based on the PF4J framework.

[0075] It should be noted that, Figure 2 This is a schematic diagram illustrating the development process of the data interaction protocol component provided by this invention. For example... Figure 2 As shown, the development process of the data interaction protocol component based on the PF4J framework is as follows:

[0076] Step 210: Inherit the abstract component class (Plugin) based on the PF4J framework specification so that the data interaction protocol component has a lifecycle and can be dynamically started and stopped.

[0077] Step 220: Write a business interface, inherit the component extension point interface according to the PF4J framework specification, and declare the encoding interface and decoding interface.

[0078] Step 230: Write an implementation class that implements the business interface in step 220, and implements the encoding and decoding interface functions. Mark the implementation class with the specific annotation (@Extension) provided by the PF4J framework specification.

[0079] Step 240: Based on the PF4J framework specification, assign a protocol component ID to the data interaction protocol component and package it into a JAR file. At this point, the development of the data interaction protocol component is complete. Now, by placing the data interaction protocol component in the specified path, the edge gateway can load, start, stop, and unload the data interaction protocol component.

[0080] Figure 3 This is a timing diagram of the protocol update system provided by the present invention. For example... Figure 3 As shown, the system includes devices, edge gateways, configuration centers, REDIS services, OSS services, and an IoT (Internet of Things) platform.

[0081] Step 310: The edge gateway service starts, and the edge gateway obtains the specified path where the data interaction protocol component is located from the configuration center.

[0082] Step 320: After the edge gateway reads the data interaction protocol component from the disk according to the specified path, it loads it using the component manager to obtain the protocol component ID. Then, the component manager starts the data interaction protocol component using the protocol component ID and stores it in memory with the component name as the KEY and the protocol component ID as the VALUE. Preferably, it is stored in memory using a HASH method.

[0083] Step 330: The edge gateway starts the communication service and binds to the data interaction protocol component. It uses the decoding module in the data interaction protocol component to decode the message data reported by the device to obtain structured data and pushes it to the IoT platform. It also uses the encoding module in the data interaction protocol component to encode the structured data sent by the edge gateway and sends the encoded message data to the device.

[0084] Step 340: After modifying the data interaction protocol component, upload the modified data interaction protocol component to the IoT platform.

[0085] Step 350: The IoT platform saves the modified data interaction protocol component to the OSS service and obtains the path where it is stored on OSS.

[0086] Step 360: The IoT platform publishes the data interaction protocol component change event to Redis.

[0087] Step 370: The edge gateway subscribes to the data interaction protocol change event. The edge gateway obtains the OSS network address from the configuration center and obtains the path where the modified data interaction protocol component is saved on OSS from the change event parameters. The two together form the download address of the modified data interaction protocol component on OSS.

[0088] Step 380: The edge gateway obtains the specified path where the modified data interaction protocol component is saved from the configuration center, and downloads the modified data interaction protocol component to the specified path according to the download address.

[0089] Step 390: The edge gateway retrieves the protocol component ID corresponding to the modified data interaction protocol component name from memory, uses the component manager to stop and unload the currently running data interaction protocol component based on the protocol component ID, and then uses the component manager to read the modified data interaction protocol component from the specified path, loads and starts the modified data interaction protocol component, thus completing the hot update.

[0090] The protocol update apparatus provided by the present invention is described below. The protocol update apparatus described below and the protocol update method described above can be referred to in correspondence.

[0091] Figure 4 This is a schematic diagram of the protocol update device provided by the present invention. Figure 4 As shown, the device includes a response module 410 and a hot update module 420.

[0092] in,

[0093] The response module 410 is used to respond to protocol update events and download the modified data interaction protocol components to the specified path;

[0094] The hot update module 420 is used to determine the protocol component ID of the modified data interaction protocol component based on the mapping relationship between the component name, application component name and component ID of the modified data interaction protocol component, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, and load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to interact with the device.

[0095] The protocol update device provided in this embodiment of the invention can respond to protocol update events through a response module and download the modified data interaction protocol component to a specified path; the hot update module is used to determine the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component, the mapping relationship between the application component name and the component ID, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, and load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to interact with the device. This realizes the hot update of the data interaction protocol component, so that redeployment is not required when the data interaction protocol changes, avoiding the problem of device data loss due to device connection interruption and the problem of device function failure due to device connection interruption, thereby improving the user experience of the device.

[0096] Based on any of the above embodiments, the response module 410 includes:

[0097] The subscription response submodule is used to respond to protocol update events in a subscription manner;

[0098] The download address determination submodule is used to determine the download address of the modified data interaction protocol component based on the path of the modified data interaction protocol component in the storage service carried in the protocol update event, and the network address of the storage service obtained from the configuration center.

[0099] The download submodule is used to download the modified data interaction protocol component from the storage service based on the download address and store it in the specified path; the specified path is obtained from the configuration center; the configuration center is used to store configuration information, including the network address of the storage service and the specified path.

[0100] Based on any of the above embodiments, the hot update module 420 includes:

[0101] The Component ID Determination Submodule is used to read the component list from the specified path, determine the component name of each component in the component list, load each component using the Component Manager, and obtain the component ID of each component.

[0102] The mapping relationship determination submodule is used to determine the mapping relationship based on the component name and component ID of each component, and cache it in local memory.

[0103] Based on any of the above embodiments, the hot update module 420 further includes:

[0104] The current component stop submodule is used to unbind the currently running data interaction protocol component and communication service, and based on the component manager and the application protocol component ID, stop and uninstall the currently running data interaction protocol component;

[0105] The Update Component Path submodule is used to determine the local path of the modified data interaction protocol component based on the specified path and the component name of the modified data interaction protocol component.

[0106] Update the startup submodule to load and start the modified data interaction protocol component based on the component manager and the application's local path, and bind the modified data interaction protocol component and the communication service.

[0107] Based on any of the above embodiments, the protocol update apparatus further includes:

[0108] The caching submodule is used to cache received message data in the local receive cache queue and structured data to be sent in the local send cache queue during the time period after the currently running data interaction protocol component and communication service are unbound and before the modified data interaction protocol component and communication service are bound.

[0109] The supplementary processing submodule is used after the modified data interaction protocol component and the communication service are bound together. The communication service calls the decoding interface in the modified data interaction protocol component to decode each message data in the local receive buffer queue; the communication service calls the encoding interface in the modified data interaction protocol component to encode each structured data in the local send buffer queue, and sends the encoded message data to the device.

[0110] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540. The processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a protocol update method. This method includes: responding to a protocol update event and downloading the modified data interaction protocol component to a specified path; determining the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component, applying the mapping relationship between the component name and component ID; stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID; and loading and starting the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to interact with the device.

[0111] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0112] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the protocol update method provided by the above methods. The method includes: responding to a protocol update event and downloading the modified data interaction protocol component to a specified path; determining the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component and the mapping relationship between the component name and the component ID; stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID; and loading and starting the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device.

[0113] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the protocol update method provided by the above methods. The method includes: responding to a protocol update event and downloading a modified data interaction protocol component to a specified path; determining the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component, applying the mapping relationship between the component name and the component ID; stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID; and loading and starting the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device.

[0114] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0115] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A protocol updating method, characterized by, include: Respond to the protocol update event and download the modified data interaction protocol component to the specified path; Based on the component name of the modified data interaction protocol component, the mapping relationship between the application component name and the component ID is used to determine the protocol component ID of the modified data interaction protocol component, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device; The response protocol update event, and downloading the modified data interaction protocol component to the specified path, includes: Respond to the protocol update event by subscription; Based on the path of the modified data interaction protocol component in the storage service carried in the protocol update event, and the network address of the storage service obtained from the configuration center, the download address of the modified data interaction protocol component is determined. Based on the download address, the modified data interaction protocol component is downloaded from the storage service and stored in the specified path; the specified path is obtained from the configuration center; the configuration center is used to store configuration information, which includes: the network address of the storage service and the specified path; The steps for determining the mapping relationship between component names and component IDs are as follows: Read the component list from the specified path, determine the component name of each component in the component list, load each component using the component manager, and obtain the component ID of each component; Based on the component name and component ID of each component, the mapping relationship is determined and cached in local memory; The step of stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID, and loading and starting the modified data interaction protocol component includes: Unbind the currently running data interaction protocol component from the communication service, and based on the component manager, use the protocol component ID to stop and uninstall the currently running data interaction protocol component; Based on the specified path and the component name of the modified data interaction protocol component, determine the local path of the modified data interaction protocol component; Based on the component manager, using the local path, the modified data interaction protocol component is loaded and started, and the modified data interaction protocol component is bound to the communication service; The data interaction protocol component includes a decoding interface and an encoding interface. After the data interaction protocol component is bound to the communication service, the decoding interface is used to decode the message data sent by the device after the communication service receives the message data to obtain structured data. The encoding interface is used to encode the structured data to be sent so that the communication service can send the encoded message data to the device.

2. The protocol update method according to claim 1, characterized in that, Also includes: During the period after the currently running data interaction protocol component and the communication service are unbound and before the modified data interaction protocol component and the communication service are bound together, the communication service caches the received message data in the local receive buffer queue and caches the structured data to be sent in the local send buffer queue. After the modified data interaction protocol component and the communication service are bound together, the communication service calls the decoding interface in the modified data interaction protocol component to decode each message data in the local receive buffer queue; the communication service calls the encoding interface in the modified data interaction protocol component to encode each structured data in the local send buffer queue, and sends the encoded message data to the device.

3. The protocol update method according to claim 1 or 2, characterized in that, The data interaction protocol component is developed based on the PF4J framework.

4. A protocol updating apparatus characterized by comprising: include: The response module is used to respond to protocol update events and download the modified data interaction protocol components to the specified path; The hot update module is used to determine the protocol component ID of the modified data interaction protocol component based on the component name of the modified data interaction protocol component, the mapping relationship between the application component name and the component ID, stop and unload the currently running data interaction protocol component corresponding to the protocol component ID, and load and start the modified data interaction protocol component so that the communication service can use the modified data interaction protocol component to perform data interaction with the device. The response protocol update event, and downloading the modified data interaction protocol component to the specified path, includes: Respond to the protocol update event by subscription; Based on the path of the modified data interaction protocol component in the storage service carried in the protocol update event, and the network address of the storage service obtained from the configuration center, the download address of the modified data interaction protocol component is determined. Based on the download address, the modified data interaction protocol component is downloaded from the storage service and stored in the specified path; the specified path is obtained from the configuration center; the configuration center is used to store configuration information, which includes: the network address of the storage service and the specified path; The steps for determining the mapping relationship between component names and component IDs are as follows: Read the component list from the specified path, determine the component name of each component in the component list, load each component using the component manager, and obtain the component ID of each component; Based on the component name and component ID of each component, the mapping relationship is determined and cached in local memory; The step of stopping and unloading the currently running data interaction protocol component corresponding to the protocol component ID, and loading and starting the modified data interaction protocol component includes: Unbind the currently running data interaction protocol component from the communication service, and based on the component manager, use the protocol component ID to stop and uninstall the currently running data interaction protocol component; Based on the specified path and the component name of the modified data interaction protocol component, determine the local path of the modified data interaction protocol component; Based on the component manager, using the local path, the modified data interaction protocol component is loaded and started, and the modified data interaction protocol component is bound to the communication service; The data interaction protocol component includes a decoding interface and an encoding interface. After the data interaction protocol component is bound to the communication service, the decoding interface is used to decode the message data sent by the device after the communication service receives the message data to obtain structured data. The encoding interface is used to encode the structured data to be sent so that the communication service can send the encoded message data to the device.

5. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the protocol update method as described in any one of claims 1 to 3.

6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the protocol update method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method and device for accessing to native functions of terminal by Web application

    CN106201610A

  • Protocol driver replacement method and device based on class loader and storage medium

    CN114489828A