Bluetooth communication method and system
By saving Mac address and key information between Bluetooth devices, and performing whitelist detection and key information analysis during the reconnection process, the problem of failed reconnection in communication between Bluetooth devices is solved, and the stability of information interaction is achieved.
Patent Information
- Application Number
- CN202210423010.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2042-04-21
AI Technical Summary
During the return process, communication between traditional Bluetooth devices is prone to failure due to information loss or environmental interference, which affects communication stability.
By saving the other party's Mac address and key information after Bluetooth pairing, sending a back-connection broadcast message after disconnection, if it complies with custom rules, send a scan request, perform whitelist detection, and parsing it when the back-return successful or failed The key information in the scan response is transmitted for data.
Regardless of whether Bluetooth is connected successfully or not, the information interaction between the terminal and the terminal controller can be realized, improving the stability of communication.
Smart Images

Figure CN114640980B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Bluetooth communication, and in particular to a Bluetooth communication method and system. Background Art
[0002] Traditionally, communication between Bluetooth devices is based on pairing and connection. After the connection is established, the Mac (Medium / Media Access Control) address of the other device is stored to achieve fast reconnection. However, in actual applications, sometimes the connection information of the other end stored by one party is lost, or due to environmental interference, the reconnection between the two parties cannot be established. At this time, it will greatly affect the communication and cause data loss. Summary of the invention
[0003] The purpose of the present invention is to provide a Bluetooth communication method and system to solve the communication problem of two paired Bluetooth devices during the reconnection process. Regardless of whether the Bluetooth reconnection is successful, information interaction can be achieved, thereby improving the stability of communication.
[0004] The present invention adopts the following technical scheme to achieve the above-mentioned purpose. A Bluetooth communication method is applied to the communication between a terminal and a corresponding terminal controller. The method comprises:
[0005] Step 1: The terminal completes Bluetooth pairing with the corresponding terminal controller, and saves each other's Mac address and key information respectively;
[0006] Step 2: After the Bluetooth connection is disconnected, the terminal controller sends a reconnection broadcast message;
[0007] Step 3: After receiving the backlink broadcast message, the terminal determines whether it meets the terminal's custom rules. If so, a scan request is issued, and the scan request carries the Bluetooth Mac addresses of both parties.
[0008] Step 4: judge the pairing information stored in the terminal controller. If the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist and the process proceeds to step 5; otherwise, the whitelist is not set and the process proceeds to step 6;
[0009] Step 5: The terminal controller receives the scan request and performs a whitelist check. If the whitelist check is passed, a scan response is returned and the process proceeds to step 7. The scan response includes the key value, key, Mac address, and key number information of the terminal controller key. If the whitelist check is not passed, the process ends.
[0010] Step 6: After receiving the scan request, the terminal controller directly replies with a scan response, wherein the reply scan response includes the key value, key, Mac address and key number information of the terminal controller key, and then proceeds to step 7;
[0011] Step 7: After receiving the scan response, if the terminal can send a connection request according to the normal process and the connection is successful, the reconnection is successful. After the reconnection is successful, the key value is transmitted in the data channel and the process ends; otherwise, go to step 8;
[0012] Step 8: The terminal parses the received scan response and determines the Mac address of the scan response. If the Mac address of the scan response is the Bluetooth Mac address of the saved paired terminal controller, proceed to step 9;
[0013] Step 9: parse the key number and key value carried in the scan response. If the key number is inconsistent with the corresponding number in the terminal, upload the key value to the terminal system to implement the corresponding key operation, and end the process.
[0014] Furthermore, in step 2, the back-connection broadcast message includes the terminal controller model and private protocol information of the custom rule.
[0015] Furthermore, the method further includes: in step 7, before the reconnection is successful, if new key information is sent from the terminal controller to the terminal via broadcast, then entering step 3.
[0016] A Bluetooth communication system, used to implement the above-mentioned Bluetooth communication method, includes a terminal and a terminal controller corresponding to the terminal, the terminal and the corresponding terminal controller complete Bluetooth pairing, and the terminal and the corresponding terminal controller respectively save each other's Mac address and key information; after the Bluetooth connection is disconnected, the terminal controller sends a back-connection broadcast message; after the terminal receives the back-connection broadcast message, it determines whether it complies with the terminal's custom rules, and if it does, it sends a scan request, and the scan request carries the Bluetooth Mac addresses of both parties; the pairing information stored in the terminal controller is judged, if the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist, the terminal controller receives the scan request and performs a whitelist detection, if it passes the whitelist detection, It replies with a scan response, which includes the key value, Mac address and number information of the terminal controller's button; otherwise, the whitelist is not set, and the terminal controller directly replies with a scan response after receiving the scan request; after the terminal receives the scan response, if it can send a connection request according to the normal process and the connection is successful, the reconnection is successful this time, and the key value is transmitted on the data channel after the reconnection is successful; otherwise, the received scan response is parsed to determine the Mac address of the scan response. If the Mac address of the scan response is the saved Bluetooth Mac address of the paired terminal controller, the button number and button value carried in the scan response are parsed. If the button number is inconsistent with the corresponding number in the terminal, the key value is uploaded to the terminal system to implement the corresponding button operation.
[0017] After the Bluetooth reconnection is successful, the present invention performs key-value transmission in the data channel, transmits the key-value information of the terminal controller to the terminal, and realizes the control of the terminal; in the process of abnormal reconnection, the terminal first parses the received scan response, determines the Mac address of the scan response, and if the Mac address of the scan response is the saved Bluetooth Mac address of the paired terminal controller, parses the key number and key value carried in the scan response, and if the key number is inconsistent with the corresponding number in the terminal, uploads the key value to the terminal system to realize the corresponding key operation, completes the transmission of the terminal controller key information, and realizes the control of the terminal; thereby, regardless of whether the Bluetooth reconnection is successful, information interaction between the terminal and the corresponding terminal controller can be realized, thereby improving the stability of communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a Bluetooth communication flow chart provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0020] The Bluetooth communication method of the present invention is applied to the communication between a terminal and a corresponding terminal controller, and the method comprises:
[0021] Step 1: The terminal completes Bluetooth pairing with the corresponding terminal controller, and saves each other's Mac address and key information respectively;
[0022] Step 2: After the Bluetooth connection is disconnected, the terminal controller sends a reconnection broadcast message;
[0023] Step 3: After receiving the backlink broadcast message, the terminal determines whether it meets the terminal's custom rules. If so, a scan request is issued, and the scan request carries the Bluetooth Mac addresses of both parties.
[0024] Step 4: judge the pairing information stored in the terminal controller. If the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist and the process proceeds to step 5; otherwise, the whitelist is not set and the process proceeds to step 6;
[0025] Step 5: The terminal controller receives the scan request and performs a whitelist check. If the whitelist check is passed, a scan response is returned and the process proceeds to step 7. The scan response includes the key value, key, Mac address, and number information of the key of the terminal controller.
[0026] Step 6: After receiving the scan request, the terminal controller directly replies with a scan response and proceeds to step 7;
[0027] Step 7: After receiving the scan response, if the terminal can send a connection request according to the normal process and the connection is successful, the reconnection is successful. After the reconnection is successful, the key value is transmitted in the data channel and the process ends; otherwise, go to step 8;
[0028] Step 8: The terminal parses the received scan response and determines the Mac address of the scan response. If the Mac address of the scan response is the Bluetooth Mac address of the saved paired terminal controller, proceed to step 9;
[0029] Step 9: parse the key number and key value carried in the scan response. If the key number is inconsistent with the corresponding number in the terminal, upload the key value to the terminal system to implement the corresponding key operation, and end the process.
[0030] In step 2, the back-connection broadcast message includes the terminal controller model and private protocol information of the custom rule.
[0031] In step 7, before the reconnection is successful, if new key information is sent from the terminal controller to the terminal through broadcast, go to step 3.
[0032] The Bluetooth communication system includes a terminal and a terminal controller corresponding to the terminal. The terminal and the corresponding terminal controller complete Bluetooth pairing, and the terminal and the corresponding terminal controller respectively save each other's Mac address and key information; after the Bluetooth connection is disconnected, the terminal controller sends a back-connection broadcast message; after the terminal receives the back-connection broadcast message, it determines whether it meets the terminal's custom rules. If it meets the rules, a scan request is sent, and the scan request carries the Bluetooth Mac addresses of both parties; the pairing information stored in the terminal controller is judged. If the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist. The terminal controller receives the scan request and performs a whitelist detection. If the whitelist detection is passed, a scan response is replied. If yes, the reply scan response includes the key value, Mac address and number information of the terminal controller button; otherwise, the whitelist is not set, and the terminal controller directly replies with a scan response after receiving the scan request; after the terminal receives the scan response, if it can send a connection request according to the normal process and the connection is successful, the reconnection is successful this time, and the key value is transmitted on the data channel after the reconnection is successful; otherwise, the received scan response is parsed to determine the Mac address of the scan response. If the Mac address of the scan response is the saved Bluetooth Mac address of the paired terminal controller, the key number and key value carried in the scan response are parsed. If the key number is inconsistent with the corresponding number in the terminal, the key value is uploaded to the terminal system to implement the corresponding key operation.
[0033] This embodiment takes the Bluetooth communication between a TV and a remote controller as an example.
[0034] Bluetooth communication method between TV and remote control, such as Figure 1 As shown, the specific steps include:
[0035] The first step is to pair the TV with the remote control and save each other's Mac address and key information.
[0036] In the second step, after the Bluetooth connection is disconnected, the Bluetooth remote control performs a reconnection action (for example, the user presses a button to reconnect or automatically reconnects) to try to restore the connection with the TV. The reconnection action specifically includes the remote control sending a reconnection broadcast message ADV_IND on the broadcast channel. The message contains the remote control model and private protocol information that conforms to the custom rules;
[0037] Step 3: After receiving the backlink broadcast message ADV_IND, the TV determines whether it meets the custom rules. If so, it sends a scan request SCAN_REQ, which carries the Bluetooth MAC addresses of both parties.
[0038] Step 4: If the pairing information of the remote control is not lost, the Bluetooth MAC address of the paired TV is used as the whitelist filtering condition. After the remote control receives SCAN_REQ, if it passes the whitelist detection, it replies with a scan response SCAN_RSP. If the pairing information of the remote control is lost, the whitelist detection is no longer performed, and the scan response SCAN_RSP is directly replied;
[0039] Among them, the scan response SCAN_RSP replied by the remote control carries specific information, including: the key value of the user's key, key information, the remote control MAC address and the number of the current key (after the remote control is powered on, when the Bluetooth is disconnected, each key is numbered from 1 to 255 by 1 each time, so that the TV end can distinguish each key action);
[0040] Step 5: After receiving SCAN_RSP, if the TV can initiate a connection according to the normal process, send CONNET_REQ, and successfully complete the entire connection process, then the reconnection is successful; the key value transmission is then performed on the data channel. If the reconnection cannot be completed normally due to loss or damage of the key data saved by the TV, or environmental interference, etc., then proceed to step 6;
[0041] Step 6: The TV parses the received SCAN_RSP. If it determines that the Mac address in the scan response is the Bluetooth MAC address of the saved paired remote control, it further parses the key number and key value carried in SCAN_RSP. If the key sequence number is different from the current value (after the TV is turned on, the current value of the key sequence number is set to 0, and the key sequence number carried in the received remote control SCAN_RSP is synchronized later), the key value is uploaded to the terminal system to implement the corresponding key operation, completing a complete transmission process of the key information;
[0042] In the above process, before the reconnection is successful, if new key information is sent from the remote control to the TV through the broadcast channel, enter the third step.
[0043] In summary, the present invention realizes information interaction between a terminal and a corresponding terminal controller regardless of whether the Bluetooth backconnection is successful, thereby improving the stability of communication.
Claims
1. Bluetooth communication method, applied to the communication between the terminal and the corresponding terminal controller, It is characterized in that include: Step 1: The terminal completes Bluetooth pairing with the corresponding terminal controller, and saves each other's Mac address and key information respectively; Step 2: After the Bluetooth connection is disconnected, the terminal controller sends a back-connection broadcast message, and the back-connection broadcast message includes the terminal controller model of the custom rule and private protocol information; Step 3: After receiving the backlink broadcast message, the terminal determines whether it meets the terminal's custom rules. If so, a scan request is issued, and the scan request carries the Bluetooth Mac addresses of both parties. Step 4: judge the pairing information stored in the terminal controller. If the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist and the process proceeds to step 5; otherwise, the whitelist is not set and the process proceeds to step 6; Step 5: The terminal controller receives the scan request and performs a whitelist check. If the whitelist check is passed, a scan response is returned and the process proceeds to step 7. The scan response includes the key value, key, Mac address, and key number information of the terminal controller key. If the whitelist check is not passed, the process ends. Step 6: After receiving the scan request, the terminal controller directly replies with a scan response, wherein the reply scan response includes the key value, key, Mac address and key number information of the terminal controller key, and then proceeds to step 7; Step 7: After receiving the scan response, if the terminal can send a connection request according to the normal process and the connection is successful, the reconnection is successful. After the reconnection is successful, the key value is transmitted in the data channel, and the process ends; Otherwise go to step 8; Step 8: The terminal parses the received scan response and determines the Mac address of the scan response. If the Mac address of the scan response is the Bluetooth Mac address of the saved paired terminal controller, proceed to step 9; Step 9: parse the key number and key value carried in the scan response. If the key number is inconsistent with the corresponding number in the terminal, upload the key value to the terminal system to implement the corresponding key operation, and end the process.
2. The Bluetooth communication method according to claim 1, It is characterized in that The method further includes: in step 7, before the reconnection is successful, if new key information is sent from the terminal controller to the terminal through broadcasting, then entering step 3.
3. A Bluetooth communication system, used to implement the Bluetooth communication method according to claim 1 or 2, It is characterized in that It includes a terminal and a terminal controller corresponding to the terminal. The terminal and the corresponding terminal controller complete Bluetooth pairing. The terminal and the corresponding terminal controller respectively save each other's Mac address and key information. After the Bluetooth connection is disconnected, the terminal controller sends a back-connection broadcast message. After receiving the back-connection broadcast message, the terminal determines whether it complies with the terminal's custom rules. If it does, a scan request is issued, and the scan request carries the Bluetooth Mac addresses of both parties. Then the pairing information stored in the terminal controller is judged. If the pairing information stored in the terminal controller is not lost, the paired Bluetooth Mac address is used as a whitelist. The terminal controller receives the scan request and performs a whitelist detection. If the whitelist detection is passed, a scan response is replied. The reply scan response includes the key value, Mac address and key number information of the terminal controller button; otherwise, the whitelist is not set, and the terminal controller directly replies to the scan response after receiving the scan request; after the terminal receives the scan response, if it can send a connection request according to the normal process and the connection is successful, the reconnection is successful this time, and the key value is transmitted on the data channel after the reconnection is successful; otherwise, the received scan response is parsed to determine the Mac address of the scan response. If the Mac address of the scan response is the saved Bluetooth Mac address of the paired terminal controller, the key number and key value carried in the scan response are parsed. If the key number is inconsistent with the corresponding number in the terminal, the key value is uploaded to the terminal system to implement the corresponding key operation.
