A data transmission method for a microcontroller

By cooperating with the PPP data mode and LwIP protocol stack of the cloud server through the 4G communication module, the problem of low communication efficiency of the traditional AT command set is solved, and efficient and reliable data transmission is achieved, meeting the needs of IoT for large data volume and high reliability connection.

CN120583095BActive Publication Date: 2025-10-31临海市新睿电子科技股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511073858.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-01
Publication Date
2025-10-31
Estimated Expiration
2045-08-01

AI Technical Summary

Technical Problem

In existing IoT terminals, the traditional communication method of controlling the communication between the microcontroller and the cellular communication module through the AT command set is inefficient, difficult to support large data volume or high frequency data transmission, and has weak fault tolerance.

Method used

A 4G communication module is used to establish a data communication connection with the cloud server. The LwIP protocol stack works in collaboration with the Point-to-Point Protocol (PPP) data mode to achieve link control, identity authentication and network parameter negotiation. Combined with anomaly detection mechanism and escape sequence, communication stability and fault tolerance are ensured.

Benefits of technology

It improves the stability and fault tolerance of the communication system, realizes efficient and reliable data transmission, and meets the needs of large data volume and high reliability connection in IoT scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120583095B_ABST
    Figure CN120583095B_ABST
Patent Text Reader

Abstract

This application relates to a data transmission method for a microcontroller. The method includes sending a dialing command to a 4G communication module. When the 4G communication module switches to a point-to-point protocol data mode based on the received dialing command, a point-to-point protocol session is constructed based on the LwIP protocol stack. Based on the point-to-point protocol session, a negotiation operation is performed. If the negotiation operation is successful, the point-to-point protocol session is established as a point-to-point data link, and data communication with a cloud server is conducted based on this point-to-point data link. By introducing a point-to-point protocol dialing mechanism and combining it with the LwIP protocol stack, the microcontroller can achieve efficient data communication with the cloud server without relying on traditional AT command interaction, avoiding the data bottleneck problem caused by limited serial port bandwidth, and improving the system's recovery capability and communication stability in abnormal scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of data transmission in a microcontroller, and more particularly to a data transmission method for a microcontroller. Background Technology

[0002] Currently, such as Figure 1 As shown, in existing Internet of Things (IoT) terminals, traditional communication solutions generally use microcontrollers (such as STM32, MSP430, or 51 series) in conjunction with cellular communication modules (such as 2G, 4G, and NB-IoT modules) to achieve remote data upload and network access. This type of communication system typically relies on the AT command set for control; that is, the microcontroller sends AT commands to the communication module via a serial port (UART), and the communication module performs operations such as connection, dialing, and data upload accordingly, and feeds back the execution results to the microcontroller via the serial port.

[0003] Despite the advantages of this communication method, such as simple implementation, low power consumption, and wide applicability, it still has the following technical bottlenecks because its communication principle relies on serial port interaction and command parsing: First, the serial port speed is limited and it is a half-duplex communication structure, resulting in low overall communication efficiency and difficulty in supporting the data transmission needs of large data volumes or high frequencies; Second, AT command parsing relies on the serial execution logic of the state machine, which makes information interaction complex and fault tolerance weak. Even a slight error may lead to connection interruption or system deadlock.

[0004] Therefore, there is an urgent need for a data transmission method that can overcome the bottleneck of AT command communication and improve communication efficiency. Summary of the Invention

[0005] To address the problems of low communication efficiency and complex status management caused by relying on AT command sets for control in existing technologies, this application provides a data transmission method for a microcontroller.

[0006] A data transmission method for a microcontroller, comprising communicating with a cloud server via a 4G communication module, the method including:

[0007] Check the communication connection status of the 4G communication module;

[0008] If the communication connection status is normal, a dialing command is sent to the 4G communication module. The dialing command includes at least the access point name parameter, which is used to instruct the 4G communication module to access the target network channel to initiate a point-to-point protocol dialing request.

[0009] When the 4G communication module switches to the point-to-point protocol data mode based on the received dialing command, a point-to-point protocol session is constructed based on the LwIP protocol stack. In the point-to-point protocol data mode, the 4G communication module automatically suspends the AT command parsing mechanism and detects in real time whether it is in an abnormal scenario. If it is in an abnormal scenario, an escape sequence is sent to the 4G communication module to control the 4G communication module to exit the point-to-point protocol data mode and then restore the AT command parsing mechanism.

[0010] Based on the aforementioned peer-to-peer protocol session, perform a negotiation operation;

[0011] If the negotiation operation is successful, the point-to-point protocol session is identified as a point-to-point data link, and data communication with the cloud server is carried out based on the point-to-point data link.

[0012] By adopting the above technical solution and introducing a 4G communication module to establish a data communication connection with the cloud server, stable data interaction between the microcontroller system and the remote server is realized. It has a dynamic sending mechanism for dialing commands and the ability to judge the communication status in real time, ensuring that it can exit the point-to-point protocol mode in time in abnormal scenarios, thereby improving the stability and fault tolerance of the communication system.

[0013] Preferably, the step of performing the negotiation operation based on the peer-to-peer protocol session specifically includes:

[0014] The negotiation operation includes at least link control negotiation operation, identity authentication negotiation operation and network parameter negotiation operation;

[0015] The link control negotiation operation is used to negotiate the frame structure parameters in the point-to-point data link based on the link control protocol;

[0016] The identity authentication negotiation operation is used to authenticate the access identity when accessing the target network channel based on an identity authentication protocol, wherein the identity authentication protocol is a password authentication protocol or a challenge handshake authentication protocol.

[0017] The network parameter negotiation operation is used to obtain and verify network layer communication parameters based on the network control protocol. The network layer communication parameters are allocated through the operator network-side equipment corresponding to the target network channel.

[0018] By adopting the above technical solution, and by negotiating the link control, authentication, and network parameters in the point-to-point protocol, it is ensured that the link structure, access identity, and communication parameters have been verified and configured before the data link is established. This helps to establish a secure and reliable point-to-point data link and improves the quality and security of data communication.

[0019] Preferably, the step of real-time detection of whether an abnormal scenario is in progress includes:

[0020] Construct a discrimination matrix that includes multiple communication state dimensions, wherein the communication state dimensions include at least the response state of the point-to-point protocol session and the number of negotiation rounds of the link control protocol, as well as the SIM card status and network registration status response time in the 4G communication module;

[0021] Scoring is performed according to the preset scoring rules corresponding to each of the communication status dimensions, generating corresponding scoring dimension values, and the scoring dimension values ​​are added together to generate corresponding communication anomaly scoring values.

