Method for repairing Bluetooth communication abnormity and electronic equipment
By acquiring and parsing Bluetooth communication files, combining Bluetooth standard specifications and pre-trained models to generate target protocol stack code, Bluetooth communication anomalies can be automatically repaired, solving the problems of complexity and manpower and material resource consumption in traditional methods and achieving efficient automated repair.
Patent Information
- Application Number
- CN202510587330.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-09-05
AI Technical Summary
The traditional Bluetooth communication anomaly troubleshooting and repair process is complex, consumes a lot of manpower and material resources, requires high professional knowledge of engineers, and the repair process is tedious.
By obtaining Bluetooth communication files, parsing the data and detecting abnormal information in combination with Bluetooth standard specifications, the pre-trained Bluetooth repair model is used to generate the target protocol stack code in an interpretive language, and the Bluetooth protocol stack code is automatically updated to repair the abnormality.
It realizes the automatic troubleshooting and repair of Bluetooth communication anomalies, reduces manual intervention, improves repair efficiency, avoids the steps of recompiling and burning firmware, and improves user experience.
Smart Images

Figure CN120602956A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Bluetooth, and in particular to a method and electronic device for repairing Bluetooth communication anomalies. Background Art
[0002] Troubleshooting and fixing Bluetooth communication issues has always been a technical challenge in the development and maintenance of modern electronic devices. The traditional Bluetooth troubleshooting process typically involves the following steps. First, the user manually captures the log files of the anomalous device and the Bluetooth btsnoop file (a file used to record Bluetooth communication data packets). These files record the raw data transmitted between the Bluetooth controller and the device. Next, using professional analysis tools such as Wireshark, Ellisys, or Frontline Bluetooth Analyzer, the data packets in the btsnoop file are visualized. Engineers then examine each anomalous data packet or process individually, analyzing and troubleshooting them in conjunction with the logs. Furthermore, they compare the data to the Bluetooth interaction specification to identify non-compliant behaviors or processes and ultimately determine the source of the problem. Finally, remediation is performed based on the issue, and the fixed firmware is updated to the device via over-the-air (OTA) or other methods.
[0003] However, this traditional process has numerous flaws and shortcomings. First, different systems capture log files and btsnoop files in different ways, increasing the complexity of user operations. Second, while existing analysis tools can visualize data packets, diagnosing specific issues still requires manual analysis by engineers, which requires a high level of Bluetooth protocol knowledge. Furthermore, after a fix, the firmware must be repackaged and updated via OTA, making the update process more cumbersome for devices already sold. These factors result in a significant labor-intensive and inefficient troubleshooting and repair process. Summary of the Invention
[0004] The present invention provides a method and electronic device for repairing Bluetooth communication anomalies, which can automatically troubleshoot and repair Bluetooth communication anomalies, reduce manpower and material resource consumption, and thus improve repair efficiency.
[0005] In one aspect of the present invention, a method for repairing Bluetooth communication anomalies is provided. The method comprises: obtaining a Bluetooth communication file of a device and parsing the Bluetooth communication file to obtain Bluetooth communication data; detecting anomaly information in the Bluetooth communication data according to Bluetooth standards; generating target protocol stack code based on an interpreted language using a pre-trained Bluetooth repair model based on the anomaly information; and updating the Bluetooth protocol stack code of the device according to the target protocol stack code.
[0006] In another aspect of the present invention, an electronic device is provided, comprising a memory configured to store a computer program and a processor configured to execute the computer program to perform the above-mentioned method for repairing Bluetooth communication anomalies.
[0007] According to the technical solution of the present invention, Bluetooth communication data is determined by acquiring and parsing Bluetooth communication files, which facilitates subsequent data analysis and processing, and the abnormal information that causes Bluetooth communication problems is determined in combination with Bluetooth standard specifications. Based on the abnormal information, a pre-trained Bluetooth repair model is used to generate a repaired protocol stack code based on an interpretive language, and the abnormal device is updated with the repaired protocol stack code to automatically repair the Bluetooth communication anomaly. In this way, abnormal problems in Bluetooth communication are automatically checked and repaired without the need for human intervention, and the dynamic characteristics of the interpretive language are utilized to directly update the Bluetooth protocol stack code without the need for recompiling and burning the firmware, greatly improving the efficiency of repairing Bluetooth problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 A flowchart of a method for repairing Bluetooth communication anomalies according to an embodiment of the present invention; Figure 2 This is a flow chart of a method for repairing an abnormal Bluetooth broadcast interval according to an embodiment of the present invention; Figure 3 A schematic diagram of a data packet of a connection request according to an embodiment of the present invention; Figure 4 A schematic diagram of a data packet for a response request according to an embodiment of the present invention; Figure 5 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0009] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following description is given in conjunction with the embodiments and accompanying drawings.
[0010] In existing technologies, the traditional Bluetooth troubleshooting process usually includes the following steps. First, the user needs to manually capture the log files of the abnormal device and the Bluetooth btsnoop file (a file used to record Bluetooth communication data packets). These files record the original data transmitted between the Bluetooth controller and the device. Then, professional analysis tools such as Wireshark, Ellisys or Frontline Bluetooth Analyzer are used to visualize the data packets in the btsnoop file. Engineers then review the abnormal data packets or processes one by one and analyze and troubleshoot them in combination with the logs. In addition, it is necessary to compare the Bluetooth interaction specifications to find non-standard behaviors or processes and finally confirm the problem points. Finally, repairs are made according to the problem points, and the repaired firmware is updated to the device through OTA and other methods.
[0011] However, this traditional process has numerous flaws and shortcomings. First, different systems capture log files and btsnoop files in different ways, increasing the complexity of user operations. Second, while existing analysis tools can visualize data packets, diagnosing specific issues still requires manual analysis by engineers, which requires a high level of Bluetooth protocol knowledge. Furthermore, after a fix, the firmware must be repackaged and updated via OTA, making the update process more cumbersome for devices already sold. These factors result in a significant labor-intensive and inefficient troubleshooting and repair process.
[0012] In order to solve at least the above-mentioned technical problems, the present disclosure provides a method for repairing Bluetooth communication anomalies. According to the present disclosure, the Bluetooth communication data is determined by acquiring and parsing the Bluetooth communication file, which facilitates the subsequent analysis and processing of the data, and the abnormal information causing the Bluetooth communication problem is determined in combination with the Bluetooth standard specification. According to the abnormal information, a repaired protocol stack code is generated based on an interpretive language through a pre-trained Bluetooth repair model, and the abnormal device is updated through the repaired protocol stack code to automatically repair the Bluetooth communication anomaly. In this way, according to the embodiments of the present disclosure, abnormal problems in Bluetooth communication are automatically checked and repaired without manual intervention, and the dynamic characteristics of the interpretive language are utilized to directly update the Bluetooth protocol stack code without the need for recompiling and burning the firmware, which greatly improves the efficiency of repairing Bluetooth problems.
[0013] Hereinafter, the technical solutions according to the present disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.
[0014] Figure 1 1 is a flow chart illustrating a method 100 for repairing Bluetooth communication abnormality according to an embodiment of the present disclosure. Figure 1 , the method 100 includes the following steps 102 to 108.
[0015] In step 102, a Bluetooth communication file of the device is acquired and the Bluetooth communication file is parsed to obtain Bluetooth communication data.
[0016] In some embodiments, obtaining a Bluetooth communication file of a device and parsing the Bluetooth communication file to obtain Bluetooth communication data includes: obtaining the Bluetooth communication file and verifying whether the Bluetooth communication file is a valid file; if so, reading the Bluetooth data packets in the Bluetooth communication file one by one, and parsing the Bluetooth data packets to determine the operation type of the Bluetooth data packet; and extracting the target parameters in the Bluetooth data packet according to the operation type to obtain the Bluetooth communication data. In this way, the received Bluetooth communication file is verified to ensure the validity of the file and avoid misjudgment and error processing caused by file damage or invalidity. Reading the Bluetooth data packets in the Bluetooth communication file one by one and parsing their operation types and target parameters can accurately obtain Bluetooth communication data so as to clarify the communication parameters of Bluetooth at each stage of the communication process.
[0017] In step 104, abnormal information in the Bluetooth communication data is detected according to the Bluetooth standard specification.
[0018] In some embodiments, detecting abnormal information in the Bluetooth communication data according to the Bluetooth standard specification includes: obtaining standard parameters corresponding to the operation type from the Bluetooth standard specification; verifying whether the target parameters meet preset standards based on the standard parameters; and if not, printing abnormal information based on the operation type and the target parameters. In this way, by obtaining standard parameters corresponding to the operation type from the Bluetooth standard specification and performing abnormality detection according to the standard specification, it is possible to promptly discover parameters that do not meet the standards, and print abnormal information based on the operation type and target parameters, quickly locating the problem and facilitating subsequent repair and processing. At the same time, through standardized detection processes, the time and effort of manual problem solving is reduced, and the efficiency of problem solving is improved.
[0019] In step 106, a target protocol stack code based on an interpreted language is generated by a pre-trained Bluetooth repair model according to the abnormal information.
[0020] In some embodiments, generating a target protocol stack code based on an interpreted language through a pre-trained Bluetooth repair model based on the exception information includes: obtaining the Bluetooth protocol stack code based on Python language in the device; retrieving an exception code segment that matches the exception information in the Bluetooth protocol stack code; inputting the exception information and the exception code segment into the Bluetooth repair model for analysis and processing to determine the cause of the exception in the Bluetooth communication of the device; and inputting the exception cause and the exception code segment into the Bluetooth repair model for repair processing to generate a target protocol stack code based on Python language. In this way, by retrieving an exception code segment that matches the exception information in the Bluetooth protocol stack code, the problem can be quickly located and the accuracy of problem troubleshooting can be improved. At the same time, the exception information and the exception code segment are input into the Bluetooth repair model for analysis and repair processing, so that the model can deeply understand the cause of the problem and generate targeted repair code to ensure the accuracy and effectiveness of the repair. By automating the analysis and repair process, the dependence on engineer expertise is reduced, the requirement for familiarity with the Bluetooth protocol is lowered, and labor costs are saved.
[0021] In some embodiments, multiple sets of sample question-answer pairs generated based on different functions of the Bluetooth protocol stack code are obtained, and the selected large language model is fine-tuned and trained using the sample question-answer pairs to obtain the Bluetooth repair model. In this way, the large language model is fine-tuned and trained using multiple sets of sample question-answer pairs generated based on different functions of the Bluetooth protocol stack code, so that the model can better adapt to Bluetooth communication scenarios. The fine-tuned model can better understand and handle abnormal situations in Bluetooth communications, adapt to different types of Bluetooth problems, and improve the adaptability and reliability of the model.
[0022] In some embodiments, inputting the abnormal information and the abnormal code segment into the Bluetooth repair model for analysis and processing to determine the abnormal cause of the Bluetooth communication of the device includes: obtaining the first prompt word template for analyzing the abnormal cause in the sample question and answer pair; filling the abnormal information and the abnormal code segment into the corresponding position of the first prompt word template to obtain an analysis question for analyzing the abnormal cause; and inputting the analysis question into the Bluetooth repair model to obtain the output analysis answer information to obtain the abnormal cause of the abnormal device. In this way, by obtaining the first prompt word template in the sample question and answer pair and filling the abnormal information and the abnormal code segment into it, a standardized analysis question is formed so that the large language model can fully understand the abnormal situation existing in the Bluetooth communication. The analysis question is input into the Bluetooth repair model that is fine-tuned based on the large language model, so that the contextual reasoning ability of the large language model can be used to quickly obtain accurate analysis answer information and clarify the abnormal cause without manual intervention, thereby improving the efficiency of problem solving.
[0023] In some embodiments, inputting the exception cause and the exception code segment into the Bluetooth repair model for repair processing to generate a target protocol stack code based on the Python language includes: obtaining a second prompt word template for repairing the exception information from the sample question-answer pair; inserting the exception cause and the exception code segment into corresponding positions of the second prompt word template to obtain a repair question for repairing the exception information; and inputting the repair question into the Bluetooth repair model to obtain output repair answer information, thereby obtaining the target protocol stack code based on the Python language. In this way, by obtaining the second prompt word template from the sample question-answer pair and inserting the exception cause and the exception code segment into it, a standardized repair question is formed. Because the large language model has been fine-tuned, it can fully understand the abnormal situations and code logic in Bluetooth communications. By inputting the repair question into the model in natural language, the model can accurately analyze the problem and generate a repair solution based on its language understanding capabilities. At the same time, the large language model can combine contextual information of the Bluetooth protocol stack to understand the relationship between the exception cause and the code, thereby generating repair code that better meets actual needs. Compared with traditional manual troubleshooting and repair methods, this approach greatly shortens repair time and significantly improves efficiency. The entire repair process is automatically completed by the model, eliminating the need for manual repair code writing, reducing engineers' workload and reliance on Bluetooth protocol expertise.
[0024] In step 108 , the Bluetooth protocol stack code of the device is updated according to the target protocol stack code.
[0025] In some embodiments, updating the Bluetooth protocol stack code of the device according to the target protocol stack code includes: updating the abnormal code segment in the Bluetooth protocol stack code to the target protocol stack code to repair the abnormal information. In this way, directly updating the abnormal code segment to the target protocol stack code can accurately repair problems in the Bluetooth protocol stack, avoid unnecessary code modifications, and reduce repair risks. And because the Bluetooth protocol stack code is written based on Python language, Python language is an interpreted language, which is interpreted and executed line by line by the Python interpreter of the device without compilation, so the updated protocol stack code can take effect immediately without recompiling and burning the firmware. The user only needs to turn Bluetooth on and off to solve the problem, which improves the user experience.
[0026] In some embodiments, the method may further include: executing a Bluetooth communication task based on the updated Bluetooth protocol stack code; and if the execution fails, returning to the process of acquiring the device's Bluetooth communication file and parsing the Bluetooth communication file to obtain Bluetooth communication data. In this way, executing the Bluetooth communication task based on the updated Bluetooth protocol stack code allows for timely verification of the repair effect. If the execution fails, returning to the process of receiving and parsing the Bluetooth communication file again, forming a closed-loop optimization mechanism, ensuring that the problem can be effectively resolved and improving the reliability and stability of the system.
[0027] In one application scenario, when other devices establish a Bluetooth connection with an electronic device, it is necessary to first set the BLE (Bluetooth Low Energy) broadcast parameters of the electronic device so that the other device can search for the current electronic device. After searching for the current electronic device, the other device completes the Bluetooth connection with the current electronic device.
[0028] In this embodiment, the BLE broadcast interval parameter of the electronic device is incorrectly set, resulting in other devices being unable to search for the electronic device, that is, there is a connection abnormality in the electronic device.
[0029] Figure 2 2 is a flow chart showing a method 200 for repairing a Bluetooth broadcast interval anomaly according to an embodiment of the present disclosure. Figure 2 , the method 200 includes the following steps 202 to 212.
[0030] In step 202, the electronic device starts Bluetooth after being powered on, and loads the Python-based Bluetooth protocol stack code to start executing the communication task.
[0031] In step 204 , a btsnoop binary file is collected in real time during the Bluetooth communication process through a physical interface (UART / USB), and the btsnoop binary file is stored in a memory of the electronic device.
[0032] In step 206, the btsnoop binary file is parsed and processed, and abnormal information is detected according to the Bluetooth protocol specification. That is, the btsnoop binary file is the Bluetooth communication file of the device.
[0033] In some embodiments, the btsnoop binary file is parsed according to the format of the btsnoop file. Specifically, the btsnoop file includes a file header of a data packet and record data. The file header includes an identification mode, a version number, and a data link type. The identification mode is used to identify the file as a snoop data packet capture file, the version number is used to identify the version of the data packet capture file being used, and the data link type is used to identify the data link header type used in subsequent data packet records. The record data includes data length, packet flags, timestamp, and target data.
[0034] In some embodiments, a parsing detection function is set based on the format of the btsnoop file and the Bluetooth protocol specification, and file parsing and abnormal information detection are simultaneously completed through the parsing detection function.
[0035] In this application scenario, the analyze_btsnoop function is defined to parse a btsnoop file and test whether the advertisement interval within it complies with the Bluetooth protocol specification. The analyze_btsnoop function executes as follows: 1. Open the btsnoop file in binary mode. 2. Read the first 8 bytes of the file header to determine whether it is a valid btsnoop file. If the file format is invalid, an error message is printed and the function exits. 3. If the file format is valid, a while True loop is used to read the data from the file one by one. Within this while True loop, each 24-byte packet header is read and the packet contents are read based on the data length field in the packet header. If the read packet header length is less than 24 bytes, the end of the file has been reached and the loop exits. 4. As each packet is parsed, the flag field in the packet header is used to determine whether the current packet is a send command. If so, the opcode and parameter length are extracted. 5. If the opcode is to set advertisement parameters and the parameter length is 15 bytes, the minimum and maximum advertisement interval values are extracted. 6. Check whether the maximum and minimum values of the broadcast interval are within the range allowed by the Bluetooth protocol specification. If not, print an exception message, which includes the error type and specific error parameters. For example, in this embodiment, the exception message specifically includes: broadcast interval error, current minimum broadcast interval value min, and current maximum broadcast interval value max.
[0036] In step 208, an abnormal code segment is obtained according to the abnormal information.
[0037] In this application scenario, the exception message is Advertising Interval Error: Min = 40ms, Max = 1044ms; the Bluetooth protocol specification requires a minimum advertising interval of 20ms and a maximum advertising interval of 1024ms. Based on this exception message, a code search of the Bluetooth protocol stack code revealed the following exception code segment: Python try: set_adv(sock, 40ms, 1064ms) except Exception as e: print(f"Expected error: {e}").
[0038] In step 210, the exception information and the exception code segment are sent to the pre-trained Bluetooth repair model to generate the target protocol stack code.
[0039] In some embodiments, the pre-training process of the Bluetooth repair model is specifically as follows: obtaining multiple sets of sample question-answer pairs generated based on different functions of the Bluetooth protocol stack code, and fine-tuning the selected large language model through the sample question-answer pairs to obtain the Bluetooth repair model. In this embodiment, the Bluetooth repair model can realize functions such as code generation, code understanding, error handling, code modification, and code completion. Based on the code generation function, the model can generate complete code from natural language descriptions; based on the code understanding function, the model can understand the functions of the code and the execution operations under specific circumstances; based on the error handling function, the model can analyze and understand the error handling operations; based on the code modification function, the model can modify the code according to the natural language description; based on the code interpretation function, the model can understand the meaning of the corresponding constants in the code; based on the code completion function, the model can complete the complete code based on partial code.
[0040] In this application scenario, the first set of sample question-answer pairs is: Question 1: Write a function in Python to set BLE broadcast parameters (minimum and maximum intervals), start the broadcast, and check the HCI parameters and command return status.
[0041] Answer 1: #HCI Constants HCI_SET_ADV_PARAMS = 0x2006 HCI_SET_ADV_ENABLE = 0x200A ADV_MIN = 0x20 ADV_MAX = 0x4000 def send_hci(sock, opcode, data):sock.send(struct.pack(' <H', opcode)+ bytes([len(data)]) + data)。
[0042] The second set of sample question-answer pairs are as follows: Question 2: Explain what `send_hci` function does.
[0043] Answer 2: The `send_hci` function is responsible for sending HCI commands to the Bluetooth controller and waiting for the `CommandComplete` event. It receives the socket, opcode, and data as parameters and returns the execution status of the HCI command (statusbyte).
[0044] The third set of sample question-answer pairs is as follows: Issue 3: #HCI_SET_ADV_PARAMS = 0x2006 #HCI_SET_ADV_ENABLE = 0x200A #HCI_CMD_COMPLETE = 0x0E Please explain the meaning of the above constants respectively.
[0045] Answer 3: HCI_SET_ADV_PARAMS is the opcode for the HCI command that sets BLE advertising parameters. HCI_SET_ADV_ENABLE is the opcode for the HCI command that enables BLE advertising. HCI_CMD_COMPLETE is the event code for the HCI command completion event.
[0046] The fourth set of sample question and answer pairs are as follows: Question 4: What does it mean if the status value returned by the `send_hci` function is not 0?
[0047] Answer 4: Indicates that the HCI command execution failed.
[0048] Therefore, the above four sets of sample question-answer pairs enable the large language model to understand the code content of the BLE broadcast function.
[0049] In some embodiments, the process of generating the target protocol stack code by the Bluetooth repair model is as follows: understanding the exception information, locating the exception code segment, analyzing the cause of the exception, and repairing the exception code segment. For example, when the exception information is specifically Advertising Interval Error: Min=40ms, Max=1044ms, by understanding the exception information, it can be known that the current Bluetooth communication exception is due to a broadcast interval error, and its minimum interval and maximum interval are beyond a reasonable range. By locating the exception code segment, the content about the parameter setting in the function set_adv used to set the broadcast interval is located. By analyzing the cause of the exception, it is determined that the error is due to the broadcast interval parameters in the set_adv function being set to 40ms and 1044ms, resulting in an unreasonable broadcast interval. By repairing the exception code segment, the parameters are modified to 20ms and 1024ms, thereby obtaining the target protocol stack code.
[0050] In this application scenario, generating the target protocol stack code from the Bluetooth repair model includes the following steps: Step 1: Fill in the corresponding position of the first prompt word template according to the abnormal information and abnormal code segment of the broadcast interval error to obtain an analysis question for analyzing the cause of the abnormality, and the Bluetooth repair model determines the analysis answer information based on the analysis question to obtain the cause of the abnormality.
[0051] In this embodiment, the analysis questions are specifically: After running the code, the following exception message is output: Advertising Interval Error: Min=40ms, Max=1044ms!!! Exception code snippet: Python try: set_adv(sock, 40ms, 1044ms) except Exception as e: print(f\"Expected error: {e}\") Please analyze the cause of the exception.
[0052] The analysis answer information is as follows: The exception is caused by an incorrectly set broadcast interval. The exception information shows that the minimum interval is 40ms, exceeding the allowed minimum of 20ms, and the maximum interval is 1044ms, exceeding the allowed maximum of 1024ms. The code uses set_adv(sock, 40ms, 1044ms), causing it to exceed the range.
[0053] Step 2: Fill in the corresponding position of the second prompt word template based on the abnormal cause and abnormal code segment obtained by analysis to obtain a repair question for repairing the abnormal information. The Bluetooth repair model obtains the target protocol stack code based on the Python language based on the repair answer information output by the repair question.
[0054] In this embodiment, the repair problem is specifically: Exception code snippet: Python try: set_adv(sock, 40ms, 1044ms) except Exception as e: print(f"Expected error: {e}") Exception information: Advertising Interval Error: Min=40ms, Max=1044ms!!! Please provide the complete fixed code.
[0055] The repair answer information is as follows: Python try: set_adv(sock, 20ms, 1024ms) #Change to a reasonable range except Exception as e: print(f"Expected error: {e}").
[0056] In step 212 , the target protocol stack code based on the Python language is updated to the Bluetooth protocol stack code to fix the Bluetooth anomaly.
[0057] In another application scenario, when another device establishes a Bluetooth connection with an electronic device, the other device first sends a connection request to the electronic device. Figure 3 As shown, the electronic device then sends a response message to other devices, and the response message is as follows Figure 4 As shown, the Bluetooth connection is completed. Figure 3 Records the connection HCI (Host Controller Interface) data packets sent by other devices to electronic devices.
[0058] In this embodiment, the Event Code is Connection Request, indicating that this is a connection request event from the device; the Parameters include BD_ADDR (electronic device address), indicating that the Bluetooth address of the device requesting connection is 34:29:12:B6:C2:06; the Class of Device / Service includes Minor Device Class, Major Device Class, and Major Service Class, and the Major Service Class includes Networking, Capturing, Object Transfer, and Telephony; the Link Type is ACL (Asynchronous Connection Less), indicating an asynchronous connectionless (ACL) link. Figure 4 Records the response HCI data packet sent by an electronic device to other devices.
[0059] In this embodiment, the Command Code is Accept Connection Request and includes OCF and OGF. OCF is used to identify HCI commands, and OGF is Link Control, which is used to manage commands. Parameters include BD_ADDR (electronic device address) and Role. Role is used to specify that the device is the Master in the connection to be established.
[0060] In this embodiment, the electronic device cannot send response information to other devices, resulting in the other devices being unable to connect to the electronic device normally, that is, the electronic device has a connection anomaly. According to the embodiment of the present disclosure, the method 300 for repairing Bluetooth connection anomaly includes the following steps 302 to 310.
[0061] In step 302, the btsnoop binary file is parsed and processed, and according to the Bluetooth protocol specification, it is detected that the error type in the abnormal information of the electronic device is failure to send response information to other devices, and the specific error parameter in the abnormal information is 34:29:12:B6:C2:06 is blocked.
[0062] In step 304, the abnormal code segment obtained according to the abnormal information is specifically: def bt_accept_connection(bd_addr): blocked_addr = "34:29:12:B6:C2:06" if bd_addr.startswith(blocked_addr): print("34:29:12:B6:C2:06 is blocked!!!") return -1 bt_send_response(bd_addr) return 0.
[0063] In step 306, the exception information and the exception code segment are sent to the pre-trained Bluetooth repair model to determine the cause of the exception: the device address "34:29:12:B6:C2:06" is blacklisted. Once the address matches, it is returned, resulting in a connection failure.
[0064] In step 308, the exception cause and the exception code segment are sent to the pre-trained Bluetooth repair model to generate the target protocol stack code based on the Python language: def bt_accept_connection(bd_addr): bt_send_response(bd_addr)#deleted block related code return 0.
[0065] In step 310 , the target protocol stack code based on Python language is updated to the Bluetooth protocol stack code.
[0066] It should be noted that the updated Bluetooth protocol stack code does not require recompilation or code upgrade. Users will not be aware of this and only need to turn Bluetooth on and off to solve the problem.
[0067] According to another aspect of the present invention, Figure 5 Schematic diagram of an electronic device 500 according to an embodiment of the present invention. Figure 5 The electronic device 500 includes a memory 502 and a processor 504. The memory 502 is configured to store an executable program. The processor 504 is configured to execute the program to perform the various steps of the method for repairing Bluetooth communication anomalies as described above.
[0068] In summary, the present invention provides a method and electronic device for repairing Bluetooth communication anomalies, which determines Bluetooth communication data by acquiring and parsing Bluetooth communication files, facilitates subsequent data analysis and processing, and determines the abnormal information that causes Bluetooth communication problems in combination with Bluetooth standard specifications. Based on the abnormal information, the abnormal code segment is directly located in the original Bluetooth protocol stack code, and then the pre-trained Bluetooth repair model is called according to the abnormal information and the abnormal code segment. The Bluetooth repair model is used to understand the code function and generate a target protocol stack code based on the Python language. Finally, the abnormal device is updated with the repaired target protocol stack code to automatically repair the Bluetooth communication anomaly. In this way, the present invention can automatically troubleshoot and repair abnormal problems in Bluetooth communication without manual intervention, and because the Bluetooth protocol stack code of the present invention is written in the interpreted language Python, the target protocol stack code generated by the Bluetooth repair model can directly update the Bluetooth protocol stack code by utilizing the dynamic characteristics of the Python language, without the need to recompile and burn the firmware, which greatly improves the efficiency of repairing Bluetooth problems.
[0069] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's description and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for repairing Bluetooth communication anomalies, characterized in that: include: Obtaining a Bluetooth communication file of a device and parsing the Bluetooth communication file to obtain Bluetooth communication data; Detecting abnormal information in the Bluetooth communication data according to Bluetooth standard specifications; Generate a target protocol stack code based on an interpreted language through a pre-trained Bluetooth repair model according to the abnormal information; as well as The Bluetooth protocol stack code of the device is updated according to the target protocol stack code.
2. The method according to claim 1, characterized in that Generating a target protocol stack code based on an interpreted language through a pre-trained Bluetooth repair model according to the abnormal information includes: Obtaining Python-based Bluetooth protocol stack code from the device; Retrieving an abnormal code segment matching the abnormal information in the Bluetooth protocol stack code; Inputting the abnormal information and the abnormal code segment into the Bluetooth repair model for analysis and processing to determine the abnormal cause of the Bluetooth communication of the device; and The abnormal cause and the abnormal code segment are input into the Bluetooth repair model for repair processing to generate a target protocol stack code based on the Python language.
3. The method according to claim 2, characterized in that Also includes: A plurality of groups of sample question-answer pairs generated based on different functions of the Bluetooth protocol stack code are obtained, and the selected large language model is fine-tuned and trained using the sample question-answer pairs to obtain the Bluetooth repair model.
4. The method according to claim 3, characterized in that Inputting the abnormal information and the abnormal code segment into the Bluetooth repair model for analysis and processing to determine the abnormal cause of the Bluetooth communication of the device includes: Obtaining a first prompt word template for analyzing the cause of the abnormality in the sample question-answer pair; Filling the exception information and the exception code segment into corresponding positions of the first prompt word template to obtain an analysis question for analyzing the cause of the exception; and The analysis question is input into the Bluetooth repair model to obtain output analysis answer information and obtain the cause of the abnormality.
5. The method according to claim 3, characterized in that Inputting the exception cause and the exception code segment into the Bluetooth repair model for repair processing to generate a target protocol stack code based on the Python language includes: Obtaining a second prompt word template for repairing abnormal information in the sample question-answer pair; Filling the exception cause and the exception code segment into corresponding positions of the second prompt word template to obtain a repair question for repairing the exception information; and The repair problem is input into the Bluetooth repair model to obtain output repair answer information, and a target protocol stack code based on the Python language is obtained.
6. The method according to claim 1, characterized in that Acquiring a Bluetooth communication file of a device and parsing the Bluetooth communication file to obtain Bluetooth communication data includes: Obtain the Bluetooth communication file and verify whether the Bluetooth communication file is a valid file; If yes, reading the Bluetooth data packets in the Bluetooth communication file one by one, and parsing the Bluetooth data packets to determine the operation type of the Bluetooth data packets; and The target parameters in the Bluetooth data packet are extracted according to the operation type to obtain the Bluetooth communication data.
7. The method according to claim 6, characterized in that Detecting abnormal information in the Bluetooth communication data according to the Bluetooth standard specification includes: Acquire standard parameters corresponding to the operation type from the Bluetooth standard specification; Verifying whether the target parameter meets the preset standard according to the standard parameter; and If not, print the exception information according to the operation type and the target parameters.
8. The method according to claim 2, characterized in that Updating the Bluetooth protocol stack code of the device according to the target protocol stack code includes: The abnormal code segment in the Bluetooth protocol stack code is updated to the target protocol stack code to repair the abnormal information.
9. The method according to claim 1, characterized in that Also includes: Execute Bluetooth communication tasks based on the updated Bluetooth protocol stack code; as well as If the execution fails, the process returns to executing the Bluetooth communication file of the device and parsing the Bluetooth communication file to obtain Bluetooth communication data.
10. An electronic device, characterized in that: include: a memory configured to store an executable program; as well as A processor configured to execute the program to perform the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Method and device for recovering abnormal working of Bluetooth module
CN116761196A
Code repairing method and device, equipment and medium
CN117555720A
Software detection method and device
CN119357013A
Intelligent terminal quick initialization and management method and system based on NFC and Bluetooth
CN119893485A