Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be within the scope of the present application based on the embodiments of the present application.
The embodiment of the application provides a communication mode switching method based on Bluetooth connection, which is utilized to set a reasonable overtime waiting time, if a first device does not receive request feedback information sent by a second device within the overtime waiting time, the instruction issuing authority of the first device is released, and a mode switching request is initiated to the second device again, so that the success rate of communication mode switching is improved, and the situation that the second device cannot be controlled normally due to the lack of the instruction issuing authority of the first device is avoided. And the timeout waiting time is dynamically generated according to the current use scene, so that the method can be more in line with the current use scene, and the problem that the first device fails to normally receive the request feedback information due to the fact that the mode switching request is re-initiated to the second device in advance or delayed is avoided.
The term "and/or" appearing in the present application may be an association relationship describing the association object, and indicates that three relationships may exist, for example, a and/or B, and may indicate that a exists alone, while a and B exist together, and B exists alone. In the present application, the character "/" generally indicates that the front and rear related objects are an or relationship.
The terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to only those steps or modules that are expressly listed or inherent to such process, method, article, or apparatus. The naming or numbering of the steps in the present application does not mean that the steps in the method flow must be executed according to the time/logic sequence indicated by the naming or numbering, and the execution sequence of the steps in the flow that are named or numbered may be changed according to the technical purpose to be achieved, so long as the same or similar technical effects can be achieved. The division of the modules in the present application is a logical division, and may be implemented in another manner in practical applications, for example, a plurality of modules may be combined or integrated in another system, or some features may be omitted or not implemented, and further, coupling or direct coupling or communication connection between the modules shown or discussed may be through some interfaces, and indirect coupling or communication connection between the modules may be electrical or other similar manners, which are not limited in the present application. The modules or sub-modules described as separate components may be physically separated or not, or may be distributed in a plurality of circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the present application.
The communication mode switching method based on Bluetooth connection, which is related to the embodiment of the application, is mainly applied to electronic equipment, and the electronic equipment can be a smart phone, a tablet personal computer, a notebook computer, a desktop computer, an intelligent household appliance, a server and the like, and is not limited herein. Alternatively, the server may be an independent physical server, or a server cluster or a distributed system formed by a plurality of physical servers, or an IoT cloud (internet of things cloud) that provides an ability to store, process, and manage data generated by the internet of things device, or a cloud server that provides a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network, a content delivery network), and a basic cloud computing service such as a big data and an artificial intelligence platform, which are not limited herein.
For easy understanding, a specific flow in the embodiments of the present application is described below, and referring to fig. 1, fig. 1 is a schematic flow diagram of an embodiment of a communication mode switching method based on bluetooth connection according to the embodiments of the present application.
In the embodiment shown in fig. 1, the method applied to the first device may include the steps of:
S101, when a triggering condition for starting a breathing mode is detected, a mode switching request is initiated to second equipment, and the instruction issuing authority of the first equipment is frozen.
It should be explained that the sniff mode is one of the classical bluetooth connection states for turning on when the bluetooth device does not need continuous communication to function to reduce power consumption. In the breathing mode, the Bluetooth device periodically disconnects and reestablishes the connection with the paired device, thereby achieving the effect of reducing energy consumption.
The breathing mode is typically not actively initiated by the device, but rather is automatically switched to the breathing mode when a trigger condition is detected to turn on the breathing mode when the device is in a hold mode or sleep mode. For example, when the first device is in the hold mode and it is detected that no data exchange occurs within the timeout waiting time, the first device may be considered to satisfy a trigger condition for starting the breathing mode, and the first device may automatically initiate a mode switching request to a second device connected to the first device via bluetooth, so as to request to switch the current communication mode to the breathing mode, so as to reduce power consumption of the device.
It should be noted that, in this scheme, the first device actually includes a master device control chip and a master 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 master device control chip firstly sends a mode switching application to the master device bluetooth chip, after the master device control chip receives the application success information fed back by the master device bluetooth chip, the master device control chip automatically enters an intermediate state (mode), and the master device control chip is not allowed to issue data to the master device bluetooth chip in the intermediate state. The main reasons include the following:
1. Avoiding collisions, the second device may need to perform some specific operations to adapt to the new communication mode during the mode switch. If the first device sends other instructions at this time, it may collide with the requirement of the second device during the mode switching, so that the second device cannot respond correctly or perform the wrong operation.
2. Ensuring stability, mode switching is a sensitive process that requires the second device to centralize the resources to complete. The prohibition instruction issuing can reduce the data quantity which needs to be processed during the mode switching period of the second equipment, and ensure the stability and success rate of the mode switching process.
3. Preventing erroneous operation, the second device may not support certain device instructions or may not respond correctly to such instructions during the mode switch. Disabling instruction issue may prevent the second device from being subject to errors or malfunctions due to attempts to perform improper operations.
4. Resource management, the second device may need to reconfigure its bluetooth stack and hardware resources when switching modes. In this process, the second device may not be able to process the new instruction, so disabling instruction issue is to avoid wasting resources and possible resulting problems.
S102, recording the initiation time of the mode switching request, acquiring a target parameter value corresponding to a preset parameter which is currently used for influencing the communication quality, inputting the target parameter value into a pre-trained time determination model for performing time prediction operation, and obtaining predicted timeout waiting time.
It should be explained that, because the bluetooth chip of the second device or the master device of the first device may be affected by network quality or system resources, there is a certain time delay when the request feedback information is sent to the master device control chip of the first device, if the influence possibly caused by the time delay is ignored, the request feedback information may be mistakenly considered to be sent abnormally, so that the master device control chip card of the first device is directly in an intermediate state, and cannot continuously control the second device.
For example, when the second device receives the mode switching request, or the bluetooth chip of the master device of the first device forwards the request feedback information to the control chip of the master device of the first device, the current network quality of the second device or the bluetooth chip of the master device is poor, which causes that the bluetooth chip of the second device or the bluetooth chip of the master device cannot timely send data to the corresponding receiving end, and in fact, the bluetooth chip of the second device or the bluetooth chip of the master device may be able to send the data in the next second. When the timeout waiting time is fixed, the above listed situation is determined to be timeout transmission, and meanwhile, the master device of the first device may directly cause the chip card to be controlled in an intermediate state, and the second device cannot be controlled continuously.
For another example, when the second device receives the mode switching request, or the master bluetooth chip of the first device forwards the request feedback information to the master control chip of the first device, the current network quality of the second device or the master bluetooth chip is better, and under normal conditions, the second device or the master bluetooth chip can shorten the time of transmitting the data to the corresponding receiving end. When the timeout waiting time is fixed, even if the current network quality can meet the requirement of rapid data transmission, the current network quality needs to wait until the preset timeout waiting time is exceeded, and the current network quality is possibly judged to be in timeout transmission.
In summary, because the timeout waiting time is set to be too long or too short to bring adverse effects, in this embodiment, when a mode switching request is initiated to the second device, a target parameter value corresponding to a preset parameter currently used to affect the communication quality is acquired, the target parameter value is input into a pre-trained time determination model to perform a time prediction operation, so as to obtain a predicted timeout waiting time, and the timeout waiting time is a dynamic adjustment result.
S103, monitoring an execution result of the mode switching request.
It should be noted that, if the bluetooth chip of the master device of the first device fails to upload a success event or a failure event sent by the second device to the control chip of the master device within a stipulated time due to the self-cause or environmental interference of the device, the connection state between the control chip of the master device and the bluetooth chip of the master device will stay in an intermediate state all the time, so that the control chip of the subsequent device cannot issue any instruction to the bluetooth chip of the master device. The most direct effect is that the related Bluetooth remote control command cannot be issued to the second device through the first device, so that the first device fails to control the second device. Therefore, in this embodiment, it is necessary to monitor the execution result of the mode switching request and execute a corresponding operation according to the execution result.
And S104, if the execution result is that the request feedback information is not received after the timeout waiting time is exceeded, releasing the instruction issuing authority of the first equipment.
When the execution result is that the request feedback information returned by the second device is not received after the timeout waiting time is exceeded, in order to avoid that the connection state between the master device control chip and the master device Bluetooth chip stays in the intermediate state all the time, the subsequent device control chip cannot send any instruction to the master device Bluetooth chip. In this embodiment, conditions are created for the first device to initiate the mode switching request to the second device again by releasing the instruction issuing authority of the control chip of the master device in the first device.
S105, re-initiating a mode switching request to the second equipment.
In this embodiment, by re-initiating the mode switching request to the second device, the success rate of mode switching is improved, so that the first device is prevented from staying in the intermediate state for a long time, and the first device cannot continuously control the second device.
Meanwhile, in the scheme, when the request feedback information is not received after the timeout waiting time is detected to be exceeded, the target parameter value corresponding to the current preset parameter is acquired, and the timeout waiting time is redetermined, so that the timeout waiting time can be set to a smaller value when the timeout waiting time meets the requirement of down regulation, the first equipment can timely reinitiate the mode switching request to the second equipment, and the second equipment can rapidly respond to the mode switching request.
In some embodiments, as shown in fig. 2, before said S101, the method further comprises the steps of:
And acquiring a preset parameter value generated during each link management protocol interaction in the process of establishing Bluetooth connection between the first equipment and the second equipment.
In this embodiment, the preset parameters refer to various parameters capable of affecting the communication quality, and may include, but are not limited to, the following parameters:
The device type of the second device, such as a television, a mobile phone, a sound box, an earphone, a computer, etc.
The delay value, i.e. the last five times the first device had sent the link management protocol from the downlink to the second device, and then to the time average of the feedback information received from the second device (preferably the time corresponding to the last five downlink management protocols was averaged).
Signal Strength (RSSI) values.
The number of retransmissions, i.e. the average of the number of retransmissions required by the first five times from the downlink management protocol to the hit of the second device (preferably the average of the number of times corresponding to the last five downlink management protocols).
And training the initial time determination model by taking each preset parameter value as a model training sample, and adjusting model parameters of the initial time determination model by using a random gradient descent algorithm until the loss function value of the initial time determination model exceeds a preset threshold value, and completing model training to obtain a pre-trained time determination model.
In this embodiment, a random gradient descent (SGD) algorithm is used to train the model and change the parameters of the model. During training, the random 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 for 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.
In some embodiments, as shown in fig. 2, after said S103, the method further comprises the steps of:
And S1031, if the execution result is that the switching permission feedback information returned by the second equipment is received within the timeout waiting time, switching the current communication mode between the first equipment and the second equipment to a breathing mode.
In this embodiment, when it is detected that the first device receives the feedback information that allows switching and is returned by the second device, and the feedback information is received within the timeout waiting time, and indicates that the engagement 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 may be switched to the breathing mode. It should be noted that, the switching feedback information is specifically allowed to be uploaded to the master device bluetooth chip of the first device first, and then uploaded to the master device control chip of the first device by the master device bluetooth chip.
S1032, if the execution result is that the refused switching feedback information returned by the second equipment is received within the timeout waiting time, the current communication mode between the first equipment and the second equipment is not changed, and/or prompt information containing the refused switching feedback information is generated to prompt the user.
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 feedback information is received within the timeout waiting time, it indicates that the second device refuses the mode switching request initiated by the first device, and at this time, the current communication mode between the first device and the second device is continuously maintained. It should be noted that, the refused switching feedback information is specifically uploaded to the master device bluetooth chip of the first device, and then uploaded to the master device control chip of the first device by the master device bluetooth chip.
In other embodiments, a prompt may also be generated to prompt the user containing refusal to switch feedback information, such as "the second device is temporarily unable to switch to respiratory mode because there are important files to transmit".
In some embodiments, as shown in fig. 3, before said S105, the method further comprises the steps of:
S1041, obtaining the repeated initiation times of the current mode switching request;
in this embodiment, since the first device repeatedly initiates the mode switching request multiple times, the feedback information of the request cannot be received within the timeout waiting time, possibly because the first device or the second device has an abnormal device or other unknown reasons, if the mode switching request is still repeatedly initiated to the second device without limitation at this time, the user cannot be prompted timely, so as to take intervention measures to solve the problem that the second device cannot be normally controlled at present, and waste of system resources is caused.
S1042, judging whether the repeated starting times exceeds the preset times.
S1043, if the repeated initiation times exceeds the preset times, stopping initiating a mode switching request to the second equipment, and generating an equipment abnormality message to prompt a user.
In this embodiment, the number of repeated initiation may be set, for example, three times, and when the request feedback information cannot be received within the timeout waiting time for more than three times, the initiation of the mode switching request to the second device is stopped, and the device exception message is generated to prompt the user, where the user may attempt to repair by restarting the device or disconnecting the reconnection bluetooth.
In some embodiments, as shown in fig. 4, before said S101, the method further comprises the steps of:
S1011, checking the role state of the first device in the current Bluetooth local area network, wherein the role state comprises a central device or a peripheral device.
It should be explained that in bluetooth technology, devices in bluetooth local area networks are generally classified into two roles, central device (Central) and Peripheral device (Peripheral), which are the basis of Bluetooth Low Energy (BLE) communication mode.
Central device (Central) the Central device is responsible for discovery and connection of peripheral devices. In bluetooth local area networks, the central device typically plays the role of a client, which can actively search for and establish a connection with peripheral devices. Once the connection is established, the central device may read or write the services and features of the peripheral device.
Peripheral devices (Peripheral) provide services and features that can be discovered and connected by the central device. In bluetooth local area networks, a peripheral device typically plays the role of a server, broadcasting its own presence and available services so that a central device can discover and interact with it.
And S1012, if the role state of the first device is central equipment, increasing the initial polling interval between the first device and the second device on the premise of not exceeding the preset maximum polling interval.
In this embodiment, when the first device initiates a mode switching request to the second device, it needs to ensure that the first device is a central device in the current bluetooth local area network, so that the first device has the authority to modify the polling interval, where the polling interval refers to how often the first device sends a polling command to query the state or data of the second device, so as to ensure that the first device and the second device can maintain a connection state.
The first device with the right of modifying the polling interval increases the initial polling interval on the premise of not exceeding the maximum polling interval, so that the first device and the second device can not only keep a connection state, but also occupy excessive system resources due to frequent polling operation, and the influence of the first device in the process of initiating a mode switching request to the second device is reduced, thereby improving the successful hit rate of mode switching.
In some embodiments, as shown in fig. 4, after said S1011, the method further comprises the steps of:
And S1013, if the role state of the first device is a peripheral device, initiating a role exchange request to a central device in the current Bluetooth local area network so as to modify the role state of the first device into the central device, so that the first device has modification authority for modifying the polling interval between the first device and the second device.
In this embodiment, since the first device needs to ensure that the first device is a central device in the bluetooth local area network when initiating the mode switching request, when confirming that the first device is not the central device, a role exchange request is initiated to the central device in the current bluetooth local area network, that is, a master-slave role exchange request is initiated, so that the first device has the authority to modify the polling interval.
S1014, based on the modification authority, increasing an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
In this embodiment, the first device having the right to modify the polling interval increases the initial polling interval on the premise that the maximum polling interval is not exceeded, so that the first device and the second device can not only maintain a connection state, but also occupy too many system resources due to frequent polling operation, and the influence of the first device in the process of initiating a mode switching request to the second device is reduced, thereby improving the successful hit rate of mode switching.
It can be seen that, according to the communication mode switching method based on bluetooth connection provided by the embodiment of the application, when the triggering condition of starting the breathing mode is detected, a mode switching request is initiated to a second device, the instruction issuing authority of the first device is frozen, the initiation time of the mode switching request is recorded, a target parameter value corresponding to a preset parameter which is currently used for influencing the communication quality is obtained, the target parameter value is input into a pre-trained time determination model to perform time prediction operation, a predicted timeout waiting time is obtained, the execution result of the mode switching request is monitored, if the execution result exceeds the timeout waiting time, the instruction issuing authority of the first device is released, and the mode switching request is initiated to the second device again. By setting a reasonable overtime waiting time, if the first device does not receive the request feedback information sent by the second device within the overtime waiting time, the instruction issuing authority of the first device is released, and the mode switching request is initiated to the second device again, so that the success rate of the communication mode switching is improved, and the situation that the second device cannot be controlled normally due to the lack of the instruction issuing authority of the first device is avoided. And the timeout waiting time is dynamically generated according to the current use scene, so that the method can be more in line with the current use scene, and the problem that the first device fails to normally receive the request feedback information due to the fact that the mode switching request is re-initiated to the second device in advance or delayed is avoided.
In some embodiments, in the embodiment shown in fig. 5, the method may also be applied to a second device, comprising the steps of:
s201, a mode switching request initiated by the first equipment is received.
This step can be understood by referring to the content of step S101 in fig. 1, and will not be described here.
S202, corresponding request feedback information is generated according to the mode switching request, and the request feedback information is sent to the first device.
In this embodiment, the 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 execute the corresponding operation according to the request feedback information.
And S203, if the request feedback information is the feedback information allowing switching, switching the current communication mode between the first equipment and the second equipment to a breathing mode.
This step can be understood by referring to the content of step S1031 in fig. 2, and will not be described here.
S204, if the request feedback information is refusal to switch feedback information, the current communication mode between the first equipment and the second equipment is not changed.
This step can be understood by referring to the content of step S1032 in fig. 2, and will not be described here.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein.
In particular, the application is not limited by the order of execution of the steps described, as some of the steps may be performed in other orders or concurrently without conflict.
It can be seen that the communication mode switching method based on bluetooth connection provided by the embodiment of the application is characterized by receiving a mode switching request initiated by a first device, generating corresponding request feedback information according to the mode switching request, sending the request feedback information to the first device, switching the current communication mode between the first device and a second device to a breathing mode if the request feedback information is feedback information allowing switching, and not changing the current communication mode between the first device and the second device if the request feedback information is feedback information refusing switching. By using the communication mode switching method based on Bluetooth connection provided by the embodiment of the application, corresponding request feedback information can be given according to the mode switching request initiated by the first equipment, and corresponding operation can be executed.
The embodiment of the application also provides a communication mode switching device based on the Bluetooth connection, which can be integrated in the electronic equipment.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a communication mode switching device based on bluetooth connection according to an embodiment of the present application. The communication mode switching device 30 based on bluetooth connection may include:
The detection module 31 is configured to initiate a mode switching request to a second device and freeze an instruction issuing authority of the first device when a triggering condition for opening a breathing mode is detected;
The prediction module 32 is configured to record an initiation time of the mode switching request, obtain a target parameter value corresponding to a preset parameter currently used for affecting communication quality, input the target parameter value into a pre-trained time determination model, and perform a time prediction operation, so as to obtain a predicted timeout waiting time;
a monitoring module 33, configured to monitor an execution result of the mode switching request;
A releasing module 34, configured to release the instruction issuing authority of the first device if the execution result is that the request feedback information is not received beyond the timeout waiting time;
a retry module 35, configured to reinitiate a mode switch request to the second device.
In some embodiments, the apparatus further includes a training module, configured to obtain preset parameter values generated during each link management protocol interaction in a process of establishing a bluetooth connection between the first device and the second device, train an initial time determination model by using each preset parameter value as a model training sample, and adjust model parameters of the initial time determination model by using a random gradient descent algorithm until a loss function value of the initial time determination model exceeds a preset threshold, complete model training, and obtain a pre-trained time determination model.
In some embodiments, the apparatus further includes an execution module, configured to switch a current communication mode between the first device and the second device to a breathing mode if the execution result is that the switching permission feedback information returned by the second device is received within a timeout waiting time, and/or generate a prompt message containing the switching refusal feedback information to prompt a user without changing the current communication mode between the first device and the second device if the execution result is that the switching refusal feedback information returned by the second device is received within the timeout waiting time.
In some embodiments, the apparatus further includes an obtaining module, configured to obtain a number of repeated initiation times of the current mode switching request, and if the number of repeated initiation times exceeds a preset number of times, stop initiating the mode switching request to the second device, and generate a device exception message to prompt a user.
In some embodiments, the apparatus further includes a checking module configured to check a role state of the first device in the current bluetooth local area network, where the role state includes a central device or a peripheral device, and if the role state of the first device is the central device, increase an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
In some embodiments, the apparatus further includes a modification module, configured to initiate a role exchange request to a central device in the current bluetooth local area network if the role state of the first device is a peripheral device, so as to modify the role state of the first device into the central device, so that the first device has a modification authority for modifying a polling interval with the second device, and increase an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded based on the modification authority.
In specific implementation, each module may be implemented as a separate entity, or may be combined arbitrarily and implemented as the same entity or several entities.
As can be seen from the foregoing, the communication mode switching device 30 based on bluetooth connection provided in the embodiments of the present application is configured to, when detecting a triggering condition for starting a breathing mode, initiate a mode switching request to a second device and freeze an instruction issuing authority of the first device, predict a module 32 configured to record an initiation time of the mode switching request, obtain a target parameter value corresponding to a preset parameter currently used for affecting communication quality, input the target parameter value into a pre-trained time determination model for performing a time prediction operation, obtain a predicted timeout waiting time, monitor a result of the mode switching request, and release a module 34 configured to release the instruction issuing authority of the first device if the execution result is that the request feedback information is not received beyond the timeout waiting time, and retry a module 35 configured to initiate the mode switching request to the second device again.
Referring to fig. 7, fig. 7 is a schematic diagram of another structure of a communication mode switching device based on bluetooth connection according to an embodiment of the application, the communication mode switching device 30 based on bluetooth connection includes a memory 120, one or more processors 180, and one or more application programs, wherein the one or more application programs are stored in the memory 120 and configured to be executed by the processor 180, and 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 structures and connection relationships of the above respective components may be as follows:
Memory 120 may be used to store applications and data. The memory 120 stores application programs including executable code. Applications may constitute various functional modules. The processor 180 executes various functional applications and data processing by running application programs stored in the memory 120. In addition, memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 120 may also include a memory controller to provide access to the memory 120 by the processor 180.
The processor 180 is a control center of the device, connects the various parts of the entire terminal using various interfaces and lines, and performs various functions of the device and processes data by running or executing application programs stored in the memory 120, and calling data stored in the memory 120, thereby performing overall monitoring of the device. Optionally, the processor 180 may include one or more processing cores, and preferably, the processor 180 may integrate an application processor and a modem processor, wherein the application processor primarily processes operating systems, user interfaces, application programs, and the like.
In particular, in this embodiment, the processor 180 loads executable codes corresponding to the processes of one or more application programs into the memory 120 according to the following instructions, and the processor 180 executes the application programs stored in the memory 120, so as to implement various functions:
The detection instruction is used for initiating a mode switching request to the second equipment when detecting a triggering condition for starting a breathing mode, and freezing the instruction issuing authority of the first equipment;
a prediction instruction, configured to record an initiation time of the mode switching request, obtain a target parameter value corresponding to a preset parameter currently used for affecting communication quality, input the target parameter value into a pre-trained time determination model, and perform a time prediction operation, so as to obtain a predicted timeout waiting time;
a monitoring instruction, configured to monitor an execution result of the mode switching request;
A release instruction, configured to release the instruction issuing authority of the first device if the execution result is that the request feedback information is not received beyond the timeout waiting time;
and the retry instruction is used for reinitiating a mode switching request to the second equipment.
In some embodiments, the program further includes training instructions for obtaining preset parameter values generated during each link management protocol interaction in the process of establishing the bluetooth connection between the first device and the second device, training an initial time determination model by using each preset parameter value as a model training sample, and adjusting model parameters of the initial time determination model by using a random gradient descent algorithm until a loss function value of the initial time determination model exceeds a preset threshold value, completing model training, and obtaining a pre-trained time determination model.
In some embodiments, the program further includes an execution instruction, configured to switch a current communication mode between the first device and the second device to a breathing mode if the execution result is that the switching permission feedback information returned by the second device is received within a timeout waiting time, and if the execution result is that the switching rejection 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 not changed, and/or generate a prompt message containing the switching rejection feedback information to prompt a user.
In some embodiments, the program further includes an acquisition instruction, configured to acquire a number of repeated initiation times of the current mode switching request, and if the number of repeated initiation times exceeds a preset number of times, stop initiating the mode switching request to the second device, and generate a device exception message to prompt a user.
In some embodiments, the program further includes a check instruction configured to check a role state of the first device in the current bluetooth local area network, where the role state includes a central device or a peripheral device, and if the role state of the first device is the central device, increasing an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
In some embodiments, the program further includes a modification instruction, configured to initiate a role exchange request to a central device in the current bluetooth local area network if the role state of the first device is a peripheral device, so as to modify the role state of the first device into the central device, so that the first device has a modification authority for modifying a polling interval with the second device, and based on the modification authority, increase an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
The embodiment of the application also provides electronic equipment. Referring to fig. 8, fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application, which may be used to implement the communication mode switching method based on bluetooth connection provided in the above embodiment. The electronic device 1200 may be a gateway or a smart phone or tablet.
As shown in fig. 8, the electronic device 1200 may include an RF (Radio Frequency) circuit 110, a memory 120 including one or more computer readable storage media (only one is shown), 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 processing cores (only one is shown), and a power supply 190. Those skilled in the art will appreciate that the configuration of the electronic device 1200 shown in fig. 8 is not limiting of the electronic device 1200 and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components. Wherein:
The RF circuit 110 is configured to receive and transmit electromagnetic waves, and to perform mutual conversion between the electromagnetic waves and the electrical signals, so as to communicate with a communication network or other devices. RF circuitry 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 Subscriber Identity Module (SIM) card, memory, and the like. The RF circuitry 110 may communicate with various networks such as the internet, intranets, wireless networks, or other devices via wireless networks.
The memory 120 may be used to store software programs and modules, such as program instructions/modules corresponding to the communication mode switching method based on bluetooth connection in the above embodiments, and the processor 180 executes various function applications and data processing by running the software programs and modules stored in the memory 120, so that the communication mode switching based on bluetooth connection can be automatically selected according to the current scene where the electronic device is located, thereby not only ensuring that the scenes such as a meeting are not disturbed, but also ensuring that the user can perceive an incoming call, and improving the intelligence of the electronic device. Memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 120 may further include memory remotely located relative to the processor 180, which may be connected to the electronic device 1200 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input unit 130 may be used to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 130 may comprise a touch sensitive surface 131 and other input devices 132. The touch sensitive surface 131, also referred to as a touch display screen or touch pad, may collect touch operations thereon or thereabout by a user (e.g., operations of the user on the touch sensitive surface 131 or thereabout by any suitable object or accessory such as a finger, stylus, etc.), and actuate the corresponding connection means according to a pre-set program. Alternatively, the touch sensitive surface 131 may comprise two parts, a touch detection device and a touch controller. The touch control controller receives touch control information from the touch control detection device, converts the touch control information into touch point coordinates, sends the touch point coordinates 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 of resistive, capacitive, infrared, surface acoustic wave, and the like. In addition to the touch-sensitive surface 131, the input unit 130 may also comprise other input devices 132. In particular, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, mouse, joystick, etc.
The display unit 140 may be used to display information entered by a user or provided to a user as well as various graphical user interfaces of the electronic device 1200, which may be composed of graphics, text, icons, video, and any combination thereof. The display unit 140 may include a display panel 141, and alternatively, the display panel 141 may be configured in the form of an LCD (Liquid CRYSTAL DISPLAY), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 131 may cover the display panel 141, and after the touch-sensitive surface 131 detects a touch operation thereon or thereabout, the touch-sensitive surface is transferred to the processor 180 to determine a type of touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of touch event. Although in fig. 8 the touch-sensitive surface 131 and the display panel 141 are implemented as two separate components for input and output functions, in some embodiments the touch-sensitive surface 131 may be integrated with the display panel 141 to implement the input and output functions.
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 that may adjust the brightness of the display panel 141 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 141 and/or the backlight when the electronic device 1200 moves to the ear. As one of the motion sensors, the gravitational acceleration sensor may detect the acceleration in each direction (generally, three axes), and may detect the gravity and direction when stationary, and may be used for applications of recognizing the gesture of the mobile phone (such as horizontal/vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer, and knocking), and other sensors such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, which may be further configured in the electronic device 1200, will not be described herein.
Audio circuitry 160, speaker 161, microphone 162 may provide an audio interface between a user and electronic device 1200. The audio circuit 160 may transmit the received electrical signal converted from audio data to the speaker 161 for conversion into sound signals for output by the speaker 161, while the microphone 162 may convert the collected sound signals into electrical signals for reception by the audio circuit 160 for conversion into audio data, for processing by the audio data output processor 180, for transmission to another terminal, for example, via the RF circuit 110, or for outputting the audio data to the memory 120 for further processing. The audio circuit 160 may also include an ear bud jack to provide communication of the peripheral headphones with the electronic device 1200.
The electronic device 1200 may facilitate user email, web browsing, streaming media access, etc. via the transmission module 170 (e.g., wi-Fi module), which provides wireless broadband internet access to the user. Although fig. 8 shows the transmission module 170, it is understood that it does not belong to the essential constitution of the electronic device 1200, and can be omitted entirely as required within the scope not changing the essence of the invention.
The processor 180 is a control center of the electronic device 1200, connects various parts of the entire handset using various interfaces and lines, and performs various functions of the electronic device 1200 and processes data by running or executing software programs and/or modules stored in the memory 120, and invoking data stored in the memory 120, thereby performing overall monitoring of the handset. Optionally, the processor 180 may include one or more processing cores, and in some embodiments, the processor 180 may integrate an application processor and a modem processor, wherein the application processor primarily processes operating systems, user interfaces, application programs, and the like, and the modem processor primarily processes wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 180.
The electronic device 1200 also includes a power supply 190 that provides power to the various components, and in some embodiments, may be logically connected to the processor 180 via a power management system to perform functions such as managing discharge, and managing power consumption via the power management system. The power supply 190 may also include one or more of any of a direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Although not shown, the electronic device 1200 may also include a camera (e.g., front camera, rear camera), a bluetooth module, etc., which are not described in detail herein. In particular, in the present embodiment, the display unit 140 of the electronic device 1200 is a touch screen display, the electronic device 1200 further includes a memory 120, and one or more programs, wherein the one or more programs are stored in the memory 120 and configured to be executed by the one or more processors 180, the one or more programs include instructions for:
The detection instruction is used for initiating a mode switching request to the second equipment when detecting a triggering condition for starting a breathing mode, and freezing the instruction issuing authority of the first equipment;
a prediction instruction, configured to record an initiation time of the mode switching request, obtain a target parameter value corresponding to a preset parameter currently used for affecting communication quality, input the target parameter value into a pre-trained time determination model, and perform a time prediction operation, so as to obtain a predicted timeout waiting time;
a monitoring instruction, configured to monitor an execution result of the mode switching request;
A release instruction, configured to release the instruction issuing authority of the first device if the execution result is that the request feedback information is not received beyond the timeout waiting time;
and the retry instruction is used for reinitiating a mode switching request to the second equipment.
In some embodiments, the program further includes training instructions for obtaining preset parameter values generated during each link management protocol interaction in the process of establishing the bluetooth connection between the first device and the second device, training an initial time determination model by using each preset parameter value as a model training sample, and adjusting model parameters of the initial time determination model by using a random gradient descent algorithm until a loss function value of the initial time determination model exceeds a preset threshold value, completing model training, and obtaining a pre-trained time determination model.
In some embodiments, the program further includes an execution instruction, configured to switch a current communication mode between the first device and the second device to a breathing mode if the execution result is that the switching permission feedback information returned by the second device is received within a timeout waiting time, and if the execution result is that the switching rejection 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 not changed, and/or generate a prompt message containing the switching rejection feedback information to prompt a user.
In some embodiments, the program further includes an acquisition instruction, configured to acquire a number of repeated initiation times of the current mode switching request, and if the number of repeated initiation times exceeds a preset number of times, stop initiating the mode switching request to the second device, and generate a device exception message to prompt a user.
In some embodiments, the program further includes a check instruction configured to check a role state of the first device in the current bluetooth local area network, where the role state includes a central device or a peripheral device, and if the role state of the first device is the central device, increasing an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
In some embodiments, the program further includes a modification instruction, configured to initiate a role exchange request to a central device in the current bluetooth local area network if the role state of the first device is a peripheral device, so as to modify the role state of the first device into the central device, so that the first device has a modification authority for modifying a polling interval with the second device, and based on the modification authority, increase an initial polling interval between the first device and the second device on the premise that a preset maximum polling interval is not exceeded.
The embodiment of the application also provides electronic equipment. The electronic equipment can be a smart phone, a computer and other equipment.
As can be seen from the above, the embodiment of the present application provides an electronic device 1200, wherein the electronic device 1200 performs the following steps:
when a triggering condition for starting a breathing mode is detected, a mode switching request is initiated to second equipment, and the instruction issuing authority of the first equipment is frozen;
recording the initiation time of the mode switching request, acquiring a target parameter value corresponding to a preset parameter which is currently used for influencing the communication quality, inputting the target parameter value into a pre-trained time determination model for performing time prediction operation, and obtaining predicted overtime waiting time;
Monitoring an 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 is exceeded, releasing the instruction issuing authority of the first equipment;
And re-initiating a mode switching request to the second equipment.
In some embodiments, the electronic device 1200 further performs the steps of:
receiving a mode switching request initiated by first equipment;
generating corresponding request feedback information according to the mode switching request, and sending the request feedback information to the first equipment;
If the feedback information request is feedback information allowing switching, switching the current communication mode between the first equipment and the second equipment to a breathing mode;
and if the request feedback information is refused to switch the feedback information, not changing the current communication mode between the first equipment and the second equipment.
The embodiment of the application also provides a storage medium, in which a computer program is stored, and when the computer program runs on a computer, the computer executes the communication mode switching method based on the Bluetooth connection according to any one of the embodiments.
It should be noted that, for the method for switching a communication mode based on a bluetooth connection according to the present application, it will be understood by those skilled in the art that all or part of the flow of implementing the method for switching a communication mode based on a bluetooth connection according to the embodiments of the present application may be implemented by controlling related hardware through a computer program, where the computer program may be stored in a computer readable storage medium, such as a memory of an electronic device, and executed by at least one processor in the electronic device, and the execution process may include the flow of the embodiment of the method for switching a communication mode based on a bluetooth connection. The storage medium may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a random access Memory (RAM, random Access Memory), or the like.
For the communication mode switching device based on bluetooth connection in the embodiment of the present application, each functional module may be integrated in one processing chip, or each module may exist physically separately, or two or more modules may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated module, if implemented as a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium such as read-only memory, magnetic or optical disk, etc.
The method, the device, the medium and the equipment for switching the communication modes based on the Bluetooth connection provided by the embodiment of the application are described in detail. While the principles and embodiments of the present application have been described in detail in this application, the foregoing embodiments are provided to facilitate understanding of the principles and concepts underlying the application, and variations in terms of specific embodiments and applications are apparent to those skilled in the art in light of the teachings herein, and in light of these teachings, this disclosure should not be construed to limit the application.