A method and apparatus for simulating automatic sending and responding of data by a device

By using a thread pool and timer, the automatic data transmission and response of simulated devices on the IoT platform are realized, which solves the problem of low debugging efficiency for multiple devices and enables parallel debugging of multiple devices and efficient data reporting.

CN116991673BActive Publication Date: 2026-11-24UNICOM (JILIN) INDUSTRIAL INTERNET CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311035232.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-17
Publication Date
2026-11-24
Estimated Expiration
2043-08-17

AI Technical Summary

Technical Problem

Existing IoT platforms can only be online individually when debugging multiple devices, which is labor-intensive and time-consuming, and does not support data reporting and response strategies for batch devices, resulting in low debugging efficiency.

Method used

The system uses a thread pool and timer to simulate automatic data transmission and response from the device, supporting simultaneous online debugging of multiple devices. By initializing device parameters and configuring strategies, it automatically reports and responds to data without manual intervention. The thread pool manages parallel tasks and records device logs.

Benefits of technology

It enables simultaneous debugging of multiple devices, saving time, improving debugging efficiency, quickly identifying problems, effectively utilizing system resources, avoiding task interference, and improving data reporting efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116991673B_ABST
    Figure CN116991673B_ABST
Patent Text Reader

Abstract

The application discloses a kind of methods and devices for simulating device automatically sending and responding data, it is related to Internet of Things terminal equipment simulator technical field.The application is realized by thread pool+timer mode to automatically report or respond data, so that the simulated device has the ability of automatically sending and responding data, it can be debugged and run multiple devices in the same window at the same time, it can also easily monitor the device running state, record device log, it can simultaneously expand debugging to multiple devices, quickly find problems, locate problems, avoid monitoring running one device at the same time, save time, and improve the efficiency of debugging of access Internet of Things platform device.At the same time, multiple tasks are running in parallel, triggered at regular intervals, do not interfere with each other, avoid waiting for each other, effectively utilize system resources, improve the efficiency of data reporting.
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) terminal device simulator technology, and in particular to a method and apparatus for simulating automatic data transmission and response by a device. Background Technology

[0002] In the development of the Internet of Things (IoT), connecting terminal devices to different cloud platforms is a significant part of the workload. On the one hand, the development environment on terminal devices is mostly embedded development, and on the other hand, the stability and functional completeness of the platform need to be developed in parallel. Therefore, terminal device simulators are essential. Simulators can not only identify functional design defects of the platform or business in advance, but also provide independent access modules for the development of terminal device access.

[0003] By using an IoT terminal device simulator, users can simulate platform interactions with any device, allowing for early testing of platform functionality, stability, and access performance. Manually adding devices and configuring simulated data transmission allows for testing the communication capabilities between the IoT platform and the devices, and for identifying potential problems.

[0004] However, due to the unique nature of the devices being debugged, IoT platforms often lack real-device debugging capabilities, causing significant challenges when developing data analysis functionalities. Currently, while Alibaba Cloud's IoT platform offers a simulator, it's not user-friendly. Within a single window, Alibaba Cloud's IoT platform only supports one simulator for online debugging at a time, preventing the simultaneous debugging of multiple devices. This makes it difficult for users to monitor the data reported by multiple devices simultaneously, wasting both manpower and debugging time. Furthermore, sometimes it's unnecessary to monitor the debugging window in real-time; simply checking the debugging results to confirm that the device is reporting and responding correctly is sufficient.

[0005] Therefore, there is a need to develop a solution that can save time and accurately and efficiently debug and access IoT devices, and support batch device data reporting strategies and response reply strategies. Summary of the Invention

[0006] To address the aforementioned issues, this invention proposes a method and apparatus for simulating automatic data transmission and response by devices. This allows for simultaneous online debugging of multiple devices. It pre-configures attributes and automatic event reporting strategies, setting default or random values ​​for device attributes and event automatic transmission (only for numeric parameters). It also allows for automatic response to service-issued parameters using default values. During simultaneous online debugging of multiple devices, the devices automatically report data and respond to services at pre-set intervals according to pre-defined default or random values ​​within a pre-set debugging period, requiring no manual intervention. For short-connection protocol devices, connection requests are automatically triggered during reporting. Finally, the user only needs to view the debugging results from the output logs, fully achieving the goal of unattended automatic operation of the simulator.