[0022] A communication anomaly tolerance threshold is dynamically set. When the communication anomaly score exceeds the communication anomaly tolerance threshold, it is determined that an abnormal scenario has been detected. The communication anomaly tolerance threshold is calculated by weighted average of the network registration response time, negotiation failure frequency, and number of retransmissions due to disconnection recorded by the 4G communication module during historical dialing.

[0023] By adopting the above technical solution, constructing a discrimination matrix containing multiple communication state parameters, and combining a scoring mechanism to determine in real time whether an abnormal state has been entered, it is possible to accurately identify abnormal scenarios based on the comprehensive performance of the communication state, thereby triggering a protection mechanism and effectively preventing point-to-point communication failures or system deadlocks.

[0024] Preferably, after the step of performing the negotiation operation based on the peer-to-peer protocol session, the method further includes:

[0025] If the negotiation operation fails, the dynamically updated access point name sequence is invoked to determine the optimal access point name parameters.

[0026] Based on the optimal access point name parameter, the network environment identifier parameter associated with the optimal access point name parameter, and the communication anomaly score, a new dialing command is generated.

[0027] By adopting the above technical solution, the optimized access point strategy is automatically invoked after the negotiation fails, and the dialing behavior is adjusted in combination with the communication status score. It has the ability to adapt to changes in the network environment, and improves the dialing success rate and communication recovery capability of the system in multiple network environments.

[0028] Preferably, the method for establishing the access point name sequence includes the following steps:

[0029] Multiple access point name parameters are preset, and access credential information and dialing operation parameters are configured for each access point name parameter. The access credential information is used to determine whether the corresponding access point name parameter is successfully authenticated.

[0030] An initial priority value is assigned to each of the access point name parameters, and the initial priority value is set based on the access channel type, network level, and user-defined rules;

[0031] Obtain historical usage data for each access point name parameter, wherein the historical usage data is the connection success rate, dialing response time and abnormal interruption frequency of the access point name parameter in each point-to-point protocol dialing process.

[0032] Based on a preset scoring model, the access point name parameters are dynamically updated with priority according to the historical usage data to generate a sequence of access point names arranged by priority.

[0033] By adopting the above technical solution, and by pre-setting access points and combining them with historical dialing data for priority evaluation and dynamic sorting, an optimized sequence of access points is formed. This enables the system to select the most suitable network channel based on actual communication performance, significantly improving dialing success rate and network connection efficiency.

[0034] Preferably, the step of generating a new dialing command based on the optimal access point name parameter, the network environment identifier parameter associated with the optimal access point name parameter, and the communication anomaly score includes:

[0035] Call the constructed dialing instruction template pool, which includes multiple preset dialing instruction templates configured for different access scenarios;

[0036] Obtain the network environment identification parameter associated with the optimal access point name parameter, wherein the network environment identification parameter includes at least the SIM card operator identifier, the base station identifier, and the historical average signal strength;

[0037] The network environment identification parameters and communication anomaly score are input into the policy matching engine to match the dialing instruction template most suitable for the current scenario;

[0038] A new dialing command is generated based on the matched dialing command template and the optimal access point name parameter.

[0039] By adopting the above technical solution, the dialing template is matched by inputting network environment parameters and abnormal score values ​​into the strategy engine, making the dialing command more adaptable in the actual network environment, avoiding the instability of general templates in complex environments, and realizing intelligent customization and fine control of the dialing process.

[0040] Preferably, the step of acquiring and verifying network layer communication parameters includes:

[0041] Obtain network layer communication parameters, which include at least IP address parameters and DNS address parameters;

[0042] Verify that the IP address parameter and the DNS address parameter are valid;

[0043] Verify that the number of DNS address parameters is consistent with the required number of peer-to-peer dialing requests;

[0044] The system continuously monitors whether the network parameter negotiation operation exceeds a preset negotiation time threshold. If the network parameter negotiation operation does not exceed the preset negotiation time threshold, the network parameter negotiation operation is determined to be successful. If the network parameter negotiation operation exceeds the preset negotiation time threshold, the point-to-point data link is closed or the 4G communication module is restarted.

[0045] By adopting the above technical solutions, the legality and consistency of IP addresses and DNS parameters are verified, and a negotiation time limit is set to ensure the correctness and timeliness of the network parameter negotiation process. At the same time, in the event of an abnormal timeout, the connection is automatically disconnected or restarted to ensure that the communication process does not fall into a long waiting or abnormal state.

[0046] Preferably, the step of shutting down the point-to-point data link or restarting the 4G communication module if the network parameter negotiation operation exceeds a preset negotiation time threshold includes:

[0047] If the network parameter negotiation operation exceeds a preset negotiation time threshold, a disconnection data frame is sent to the 4G communication module and the current number of times the disconnection data frame is sent is recorded.

[0048] Detect whether the returned disconnected data frame is received within a preset response time threshold. If the returned disconnected data frame is received, close the point-to-point data link.

[0049] If the disconnected data frame is not received, it is determined whether the current number of transmissions is greater than a preset transmission threshold. If it is not greater than the preset transmission threshold, the disconnected data frame is retransmitted to the 4G communication module. If it is greater than the preset transmission threshold, the 4G communication module is restarted.

[0050] By adopting the above technical solution and setting a retry mechanism for broken links and a threshold for the number of transmissions, an effective processing path is achieved after abnormal timeouts in network negotiation. When multiple attempts to break the link fail without response, the module is automatically restarted, which can prevent the dead link state from persisting and enhance the system's self-recovery capability and operational stability.

[0051] Preferably, the step of verifying the communication connection status of the 4G communication module includes:

[0052] When the 4G communication module is powered on, check whether it is synchronized with the 4G communication module. If it is not synchronized, perform the corresponding synchronization operation.

[0053] If synchronization is maintained, it is determined whether the SIM card in the 4G communication module is in normal status. If the SIM card is in abnormal status, the point-to-point protocol dialing process is exited.

[0054] If the SIM card is in normal condition, then check the network registration status of the 4G communication module;

[0055] If the network registration status of the 4G communication module is "registered", then the communication connection status is determined to be normal.

[0056] By adopting the above technical solution, the status of the communication module is detected and synchronized step by step during the system power-on phase. This ensures that the SIM card status and network registration status are both in normal condition before entering the dialing process, fundamentally guaranteeing that the necessary conditions before the communication process is established have been met, and improving the reliability of the communication initialization phase.

[0057] Preferably, the step of verifying the network registration status of the 4G communication module includes:

[0058] Send a first verification command to the 4G communication module. The first verification command is used to verify whether the 4G communication module has completed the registration of the call network.

