Communication mode switching method and device based on Bluetooth connection, medium and equipment
By dynamically adjusting the timeout waiting time in Bluetooth connection and re-initiating a mode switching request, the connection status stagnation caused by timeout is solved, the mode switching success rate is improved, and the device is ensured to be controlled normally.
Patent Information
- Application Number
- CN202411519802.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2024-12-17
AI Technical Summary
The master device does not receive feedback from the slave device during the Bluetooth connection due to timeout, resulting in the connection status being stuck in the intermediate state and unable to issue instructions, resulting in the problem of control failure.
When the breathing mode trigger condition is detected, the mode switching request is initiated and the command issuance permission is frozen, the request time is recorded, the timeout wait time is predicted through the pre-training model, the execution result is monitored and the permission is released after the timeout, the request is initiated again, and the timeout is dynamically adjusted. Wait time to improve the success rate of mode switching.
It effectively avoids the connection status stagnation caused by timeout, improves the success rate of Bluetooth communication mode switching, ensures that the device can control normally, thereby solving the problem of control failure.
Smart Images

Figure CN119155663A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to the field of communication mode switching technology based on Bluetooth connection, and in particular to a communication mode switching method, device, medium and equipment based on Bluetooth connection. Background Art
[0002] The Bluetooth core specification defines multiple modes for classic Bluetooth connection states, including Active mode, Sniff mode, and Hold mode. Active mode and Sniff mode, as well as Active mode and Hold mode, can be switched between each other. In Active mode, the master device will try its best to use available resources for communication; in Sniff mode, the master device and the slave device need to agree on a Sniff interval, and both parties communicate at the agreed interval, and the slave device sleeps during the interval; in Hold mode, the slave device can sleep until the agreed Hold mode time expires, at which time it will wake up.
[0003] When the master device initiates the breathing mode to the slave device, the master device will enter an intermediate state (mode), in which the master device is not allowed to send data to the Bluetooth chip of the master device. If the Bluetooth chip of the master device fails to upload the success event or failure event sent by the slave device to the master device within the agreed time due to the device's own reasons or environmental interference, the connection state between the master device and the Bluetooth chip of the master device will remain in the intermediate state, resulting in the subsequent master device being unable to send any instructions to the Bluetooth chip of the master device. The most direct impact at this time is that the relevant Bluetooth remote control commands cannot be sent to the slave device through the master device, causing the master device to fail to control the slave device. Summary of the invention
[0004] The embodiment of the present application provides a method, device, medium and equipment for switching communication modes based on Bluetooth connection. The method for switching communication modes based on Bluetooth connection provided by the embodiment of the present application is used to solve the problem that the host chip fails to upload the success event or failure event sent by the slave device to the master device within the agreed time, causing the connection state between the master device and the Bluetooth chip of the master device to remain in the intermediate state, resulting in the subsequent master device being unable to send any instructions to the Bluetooth chip of the master device.
[0005] On the one hand, an embodiment of the present application provides a communication mode switching method based on Bluetooth connection, which is applied to a first device, including:
[0006] When a trigger condition for starting the breathing mode is detected, a mode switching request is initiated to the second device, and the instruction issuing authority of the first device is frozen;
[0007] Recording the initiation time of the mode switching request, and obtaining a target parameter value corresponding to a preset parameter currently used to affect communication quality, inputting the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtaining a predicted timeout waiting time;
[0008] monitoring the execution result of the mode switching request;
[0009] If the execution result is that no request feedback information is received within the timeout waiting time, the instruction issuing authority of the first device is released;
[0010] Re-initiate a mode switching request to the second device.
[0011] In the communication mode switching method based on Bluetooth connection described in the embodiment of the present application, before initiating the mode switching request to the second device, the method further includes:
[0012] During the process of establishing a Bluetooth connection between the first device and the second device, obtaining a preset parameter value generated during each link management protocol interaction;
[0013] The initial time determination model is trained using each of the preset parameter values as a model training sample, and the model parameters of the initial time determination model are adjusted using a stochastic gradient descent algorithm until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
[0014] In the communication mode switching method based on Bluetooth connection described in the embodiment of the present application, after monitoring the execution result of the mode switching request, the method further includes:
[0015] If the execution result is that the switching permission feedback information returned by the second device is received within the timeout waiting time, the current communication mode between the first device and the second device is switched to the breathing mode;
[0016] If the execution result is that the switching rejection feedback information returned by the second device is received within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or
[0017] Prompt information including the switching rejection feedback information is generated to prompt the user.
[0018] In the communication mode switching method based on Bluetooth connection described in the embodiment of the present application, before re-initiating the mode switching request to the second device, the method further includes:
[0019] Obtain the number of repetitions of the current mode switching request;
[0020] If the number of repeated initiations exceeds a preset number, the mode switching request to the second device is stopped, and a device abnormality message is generated to prompt the user.
[0021] In the communication mode switching method based on Bluetooth connection described in the embodiment of the present application, before initiating the mode switching request to the second device, the method further includes:
[0022] Checking the role status of the first device in the current Bluetooth local area network, where the role status includes a central device or a peripheral device;
[0023] If the role status of the first device is a central device, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0024] In the communication mode switching method based on Bluetooth connection described in the embodiment of the present application, after checking the role status of the first device in the current Bluetooth local area network, the method further includes:
[0025] If the role status of the first device is a peripheral device, a role exchange request is initiated to a central device in the current Bluetooth local area network to change the role status of the first device to a central device, so that the first device has the modification authority to modify the polling interval between the first device and the second device;
[0026] Based on the modification authority, an initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0027] Accordingly, another aspect of the embodiment of the present application further provides a communication mode switching method based on Bluetooth connection, which is applied to a second device and includes:
[0028] receiving a mode switching request initiated by a first device;
[0029] Generate corresponding request feedback information according to the mode switching request, and send the request feedback information to the first device;
[0030] If the request feedback information is switching permission feedback information, switching the current communication mode between the first device and the second device to a breathing mode;
[0031] If the request feedback information is switching rejection feedback information, the current communication mode between the first device and the second device is not changed.
[0032] Correspondingly, another aspect of the embodiment of the present application further provides a communication mode switching device based on Bluetooth connection, which is applied to a first device, and the communication mode switching device based on Bluetooth connection includes:
[0033] A detection module, configured to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when a trigger condition for starting the breathing mode is detected;
[0034] A prediction module, used to record the initiation time of the mode switching request, and obtain a target parameter value corresponding to a preset parameter currently used to affect the communication quality, and input the target parameter value into a pre-trained time determination model to perform a time prediction operation to obtain a predicted timeout waiting time;
[0035] A monitoring module, used for monitoring the execution result of the mode switching request;
[0036] a release module, configured to release the instruction issuing authority of the first device if the execution result is that no request feedback information is received within the timeout waiting time;
[0037] A retry module is used to re-initiate a mode switching request to the second device.
[0038] Correspondingly, another aspect of the embodiment of the present application further provides a storage medium, wherein the storage medium stores a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute the communication mode switching method based on Bluetooth connection as described above.
[0039] Correspondingly, another aspect of an embodiment of the present application further provides an electronic device, including a processor and a memory, wherein the memory stores a plurality of instructions, and the processor loads the instructions to execute the communication mode switching method based on Bluetooth connection as described above.
[0040] The embodiment of the present application provides a communication mode switching method, device, medium and equipment based on Bluetooth connection. The method initiates a mode switching request to the second device and freezes the instruction issuing authority of the first device when detecting the trigger condition for turning on the breathing mode; records the initiation time of the mode switching request, obtains the target parameter value corresponding to the preset parameter currently used to affect the communication quality, inputs the target parameter value into the time determination model for time prediction operation, and obtains the predicted timeout waiting time; monitors the execution result of the mode switching request; if the execution result is that the request feedback information is not received after the timeout waiting time, the instruction issuing authority of the first device is released; and the mode switching request is re-initiated to the second device. Using the communication mode switching method based on Bluetooth connection provided by the embodiment of the present application, by setting a reasonable timeout waiting time, if the first device does not receive the request feedback information sent by the second device within the timeout waiting time, the instruction issuing authority of the first device is released; and the mode switching request is re-initiated to the second device to improve the success rate of the communication mode switching and avoid the first device from being unable to control the second device normally due to the lack of instruction issuing authority. Moreover, the timeout waiting time is dynamically generated according to the current usage scenario, which can better meet the current usage scenario and avoid the problem that the first device fails to normally receive the request feedback information due to early or delayed re-initiating of the mode switching request to the second device. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and those skilled in the art can obtain other drawings based on these drawings without creative work.
[0042] Figure 1 A flowchart of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0043] Figure 2 Another flowchart of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0044] Figure 3 Another flowchart of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0045] Figure 4 Another flowchart of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0046] Figure 5 Another flowchart of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0047] Figure 6 A schematic diagram of the structure of a communication mode switching device based on Bluetooth connection provided in an embodiment of the present application.
[0048] Figure 7 Another structural schematic diagram of the communication mode switching device based on Bluetooth connection provided in an embodiment of the present application.
[0049] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0051] The embodiment of the present application provides a communication mode switching method based on Bluetooth connection. By using this method, a reasonable timeout waiting time is set. If the first device does not receive the request feedback information sent by the second device within the timeout waiting time, the command issuing authority of the first device is released, and a mode switching request is re-initiated to the second device, so as to improve the success rate of communication mode switching and avoid the first device being unable to control the second device normally due to lack of command issuing authority. In addition, the timeout waiting time is dynamically generated according to the current usage scenario, which can be more in line with the current usage scenario, avoiding the problem that the first device fails to receive the request feedback information normally due to the early or delayed re-initiation of the mode switching request to the second device.
[0052] The term "and / or" in this application can be a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.
[0053] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described here can be implemented in an order other than that illustrated or described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to the steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The process steps that have been named or numbered can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of modules in this application is a logical division. There may be other division methods when it is implemented in actual applications. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection between modules can be electrical or other similar forms, which are not limited in this application. In addition, the modules or submodules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed in multiple circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the present application.
[0054] The communication mode switching method based on Bluetooth connection involved in the embodiment of the present application is mainly applied to electronic devices, which may be smart phones, tablet computers, laptop computers, desktop computers, smart home appliances and servers, etc., which are not limited here. Optionally, the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or an IoT cloud (Internet of Things cloud) that provides the ability to store, process and manage data generated by IoT devices, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, which are not limited here.
[0055] For ease of understanding, the specific process in the embodiments of the present application is described below. Figure 1 , Figure 1A flow chart of an embodiment of a method for switching communication modes based on Bluetooth connection provided in an embodiment of the present application.
[0056] exist Figure 1 In the illustrated embodiment, the method is applied to a first device and may include the following steps:
[0057] S101, when a trigger condition for starting the breathing mode is detected, a mode switching request is initiated to the second device, and the instruction issuing authority of the first device is frozen.
[0058] It should be explained that breathing mode is a classic Bluetooth connection state, which is used to reduce power consumption when the Bluetooth device does not need to communicate continuously. In breathing mode, the Bluetooth device will periodically disconnect and re-establish the connection with the paired device to achieve the effect of reducing energy consumption.
[0059] The breathing mode is usually not initiated by the device, but when the device is in the hold mode or sleep mode, it detects the triggering condition for turning on the breathing mode and automatically switches to the breathing mode. For example, when the first device is in the hold mode and detects that no data exchange occurs within the timeout waiting time, it can be considered that the first device meets the triggering condition for turning on the breathing mode. The first device will automatically initiate a mode switching request to the second device connected to it by Bluetooth, requesting to switch the current communication mode to the breathing mode to reduce the power consumption of the device.
[0060] It should be noted that the first device in this solution actually includes a main device control chip and a main device Bluetooth chip. When the first device initiates a mode switching request to the second device to switch the current communication mode to the breathing mode, the main device control chip first sends a mode switching application to the main device Bluetooth chip. After the main device control chip receives the application success information fed back by the main device Bluetooth chip, the main device control chip will automatically enter the intermediate state (mode). In the intermediate state, the main device control chip is not allowed to send data to the main device Bluetooth chip. The main reasons include the following:
[0061] 1. Avoid conflicts. During the mode switching process, the second device may need to perform some specific operations to adapt to the new communication mode. If the first device sends other instructions at this time, it may conflict with the needs of the second device during the mode switching process, causing the second device to fail to respond correctly or perform incorrect operations.
[0062] 2. Ensure stability. Mode switching is a sensitive process that requires the second device to concentrate resources to complete. Prohibiting the issuance of instructions can reduce the amount of data that the second device needs to process during mode switching, ensuring the stability and success rate of the mode switching process.
[0063] 3. Preventing erroneous operations: During mode switching, the second device may not support certain device commands or may not be able to respond to these commands correctly. Prohibiting the issuance of commands can prevent the second device from making errors or malfunctions due to attempting to perform inappropriate operations.
[0064] 4. Resource management: When switching modes, the second device may need to reconfigure its Bluetooth stack and hardware resources. During this process, the second device may not be able to process new instructions, so prohibiting the issuance of instructions is to avoid wasting resources and possible problems.
[0065] S102, recording the initiation time of the mode switching request, and obtaining a target parameter value corresponding to a preset parameter currently used to affect communication quality, inputting the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtaining a predicted timeout waiting time.
[0066] It needs to be explained that since the main device Bluetooth chip of the second device or the first device may be affected by the network quality or system resources, there may be a certain time delay when sending request feedback information to the main device control chip of the first device. If the impact that may be caused by the time delay is ignored, it may be mistakenly believed that the request feedback information is sent abnormally at this time, which directly causes the main device control chip of the first device to be stuck in an intermediate state and unable to continue to control the second device.
[0067] For example, when the second device receives a mode switching request, or the master device Bluetooth chip of the first device forwards the request feedback information to the master device control chip of the first device, if the current network quality of the second device or the master device Bluetooth chip is poor, the second device or the master device Bluetooth chip will be unable to send data to the corresponding receiving end in time, while the data may actually be delivered in the next second. When the timeout waiting time is fixed, the above-mentioned situations will be judged as timeout sending, and may directly cause the master device control chip of the first device to be stuck in an intermediate state and unable to continue to control the second device.
[0068] For another example, when the second device receives a mode switching request, or the main device Bluetooth chip of the first device forwards the request feedback information to the main device control chip of the first device, the current network quality of the second device or the main device Bluetooth chip is good. Under normal circumstances, the second device or the main device Bluetooth chip can shorten the time to send data to the corresponding receiving end. When the timeout waiting time is fixed, even if the current network quality can meet the fast transmission of data, it is necessary to wait until the preset timeout waiting time is exceeded before it may be judged as a timeout transmission. In the traditional solution, when a timeout transmission is detected, an error will be reported to remind the user to restart the current first device. If the timeout waiting time is set to be long, the abnormal problem will be prolonged because it is not handled in time.
[0069] In summary, since setting the timeout waiting time too long or too short will bring adverse effects, in this embodiment, by obtaining the target parameter value corresponding to the preset parameter currently used to affect the communication quality when initiating a mode switching request to the second device, the target parameter value is input into the pre-trained time determination model to perform a time prediction operation, and the predicted timeout waiting time is obtained, so that the timeout waiting time is a result of dynamic adjustment, and a suitable value can be determined according to the actual usage scenario, thereby avoiding unnecessary negative effects caused by the timeout waiting time being set too long or too short.
[0070] S103: monitoring the execution result of the mode switching request.
[0071] It should be noted that if the master device Bluetooth chip of the first device fails to upload the success event or failure event sent by the second device to the master device control chip within the agreed time due to the device's own reasons or environmental interference, the connection state between the master device control chip and the master device Bluetooth chip will remain in an intermediate state, resulting in the inability of the subsequent device control chip to send any instructions to the master device Bluetooth chip. The most direct impact at this time is that the relevant Bluetooth remote control command cannot be sent to the second device through the first device, causing the first device to fail to control the second device. Therefore, in this embodiment, it is necessary to monitor the execution result of the mode switching request and perform corresponding operations according to the execution result.
[0072] S104: If the execution result is that no request feedback information is received within the timeout waiting time, the instruction issuing authority of the first device is revoked.
[0073] When the execution result is that the request feedback information returned by the second device is not received after the timeout waiting time, in order to avoid the connection state between the master device control chip and the master device Bluetooth chip being stuck in an intermediate state, resulting in the subsequent device control chip being unable to send any instructions to the master device Bluetooth chip. In this embodiment, by revoking the instruction sending authority of the master device control chip in the first device, conditions are created for the first device to re-initiate a mode switching request to the second device.
[0074] S105: Re-initiate a mode switching request to the second device.
[0075] In this embodiment, by re-initiating a mode switching request to the second device, the success rate of the mode switching is improved, and it is avoided that the first device stays in the intermediate state for a long time, resulting in the first device being unable to continue to control the second device.
[0076] At the same time, since the present solution obtains the target parameter value corresponding to the current preset parameter and redetermines the timeout waiting time each time it detects that no request feedback information is received after the timeout waiting time, it is possible to set the timeout waiting time to a smaller value when the timeout waiting time meets the downward adjustment requirements, so that the first device can promptly re-initiate a mode switching request to the second device, so that the second device can quickly respond to the mode switching request.
[0077] In some embodiments, Figure 2 As shown, before S101, the method further includes the following steps:
[0078] During the process of establishing a Bluetooth connection between the first device and the second device, a preset parameter value generated during each link management protocol interaction is obtained.
[0079] In this embodiment, the preset parameters refer to various parameters that can affect the communication quality, and may include but are not limited to the following parameters:
[0080] The device type of the second device, such as TV, mobile phone, speaker, headset, computer, etc.
[0081] The delay value is the average time of the first five times from the first device sending the link management protocol to the second device and then receiving the feedback information from the second device (preferably the average time corresponding to the five most recent times of sending the link management protocol is calculated).
[0082] Signal strength (RSSI) value.
[0083] The number of retransmissions, that is, the average number of retransmissions required by the first device from sending the link management protocol to hitting the second device in the first five times (preferably, the average number of times corresponding to the five most recent times of sending the link management protocol is calculated).
[0084] The initial time determination model is trained by using each of the preset parameter values as a model training sample, and the model parameters of the initial time determination model are adjusted using a stochastic gradient descent algorithm until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
[0085] In this embodiment, the stochastic gradient descent (SGD) algorithm is used to train the model and change the parameters of the model. During the training process, the stochastic gradient descent algorithm optimizes the performance of the model by iteratively adjusting the parameters of the model to minimize the loss function. Specifically, the stochastic gradient descent algorithm calculates the gradient of the loss function with respect to the model parameters at each iteration, and updates the parameters of the model based on these gradients and the learning rate. This process continues until the loss function value of the model reaches a preset threshold, or the performance of the model is no longer significantly improved.
[0086] In some embodiments, Figure 2 As shown, after S103, the method further includes the following steps:
[0087] S1031: If the execution result is that the switching permission feedback information returned by the second device is received within the timeout waiting period, the current communication mode between the first device and the second device is switched to the breathing mode.
[0088] In this embodiment, when it is detected that the first device receives the feedback information of allowing switching returned by the second device, and the information is received within the timeout waiting period, and it indicates that the agreement of the breathing mode has been completed between the first device and the second device, the current communication mode between the first device and the second device can be switched to the breathing mode. It should be noted that the feedback information of allowing switching is specifically first uploaded to the main device Bluetooth chip of the first device, and then uploaded to the main device control chip of the first device by the main device Bluetooth chip.
[0089] S1032: If the execution result is that a rejection switching feedback information returned by the second device is received within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or a prompt message containing the rejection switching feedback information is generated to prompt the user.
[0090] In this embodiment, when it is detected that the first device receives the feedback information of allowing switching returned by the second device, and the information is received within the timeout waiting period, indicating that the second device rejects the mode switching request initiated by the first device, the current communication mode between the first device and the second device is maintained. It should be noted that the feedback information of rejecting switching is first uploaded to the main device Bluetooth chip of the first device, and then uploaded to the main device control chip of the first device by the main device Bluetooth chip.
[0091] In some other embodiments, a prompt message including feedback information of rejecting switching may be generated to prompt the user, for example, "the second device cannot be switched to the breathing mode temporarily because there are important files to be transferred."
[0092] In some embodiments, Figure 3 As shown, before S105, the method further includes the following steps:
[0093] S1041, obtaining the number of repetitions of the current mode switching request;
[0094] In this embodiment, since the first device repeatedly initiated the mode switching request many times but failed to receive the request feedback information within the timeout waiting period, it may be because there is a device abnormality or other unknown reasons in the first device or the second device. If the mode switching request continues to be repeatedly initiated to the second device indefinitely at this time, not only will it be impossible to prompt the user in time to take intervention measures to solve the current problem of being unable to control the second device normally, but it will also cause a waste of system resources.
[0095] S1042, determining whether the number of repeated initiations exceeds a preset number.
[0096] S1043: If the number of repeated initiations exceeds a preset number, stop initiating the mode switching request to the second device, and generate a device abnormality message to prompt the user.
[0097] In this embodiment, the number of repeated initiations can be set, for example three times. If the request feedback information cannot be received within the timeout waiting period after more than three times, the mode switching request to the second device is stopped, and a device abnormality message is generated to prompt the user. The user can try to repair it by restarting the device or disconnecting and reconnecting Bluetooth.
[0098] In some embodiments, Figure 4 As shown, before S101, the method further includes the following steps:
[0099] S1011, checking the role status of the first device in the current Bluetooth local area network, where the role status includes a central device or a peripheral device.
[0100] It needs to be explained that in Bluetooth technology, devices in a Bluetooth local area network are generally divided into two roles: central devices (Central) and peripheral devices (Peripheral), which is the basis of the Bluetooth low energy (BLE) communication mode.
[0101] Central: The central device is responsible for discovering and connecting to peripheral devices. In a Bluetooth LAN, the central device usually plays the role of a client, which can actively search for peripheral devices and establish connections with them. Once the connection is established, the central device can read or write the services and characteristics of the peripheral device.
[0102] Peripheral: A peripheral device provides services and characteristics that can be discovered and connected by a central device. In a Bluetooth LAN, a peripheral device usually plays the role of a server, broadcasting its existence and available services so that a central device can discover and interact with it.
[0103] S1012: If the role status of the first device is a central device, increase the initial polling interval between the first device and the second device without exceeding a preset maximum polling interval.
[0104] In this embodiment, when the first device initiates a mode switching request to the second device, it needs to first ensure that it is the central device in the current Bluetooth local area network, so that the first device has the authority to modify the polling interval. The polling interval refers to how often the first device sends a polling command to query the status or data of the second device to ensure that the first device and the second device can maintain a connection.
[0105] Allow the first device with the permission to modify the polling interval to increase the initial polling interval without exceeding the maximum polling interval, so that the first device and the second device can maintain a connection state without occupying too many system resources due to frequent polling operations, reducing the impact of the first device in the process of initiating a mode switching request to the second device, thereby improving the success rate of mode switching.
[0106] In some embodiments, Figure 4 As shown, after S1011, the method further includes the following steps:
[0107] S1013, if the role status of the first device is a peripheral device, initiate a role exchange request to the central device in the current Bluetooth local area network to change the role status of the first device to a central device, so that the first device has the right to modify the polling interval between the first device and the second device.
[0108] In this embodiment, since the first device needs to ensure that it is the central device in the Bluetooth local area network when initiating a mode switching request, it is necessary to initiate a role swap request to the central device in the current Bluetooth local area network when confirming that the first device is not currently the central device, that is, to initiate a master-slave role swap request, so that the first device has the authority to modify the polling interval.
[0109] S1014: Based on the modification authority, increase the initial polling interval between the first device and the second device without exceeding a preset maximum polling interval.
[0110] In this embodiment, the first device having the permission to modify the polling interval increases the initial polling interval without exceeding the maximum polling interval, so that the first device and the second device can maintain a connection without occupying too many system resources due to frequent polling operations, thereby reducing the impact of the first device in initiating a mode switching request to the second device, thereby improving the success rate of the mode switching.
[0111] As can be seen from the above, the communication mode switching method based on Bluetooth connection provided by the embodiment of the present application initiates a mode switching request to the second device when the trigger condition for turning on the breathing mode is detected, and freezes the instruction issuing authority of the first device; records the initiation time of the mode switching request, and obtains the target parameter value corresponding to the preset parameter currently used to affect the communication quality, and inputs the target parameter value into the pre-trained time determination model for time prediction operation to obtain the predicted timeout waiting time; monitors the execution result of the mode switching request; if the execution result is that the request feedback information is not received after the timeout waiting time, the instruction issuing authority of the first device is released, and the mode switching request is re-initiated to the second device. Using the communication mode switching method based on Bluetooth connection provided by the embodiment of the present application, by setting a reasonable timeout waiting time, if the first device does not receive the request feedback information sent by the second device within the timeout waiting time, the instruction issuing authority of the first device is released, and the mode switching request is re-initiated to the second device, so as to improve the success rate of the communication mode switching, and avoid the first device from being unable to control the second device normally due to the lack of instruction issuing authority. Moreover, the timeout waiting time is dynamically generated according to the current usage scenario, which can better meet the current usage scenario and avoid the problem that the first device fails to normally receive the request feedback information due to early or delayed re-initiating of the mode switching request to the second device.
[0112] In some embodiments, Figure 5 In the illustrated embodiment, the method may also be applied to a second device, comprising the following steps:
[0113] S201: Receive a mode switching request initiated by a first device.
[0114] This step can be found in Figure 1 The content of step S101 can be understood by referring to the above, and will not be elaborated here.
[0115] S202: Generate corresponding request feedback information according to the mode switching request, and send the request feedback information to the first device.
[0116] In this embodiment, corresponding request feedback information is given according to the mode switching request initiated by the first device, and the request feedback information is sent to the first device, so that the first device can perform corresponding operations according to the request feedback information.
[0117] S203: If the request feedback information is switching permission feedback information, switch the current communication mode between the first device and the second device to a breathing mode.
[0118] This step can be found in Figure 2 The content of step S1031 can be understood by referring to the figure, and will not be elaborated here.
[0119] S204: If the request feedback information is switching rejection feedback information, the current communication mode between the first device and the second device is not changed.
[0120] This step can be found in Figure 2 The content of step S1032 can be understood by referring to the above, and will not be elaborated here.
[0121] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0122] In specific implementation, the present application is not limited by the execution order of the various steps described. If no conflict occurs, some steps can be performed in other orders or simultaneously.
[0123] As can be seen from the above, the communication mode switching method based on Bluetooth connection provided in the embodiment of the present application receives a mode switching request initiated by the first device; generates corresponding request feedback information according to the mode switching request, and sends the request feedback information to the first device; if the request feedback information is feedback information for allowing switching, the current communication mode between the first device and the second device is switched to the breathing mode; if the request feedback information is feedback information for rejecting switching, the current communication mode between the first device and the second device is not changed. Using the communication mode switching method based on Bluetooth connection provided in the embodiment of the present application, it is possible to give corresponding request feedback information according to the mode switching request initiated by the first device and perform corresponding operations.
[0124] An embodiment of the present application also provides a communication mode switching device based on Bluetooth connection, and the communication mode switching device based on Bluetooth connection can be integrated in an electronic device.
[0125] See also Figure 6 , Figure 6 A schematic diagram of the structure of a communication mode switching device based on Bluetooth connection provided in an embodiment of the present application. The communication mode switching device 30 based on Bluetooth connection may include:
[0126] The detection module 31 is used to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when a trigger condition for starting the breathing mode is detected;
[0127] A prediction module 32, used to record the initiation time of the mode switching request, and obtain a target parameter value corresponding to a preset parameter currently used to affect the communication quality, and input the target parameter value into a pre-trained time determination model to perform a time prediction operation to obtain a predicted timeout waiting time;
[0128] A monitoring module 33, used to monitor the execution result of the mode switching request;
[0129] A release module 34, if the execution result is that no request feedback information is received within the timeout waiting time, then releasing the instruction issuing authority of the first device;
[0130] The retry module 35 is used to re-initiate a mode switching request to the second device.
[0131] In some embodiments, the device also includes a training module for obtaining preset parameter values generated during each link management protocol interaction during the process of establishing a Bluetooth connection between the first device and the second device; using each of the preset parameter values as a model training sample to train the initial time determination model, and using a stochastic gradient descent algorithm to adjust the model parameters of the initial time determination model until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
[0132] In some embodiments, the device also includes an execution module, which is used to switch the current communication mode between the first device and the second device to the breathing mode if the execution result is that feedback information allowing switching is received from the second device within the timeout waiting period; if the execution result is that feedback information rejecting switching is received from the second device within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or a prompt message containing the feedback information rejecting switching is generated to prompt the user.
[0133] In some embodiments, the apparatus further comprises an acquisition module for acquiring the number of repeated initiations of the current mode switching request; if the number of repeated initiations exceeds a preset number, the mode switching request to the second device is stopped, and a device abnormality message is generated to prompt the user.
[0134] In some embodiments, the device also includes a viewing module for viewing the role status of the first device in the current Bluetooth local area network, and the role status includes a central device or a peripheral device; if the role status of the first device is a central device, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0135] In some embodiments, the device also includes a modification module, which is used to initiate a role swap request to the central device in the current Bluetooth local area network if the role status of the first device is a peripheral device, so as to modify the role status of the first device to a central device, so that the first device has the modification authority to modify the polling interval between the first device and the second device; based on the modification authority, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0136] In specific implementation, the above modules can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same entity or several entities.
[0137] As can be seen from the above, the communication mode switching device 30 based on Bluetooth connection provided in the embodiment of the present application, wherein the detection module 31 is used to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when the trigger condition for starting the breathing mode is detected; the prediction module 32 is used to record the initiation time of the mode switching request, and obtain the target parameter value corresponding to the preset parameter currently used to affect the communication quality, and input the target parameter value into the pre-trained time determination model to perform a time prediction operation to obtain the predicted timeout waiting time; the monitoring module 33 is used to monitor the execution result of the mode switching request; the release module 34 is used to release the instruction issuing authority of the first device if the execution result is that no request feedback information is received after the timeout waiting time; the retry module 35 is used to re-initiate the mode switching request to the second device.
[0138] See also Figure 7 , Figure 7 Another structural diagram of a communication mode switching device based on Bluetooth connection provided in an embodiment of the present application, the communication mode switching device based on Bluetooth connection 30 includes a memory 120, one or more processors 180, and one or more applications, wherein the one or more applications are stored in the memory 120 and configured to be executed by the processor 180; the processor 180 may include a detection module 31, a prediction module 32, a monitoring module 33, a release module 34, and a retry module 35. For example, the structure and connection relationship of the above components can be as follows:
[0139] The memory 120 can be used to store applications and data. The applications stored in the memory 120 include executable codes. The applications can be composed of various functional modules. The processor 180 executes various functional applications and data processing by running the applications stored in the memory 120. In addition, the memory 120 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 120 may also include a memory controller to provide the processor 180 with access to the memory 120.
[0140] The processor 180 is the control center of the device, and uses various interfaces and lines to connect various parts of the entire terminal, and executes various functions of the device and processes data by running or executing applications stored in the memory 120, and calling data stored in the memory 120, so as to monitor the device as a whole. Optionally, the processor 180 may include one or more processing cores; preferably, the processor 180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs.
[0141] Specifically in this embodiment, the processor 180 will load the executable code corresponding to the process of one or more applications into the memory 120 according to the following instructions, and the processor 180 will run the application stored in the memory 120 to implement various functions:
[0142] A detection instruction, used to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when a trigger condition for turning on the breathing mode is detected;
[0143] A prediction instruction, used to record the initiation time of the mode switching request, and obtain a target parameter value corresponding to a preset parameter currently used to affect communication quality, input the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtain a predicted timeout waiting time;
[0144] A monitoring instruction, used to monitor the execution result of the mode switching request;
[0145] A release instruction, used to release the instruction issuing authority of the first device if the execution result is that no request feedback information is received within the timeout waiting time;
[0146] A retry instruction is used to re-initiate a mode switching request to the second device.
[0147] In some embodiments, the program also includes training instructions for obtaining preset parameter values generated during each link management protocol interaction during the process of establishing a Bluetooth connection between the first device and the second device; using each of the preset parameter values as a model training sample to train the initial time determination model, and using a stochastic gradient descent algorithm to adjust the model parameters of the initial time determination model until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
[0148] In some embodiments, the program also includes execution instructions for switching the current communication mode between the first device and the second device to the breathing mode if the execution result is that feedback information allowing switching is received from the second device within the timeout waiting period; if the execution result is that feedback information rejecting switching is received from the second device within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or a prompt message containing the feedback information rejecting switching is generated to prompt the user.
[0149] In some embodiments, the program also includes an acquisition instruction for obtaining the number of repeated initiations of the current mode switching request; if the number of repeated initiations exceeds a preset number, stop initiating the mode switching request to the second device and generate a device abnormality message to prompt the user.
[0150] In some embodiments, the program also includes viewing instructions for viewing the role status of the first device in the current Bluetooth local area network, the role status including central device or peripheral device; if the role status of the first device is a central device, then the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0151] In some embodiments, the program also includes a modification instruction for initiating a role swap request to a central device in the current Bluetooth local area network if the role status of the first device is a peripheral device, so as to change the role status of the first device to a central device, so that the first device has the modification authority to modify the polling interval between the first device and the second device; based on the modification authority, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0152] The present application also provides an electronic device. Figure 8 , Figure 8 The electronic device 1200 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device can be used to implement the communication mode switching method based on Bluetooth connection provided in the above embodiment. The electronic device 1200 can be a gateway, a smart phone, or a tablet computer.
[0153] like Figure 8 As shown, the electronic device 1200 may include an RF (Radio Frequency) circuit 110, a memory 120 including one or more (only one is shown in the figure) computer-readable storage media, an input unit 130, a display unit 140, a sensor 150, an audio circuit 160, a transmission module 170, a processor 180 including one or more (only one is shown in the figure) processing cores, and a power supply 190. Those skilled in the art will understand that Figure 8 The structure of the electronic device 1200 shown in the figure does not constitute a limitation on the electronic device 1200, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0154] The RF circuit 110 is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices. The RF circuit 110 may include various existing circuit elements for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption / decryption chip, a user identity module (SIM) card, a memory, etc. The RF circuit 110 can communicate with various networks such as the Internet, an intranet, a wireless network, or communicate with other devices through a wireless network.
[0155] The memory 120 can be used to store software programs and modules, such as the program instructions / modules corresponding to the communication mode switching method based on Bluetooth connection in the above embodiment. The processor 180 executes various functional applications and data processing by running the software programs and modules stored in the memory 120. The vibration reminder mode can be automatically selected according to the current scene of the electronic device to switch the communication mode based on Bluetooth connection, which can not only ensure that scenes such as meetings are not disturbed, but also ensure that users can perceive incoming calls, thereby improving the intelligence of the electronic device. The memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 120 may further include a memory remotely arranged relative to the processor 180, and these remote memories may be connected to the electronic device 1200 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0156] The input unit 130 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, the input unit 130 may include a touch-sensitive surface 131 and other input devices 132. The touch-sensitive surface 131, also known as a touch display screen or a touch pad, can collect the user's touch operations on or near it (such as the user's operation on or near the touch-sensitive surface 131 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface 131 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 180, and can receive and execute commands sent by the processor 180. In addition, the touch-sensitive surface 131 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface 131, the input unit 130 may further include other input devices 132. Specifically, the other input devices 132 may include, but are not limited to, one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0157] The display unit 140 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device 1200, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 140 may include a display panel 141. Optionally, the display panel 141 may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. Further, the touch-sensitive surface 131 may cover the display panel 141. When the touch-sensitive surface 131 detects a touch operation on or near it, it is transmitted to the processor 180 to determine the type of touch event. Subsequently, the processor 180 provides corresponding visual output on the display panel 141 according to the type of touch event. Although in Figure 8 In the embodiment, the touch-sensitive surface 131 and the display panel 141 are implemented as two independent components to realize the input and output functions. However, in some embodiments, the touch-sensitive surface 131 and the display panel 141 can be integrated to realize the input and output functions.
[0158] The electronic device 1200 may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 141 and / or the backlight when the electronic device 1200 is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured in the electronic device 1200, they will not be repeated here.
[0159] The audio circuit 160, the speaker 161, and the microphone 162 can provide an audio interface between the user and the electronic device 1200. The audio circuit 160 can transmit the received audio data to the speaker 161 after converting the received audio data into an electrical signal, which is converted into a sound signal for output by the speaker 161; on the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, and then the audio data is processed by the output processor 180, and then sent to another terminal through the RF circuit 110, or the audio data is output to the memory 120 for further processing. The audio circuit 160 may also include an earplug jack to provide communication between an external headset and the electronic device 1200.
[0160] The electronic device 1200 can help users send and receive emails, browse web pages, and access streaming media through the transmission module 170 (such as a Wi-Fi module), which provides users with wireless broadband Internet access. Figure 8 The transmission module 170 is shown, but it is understandable that it is not an essential component of the electronic device 1200 and can be omitted as needed without changing the essence of the invention.
[0161] The processor 180 is the control center of the electronic device 1200. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, it executes various functions of the electronic device 1200 and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 180 may include one or more processing cores; in some embodiments, the processor 180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 180.
[0162] The electronic device 1200 also includes a power supply 190 for supplying power to various components. In some embodiments, the power supply can be logically connected to the processor 180 through a power management system, so that the power management system can realize functions such as managing discharge and power consumption. The power supply 190 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0163] Although not shown, the electronic device 1200 may also include a camera (such as a front camera, a rear camera), a Bluetooth module, etc., which will not be described in detail here. Specifically in this embodiment, the display unit 140 of the electronic device 1200 is a touch screen display, and the electronic device 1200 also includes a memory 120, and one or more programs, wherein one or more programs are stored in the memory 120, and are configured to be executed by one or more processors 180. One or more programs include instructions for performing the following operations:
[0164] A detection instruction, used to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when a trigger condition for turning on the breathing mode is detected;
[0165] A prediction instruction, used to record the initiation time of the mode switching request, and obtain a target parameter value corresponding to a preset parameter currently used to affect communication quality, input the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtain a predicted timeout waiting time;
[0166] A monitoring instruction, used to monitor the execution result of the mode switching request;
[0167] A release instruction, used to release the instruction issuing authority of the first device if the execution result is that no request feedback information is received within the timeout waiting time;
[0168] A retry instruction is used to re-initiate a mode switching request to the second device.
[0169] In some embodiments, the program also includes training instructions for obtaining preset parameter values generated during each link management protocol interaction during the process of establishing a Bluetooth connection between the first device and the second device; using each of the preset parameter values as a model training sample to train the initial time determination model, and using a stochastic gradient descent algorithm to adjust the model parameters of the initial time determination model until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
[0170] In some embodiments, the program also includes execution instructions for switching the current communication mode between the first device and the second device to the breathing mode if the execution result is that feedback information allowing switching is received from the second device within the timeout waiting period; if the execution result is that feedback information rejecting switching is received from the second device within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or a prompt message containing the feedback information rejecting switching is generated to prompt the user.
[0171] In some embodiments, the program also includes an acquisition instruction for obtaining the number of repeated initiations of the current mode switching request; if the number of repeated initiations exceeds a preset number, stop initiating the mode switching request to the second device and generate a device abnormality message to prompt the user.
[0172] In some embodiments, the program also includes viewing instructions for viewing the role status of the first device in the current Bluetooth local area network, the role status including central device or peripheral device; if the role status of the first device is a central device, then the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0173] In some embodiments, the program also includes a modification instruction for initiating a role swap request to a central device in the current Bluetooth local area network if the role status of the first device is a peripheral device, so as to change the role status of the first device to a central device, so that the first device has the modification authority to modify the polling interval between the first device and the second device; based on the modification authority, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
[0174] The embodiment of the present application also provides an electronic device, which may be a smart phone, a computer or other device.
[0175] As can be seen from the above, the embodiment of the present application provides an electronic device 1200, and the electronic device 1200 performs the following steps:
[0176] When a trigger condition for starting the breathing mode is detected, a mode switching request is initiated to the second device, and the instruction issuing authority of the first device is frozen;
[0177] Recording the initiation time of the mode switching request, and obtaining a target parameter value corresponding to a preset parameter currently used to affect communication quality, inputting the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtaining a predicted timeout waiting time;
[0178] monitoring the execution result of the mode switching request;
[0179] If the execution result is that no request feedback information is received within the timeout waiting time, the instruction issuing authority of the first device is released;
[0180] Re-initiate a mode switching request to the second device.
[0181] In some embodiments, the electronic device 1200 further performs the following steps:
[0182] receiving a mode switching request initiated by a first device;
[0183] Generate corresponding request feedback information according to the mode switching request, and send the request feedback information to the first device;
[0184] If the request feedback information is switching permission feedback information, switching the current communication mode between the first device and the second device to a breathing mode;
[0185] If the request feedback information is switching rejection feedback information, the current communication mode between the first device and the second device is not changed.
[0186] An embodiment of the present application further provides a storage medium, in which a computer program is stored. When the computer program is executed on a computer, the computer executes the communication mode switching method based on Bluetooth connection described in any of the above embodiments.
[0187] It should be noted that, for the communication mode switching method based on Bluetooth connection described in the present application, ordinary testers in the field can understand that all or part of the process of implementing the communication mode switching method based on Bluetooth connection described in the embodiment of the present application can be completed by controlling the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, such as stored in the memory of an electronic device, and executed by at least one processor in the electronic device, and the execution process may include the process of the embodiment of the communication mode switching method based on Bluetooth connection. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM, Read Only Memory), a random access memory (RAM, Random Access Memory), etc.
[0188] For the communication mode switching device based on Bluetooth connection in the embodiment of the present application, each functional module can be integrated into a processing chip, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium, such as a read-only memory, a disk or an optical disk.
[0189] The above is a detailed introduction to the communication mode switching method, device, medium and equipment based on Bluetooth connection provided by the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A communication mode switching method based on Bluetooth connection, applied to a first device, characterized in that: include: When a trigger condition for starting the breathing mode is detected, a mode switching request is initiated to the second device, and the instruction issuing authority of the first device is frozen; Recording the initiation time of the mode switching request, and obtaining a target parameter value corresponding to a preset parameter currently used to affect communication quality, inputting the target parameter value into a pre-trained time determination model to perform a time prediction operation, and obtaining a predicted timeout waiting time; monitoring the execution result of the mode switching request; If the execution result is that no request feedback information is received within the timeout waiting time, the instruction issuing authority of the first device is released; Re-initiate a mode switching request to the second device.
2. The communication mode switching method according to claim 1, characterized in that: Before initiating the mode switching request to the second device, the method further includes: During the process of establishing a Bluetooth connection between the first device and the second device, obtaining a preset parameter value generated during each link management protocol interaction; The initial time determination model is trained using each of the preset parameter values as a model training sample, and the model parameters of the initial time determination model are adjusted using a stochastic gradient descent algorithm until the loss function value of the initial time determination model exceeds a preset threshold, completing the model training and obtaining a pre-trained time determination model.
3. The communication mode switching method according to claim 1, characterized in that: After monitoring the execution result of the mode switching request, the method further includes: If the execution result is that the switching permission feedback information returned by the second device is received within the timeout waiting time, the current communication mode between the first device and the second device is switched to the breathing mode; If the execution result is that the rejection switching feedback information returned by the second device is received within the timeout waiting period, the current communication mode between the first device and the second device is not changed; and / or a prompt message containing the rejection switching feedback information is generated to prompt the user.
4. The communication mode switching method according to claim 1, characterized in that: Before re-initiating the mode switching request to the second device, the method further includes: Obtain the number of repetitions of the current mode switching request; If the number of repeated initiations exceeds a preset number, the mode switching request to the second device is stopped, and a device abnormality message is generated to prompt the user.
5. The communication mode switching method according to claim 1, characterized in that: Before initiating the mode switching request to the second device, the method further includes: Checking the role status of the first device in the current Bluetooth local area network, where the role status includes a central device or a peripheral device; If the role status of the first device is a central device, the initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
6. The communication mode switching method according to claim 5, characterized in that: After checking the role status of the first device in the current Bluetooth local area network, the method further includes: If the role status of the first device is a peripheral device, a role exchange request is initiated to a central device in the current Bluetooth local area network to change the role status of the first device to a central device, so that the first device has the modification authority to modify the polling interval between the first device and the second device; Based on the modification authority, an initial polling interval between the first device and the second device is increased without exceeding a preset maximum polling interval.
7. A communication mode switching method based on Bluetooth connection, applied to a second device, characterized in that: include: receiving a mode switching request initiated by a first device; Generate corresponding request feedback information according to the mode switching request, and send the request feedback information to the first device; If the request feedback information is switching permission feedback information, switching the current communication mode between the first device and the second device to a breathing mode; If the request feedback information is switching rejection feedback information, the current communication mode between the first device and the second device is not changed.
8. A communication mode switching device based on Bluetooth connection, applied to a first device, characterized in that: The communication mode switching device based on Bluetooth connection includes: A detection module, configured to initiate a mode switching request to the second device and freeze the instruction issuing authority of the first device when a trigger condition for starting the breathing mode is detected; A prediction module, used to record the initiation time of the mode switching request, and obtain a target parameter value corresponding to a preset parameter currently used to affect the communication quality, and input the target parameter value into a pre-trained time determination model to perform a time prediction operation to obtain a predicted timeout waiting time; A monitoring module, used for monitoring the execution result of the mode switching request; a release module, configured to release the instruction issuing authority of the first device if the execution result is that no request feedback information is received within the timeout waiting time; A retry module is used to re-initiate a mode switching request to the second device.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the communication mode switching method based on Bluetooth connection according to any one of claims 1 to 7.
10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions, and the processor loads the instructions to execute the communication mode switching method based on Bluetooth connection according to any one of claims 1 to 7.