[0007] To achieve the above objectives, the present invention provides the following technical solution: On one hand, the present invention provides a method for simulating automatic data transmission and response by a device, comprising the following steps: Step S1: Initialize the simulated device parameters, including initializing basic device information, device object model information, and automatic reporting or response strategy configuration information; the basic device information is obtained through the device module and includes device identifier, device type, and encrypted transmission method; the device object model information is obtained through the device object model module and consists of device-specific resources conforming to IoT standard protocols, including the device's reporting attributes, services, and events, and the maximum, minimum, and step sizes of the data format are configured for each resource; the automatic reporting or response strategy configuration information includes relevant rules for the data reporting or response cycle corresponding to the device object model information. Step S2: Use the device object model module to obtain device object model information and proceed to step S3; at the same time, use the device data delivery listener module to configure the device data delivery listener. When the device data delivery listener module receives the server response data, proceed to step S43 to process the data response. Step S3: Create a virtual device client and register and connect to the server according to the IoT standard protocol; Step S4: Use the data reporting module to determine whether the timed strategy is enabled. If not enabled, proceed to step S5; if enabled, proceed to the following steps: S41: Call the timing strategy module to start the multi-threaded timer program; S42: The timing strategy module verifies whether the current time is an executable resource that can be automatically reported. If so, proceed to S43; otherwise, end the current timer. S43: The timed strategy module verifies whether the virtual device has defined this resource and automatically reported or responded. If so, proceed to step S5; otherwise, end the task. Step S5: The data reporting module checks the cached virtual client to confirm whether the client is online. If online, proceed to step S6; otherwise, proceed to the following steps: S51: The data reporting module calls the device basic information module to obtain the autoReconn field, which is the threshold for the number of automatic reconnections, to determine whether the simulated device allows automatic reconnection. S52: The data reporting module calls the device basic information module to obtain the automatic reconnection number threshold autoReconn and the current value of the automatic reconnection number autoReconnCurr to determine whether the automatic reconnection number is greater than 0. If so, automatic reconnection is performed and the process jumps to step S2. Otherwise, the reporting is stopped. Step S6: The data reporting module reports or responds to data; Step S7: The data reporting module records the device debugging log.

[0008] Furthermore, in the above-mentioned method for automatically sending and responding to data by a simulated device, in step S1, the basic information of the device is stored in a relational database sqlite, and its data structure is: device=[device name, device type, product key, device key, authentication method, security key, encryption method, IMEI number, CA certificate, automatic reconnection number threshold autoReconn, current value of automatic reconnection number autoReconnCurr].

[0009] Furthermore, in the above-mentioned method for automatically sending and responding to data by a simulated device, in step S1, the object model information is stored in a non-relational database lowdb, and its data is stored and manipulated in JSON format: physicalModel={device identifier, object model basic parameters, [attribute identifier, attribute reporting parameters, attribute response parameters], [event identifier, event reporting parameters, event response parameters], [service identifier, service reporting parameters, service response parameters]}.

[0010] Furthermore, in the above-mentioned method for automatically sending and responding to data by the simulation device, the relevant rules in step S1 include the following methods: fixed value reporting, random number reporting, and incremental reporting within a range.

[0011] Furthermore, in the above-mentioned method for automatically sending and responding to data by a simulated device, in step S1, the automatic reporting or response strategy configuration information is stored in a non-relational database lowdb, and its data is stored and manipulated in JSON format: autoStrategy={device identifier, [resource identifier, start time, end time, reporting type, value type, reported value / range, step size]}, where the resource identifier is an attribute identifier, event identifier, or service identifier, the reporting type is reporting or response, and the value type is a fixed value, random, or step size increase.

[0012] Furthermore, in the above-mentioned method for automatically sending and responding to data by an analog device, step S41 specifically includes the multi-threaded timer program: (1) Configure thread pool parameters, including core thread count, maximum thread count, and number of idle threads; (2) After the project starts, a local global constant Map is built to cache all created threads; (3) After the simulated device is registered and put online, a thread is created for each resource using the ScheduledExecutorService class according to the configured reporting strategy. The delay and time period parameters are set, and the run() method is implemented in the thread to complete the automatic reporting logic. After creation, the thread is started and added to the global Map with <device identifier + resource identifier> as the key and the thread instance as the value. (4) When the device goes offline, use the global Map to query all the threads created by this device, and call the stop() method to stop the threads one by one.