[0059] The system receives a first return value sent by the 4G communication module in real time. The first return value is used to determine that the 4G communication module has completed the registration of the call network. If the first return value is not received within a first preset time threshold, the system controls the 4G communication module to perform a restart operation.

[0060] If the first return value of the 4G communication module is received, a second verification instruction is sent to the 4G communication module. The second verification instruction is used to verify whether the Internet access network of the 4G communication module has been registered.

[0061] The system receives a second return value sent by the 4G communication module in real time. The second return value is used to determine that the 4G communication module has completed its Internet registration. If the second return value is not received within a second preset time threshold, the system controls the 4G communication module to perform a restart operation.

[0062] By adopting the above technical solution, the registration status is determined by phased registration verification of the voice network and the Internet network, and a time threshold for receiving the response is set. If the timeout occurs, the communication module is restarted in time, thereby effectively avoiding the problem of dialing failure due to abnormal network registration and ensuring the initialization success rate and response speed of the communication system.

[0063] In summary, this application includes at least one of the following beneficial technical effects:

[0064] By introducing a Point-to-Point Protocol (PPP) data mode in conjunction with the LwIP protocol stack, the traditional AT command-based serial communication mode is replaced, achieving a more efficient and stable communication mechanism between the microcontroller and the 4G communication module. First, a status check mechanism ensures the 4G communication module is available, preventing invalid dialing due to SIM card malfunctions or unregistered networks. Then, the microcontroller sends a dialing command containing the access point name parameter, driving the 4G communication module to switch to PPP data mode and automatically suspending the AT command parsing process, ensuring the communication link is dedicated to data transmission. Based on this, the LwIP protocol stack is used to build a PPP session and complete necessary link negotiation, authentication, and network parameter allocation, ultimately establishing a point-to-point data link to support efficient data communication with the cloud server. Simultaneously, an escape mechanism is implemented, which, upon detecting a communication anomaly, sends a specific escape command to control the module to exit PPP data mode and resume the AT command channel, thereby improving the system's fault tolerance and recovery capabilities. It not only solves the problems of low communication efficiency and slow status response in traditional solutions, but also avoids frequent reliance on command-level interaction, significantly enhancing the real-time performance and stability of data transmission, and meeting the communication needs of large data volumes and highly reliable connections in IoT scenarios. Attached Figure Description

[0065] Figure 1 This is a block diagram illustrating the principle of the prior art in this application.

[0066] Figure 2 This is a flowchart illustrating an implementation of a data transmission method for a microcontroller according to one embodiment of this application. Detailed Implementation

[0067] The present application will be further described in detail below with reference to the accompanying drawings.

[0068] In one embodiment, this application discloses a data transmission method for a microcontroller, which communicates with a cloud server via a 4G communication module. The data transmission method for a microcontroller includes:

[0069] S10. Check the communication connection status of the 4G communication module; the communication connection status refers to the connectivity between the microcontroller and the 4G communication module, as well as between the module itself and the mobile communication network.

[0070] S20. If the communication connection status is normal, a dialing command is sent to the 4G communication module. The dialing command includes at least the Access Point Name (APN) parameter, which instructs the 4G communication module to access the target network channel to initiate a point-to-point protocol dialing request. The dialing command is a set of commands used by the microcontroller to control the 4G communication module to enter data transmission mode. The APN parameter it includes refers to the identification information used to identify and access a specific data channel allocated by the operator. This parameter affects the module's final data access route selection. The target network channel represents the cellular network channel for data transmission that the 4G communication module will access. The establishment of this channel depends on the APN and the operator's network resource allocation.

[0071] S30. When the 4G communication module switches to point-to-point protocol data mode based on the received dialing command, a point-to-point protocol session is constructed based on the LwIP protocol stack. In this mode, the 4G communication module automatically suspends the AT command parsing mechanism and continuously monitors for abnormal scenarios. If an abnormal scenario is detected, an escape sequence is sent to the 4G communication module to control it to exit the point-to-point protocol data mode and resume the AT command parsing mechanism. Point-to-point protocol data mode refers to the communication module switching from AT command control mode to a mode that only transmits raw PPP data packets. In this mode, the module pauses AT command parsing and focuses on establishing and maintaining the data link. The LwIP protocol stack is a lightweight embedded TCP / IP protocol stack, typically running in resource-constrained microcontroller environments, used to handle data communication tasks above the IP layer. A point-to-point protocol session refers to the logical connection process established between the microcontroller and the communication module based on the PPP protocol. This session requires link negotiation, authentication, and IP configuration. The AT command parsing mechanism is a command parsing system used by 4G communication modules in their default state to receive and parse microcontroller control commands. In data mode, this mechanism typically needs to be paused to avoid interfering with data transmission. Abnormal scenarios refer to abnormal states during communication, such as connection interruption, negotiation failure, or module freezing. These states need to be monitored in real time to ensure system stability. An escape sequence is a specific character sequence. When the microcontroller sends this sequence to the communication module, it can trigger the module to exit the current data mode and return to the command interaction mode, thereby restoring or restarting communication.

[0072] S40. Based on the point-to-point protocol session, perform negotiation operations. Negotiation operations refer to the process of bidirectionally agreeing on link structure, access permissions, and network configuration during a PPP session using methods such as link control protocols, authentication protocols, and network control protocols. A point-to-point data link refers to a stable communication path formed after successful negotiation, which allows the microcontroller to perform bidirectional data transmission with the cloud server via the standard IP protocol.

[0073] S50. If the negotiation operation is successful, the point-to-point protocol session is established as a point-to-point data link, and data communication with the cloud server is conducted based on the point-to-point data link. The cloud server is a remote data center device deployed in the Internet or a private network. It is typically used to receive data reports from edge devices (such as microcontroller terminals) and can return corresponding control commands or perform data analysis and storage operations.

[0074] Specifically, the microcontroller connects to a 4G communication module (such as the Quectel EC20 or EG91 series) via USB Host to achieve data communication with the cloud server. The microcontroller runs an embedded real-time operating system (e.g., FreeRTOS), which provides scheduling support for multiple tasks including network management, USB management, data acquisition and reporting, serial communication, and remote upgrades. The USB management task initializes and enumerates the connected 4G communication modules, identifies the module type, and establishes a virtual serial communication channel through the USB CDC / ACM driver. The microcontroller sends AT commands to the 4G communication module through this channel to perform a dialing operation. The dialing command includes an Access Point Name (APN) parameter, instructing the 4G communication module to access the specified cellular data channel and enter point-to-point protocol data mode. After successful PPP dialing, the 4G communication module switches from the default AT command parsing state to point-to-point protocol data mode. At this time, the microcontroller constructs a PPP session through the LwIP protocol stack, calls the pppos_create interface to establish a connection, and inputs the data packets received from the USB CDC port to the pppos_input interface for processing. To ensure real-time data transmission, the system triggers the pppos_poll function via interrupts or timer polling to keep the point-to-point data link active.

