A low-power Bluetooth communication method and system for embedded devices
Through the fast adaptive algorithm to adjust Bluetooth transmission power and communication parameters, the problems of instability and individual differences in communication in low-power mode are solved, and efficient communication in different environments and production processes are achieved.
Patent Information
- Application Number
- CN202411583336.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-07
AI Technical Summary
The existing Bluetooth communication technology is difficult to ensure the stability of communication in low-power mode, and the individual differences in equipment in different environments and production processes lead to different communication quality, affecting the normal operation and reliability of the equipment.
The Bluetooth transmission power is adjusted using a fast adaptive algorithm, and the transmission parameters are adaptively adjusted through calculation formulas, including power adjustment coefficient, emission rate and retransmission interval time, to adapt to changes in different environments and equipment.
It realizes the stability of communication in low-power mode, adapts to the differences in different environments and production processes, improves the normal operation and reliability of the equipment, and achieves fast and efficient communication in the on-site test.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Bluetooth communication, and in particular to a low-power Bluetooth communication method and system for embedded devices. Background Art
[0002] Wireless communication devices, embedded systems and low-power communication technologies are important components of modern science and technology. Wireless communication devices exchange information through wireless signals and are widely used in mobile phones, computers, IoT devices, etc. An embedded system is a computer system that combines dedicated hardware and software, and is usually used to control, monitor or assist in the operation of various devices. Low-power communication technology is a communication technology developed to meet the long-term endurance requirements of battery-powered devices, among which Bluetooth technology is a typical low-power wireless communication technology.
[0003] The inventor of this case previously applied for an embedded device log viewing and parameter management system with application number 202211651192.3. In this case, a radio frequency module was used for data interaction. However, technical shortcomings of radio frequency technology were found in actual applications. Because when maintaining equipment on-site, if 433 radio frequency is used, an RF tooling with USB is required, which is inserted into the computer via USB, and transferred to the mobile phone via USB to the HUB. If the mobile phone interface is different, other converters are required, which is inconvenient to carry and easy to forget. At the same time, the products of the previous case are mainly used in different overseas countries, such as Indonesia, Thailand, Malaysia, etc., and different mobile phones and computers will be used. There will be compatibility issues with the USB RF tooling, which will make it impossible to configure parameters on-site.
[0004] Therefore, this case made further improvements and chose Bluetooth as the communication method. The advantage is that both mobile phones and PCs have built-in Bluetooth modules and can communicate directly; they are not easy to damage and are easy to use. However, during the test, it was found that if Bluetooth technology is used, the following four problems will occur in this product:
[0005] (1) Environment: When the device is hung on the line, it may be affected by electromagnetic interference, power line noise, metal obstacles, interference from other wireless devices in the environment, weather and environmental factors, signal transmission distance and other issues. These interferences may cause Bluetooth communication instability, signal attenuation, data transmission errors or connection interruptions, affecting the normal operation and reliability of the device. In addition, Bluetooth is usually subject to greater interference in the crowded 2.4 GHz frequency band than in 433 MHz.
[0006] (2) Low power consumption: Existing Bluetooth communication technology may not be able to guarantee communication stability in low power consumption mode, which is an important issue for battery-powered devices.
[0007] (3) Production: Due to differences in equipment manufacturing processes and materials during the production process, individual problems may arise in Bluetooth communication quality, resulting in different communication qualities for different devices. The conventional solution is for technicians to configure vague parameters to adjust communication quality before shipment.
[0008] (4) Test site: On the equipment line, there are mobile devices and fixed devices on the other end of the communication. The mobile device moves under the pole, the signal will change constantly, and the bit error rate will increase. If you want to increase the signal value, you must increase the transmission power. In this way, fixed transmission power will lead to excessive power consumption. In fact, the mobile end is only used when modifying parameters and querying information. Most of the time it is connected to the fixed end device. Due to the need for low power consumption, the default transmission power is at a low level, resulting in the inability of mobile APP configuration parameters and other functions to work properly. Personnel need to move constantly to adjust the best signal and then configure parameters. Summary of the invention
[0009] In view of this, the purpose of the present invention is to propose a low-power Bluetooth communication method and system for an embedded device, which can quickly adapt the algorithm to adjust the transmission power to solve at least one technical problem mentioned in the background technology.
[0010] According to one aspect of the present invention, a low-power Bluetooth communication method for an embedded device is provided, the method being based on a first Bluetooth communication device that is fixedly set, a second Bluetooth communication device that communicates at a fixed position relative to the first Bluetooth communication device, and a third Bluetooth communication device that communicates at a dynamic displacement relative to the second Bluetooth communication device;
[0011] The method comprises the following steps:
[0012] The second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and adaptively adjusts the transmission parameters based on the device type through the following calculation formula;
[0013]
[0014] In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula:
[0015]
[0016]
[0017]
[0018] in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment coefficients;
[0019] The transmission power of the second Bluetooth communication device is adjusted based on the Bluetooth transmission power.
[0020] Among the above technical solutions, in this study, we proposed a method to simplify complex mathematical models into linear regression or other basic models, aiming to reduce the consumption of computing and storage resources. Specifically, we adopted an incremental parameter update strategy that only retains the current parameter values without storing historical data. This method is particularly important for resource-constrained microcontroller systems because it can significantly reduce memory usage, thereby achieving more efficient data processing within a limited storage space. When new data arrives, only the current parameters α, β, and γ are incrementally updated. The learning rate η, as a control parameter, determines the model's ability to quickly adapt to new data, and its value can be configured according to different application environments. For example, in a mobile device environment that requires a fast response, the η value can be increased to speed up the adaptive process; while in a terminal device at a fixed location, the η value can be reduced to achieve more stable parameter adjustment.
[0021] Compared with the prior art, this patent has at least one of the following advantages:
[0022] 1. Environmental adaptability: When the device is hung on the line, it may encounter challenges such as electromagnetic interference, power line noise, metal obstacle interference, signal interference from other wireless devices, weather changes, and signal transmission distance. This method dynamically adjusts the transmission power through a fast adaptive algorithm to adapt to communication needs under different environmental conditions.
[0023] 2. Low power operation: Traditional Bluetooth communication technology may have difficulty ensuring communication stability in low power mode, which is a key issue for devices that rely on battery power. This method adjusts the transmission power through a fast algorithm to ensure communication stability while reducing power consumption.
[0024] 3. Production consistency: During the production process, due to differences in manufacturing processes and materials, the quality of Bluetooth communication may show individual differences. This method determines the optimal transmission power, transmission rate, and retransmission interval through production testing, and then further optimizes these parameters on the line to achieve the best communication effect.
[0025] 4. Field test efficiency: After the equipment is deployed on the line, it needs to communicate with mobile and fixed devices. Due to the mobility of mobile devices, the signal quality will change constantly, resulting in an increase in the bit error rate. If you want to increase the signal value, you must increase the transmit power, so a fixed transmit power will result in excessive power consumption. In fact, the mobile terminal is only used when modifying parameters and querying information. Most of the time it is connected to the fixed-end device. Due to the need for low power consumption, the default transmit power is at a low level, resulting in the inability of mobile APP configuration parameters and other functions to work properly. Personnel need to move constantly to adjust the configuration parameters after the best signal. This method switches the connection between the mobile and fixed-end devices, uses adaptive algorithms with different learning degrees to adjust the transmit power, and stores these parameters, thereby achieving fast and efficient communication between different device ends.
[0026] In some embodiments, when calculating the transmit power, the floating point number is converted into an integer for calculation.
[0027] In the above technical solution, a method for optimizing memory usage is adopted, that is, replacing the traditional floating-point data type with an integer data type. The motivation for this method is that floating-point numbers occupy a large memory space in the microcontroller system, while integers are relatively more compact. Through this data type conversion, the program's memory usage can be effectively reduced, thereby freeing up valuable storage resources for other computing tasks. We convert floating-point operations into equivalent integer operations through algorithm conversion, ensuring the calculation accuracy while significantly reducing memory consumption. This optimization strategy is particularly important for resource-constrained embedded systems because it allows the system to achieve more efficient memory management while maintaining computational efficiency. In addition, integer operations generally have higher computing speeds and lower energy consumption than floating-point operations, which further enhances system performance and battery life.
[0028] In some embodiments, the average signal value and the average bit error rate are calculated based on the following formula:
[0029]
[0030]
[0031] In the formula, represents a fixed window length, is the window length The first signal value, is the window length The first A bit error rate.
[0032] In the above technical solution, a sliding window is used to calculate the average value of the data; this method updates the mean value through a sliding window and only retains the data within the window to update the mean value, thereby significantly reducing memory usage. By using a sliding window, we can dynamically calculate the average value of the data without storing the entire data sequence. This method effectively utilizes the strategy of trading time for space, that is, reducing memory usage by increasing the frequency of calculations. This is particularly important for microcontroller systems with limited memory resources, especially when the memory RAM is only 64KB, but there are many functions involved, and memory optimization needs to be maintained at all times.
[0033] In some embodiments, the adaptively adjusting the transmission parameters further comprises adjusting the transmission rate;
[0034]
[0035] In the formula, is the emission rate, is the maximum emission rate, is the bit error rate influencing factor, is the transmission power impact factor;
[0036] Among them, the bit error rate impact factor and the transmission power impact factor are calculated by the following formula:
[0037]
[0038]
[0039] In the formula, is the average bit error rate, is the maximum bit error rate, is the current transmit power, is the maximum transmit power.
[0040] In the above technical solution, in the application scenario at the test site, the device is deployed on the line to exchange data with the mobile device and the fixed device of the communication counterpart. As the mobile device moves under the pole, its signal quality will change continuously, resulting in an increase in the bit error rate. The traditional solution is to enhance the signal by increasing the transmission power, but this will lead to a significant increase in power consumption, especially in the case of fixed transmission power, which will consume more energy unnecessarily. Given that the device is connected to the fixed-end device most of the time, and a higher transmission power is mainly required for parameter modification and information query, this study proposes a transmission power adjustment method based on an adaptive algorithm. This method switches the connection between the mobile and fixed-end devices, adjusts the transmission power according to the parameter data of the two end types and the different learning degrees, and stores these parameters to achieve fast and efficient communication between different device ends.
[0041] In some embodiments, the adaptively adjusting the transmission parameters further comprises adjusting the retransmission interval;
[0042]
[0043] In the formula, is the retransmission interval, is the basic retransmission interval, is the comprehensive adjustment value;
[0044] Among them, the comprehensive adjustment value is calculated as follows:
[0045]
[0046] In the formula, is the bit error rate adjustment value, Adjust the value for the number of retransmissions. is the adjustment value of the sum of the time differences between the two Bluetooth communication devices. The clip(x, max) function ensures that The absolute value does not exceed Absolute value.
[0047] The bit error rate adjustment value, the retransmission number adjustment value, and the transmission and reception time difference adjustment value are obtained by the following formula:
[0048]
[0049]
[0050]
[0051] In the formula, is the bit error rate of the current round, is the minimum bit error rate, is the maximum bit error rate, is the number of repetitions of the current round, is the minimum number of retransmissions, is the maximum number of retransmissions, is the sum of the time difference between the two Bluetooth communication devices in the current round of sending and receiving. is the minimum value of the sum of the time differences between the two Bluetooth communication devices. It is the maximum value of the sum of the time differences between sending and receiving two Bluetooth communication devices.
[0052] In the above technical solution, in the field of wireless communications, the reliability of data transmission is affected by many factors, including signal interference, insufficient signal strength, and loss of data packets. In order to improve the success rate of data transmission, this case reduces the occurrence of communication failures by adjusting the data retransmission interval. Specifically, by dynamically adjusting the retransmission interval, the time interval can provide enough time to wait for the improvement of channel conditions, but not too long to affect the overall data transmission efficiency. At the same time, the data transmission process is adaptively optimized under different channel conditions, so as to ensure communication reliability while taking into account transmission efficiency.
[0053] In some embodiments, the second Bluetooth communication device receives a Bluetooth connection request, and determines the device type according to the protocol header, further comprising a first detection step, specifically:
[0054] Determine whether the receiving device type is correct. If not, end the detection and disconnect Bluetooth; otherwise,
[0055] Determine whether the message header is standard. If not, end the detection and disconnect Bluetooth. Otherwise,
[0056] Determine whether the number of verification failures reaches a threshold, if so, end the detection and disconnect Bluetooth; otherwise, repeat the first detection step.
[0057] In the above technical solution, it is aimed to optimize the energy consumption of the device and improve the communication efficiency. Specifically, under this detection process, when a non-associated device attempts to connect, the system identifies the device type and automatically disconnects the Bluetooth connection, thereby avoiding abnormal devices from occupying the Bluetooth channel for a long time, resulting in unnecessary energy waste. By dynamically managing Bluetooth connections, it is ensured that only legitimate and necessary device connections are maintained. In this way, the energy consumption of the device can be effectively reduced, especially on resource-constrained devices such as microcontrollers, whose memory RAM is only 64KB, and memory optimization is required between multiple functions.
[0058] In some embodiments, the second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and further includes a second detection step, specifically:
[0059] If the first Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed:
[0060] Determine whether there is data interaction within the specified time. If not, end the detection and disconnect Bluetooth; otherwise,
[0061] Determine whether the detection time reaches the threshold. If not, repeat the second detection step. Otherwise,
[0062] Determine whether the number of interactions reaches the threshold. If not, repeat the second detection step. Otherwise,
[0063] Perform subsequent adaptive adjustment steps, end the detection after the adjustment is completed, and disconnect Bluetooth.
[0064] In the above technical scheme, it is aimed to optimize energy consumption and improve communication efficiency. Specifically, when the Bluetooth connection is established, the system will monitor the data interaction within the specified time window. If the number of data interactions within this time window reaches the preset threshold, the system will automatically calculate and adjust the transmission power, transmission rate and retransmission interval to achieve the best communication performance. By dynamically adjusting the communication parameters to adapt to the actual data interaction needs. In this way, it is possible to reduce unnecessary energy consumption while ensuring the quality of communication. Specifically, when no data interaction is detected within the specified time window, the system will automatically end the detection process and disconnect the Bluetooth connection. This mechanism effectively avoids long-term Bluetooth detection and connection, thereby reducing the waste of power consumption caused by long-term occupation of the Bluetooth channel.
[0065] In some embodiments, the second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and further includes a third detection step, specifically:
[0066] If the third Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed:
[0067] Determine whether there is data interaction within the specified time. If not, end the detection and disconnect Bluetooth; otherwise,
[0068] Determine whether the timing is turned on for detection. If not, repeat the third detection step; otherwise,
[0069] Determine whether the detection time reaches the threshold. If not, repeat the third detection step; otherwise,
[0070] Determine whether the number of interactions reaches the threshold. If not, repeat the third detection step; otherwise,
[0071] Perform a subsequent adaptive adjustment step, and after the adjustment is completed, repeat the third detection step starting from determining whether the timing is turned on.
[0072] In the above technical solution, the best balance between energy efficiency and communication performance is achieved. Specifically, after connecting to Bluetooth, the detection is started, and the detection cycle is started regularly. The system will monitor the frequency of data interaction within the specified time. If the number of data interactions meets the preset threshold value, the system will automatically perform a series of calculations to optimize the transmission power, transmission rate and retransmission interval to ensure that the communication parameters are optimally configured. This process is continuously carried out under the control of the timer to dynamically adjust the communication parameters to meet the actual needs of on-site maintenance. Since the location of on-site maintenance personnel will change continuously, the system has designed a timed detection mechanism to allow short-term continuous detection without affecting the overall average power consumption. This design takes into account the connection time limit of mobile devices and is mainly aimed at specific usage scenarios during on-site maintenance. In addition, if no data interaction is detected within the specified time window, the system will automatically terminate the detection process and disconnect the Bluetooth connection. This mechanism effectively avoids invalid detection due to long-term lack of data interaction, thereby reducing unnecessary energy consumption and optimizing the energy management of the device.
[0073] According to another aspect of the present invention, a low-power Bluetooth communication system for an embedded device is provided, based on the above method; comprising:
[0074] An analysis module, configured to determine the device type through the protocol header when the second Bluetooth communication device receives the Bluetooth connection request, and adaptively adjust the transmission parameters through the following calculation formula based on the device type;
[0075]
[0076] In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula:
[0077]
[0078]
[0079]
[0080] in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment factor;
[0081] The adjustment module is used to adjust the transmission power of the second Bluetooth communication device based on the Bluetooth transmission power.
[0082] In the above technical scheme, in order to better use the above method, the present application proposes a low-power Bluetooth communication system for embedded devices, and each module corresponds to each step of the above method. The specific principles have been described above and will not be repeated here.
[0083] According to another aspect of the present invention, a computer-readable storage medium is provided, storing a computer program, wherein the computer program implements the above method when executed by a processor.
[0084] In the above technical solution, in order to better run and use the method, the above method is stored in a computer-readable storage medium, and the above method is implemented by a processor. It should be noted that the principle and effect of each step have been described above and will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0086] Figure 1 It is a communication schematic diagram of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0087] Figure 2 It is a flow chart of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0088] Figure 3 It is a schematic diagram of a framework of an embodiment of a low-power Bluetooth communication method for an embedded device according to the present invention;
[0089] Figure 4 This is a schematic flow chart of the first detection step of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0090] Figure 5 It is a schematic flow chart of the second detection step of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0091] Figure 6 This is a schematic flow chart of the third detection step of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0092] Figure 7 It is a schematic diagram of adjustment logic of an embodiment of a low-power Bluetooth communication method for an embedded device of the present invention;
[0093] Figure 8 It is a structural schematic diagram of an embodiment of a low-power Bluetooth communication system for embedded devices of the present invention. DETAILED DESCRIPTION
[0094] The present invention will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present invention, but are not intended to limit the scope of the present invention. Similarly, the following examples are only partial embodiments of the present invention rather than all embodiments, and all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present invention.
[0095] The present invention provides a low-power Bluetooth communication method and system for an embedded device, which can quickly adapt an algorithm to adjust the transmission power to solve at least one technical problem mentioned in the background technology.
[0096] Embodiment 1
[0097] A low-power Bluetooth communication method for an embedded device, the method being based on a first Bluetooth communication device that is fixedly arranged, a second Bluetooth communication device that communicates at a fixed position relative to the first Bluetooth communication device, and a third Bluetooth communication device that communicates at a dynamic displacement relative to the second Bluetooth communication device;
[0098] Given that this case is an improvement scheme based on a system for viewing and managing embedded device logs and parameters with application number 202211651192.3. Based on this, the first Bluetooth communication device in this case refers to the aggregation unit in this case, the second Bluetooth communication device refers to the collection unit in this case, and the third Bluetooth communication refers to the mobile terminal. Pay special attention to the above distinction. The collection unit is hung on the line, and the aggregation unit is hung on the line pole. For details, please refer to the above patent documents, so the position is basically fixed and the communication distance is also fixed. The mobile APP is used by people under the line, so the position is variable.
[0099] See also Figure 1The system is mainly composed of a collection unit and a collection unit. The collection unit stores data on the collection line, reads and writes collection unit parameters and historical records through the mobile terminal Bluetooth connection operation, and actively uploads data. The collection unit obtains the collection unit data through Bluetooth communication and sends it to the main station through the 2 / 3 / 4G network under GPRS. The collection unit Bluetooth uses low-power Bluetooth and a low-power sleep mode unique to the MCU. Receiving data can wake up the MCU to run at full speed, and wait for Bluetooth to be disconnected before entering sleep mode.
[0100] See also Figure 2 , the method comprises the following steps:
[0101] S1. The second Bluetooth communication device receives the Bluetooth connection request and determines the device type through the protocol header (the protocol header is mainly used to identify the product type and data source. The data sources include the aggregation unit, the collection unit, the mobile phone APP and the third-party device.), and adaptively adjusts the transmission parameters based on the device type through the following calculation formula;
[0102]
[0103] In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula:
[0104]
[0105]
[0106]
[0107] in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment coefficients;
[0108] S2. Adjust the transmission power of the second Bluetooth communication device based on the Bluetooth transmission power.
[0109] In this embodiment, the case simplifies the complex formula into a linear regression model or other simple models to reduce the computational and storage overhead. Furthermore, an incremental update method is adopted, that is, only the current parameter value is retained and historical data is not stored. This method only needs to save the current parameters α, β, γ, and perform incremental updates when new data arrives. η is the learning rate, which controls the step size of each parameter update and determines whether it is fast adaptive. This parameter is configurable and used in different environments. For example, if the mobile terminal needs fast adaptation, the η learning rate can be increased, and if the terminal is in a fixed position, it can be adjusted slowly.
[0110] Compared with the prior art, this patent has at least one of the following advantages:
[0111] 1. Environment: When the device is hung on the line, it may be affected by electromagnetic interference, power line noise, metal obstacles, interference from other wireless devices in the environment, weather and environmental factors, signal transmission distance, etc. When encountering different harsh environments, the fast adaptive algorithm adjusts the transmission power.
[0112] 2. Low power consumption: Existing Bluetooth communication technology may not guarantee stable communication in low power consumption mode, which is an important issue for battery-powered devices. Fast algorithms are used to adjust the transmission power while reducing power consumption and stabilizing the communication state.
[0113] 3. Production: Due to the differences in equipment manufacturing processes and materials during the production process, individual problems may occur in the quality of Bluetooth communication, resulting in different communication quality for different devices. The conventional solution is for technicians to configure vague parameters to adjust the communication quality before leaving the factory. The accurate transmission power, transmission rate and retransmission interval are determined through production testing, and then the efficiency of the parameters is further improved after hanging on the line to achieve the best communication effect.
[0114] 4. Hanging test site: The equipment is on the line, and there are mobile devices and fixed devices on the communication side. The mobile device moves under the pole, the signal will change constantly, and the bit error rate will increase. If you want to increase the signal value, you must increase the transmission power. In this way, fixed transmission power will lead to excessive power consumption. In fact, the mobile terminal is only used when modifying parameters and querying information. Most of the time it is connected to the fixed-end device. Due to the need for low power consumption, the default transmission power is at a low level, resulting in the inability of mobile APP configuration parameters and other functions to work properly. Personnel need to move constantly to adjust the configuration parameters after the best signal. Through the connection switching of mobile and fixed-end devices, the transmission power of the type parameter data at both ends is adjusted and stored in the adaptive algorithm with different learning degrees, so that fast and efficient communication can be achieved between different device ends.
[0115] In this embodiment, the sending and receiving time difference is calculated as follows:
[0116] Calculate the time difference between device A sending and device B receiving:
[0117]
[0118] Calculate the time difference between device B sending the ACK and device A receiving the ACK:
[0119]
[0120] Calculate the total send and receive time difference:
[0121]
[0122] In this embodiment, the bit error rate is calculated as follows:
[0123]
[0124] In the formula, is the number of bit errors and is the total number of transmitted bits.
[0125] In this embodiment, when calculating the transmit power, the floating point number is converted into an integer for calculation. Integers are used instead of floating point numbers to further reduce memory usage. The specific calculation formula is as follows:
[0126] To further reduce memory usage, floating point calculations can be converted to integers:
[0127]
[0128] Multiply A, B, and C by k to convert them into integers. , ,
[0129] It turns out that: ,
[0130] Floating point calculations are very resource intensive, so use integers for calculations and divide by reduction.
[0131] In this embodiment, the average signal value and the average bit error rate are calculated based on the following formula:
[0132]
[0133]
[0134] In the formula, represents a fixed window length, is the window length The first signal value, is the window length The first The average value is calculated using a sliding window. When the average value is updated by sliding the window, only the data within the window needs to be retained, thus reducing memory usage.
[0135] In this embodiment, the adaptive adjustment of the transmission parameters also includes adjusting the transmission rate; the transmission rate adjustment is based on the average bit error rate and the current transmit power .
[0136] Calculate the target sending rate:
[0137]
[0138] in, is the calculated sending rate, is the maximum sending amount, for example 1000 bytes / s, is the maximum transmit power, Maximum bit error rate.
[0139] Calculate the bit error rate influencing factor:
[0140]
[0141] This factor reflects the impact of the bit error rate on the transmission rate. When the bit error rate is low, the factor is close to 1, thus maintaining a higher transmission rate.
[0142] Calculate the transmit power impact factor:
[0143]
[0144] This factor reflects the effect of transmit power on the transmission rate. The higher the transmit power, the closer the factor is to 1, thereby increasing the transmission rate.
[0145] Calculate the final sending rate:
[0146]
[0147] Multiply the two factors together and then multiply by the maximum sending rate to get the final sending rate.
[0148] In this embodiment, the adaptive adjustment of the transmission parameters further includes adjusting the retransmission interval time;
[0149] The retransmission interval is adjusted based on the bit error rate (BER), the number of retransmissions, and the time difference between sending and receiving ( ). The retransmission interval ranges from [0.5, 2] seconds, and the amplitude is adjusted each time. For example, ±0.5 seconds, this value can be adjusted according to the factory setting of the device. The number of retransmissions.
[0150] Bit error rate adjustment:
[0151]
[0152] Adjust the number of retransmissions:
[0153]
[0154] Adjustment of sending and receiving time difference:
[0155]
[0156] Comprehensive adjustment value:
[0157]
[0158] The clip(x, max) function ensures that The absolute value does not exceed Absolute value.
[0159] Calculate the target retransmission interval:
[0160]
[0161] in, The basic retransmission interval (e.g. 1s)
[0162] See also Figure 3 Based on the above adaptive adjustment process, this case also sets different detection processes for different devices, specifically:
[0163] See also Figure 4 , the first detection step, specifically:
[0164] Determine whether the receiving device type is correct. If not, end the detection and disconnect Bluetooth. Otherwise, determine whether the message header is standardized. If not, end the detection and disconnect Bluetooth. Otherwise, determine whether the number of verification failures reaches the threshold. If so, end the detection and disconnect Bluetooth. Otherwise, repeat the first detection step. Under this detection process, after other unrelated devices are connected, the abnormal Bluetooth will be automatically disconnected by receiving the device type, avoiding the problem of power consumption and Bluetooth connection occupation caused by long connection of abnormal devices.
[0165] See also Figure 5 , the second detection step, specifically:
[0166] If the first Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed: determine whether there is data interaction within the specified time, if not, end the detection and disconnect Bluetooth; otherwise, determine whether the detection time reaches the threshold, if not, repeat the second detection step, otherwise, determine whether the number of interactions reaches the threshold, if not, repeat the second detection step, otherwise, perform subsequent adaptive adjustment steps, end the detection after the adjustment is completed, and disconnect Bluetooth. After connecting to Bluetooth, if there is data interaction within the specified time and the number of interactions reaches the threshold, the transmission power, transmission rate and retransmission interval are calculated to achieve the optimal value. If there is no data interaction within the specified time, end the detection and disconnect Bluetooth to avoid power consumption waste caused by long-term detection and long-term Bluetooth connection.
[0167] See also Figure 6 , the third detection step, specifically:
[0168] If the third Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed:
[0169] Determine whether there is data interaction within the specified time. If not, end the detection and disconnect Bluetooth; otherwise, determine whether the detection is turned on at the scheduled time. If not, repeat the third detection step; otherwise, determine whether the detection time reaches the threshold. If not, repeat the third detection step; otherwise, determine whether the number of interactions reaches the threshold. If not, repeat the third detection step; otherwise, perform the subsequent adaptive adjustment step. After the adjustment is completed, repeat the third detection step from determining whether the detection is turned on at the scheduled time. After connecting to Bluetooth, enter the detection, start the detection cycle at the scheduled time. If there is data interaction within the specified time and the number of interactions reaches the threshold, calculate the transmission power, transmission rate and retransmission interval to achieve the optimal value. Continuously calculate the optimal value under the timer. The mobile terminal connection time is limited. It is mainly used during on-site maintenance. Because personnel will move, the scheduled detection can be turned on. The short-term continuous detection does not affect the overall average power consumption. If there is no data interaction within the specified time, the detection is ended and Bluetooth is disconnected to avoid long-term detection and long-term Bluetooth connection. Waste of power consumption.
[0170] See also Figure 7 , all the adaptive adjustment and monitoring links of this embodiment are shown in the figure.
[0171] Transmitting power: Within a certain distance, the greater the power, the greater the power consumption and the greater the signal value. The power range is -40dBm to 4dBm, and the default is 0dBm.
[0172] Adaptive adjustment of the sending rate: Dynamic adjustment in the range of 100 bytes / second to 1000 bytes / second at each ±100 bytes / second. The higher the sending rate, the greater the packet loss rate and bit error rate.
[0173] Retransmission interval: 0.5s-2s range, dynamically adjusted by ±0.5s each time. The faster the retransmission interval, the greater the possibility of non-response, because the MCU low power mode responds and processes data requires time.
[0174] Average signal value: The signal value is also called signal strength (RSSI). At the same distance, the greater the power, the greater the signal. The RSSI value will gradually decrease with the increase of distance, the increase of obstacles or the increase of interference sources. The average signal value is calculated by averaging the received signals.
[0175] Bit error rate: The higher the bit error rate, the worse the communication quality. Reducing the sending rate can reduce the bit error rate, and increasing the number of retransmissions can ensure correct data transmission.
[0176] Retransmission times: The more retransmission times are received, the more time the MCU has to wait to process the data. You need to increase the retransmission interval to give the MCU enough processing time.
[0177] Signal quality: The quality of the signal is monitored in real time through sensors on embedded devices, including signal strength, signal-to-noise ratio, bit error rate and other parameters. Based on these parameters, the system can determine the quality of the current signal.
[0178] Transmit power: Higher transmit power helps reduce signal attenuation and interference during transmission, thereby reducing bit error rates and helping to maintain higher average signal values at longer distances. The greater the transmit power, the greater the signal's propagation distance and penetration ability, but it also increases the power consumption of the device.
[0179] Interaction data monitoring: By monitoring the interaction data between devices, the time difference between sending and receiving can be obtained. In the specific implementation, the timestamp technology is used to record the timestamp when the data is sent and received, so as to calculate the time difference between sending and receiving. The accurate measurement of the time difference between sending and receiving helps to more accurately calculate the retransmission interval and adjust the sending rate.
[0180] In order to reduce power consumption, it is necessary to lower the transmit power level threshold and maintain a stable transmit rate threshold. The transmit power, transmit rate and retransmission time interval thresholds should be as balanced as possible while ensuring low power consumption.
[0181] Special note: The factory test will adjust the transmission power, transmission rate and retransmission interval according to the above process, and further fine-tune the formula on site to achieve the best communication status.
[0182] Based on the above embodiments, compared with the prior art, the present invention has at least one of the following advantages:
[0183] 1. Environment: When the device is hung on the line, it may be affected by electromagnetic interference, power line noise, metal obstacles, interference from other wireless devices in the environment, weather and environmental factors, signal transmission distance, etc. When encountering different harsh environments, the fast adaptive algorithm adjusts the transmission power.
[0184] 2. Low power consumption: Existing Bluetooth communication technology may not guarantee stable communication in low power consumption mode, which is an important issue for battery-powered devices. Fast algorithms are used to adjust the transmission power while reducing power consumption and stabilizing the communication state.
[0185] 3. Production: Different manufacturing processes and materials of equipment during the production process will cause individual problems in Bluetooth communication quality, resulting in different communication quality of different devices. The conventional solution is that technicians configure vague parameters to adjust the communication quality before leaving the factory. The accurate transmission power, transmission rate and retransmission interval are determined through production testing, and then the efficiency of the parameters is further improved after hanging on the line to achieve the best communication effect.
[0186] 4. Hanging test site: The equipment is on the line, and there are mobile devices and fixed devices on the communication side. The mobile device moves under the pole, the signal will change constantly, and the bit error rate will increase. If you want to increase the signal value, you must increase the transmission power. In this way, fixed transmission power will lead to excessive power consumption. In fact, the mobile terminal is only used when modifying parameters and querying information. Most of the time it is connected to the fixed-end device. Due to the need for low power consumption, the default transmission power is at a low level, resulting in the inability of mobile APP configuration parameters and other functions to work properly. Personnel need to move constantly to adjust the configuration parameters after the best signal. Through the connection switching of mobile and fixed-end devices, the transmission power of the type parameter data at both ends is adjusted and stored in the adaptive algorithm with different learning degrees, so that fast and efficient communication can be achieved between different device ends.
[0187] Embodiment 2
[0188] See also Figure 8 , a low-power Bluetooth communication system for an embedded device, based on the method described in one of the embodiments; comprising:
[0189] An analysis module, configured to determine the device type through the protocol header when the second Bluetooth communication device receives the Bluetooth connection request, and adaptively adjust the transmission parameters through the following calculation formula based on the device type;
[0190]
[0191] In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula:
[0192]
[0193]
[0194]
[0195] in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment factor;
[0196] The adjustment module is used to adjust the transmission power of the second Bluetooth communication device based on the Bluetooth transmission power.
[0197] In the above technical scheme, in order to better use the method described in one of the embodiments, the present application proposes a low-power Bluetooth communication system for embedded devices, and each module corresponds to each step of the above method. The specific principles have been described above and will not be repeated here.
[0198] Embodiment 3
[0199] A computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0200] In the above technical solution, in order to better run and use the method described in one of the embodiments, the above method is stored in a computer-readable storage medium, and a processor is used to implement the method described in one of the embodiments. It should be noted that the principle and effect of each step have been described above and will not be described in detail here.
[0201] The above descriptions are only some embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any equivalent device or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A low-power Bluetooth communication method for an embedded device, the method being based on a first Bluetooth communication device that is fixedly arranged, a second Bluetooth communication device that communicates at a fixed position relative to the first Bluetooth communication device, and a third Bluetooth communication device that communicates at a dynamic displacement relative to the second Bluetooth communication device; It is characterized in that The method comprises the following steps: The second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and adaptively adjusts the transmission parameters based on the device type through the following calculation formula; In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula: in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment coefficients; The transmission power of the second Bluetooth communication device is adjusted based on the Bluetooth transmission power.
2. A low-power Bluetooth communication method for an embedded device as claimed in claim 1, characterized in that: When calculating the transmit power, the floating point number is converted into an integer for calculation.
3. A low-power Bluetooth communication method for embedded devices as claimed in claim 1, characterized in that: The average signal value and the average bit error rate are calculated based on the following formula: In the formula, represents a fixed window length, is the window length The first signal value, is the window length The first A bit error rate.
4. A low-power Bluetooth communication method for embedded devices as claimed in claim 1, characterized in that: The adaptively adjusting the transmission parameters also includes adjusting the transmission rate; In the formula, is the emission rate, is the maximum emission rate, is the bit error rate influencing factor, is the transmission power impact factor; Among them, the bit error rate impact factor and the transmission power impact factor are calculated by the following formula: In the formula, is the average bit error rate, is the maximum bit error rate, is the current transmit power, is the maximum transmit power.
5. A low-power Bluetooth communication method for embedded devices as claimed in claim 1, characterized in that: The adaptive adjustment of the transmission parameters also includes adjusting the retransmission interval time; In the formula, is the retransmission interval, is the basic retransmission interval, is the comprehensive adjustment value; Among them, the comprehensive adjustment value is calculated as follows: In the formula, is the bit error rate adjustment value, Adjust the value for the number of retransmissions. is the adjustment value of the sum of the time differences between the two Bluetooth communication devices. The clip(x, max) function ensures that The absolute value does not exceed Absolute value; The bit error rate adjustment value, the retransmission number adjustment value, and the transmission and reception time difference adjustment value are obtained by the following formula: In the formula, is the bit error rate of the current round, is the minimum bit error rate, is the maximum bit error rate, is the number of repetitions of the current round, is the minimum number of retransmissions, is the maximum number of retransmissions, is the sum of the time difference between the two Bluetooth communication devices in the current round of sending and receiving. is the minimum value of the sum of the time differences between the two Bluetooth communication devices. It is the maximum value of the sum of the time differences between sending and receiving two Bluetooth communication devices.
6. A low-power Bluetooth communication method for embedded devices as claimed in claim 1, characterized in that: The second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and further includes a first detection step, specifically: Determine whether the receiving device type is correct. If not, end the detection and disconnect Bluetooth; otherwise, Determine whether the message header is standard. If not, end the detection and disconnect Bluetooth. Otherwise, Determine whether the number of verification failures reaches a threshold, if so, end the detection and disconnect Bluetooth; otherwise, repeat the first detection step.
7. A low-power Bluetooth communication method for an embedded device as claimed in claim 1 or 6, characterized in that: The second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and further includes a second detection step, specifically: If the first Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed: Determine whether there is data interaction within the specified time. If not, end the detection and disconnect Bluetooth; otherwise, Determine whether the detection time reaches the threshold. If not, repeat the second detection step. Otherwise, Determine whether the number of interactions reaches the threshold. If not, repeat the second detection step. Otherwise, Perform subsequent adaptive adjustment steps, end the detection after the adjustment is completed, and disconnect Bluetooth.
8. A low-power Bluetooth communication method for an embedded device as claimed in claim 1 or 6, characterized in that: The second Bluetooth communication device receives the Bluetooth connection request, determines the device type through the protocol header, and further includes a third detection step, specifically: If the third Bluetooth communication device is connected to the second Bluetooth communication device, the following steps are performed: Determine whether there is data interaction within the specified time. If not, end the detection and disconnect Bluetooth; otherwise, Determine whether the timing is turned on for detection. If not, repeat the third detection step; otherwise, Determine whether the detection time reaches the threshold. If not, repeat the third detection step; otherwise, Determine whether the number of interactions reaches the threshold. If not, repeat the third detection step; otherwise, Perform a subsequent adaptive adjustment step, and after the adjustment is completed, repeat the third detection step starting from determining whether the timing is turned on.
9. A low-power Bluetooth communication system for embedded devices, characterized in that: The method according to any one of claims 1 to 8; comprising: An analysis module, configured to determine the device type through the protocol header when the second Bluetooth communication device receives the Bluetooth connection request, and adaptively adjust the transmission parameters through the following calculation formula based on the device type; In the formula, is the Bluetooth transmission power, is the average signal value, is the average bit error rate, , , are the power adjustment coefficients respectively; in each round of adaptive adjustment, , , Obtained by the following formula: in, is the adaptive learning rate; is the average signal value, is the average bit error rate; The subscript represents the power adjustment coefficient of the previous round, The subscripts indicate the updated power adjustment coefficients; The adjustment module is used to adjust the transmission power of the second Bluetooth communication device based on the Bluetooth transmission power.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
System for log viewing and parameter management of embedded device
CN116016618A
System and method for automatically adjusting performance parameters of low-power-consumption Bluetooth chip
CN110022243A
Bluetooth power control method, device and equipment
CN115278846A