[0013] On the other hand, the present invention provides an apparatus for simulating automatic data transmission and response by a device, comprising the following functional modules to implement the method described in any of the above: Device module: Used to record and retrieve basic device information; Equipment model module: used to record and retrieve equipment model information; Data reporting module: used to determine whether to start the timed policy, whether the cached virtual client is online, whether the simulated device allows automatic reconnection, and to report or respond to data; Device data delivery listener module: Used to configure the device data delivery listener to listen for data delivered by the server and respond to the server. Automatic reporting or response strategy configuration module: used to set the relevant rules for the data reporting or response cycle corresponding to the equipment physical model information; The timing strategy module is used to manage and operate multi-threaded timers, and to execute and stop tasks of the automatic reporting or response strategy configuration module.

[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: The present invention proposes a method and apparatus for automatically sending and responding to data using simulated devices. This method employs a thread pool and timer to achieve automatic data reporting and response, enabling simulated devices to automatically send and respond to data. It allows for the simultaneous debugging and operation of multiple devices within the same window, and also facilitates easy monitoring of device operating status and recording of device logs. This avoids the limitation of monitoring only one device at a time, saving time and improving testing efficiency. Under this design mechanism, all data reporting operations are completed in independent threads, and all tasks are stored in memory using dynamic linked lists and red-black tree structures. This allows for simultaneous debugging of multiple devices, quickly identifying and locating problems, and significantly improving the debugging efficiency of devices connected to the IoT platform. Furthermore, multiple tasks run in parallel, triggered periodically, without interference or waiting, effectively utilizing system resources and improving data reporting efficiency. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0016] Figure 1 A flowchart illustrating the method for automatically sending and responding to data using a simulation device provided by the present invention.

[0017] Figure 2 The functional block diagram of the device for automatically sending and responding to data in the simulation equipment provided by the present invention. Detailed Implementation

[0018] To better understand this technical solution, the technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described examples are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.