[0075] During the negotiation phase of the point-to-point data link, the system first completes LCP negotiation to establish a reliable frame structure; then it performs AUTH authentication, supporting PAP or CHAP protocols to verify the legitimacy of the access identity; next, it performs IPCP negotiation, automatically allocating and obtaining valid network layer parameters such as IP address parameters and DNS address parameters from the operator's network side corresponding to the target network channel. If the IPCP process is not completed within the set time during the negotiation, the system will control the sending of the escape sequence "+++" to the 4G communication module, thereby causing the 4G communication module to exit the point-to-point protocol data mode and restore the AT command parsing mechanism, so as to perform redial or restart the 4G communication module process. After obtaining the network layer communication parameters, the LwIP protocol stack establishes IP layer communication capabilities, and the system can then perform higher-level data communication tasks through the point-to-point data link.

[0076] In this embodiment, the upper-layer protocols include MQTT, HTTP, and Modbus. The system uses a lightweight MQTT client library such as Paho Embedded C to connect to the cloud server via TCP / IP for remote data reporting and command issuance. Simultaneously, the system supports the Modbus RTU protocol for acquiring operational data from industrial equipment via serial port, and also supports the Modbus TCP protocol for directly reading data from or controlling remote devices via LwIP. To improve system reliability, the device supports OTA remote upgrade functionality. While ensuring uninterrupted service, a dual-partition design enables firmware breakpoint resumption and redundant backup, effectively improving the security and success rate of the upgrade process.

[0077] In one embodiment, step S10, namely the step of checking the communication connection status of the 4G communication module, includes:

[0078] S101. When the 4G communication module is powered on, check whether it is synchronized with the 4G communication module. If it is not synchronized, perform the corresponding synchronization operation. Serial port (UART) communication is an asynchronous communication method without a dedicated clock signal line. Therefore, both parties must agree on the baud rate before communication. Otherwise, the bit sequence sent by one party will not be correctly parsed into bytes by the other party. Therefore, synchronization is required. However, for modules using USB CDC interface, such as EC20 and EG91, baud rate synchronization is not required in USB interface communication because USB CDC is a simulated serial port but uses a packet transmission mechanism in hardware and does not depend on the baud rate of traditional serial ports.

[0079] S102. If synchronization is maintained, determine whether the SIM card in the 4G communication module is in normal status. If the SIM card is in abnormal status, exit the point-to-point protocol dialing process.

[0080] S103. If the SIM card is in normal condition, check the network registration status of the 4G communication module.

[0081] S104. If the network registration status of the 4G communication module is registered, then the communication connection status is determined to be normal.

[0082] Specifically, after the 4G communication module completes its power-on initialization, the main control microcontroller first sends a synchronization command to the 4G communication module via a preset serial port baud rate to confirm whether it has maintained synchronization. If synchronization is not maintained, it tries different baud rate combinations until a valid response is received from the module, thus completing the synchronization establishment. After maintaining synchronization, the system sends a SIM card status verification command to the 4G communication module, such as AT+CPIN?, to determine whether the SIM card in the 4G communication module is in normal status. If no SIM card insertion or ready status information is detected within the set response waiting time threshold (e.g., 20 seconds), it is considered that the SIM card status is abnormal, and the control system exits the current point-to-point protocol dialing process and performs a module restart operation; if the SIM card status is normal, it continues to check the network registration status of the 4G communication module.

[0083] In one embodiment, step S103, namely the step of checking the network registration status of the 4G communication module, includes:

[0084] S1031. Send a first verification command to the 4G communication module. The first verification command is used to verify whether the 4G communication module has completed the registration of the call network.

[0085] S1032. Receive the first return value sent by the 4G communication module in real time. The first return value is used to determine that the 4G communication module has completed the registration of the call network. If the first return value is not received within the first preset time threshold, control the 4G communication module to perform a restart operation.

[0086] S1033. If the first return value of the 4G communication module is received, a second verification instruction is sent to the 4G communication module. The second verification instruction is used to verify whether the 4G communication module has completed the registration of the Internet access network.

[0087] S1034. Receive the second return value sent by the 4G communication module in real time. The second return value is used to determine that the 4G communication module has completed the registration of the Internet. If the second return value is not received within the second preset time threshold, control the 4G communication module to perform a restart operation.

[0088] Specifically, the first verification command refers to the control command actively sent by the microcontroller to the 4G communication module to detect whether it has successfully accessed the cellular communication network (i.e., the calling network). In practice, this command is usually a standard AT command, such as AT+CREG?, and its function is to query whether the module has completed base station registration to have the ability to make calls or receive SMS messages. The first return value refers to the status value returned by the 4G communication module in response to the first verification command. Its content indicates whether access to the calling network has been successful. For example, the number "1" or "5" in the return value represents a registered status, and the main control system uses this to determine whether to allow proceeding to the next step. The first preset time threshold refers to the maximum waiting time set by the microcontroller after sending the first verification command. If a valid first return value is not received within this time, it usually indicates that the module cannot register with the network normally. The system then controls the module to restart to clear the fault state and reinitialize. The second verification command refers to the control command sent by the microcontroller after confirming successful network registration to check whether the 4G communication module has successfully registered with the packet-switched network (i.e., the internet network). This command is often AT+CGREG? in implementation and is used to determine whether data communication capability is available. The second return value is the response of the 4G communication module to the second verification command. The returned registration status value represents whether the connection to the PS network has been successfully completed, also marked by "1" or "5" for normal registration. The second preset time threshold refers to the maximum waiting time set by the system after sending the second verification command. If the second return value is not obtained within the timeout period, the network is also considered abnormal, and the system will automatically control the module to restart and restart the entire communication connection process.

[0089] In one embodiment, step S40, namely the step of performing a negotiation operation based on a point-to-point protocol session, specifically includes:

[0090] The negotiation operation includes the link control negotiation operation, which is used to negotiate the frame structure parameters in the point-to-point data link based on the link control protocol.

