An intelligent gateway, a dynamic debugging method and an Internet of Things system
By introducing Lua dynamic debugging scripts and interface modules into the smart gateway, the problem of insufficient debugging tools for IoT systems is solved, enabling rapid fault location and flexible debugging, and improving troubleshooting efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU ROBUSTEL CO LTD
- Filing Date
- 2023-10-25
- Publication Date
- 2026-06-23
AI Technical Summary
Existing smart gateways cannot be directly debugged when IoT device data collection fails or the reported data is inconsistent with the platform. Debugging tools are limited, and IoT system problems often emerge during operation, resulting in time-consuming troubleshooting.
The smart gateway introduces Lua dynamic debugging scripts and dynamic debugging interface modules, supporting POSIX signals, sockets, pipes, and message queue interfaces. It calls Lua dynamic debugging scripts through external triggers, including a first debugging script, a second debugging script, and a third debugging script, which are used to dynamically modify the log level, output real-time status, and load new Lua scripts for debugging, respectively.
It improves troubleshooting efficiency, can output debugging information in real time, quickly locate difficulties, flexibly deal with unknown problems, avoid recompiling and deployment, and improve debugging efficiency.
Smart Images

Figure CN117395137B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of communication technology, and more specifically, relates to an intelligent gateway, a dynamic debugging method, and an Internet of Things system. Background Technology
[0002] The applicant's prior application 202210768758.4 discloses a smart gateway, comprising the following modules: a data acquisition module for acquiring business data from IoT devices, converting the business data into first intermediate data recognizable by a data abstraction module, and sending it to the data abstraction module; a data abstraction module for converting the first intermediate data into second intermediate data in key-value pair format; a data processing module for encapsulating one or more key-value pairs from the second intermediate data into upload data recognizable by the platform and sending it to a platform interface module; and a platform interface module for sending the upload data to the platform.
[0003] The smart gateway uses a dynamic language to develop the data processing sub-module program, which greatly improves the development efficiency of IoT data acquisition system software.
[0004] However, the software in smart gateways is embedded software, which usually lacks a user-friendly human-machine interface. When IoT devices fail to collect data or the data reported to the platform does not match expectations, the smart gateways cannot be directly debugged, and the methods and tools available for troubleshooting are very limited. Moreover, the special nature of IoT systems means that many problems will only be exposed during actual system operation and interaction with various IoT devices. At this time, the debugging methods that can be used during development become ineffective, and only the limited logs recorded can be relied upon to troubleshoot problems, which is often very time-consuming. Summary of the Invention
[0005] The main objective of this invention is to provide an intelligent gateway that can trigger dynamic debugging through an interface and call a preset Lua dynamic debugging script for easy debugging; at the same time, it also provides a dynamic debugging method and an Internet of Things system.
[0006] According to a first aspect of the present invention, a smart gateway is provided, including a data acquisition module, a data processing framework, and a platform interface module. The data acquisition module acquires data from Internet of Things (IoT) devices to form first data. The data processing framework includes a device data transceiver module, a Lua scheduling module, a Lua data processing script, a Lua dynamic debugging script, and a dynamic debugging interface module.
[0007] The device data transceiver module receives the first data and forwards it to the Lua data processing script through the Lua scheduling module. The Lua data processing script then converts the first data into second data for storage.
[0008] The Lua data processing script processes the second data according to business needs, encapsulates the second data into third data that the platform can recognize, and then returns the third data to the Lua scheduling module.
[0009] The Lua scheduling module sends the third data to the platform interface module;
[0010] When the dynamic debugging interface module receives an external trigger signal, it calls the Lua dynamic debugging script through the Lua scheduling module.
[0011] In the aforementioned smart gateway, the dynamic debugging interface module supports interfaces including POSIX signals, Socket, Pipe, and message queue.
[0012] In the aforementioned smart gateway, the Lua dynamic debugging script includes a first debugging script, a second debugging script, and a third debugging script. The Lua scheduling module schedules different debugging scripts according to different trigger signal parameters.
[0013] In the aforementioned smart gateway, the data processing framework further includes a log printing module. The first debugging script is used to configure the log printing module and can dynamically modify the log level.
[0014] The second debugging script is associated with the Lua data processing script so that the second debugging script can obtain the real-time running data of the Lua data processing script;
[0015] The third debugging script can load new Lua scripts, which serve as submodules of the Lua data processing script. The Lua data processing script runs and loads the submodules for debugging output.
[0016] According to a second aspect of the present invention, a dynamic debugging method is provided, relating to a smart gateway as described in the first aspect, comprising the following steps:
[0017] Step 1: The dynamic debugging interface module acquires the trigger signal and sends the trigger signal to the Lua scheduling module;
[0018] Step 2: The Lua scheduling module calls the corresponding Lua dynamic debugging script according to the trigger signal. The Lua dynamic debugging script includes a first debugging script, a second debugging script, and a third debugging script.
[0019] In the above dynamic debugging method, the first debugging script executes the first debugging method, which involves a log printing module and includes the following steps:
[0020] Modify the configuration of the log printing module to create a new configuration;
[0021] All logs from each module are output according to the new configuration.
[0022] In the above dynamic debugging method, the second debugging script executes the second debugging method, which includes the following steps:
[0023] Obtain the variable data of the Lua data processing script;
[0024] Save the variable data of the Lua data processing script to a new Lua table in key-object format;
[0025] Then convert the Lua table to a JSON string and save it to the specified file.
[0026] In the above dynamic debugging method, the third debugging script executes the third debugging method, which includes the following steps:
[0027] Pass in the new Lua script;
[0028] The new Lua script is dynamically loaded as a submodule of the Lua data processing script through the dynamic debugging interface module;
[0029] Lua data processing scripts run to load submodules for debugging and output.
[0030] According to a third aspect of the present invention, an Internet of Things (IoT) system is provided, comprising a plurality of IoT devices, a plurality of IoT platforms, and a smart gateway as described in the first aspect;
[0031] Each IoT device corresponds one-to-one with the data acquisition module;
[0032] The data acquisition module collects data from the corresponding IoT device to form first data, and sends the first data to the device data transceiver module.
[0033] The device data transceiver module receives the first data and forwards it to the Lua data processing script through the Lua scheduling module. The Lua data processing script then converts the first data into second data for storage.
[0034] The Lua data processing script encapsulates the second data into third data that can be recognized by the IoT platform, and returns the third data to the Lua scheduling module;
[0035] The Lua scheduling module sends the third data to the platform interface module;
[0036] The platform docking module corresponds one-to-one with the IoT platform, and the platform docking module sends the third data to the corresponding IoT platform.
[0037] In the aforementioned IoT system, the Lua data processing script can perform edge computing according to the rules issued by the platform. The results of the edge computing are sent to the device data transceiver module through the Lua scheduling module, and the corresponding IoT device can be directly controlled through the device data transceiver module.
[0038] One of the above-described technical solutions of the present invention has at least one of the following advantages or beneficial effects:
[0039] The present invention incorporates a dynamic debugging interface module in the data processing framework, providing the ability to trigger dynamic debugging through an external interface, thereby enabling the invocation of preset Lua dynamic debugging scripts and giving the smart gateway powerful debugging capabilities.
[0040] When the first debugging script is called, the output log level can be dynamically modified, and debug logging can be enabled without restarting. This allows debug information to be output in real time when a problem occurs, quickly locate the difficult point, help find problems that are difficult to reproduce, and improve troubleshooting efficiency.
[0041] When the second debugging script is called, the real-time status of the Lua data processing script can be output in JSON format. It includes not only logs but also all variable data, providing more comprehensive and complete information. Technical personnel can quickly locate various program faults by analyzing the JSON status output in the specified file without having to add print statements in the source code in advance. It can flexibly deal with various unknown problems without recompiling and deploying the program. It can output the current status at any time, greatly improving debugging efficiency.
[0042] When calling a third debugging script, a new Lua script can be loaded for debugging output. This can bypass the limitations of the local environment, enable targeted debugging by writing new Lua scripts, write corresponding code as needed, and take different measures for different problems, thus providing greater flexibility. Attached Figure Description
[0043] The present invention will be further described below with reference to the accompanying drawings and embodiments;
[0044] Figure 1 This is a structural block diagram of the smart gateway of the present invention;
[0045] Figure 2 This is a flowchart of the dynamic debugging method of the present invention;
[0046] Figure 3 This is a structural block diagram of the Internet of Things system of the present invention. Detailed Implementation
[0047] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0048] The software in smart gateways is embedded software, which usually lacks a user-friendly human-machine interface. When IoT devices fail to collect data or the data reported to the platform does not match expectations, existing smart gateways cannot be directly debugged, and the methods and tools available for troubleshooting are very limited. Moreover, the special nature of IoT systems means that many problems will only be exposed during actual system operation and interaction with various IoT devices. At this time, the debugging methods that can be used during development become ineffective, and only the limited logs recorded can be relied upon to troubleshoot problems, which is often very time-consuming.
[0049] Reference Figure 1 As shown, according to a first aspect of the present invention, an intelligent gateway is provided, which is based on the Lua language and has a dynamic debugging interface module arranged in the data processing framework. It provides the ability to trigger dynamic debugging through an external interface, and can then call a preset Lua dynamic debugging script to improve the efficiency of fault diagnosis, facilitate the location of fault problems, and enable targeted debugging of fault problems, thus giving the intelligent gateway a powerful debugging capability.
[0050] The smart gateway includes a data acquisition module 1, a data processing framework 2, and a platform integration module 3;
[0051] Data acquisition module 1 is a data acquisition program for a single IoT field protocol, mainly for collecting data from the corresponding IoT devices. During field deployment, one or more data acquisition modules 1 will be selected for data acquisition based on the actual situation. The acquisition parameters of each data acquisition module 1 are configured during deployment and a final configuration file is generated. The data acquisition module 1 will take the acquired data as the first data and send the first data to the data processing framework 2.
[0052] The data processing framework 2 includes a device data transceiver module 21, a Lua scheduling module 22, a Lua data processing script 23, a Lua dynamic debugging script, and a dynamic debugging interface module 24;
[0053] The device data transceiver module 21 receives the first data and forwards it to the Lua data processing script 23 through the Lua scheduling module 22. The Lua data processing script 23 converts the first data into the second data for storage. Specifically, it converts the JSON string into a Lua table.
[0054] Meanwhile, Lua data processing script 23 will process the second data according to business needs, encapsulate the second data into third data, the third data is in a data format that the platform can recognize, and then return the third data to Lua scheduling module 22.
[0055] Lua scheduling module 22 sends the third data to platform interface module 3;
[0056] Platform integration module 3 sends the third-party data to the corresponding interface of the platform to complete the data collection.
[0057] In this embodiment, the Lua data processing script 23 can also perform edge computing according to the rules issued by the platform. The results of the edge computing are sent to the device data transceiver module 21 through the Lua scheduling module 22, and then the device data transceiver module 21 directly controls the IoT device. In this way, the data does not need to be reported to the platform and then returned, which greatly improves the data processing efficiency of the IoT system and solves the problem of unstable platform network connection.
[0058] In this embodiment, the data processing framework 2 includes a dynamic debugging interface module 24, which provides the ability to trigger dynamic debugging through external interfaces. Supported interfaces include POSIX signals, Socket, Pipe, and message queues.
[0059] When the dynamic debugging interface module 24 receives an external trigger signal, it will call the preset Lua dynamic debugging script through the Lua scheduling module 22.
[0060] The preset Lua dynamic debugging scripts include a first debugging script 25, a second debugging script 26, and a third debugging script 27. The Lua scheduling module 22 can schedule different debugging scripts according to different trigger signal parameters.
[0061] The first debugging script 25 can dynamically modify the log level and output all debugging information, including the debug level.
[0062] Because embedded devices have limited storage space, they can only save a limited number of log files. If all debugging information is printed, the device will quickly run out of logs to save. Therefore, only important logs, such as warn and info levels and above, are usually output, while debug logs are not output. When debugging is needed, debug logging is enabled by modifying the configuration and restarting the system. However, some problems are difficult to reproduce after restarting.
[0063] The data processing framework 2 includes a log printing module 28. In this embodiment, the first debugging script 25 can be directly called to modify the configuration of the log printing module 28, forming a new configuration. The logs are output according to the new configuration, thereby dynamically modifying the output log level. Debug logging can be enabled without restarting, so that when a problem occurs, debug information can be output immediately to quickly locate the difficult point. Moreover, temporarily enabling debug logging does not affect long-term log storage, avoiding the loss of important information. This dynamic modification of log level is more flexible, and additional debug information can be enabled at any time, which is conducive to discovering problems that are difficult to reproduce and improving troubleshooting efficiency.
[0064] The second debugging script 26 is associated with the Lua data processing script 23, enabling the second debugging script 26 to obtain the real-time running data of the Lua data processing script 23. Upon receiving the corresponding signal, it outputs the real-time status of the Lua data processing script 23 in JSON format, making it convenient to view all information.
[0065] Traditional debugging methods can only view the log information preset during the design phase. When the actual problem is not expected and there is no corresponding log, troubleshooting becomes difficult. The usual approach is to modify the source code, add printing, recompile and download the program to obtain the corresponding information. However, this embodiment does not require this. In this embodiment, when a problem occurs, the second debugging script 26 can be called to obtain the variable data of the Lua data processing script 23. The variable data of the Lua data processing script 23 is saved to a new Lua table in key-object format. Then, the Lua table is converted into a JSON string and saved to a specified file. This outputs the complete running status, including not only logs but also all variable data, providing more comprehensive and complete information. Technicians can quickly locate various program faults by analyzing the JSON status output in the specified file.
[0066] Based on the second debugging script 26, there is no need to add print statements in the source code in advance. It can flexibly deal with various unknown problems, without recompiling and deploying the program. It can output the current status at any time, which greatly improves debugging efficiency. At the same time, it can avoid the interference of modifying code and restarting the system. It is especially suitable for debugging difficult problems after product deployment.
[0067] The third debugging script 27 can load new Lua scripts, trigger the Lua data processing script 23 through script code, and modify the running data. Since Lua supports dynamic script loading, the data of the Lua data processing script 23 and the third debugging script 27 can be associated. When encountering problems that are difficult to locate, a new Lua script can be written to interact with the Lua data processing script 23 to obtain more information. After loading and running the new Lua script, more comprehensive debugging information can be obtained.
[0068] Traditional debugging methods can only passively check logs after the fact, and debugging tools such as gdb are difficult to use in the field environment, resulting in low efficiency in troubleshooting difficult problems. In this embodiment, technicians can write new Lua scripts in real time to address problems. These new Lua scripts are passed in through the third debugging script 27, and dynamically loaded as submodules of the Lua data processing script 23 through the dynamic debugging interface module 24. Submodules can be dynamically loaded and unloaded, and the Lua data processing script 23 runs the loaded submodules for debugging output. Submodules can interact with the Lua data processing script 34. After loading a submodule, the Lua data processing script 34 passes its own data as a parameter to the submodule, allowing the content of the Lua data processing script 34 to be dynamically modified through the submodule. By dynamically loading different submodules, different debugging purposes can be achieved. For example, variable values in the Lua data processing script 23 can be actively modified to trigger function calls, thereby actively checking logs. Based on this approach, the limitations of the field environment can be bypassed, and targeted debugging can be achieved by writing new Lua scripts. Corresponding code can be written as needed, and different measures can be taken for different problems, resulting in greater flexibility.
[0069] Reference Figure 2 As shown, according to a second aspect of the present invention, a dynamic debugging method is provided, relating to the smart gateway of the first aspect;
[0070] Includes the following steps:
[0071] Step 1: The dynamic debugging interface module 24 obtains the trigger signal and sends the trigger signal to the Lua scheduling module 22;
[0072] Step 2: The Lua scheduling module 22 calls the corresponding Lua dynamic debugging script based on the trigger signal.
[0073] In this embodiment, the Lua dynamic debugging script includes a first debugging script 25, a second debugging script 26, and a third debugging script 27.
[0074] In this embodiment, the first debugging script 25 executes the first debugging method, which involves the log printing module 28 and includes the following specific steps:
[0075] Modify the configuration of log printing module 28 to create a new configuration;
[0076] All logs from each module are output according to the new configuration;
[0077] By modifying the configuration of the log printing module 28, the log level can be dynamically modified, and all debugging information, including the debug level, can be output. Debug logging can be enabled without restarting, so that when a problem occurs, debug information can be output immediately to quickly locate the difficult point. Moreover, temporarily enabling debug logging does not affect long-term log storage, avoiding the loss of important information. This dynamic log level modification scheme is more flexible and can enable additional debugging information at any time, which is conducive to discovering problems that are difficult to reproduce and improving troubleshooting efficiency.
[0078] In this embodiment, the second debugging script 26 executes the second debugging method, which includes the following specific steps:
[0079] Retrieve variable data from Lua data processing script 23;
[0080] Save the variable data of Lua data processing script 23 to a new Lua table in key-object format;
[0081] Convert a Lua table to a JSON string and save it to a specified file;
[0082] This outputs a complete running status, including not only logs but also all variable data, providing more comprehensive and complete information. Technical personnel can quickly locate various program faults by analyzing the JSON status output in the specified file.
[0083] Based on the second debugging script 26, there is no need to add print statements in the source code in advance. It can flexibly deal with various unknown problems, without recompiling and deploying the program. It can output the current status at any time, which greatly improves debugging efficiency. At the same time, it can avoid the interference of modifying code and restarting the system. It is especially suitable for debugging difficult problems after product deployment.
[0084] In this embodiment, the third debugging script 27 executes the third debugging method, which includes the following specific steps:
[0085] Pass in the new Lua script;
[0086] The new Lua script is dynamically loaded as a submodule of the Lua data processing script 23 through the dynamic debugging interface module 24. The Lua data processing script 23 runs the loaded submodule for debugging output.
[0087] Submodules can interact with Lua data processing scripts 34. After loading a submodule, Lua data processing script 34 passes its own data as a parameter to the submodule. The content of Lua data processing script 34 can be dynamically modified through the submodule. Different debugging purposes can be achieved by dynamically loading different submodules. Based on this method, the limitations of the on-site environment can be bypassed. Targeted debugging can be achieved by writing new Lua scripts, writing corresponding code as needed, and taking different measures for different problems, which is more flexible.
[0088] Reference Figure 3 As shown, according to a third aspect of the present invention, an Internet of Things (IoT) system is provided, including a plurality of IoT devices 100, a plurality of IoT platforms 200, and a smart gateway as described in the first aspect;
[0089] The IoT device 100 corresponds one-to-one with the data acquisition module 1. The data acquisition module 1 will collect the data of the corresponding IoT device 100 to form the first data and send the first data to the data processing framework 2.
[0090] The data processing framework 2 includes a device data transceiver module 21, a Lua scheduling module 22, a Lua data processing script 23, a Lua dynamic debugging script, and a dynamic debugging interface module 24;
[0091] The device data transceiver module 21 receives the first data and forwards it to the Lua data processing script 23 through the Lua scheduling module 22. The Lua data processing script 23 converts the first data into the second data for storage. Specifically, it converts the JSON string into a Lua table.
[0092] Meanwhile, Lua data processing script 23 will process the second data according to business needs, encapsulate the second data into third data, the third data is in a data format that the IoT platform 200 can recognize, and then return the third data to Lua scheduling module 22.
[0093] Lua scheduling module 22 sends the third data to platform interface module 3;
[0094] Platform docking module 3 corresponds one-to-one with IoT platform 200. Platform docking module 3 sends the third data to the corresponding IoT platform 200 to complete data collection.
[0095] In this embodiment, the Lua data processing script 23 can also perform edge computing according to the rules issued by the platform. The results of the edge computing are sent to the device data transceiver module 21 through the Lua scheduling module 22, and then the device data transceiver module 21 directly controls the IoT device 100. In this way, the data does not need to be reported to the IoT platform 200 and then returned, which greatly improves the data processing efficiency of the IoT system and solves the problem of unstable platform network connection.
[0096] In this embodiment, a dynamic debugging interface module 24 is also provided, which provides the ability to trigger dynamic debugging through an external interface. When the dynamic debugging interface module 24 receives an external trigger signal, it will call a preset Lua dynamic debugging script through the Lua scheduling module 22.
[0097] The preset Lua dynamic debugging scripts include a first debugging script 25, a second debugging script 26, and a third debugging script 27. The Lua scheduling module 22 can schedule different debugging scripts according to different trigger signal parameters.
[0098] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
Claims
1. A smart gateway, comprising a data acquisition module, a data processing framework, and a platform interface module, wherein the data acquisition module acquires data from IoT devices to form first data, characterized in that, The data processing framework includes a device data transceiver module, a Lua scheduling module, a Lua data processing script, a Lua dynamic debugging script, and a dynamic debugging interface module. The device data transceiver module receives the first data and forwards it to the Lua data processing script through the Lua scheduling module. The Lua data processing script then converts the first data into second data for storage. The Lua data processing script processes the second data according to business needs, encapsulates the second data into third data that the platform can recognize, and then returns the third data to the Lua scheduling module. The Lua scheduling module sends the third data to the platform interface module; When the dynamic debugging interface module receives an external trigger signal, it calls the Lua dynamic debugging script through the Lua scheduling module. The Lua dynamic debugging script includes a first debugging script, a second debugging script, and a third debugging script. The Lua scheduling module schedules different debugging scripts according to different trigger signal parameters. The data processing framework also includes a log printing module. The first debugging script is used to configure the log printing module and can dynamically modify the log level. The second debugging script is associated with the Lua data processing script so that the second debugging script can obtain the real-time running data of the Lua data processing script; The third debugging script can load new Lua scripts, which serve as submodules of the Lua data processing script. The Lua data processing script runs and loads the submodules for debugging output.
2. The smart gateway according to claim 1, characterized in that, The dynamic debugging interface module is triggered via POSIX signals, sockets, pipes, and message queues.
3. A dynamic debugging method, characterized in that, Applied to the smart gateway as described in any one of claims 1-2, the method includes the following steps: Step 1: The dynamic debugging interface module acquires the trigger signal and sends the trigger signal to the Lua scheduling module; Step 2: The Lua scheduling module calls the corresponding Lua dynamic debugging script according to the trigger signal. The Lua dynamic debugging script includes a first debugging script, a second debugging script, and a third debugging script.
4. The dynamic debugging method according to claim 3, characterized in that, The first debugging script executes a first debugging method, which involves a log printing module and includes the following steps: Modify the configuration of the log printing module to create a new configuration; All logs from each module are output according to the new configuration.
5. The dynamic debugging method according to claim 3, characterized in that, The second debugging script executes the second debugging method, which includes the following steps: Obtain the variable data of the Lua data processing script; Save the variable data of the Lua data processing script to a new Lua table in key-object format; Then convert the Lua table to a JSON string and save it to the specified file.
6. The dynamic debugging method according to claim 3, characterized in that, The third debugging script executes a third debugging method, which includes the following steps: Pass in the new Lua script; The new Lua script is dynamically loaded as a submodule of the Lua data processing script through the dynamic debugging interface module; Lua data processing scripts run to load submodules for debugging and output.
7. An Internet of Things (IoT) system, characterized in that, Includes multiple IoT devices, multiple IoT platforms, and a smart gateway as described in any one of claims 1-2; Each IoT device corresponds one-to-one with the data acquisition module; The data acquisition module collects data from the corresponding IoT device to form first data, and sends the first data to the device data transceiver module. The device data transceiver module receives the first data and forwards it to the Lua data processing script through the Lua scheduling module. The Lua data processing script then converts the first data into second data for storage. The Lua data processing script encapsulates the second data into third data that can be recognized by the IoT platform, and returns the third data to the Lua scheduling module; The Lua scheduling module sends the third data to the platform interface module; The platform docking module corresponds one-to-one with the IoT platform, and the platform docking module sends the third data to the corresponding IoT platform.
8. The Internet of Things system according to claim 7, characterized in that, The Lua data processing script can perform edge computing according to the rules issued by the platform. The results of the edge computing are sent to the device data transceiver module through the Lua scheduling module, and the corresponding IoT device can be directly controlled through the device data transceiver module.