[0019] The method for automatically sending and responding to data in a simulated device proposed in this invention, such as... Figure 1 As shown, it includes the following steps: Step S1: Initialize the simulation equipment parameters, including initializing basic equipment information, equipment object model information, and automatic reporting or response strategy configuration information. During this process, the following data structures are created: Basic device information: obtained through the device module, including device identifier, device type, and encrypted transmission method; device information is stored in the relational database sqlite, and its data structure is: device=[device name, device type, product key, device key, authentication method, security key, encryption method, IMEI number, CA certificate, automatic reconnection count threshold autoReconn, current value of automatic reconnection count autoReconnCurr.

[0020] Device object model information: Device-specific resources that conform to IoT standard protocols are obtained through the device object model module, including the device's reported attributes, services, and events. Maximum, minimum, and step sizes for data formats are configured for each resource. The object model information is stored in the non-relational database lowdb, and the data is stored and manipulated in JSON format: physicalModel={Device ID, Object Model Basic Parameters, [Attribute ID, Attribute Reporting Parameters, Attribute Response Parameters], [Event ID, Event Reporting Parameters, Event Response Parameters], [Service ID, Service Reporting Parameters, Service Response Parameters]}.

[0021] Automatic reporting or response strategy configuration information includes rules related to the data reporting or response cycle corresponding to the device object model information. Examples include fixed value reporting, random number reporting, and incremental reporting within a range. The reporting or response strategy information is stored in the non-relational database lowdb, and the data is stored and manipulated in JSON format: autoStrategy={Device ID, [Resource ID (attribute, event, or service ID), Start Time, End Time, Reporting Type (1 Report, 2 Response), Value Type (1 Fixed Value, 2 Random, 3 Incremental Reporting), Reported Value / Range, Step Size]}.

[0022] Step S2: Use the device object model module to obtain device object model information and proceed to step S3; at the same time, use the device data delivery listener module to configure the device data delivery listener. When the device data delivery listener module receives the server response data, proceed to step S43 to process the data response. Step S3: Create a virtual device client and register and connect to the server according to the IoT standard protocol; Step S4: Use the data reporting module to determine whether the timed strategy is enabled. If not enabled, proceed to step S5; if enabled, proceed to the following steps: S41: Call the timing strategy module to start the multi-threaded timer program; The multi-threaded timer program specifically includes: (1) Configure thread pool parameters, including core thread count, maximum thread count, and number of idle threads; (2) After the project starts, a local global constant Map is built to cache all created threads; (3) After the simulated device is registered and put online, according to the configured reporting strategy, a thread is created for each resource using the ScheduledExecutor Service class, and the delay and time period parameters are set. The run() method is implemented in the thread to complete the automatic reporting logic. After creation, the thread is started and added to the global Map with <device identifier + resource identifier> as the key and the thread instance as the value. (4) When the device goes offline, use the global Map to query all the threads created by this device, and call the stop() method to stop the threads one by one.

[0023] S42: The timing strategy module verifies whether the current time is an executable resource that can be automatically reported. If so, proceed to S43; otherwise, end the current timer. S43: The timed strategy module verifies whether the virtual device has defined this resource and automatically reported or responded. If so, proceed to step S5; otherwise, end the task. Step S5: The data reporting module checks the cached virtual client to confirm whether the client is online. If online, proceed to step S6; otherwise, proceed to the following steps: S51: The data reporting module calls the device basic information module to obtain the automatic reconnection number threshold autoReconn to determine whether the simulated device allows automatic reconnection. S52: The data reporting module calls the device basic information module to obtain the automatic reconnection number threshold autoReconn and the current value of the automatic reconnection number autoReconnCurr to determine whether the automatic reconnection number is greater than 0. If so, automatic reconnection is performed and the process jumps to step S2. Otherwise, the reporting is stopped. To better implement the automatic data reporting or response proposed in this invention, an `autoReconn` attribute is set in the device information for automatic reconnection counts when the device automatically reconnects in the event of a non-intentional disconnection. After the virtual device successfully comes online, this invention sets the current value of the `autoReconnCurr` attribute to be the same as the automatic reconnection count threshold (default is 0, and the value of the `autoReconn` threshold can be modified through the device information module). When the device abnormally disconnects and attempts to automatically reconnect, the current value of the automatic reconnection count is decremented by 1. When this value reaches 0, the device will stop automatically reconnecting.

[0024] Step S6: The data reporting module reports or responds to data; Step S7: The data reporting module records the device debugging log.

[0025] The method of this invention uses a thread pool and timer to achieve automatic data reporting or response. All data reporting operations are completed in independent threads, and all tasks are stored in memory in the form of dynamic linked lists and red-black trees. They all run in parallel, are triggered on a timer, do not interfere with each other, avoid waiting for each other, effectively utilize system resources, and improve the efficiency of data reporting.

[0026] Corresponding to the above-described method for automatically sending and responding to data in a simulated device, the present invention provides an apparatus for automatically sending and responding to data in a simulated device, such as... Figure 2 As shown, the following functional modules are included to implement the above method: Device module: Used to record and retrieve basic device information; Equipment model module: used to record and retrieve equipment model information; Data reporting module: used to determine whether to start the timed policy, whether the cached virtual client is online, whether the simulated device allows automatic reconnection, and to report or respond to data; Device data delivery listener module: Used to configure the device data delivery listener to listen for data delivered by the server and respond to the server. Automatic reporting or response strategy configuration module: used to set the relevant rules for the data reporting or response cycle corresponding to the equipment physical model information; The timing strategy module is used to manage and operate multi-threaded timers, and to execute and stop tasks of the automatic reporting or response strategy configuration module.

[0027] The above description is merely a detailed explanation of preferred embodiments and principles of the present invention and is not intended to limit the scope of protection of the present invention. For those skilled in the art, any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention, based on the ideas provided by the present invention, should be considered within the scope of protection of the present invention.

Claims

1. A method for simulating automatic data transmission and response by a device, characterized in that, Includes the following steps: Step S1: Initialize the simulated device parameters, including initializing basic device information, device object model information, and automatic reporting or response strategy configuration information; the basic device information is obtained through the device module and includes device identifier, device type, and encrypted transmission method; the device object model information is obtained through the device object model module and consists of device-specific resources conforming to IoT standard protocols, including the device's reporting attributes, services, and events, and the maximum, minimum, and step sizes of the data format are configured for each resource; the automatic reporting or response strategy configuration information includes relevant rules for the data reporting or response cycle corresponding to the device object model information. Step S2: Use the device object model module to obtain device object model information and proceed to step S3; at the same time, use the device data delivery listener module to configure the device data delivery listener. When the device data delivery listener module receives the server response data, proceed to step S43 to process the data response. Step S3: Create a virtual device client and register and connect to the server according to the IoT standard protocol; Step S4: Use the data reporting module to determine whether the timed strategy is enabled. If not enabled, proceed to step S5; if enabled, proceed to the following steps: S41: Call the timing strategy module to start the multi-threaded timer program; in step S41, the multi-threaded timer program specifically includes: (1) Configure thread pool parameters, including core thread count, maximum thread count, and number of idle threads; (2) After the project starts, a local global constant Map is built to cache all created threads; (3) After the simulated device is registered and put online, a thread is created for each resource using the ScheduledExecutorService class according to the configured reporting strategy. The delay and time period parameters are set, and the run() method is implemented in the thread to complete the automatic reporting logic. After creation, the thread is started and added to the global Map with <device identifier + resource identifier> as the key and the thread instance as the value. (4) When the device goes offline, use the global Map to query all the threads created by this device, and call the stop() method to stop the threads one by one; S42: The timing strategy module verifies whether the current time is an executable resource that can be automatically reported. If so, proceed to S43; otherwise, end the current timer. S43: The timed strategy module verifies whether the virtual device has defined this resource and automatically reported or responded. If so, proceed to step S5; otherwise, end the task. Step S5: The data reporting module checks the cached virtual client to confirm whether the client is online. If online, proceed to step S6; otherwise, proceed to the following steps: S51: The data reporting module calls the device basic information module to obtain the autoReconn field, which is the threshold for the number of automatic reconnections, to determine whether the simulated device allows automatic reconnection. S52: The data reporting module calls the device basic information module to obtain the automatic reconnection number threshold autoReconn and the current value of the automatic reconnection number autoReconnCurr to determine whether the automatic reconnection number is greater than 0. If so, automatic reconnection is performed and the process jumps to step S2. Otherwise, the reporting is stopped. Step S6: The data reporting module reports or responds to data; Step S7: The data reporting module records the device debugging log.

2. The method for automatically sending and responding to data using a simulation device according to claim 1, characterized in that, In step S1, the basic device information is stored in the relational database SQLite, and its data structure is: device=[device name, device type, product key, device key, authentication method, security key, encryption method, IMEI number, CA certificate, automatic reconnection count threshold autoReconn, current value of automatic reconnection count autoReconnCurr].

3. The method for automatically sending and responding to data using a simulation device according to claim 1, characterized in that, In step S1, the object model information is stored in the non-relational database lowdb, and its data is stored and manipulated in JSON format: physicalModel={device identifier, object model basic parameters, [attribute identifier, attribute reporting parameters, attribute response parameters], [event identifier, event reporting parameters, event response parameters], [service identifier, service reporting parameters, service response parameters]}.

4. The method for automatically sending and responding to data using a simulation device according to claim 1, characterized in that, In step S1, the relevant rules include the following methods: fixed value reporting, random number reporting, and incremental reporting within a range.

5. The method for automatically sending and responding to data using a simulation device according to claim 1, characterized in that, In step S1, the automatic reporting or response strategy configuration information is stored in the non-relational database lowdb, and its data is stored and manipulated in JSON format: autoStrategy={device identifier, [resource identifier, start time, end time, reporting type, value type, reported value / range, step size]}, where the resource identifier is an attribute identifier, event identifier, or service identifier, the reporting type is reporting or response, and the value type is fixed value, random, or step size increase.

6. A device for automatically sending and responding to data in a simulation device, characterized in that, The following functional modules are included to implement the method described in any one of claims 1-5: Device module: Used to record and retrieve basic device information; Equipment model module: used to record and retrieve equipment model information; Data reporting module: used to determine whether to start the timed policy, whether the cached virtual client is online, whether the simulated device allows automatic reconnection, and to report or respond to data; Device data delivery listener module: Used to configure the device data delivery listener to listen for data delivered by the server and respond to the server. Automatic reporting or response strategy configuration module: used to set the relevant rules for the data reporting or response cycle corresponding to the equipment physical model information; The timing strategy module is used to manage and operate multi-threaded timers, and to execute and stop tasks of the automatic reporting or response strategy configuration module.

Citation Information

Patent Citations

  • Testing method and testing device for intelligent equipment platform

    CN105959174A

  • Method and device for realizing information data collection and sending processing based on wireless AP, processor and computer readable storage medium thereof

    CN114501685A