[0091] Specifically, after the point-to-point protocol session is established, the microcontroller calls the `pppos_create` interface in the LwIP protocol stack to initialize the PPP session and continuously receives link negotiation frame data from the 4G communication module through the `pppos_input` function. The negotiation operation first performs link control negotiation, which involves bidirectional negotiation of frame structure parameters of the point-to-point data link using the link control protocol, including parameters such as maximum receiver unit size, whether to enable protocol compression, and asynchronous control character mapping. This negotiation is conducted by sending and responding to LCP configuration requests (`Configure-Request`) and acknowledgment frames (`Configure-Ack`), ensuring that the data link layer configuration between the main control microcontroller and the 4G communication module remains consistent, thus laying the foundation for subsequent authentication and network parameter negotiation.

[0092] In one embodiment, step S40, namely the step of performing a negotiation operation based on a point-to-point protocol session, specifically includes:

[0093] The negotiation operation includes an identity authentication negotiation operation, which is used to authenticate the access identity when accessing the target network channel based on an identity authentication protocol. The identity authentication protocol can be a password authentication protocol or a challenge handshake authentication protocol.

[0094] Specifically, after completing link control negotiation, the microcontroller continues with authentication negotiation via the LwIP protocol stack. This operation verifies the microcontroller's access identity when accessing the target network channel based on an authentication protocol. The authentication protocol can be either a password authentication protocol or a challenge-and-handshake authentication protocol. The former authenticates directly using a username and password combination, while the latter involves the server sending a random challenge code, and the microcontroller calculating a response value based on a preset password to complete the authentication process. The authentication process begins with the 4G communication module sending an authentication request frame. The microcontroller responds based on the configured access credentials and waits for authentication confirmation. If authentication is successful, the system continues into the network layer negotiation process to ensure a legitimate access identity before the data communication channel is established.

[0095] In one embodiment, step S40, namely the step of performing a negotiation operation based on a point-to-point protocol session, specifically includes:

[0096] The negotiation operation includes network parameter negotiation, which is used to obtain and verify network layer communication parameters based on the network control protocol. The network layer communication parameters are allocated through the operator's network-side equipment corresponding to the target network channel.

[0097] Specifically, after completing the identity authentication negotiation operation, the microcontroller continues to perform a network parameter negotiation operation. This network parameter negotiation operation is based on the Network Control Protocol (NCP), specifically the IP Control Protocol. Through this process, the microcontroller initiates a NCP negotiation request to the 4G communication module to obtain network layer communication parameters, including IP address, subnet mask, gateway address, and DNS server address. These network layer communication parameters are dynamically allocated to the currently established point-to-point protocol session by the operator's network-side equipment corresponding to the target network channel. The microcontroller receives the NCP negotiation response through the pppos module in the LwIP protocol stack and verifies the validity of the network layer communication parameters allocated in the point-to-point protocol session. If the allocated parameters are complete and valid, the network layer initialization of the point-to-point protocol session is completed, providing stable network support for subsequent data communication with the cloud server based on the point-to-point data link.

[0098] In one embodiment, step S40, namely the step of acquiring and verifying network layer communication parameters, includes:

[0099] S401. Obtain network layer communication parameters, which include at least IP address parameters and DNS address parameters;

[0100] S402. Verify that the IP address parameters and DNS address parameters are valid;

[0101] S403. Verify that the number of DNS address parameters is consistent with the number required for a point-to-point dial-up request;

[0102] S404. Real-time determination of whether the network parameter negotiation operation exceeds the preset negotiation time threshold. If the network parameter negotiation operation does not exceed the preset negotiation time threshold, the network parameter negotiation operation is determined to be successful. If the network parameter negotiation operation exceeds the preset negotiation time threshold, the point-to-point data link is closed or the 4G communication module is restarted.

[0103] Specifically, the network control protocol is the Internet Protocol Control Protocol (IPC). The network layer communication parameters include IP address parameters and DNS address parameters, which are dynamically allocated by the network-side equipment of the operator corresponding to the target network channel. After receiving the network layer communication parameters from the 4G communication module, the microcontroller verifies the validity of the IP address parameters and the matching of the number of DNS address parameters. If the IP address parameters do not conform to the format specification, or the number of DNS address parameters is inconsistent with the number of requests preset by the microcontroller, the network parameter negotiation is deemed to have failed. If the network parameter negotiation is not completed within the set negotiation time limit, for example, if the acquisition of network layer communication parameters is not completed within 90 seconds, the microcontroller controls the 4G communication module to actively terminate the current point-to-point protocol session and regenerate dialing instructions to initiate a new point-to-point protocol dialing request, thereby ensuring that the new network parameter negotiation operation can be successfully completed, providing effective support for subsequent data communication with the cloud server.

[0104] In one embodiment, step S30, the step of real-time detection of whether an abnormal scenario is in progress, includes:

[0105] S301. Construct a discrimination matrix that includes multiple communication state dimensions, wherein the communication state dimensions include at least the response state of the point-to-point protocol session and the number of negotiation rounds of the link control protocol, as well as the SIM card status and network registration status response time in the 4G communication module.

[0106] S302. Scoring is performed according to the preset scoring rules corresponding to each of the communication status dimensions, generating corresponding scoring dimension values, and the scoring dimension values ​​are added together to generate corresponding communication anomaly scoring values.

[0107] S303. Dynamically set a communication anomaly tolerance threshold. When the communication anomaly score exceeds the communication anomaly tolerance threshold, it is determined that an abnormal scenario has been detected. The communication anomaly tolerance threshold is calculated by weighted average of the network registration response time, negotiation failure frequency, and number of retransmissions during the historical dialing process recorded by the 4G communication module.

[0108] Specifically, to automatically identify whether the 4G communication module is in an abnormal state during operation, the system constructs an anomaly detection mechanism based on multi-dimensional communication status indicators. First, a multi-dimensional discrimination matrix is ​​designed to capture key communication status parameters. Each dimension of this matrix corresponds to an important indicator reflecting the stability of the communication process. For example, the response status of the Point-to-Point Protocol (PPP) session phase indicates whether the data link initialization has received effective feedback; the number of Link Control Protocol (LCP) negotiation rounds characterizes the number of retries during link establishment; the SIM card status reflects whether the communication module has valid identity access credentials; and the response time of the network registration status measures the time consumed for the module to establish a communication connection with the operator's core network.

[0109] Subsequently, the system configures corresponding scoring criteria for each of the above dimensions. For example, if a PPP session does not respond within a preset time, that dimension is recorded as high-risk and given a higher score; if LCP requires multiple renegotiations to complete, the score is accumulated according to the number of negotiation rounds; and if the SIM card status is invalid or abnormal, it is directly included in the highest risk value. In addition, network registration response time is also set with multiple scoring levels based on latency ranges to meticulously reflect connection quality.

