A method, device, medium, and product for instruction interaction
By dynamically adjusting the power consumption strategy level and baud rate by collecting device status parameters, and sending AT commands in combination or separately, the problems of invalid wake-up and energy waste in IoT devices are solved, and the system power consumption is reduced.
Patent Information
- Application Number
- CN202611273248.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-17
AI Technical Summary
In existing IoT terminal devices, the wake-up and sleep strategies of MCU and communication modules lead to frequent invalid wake-ups, and static baud rate configuration results in energy waste and increased system power consumption.
Collect device operating status parameters, dynamically determine power consumption policy level, classify AT commands based on policy level and command semantic information, merge or send AT commands individually, adaptively adjust communication baud rate, and predict wake-up state to send AT commands.
Reduce the number of invalid module wake-ups, avoid invalid transmissions, and reduce system power consumption.
Smart Images

Figure CN123123833A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a method, device, medium and product for instruction interaction. Background Technology
[0002] In IoT terminal devices, MCUs (Microcontroller Units) typically interact with communication modules via AT (Attention Command) commands to complete data transmission and reception and status queries. In existing technologies, the wake-up and sleep modes of the communication module often employ fixed timing strategies or rely on external interrupts, resulting in frequent invalid wake-ups. Furthermore, the baud rate between the microcontroller and the communication module is often statically configured, leading to energy waste and increased system power consumption.
[0003] Therefore, how to reduce system power consumption is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a command interaction method, device, medium, and product that can reduce system power consumption. The specific solution is as follows: Firstly, this application provides an instruction interaction method applied to a microcontroller, comprising: Collect device operating status parameters and determine the current power consumption strategy level based on the device operating status parameters; Based on the current power consumption policy level and instruction semantic information, it is determined whether AT commands can be delayed in transmission. The communication baud rate between the communication module is determined based on the current power consumption strategy level. During the predicted wake-up state period of the communication module, the delayed AT command is sent to the communication module at the communication baud rate.
[0005] Optionally, sending the delayed AT command includes: Delayed AT commands that have no dependencies are merged into a batch packet and then sent. Delayed AT commands with dependencies are sent individually in the order of dependency.
[0006] Optionally, determining the AT commands that can be delayed based on the current power consumption policy level and command semantic information includes: Based on the current power consumption policy level and instruction semantic information, determine the AT commands that cannot be delayed and the AT commands that can be delayed. The method further includes: immediately sending the non-delayed AT command to the communication module at the communication baud rate.
[0007] Optionally, based on the current power consumption policy level and instruction semantic information, determine the non-delayable AT commands and the delayable AT commands, including: Priority labels for each AT command are generated based on the current power consumption policy level and command semantic information; The AT commands carrying the priority tags are divided into non-delayable AT commands and delayable AT commands, wherein both the non-delayable AT commands and the delayable AT commands are sent in the order of the priority tags.
[0008] Optionally, collect device operating status parameters, including: Collect one or more of the following parameters: battery status parameters, network quality parameters, service load parameters, and device temperature parameters; Accordingly, when collecting multiple parameters, the current power consumption strategy level is determined based on the device operating status parameters, including: The strategy value is obtained by weighting the weight coefficients and normalized parameter values of each parameter. The current power consumption strategy level is determined based on the strategy value.
[0009] Optionally, determining the communication baud rate with the communication module based on the current power consumption strategy level includes: When the current power consumption strategy level is power saving mode, the communication baud rate is determined to be the first baud rate; When the current power consumption strategy level is balanced mode, the communication baud rate is determined to be the second baud rate; When the current power consumption strategy level is high-performance mode, the communication baud rate is determined to be the third baud rate; Wherein, the first baud rate is lower than the second baud rate, and the second baud rate is lower than the third baud rate.
[0010] Optional, also includes: Obtain the target non-requested result code reported by the communication module; wherein, the target non-requested result code is a non-requested result code obtained by filtering out specific non-requested result codes, and the specific non-requested result code is a non-urgent non-requested result code when the communication module is in a dormant state.
[0011] Secondly, this application provides an instruction interaction device applied to a microcontroller, comprising: The strategy determination module is used to collect device operating status parameters and determine the current power consumption strategy level based on the device operating status parameters; The delayed instruction determination module is used to determine the AT instructions that can be delayed based on the current power consumption strategy level and instruction semantic information. A baud rate determination module is used to determine the communication baud rate with the communication module based on the current power consumption strategy level. The instruction sending module is used to send the delayed AT instruction to the communication module at the communication baud rate during the predicted wake-up state period of the communication module.
[0012] Thirdly, this application provides an electronic device, including a memory and a processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to implement the aforementioned instruction interaction method.
[0013] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned instruction interaction method.
[0014] Fifthly, this application provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the aforementioned instruction interaction method.
[0015] As can be seen from the above scheme, this application provides an instruction interaction method applied to a microcontroller, including: collecting device operating status parameters and determining the current power consumption policy level based on the device operating status parameters; determining a delayable AT instruction based on the current power consumption policy level and instruction semantic information; determining the communication baud rate between the microcontroller and the communication module based on the current power consumption policy level; and sending the delayable AT instruction to the communication module at the communication baud rate during the predicted wake-up state period of the communication module.
[0016] As can be seen, the beneficial effects of this application are as follows: by collecting device operating status parameters and dynamically determining the power consumption strategy level, and combining the power consumption strategy level and instruction semantic information to classify AT commands, AT commands that can be delayed are centrally scheduled to be sent uniformly during the predicted wake-up state period, reducing the number of times the module is individually woken up and avoiding invalid wake-ups caused by fixed periods. At the same time, the communication baud rate is adaptively determined based on the power consumption strategy level, avoiding resource waste caused by high baud rates in low-power demand scenarios. In this way, system power consumption can be reduced.
[0017] Correspondingly, the instruction interaction device, equipment, readable storage medium, and product provided in this application also have the above-mentioned technical effects. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0019] Figure 1 A flowchart of an instruction interaction method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of an instruction interaction device provided in an embodiment of this application; Figure 3 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] Existing technologies employ a fixed sleep strategy: module wake-up relies on timers or external events, failing to adapt to dynamic business needs; indiscriminate AT command merging: simple FIFO (First-In-First-Out) queues merge commands, ignoring dependencies and semantic differences between commands; static baud rate settings: transmission rates cannot adaptively adjust according to business priorities, leading to energy waste. These technologies suffer from issues such as invalid wake-up, redundant transmission, and high power consumption. To address these issues, this application provides a command interaction scheme that can reduce system power consumption.
[0022] See Figure 1 As shown in the figure, this application discloses an instruction interaction method applied to a microcontroller, including: Step S11: Collect device operating status parameters and determine the current power consumption strategy level based on the device operating status parameters.
[0023] Among them, equipment operating status parameters refer to parameters that reflect the current operating status of the equipment. The types of parameters can be determined based on the usage scenario, and may include equipment-level operating parameters and operating parameters of communication modules in the equipment.
[0024] In an optional embodiment, collecting device operating status parameters may include collecting one or more of the following parameters: battery status parameters, network quality parameters, service load parameters, and device temperature parameters. Correspondingly, when multiple parameters are collected, determining the current power consumption policy level based on the device operating status parameters includes: performing a weighted calculation based on the weight coefficients corresponding to each parameter and the normalized parameter values corresponding to each parameter to obtain a policy value; and determining the current power consumption policy level based on the policy value.
[0025] Among them, battery status parameters reflect the current power level and voltage status of the device; network quality parameters reflect the current network signal strength and connection stability of the communication module, and can be obtained through AT+CSQ (Channel Signal Quality) commands; service load parameters reflect the current data processing pressure of the device; and device temperature parameters reflect the current operating temperature of the device. When the temperature is too high, a degradation strategy may be triggered to protect the device. Normalized parameter values refer to the values after mapping the collected data to a standard range (such as [0,1]); weighting coefficients refer to the proportion of each parameter in the weighted calculation, which can be dynamically adjusted according to real-time changes in the parameters. For example, the basic weight of the battery status parameter is 0.4, and the weight increases by 0.3 when the voltage is below 3.5V; the basic weight of the network quality parameter is 0.3, and the weight decreases by 0.2 when the packet loss rate is greater than 20%; the basic weight of the service load parameter is 0.2, and the weight increases by 0.3 when a high load is predicted in the next 5 minutes; and the basic weight of the device temperature parameter is 0.1, and a degradation strategy is triggered when the temperature is above 45℃. The strategy value is obtained by multiplying the normalized parameter values of each parameter by their corresponding weight coefficients and then summing the results.
[0026] Furthermore, determining the current power consumption policy level based on the policy value can include: determining the current power consumption policy level according to the range in which the policy value falls. The power consumption policy level is a decision level used to guide subsequent instruction scheduling and transmission parameter selection. For example, a policy value in the range of 0 to 0.3 is determined to be energy-saving mode, in the range of 0.3 to 0.7 is determined to be balanced mode, and in the range of 0.7 to 1 is determined to be high-performance mode. Among them, energy-saving mode is suitable for scenarios where the battery level is below a threshold and there is no external power supply, with the goal of maximizing battery life; balanced mode is suitable for periodic data reporting scenarios where the device battery level meets preset sufficient conditions, with the goal of optimizing the balance between battery life and response speed; high-performance mode is suitable for high real-time business scenarios, with the goal of minimizing latency. If the device battery level is 5% and the voltage is below 3.5V, and the policy value falls in the range of 0 to 0.3 after weighted calculation, the current power consumption policy level is determined to be energy-saving mode.
[0027] In optional embodiments, a context-aware engine can be created to collect device operating status parameters, including but not limited to business scenario tags (urgent / normal), module status (AT+CPAS (Phone Activity Status) response), network metrics (AT+CSQ), system battery level, etc. This engine outputs a dynamic power consumption policy level (EXTREME_SAVING / HIGH_PERFORMANCE). The context-aware engine dynamically weights multiple parameters (such as the input parameters mentioned above) to determine the power consumption policy level. It can automatically adjust the weight coefficients according to the urgency level. For example, the base weight and dynamic adjustment rule for battery status are 0.4, with a weight increase of 0.3 when voltage < 3.5V; the base weight and dynamic adjustment rule for network quality are 0.3, with a weight decrease of 0.2 when packet loss rate > 20%; the base weight and dynamic adjustment rule for business load are 0.2, with a weight increase of 0.3 when high load is predicted for the next 5 minutes; and the base weight and dynamic adjustment rule for temperature are 0.1, triggering a degradation policy when temperature > 45℃. The decision formula can be: ; Among them, W i : The dynamically adjusted weights, p i : Normalized parameter value, ±0.05, random perturbation, to prevent policy oscillation, StrategyScore is the policy value. The normalization parameter value is calculated by transforming the original data to a standard interval (such as [0,1]), for example, using linear normalization: ; Among them, X i The parameter values to be normalized, This is the maximum value corresponding to this parameter. This is the minimum value corresponding to the parameter. Applicable scenario: When the data is evenly distributed (e.g., temperature 20℃~40℃, mapped to 0~1). Example: Battery voltage 3.3V~4.2V, normalized value of 3.6V = (3.6-3.3) / (4.2-3.3)≈0.33.
[0028] Understandably, the types of device operating status parameters can be adjusted according to the usage scenario. The power consumption strategy level can also be adjusted based on the weighted score, for example, with three power consumption strategy levels corresponding to 0-0.3, 0.3-0.7, and 0.7-1.
[0029] EXTREME_SAVING (Extreme Power Saving Mode, also known as the aforementioned power saving mode). Core objective: Maximize battery life, tolerate high latency and partial functional degradation, suitable for scenarios where the battery is about to run out or where the device is unattended for extended periods. Typical scenarios: Device battery level below 10% and no external power supply, device deployed in remote environments where battery replacement is difficult (e.g., agricultural sensors), background maintenance tasks (e.g., log uploads, non-critical configuration synchronization). Key behavioral characteristics: Extremely high tolerance for instruction latency: Allows non-critical instructions to be delayed by several minutes or even hours. Maximized batch processing window: Actively merges all delayable instructions, with window sizes reaching the minute level. For example, if the first instruction is delayed by 5 minutes and the second by 10 minutes, the window size is 10 minutes. Forced low baud rate: Negotiates the use of the lowest stable baud rate (e.g., 9600bps), significantly reducing the power consumption of the UART (Universal Asynchronous Receiver / Transmitter) interface. Predictive wake-up suppression: The module is only woken up when there is a CRITICAL (urgent) command or during a deterministic wake-up period (such as a network paging cycle). The module will definitely be woken up when the paging cycle arrives. URC (Unsolicited Result Code) handling degradation: Non-urgent asynchronous events (such as network status updates) are cached or discarded to avoid waking the MCU. Conservative error retries: Network errors are retried with long intervals (>60 seconds) and few times (≤2 times); command errors are reported directly.
[0030] BALANCED (Balanced Mode, Default Recommendation). Core Objective: Optimize the balance between battery life and response speed to meet the needs of most IoT scenarios and ensure the real-time performance of core functions. Typical Scenario: Devices with sufficient battery power (>30%) rely on periodic data reporting (e.g., smart meters) and require timely response to non-emergency events (e.g., device status anomaly alarms). This is the default mode for daily operation. Key Behavioral Characteristics: Tiered Delay Control: CRITICAL / HIGH (high priority) commands: sent immediately (millisecond delay); MEDIUM (medium priority) commands: allowed second-level delay (1-30 seconds); LOW (low priority) commands: minute-level delay or batch merging. Dynamic Batch Processing Window: Window size is dynamically adjusted based on queue load and module status prediction (seconds to minutes). Adaptive Baud Rate: Default medium-speed baud rate (e.g., 115200bps), switching to low speed only when a long idle period, i.e., sleep state, is predicted. Proactive Utilization of Module Wake-up Period: Proactively send cached commands before the module enters an idle state or during the network paging cycle. Selective URC processing: Emergency URCs (such as SMS and incoming calls) are processed in real time; non-emergency URCs are processed in small batches with a delay. Intelligent error retry: Network errors are retried exponentially (initially 2 seconds, maximum 5 times); command errors are retried 1-2 times immediately before an error is reported.
[0031] HIGH_PERFORMANCE (High-Performance Mode) has the core objective of maximizing real-time throughput, with power consumption optimization as a secondary objective. It is suitable for externally powered or high-bandwidth scenarios. Typical scenarios include: devices connected to external power sources (e.g., industrial gateways), FOTA (Firmware Over-The-Air) large-volume data transmissions, real-time control commands (e.g., emergency device shutdown), and scenarios requiring frequent retransmissions due to extremely poor network quality. Key behavioral characteristics include: Zero command latency: Commands are sent in real-time (except for LOW-level commands, which allow microsecond-level queuing). Minimal batch processing: Only strictly independent and similar commands are merged (e.g., continuous parameter settings). Maximum baud rate: The highest baud rate supported by the module is enforced (e.g., 921600bps). Suppress sleep: The module remains constantly awake; the UART controller remains active for extended periods. Real-time URC processing: All asynchronous events are reported and processed immediately. Aggressive error retry: Network errors are quickly retried (initially 200ms, maximum 10 times); command errors are retried immediately.
[0032] Step S12: Determine the AT command that can be delayed based on the current power consumption policy level and command semantic information.
[0033] The semantic information of the AT commands can include the business meaning, real-time attributes, and criticality of the commands, used to distinguish the urgency of the commands. Different AT commands correspond to different business operations, and the semantic information reflects the real-time requirements of that business operation. For example, the semantic information of alarm commands corresponds to high real-time requirements, while the semantic information of data reporting commands corresponds to low real-time requirements.
[0034] This application's embodiments can identify the dependencies between the various deferred AT commands. A dependency refers to an execution order constraint between commands; commands with dependencies have a strict execution order, and reversing the order will lead to execution failure. For example, commands that establish a data connection before sending data have a dependency relationship.
[0035] Furthermore, embodiments of this application can determine non-delayable AT commands and delayable AT commands based on the current power consumption policy level and command semantic information. Non-delayable AT commands refer to AT commands that need to be sent immediately, and may include service commands requiring real-time response, such as those related to security, alarms, and faults. Delayable AT commands refer to commands that can be sent later, such as periodic, non-urgent daily service operation commands.
[0036] In optional embodiments, priority tags for each AT command are generated based on the current power consumption policy level and command semantic information. Priority tags are markers used to identify the urgency of commands. In this embodiment, AT commands carrying the priority tags are divided into non-delayable AT commands and delayable AT commands. Both non-delayable and delayable AT commands are sent in the order of their priority tags. Furthermore, delayable AT commands without dependencies are merged into batch packets and sent; wherein merging into batch packets can be configured to merge some or all AI commands according to preset conditions, and unmerged commands are sent separately according to priority. Delayable AT commands with dependencies are sent separately in dependency order. It is understood that if a batch packet exists, the priority tag of the batch packet is determined so that the batch packet is sent according to the priority tag.
[0037] Non-delayable AT commands are sent immediately, while delayable AT commands can be sent during the predicted wake-up period of the communication module. Different power consumption strategy levels can pre-specify the corresponding non-delayable AT commands and / or delayable AT commands.
[0038] Step S13: Determine the communication baud rate between the communication module and the current power consumption strategy level.
[0039] The communication baud rate is the data transmission rate of the UART interface between the microcontroller and the communication module, measured in bps (bits per second). The baud rate directly affects the data transmission speed and interface power consumption; a higher baud rate results in faster transmission speed but higher power consumption, while a lower baud rate results in slower transmission speed but lower power consumption.
[0040] In an optional embodiment, determining the communication baud rate with the communication module based on the current power consumption policy level may include: determining the communication baud rate as a first baud rate when the current power consumption policy level is in energy-saving mode; determining the communication baud rate as a second baud rate when the current power consumption policy level is in balanced mode; and determining the communication baud rate as a third baud rate when the current power consumption policy level is in high-performance mode; wherein the first baud rate is lower than the second baud rate, and the second baud rate is lower than the third baud rate.
[0041] For example, the first baud rate could be 9600bps, the lowest stable baud rate, to significantly reduce UART interface power consumption; the second baud rate could be 115200bps, the default medium-speed baud rate, to balance transmission efficiency and power consumption; the third baud rate could be the highest stable baud rate supported by the module to meet the transmission requirements of high real-time services. If the current power consumption strategy level is energy-saving mode, the microcontroller will set the communication baud rate to 9600bps.
[0042] Step S14: Send the delayed transmission AT command to the communication module at the communication baud rate during the predicted wake-up state period of the communication module.
[0043] The predicted wake-up state period can be a period of time during which the communication module remains awake, predicted based on historical data. During the wake-up state period, the communication module needs to remain awake to handle services; during the sleep-available period, it can enter sleep mode to reduce power consumption. The network paging cycle is the mechanism by which the cellular communication network periodically sends paging messages to the terminal. When the paging cycle arrives, the communication module must wake up to listen for network messages; therefore, the period during which the paging cycle arrives belongs to the wake-up state period.
[0044] In this embodiment, non-dependent, deferred-transmission AT commands are merged into a batch packet and sent; dependent, deferred-transmission AT commands are sent individually in the order of dependency. A batch packet refers to combining multiple non-conflicting, deferred-transmission AT commands into a single data packet for one-time transmission, reducing the number of transmissions and UART interface activity time. Dependent, deferred-transmission AT commands are sent individually in the order of dependency to avoid command execution failure due to incorrect execution order.
[0045] Furthermore, in this embodiment, the non-delayed AT command is immediately sent to the communication module at the stated communication baud rate. The non-delayed AT command does not involve waiting for a predicted wake-up period; it is sent immediately by the microcontroller to wake up the communication module.
[0046] Furthermore, embodiments of this application may also: obtain the target non-requested result code reported by the communication module; wherein the target non-requested result code is a non-requested result code obtained by filtering out specific non-requested result codes, and the specific non-requested result code is a non-urgent non-requested result code when the communication module is in a dormant state.
[0047] In optional embodiments, an instruction semantic grader can be created to generate dynamic priority tags based on instruction criticality (CRITICAL / LOW), real-time timeliness (REALTIME / DEFERRABLE), and resource dependencies. For example, instructions at the CRITICAL level have higher priority than those at the LOW level. Based on the determined power consumption policy level, execution priorities are assigned to the ATs (including multiple sets of dependent ATs) that need to be executed. For example, under EXTREME_SAVING, only alarm instructions are critical, while other instructions are downgraded. Furthermore, an intelligent batch processing engine is created for predictive wake-up: triggering batch packet transmission based on a module state prediction model; and dependency-aware merging: resolving instruction dependencies through a directed acyclic graph (DAG) to ensure safe parallel execution of instructions within the batch packet. Further, an adaptive UART controller can be created, which dynamically negotiates the baud rate based on the current policy level (e.g., switching to 9600bps in EXTREME_SAVING mode). During instruction intervals, the UART controller is forced into a low-power mode (Clock Gating). Among them, under different power consumption strategy levels, instructions belonging to high priority and instructions belonging to low priority can be identified according to the application scenario.
[0048] This embodiment can determine idle times of the day based on historical usage data. During these times, the device or module can sleep to reduce power consumption and does not need to be woken up. However, if it is predicted that an important URC report will be submitted or a paging cycle will arrive at a certain time based on historical data, the module will be woken up (this is the wake-up state), and batch processing messages will be sent. The wake-up state means the communication module is in normal working condition, capable of receiving AT commands, processing services, and reporting URCs. The sleep state means the communication module is in a low-power state, with most circuits turned off, retaining only basic functions. The paging cycle is the periodic communication mechanism between the cellular network and the terminal device. The network sends paging messages to the device at fixed time intervals to check if the device is online.
[0049] Non-requested result codes are messages actively reported by the communication module to the microcontroller. Non-requested result codes include urgent non-requested result codes (such as SMS arrival, incoming call ringing) and non-urgent non-requested result codes (such as network status changes, signal strength updates). When the communication module is in sleep mode, the microcontroller discards the non-urgent non-requested result codes reported by the communication module and only accepts urgent non-requested result codes to avoid unnecessary non-requested result code reporting that could unnecessarily wake up the communication module.
[0050] In an optional embodiment, an asynchronous event optimizer can be created to enable a delayed processing mechanism for non-urgent URCs (such as +CGEV:ME PDNACT (Mobile Equipment PDN Activate, indicating successful activation of the terminal's PDN (Packet Data Network) network context)) to reduce the number of MCU wake-ups. Non-urgent URCs can be understood as proactively reported messages triggered for some reason, not requests for results from AT commands. For example, if the network changes, such as switching from 5G to 4G, a message will be proactively reported without needing to send AT commands to query it.
[0051] In this way, based on the operating status parameters of multiple devices and combined with different weight ratios, a dynamic power consumption strategy level is calculated. IoT (Internet of Things) devices predict the device wake-up time based on historical usage and send delayed instructions to avoid invalid wake-up, redundant transmission and high power consumption problems caused by lack of context awareness and prediction capabilities. Redundant transmission is unnecessary URC reporting.
[0052] Below is an example: Step 1: 5% battery level, EXTREME_SAVING strategy; Step 2: Command Classification: Alarm (CRITICAL) | Temperature / CSQ (LOW); Step 3: Queue scheduling: Alarm command, send immediately; Temperature + CSQ, dynamic batch processing (waiting for wake-up window); Step 4: UART control: Reduce baud rate to 9600bps; alarm sent successfully; prediction module wakes up and sends batch packet; UART forced to sleep; Step 5: Response Processing: Update signal strength to 15, update module status to deep sleep, and discard non-urgent URCs; this operation can be performed regardless of whether the data transmission in the previous step was successful (of course, a retransmission mechanism can be added to ensure the success rate). Discarding non-urgent URCs means that during the module's sleep period, unless it is a designated necessary URC, other URCs will not be reported.
[0053] Furthermore, feedback is sent to step 1, and the context update is complete.
[0054] Below is another example: Scenario description: The device needs to complete three tasks: Critical task: pH value exceeding the standard alarm (AT+CMGS="Alarm Center"); Normal task: Periodically report temperature data (AT+HTTPPOST=Temperature Data); Background task: Read module signal strength (AT+CSQ). The coordinated execution process is as follows: Step 1: Context-Aware Engine. Input: Battery level = 5%, triggering EXTREME_SAVING mode; poor network signal (AT+CSQ historical value = 15); module status prediction: just completed data transmission, about to enter deep sleep; output: policy level = EXTREME_SAVING; parameters: maximum command latency = 10 minutes, lower baud rate limit = 9600bps. Maximum command latency is the maximum command delay time. If the predicted wake-up time does not arrive within 10 minutes, the data is discarded.
[0055] Step 2: Command Classification and Tagging of Original Commands. Classification Results: AT+CMGS="Alarm Center", CRITICAL (Real-time = REALTIME); AT+HTTPPOST=Temperature Data, LOW (Real-time = DEFERRABLE); AT+CSQ, LOW (Real-time = BATCHABLE). Basis: Under EXTREME_SAVING, only alarm commands are classified as critical; others are downgraded.
[0056] Step 3: Instruction Queue and Scheduling. Decision Process: Upon detecting a CRITICAL instruction, immediately wake up the module (interrupt the current sleep); if two LOW instructions are detected simultaneously, dynamically batch process them (merge them into the same window); Dependency Resolution: If there are no conflicts, package them as AT+HTTPPOST=temperature data; AT+CSQ, output: prioritize sending alarm instructions, delay sending batch packets (waiting for the module to wake up the window).
[0057] Step 4: Adaptive UART Transmission Control. Execution sequence: Negotiate baud rate 9600bps (meets policy lower limit); Send high-priority command: AT+CMGS="Alarm Center" (sent separately); Detection module response: Alarm transmission successful module returns OK; Prediction module, enters wake-up state after 10 seconds, predicts based on historical data; When the wake-up window arrives, send batch packets: AT+HTTPPOST...; AT+CSQ; After transmission is complete, force the UART controller to sleep.
[0058] Step 5: Response Processing and Status Synchronization. Key Actions: Parse AT+CMGS response: +CMGS: 42 (SMS ID), alarm successful; Parse batch response: textCopy Code, +HTTPPOST: 0,200, temperature reporting successful, +CSQ: 15,0, signal strength updated. Update context engine: network signal = 15 (maintaining "poor"), module state = deep sleep (accurate prediction); discard non-urgent URCs: such as +CEREG: 1 (network registration event). Updating the context engine means the MCU records this data. Deep sleep can be understood as informing the MCU that the module's state needs to be refreshed, and it should enter sleep mode next.
[0059] In the field of Internet of Things (IoT) device communication technology, scenarios where wireless communication modules (such as cellular / NB-IoT (Narrow Band Internet of Things) / WiFi modules) are controlled via UART serial ports by sending AT commands, can achieve dynamic power consumption control through software layer optimization. This reduces the active time of the UART interface, which is the channel connecting the module to the MCU and includes wake-up and sleep states. By minimizing the number of module wake-ups while minimizing impact on business operations, power consumption can be reduced.
[0060] Further, see Figure 2 As shown, this application provides an instruction interaction device applied to a microcontroller, comprising: The strategy determination module 11 is used to collect device operating status parameters and determine the current power consumption strategy level based on the device operating status parameters; The delayed instruction determination module 12 is used to determine the AT instruction that can be delayed based on the current power consumption strategy level and instruction semantic information. Baud rate determination module 13 is used to determine the communication baud rate with the communication module based on the current power consumption strategy level; The instruction sending module 14 is used to send the delayed AT instruction to the communication module at the communication baud rate during the predicted wake-up state period of the communication module.
[0061] As can be seen, this embodiment of the application collects device operating status parameters and dynamically determines the power consumption strategy level. It then classifies AT commands based on the power consumption strategy level and command semantic information, centrally scheduling AT commands that can be delayed to be sent uniformly during the predicted wake-up period. This reduces the number of times modules are individually woken up and avoids invalid wake-ups caused by fixed periods. Simultaneously, it adaptively determines the communication baud rate based on the power consumption strategy level, avoiding resource waste caused by high baud rates in low-power demand scenarios. In this way, system power consumption can be reduced.
[0062] See Figure 3 As shown in the figure, this application discloses an electronic device 20, including a processor 21 and a memory 22; wherein, the memory 22 is used to store a computer program; the processor 21 is used to execute the computer program and the instruction interaction method disclosed in the foregoing embodiments.
[0063] For details regarding the specific process of the above-mentioned instruction interaction method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0064] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, and the storage method can be temporary storage or permanent storage.
[0065] In addition, the electronic device 20 also includes a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26; wherein, the power supply 23 is used to provide operating voltage for the various hardware devices on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0066] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the instruction interaction method disclosed in the foregoing embodiments.
[0067] For details regarding the specific process of the above-mentioned instruction interaction method, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0068] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0069] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0070] The above provides a detailed description of the instruction interaction method, device, medium, and product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A command interaction method, characterized in that, Applications in microcontrollers include: Collect device operating status parameters and determine the current power consumption strategy level based on the device operating status parameters; Based on the current power consumption policy level and instruction semantic information, it is determined whether AT commands can be delayed in being sent. The communication baud rate between the communication module is determined based on the current power consumption strategy level. During the predicted wake-up state period of the communication module, the delayed AT command is sent to the communication module at the communication baud rate.
2. The instruction interaction method according to claim 1, characterized in that, Sending the delayed AT command includes: Delayed AT commands that have no dependencies are merged into a batch packet and then sent. Delayed AT commands with dependencies are sent individually in the order of dependency.
3. The instruction interaction method according to claim 2, characterized in that, Based on the current power consumption policy level and instruction semantic information, the determination of AT commands that can be delayed includes: Based on the current power consumption policy level and instruction semantic information, determine the AT commands that cannot be delayed and the AT commands that can be delayed. The method further includes: immediately sending the non-delayed AT command to the communication module at the communication baud rate.
4. The instruction interaction method according to claim 3, characterized in that, Based on the current power consumption policy level and instruction semantic information, determine the non-delayable AT commands and the delayable AT commands, including: Priority labels for each AT command are generated based on the current power consumption policy level and command semantic information; The AT commands carrying the priority tags are divided into non-delayable AT commands and delayable AT commands, wherein both the non-delayable AT commands and the delayable AT commands are sent in the order of the priority tags.
5. The instruction interaction method according to claim 1, characterized in that, Collect equipment operating status parameters, including: Collect one or more of the following parameters: battery status parameters, network quality parameters, service load parameters, and device temperature parameters; Accordingly, when collecting multiple parameters, the current power consumption strategy level is determined based on the device operating status parameters, including: The strategy value is obtained by weighting the weight coefficients and normalized parameter values of each parameter. The current power consumption strategy level is determined based on the strategy value.
6. The instruction interaction method according to claim 1, characterized in that, Determining the communication baud rate between the communication module based on the current power consumption strategy level includes: When the current power consumption strategy level is power saving mode, the communication baud rate is determined to be the first baud rate; When the current power consumption strategy level is balanced mode, the communication baud rate is determined to be the second baud rate; When the current power consumption strategy level is high-performance mode, the communication baud rate is determined to be the third baud rate; Wherein, the first baud rate is lower than the second baud rate, and the second baud rate is lower than the third baud rate.
7. The instruction interaction method according to any one of claims 1 to 6, characterized in that, Also includes: Obtain the target non-requested result code reported by the communication module; wherein, the target non-requested result code is a non-requested result code obtained by filtering out specific non-requested result codes, and the specific non-requested result code is a non-urgent non-requested result code when the communication module is in a dormant state.
8. An electronic device, characterized in that, Includes memory and processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the instruction interaction method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the instruction interaction method as described in any one of claims 1 to 7.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the instruction interaction method as described in any one of claims 1 to 7.