[0110] All scores will be uniformly quantified and accumulated to form a communication anomaly score. To dynamically adapt to network environment fluctuations, the system uses a weighted average algorithm to set a communication anomaly tolerance threshold. This threshold is calculated based on key data indicators recorded during each dialing process of the 4G communication module, including the average network registration delay, the number of negotiation failures, and the number of retransmission attempts after connection loss. Finally, when the current score exceeds this dynamic threshold, the current communication process can be determined to be in an abnormal state, and the system will trigger an escape mechanism or other recovery operations to ensure the stability and reliability of the communication link.

[0111] In one embodiment, step S404, namely, the step of shutting down the point-to-point data link or restarting the 4G communication module if the network parameter negotiation operation exceeds a preset negotiation time threshold, includes:

[0112] S4041. If the network parameter negotiation operation exceeds the preset negotiation time threshold, a disconnection data frame is sent to the 4G communication module, and the current number of disconnection data frames sent is recorded. A disconnection data frame is a data frame used to indicate the termination of the current point-to-point protocol session. This data frame is sent by the microcontroller to the 4G communication module, aiming to proactively close the current point-to-point data link in the event of negotiation failure or an anomaly, thereby releasing communication resources and preparing for the next redial process. The current number of transmissions refers to the cumulative number of times the microcontroller has sent disconnection data frames to the 4G communication module. This value is updated after each disconnection data frame is sent to determine whether a retry is needed or the module should be restarted directly.

[0113] S4042. Detect whether a broken link data frame is received within a preset response time threshold. If a broken link data frame is received, close the point-to-point data link. The preset response time threshold refers to the longest time allowed by the system to wait for a response from the 4G communication module, starting from the time the broken link data frame is sent. If no response is received after this time, it is considered a communication timeout. Closing the point-to-point data link means that when the microcontroller detects that the broken link condition is met, it actively calls the protocol stack interface to release the point-to-point protocol session resources, so that the current communication state returns to the initial waiting dialing state, and re-establishes the dialing environment for the next communication.

[0114] S4043. If no returned disconnected data frame is received, determine if the current transmission count exceeds a preset transmission count threshold. If it does not exceed the preset transmission count threshold, resend the disconnected data frame to the 4G communication module. If it exceeds the preset transmission count threshold, restart the 4G communication module. The preset transmission count threshold refers to the maximum number of times the system is allowed to attempt to send disconnected data frames. If this threshold is reached or exceeded, the current communication is considered abnormal and cannot be recovered by disconnected data frames, requiring more forceful measures such as restarting the module.

[0115] Specifically, when the microcontroller establishes a point-to-point protocol session via the 4G communication module, if a link anomaly or negotiation failure is detected, it can control the 4G communication module to exit the point-to-point protocol data mode by sending an escape sequence, restore the AT command parsing mechanism, thereby terminating the current dialing process and re-acquiring module status information. The escape sequence is a data control command composed of specific characters (e.g., +++), used to switch to AT command mode when the 4G communication module is in point-to-point protocol data mode.

[0116] In another scenario, when a point-to-point protocol session has been successfully negotiated and a point-to-point data link has been established, and the microcontroller needs to actively release communication resources, the microcontroller can send a PPP session termination request frame to the 4G communication module via the LwIP protocol stack, i.e., the TerminateRequest frame in the standard PPP protocol. If a TerminateAck frame is received within a preset time, the link is considered to have been released normally, and the communication process ends; otherwise, if no response is received, the microcontroller can choose to retransmit or use an escape sequence mechanism to force a disconnection.

[0117] In one embodiment, after step S10, i.e., the step of performing the negotiation operation based on the point-to-point protocol session, the method further includes:

[0118] S41. If the negotiation operation fails, the dynamically updated access point name sequence is invoked to determine the optimal access point name parameters.

[0119] S42. Based on the optimal access point name parameter and the network environment identifier parameter associated with the optimal access point name parameter, as well as the communication anomaly score, generate a new dialing command.

[0120] In one embodiment, step S10, namely the method for establishing the access point name sequence, includes the following steps:

[0121] S01. Multiple access point name parameters are preset. Access credential information and dialing operation parameters are configured for each access point name parameter. Access credential information is used to determine whether the corresponding access point name parameter has been successfully authenticated. Dialing operation parameters include a retry threshold and a runtime threshold. Each access point name parameter typically contains an access point identifier provided by the operator, such as "cmnet" or "uninet," which determines which network channel the module will use to initiate data communication subsequently. Access credential information is authentication information that accompanies the access point name parameter and is used to determine whether the network corresponding to that parameter can successfully complete the authentication process. This credential information may include a username, password, and identification code. Dialing operation parameters refer to a set of parameters used to control dialing behavior, including restrictions on retrying failures and time management strategies. The retry threshold limits the maximum number of dialing attempts for a single access point, and the runtime threshold represents the maximum allowed time from the start of dialing to the establishment of a connection.

[0122] S02. Assign an initial priority value to each access point name parameter. The initial priority value is set based on the access channel type, network level, and user configuration rules. The initial priority value is the priority level that the system presets for the access point name parameter when there is no historical data. It is set according to the access channel type (such as public network / private network), network level (such as 4G / 5G), or user configuration rules (such as preferences or fees).

[0123] S03. Obtain historical usage data for each access point name parameter. Historical usage data includes the connection success rate, dialing response time, and frequency of abnormal interruptions of the access point name parameter in each point-to-point protocol dialing process. Historical usage data refers to the operation records generated by each access point name parameter in the past, including the proportion of successful connections for that parameter, the average time required to establish a connection, and the number of abnormalities such as connection interruptions during communication.

[0124] S04. Based on the preset scoring model and historical usage data, dynamically update the access point name parameters according to their priority to generate a sequence of access point names arranged by priority. The scoring model refers to the process of transforming historical usage data into a scoring criterion that can be used for comparison and ranking based on pre-set rules and weights, thereby dynamically updating the priority of each access point name parameter. The access point name sequence is a set composed of all access point name parameters arranged in order of their current priority, used for selecting backup strategies in case of dialing failure or abnormality.

[0125] Specifically, the system pre-sets three access point name parameters: "apn_a", "apn_b", and "apn_c", each configured with a username and password, a maximum of 3 retries, and a maximum dialing time of 30 seconds. Initially, "apn_a" was given the highest priority due to its high-speed public network channel. However, in actual operation, "apn_a" failed to connect three out of the last five attempts and had long response times, while "apn_b" had a high success rate and stable connections. Therefore, the system re-evaluated based on the scoring model, increasing the priority of "apn_b" and adjusting the access point name sequence to "apn_b", "apn_a", and "apn_c". Subsequent dialing failures will prioritize attempting a connection using the "apn_b" parameter.

[0126] More specifically, in step S02, the process of assigning an initial priority value to each access point name parameter includes: the system pre-setting a priority evaluation rule table, which lists priority scoring factors corresponding to various access channel types, network levels, and user-defined rules. Access channel types include public network access, private network access, and virtual private network access, corresponding to base scores of 30, 50, and 70 respectively; network levels include 2G, 3G, 4G, and 5G, corresponding to base scores of 10, 30, 50, and 80 respectively; user-defined rules include user-defined preferences (such as prioritizing a certain operator), connection cost weighting (such as prioritizing those with lower data charges), etc. The system converts user rules into bonus or deduction items, with each bonus item weighted at 5-20 points. When configuring each access point name parameter, the system reads its access channel type, supported network level, and whether it matches a user-defined rule, and assigns scores to each factor according to the aforementioned rule table. Finally, the weighted sum of these three factors is used as the initial priority value for that access point name parameter.

[0127] More specifically, step S04, which involves constructing and using a preset scoring model, includes: The system has a built-in scoring model used to calculate the current dynamic priority value of each access point name parameter based on its historical usage data. This scoring model includes a connection success rate scoring module, a dial-up response time scoring module, and an abnormal interruption frequency scoring module. The connection success rate scoring module divides the number of successful connections for each access point name parameter in the most recent N dial-up attempts by the total number of dial-ups to obtain the success rate, which is then mapped proportionally to a score range of 0-40. For example, a success rate greater than or equal to 90% is assigned a score of 40, and a success rate less than 60% is assigned a score of 20. The dial-up response time scoring module records the average system response time in the most recent N dial-ups; shorter response times result in higher scores. For example, a response time less than 3 seconds scores 30, and a response time greater than 10 seconds scores 10. The abnormal interruption frequency scoring module records the number of non-user-initiated interruptions occurring per unit time; fewer interruptions result in higher scores. For example, no interruptions for 3 consecutive days scores 30, and more than 3 interruptions score 10.

[0128] After scoring the three modules mentioned above, the system performs a comprehensive evaluation using a weighted ratio of connection success rate: dial-up response time: abnormal interruption frequency = 4:3:3. The system uses the comprehensive score as the current dynamic priority value for the access point name parameter, with higher dynamic priority values ​​ranking higher. When updating the access point name sequence, the system calls this scoring model to calculate the comprehensive score for each access point and sorts them from highest to lowest, thus forming a priority-ordered access point name sequence that can be used in the dial-up retry process.

[0129] In one embodiment, step S42, namely the step of generating a new dialing instruction based on the optimal access point name parameter, the network environment identifier parameter associated with the optimal access point name parameter, and the communication anomaly score, includes:

[0130] S421. Call the constructed dialing instruction template pool, which includes multiple preset dialing instruction templates configured for different access scenarios;

[0131] S422. Obtain the network environment identification parameter associated with the optimal access point name parameter, wherein the network environment identification parameter includes at least the SIM card operator identifier, the base station identifier, and the historical average signal strength.

[0132] S423. Input the network environment identification parameters and communication anomaly score into the policy matching engine to match the dialing instruction template most suitable for the current scenario;

[0133] S424. Generate a new dialing command based on the matched dialing command template and the optimal access point name parameter.

[0134] Specifically, the dialing command template pool consists of multiple preset templates, each corresponding to a specific communication access scenario. These templates are stored in a storage unit according to a predefined format and contain complete dialing parameter configuration content, such as dialing type, access point name, authentication method, maximum allowed dialing retries, dialing time limit, whether to enable automatic reconnection mechanism after disconnection, and DNS configuration method. Each template also includes a scenario label to indicate the type of network environment it is applicable to, such as mobile network, weak signal environment, or high packet loss rate environment.

[0135] During communication, when the system determines that there is an anomaly in the current communication or detects a negotiation failure, the access point management module first selects an optimal access point name parameter. This parameter is selected based on the usage performance of each access point in the communication module's historical dialing records, taking into account indicators such as the number of successful connections, dialing response time, and disconnection frequency.

[0136] Subsequently, the system activates the environment awareness module to collect network environment identification parameters for the current communication scenario. These parameters include, but are not limited to: the operator information of the SIM card used by the communication module, which is determined by reading user identification data to identify the type of operator currently being accessed; the base station number information, which reflects the current wireless communication area; and the average signal quality level corresponding to the base station, which is obtained by continuously collecting and calculating the average value over a period of time by the communication module.

[0137] The aforementioned network environment identification parameters, along with the current communication anomaly score, are transmitted to the policy matching module. The policy matching module uses an embedded rule lookup table and a weighted scoring model to filter multiple templates in the dialing command template pool. First, it performs preliminary filtering using scenario tags and network environment identification parameters, eliminating templates that are clearly unsuitable for the current network conditions. Next, it calculates the priority based on the usage conditions corresponding to each template and the current score, selecting the most suitable dialing template.

[0138] After selecting a template, the system merges its parameters with the currently selected optimal access point name parameters to generate a new dialing command. This dialing command contains all the parameter configurations required by the communication module to perform the dialing operation, ensuring that it can adaptively dial based on the current network characteristics and system status. The generated dialing command will be sent to the communication module, which will then initiate a new point-to-point dialing process based on it.

[0139] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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. Such 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 this application, and should all be included within the protection scope of this application.

Claims

1. A data transmission method for a microcontroller, characterized in that, The data transmission method of the microcontroller, which communicates with the cloud server via a 4G communication module, includes: Check the communication connection status of the 4G communication module; If the communication connection status is normal, a dialing command is sent to the 4G communication module. The dialing command includes at least the access point name parameter, which is used to instruct the 4G communication module to access the target network channel to initiate a point-to-point protocol dialing request. When the 4G communication module switches to the point-to-point protocol data mode based on the received dialing command, a point-to-point protocol session is constructed based on the LwIP protocol stack. In the point-to-point protocol data mode, the 4G communication module automatically suspends the AT command parsing mechanism and detects in real time whether it is in an abnormal scenario. If it is in an abnormal scenario, an escape sequence is sent to the 4G communication module to control the 4G communication module to exit the point-to-point protocol data mode and then restore the AT command parsing mechanism. Based on the aforementioned peer-to-peer protocol session, perform a negotiation operation; If the negotiation operation is successful, the point-to-point protocol session is identified as a point-to-point data link, and data communication with the cloud server is carried out based on the point-to-point data link. The step of real-time detection of whether an abnormal scenario is occurring includes: Construct a discrimination matrix that includes multiple communication state dimensions, wherein the communication state dimensions include at least the response state of the point-to-point protocol session and the number of negotiation rounds of the link control protocol, as well as the SIM card status and network registration status response time in the 4G communication module; Scoring is performed according to the preset scoring rules corresponding to each of the communication status dimensions, generating corresponding scoring dimension values, and the scoring dimension values ​​are added together to generate corresponding communication anomaly scoring values. A communication anomaly tolerance threshold is dynamically set. When the communication anomaly score exceeds the communication anomaly tolerance threshold, it is determined that an abnormal scenario has been detected. The communication anomaly tolerance threshold is calculated by weighted average of the network registration response time, negotiation failure frequency, and number of disconnection retransmissions recorded by the 4G communication module during historical dialing. After the step of performing the negotiation operation based on the peer-to-peer protocol session, the method further includes: If the negotiation operation fails, the dynamically updated access point name sequence is invoked to determine the optimal access point name parameters. Based on the optimal access point name parameter, the network environment identifier parameter associated with the optimal access point name parameter, and the communication anomaly score, a new dialing command is generated.

2. The data transmission method for a microcontroller according to claim 1, characterized in that, The steps for performing the negotiation operation based on the peer-to-peer protocol session specifically include: The negotiation operation includes at least link control negotiation operation, identity authentication negotiation operation and network parameter negotiation operation; The link control negotiation operation is used to negotiate the frame structure parameters in the point-to-point data link based on the link control protocol; The identity authentication negotiation operation is used to authenticate the access identity when accessing the target network channel based on an identity authentication protocol, wherein the identity authentication protocol is a password authentication protocol or a challenge handshake authentication protocol. The network parameter negotiation operation is used to obtain and verify network layer communication parameters based on the network control protocol. The network layer communication parameters are allocated through the operator network-side equipment corresponding to the target network channel.

3. The data transmission method for a microcontroller according to claim 1, characterized in that, The method for establishing the access point name sequence includes the following steps: Multiple access point name parameters are preset, and access credential information and dialing operation parameters are configured for each access point name parameter. The access credential information is used to determine whether the corresponding access point name parameter is successfully authenticated. An initial priority value is assigned to each of the access point name parameters, and the initial priority value is set based on the access channel type, network level, and user-defined rules; Obtain historical usage data for each access point name parameter, wherein the historical usage data is the connection success rate, dialing response time and abnormal interruption frequency of the access point name parameter in each point-to-point protocol dialing process. Based on a preset scoring model, the access point name parameters are dynamically updated with priority according to the historical usage data to generate a sequence of access point names arranged by priority.

4. The data transmission method for a microcontroller according to claim 1, characterized in that, The step of generating a new dialing command based on the optimal access point name parameter, the network environment identifier parameter associated with the optimal access point name parameter, and the communication anomaly score includes: Call the constructed dialing instruction template pool, which includes multiple preset dialing instruction templates configured for different access scenarios; Obtain the network environment identification parameter associated with the optimal access point name parameter, wherein the network environment identification parameter includes at least the SIM card operator identifier, the base station identifier, and the historical average signal strength; The network environment identification parameters and communication anomaly score are input into the policy matching engine to match the dialing instruction template most suitable for the current scenario; A new dialing command is generated based on the matched dialing command template and the optimal access point name parameter.

5. The data transmission method for a microcontroller according to claim 2, characterized in that, The step of acquiring and verifying network layer communication parameters includes: Obtain network layer communication parameters, which include at least IP address parameters and DNS address parameters; Verify that the IP address parameter and the DNS address parameter are valid; Verify that the number of DNS address parameters is consistent with the required number of peer-to-peer dialing requests; The system continuously monitors whether the network parameter negotiation operation exceeds a preset negotiation time threshold. If the network parameter negotiation operation does not exceed the preset negotiation time threshold, the network parameter negotiation operation is determined to be successful. If the network parameter negotiation operation exceeds the preset negotiation time threshold, the point-to-point data link is closed or the 4G communication module is restarted.

6. The data transmission method for a microcontroller according to claim 5, characterized in that, The step of shutting down the point-to-point data link or restarting the 4G communication module if the network parameter negotiation operation exceeds a preset negotiation time threshold includes: If the network parameter negotiation operation exceeds a preset negotiation time threshold, a disconnection data frame is sent to the 4G communication module and the current number of times the disconnection data frame is sent is recorded. Detect whether the returned disconnected data frame is received within a preset response time threshold. If the returned disconnected data frame is received, close the point-to-point data link. If the disconnected data frame is not received, it is determined whether the current number of transmissions is greater than a preset transmission threshold. If it is not greater than the preset transmission threshold, the disconnected data frame is retransmitted to the 4G communication module. If it is greater than the preset transmission threshold, the 4G communication module is restarted.

7. The data transmission method for a microcontroller according to claim 1, characterized in that, The step of verifying the communication connection status of the 4G communication module includes: When the 4G communication module is powered on, check whether it is synchronized with the 4G communication module. If it is not synchronized, perform the corresponding synchronization operation. If synchronization is maintained, it is determined whether the SIM card in the 4G communication module is in normal status. If the SIM card is in abnormal status, the point-to-point protocol dialing process is exited. If the SIM card is in normal condition, then check the network registration status of the 4G communication module; If the network registration status of the 4G communication module is "registered", then the communication connection status is determined to be normal.

8. The data transmission method for a microcontroller according to claim 7, characterized in that, The step of verifying the network registration status of the 4G communication module includes: Send a first verification command to the 4G communication module. The first verification command is used to verify whether the 4G communication module has completed the registration of the call network. The system receives a first return value sent by the 4G communication module in real time. The first return value is used to determine that the 4G communication module has completed the registration of the call network. If the first return value is not received within a first preset time threshold, the system controls the 4G communication module to perform a restart operation. If the first return value of the 4G communication module is received, a second verification instruction is sent to the 4G communication module. The second verification instruction is used to verify whether the Internet access network of the 4G communication module has been registered. The system receives a second return value sent by the 4G communication module in real time. The second return value is used to determine that the 4G communication module has completed its Internet registration. If the second return value is not received within a second preset time threshold, the system controls the 4G communication module to perform a restart operation.

Citation Information

Patent Citations

  • Method and system for remotely maintaining STM32 equipment based on LwIP protocol stack

    CN113347044A

  • Method for supporting PPP dialing, PPP dialing method and terminal equipment

    CN114584569A