WO2023082778A1 - Method for configuring sniff interval and corresponding electronic device - Google Patents

Method for configuring sniff interval and corresponding electronic device Download PDF

Info

Publication number
WO2023082778A1
WO2023082778A1 PCT/CN2022/115426 CN2022115426W WO2023082778A1 WO 2023082778 A1 WO2023082778 A1 WO 2023082778A1 CN 2022115426 W CN2022115426 W CN 2022115426W WO 2023082778 A1 WO2023082778 A1 WO 2023082778A1
Authority
WO
WIPO (PCT)
Prior art keywords
period
default
listening
monitoring period
value
Prior art date
Application number
PCT/CN2022/115426
Other languages
French (fr)
Chinese (zh)
Inventor
索亚运
Original Assignee
荣耀终端有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 荣耀终端有限公司 filed Critical 荣耀终端有限公司
Publication of WO2023082778A1 publication Critical patent/WO2023082778A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0811Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/08Testing, supervising or monitoring using real traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/20Manipulation of established connections
    • H04W76/25Maintenance of established connections

Definitions

  • the present application relates to the technical field of communications, and in particular to a method for configuring a monitoring period and corresponding electronic equipment.
  • the mobile phone After the user's mobile phone establishes a Bluetooth connection with Bluetooth peripherals such as bracelets and watches, in order to save the power consumption of the Bluetooth peripherals, the mobile phone will control the Bluetooth peripherals to enter the monitoring mode (Sniffmode) when there is no call, music, etc. power consumption.
  • the monitoring mode in order to maintain the Bluetooth connection between the mobile phone and the Bluetooth peripheral, the mobile phone will send a heartbeat packet to the Bluetooth peripheral according to the sniff interval (Sniff interval), and the Bluetooth peripheral will reply the heartbeat packet to notify the mobile phone that the current Bluetooth peripheral is online.
  • the Bluetooth connection is not disconnected.
  • the Bluetooth peripheral device cannot correctly reply to the heartbeat packet sent by the mobile phone, which causes the mobile phone to think that the Bluetooth peripheral device is not online, and thus actively disconnects from the Bluetooth peripheral device. Therefore, there are frequent disconnections between the mobile phone and the Bluetooth peripheral in the monitoring mode.
  • the present application provides a method for configuring a monitoring period and corresponding electronic equipment, aiming at solving the problem of frequent disconnection of Bluetooth communication in the monitoring mode.
  • the present application discloses a method for configuring a listening period performed by a first device, the first device and the second device are in a Bluetooth connection state, the method includes: using the data stored in the first device for the second The monitoring period of the device is set to a non-default monitoring period, where the non-default monitoring period is used for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption period of the second device cycle. and sending information about the non-default listening period to the second device.
  • the method for configuring the monitoring period performed by the first device by setting the monitoring period stored in the first device for the second device as a non-default monitoring period instead of a default monitoring period
  • the cycle is used for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption cycle of the second device, so that the second device can
  • the monitoring period coincides with the monitoring period, so that the Bluetooth communication will not be disconnected due to the monitoring period and the interruption period.
  • the method before setting the monitoring period stored in the first device for the second device as a non-default monitoring period, the method further includes: judging whether a condition for using the default monitoring period is satisfied. When the condition for using the default monitoring period is not satisfied, the monitoring period stored in the first device for the second device is set as a non-default monitoring period.
  • the default monitoring period may not coincide with the interruption period of the second device in individual cases, or the current situation cannot use a non-default monitoring period, it is necessary to determine whether the use
  • the condition of the default monitoring period is to set the monitoring period stored in the first device for the second device as a non-default monitoring period only when the condition for using the default monitoring period is not met.
  • condition for using the default monitoring period is that the first device fails to obtain the interruption period of the second device.
  • the method before judging whether the condition for using the default monitoring period is met, the method further includes: sending an interrupt parameter acquisition command to the second device, where the interrupt parameter acquisition command is used to acquire the second device's interrupt cycle.
  • the response information corresponding to the interrupt parameter acquisition command is received, and the response information carries the interrupt period of the second device, it is determined that the condition for using the default monitoring period is satisfied.
  • the response information corresponding to the interruption parameter acquisition command is not received, or the interruption period of the second device is not carried in the response information, it is determined that the condition of using the default monitoring period is not satisfied.
  • the method further includes: determining a non-default monitoring period at least according to an interruption period of the second device.
  • determining the non-default monitoring period at least according to the interruption period of the second device includes: when the received interruption period of the second device is one, according to the received interruption period, a specific multiple , and the offset value are calculated to obtain the non-default monitoring period.
  • a non-default monitoring period is calculated according to the least common multiple, specific multiple, and offset value of the plurality of interruption periods received, or, according to the received The maximum value, specific multiple, and offset value among multiple interrupt periods of , are calculated to obtain a non-default monitoring period.
  • the specific multiple is a positive integer
  • the offset value is an integer.
  • the value of the non-default monitoring period satisfies a condition of being within a preset range, where the preset range is set according to the default monitoring period.
  • the preset range is a range in which a difference between a non-default listening period and a default listening period is less than or equal to a preset deviation value.
  • the interrupt parameter acquisition command is also used to obtain the period deviation of the second device, and the value of the non-default listening period also satisfies that the difference between the non-default listening period and the default listening period is greater than the period deviation conditions of.
  • the method further includes: when the Bluetooth communication between the first device and the second device is disconnected in the listening mode, When the number of times is greater than or equal to the disconnection threshold, the value of the listening duration of the second device is increased to a preset value to determine an updated listening duration, and information about the updated listening duration is sent to the second device.
  • the possibility of the second device being able to listen to the heartbeat packet is increased, so that the Bluetooth will not be caused by the second device not replying to the heartbeat packet. Communication is lost.
  • the condition for using the default listening period is that the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is less than a disconnection threshold.
  • the method before judging whether a condition for using the default monitoring period is met, the method further includes: sending information about the default monitoring period to the second device.
  • the second device monitors the heartbeat packet sent by the first device with a default monitoring period.
  • the non-default monitoring period is the sum of the default monitoring period and an offset value, where the offset value is an integer.
  • the value of the non-default monitoring period satisfies a condition of being within a preset range, where the preset range is set according to the default monitoring period.
  • the method further includes: when the Bluetooth communication between the first device and the second device is disconnected, the second device The value of the listening duration of the second device is increased to a preset value to determine an updated listening duration, and send information about the updated listening duration to the second device.
  • the method further includes: sending a request to the second device to exit the listening mode , and clear the number of disconnections.
  • the present application discloses an electronic device, the electronic device includes: a communication module, the communication module includes a wireless communication module, and the wireless communication module is used to execute the method performed by the first device as proposed in any one of the above first aspects. Method for configuring the listening period.
  • FIG. 1a is a schematic diagram of a scenario of a Bluetooth connection according to an embodiment of the present application
  • FIG. 1b is a schematic flow diagram of a Bluetooth communication method according to an embodiment of the present application.
  • FIG. 1c is a schematic diagram of a monitoring cycle in a monitoring mode according to an embodiment of the present application.
  • Fig. 1d is a schematic diagram of a scene where a disconnection occurs in a listening mode according to an embodiment of the present application
  • FIG. 2 is a schematic diagram of a hardware structure of a first device according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of a hardware structure of a second device according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a bluetooth protocol framework according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application
  • FIG. 6 is a schematic flowchart of calculating the listening period SN by the first device according to an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a scene of a wristband under an interruption period and a monitoring period according to an embodiment of the present application
  • Fig. 8 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application.
  • words such as “exemplary” or “for example” are used as examples, illustrations or illustrations. Any embodiment or design scheme described as “exemplary” or “for example” in the embodiments of the present application shall not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Rather, the use of words such as “exemplary” or “such as” is intended to present related concepts in a concrete manner.
  • Bluetooth technology is a radio technology that supports short-distance communication of devices. It can exchange information wirelessly among many devices including mobile terminals, wireless headsets, laptops, mobile hard drives, e-books, and related peripherals. , Vehicle equipment and other fields are widely used. After the Bluetooth connection is successful, there is only one master device in the Bluetooth system, and there can be multiple slave devices, and Bluetooth communication can be performed between the master device and the slave device.
  • the master device is a device having a master control right
  • the slave device is a device subject to the control of the master device.
  • Fig. 1a is a schematic diagram of a scenario of a Bluetooth connection according to an embodiment of the present application.
  • the mobile phone 101 is the master device, and establishes Bluetooth connections with the earphone 102 and the wristband 103 respectively, and both the earphone 102 and the wristband 103 are slave devices of the mobile phone 101 .
  • the master device is collectively referred to as the first device, and the slave devices are collectively referred to as the second device.
  • Fig. 1b is a schematic flowchart of a Bluetooth communication method according to an embodiment of the present application. Referring to Figure 1b, the Bluetooth communication process between the first device and the second device is:
  • step S101 a Bluetooth connection is established between the first device and the second device.
  • step S102 after the first device and the second device establish a Bluetooth connection, the first device and the second device directly enter into an active mode (Active mode).
  • Active mode an active mode
  • step S103 after the first device finds that there is currently no data interaction requirement, it sends a request to the second device to enter the monitoring mode, wherein the request to enter the monitoring mode carries a fixed monitoring period parameter.
  • the second device usually has a requirement for low power consumption.
  • the second device is a device of an embedded system such as a Bluetooth peripheral, and the embedded system has a requirement for low power consumption. Therefore, in order to reduce power consumption, the first device can control the second device to enter the listening mode from the working mode (Active mode) when the second device is not required to perform services such as calls, music, and data transmission (that is, when there is no need for data interaction). mode to reduce the power consumption of the second device.
  • the value of the monitoring period is a fixed value preconfigured by the first device (ie, the default monitoring period).
  • step S104 the second device enters the listening mode in response to the request for entering the listening mode.
  • the second device When the second device is in the listening mode, the second device can periodically wake up and listen according to the listening cycle sent by the first device, and no longer needs to send data to the second device every time slice (master -to-slave slot) are monitored to achieve the purpose of saving power consumption.
  • the 4 master-to-slave slots are a monitoring cycle, that is, monitoring once every 4 time slices to obtain the data sent by the first device to the second device to save power consumption.
  • one time slice is, for example, 0.625ms.
  • step S105 the first device sends a heartbeat packet to the second device according to a fixed monitoring period.
  • the first device In the monitoring mode, the first device needs to periodically send a heartbeat packet to the second device according to a fixed monitoring period to ensure the effective survival of the Bluetooth connection.
  • the first device notifies the second device that it is online through the heartbeat packet and waits for the second
  • the second device replies with a heartbeat packet.
  • step S106 the second device does not reply to the heartbeat packet sent by the first device.
  • the second device wakes up when the monitoring period comes and monitors whether it has received a heartbeat packet. If it receives a heartbeat packet, it will reply a heartbeat packet to notify the first device that it is online.
  • FIG. 1c is a schematic diagram of the monitoring cycle according to the monitoring mode of the embodiment of the present application. The second device wakes up at the wake-up anchor points (Sniff anchor points) of each monitoring cycle and starts to monitor the heartbeat packet. If a heartbeat packet is detected within the t1 period, it will reply. The same is true for other monitoring periods in FIG. 1c , which will not be repeated here.
  • the second device may not respond to the heartbeat packet sent by the first device in step S106.
  • the reason why the second device does not reply the heartbeat packet is mainly that it is affected by the interruption period of the second device.
  • the second device will process the interrupt task. For example, when the interruption period of the sensor comes, the second device will read the data of the sensor.
  • the interrupt period coincides with the monitoring period, after the second device wakes up, it needs to process the interrupt task and the heartbeat packet reply task, but because the interrupt task processing priority is higher, the second device will process the interrupt task instead of the heartbeat packet. Reply, and then cause the first device to fail to receive the heartbeat packet reply from the second device.
  • step S107 the first device disconnects the Bluetooth connection with the second device.
  • the first device When the first device does not receive a reply from the second device for a long time, it will consider that the second device is currently offline, and then the first device will actively disconnect the Bluetooth connection with the second device.
  • FIG. 1d is a schematic diagram of a scene where a disconnection occurs in a listening mode according to an embodiment of the present application.
  • the mobile phone 10 and the wristband 20 are in the state of Bluetooth connection, and the mobile phone 10 sends a heartbeat packet to the wristband 20.
  • the wristband 20 is in the monitoring cycle, there are two tasks to process at the same time, which are interrupt Process the data of the acceleration sensor and reply the heartbeat packet.
  • the processing priority of interrupt processing the data of the acceleration sensor is higher than that of the heartbeat packet reply. Therefore, as shown in (2) of FIG. 1d, after executing the interrupt processing task, the wristband 20 sleeps without replying the heartbeat packet.
  • the mobile phone 10 will actively disconnect from the communication because it has not received a heartbeat packet reply.
  • the Bluetooth connection of the bracelet 20 is a schematic diagram of a scene where a disconnection occurs in a listening mode according to an embodiment of the present application.
  • the embodiment of the present application proposes a method for configuring the listening period , is executed by the interaction between the first device and the second device, so that the monitoring period of the first device and the second device in the monitoring mode does not coincide with the interrupt period, and then the second device can be prompted to reply the heartbeat packet normally, so that the No disconnection occurs in monitor mode.
  • Listening mode the mode used by the first device and the second device in the Bluetooth connection state when power saving and low power consumption are required.
  • the second device does not need to monitor the data of the first device in every time slice, but only needs to monitor according to the monitoring period in the monitoring mode. When the monitoring period does not come, the second device can sleep to achieve low power consumption. consumption effect.
  • Link timeout monitoring time (supervision timeout): After the first device establishes a Bluetooth connection with the second device, the first device will issue the link timeout monitoring time parameter. When the heartbeat packet replying from the second device is not received, the first device will actively disconnect the Bluetooth connection with the second device.
  • the listening duration in listening mode can be represented by Nsniff attempt.
  • the listening duration in listening mode includes the Sniff anchor point.
  • the second device should monitor the number of time slices transmitted by the first device, that is, when the second device The listening time after waking up at the Sniff anchor point.
  • the time period t1 shown in FIG. 1 c is the value of the listening duration in the listening mode.
  • Sniff interval In the sniff mode, the second device periodically (wakes up) monitors the time period for the data sent by the first device.
  • any second device in this scenario can cooperate with the first device Execute the method for configuring the monitoring period in the embodiment of the present application. It may also be applicable to a scenario where a first device establishes a Bluetooth connection with a second device.
  • both the first device and the second device may be mobile phones, tablet computers, desktops, laptops, notebook computers, ultra-mobile personal computers (Ultra-mobile Personal Computer, UMPC), handheld computers, netbooks, Personal digital assistants (Personal Digital Assistant, PDA), wearable electronic devices, smart watches and other electronic devices with Bluetooth communication functions.
  • Ultra-mobile Personal Computer Ultra-mobile Personal Computer
  • PDA Personal Digital Assistant
  • Fig. 2 is a schematic diagram of a hardware structure of a first device according to an embodiment of the present application.
  • the structure of the first device can be as shown in FIG. 2, and the first device 201 can include: a processor 210, an external memory interface 220, an internal memory 221, and a universal serial bus (universal serial bus, USB) interface 230, charging management module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, speaker 270A, receiver 270B, microphone 270C, earphone jack 270D, sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (subscriber identification module, SIM) card interface 295, etc.
  • SIM subscriber identification module
  • the sensor module 280 may include a pressure sensor 280A, a gyro sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, and an ambient light sensor.
  • the structure shown in this embodiment does not constitute a specific limitation on the first device 201 .
  • the first device 201 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange different components.
  • the illustrated components can be realized in hardware, software or a combination of software and hardware.
  • the processor 210 may include one or more processing units, for example: the processor 210 may include an application processor (application processor, AP), a Modem, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor) , ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • Modem graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the charging management module 240 is configured to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the power management module 241 is used for connecting the battery 242 , the charging management module 240 and the processor 210 .
  • the power management module 241 receives the input from the battery 242 and/or the charging management module 240 to provide power for the processor 210 , the internal memory 221 , the display screen 294 , the camera 293 , and the wireless communication module 260 .
  • the wireless communication function of the first device 201 may be realized by the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, a modem, and a baseband processor.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the first device 201 can be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
  • the mobile communication module 250 can provide wireless communication solutions including 2G/3G/4G/5G applied on the first device 201 .
  • the wireless communication module 260 can provide applications on the first device 201 including wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (wireless fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation Satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • the wireless communication module 260 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 260 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210 .
  • the wireless communication module 260 can also receive the signal to be sent from the processor 210 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 to radiate out.
  • the wireless communication module 260 may specifically be a Bluetooth chip or a Bluetooth module, and the wireless communication module 260 may execute the method for configuring the listening period proposed in the embodiment of the present application
  • the wireless communication module 260 may execute the method for configuring the listening period proposed in the embodiment of the present application
  • the processor 210 may execute the steps executed by the first device in the method for configuring the listening period proposed in the embodiment of the present application.
  • the first device 201 implements a display function through a GPU, a display screen 294, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 294 and the application processor.
  • the display screen 294 is used to display images, videos and the like.
  • a series of graphical user interfaces can be displayed on the display screen 294 of the first device 201.
  • the electronic device 200 can realize the shooting function through the ISP, the camera 293 , the video codec, the GPU, the display screen 294 and the application processor.
  • Camera 293 is used to capture still images or video.
  • the external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200.
  • an external memory card such as a Micro SD card
  • the internal memory 221 may be used to store computer-executable program codes including instructions.
  • the processor 210 executes various functional applications and data processing of the electronic device 200 by executing instructions stored in the internal memory 221 .
  • the first device 201 may implement an audio function through an audio module 270 , a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, and an application processor. Such as music playback, recording, etc.
  • the electronic device 200 may also include a pressure sensor 280A, an air pressure sensor 280C, a gyro sensor 280B, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, an ambient light sensor 280L, a fingerprint sensor 280H, a temperature sensor 280J, Touch sensor 280K, bone conduction sensor 280M, button 290, motor 291, indicator 292, etc.
  • the SIM card interface 295 is used for connecting a SIM card.
  • the SIM card can be connected and separated from the electronic device 200 by inserting it into the SIM card interface 295 or pulling it out from the SIM card interface 295 .
  • the electronic device 200 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • SIM card interface 295 can support Nano SIM card, Micro SIM card, SIM card etc. Multiple cards can be inserted into the same SIM card interface 295 at the same time.
  • the SIM card interface 295 is also compatible with external memory cards.
  • the first device 201 interacts with the network through the SIM card to implement functions such as calling and data communication.
  • operating systems such as Hongmeng operating system, iOS operating system, Android operating system, Windows operating system, etc.
  • Applications can be installed and run on this operating system.
  • Fig. 3 is a schematic diagram of a hardware structure of a second device according to an embodiment of the present application.
  • the structure of the second device may be as shown in FIG. 3
  • the second device 202 may include: a processor 201A, a memory 202A, a Bluetooth communication module 203A, an antenna 204A, a power switch 205A, a USB communication processing module 206A, Audio module 207A, sensor module 208A. in:
  • Processor 201A may be used to read and execute computer readable instructions.
  • the processor 201A may mainly include a controller, an arithmetic unit, and a register.
  • the controller is mainly responsible for instruction decoding, and sends out control signals for the operations corresponding to the instructions.
  • the arithmetic unit is mainly responsible for saving the register operands and intermediate operation results temporarily stored during the execution of the instruction.
  • the hardware architecture of the processor 201A may be an application-specific integrated circuit (ASIC) architecture, a MIPS architecture, an ARM architecture, or an NP architecture, and the like.
  • ASIC application-specific integrated circuit
  • the processor 201A may be used to analyze signals received by the Bluetooth communication processing module 203, such as requests, commands, heartbeat packets and the like sent by the first device 201.
  • the processing 201A can be used to perform corresponding processing operations according to the parsing results, such as generating a response corresponding to a request, a response corresponding to a command, and so on.
  • the memory 202A is coupled with the processor 201A for storing various software programs and/or sets of instructions.
  • the memory 202A may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices or other non-volatile solid-state storage devices.
  • the memory 202A can store operating systems, such as embedded operating systems such as uCOS, VxWorks, and RTLinux.
  • the memory 202A can also store a communication program that can be used to communicate with the first device 201, one or more servers, or other devices.
  • the Bluetooth communication module 203A may include a Bluetooth Classic (BR/EDR) module and a Bluetooth Low Energy (BLE) module.
  • BR/EDR Bluetooth Classic
  • BLE Bluetooth Low Energy
  • the Bluetooth communication module 203A can execute the steps performed by the second device 202 in the method for configuring the listening period proposed in the embodiment of the present application.
  • the processor 201A may execute the steps executed by the second device in the method for configuring the listening period proposed in the embodiment of the present application.
  • the wireless communication function of the second device 202 can be realized through the antenna 204A, the Bluetooth communication module 203A, the modem processor and the like.
  • the antenna 204A can be used to transmit and receive electromagnetic wave signals.
  • Each antenna in the second electronic device 200 may be used to cover single or multiple communication frequency bands.
  • the power switch 205A can be used to control power supply to the second electronic device 200 .
  • the USB communication processing module 206A can be used to communicate with other devices through a USB interface (not shown).
  • the audio module 207A can be used to output audio signals through the audio output interface, so that the second device 202 can support audio playback.
  • the audio module can also be used to receive audio data through the audio input interface.
  • the second device 202 may be a media player such as a Bluetooth headset.
  • the sensor module 208A includes one or more sensors. For example, acceleration sensors and gyro sensors may be included.
  • the acceleration sensor can detect the acceleration of the second device 202 in various directions (generally three axes). When the second device 202 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the second device 202, and it can be applied to applications such as horizontal and vertical screen switching, pedometer, etc.
  • the gyroscope sensor can be used to determine the motion posture of the second device 202 .
  • the angular velocity of the second device 202 about three axes i.e., x, y, and z axes
  • the gyro sensor can be used for image stabilization.
  • the Bluetooth communication module 203A will process the data collected by the sensor when the interruption period of the sensor in the sensor module 208A comes.
  • the structure shown in FIG. 3 does not constitute a specific limitation on the second device 202 .
  • the second device 202 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
  • the illustrated components can be realized in hardware, software or a combination of software and hardware.
  • the structural diagram of the first device 201 may also be shown in FIG. 3
  • the structural diagram of the second device 202 may also be shown in FIG. 2 , which is not limited in this embodiment of the present application.
  • FIG. 4 is a schematic diagram of a Bluetooth protocol framework according to an embodiment of the present application. As shown in Figure 4, the embodiment of the present application provides a schematic diagram of a bluetooth protocol framework.
  • the schematic diagram includes but is not limited to Host (host) protocol stack, HCI (Host Controller Interface), and controller (controller).
  • the Host protocol stack defines multiple applications (profiles) and core protocols (protocols) in the Bluetooth framework, each profile defines its corresponding message format and application rules, and a profile is a Bluetooth service (Application).
  • the Bluetooth protocol has formulated specifications for various possible and general-purpose application scenarios, such as A2DP (advanced audio distribution profile), HFP (hands-free profile) and so on.
  • Core protocols include, but are not limited to, the basic Bluetooth service protocol SDP (service discover protocol), logical link control and adaptation protocol L2CAP (logical link control and adaptation protocol), etc.
  • the core protocol is essential in the Bluetooth protocol stack.
  • HCI provides a unified interface for the upper layer protocol to enter the link manager and a unified way to enter the baseband.
  • SIG Bluetooth Special Interest Group stipulates four physical bus methods connected to hardware, that is, four HCI transport layers: USB, RS232, UART and PC card.
  • the controller defines the underlying hardware part, including radio frequency (RF), baseband (BB) and link management (LM).
  • the RF layer realizes the filtering and transmission of the data bit stream through the microwave of the 2.4GHz unlicensed ISM frequency band. It mainly defines the conditions that the Bluetooth transceiver needs to meet to work normally in this frequency band.
  • the baseband is responsible for frequency hopping and transmission of Bluetooth data and information frames.
  • Link management is responsible for connecting, establishing and tearing down links and performing security controls.
  • the LM (Link Manager) layer is the link management protocol of the Bluetooth protocol stack. It is responsible for translating the upper-layer HCI commands into operations acceptable to the baseband, and establishing an asynchronous connection-oriented link (ACL) and a synchronous connection.
  • ACL asynchronous connection-oriented link
  • the LC (LinkControl) layer is responsible for responding to upper-layer LM commands during the transmission of a batch of data packets (such as executing LM commands for establishing a transmission link for data packets, maintaining links, etc.).
  • FIG. 4 shows a schematic diagram of the Bluetooth protocol framework of the first device
  • the Bluetooth protocol stack (BT Stack) can be used to execute relevant parts of the first device in FIGS. 5 and 8 .
  • FIG. 4 shows a schematic diagram of the bluetooth protocol framework of the second device
  • the bluetooth protocol stack (BT Stack) can be used to execute the relevant parts of the second device in FIG. 5 and FIG. 8 .
  • Fig. 5 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application.
  • the embodiment of the present application aims at that the first device and the second device are electronic devices of the same manufacturer, and there is a mutual agreement between the first device and the second device
  • a method for configuring a monitoring period is proposed, which is executed by the first device and the second device in cooperation with each other. Specifically include the following steps:
  • a Bluetooth connection can be established between the first device and the second device through Bluetooth technology (including classic Bluetooth (Basic Rate/Enhanced Data Rate, BR/EDR) and Bluetooth Low Energy (Bluetooth Low Energy, BLE)).
  • Bluetooth technology including classic Bluetooth (Basic Rate/Enhanced Data Rate, BR/EDR) and Bluetooth Low Energy (Bluetooth Low Energy, BLE)
  • BLE Bluetooth Low Energy
  • the agreement between the first device and the second device stipulates that the first device is a master device, and the second device is a slave device.
  • the user can operate the interface of the first device to enable the Bluetooth function, pair and connect the wristband, and establish a connection between the mobile phone and the wristband.
  • Bluetooth connection there are many ways to implement the establishment process of the Bluetooth connection, including but not limited to the content proposed in the embodiment of the present application.
  • a manner of establishing a Bluetooth connection between the first device and the second device reference may be made to the provisions of the Bluetooth protocol, which is not limited in this embodiment of the present application.
  • the first device sends an interrupt parameter acquisition command to the second device.
  • the interrupt parameter acquiring command is used to acquire the interrupt period and period deviation of the second device.
  • the interrupt period refers to a period in which the second device executes the interrupt task.
  • the interruption cycle is uniformly represented by N, and the cycle deviation is represented by o.
  • the interruption period may be the interruption period of the sensor of the second device, and the interruption task is the task of reading sensor data, that is, the second device periodically reads and processes the data collected by the sensor according to the interruption period of the sensor.
  • the second device may have multiple interrupt cycles, which are respectively used to execute different interrupt tasks.
  • the period offset o refers to the clock error of the second device.
  • the second device should execute the interrupt task at 500ms, but because of the clock error, the second device may execute the interrupt task in the range of 495ms to 505ms Execute the interrupt task within.
  • step S502 is performed by the first device in the working mode.
  • the first device directly controls the second device to enter the working mode. For example, the first device sends a request to enter the working mode to the second device, and the second device enters the working mode in response to the request to enter the working mode.
  • the first device may execute step S502 at any time in the working mode. The timing of executing step S502 in the working mode is not limited in this embodiment of the present application.
  • the interrupt parameter acquisition command can be a private command of the response protocol (echo), that is, an echo message based on the Logical Link Control and Adaptation Protocol (Logical Link Control and Adaptation Protocol, L2CAP) for interaction. private command.
  • the interrupt parameter acquisition command carries a specific ID inside, and the specific ID is pre-defined by both the first device and the second device.
  • the format of the echo private command is a format consisting of a service ID, a command ID, and a payload.
  • the service ID and command ID in the format of the interrupt parameter acquisition command are specific, and are used to define the acquisition interrupt cycle N and cycle deviation o.
  • the second device responds to the interrupt parameter acquisition command, and returns response information corresponding to the interrupt parameter acquisition command to the first device.
  • the second device can successfully respond to the interrupt parameter acquisition command, it can carry all the interrupt cycles N and cycle deviation o of the second device in the response information and return them to the first device. If the second device fails to respond successfully to the interrupt parameter acquisition command, it may not return response information, or the returned response information does not carry the interrupt period N and the period deviation o.
  • the interrupt parameter acquisition command is a private command based on the echo protocol.
  • the scenario where the second device can successfully respond to the command is: the interrupt parameter acquisition command is predefined inside the second device, and the second device can parse out that the command is used to obtain the interrupt period N and The command of the period deviation o can then successfully respond to the command, carry its own interrupt period N and the period deviation o into the response information and return it to the first device.
  • the scenario where the second device cannot successfully respond to the command is as follows: 1.
  • the second device does not support the private command. When the second device does not support the private command, it cannot parse the interrupt parameter acquisition command, and thus cannot respond, and will not return any data to the first device. At this time, the first device cannot receive the response information. 2.
  • the command is not predefined in the second device. If the ID in the interrupt parameter acquisition command sent by the first device does not find a definition inside the second device, the second device cannot parse out that the command is used to obtain the interrupt cycle N and cycle deviation o, and then the response returned by the second device Information may be garbled.
  • the second device may actively report to the first device. For example, the second device may use the echo private command to report the interruption period. Then the first device stores the new interruption period N again, and uses the new interruption period N to calculate SN when step S509 is executed subsequently.
  • the second device may also actively report the interruption period to the first device, without reporting to the first device after the first device performs step S502. That is, the reporting of the interrupt period by the second device may not be triggered by a command or request from the first device.
  • the first device judges whether the interruption period N and the period deviation o are successfully obtained.
  • the first device may parse and read the response information corresponding to the received interrupt parameter acquisition command, and judge whether there is an interrupt period N and a period deviation o in the response information. If the interruption period N and the period deviation o are returned in the response information, step S505 is performed. If the response information does not reply the interruption cycle N and the cycle deviation o, for example, a garbled code is returned, then step S506 is executed.
  • step S506 if the first device does not receive the response information returned by the second device within the preset time period, it also judges that the interruption period N and the period deviation o have not been successfully obtained, and step S506 is executed.
  • the first device stores the acquired interrupt period N and period deviation o.
  • the first device stores both the N and o parameters read from the response information for use when the first device and the second device enter the monitoring mode.
  • the first device may execute step S505 through the Bluetooth protocol stack in the first device.
  • the Bluetooth protocol stack For the relevant description of the Bluetooth protocol stack, reference may be made to the relevant part in FIG. 4 , which will not be repeated here.
  • the first device sets the interrupt period N as a special value.
  • the interrupt cycle N can be set to a special value, such as 0, -1 or other negative numbers as the special value, to indicate that the first device has not obtained the interrupt cycle parameter and the cycle deviation parameter.
  • an additional acquisition result status parameter K may also be specially used to identify whether the interruption period parameter and the period deviation parameter have been successfully acquired. For example, when the interruption period N and the period deviation o are successfully obtained, K can also be set to 1, which means that the first device successfully obtains the interruption period N and the period deviation o, and when the second device enters the monitoring mode, the first device When it is read that K is 1, the interrupt period N and period deviation o stored in step S505 can be used.
  • K can also be set to -1, indicating that the first device has not obtained the interruption period N and period deviation o, and when the second device enters the monitoring mode, the first device reads When K is -1, no longer read and use the interrupt cycle N and cycle deviation o.
  • the first device determines that there is no data interaction between it and the second device.
  • step S507 the first device and the second device work in the working mode, and the second device monitors in each slot.
  • the first device determines that there is no need for data interaction with the second device at present, or that there is no business that needs to be performed by the second device, then it can be determined that there is no data interaction between it and the second device .
  • the first device judges whether the interruption period N is a positive number.
  • step S508 The purpose of executing step S508 is to determine whether the first device successfully acquires the interruption period N.
  • step S503 When the first device successfully obtains the interruption period N in the aforementioned step S503, after the processing of step S505, the read interruption period N will be a positive number, that is, it is judged that the interruption period N is a positive number, and step S509 is executed. It should be noted that, if the interrupt cycle N is successfully obtained in step S503, there may be more than one interrupt cycle N, and all of them are positive numbers.
  • step S506 When the first device fails to obtain the interruption period N, after the processing of step S506, the interruption period N read in step S508 will be -1, that is, it is determined that N is not a positive number, and step S510 is executed.
  • the first device calculates the monitoring period of the second device according to the interruption period N.
  • the listening period of the second device calculated by the first device is the listening period used by the second device in the listening mode.
  • the monitoring period is collectively denoted by SN below, wherein the monitoring period SN of the second device does not coincide with the interruption period N.
  • the listening period SN calculated by the first device is a period that will not overlap with the interruption period N. Furthermore, it can be ensured that the second device will not encounter a conflict between the interruption task and the heartbeat packet reply task.
  • the monitoring periods obtained through calculation all belong to non-default monitoring periods.
  • the originally pre-configured monitoring period is called the default monitoring period.
  • SD is used to represent the default monitoring period.
  • the SN satisfies the condition of being in the range of [SD-L, SD+L].
  • L is a preset deviation value, for example, L may be 100ms.
  • the value of the default listening period of the first device is adaptively different for different second devices.
  • the default monitoring period is obtained through experiments, and is a relatively suitable monitoring period for the second device in the monitoring mode, and can meet the performance requirements of the second device in the monitoring mode. Therefore, when SN is in the range of [SD-L, SD+L], SN is close to SD, and the monitoring period of the second device is set reasonably, which can meet the performance requirements of the second device in the monitoring mode.
  • SN also satisfies the condition that the difference from SD is greater than the periodic deviation o. Due to the problem of clock delay in the second device, there may be a deviation in the interrupt period.
  • the cycle deviation o means that if the interrupt cycle is N, the interrupt cycle in actual operation may be N ⁇ o. For example, if the interrupt period N is 300ms, and the period deviation o is 10ms, then the actual interrupt period during operation is within the range of 300 ⁇ 10ms. Therefore, in order to avoid clock delays, the calculated SN will still coincide with the interrupt period.
  • SN and The difference between SD can also be greater than the periodic deviation o.
  • the offset value A is an integer
  • A represents the deviation value between the SN and the interrupt period N
  • A can be a positive integer or a negative integer
  • X is a specific multiple, and is a positive integer.
  • FIG. 6 is a schematic flowchart of calculating the listening period SN by the first device according to an embodiment of the present application.
  • the first device randomly selects X and A, where X is a positive integer and A is a positive number.
  • step S5093 the first device judges whether the SN is within the range of [SD-L, SD+L] and the difference between SN and SD is greater than the period deviation o, if not, return to step S5091, That is, select X and A again, and if they are satisfied, execute step S5094 and output SN.
  • the offset value A is an integer
  • A represents the deviation value between the SN and the interrupt period N
  • A can be a positive integer or a negative integer
  • X is a positive integer.
  • Z is a common multiple of multiple interrupt periods N. For example, if the multiple interruption periods N are 200ms and 300ms respectively, then Z may be 600ms.
  • the values of X and A may be the same as those mentioned above when there is only one interrupt period N, and will not be repeated here.
  • the offset value A is an integer
  • A represents the deviation value between SN and the interrupt period N
  • A can be either a positive integer or a negative integer
  • X represents a specific multiple
  • M is the maximum value of multiple interruption periods N. For example, if the multiple interruption periods N are 200ms and 300ms respectively, then M is 300ms.
  • the values of X and A may be the same as those mentioned above when there is only one interrupt period N, and will not be repeated here.
  • the values of X and A may also be used so that SN satisfies the condition within the range of [SD-L, SD+L], and /or, the condition that the difference from SD is greater than the period deviation o.
  • the specific adjustment process refer to the flow shown in Figure 6, but the formula for calculating SN is different from that in Figure 6.
  • step S502 the interrupt parameter acquisition command in step S502 may only be used to acquire the interrupt parameter N.
  • step S504 it may only be judged whether the interruption period N is successfully obtained, or only the interruption period N may be stored in step S505.
  • the first device sets the value of SN to SD.
  • the monitoring period SN of the second device is set as the default monitoring period SD of the second device.
  • step S508 to step S510 are actually a process of setting the SN.
  • the process of setting the SN can be triggered after step S507, or after step S506, that is, after completing the setting of the interrupt period N.
  • the process of setting the SN only needs to occur before entering the monitoring mode.
  • the first device sends information about the SN to the second device.
  • the information about the SN may be a request to enter the monitoring mode, wherein the request to enter the monitoring mode carries the SN.
  • the first device After the first device sets the monitoring period SN of the second device, it carries the SN in the request to enter the monitoring mode and sends it to the second device so that the second device can enter the monitoring mode. run.
  • the second device responds to the request to enter the monitoring mode, enters the monitoring mode, monitors and replies the heartbeat packet sent by the first device according to the period of the SN.
  • the second device can obtain the SN sent by the first device from the request, and then determine that the monitoring period of itself in the monitoring mode is SN, and then enter the operating state of the monitoring mode.
  • the first device sends at least one heartbeat packet to the second device according to the cycle of the SN, and the second device wakes up according to the cycle of the SN, listens to the heartbeat packet during the t1 period, and sends the heartbeat packet to the first device after listening to the heartbeat packet.
  • the device sends a heartbeat packet response to notify the first device that it is still online, and accordingly the Bluetooth connection is still valid.
  • the listening mode please refer to the introduction of the aforementioned part of FIG. 1 c and for the related technologies, please refer to the relevant parts of the aforementioned brief introduction to the related technologies under the Bluetooth communication scheme, and will not be repeated here.
  • the offset value A 101ms, taking one of the interruption period N and one SN period as an example, it can be seen that the supplementary sum of the interruption period N and SN deviates by 101ms, and when the interruption period N comes, the wristband 20 only executes Interrupt task, and when the monitoring period SN comes, it only needs to execute the heartbeat packet reply task, that is, monitor and reply the heartbeat packet during the t1 period.
  • the SN set by the first device will not coincide with the interrupt period of the second device, so the second device follows When the SN monitors periodically, it will not be unable to reply to the heartbeat packet due to the execution of the interrupt task, and will not be disconnected due to the inability to reply to the heartbeat packet.
  • the first device records the disconnection times in the monitoring mode.
  • the number of disconnections refers to the number of disconnections of the Bluetooth communication between the first device and the second device.
  • the number of disconnections is represented by DN in this application.
  • step S513 is executed in the following manner: judging whether disconnection occurs in the listening mode, and if disconnection occurs, increment DN by 1.
  • step S513 is a step that is repeatedly executed in real time, that is, step S513 is always executed in the monitoring mode.
  • the first device judges whether the disconnection count DN in the monitoring mode is greater than or equal to a disconnection threshold.
  • the disconnection threshold can be set arbitrarily, and an exemplary disconnection threshold can be set to 3 according to experience.
  • the DN is greater than or equal to the disconnection threshold, it indicates frequent disconnection between the first device and the second device.
  • the main reason for the disconnection in the listening mode is that the second device does not reply the heartbeat packet for a long time.
  • the first device may send a link timeout monitoring time to the second device, and when the second device does not reply a heartbeat packet to the first device for a period exceeding the link timeout monitoring time, the second A device may consider that the second device is not online, so as to actively disconnect the Bluetooth connection.
  • the interruption period has been avoided through the setting method of step S509, which reduces the probability that the second device does not reply the heartbeat packet.
  • the reason for frequent disconnection may be that the listening time in listening mode is too short.
  • the monitoring time is too short, the second device may not be able to monitor the heartbeat packet, and thus cannot reply the heartbeat packet.
  • the listening duration of the second device's current listening mode may be sent to the second device by being included in the request for entering the listening mode when the first device executes step S511. Therefore, when the DN is greater than or equal to the disconnection threshold, step S515 may be executed to adjust the listening duration of the second device in the listening mode. And if the DN is smaller than the disconnection threshold, it means that there is no frequent disconnection at present, and it only needs to continue to return to step S513.
  • step S514 is continuously executed until it is determined in step S514 that the DN is greater than or equal to the disconnection threshold, and then the execution of step S514 is ended and the process enters into S515.
  • the first device doubles the value of the listening duration to obtain an updated listening duration.
  • the first device doubles the original listening duration to obtain an updated listening duration.
  • the updated listen duration is longer than the original listen duration.
  • the original listening duration is 5ms
  • the updated listening duration is 10ms.
  • the first device may also use other methods to increase the value of the listening duration.
  • step S515 may also be to increase the value of the listening duration by a preset value.
  • the preset value can be set to 3ms, the original monitoring time is 5ms, and after increasing the preset value, it becomes 3ms.
  • step S515 is actually to increase the value of the listening duration.
  • the specific rules and methods for increasing the value of the listening duration may not be limited in this embodiment of the present application.
  • step S515 after step S515 is executed, the DN can be cleared, and then return to step S514. If it is judged again that the DN is greater than or equal to the disconnection threshold, step S515 is executed again, that is, the monitoring value is increased again. duration.
  • the listening duration may be limited to a value not greater than a listening duration threshold.
  • the listening duration can be set according to the value of the SN, for example, it can be half of the SN.
  • the first device sends the updated listening duration to the second device.
  • the first device performs step S516 by resending a request to enter the listening mode to the second device, and the request carries the updated listening duration and SN.
  • the second device uses the updated monitoring duration to perform a monitoring operation. That is, when each monitoring cycle comes, the length of the monitoring time is the updated monitoring time length. Since the updated monitoring time is longer, the time required for monitoring is longer, so the probability that the second device can monitor the heartbeat packet is greater, and the possibility of disconnection will be reduced.
  • the first device may also determine whether disconnection occurs, and if disconnection still occurs, return to step S515 to readjust the monitoring duration until no disconnection occurs.
  • the first device clears the DN to zero.
  • the exit of the monitoring mode in step S517 refers to the normal termination of the monitoring mode. If the exit of the monitoring mode is caused by an abnormality such as a disconnection, the DN will not be cleared to zero, but the DN will continue to be increased by 1.
  • the way for the first device to exit the listening mode is: the first device sends a request for exiting the listening mode to the second device, and the second device responds to the request for exiting the listening mode, exits the listening mode, and no longer follows the monitoring cycle. monitor.
  • the first device clears the DN to zero after sending the request to exit the listening mode.
  • steps S513 to S517 may not be performed, that is, the listening duration is not adjusted.
  • steps S502 to S506 are to enable the first device to obtain the interrupt period of the second device, and the implementation method and process of obtaining the interrupt period of the second device are not discussed in this embodiment of the present application. limit.
  • Steps S508 to S510 are used to determine whether to set the value of SN as the default monitoring period SD.
  • the interrupt cycle N if the interrupt cycle N is successfully obtained, SN is not set to SD, but the interrupt cycle N is used to calculate SN, so that SN does not overlap with N; and when N is not successfully obtained, SN The value of is set to SD.
  • other conditions may also be used to determine whether the value of SN needs to be set to SD, which is not limited in this embodiment of the present application.
  • step S509 the period deviation parameter o may not be used in the process of calculating SN, therefore, the interrupt parameter acquisition command in step S502 may also be used only to acquire the interrupt parameter N.
  • step S504 it may only be judged whether the interruption period N is successfully obtained, and in step S505, only the interruption period N may be stored.
  • steps S513 to S517 are to increase the listening duration when the DN is greater than or equal to the disconnection threshold.
  • Step S515 is only one way of increasing the value of the listening duration, and the present application does not limit the way of increasing the value of the listening duration.
  • the steps to be performed by the first device in FIG. 5 can be performed by the Bluetooth protocol stack in the first device, and the wireless communication module 260 shown in FIG. 2 can be used as hardware support, and the steps performed by the second device can be It can be executed through the Bluetooth protocol stack in the second device, and the Bluetooth communication module 203A shown in FIG. 2 can be used as hardware support.
  • the Bluetooth protocol stack for the related description of the Bluetooth protocol stack, reference may be made to relevant parts in FIG. 4 , which will not be repeated here.
  • default values of the monitoring period, link timeout monitoring time, and monitoring duration issued by the first device may be adaptively different.
  • the SN set by the first device will not coincide with the interrupt period N of the second device, so the second device When monitoring according to the cycle of the SN, it will not be unable to reply the heartbeat packet due to the execution of the interrupt task, and will not be disconnected due to the inability to reply the heartbeat packet.
  • Fig. 8 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application.
  • the embodiment of the present application aims at the first device and the second device being electronic devices of different manufacturers, and the private command cannot be passed between the first device and the second device.
  • another method for configuring a monitoring period is proposed, which is executed by the cooperation of the first device and the second device. Specifically include the following steps:
  • step S801 For the execution principle and process of step S801, reference may be made to step S501, which will not be repeated here.
  • the first device determines that there is no data interaction with the second device, and sends a request to enter the monitoring mode to the second device, wherein the value of the monitoring period SN carried in the request to enter the monitoring mode is a default monitoring period SD.
  • step S802 For the execution process and principle of determining no data interaction with the second device in step S802, reference may be made to step S507, which will not be repeated here.
  • step S511 For the process of sending a request to enter the listening mode, reference may be made to step S511.
  • step S802 is different from step S511 in that when the first device requests to enter the monitoring mode for the first time, the value of SN used is the default value SD.
  • the second device responds to the request to enter the monitoring mode, enters the monitoring mode, monitors and replies the heartbeat packet sent by the first device according to the period of the SN.
  • step S512 For the execution process and principle of step S803, please refer to step S512.
  • the main difference is that the SN used in step S512 may be obtained by setting in step S509, while the SN in step S803 is the default value SD.
  • the first device records the disconnection times DN in the monitoring mode.
  • step S804 for the execution process and principle of step S804, reference may be made to step S513, which will not be repeated here.
  • the first device determines whether the DN is greater than or equal to the disconnection threshold.
  • the disconnection threshold can be set arbitrarily, for example, it can be set to 3 according to experience.
  • the DN is greater than or equal to the disconnection threshold, it indicates frequent disconnection between the first device and the second device.
  • the main reason for the disconnection in the listening mode is that the second device does not reply the heartbeat packet for a long time.
  • the SN used by the second device is a default value SD, the reason for the frequent disconnection phenomenon can be analyzed, which may be because when the current SN is the default value SD, the SN will be connected to the second device The interruption period of the two overlaps, so the SN can be reset, that is, step S806 is executed.
  • the DN When the DN is less than the disconnection threshold, it means that there is no frequent disconnection at present, the SN does not need to be reset, and the second device continues to monitor according to the cycle in which the SN is the default value SD.
  • step S805 is continuously executed until it is determined in step S805 that the DN is greater than or equal to the disconnection threshold, and then the execution of step S805 is ended and the process enters into S806.
  • the first device uses the sum of the SN and the offset value A as the updated SN.
  • the first device resets the SN
  • the reset SN that is, the updated SN
  • the offset value A can be set according to personal experience (for example, an odd number and a prime number can be selected as the offset value A), or it can be based on the cycle deviation (that is, the clock deviation) and the interruption period of the second device based on common experience. factor, to set A.
  • personal experience for example, an odd number and a prime number can be selected as the offset value A
  • the cycle deviation that is, the clock deviation
  • the interruption period of the second device based on common experience. factor
  • the first device sends the updated SN to the second device.
  • the first device performs step S807 by sending a request to enter the monitoring mode to the second device, and the request carries the updated SN.
  • the second device monitors and responds to the heartbeat packet of the first device according to the period of the updated SN.
  • the second device monitors the heartbeat packet according to the period of the updated SN, and returns the heartbeat packet of the first device after monitoring the heartbeat packet.
  • the updated SN is actually the sum of the SD and the offset value A
  • the original SN may be due to coincidence with the interrupt cycle, resulting in a conflict between the interrupt task of the second device and the task of replying the heartbeat packet, and the interrupt task is executed first.
  • Reply the heartbeat packet resulting in a disconnection.
  • the updated SN is offset by A on the basis of the original SN, so it will not coincide with the interrupt cycle, and will not cause disconnection due to the conflict between the heartbeat packet reply task and the interrupt task.
  • the first device determines whether a disconnection occurs.
  • the first device may determine whether a disconnection still occurs. If the disconnection still occurs even though the SN has been updated, it may be because the listening time in the listening mode is too short. Wherein, the current listening duration of the second device may be carried in the request for entering the listening mode in step S803. That is, when the first device executes step S803, it also includes the listening duration in the request and sends it to the second device. When the monitoring time is too short, it may go to sleep without listening to the heartbeat packet, so there is no reply to the heartbeat packet. Therefore, when it is determined in step S809 that a disconnection occurs, step S810 is executed to increase the value of the listening duration.
  • step S809 when it is determined in step S809 that the disconnection still occurs, it is also possible to return to step S806, that is, to update and adjust the SN mode again, so as to achieve the purpose of no further disconnection.
  • step S809 is continuously executed. After it is judged that there is no disconnection, step S809 still needs to be executed until it is judged that disconnection occurs, or the monitoring mode is exited, and the execution of step S809 is not completed.
  • the first device doubles the value of the listening duration to obtain an updated listening duration.
  • step S810 For the execution process and principle of step S810, reference may be made to step S515, which will not be repeated here.
  • the first device sends the updated listening duration to the second device.
  • step S811 for the execution process and principle of step S811, reference may be made to step S516, which will not be repeated here.
  • step S812 for the execution process and principle of step S812, reference may be made to step S517, which will not be repeated here.
  • steps S809 to S811 may not be performed, that is, the value of the listening duration is not updated and adjusted.
  • the steps to be performed by the first device in FIG. 8 can be performed by the Bluetooth protocol stack in the first device, and the wireless communication module 260 shown in FIG. 2 can be used as hardware support.
  • the steps executed by the second device can be executed by the Bluetooth protocol stack in the second device, and the Bluetooth communication module 203A shown in FIG. 2 can be used as hardware support.
  • the Bluetooth protocol stack for the related description of the Bluetooth protocol stack, reference may be made to relevant parts in FIG. 4 , which will not be repeated here.
  • default values of the monitoring period, link timeout monitoring time, and monitoring duration issued by the first device may be adaptively different.
  • the interruption period of the second device coincides with the current SN
  • the first device uses the sum of the current SN and the offset value A as the updated SN .
  • the updated SN is sent to the second device, so that the second device monitors at the period of the updated SN in the monitoring mode. Since the updated SN is offset by the offset value A compared with the original SN, the possibility of coincidence with the interrupt cycle is reduced, and the second device will not respond to the heartbeat packet due to the conflict between the interrupt task and the heartbeat packet reply task. In this case, the occurrence of frequent disconnection is reduced.
  • the listening period SN in the first device mentioned in the embodiment of this application refers to the information stored in the first device for the second The monitoring period of the device.
  • the condition for using the default monitoring period SD is that the interrupt period has not been successfully obtained
  • the condition for using the default monitoring period SD is that the first device and the second device in the monitoring mode
  • the disconnection times of the Bluetooth communication between devices is less than the disconnection threshold.
  • steps S502 to S508 and steps S802 to S805 are specific implementation methods for the first device to determine whether the condition for using the default monitoring period SD is satisfied, and when the remote device determines that the condition for using the default monitoring period is not met , it means that the default monitoring period may coincide with the interruption period of the second device.
  • the monitoring period SN is recalculated by means of step S509, and the calculated monitoring period SN is calculated according to the interruption period, which is non-default The non-default monitoring period does not coincide with the interrupt period, so it can prompt the second device to normally reply the heartbeat packet when monitoring according to the non-default monitoring period.
  • the monitoring period SN is recalculated through step S806.
  • the calculated monitoring period SN is calculated according to the default monitoring period and the offset value A, and is a non-default monitoring period.
  • the non-default monitoring period does not Coincident with the interruption period, it can also prompt the second device to normally reply the heartbeat packet when monitoring according to the non-default monitoring period. Therefore, both step S806 and step S509 are an implementation manner of determining the monitoring period of the second device as a non-default monitoring period when it is determined that the condition for using the default monitoring period is not met.
  • the non-default monitoring period refers to a monitoring period that needs to be calculated and processed, rather than a monitoring period that is directly used by default.
  • the methods for configuring the monitoring period shown in FIG. 5 and FIG. 8 all determine that the monitoring period of the second device is a non-default monitoring period after judging that the condition for using the default monitoring period is not met, and
  • the non-default monitoring period is a monitoring period for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption period of the second device, so the non-default monitoring period is sent to the second device
  • the information of the period can make the second device monitor according to the non-default monitoring period, and will not be affected by the conflict of the interrupt task, and can reply the heartbeat packet normally, so that no disconnection will occur.
  • the step of judging whether the condition of using the default monitoring period is satisfied may be performed, and the monitoring period stored in the first device for the second device is directly set as a non-default monitoring period.
  • the step of judging whether the condition of using a default listening period is satisfied may be performed by other devices than the first device.
  • This embodiment also provides a computer-readable storage medium, the computer-readable storage medium includes instructions, and when the above-mentioned instructions are run on the electronic device, the electronic device is made to execute the relevant method steps of the first device in FIG. 5 , The related method steps of the second device in FIG. 5 , the related method steps of the second device in FIG. 8 , or the related method steps of the second device in FIG. 8 , so as to implement the methods in the foregoing embodiments.
  • This embodiment also provides a computer program product containing instructions.
  • the computer program product When the computer program product is run on the electronic device, the electronic device is made to execute the relevant method steps of the first device in FIG. 5 and the second device in FIG. 5 , the related method steps of the second device in FIG. 8 , or the related method steps of the second device in FIG. 8 , so as to implement the methods in the foregoing embodiments.
  • control device includes a processor and a memory
  • the memory is used to store computer program codes
  • the computer program codes include computer instructions
  • the control device executes the related method steps of the first device in FIG. 5, the related method steps of the second device in FIG. 5, the related method steps of the second device in FIG. 8, or the related method steps of the second device in FIG. Method steps to implement the methods in the above embodiments.
  • the control device can be an integrated circuit IC, or a system-on-chip SOC.
  • the integrated circuit can be a general integrated circuit, a field programmable gate array FPGA, or an application specific integrated circuit ASIC.
  • the disclosed system, device and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of this embodiment may be integrated into one processing unit, or each unit may physically exist separately, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of this embodiment is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium
  • several instructions are included to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor execute all or part of the steps of the method described in each embodiment.
  • the aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk, and other various media capable of storing program codes.

Abstract

The present application discloses a method for configuring a sniff interval and a corresponding electronic device, which relate to the technical field of communications, and aim to solve the problem of frequent disconnection of Bluetooth communication in a sniff mode. A specific solution is as follows: when a first device and a second device are in a Bluetooth connection state, the first device sets a sniff interval that is stored in the first device and that is used by the second device as a non-default sniff interval, and sends information about the non-default sniff interval to the second device, the non-default sniff interval being a sniff interval that is used by the second device to monitor in a sniff mode a heartbeat packet sent by the first device and that does not coincide with an interruption period of the second device. The sniff interval that is stored in the first device and that is used by the second device is set as the non-default sniff interval, so that the Bluetooth communication will not be disconnected due to the sniff interval coinciding with the interruption period.

Description

一种用于配置监听周期的方法及相应的电子设备A method for configuring monitoring period and corresponding electronic equipment
本申请要求于2021年11月11日提交中国国家知识产权局、申请号为202111330141.6、发明名称为“一种用于配置监听周期的方法及相应的电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the State Intellectual Property Office of China on November 11, 2021, with the application number 202111330141.6, and the title of the invention is "a method for configuring the monitoring cycle and corresponding electronic equipment", which The entire contents are incorporated by reference in this application.
技术领域technical field
本申请涉及通信技术领域,尤其涉及一种用于配置监听周期的方法及相应的电子设备。The present application relates to the technical field of communications, and in particular to a method for configuring a monitoring period and corresponding electronic equipment.
背景技术Background technique
用户的手机与手环、手表等蓝牙外设建立蓝牙连接之后,为了节省蓝牙外设的功耗,手机会在没有通话、音乐等业务时,控制蓝牙外设进入监听模式(Sniffmode),以降低功耗。在监听模式下,手机与蓝牙外设之间为了保持蓝牙连接,手机会按照监听周期(Sniff interval)发送心跳包给蓝牙外设,由蓝牙外设回复心跳包,通知手机当前蓝牙外设在线,蓝牙连接没有断开。After the user's mobile phone establishes a Bluetooth connection with Bluetooth peripherals such as bracelets and watches, in order to save the power consumption of the Bluetooth peripherals, the mobile phone will control the Bluetooth peripherals to enter the monitoring mode (Sniffmode) when there is no call, music, etc. power consumption. In the monitoring mode, in order to maintain the Bluetooth connection between the mobile phone and the Bluetooth peripheral, the mobile phone will send a heartbeat packet to the Bluetooth peripheral according to the sniff interval (Sniff interval), and the Bluetooth peripheral will reply the heartbeat packet to notify the mobile phone that the current Bluetooth peripheral is online. The Bluetooth connection is not disconnected.
然而,现有的监听模式下,蓝牙外设存在无法正确回复手机发送的心跳包的问题,导致手机会认为蓝牙外设不在线,从而主动断开与蓝牙外设的连接。因此,监听模式下手机与蓝牙外设之间存在频繁断连的现象。However, in the existing monitoring mode, the Bluetooth peripheral device cannot correctly reply to the heartbeat packet sent by the mobile phone, which causes the mobile phone to think that the Bluetooth peripheral device is not online, and thus actively disconnects from the Bluetooth peripheral device. Therefore, there are frequent disconnections between the mobile phone and the Bluetooth peripheral in the monitoring mode.
发明内容Contents of the invention
本申请提供了一种用于配置监听周期的方法及相应的电子设备,目的在于解决监听模式下蓝牙通信频繁断连的问题。The present application provides a method for configuring a monitoring period and corresponding electronic equipment, aiming at solving the problem of frequent disconnection of Bluetooth communication in the monitoring mode.
为了实现上述目的,本申请提供了以下技术方案:In order to achieve the above object, the application provides the following technical solutions:
第一方面,本申请公开了一种由第一设备执行的用于配置监听周期的方法,第一设备和第二设备处于蓝牙连接状态,方法包括:将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期,其中非默认的监听周期是用于第二设备在监听模式下监听第一设备发送的心跳包的、并且与第二设备的中断周期不重合的监听周期。以及向第二设备发送关于非默认的监听周期的信息。In a first aspect, the present application discloses a method for configuring a listening period performed by a first device, the first device and the second device are in a Bluetooth connection state, the method includes: using the data stored in the first device for the second The monitoring period of the device is set to a non-default monitoring period, where the non-default monitoring period is used for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption period of the second device cycle. and sending information about the non-default listening period to the second device.
本申请实施例公开的由第一设备执行的用于配置监听周期的方法中,通过将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期,而非默认的监听周期又是用于第二设备在监听模式下监听第一设备发送的心跳包的、并且与第二设备的中断周期不重合的监听周期,实现让第二设备能够按照不与第二设备的中断周期重合的监听周期来进行监听,进而不会因监听周期与中断周期而导致蓝牙通信断开。In the method for configuring the monitoring period performed by the first device disclosed in the embodiment of the present application, by setting the monitoring period stored in the first device for the second device as a non-default monitoring period instead of a default monitoring period The cycle is used for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption cycle of the second device, so that the second device can The monitoring period coincides with the monitoring period, so that the Bluetooth communication will not be disconnected due to the monitoring period and the interruption period.
在一种可能的实现方式中,在将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期之前,该方法还包括:判断是否满足使用默认的监听周期的条件。当不满足使用默认的监听周期的条件时,将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期。In a possible implementation manner, before setting the monitoring period stored in the first device for the second device as a non-default monitoring period, the method further includes: judging whether a condition for using the default monitoring period is satisfied. When the condition for using the default monitoring period is not satisfied, the monitoring period stored in the first device for the second device is set as a non-default monitoring period.
本申请实施例中,由于个别情况下默认的监听周期也可能是与第二设备的中断周期不重合的监听周期,或者当前的情况不能够使用非默认的监听周期,因此,需要判断是否满足使用默认的监听周期的条件,仅在不满足使用默认的监听周期的条件时,才将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期。In the embodiment of this application, since the default monitoring period may not coincide with the interruption period of the second device in individual cases, or the current situation cannot use a non-default monitoring period, it is necessary to determine whether the use The condition of the default monitoring period is to set the monitoring period stored in the first device for the second device as a non-default monitoring period only when the condition for using the default monitoring period is not met.
在另一种可能的实现方式中,使用默认的监听周期的条件为第一设备未成功获取到第二设备的中断周期。In another possible implementation manner, the condition for using the default monitoring period is that the first device fails to obtain the interruption period of the second device.
在另一种可能的实现方式中,在判断是否满足使用默认的监听周期的条件之前,该方法还包括:向第二设备发送中断参数获取命令,其中中断参数获取命令用于获取第二设备的中断周期。当接收到与中断参数获取命令对应的响应信息,且响应信息中携带有第二设备的中断周期时,判断出满足使用默认的监听周期的条件。以及当未接收到与中断参数获取命令对应的响应信息,或者,响应信息中未携带有第二设备的中断周期时,判断出不满足使用默认的监听周期的条件。In another possible implementation manner, before judging whether the condition for using the default monitoring period is met, the method further includes: sending an interrupt parameter acquisition command to the second device, where the interrupt parameter acquisition command is used to acquire the second device's interrupt cycle. When the response information corresponding to the interrupt parameter acquisition command is received, and the response information carries the interrupt period of the second device, it is determined that the condition for using the default monitoring period is satisfied. And when the response information corresponding to the interruption parameter acquisition command is not received, or the interruption period of the second device is not carried in the response information, it is determined that the condition of using the default monitoring period is not satisfied.
在另一种可能的实现方式中,还包括:至少根据第二设备的中断周期确定非默认的监听周期。In another possible implementation manner, the method further includes: determining a non-default monitoring period at least according to an interruption period of the second device.
在另一种可能的实现方式中,至少根据第二设备的中断周期确定非默认的监听周期包括:当接收到的第二设备的中断周期为一个时,根据所接收到的中断周期、特定倍数、以及偏移值,计算得到非默认的监听周期。当接收到的第二设备的中断周期为多个时,根据所接收到的多个中断周期的最小公倍数、特定倍数、以及偏移值,计算得到非默认的监听周期,或者,根据所接收到的多个中断周期中的最大值、特定倍数、以及偏移值,计算得到非默认的监听周期。其中,特定倍数为正整数,偏移值为整数。In another possible implementation manner, determining the non-default monitoring period at least according to the interruption period of the second device includes: when the received interruption period of the second device is one, according to the received interruption period, a specific multiple , and the offset value are calculated to obtain the non-default monitoring period. When multiple interruption periods of the second device are received, a non-default monitoring period is calculated according to the least common multiple, specific multiple, and offset value of the plurality of interruption periods received, or, according to the received The maximum value, specific multiple, and offset value among multiple interrupt periods of , are calculated to obtain a non-default monitoring period. Wherein, the specific multiple is a positive integer, and the offset value is an integer.
在另一种可能的实现方式中,非默认的监听周期的值满足处于预设范围内的条件,其中预设范围是根据默认的监听周期设定的。In another possible implementation manner, the value of the non-default monitoring period satisfies a condition of being within a preset range, where the preset range is set according to the default monitoring period.
在另一种可能的实现方式中,预设范围为非默认的监听周期与默认的监听周期的差值小于或等于预设偏差值的范围。In another possible implementation manner, the preset range is a range in which a difference between a non-default listening period and a default listening period is less than or equal to a preset deviation value.
在另一种可能的实现方式中,中断参数获取命令还用于获取第二设备的周期偏差,非默认的监听周期的值还满足非默认的监听周期与默认的监听周期的差值大于周期偏差的条件。In another possible implementation, the interrupt parameter acquisition command is also used to obtain the period deviation of the second device, and the value of the non-default listening period also satisfies that the difference between the non-default listening period and the default listening period is greater than the period deviation conditions of.
在另一种可能的实现方式中,在向第二设备发送关于非默认的监听周期的信息之后,该方法还包括:当监听模式下第一设备与第二设备之间的蓝牙通信的断连次数大于或等于断连阈值时,将第二设备的监听时长的值增加至预设值,以确定更新后的监听时长,向第二设备发送关于更新后的监听时长的信息。In another possible implementation, after sending the information about the non-default listening period to the second device, the method further includes: when the Bluetooth communication between the first device and the second device is disconnected in the listening mode, When the number of times is greater than or equal to the disconnection threshold, the value of the listening duration of the second device is increased to a preset value to determine an updated listening duration, and information about the updated listening duration is sent to the second device.
本申请实施例中,通过将第二设备的监听时长的值增加至预设值,以提高第二设备能够监听到心跳包的可能性,进而不会因第二设备不回复心跳包而导致蓝牙通信断开。In the embodiment of the present application, by increasing the value of the monitoring duration of the second device to a preset value, the possibility of the second device being able to listen to the heartbeat packet is increased, so that the Bluetooth will not be caused by the second device not replying to the heartbeat packet. Communication is lost.
在另一种可能的实现方式中,使用默认的监听周期的条件为监听模式下第一设备与第二设备之间的蓝牙通信的断连次数小于断连阈值。In another possible implementation manner, the condition for using the default listening period is that the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is less than a disconnection threshold.
在另一种可能的实现方式中,在判断是否满足使用默认的监听周期的条件之前,还包括:向第二设备发送关于默认的监听周期的信息。其中第二设备以默认的监听周期来监听第一设备发送的心跳包。In another possible implementation manner, before judging whether a condition for using the default monitoring period is met, the method further includes: sending information about the default monitoring period to the second device. The second device monitors the heartbeat packet sent by the first device with a default monitoring period.
在另一种可能的实现方式中,非默认的监听周期为默认的监听周期与偏移值的和,其中偏移值为整数。In another possible implementation manner, the non-default monitoring period is the sum of the default monitoring period and an offset value, where the offset value is an integer.
在另一种可能的实现方式中,非默认的监听周期的值满足处于预设范围内的条件,其中,预设范围是根据默认的监听周期设定的。In another possible implementation manner, the value of the non-default monitoring period satisfies a condition of being within a preset range, where the preset range is set according to the default monitoring period.
在另一种可能的实现方式中,在向第二设备发送关于非默认的监听周期的信息之后,该方法还包括:当第一设备和第二设备之间的蓝牙通信断连时,将第二设备的监听时长的值增加至预设值,以确定更新后的监听时长,向第二设备发送关于更新后的监听时长的信息。In another possible implementation manner, after sending the information about the non-default listening period to the second device, the method further includes: when the Bluetooth communication between the first device and the second device is disconnected, the second device The value of the listening duration of the second device is increased to a preset value to determine an updated listening duration, and send information about the updated listening duration to the second device.
在另一种可能的实现方式中,在将第二设备的监听时长的值增加至预设值,以确定更新后的监听时长之后,该方法还包括:向第二设备发送退出监听模式的请求,并将断连次数清零。In another possible implementation, after increasing the value of the listening duration of the second device to a preset value to determine the updated listening duration, the method further includes: sending a request to the second device to exit the listening mode , and clear the number of disconnections.
第二方面,本申请公开了一种电子设备,该电子设备包括:通信模块,通信模块包括无线通信模块,无线通信模块用于执行如上述第一方面中任一提出的由第一设备执行的用于配置监听周期的方法。In a second aspect, the present application discloses an electronic device, the electronic device includes: a communication module, the communication module includes a wireless communication module, and the wireless communication module is used to execute the method performed by the first device as proposed in any one of the above first aspects. Method for configuring the listening period.
附图说明Description of drawings
图1a为根据本申请实施例的蓝牙连接的场景示意图;FIG. 1a is a schematic diagram of a scenario of a Bluetooth connection according to an embodiment of the present application;
图1b为根据本申请实施例的蓝牙通信方法的流程示意图;FIG. 1b is a schematic flow diagram of a Bluetooth communication method according to an embodiment of the present application;
图1c为根据本申请实施例的监听模式下的监听周期示意图;FIG. 1c is a schematic diagram of a monitoring cycle in a monitoring mode according to an embodiment of the present application;
图1d为根据本申请实施例的监听模式下产生断连的场景示意图;Fig. 1d is a schematic diagram of a scene where a disconnection occurs in a listening mode according to an embodiment of the present application;
图2为根据本申请实施例的第一设备的硬件结构示意图;FIG. 2 is a schematic diagram of a hardware structure of a first device according to an embodiment of the present application;
图3为根据本申请实施例的第二设备的硬件结构示意图;FIG. 3 is a schematic diagram of a hardware structure of a second device according to an embodiment of the present application;
图4为根据本申请实施例的蓝牙协议框架示意图;FIG. 4 is a schematic diagram of a bluetooth protocol framework according to an embodiment of the present application;
图5为根据本申请实施例的用于配置监听周期的方法的一流程示意图;FIG. 5 is a schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application;
图6为根据本申请实施例的第一设备计算监听周期SN的流程示意图;FIG. 6 is a schematic flowchart of calculating the listening period SN by the first device according to an embodiment of the present application;
图7为根据本申请实施例的手环在中断周期和监听周期下的场景示意图;FIG. 7 is a schematic diagram of a scene of a wristband under an interruption period and a monitoring period according to an embodiment of the present application;
图8为根据本申请实施例的用于配置监听周期的方法的另一流程示意图。Fig. 8 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application.
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.
具体实施方式Detailed ways
本申请说明书和权利要求书及附图说明中的术语“第一”、“第二”和“第三”等是用于区别不同对象,而不是用于限定特定顺序。The terms "first", "second" and "third" in the specification, claims and description of the drawings of this application are used to distinguish different objects, rather than to limit a specific order.
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, words such as "exemplary" or "for example" are used as examples, illustrations or illustrations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of the present application shall not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete manner.
为了下述各实施例的描述清楚简洁,首先给出一种蓝牙通信的监听模式的简要介绍。In order to make the description of the following embodiments clear and concise, a brief introduction of a listening mode of Bluetooth communication is given first.
蓝牙技术是一种支持设备短距离通信的无线电技术,能够在包括移动终端、无线耳机、笔记本电脑、移动硬盘、电子书、相关外设等众多设备之间进行无线信息交换,在计算机、移动互联网、车载设备等领域被广泛应用。蓝牙连接成功之后,在蓝牙系统中的主设备只有一台,从设备可以多台,主设备和从设备之间可以进行蓝牙通信。其中,主设备为具有主控制权的设备,从设备为服从主设备的控制的设备。Bluetooth technology is a radio technology that supports short-distance communication of devices. It can exchange information wirelessly among many devices including mobile terminals, wireless headsets, laptops, mobile hard drives, e-books, and related peripherals. , Vehicle equipment and other fields are widely used. After the Bluetooth connection is successful, there is only one master device in the Bluetooth system, and there can be multiple slave devices, and Bluetooth communication can be performed between the master device and the slave device. Wherein, the master device is a device having a master control right, and the slave device is a device subject to the control of the master device.
图1a为根据本申请实施例的蓝牙连接的场景示意图。例如在图1a所示的蓝牙系统中,手机101为主设备,分别与耳机102和手环103之间建立蓝牙连接,耳机102和手环103均为手机101的从设备。为了描述清楚,本申请实施例中全文将主设备统称为第一设备,从设备统称为第二设备。Fig. 1a is a schematic diagram of a scenario of a Bluetooth connection according to an embodiment of the present application. For example, in the Bluetooth system shown in FIG. 1 a , the mobile phone 101 is the master device, and establishes Bluetooth connections with the earphone 102 and the wristband 103 respectively, and both the earphone 102 and the wristband 103 are slave devices of the mobile phone 101 . For clarity of description, throughout the embodiments of the present application, the master device is collectively referred to as the first device, and the slave devices are collectively referred to as the second device.
图1b为根据本申请实施例的蓝牙通信方法的流程示意图。参阅图1b,第一设备和第二设备之间的蓝牙通信过程为:Fig. 1b is a schematic flowchart of a Bluetooth communication method according to an embodiment of the present application. Referring to Figure 1b, the Bluetooth communication process between the first device and the second device is:
在步骤S101中,第一设备和第二设备之间建立蓝牙连接。In step S101, a Bluetooth connection is established between the first device and the second device.
在步骤S102中,第一设备和第二设备在建立蓝牙连接之后,第一设备和第二设备直接进入到了工作模式(Active mode)。In step S102, after the first device and the second device establish a Bluetooth connection, the first device and the second device directly enter into an active mode (Active mode).
在步骤S103中,第一设备发现当前无数据交互需求后,向第二设备发送进入监听模式的请求,其中,进入监听模式的请求中携带了固定的监听周期参数。In step S103, after the first device finds that there is currently no data interaction requirement, it sends a request to the second device to enter the monitoring mode, wherein the request to enter the monitoring mode carries a fixed monitoring period parameter.
第二设备通常具有低功耗的需求,例如第二设备是蓝牙外设这类的嵌入式系统的设备,而嵌入式系统具有低功耗的需求。因此,为了降低功耗,第一设备可以在不需要第二设备执行通话、音乐、数据传输等业务时(即没有数据交互需求时),控制第二设备从工作模式(Active mode)进入到监听模式,以降低第二设备的功耗。其中监听周期的值是由第一设备预配置的固定值(即默认的监听周期)。The second device usually has a requirement for low power consumption. For example, the second device is a device of an embedded system such as a Bluetooth peripheral, and the embedded system has a requirement for low power consumption. Therefore, in order to reduce power consumption, the first device can control the second device to enter the listening mode from the working mode (Active mode) when the second device is not required to perform services such as calls, music, and data transmission (that is, when there is no need for data interaction). mode to reduce the power consumption of the second device. The value of the monitoring period is a fixed value preconfigured by the first device (ie, the default monitoring period).
在步骤S104中,第二设备响应进入监听模式的请求,进入监听模式。In step S104, the second device enters the listening mode in response to the request for entering the listening mode.
当第二设备处于监听模式时,第二设备可以按照第一设备发送的监听周期,周期性地醒来监听,而不再需要在第一设备向第二设备发送数据的每个时间片(master-to-slave slot)都进行监听,达到了节省功耗的目的。例如如图1c所示,4个master-to-slave slot是一个监听周期,即每4个时间片监听一次,以获取第一设备发给第二设备的数据,节省功耗。其中,一个时间片例如为0.625ms。When the second device is in the listening mode, the second device can periodically wake up and listen according to the listening cycle sent by the first device, and no longer needs to send data to the second device every time slice (master -to-slave slot) are monitored to achieve the purpose of saving power consumption. For example, as shown in Figure 1c, the 4 master-to-slave slots are a monitoring cycle, that is, monitoring once every 4 time slices to obtain the data sent by the first device to the second device to save power consumption. Wherein, one time slice is, for example, 0.625ms.
在步骤S105中,第一设备按照固定的监听周期向第二设备发送心跳包。In step S105, the first device sends a heartbeat packet to the second device according to a fixed monitoring period.
在监听模式下,第一设备需要按照固定的监听周期,周期性地向第二设备发送心跳包,以确保蓝牙连接有效存活,第一设备通过心跳包通知第二设备自己当前在线,并等待第二设备回复心跳包。In the monitoring mode, the first device needs to periodically send a heartbeat packet to the second device according to a fixed monitoring period to ensure the effective survival of the Bluetooth connection. The first device notifies the second device that it is online through the heartbeat packet and waits for the second The second device replies with a heartbeat packet.
在步骤S106中,第二设备不回复第一设备发送的心跳包。正常情况下,第二设备在监听周期来临时醒来监听是否有收到心跳包,若收到了心跳包,就会回复心跳包,以通知第一设备自己处于在线状态。例如如图1c所示,图1c为根据本申请实施例的监听模式下的监听周期示意图,第二设备在每一个监听周期的唤醒锚点(Sniff anchor points)时刻醒过来,开始监听心跳包,若在t1时段内监听到了心跳包就会进行回复。图1c中的其他的监听周期也是如此,此处不再赘述。In step S106, the second device does not reply to the heartbeat packet sent by the first device. Under normal circumstances, the second device wakes up when the monitoring period comes and monitors whether it has received a heartbeat packet. If it receives a heartbeat packet, it will reply a heartbeat packet to notify the first device that it is online. For example, as shown in FIG. 1c, FIG. 1c is a schematic diagram of the monitoring cycle according to the monitoring mode of the embodiment of the present application. The second device wakes up at the wake-up anchor points (Sniff anchor points) of each monitoring cycle and starts to monitor the heartbeat packet. If a heartbeat packet is detected within the t1 period, it will reply. The same is true for other monitoring periods in FIG. 1c , which will not be repeated here.
但个别情况下,第二设备会出现步骤S106中的不回复第一设备发送的心跳包的情况。 第二设备不回复心跳包的原因主要是遭受了第二设备的中断周期影响。第二设备在中断周期来临时,会处理中断任务。例如在传感器的中断周期来临时,第二设备会读取传感器的数据。而当中断周期与监听周期重合时,第二设备醒来后,需要处理中断任务和心跳包回复任务,但由于中断任务处理优先级更高,因此第二设备会处理中断任务而不进行心跳包回复,进而导致第一设备无法接收到来自第二设备的心跳包回复。However, in some cases, the second device may not respond to the heartbeat packet sent by the first device in step S106. The reason why the second device does not reply the heartbeat packet is mainly that it is affected by the interruption period of the second device. When the interrupt period comes, the second device will process the interrupt task. For example, when the interruption period of the sensor comes, the second device will read the data of the sensor. When the interrupt period coincides with the monitoring period, after the second device wakes up, it needs to process the interrupt task and the heartbeat packet reply task, but because the interrupt task processing priority is higher, the second device will process the interrupt task instead of the heartbeat packet. Reply, and then cause the first device to fail to receive the heartbeat packet reply from the second device.
在步骤S107中,第一设备断开与第二设备之间的蓝牙连接。In step S107, the first device disconnects the Bluetooth connection with the second device.
当第一设备长时间没收到第二设备的回复之后,就会认为第二设备当前不在线,进而第一设备会主动断开与第二设备的蓝牙连接。When the first device does not receive a reply from the second device for a long time, it will consider that the second device is currently offline, and then the first device will actively disconnect the Bluetooth connection with the second device.
举例说明,图1d为根据本申请实施例的监听模式下产生断连的场景示意图。如图1d的(1)所示,手机10和手环20处于蓝牙连接的状态,手机10发送心跳包给手环20,手环20在监听周期时,同时有两个任务处理,分别为中断处理加速度传感器的数据以及进行心跳包回复。但中断处理加速度传感器的数据的处理优先级高于心跳包回复。因此如图1d的(2)所示,手环20执行了中断处理任务后,进行休眠,而没有回复心跳包。在多个连续的监听周期都重复发生了(1)和(2)的情况后,如图1d的(3)所示,手机10就会因为一直未收到心跳包回复,主动断开了与手环20的蓝牙连接。For example, FIG. 1d is a schematic diagram of a scene where a disconnection occurs in a listening mode according to an embodiment of the present application. As shown in (1) of Figure 1d, the mobile phone 10 and the wristband 20 are in the state of Bluetooth connection, and the mobile phone 10 sends a heartbeat packet to the wristband 20. When the wristband 20 is in the monitoring cycle, there are two tasks to process at the same time, which are interrupt Process the data of the acceleration sensor and reply the heartbeat packet. However, the processing priority of interrupt processing the data of the acceleration sensor is higher than that of the heartbeat packet reply. Therefore, as shown in (2) of FIG. 1d, after executing the interrupt processing task, the wristband 20 sleeps without replying the heartbeat packet. After the situations (1) and (2) have occurred repeatedly in multiple consecutive monitoring cycles, as shown in (3) in Figure 1d, the mobile phone 10 will actively disconnect from the communication because it has not received a heartbeat packet reply. The Bluetooth connection of the bracelet 20.
由上述描述可知,第一设备和第二设备之间的断连是由于第二设备的中断周期与监听周期重合导致的,为此,本申请实施例提出了一种用于配置监听周期的方法,由第一设备和第二设备之间交互配合执行,以使得第一设备和第二设备在监听模式下的监听周期不与中断周期重合,进而可促使第二设备正常回复心跳包,实现在监听模式下不发生断连。It can be seen from the above description that the disconnection between the first device and the second device is caused by the coincidence of the interruption period and the listening period of the second device. Therefore, the embodiment of the present application proposes a method for configuring the listening period , is executed by the interaction between the first device and the second device, so that the monitoring period of the first device and the second device in the monitoring mode does not coincide with the interrupt period, and then the second device can be prompted to reply the heartbeat packet normally, so that the No disconnection occurs in monitor mode.
为了下述对本申请提出的用于配置监听周期的方法的实施例描述清楚,首先给出与本申请实施例相关技术的简要介绍:In order to clearly describe the following embodiments of the method for configuring the monitoring period proposed by the present application, a brief introduction to the technologies related to the embodiments of the present application is first given:
1、监听模式:处于蓝牙连接状态下的第一设备和第二设备,在需要省电低功耗时所采用的模式。在监听模式下,第二设备不需要在每一个时间片都监听第一设备的数据,只需要按照监听模式下的监听周期进行监听,监听周期没来临时,第二设备可以休眠,达到低功耗的效果。1. Listening mode: the mode used by the first device and the second device in the Bluetooth connection state when power saving and low power consumption are required. In the monitoring mode, the second device does not need to monitor the data of the first device in every time slice, but only needs to monitor according to the monitoring period in the monitoring mode. When the monitoring period does not come, the second device can sleep to achieve low power consumption. consumption effect.
2、工作模式:当在蓝牙连接状态下,第二设备处于工作模式时,第二设备在第一设备向第二设备发送数据的每一个时间片单位(master-to-slave slot)中,都需要监听第一设备发给第二设备的数据。2. Working mode: When the second device is in the working mode under the bluetooth connection state, the second device sends data to the second device in every time slice unit (master-to-slave slot). It is necessary to monitor the data sent by the first device to the second device.
3、链接超时监控时间(supervision timeout):第一设备在与第二设备建立蓝牙连接之后,第一设备会下发链接超时监控时间参数,当第一设备连续在链接超时监控时间的时长内都没有收到第二设备回复的心跳包时,第一设备会主动断开与第二设备之间的蓝牙连接。3. Link timeout monitoring time (supervision timeout): After the first device establishes a Bluetooth connection with the second device, the first device will issue the link timeout monitoring time parameter. When the heartbeat packet replying from the second device is not received, the first device will actively disconnect the Bluetooth connection with the second device.
4、监听模式下的监听时长,可以用Nsniff attempt表示,监听模式下的监听时长是包含Sniff anchor point在内的、第二设备应该监听第一设备传输的时间片的数量,即当第二设备在Sniff anchor point时刻醒来后的监听时长。例如图1c示出的t1时段就是监听模式下的监听时长的值。4. The listening duration in listening mode can be represented by Nsniff attempt. The listening duration in listening mode includes the Sniff anchor point. The second device should monitor the number of time slices transmitted by the first device, that is, when the second device The listening time after waking up at the Sniff anchor point. For example, the time period t1 shown in FIG. 1 c is the value of the listening duration in the listening mode.
5、监听周期(Sniff interval):监听模式下第二设备定期(醒来)监听第一设备发送的数据的时间周期。5. Sniff interval (Sniff interval): In the sniff mode, the second device periodically (wakes up) monitors the time period for the data sent by the first device.
本申请提供的实施例可以适用于一个第一设备分别和多个第二设备建立蓝牙连接的场 景,例如图1a所示,该场景下的任意一个第二设备和第一设备之间均可配合执行本申请实施例的用于配置监听周期的方法。也可以适用于一个第一设备和一个第二设备建立蓝牙连接的场景。The embodiments provided in this application can be applied to a scenario where a first device establishes Bluetooth connections with multiple second devices, for example, as shown in Figure 1a, any second device in this scenario can cooperate with the first device Execute the method for configuring the monitoring period in the embodiment of the present application. It may also be applicable to a scenario where a first device establishes a Bluetooth connection with a second device.
本申请实施例中,第一设备和第二设备均可以是手机、平板电脑、桌面型、膝上型、笔记本电脑、超级移动个人计算机(Ultra-mobile Personal Computer,UMPC)、手持计算机、上网本、个人数字助理(Personal Digital Assistant,PDA)、可穿戴电子设备、智能手表等具有蓝牙通信功能的电子设备。In the embodiment of the present application, both the first device and the second device may be mobile phones, tablet computers, desktops, laptops, notebook computers, ultra-mobile personal computers (Ultra-mobile Personal Computer, UMPC), handheld computers, netbooks, Personal digital assistants (Personal Digital Assistant, PDA), wearable electronic devices, smart watches and other electronic devices with Bluetooth communication functions.
图2为根据本申请实施例的第一设备的硬件结构示意图。在一些实施例中,第一设备的结构可以如图2所示,第一设备201可以包括:处理器210,外部存储器接口220,内部存储器221,通用串行总线(universal serial bus,USB)接口230,充电管理模块240,电源管理模块241,电池242,天线1,天线2,移动通信模块250,无线通信模块260,音频模块270,扬声器270A,受话器270B,麦克风270C,耳机接口270D,传感器模块280,按键290,马达291,指示器292,摄像头293,显示屏294,以及用户标识模块(subscriber identification module,SIM)卡接口295等。其中传感器模块280可以包括压力传感器280A,陀螺仪传感器280B,气压传感器280C,磁传感器280D,加速度传感器280E,距离传感器280F,接近光传感器280G,指纹传感器280H,温度传感器280J,触摸传感器280K,环境光传感器280L,骨传导传感器280M等。Fig. 2 is a schematic diagram of a hardware structure of a first device according to an embodiment of the present application. In some embodiments, the structure of the first device can be as shown in FIG. 2, and the first device 201 can include: a processor 210, an external memory interface 220, an internal memory 221, and a universal serial bus (universal serial bus, USB) interface 230, charging management module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, speaker 270A, receiver 270B, microphone 270C, earphone jack 270D, sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (subscriber identification module, SIM) card interface 295, etc. The sensor module 280 may include a pressure sensor 280A, a gyro sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, and an ambient light sensor. Sensor 280L, bone conduction sensor 280M, etc.
可以理解的是,本实施例示意的结构并不构成对第一设备201的具体限定。在另一些实施例中,第一设备201可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure shown in this embodiment does not constitute a specific limitation on the first device 201 . In some other embodiments, the first device 201 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.
处理器210可以包括一个或多个处理单元,例如:处理器210可以包括应用处理器(application processor,AP),Modem,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 210 may include one or more processing units, for example: the processor 210 may include an application processor (application processor, AP), a Modem, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor) , ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
充电管理模块240用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。The charging management module 240 is configured to receive charging input from the charger. Wherein, the charger may be a wireless charger or a wired charger.
电源管理模块241用于连接电池242,充电管理模块240与处理器210。电源管理模块241接收电池242和/或充电管理模块240的输入,为处理器210,内部存储器221,显示屏294,摄像头293,和无线通信模块260等供电。The power management module 241 is used for connecting the battery 242 , the charging management module 240 and the processor 210 . The power management module 241 receives the input from the battery 242 and/or the charging management module 240 to provide power for the processor 210 , the internal memory 221 , the display screen 294 , the camera 293 , and the wireless communication module 260 .
第一设备201的无线通信功能可以通过天线1,天线2,移动通信模块250,无线通信模块260,调制解调器以及基带处理器等实现。The wireless communication function of the first device 201 may be realized by the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, a modem, and a baseband processor.
天线1和天线2用于发射和接收电磁波信号。第一设备201中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。 Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the first device 201 can be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.
移动通信模块250可以提供应用在第一设备201上的包括2G/3G/4G/5G等无线通信的解决方案。The mobile communication module 250 can provide wireless communication solutions including 2G/3G/4G/5G applied on the first device 201 .
无线通信模块260可以提供应用在第一设备201上的包括无线局域网(wireless local  area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块260可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块260经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器210。无线通信模块260还可以从处理器210接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 260 can provide applications on the first device 201 including wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (wireless fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation Satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 260 may be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210 . The wireless communication module 260 can also receive the signal to be sent from the processor 210 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 to radiate out.
在一些实施例中,在无线通信模块260提供蓝牙通信的示例中,无线通信模块260具体可以是蓝牙芯片或者蓝牙模块,无线通信模块260可以执行本申请实施例提出的用于配置监听周期的方法中第一设备所执行的步骤,具体可参阅图5和图8中的第一设备的相关描述,此处不再赘述。可替换地,处理器210可以执行本申请实施例提出的用于配置监听周期的方法中第一设备所执行的步骤。In some embodiments, in an example where the wireless communication module 260 provides Bluetooth communication, the wireless communication module 260 may specifically be a Bluetooth chip or a Bluetooth module, and the wireless communication module 260 may execute the method for configuring the listening period proposed in the embodiment of the present application For the steps performed by the first device in FIG. 5 , please refer to the relevant description of the first device in FIG. 5 and FIG. 8 for details, and details are not repeated here. Alternatively, the processor 210 may execute the steps executed by the first device in the method for configuring the listening period proposed in the embodiment of the present application.
第一设备201通过GPU,显示屏294,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏294和应用处理器。The first device 201 implements a display function through a GPU, a display screen 294, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen 294 and the application processor.
显示屏294用于显示图像,视频等。第一设备201的显示屏294上可以显示一系列图形用户界面(graphical user interface,GUI)。The display screen 294 is used to display images, videos and the like. A series of graphical user interfaces (graphical user interface, GUI) can be displayed on the display screen 294 of the first device 201.
电子设备200可以通过ISP,摄像头293,视频编解码器,GPU,显示屏294以及应用处理器等实现拍摄功能。The electronic device 200 can realize the shooting function through the ISP, the camera 293 , the video codec, the GPU, the display screen 294 and the application processor.
摄像头293用于捕获静态图像或视频。Camera 293 is used to capture still images or video.
外部存储器接口220可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备200的存储能力。The external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200.
内部存储器221可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器210通过运行存储在内部存储器221的指令,从而执行电子设备200的各种功能应用以及数据处理。The internal memory 221 may be used to store computer-executable program codes including instructions. The processor 210 executes various functional applications and data processing of the electronic device 200 by executing instructions stored in the internal memory 221 .
第一设备201可以通过音频模块270,扬声器270A,受话器270B,麦克风270C,耳机接口270D,以及应用处理器等实现音频功能。例如音乐播放,录音等。电子设备200还可以包括压力传感器280A,气压传感器280C,陀螺仪传感器280B,磁传传感器280D,加速度传感器280E,距离传感器280F,接近光传感器280G,环境光传感器280L,指纹传感器280H,温度传感器280J,触摸传感器280K,骨传导传感器280M,按键290,马达291,指示器292等。The first device 201 may implement an audio function through an audio module 270 , a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, and an application processor. Such as music playback, recording, etc. The electronic device 200 may also include a pressure sensor 280A, an air pressure sensor 280C, a gyro sensor 280B, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, an ambient light sensor 280L, a fingerprint sensor 280H, a temperature sensor 280J, Touch sensor 280K, bone conduction sensor 280M, button 290, motor 291, indicator 292, etc.
SIM卡接口295用于连接SIM卡。SIM卡可以通过插入SIM卡接口295,或从SIM卡接口295拔出,实现和电子设备200的接触和分离。电子设备200可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口295可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口295可以同时插入多张卡。SIM卡接口295也可以兼容外部存储卡。第一设备201通过SIM卡和网络交互,实现通话以及数据通信等功能。The SIM card interface 295 is used for connecting a SIM card. The SIM card can be connected and separated from the electronic device 200 by inserting it into the SIM card interface 295 or pulling it out from the SIM card interface 295 . The electronic device 200 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. SIM card interface 295 can support Nano SIM card, Micro SIM card, SIM card etc. Multiple cards can be inserted into the same SIM card interface 295 at the same time. The SIM card interface 295 is also compatible with external memory cards. The first device 201 interacts with the network through the SIM card to implement functions such as calling and data communication.
另外,在上述部件之上,运行有操作系统,例如鸿蒙操作系统、iOS操作系统,Android操作系统,Windows操作系统等。在该操作系统上可以安装运行应用程序。在另一些实施例中,电子设备内运行的操作系统可以有多个。In addition, on the above components, there are operating systems running, such as Hongmeng operating system, iOS operating system, Android operating system, Windows operating system, etc. Applications can be installed and run on this operating system. In other embodiments, there may be multiple operating systems running in the electronic device.
图3为根据本申请实施例的第二设备的硬件结构示意图。在一些实施例中,第二设备的结构可以如图3所示,第二设备202可以包括:处理器201A,存储器202A,蓝牙通信模块203A,天线204A,电源开关205A,USB通信处理模块206A,音频模块207A,传感器模块208A。其中:Fig. 3 is a schematic diagram of a hardware structure of a second device according to an embodiment of the present application. In some embodiments, the structure of the second device may be as shown in FIG. 3 , and the second device 202 may include: a processor 201A, a memory 202A, a Bluetooth communication module 203A, an antenna 204A, a power switch 205A, a USB communication processing module 206A, Audio module 207A, sensor module 208A. in:
处理器201A可用于读取和执行计算机可读指令。具体实现中,处理器201A可主要包括控制器、运算器和寄存器。其中,控制器主要负责指令译码,并为指令对应的操作发出控制信号。运算器主要负责保存指令执行过程中临时存放的寄存器操作数和中间操作结果等。具体实现中,处理器201A的硬件架构可以是专用集成电路(ASIC)架构、MIPS架构、ARM架构或者NP架构等等。Processor 201A may be used to read and execute computer readable instructions. In a specific implementation, the processor 201A may mainly include a controller, an arithmetic unit, and a register. Among them, the controller is mainly responsible for instruction decoding, and sends out control signals for the operations corresponding to the instructions. The arithmetic unit is mainly responsible for saving the register operands and intermediate operation results temporarily stored during the execution of the instruction. In a specific implementation, the hardware architecture of the processor 201A may be an application-specific integrated circuit (ASIC) architecture, a MIPS architecture, an ARM architecture, or an NP architecture, and the like.
在一些实施例中,处理器201A可以用于解析蓝牙通信处理模块203接收到的信号,如第一设备201发送的请求、命令、心跳包等等。处理201A可以用于根据解析结果进行相应的处理操作,如生成请求对应的响应、命令对应的响应等等。In some embodiments, the processor 201A may be used to analyze signals received by the Bluetooth communication processing module 203, such as requests, commands, heartbeat packets and the like sent by the first device 201. The processing 201A can be used to perform corresponding processing operations according to the parsing results, such as generating a response corresponding to a request, a response corresponding to a command, and so on.
存储器202A与处理器201A耦合,用于存储各种软件程序和/或多组指令。具体实现中,存储器202A可包括高速随机存取的存储器,并且也可包括非易失性存储器,例如一个或多个磁盘存储设备、闪存设备或其他非易失性固态存储设备。存储器202A可以存储操作系统,例如uCOS,VxWorks、RTLinux等嵌入式操作系统。存储器202A还可以存储通信程序,该通信程序可用于与第一设备201,一个或多个服务器,或其他设备进行通信。The memory 202A is coupled with the processor 201A for storing various software programs and/or sets of instructions. In a specific implementation, the memory 202A may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices or other non-volatile solid-state storage devices. The memory 202A can store operating systems, such as embedded operating systems such as uCOS, VxWorks, and RTLinux. The memory 202A can also store a communication program that can be used to communicate with the first device 201, one or more servers, or other devices.
蓝牙通信模块203A可以包括经典蓝牙(BR/EDR)模块和低功耗蓝牙(BLE)模块。The Bluetooth communication module 203A may include a Bluetooth Classic (BR/EDR) module and a Bluetooth Low Energy (BLE) module.
在一些实施例中,蓝牙通信模块203A可以执行本申请实施例提出的用于配置监听周期的方法中第二设备202所执行的步骤,具体可参阅图5和图8中的第二设备的相关描述,此处不再赘述。可替换地,处理器201A可以执行本申请实施例提出的用于配置监听周期的方法中第二设备所执行的步骤。In some embodiments, the Bluetooth communication module 203A can execute the steps performed by the second device 202 in the method for configuring the listening period proposed in the embodiment of the present application. For details, please refer to the related information of the second device in FIG. 5 and FIG. 8 . description and will not be repeated here. Alternatively, the processor 201A may execute the steps executed by the second device in the method for configuring the listening period proposed in the embodiment of the present application.
第二设备202的无线通信功能可以通过天线204A,蓝牙通信模块203A,调制解调处理器等实现。The wireless communication function of the second device 202 can be realized through the antenna 204A, the Bluetooth communication module 203A, the modem processor and the like.
天线204A可用于发射和接收电磁波信号。第二电子设备200中的每个天线可用于覆盖单个或多个通信频带。The antenna 204A can be used to transmit and receive electromagnetic wave signals. Each antenna in the second electronic device 200 may be used to cover single or multiple communication frequency bands.
在一些实施例中蓝牙通信模块203A的天线可以有一个或多个。In some embodiments, there may be one or more antennas of the Bluetooth communication module 203A.
电源开关205A可用于控制电源向第二电子设备200的供电。The power switch 205A can be used to control power supply to the second electronic device 200 .
USB通信处理模块206A可用于通过USB接口(未示出)与其他设备进行通信。The USB communication processing module 206A can be used to communicate with other devices through a USB interface (not shown).
音频模块207A可用于通过音频输出接口输出音频信号,这样可使得第二设备202支持音频播放。音频模块还可用于通过音频输入接口接收音频数据。第二设备202可以为蓝牙耳机等媒体播放设备。The audio module 207A can be used to output audio signals through the audio output interface, so that the second device 202 can support audio playback. The audio module can also be used to receive audio data through the audio input interface. The second device 202 may be a media player such as a Bluetooth headset.
传感器模块208A包括一个或多个传感器。例如,可以包括加速度传感器和陀螺仪传感器。The sensor module 208A includes one or more sensors. For example, acceleration sensors and gyro sensors may be included.
加速度传感器可检测第二设备202在各个方向上(一般为三轴)加速度的大小。当第二设备202静止时可检测出重力的大小及方向。还可以用于识别第二设备202姿态,应用于横竖屏切换,计步器等应用。The acceleration sensor can detect the acceleration of the second device 202 in various directions (generally three axes). When the second device 202 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the second device 202, and it can be applied to applications such as horizontal and vertical screen switching, pedometer, etc.
陀螺仪传感器可以用于确定第二设备202的运动姿态。在一些实施例中,可以通过陀 螺仪传感器确定第二设备202围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器可以用于拍摄防抖。The gyroscope sensor can be used to determine the motion posture of the second device 202 . In some embodiments, the angular velocity of the second device 202 about three axes (i.e., x, y, and z axes) may be determined by a gyroscopic sensor. The gyro sensor can be used for image stabilization.
在本申请实施例中,蓝牙通信模块203A在传感器模块208A中的传感器的中断周期来临时,会处理传感器所采集到的数据。In the embodiment of the present application, the Bluetooth communication module 203A will process the data collected by the sensor when the interruption period of the sensor in the sensor module 208A comes.
可以理解的是图3示意的结构并不构成对第二设备202的具体限定。在本申请另一些实施例中,第二设备202可以包括比图示更多或更少的部件,或组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure shown in FIG. 3 does not constitute a specific limitation on the second device 202 . In some other embodiments of the present application, the second device 202 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.
在一些实施例中,第一设备201的结构图也可以如图3所示,第二设备202的结构图也可以如图2所示,本申请实施例对此不作限制。In some embodiments, the structural diagram of the first device 201 may also be shown in FIG. 3 , and the structural diagram of the second device 202 may also be shown in FIG. 2 , which is not limited in this embodiment of the present application.
图4为根据本申请实施例的蓝牙协议框架示意图。如图4所示,本申请实施例提供一种蓝牙协议框架示意图,该蓝牙协议框架示意图可以是第一设备201的蓝牙协议框架,也可以是第二设备202的蓝牙协议框架,该蓝牙协议框架示意图包括但不限于Host(主机)协议栈、HCI(Host Controller Interface)、控制器(controller)。FIG. 4 is a schematic diagram of a Bluetooth protocol framework according to an embodiment of the present application. As shown in Figure 4, the embodiment of the present application provides a schematic diagram of a bluetooth protocol framework. The schematic diagram includes but is not limited to Host (host) protocol stack, HCI (Host Controller Interface), and controller (controller).
其中,Host协议栈定义了蓝牙框架中的多个应用(profile)和核心协议(protocol),每个profile定义了各自相应的消息格式与应用规则,profile是蓝牙服务(Application)。为了实现不同平台下的不同设备的互联互通,蓝牙协议为各种可能的、有通用意义的应用场景,都制定了规范,如A2DP(advanced audio distributionprofile)、HFP(hands-free profile)等等。核心协议包括但不限于蓝牙基本的服务协议SDP(servicediscoverprotocol)、逻辑链路控制和适配协议L2CAP(logical link control andadaptation protocol)等。核心协议是蓝牙协议栈中必不可少的。Among them, the Host protocol stack defines multiple applications (profiles) and core protocols (protocols) in the Bluetooth framework, each profile defines its corresponding message format and application rules, and a profile is a Bluetooth service (Application). In order to realize the interconnection and intercommunication of different devices under different platforms, the Bluetooth protocol has formulated specifications for various possible and general-purpose application scenarios, such as A2DP (advanced audio distribution profile), HFP (hands-free profile) and so on. Core protocols include, but are not limited to, the basic Bluetooth service protocol SDP (service discover protocol), logical link control and adaptation protocol L2CAP (logical link control and adaptation protocol), etc. The core protocol is essential in the Bluetooth protocol stack.
其中,HCI为上层协议提供了进入链路管理器的统一接口和进入基带的统一方式,在主机核心协议栈和控制器之间会存在若干传输层,这些传输层是透明的,完成传输数据的任务,蓝牙技术联盟(Bluetooth Special Interest Group,SIG)规定了四种与硬件连接的物理总线方式,即四种HCI传输层:USB、RS232、UART和PC卡。Among them, HCI provides a unified interface for the upper layer protocol to enter the link manager and a unified way to enter the baseband. There will be several transport layers between the host core protocol stack and the controller. These transport layers are transparent and complete the transmission of data. Task, the Bluetooth Special Interest Group (SIG) stipulates four physical bus methods connected to hardware, that is, four HCI transport layers: USB, RS232, UART and PC card.
其中,controller定义了底层硬件部分,包括无线射频(RF)、基带(BB)和链路管理(LM),RF层通过2.4GHz无需授权的ISM频段的微波,实现数据位流的过滤和传输,主要定义了蓝牙收发器在此频带正常工作所需要满足的条件。基带负责跳频以及蓝牙数据和信息帧的传输。链路管理负责连接、建立和拆除链路并进行安全控制。LM(Link Manager)层是蓝牙协议栈的链路管理层协议,负责将上层HCI命令翻译成基带能接受的操作,建立异步链路(asynchronous connection-oriented link,ACL)和同步链路(synchronous connection-oriented/extended,SCO)以及使第二电子设备进入节能状态的工作模式等。LC(LinkControl)层负责在一批数据包传送期间,响应上层LM命令(如执行建立数据包的传输链路,维持链路等功能的LM命令)。Among them, the controller defines the underlying hardware part, including radio frequency (RF), baseband (BB) and link management (LM). The RF layer realizes the filtering and transmission of the data bit stream through the microwave of the 2.4GHz unlicensed ISM frequency band. It mainly defines the conditions that the Bluetooth transceiver needs to meet to work normally in this frequency band. The baseband is responsible for frequency hopping and transmission of Bluetooth data and information frames. Link management is responsible for connecting, establishing and tearing down links and performing security controls. The LM (Link Manager) layer is the link management protocol of the Bluetooth protocol stack. It is responsible for translating the upper-layer HCI commands into operations acceptable to the baseband, and establishing an asynchronous connection-oriented link (ACL) and a synchronous connection. -oriented/extended, SCO) and the working mode that makes the second electronic device enter the energy-saving state, etc. The LC (LinkControl) layer is responsible for responding to upper-layer LM commands during the transmission of a batch of data packets (such as executing LM commands for establishing a transmission link for data packets, maintaining links, etc.).
本申请实施例中,当图4示出的是第一设备的蓝牙协议框架示意图时,蓝牙协议栈(BT Stack)可以用于执行图5和图8中第一设备的相关部分内容。当图4示出的是第二设备的蓝牙协议框架示意图时,蓝牙协议栈(BT Stack)可以用于执行图5和图8中第二设备的相关部分内容。In the embodiment of the present application, when FIG. 4 shows a schematic diagram of the Bluetooth protocol framework of the first device, the Bluetooth protocol stack (BT Stack) can be used to execute relevant parts of the first device in FIGS. 5 and 8 . When FIG. 4 shows a schematic diagram of the bluetooth protocol framework of the second device, the bluetooth protocol stack (BT Stack) can be used to execute the relevant parts of the second device in FIG. 5 and FIG. 8 .
实施例一Embodiment one
图5为根据本申请实施例的用于配置监听周期的方法的另一流程示意图。参阅图5,基于前述所提及的第一设备和第二设备,本申请实施例针对第一设备和第二设备为同一厂家的电子设备,且第一设备和第二设备之间有相互约定好的基于应答协议(echo)的私有命令的场景,提出了一种用于配置监听周期的方法,由第一设备和第二设备相互配合执行。具体包括以下步骤:Fig. 5 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application. Referring to Figure 5, based on the first device and the second device mentioned above, the embodiment of the present application aims at that the first device and the second device are electronic devices of the same manufacturer, and there is a mutual agreement between the first device and the second device In the scenario of a private command based on the response protocol (echo), a method for configuring a monitoring period is proposed, which is executed by the first device and the second device in cooperation with each other. Specifically include the following steps:
S501、第一设备与第二设备之间建立蓝牙连接。S501. Establish a Bluetooth connection between the first device and the second device.
第一设备和第二设备之间可以通过蓝牙技术(包括经典蓝牙(Basic Rate/EnhancedData Rate,BR/EDR)和低功耗蓝牙(Bluetooth Low Energy,BLE))建立蓝牙连接。在建立蓝牙连接的过程中,第一设备与第二设备之间协议约定第一设备为主设备,第二设备为从设备。A Bluetooth connection can be established between the first device and the second device through Bluetooth technology (including classic Bluetooth (Basic Rate/Enhanced Data Rate, BR/EDR) and Bluetooth Low Energy (Bluetooth Low Energy, BLE)). In the process of establishing the Bluetooth connection, the agreement between the first device and the second device stipulates that the first device is a master device, and the second device is a slave device.
举例说明,当第一设备为手机,第二设备为手环时,用户可以操作第一设备的界面开启蓝牙功能,配对连接手环,实现手机和手环之间建立连接。For example, when the first device is a mobile phone and the second device is a wristband, the user can operate the interface of the first device to enable the Bluetooth function, pair and connect the wristband, and establish a connection between the mobile phone and the wristband.
具体的,蓝牙连接的建立过程的实现方式有很多,包括但不限于本申请实施例所提出的内容。第一设备和第二设备之间建立蓝牙连接的方式可以参考蓝牙协议的规定,本申请实施例对此不做限定。Specifically, there are many ways to implement the establishment process of the Bluetooth connection, including but not limited to the content proposed in the embodiment of the present application. For a manner of establishing a Bluetooth connection between the first device and the second device, reference may be made to the provisions of the Bluetooth protocol, which is not limited in this embodiment of the present application.
S502、第一设备向第二设备发送中断参数获取命令。S502. The first device sends an interrupt parameter acquisition command to the second device.
其中,中断参数获取命令用于获取第二设备的中断周期和周期偏差。中断周期指的是第二设备执行中断任务的周期。为了描述更为清楚简洁,在下文中,中断周期统一用N来表示,周期偏差用o来表示。例如,中断周期可以是第二设备的传感器的中断周期,中断任务为读取传感器数据的任务,即第二设备按照传感器的中断周期,周期性地读取并处理传感器采集到的数据。第二设备可以具有多个中断周期,分别用于执行不同的中断任务。周期偏差o指的是第二设备的时钟误差。例如,当第二设备的周期偏差o为5ms,而中断周期为500ms时,本来第二设备应该在500ms时执行中断任务,但因为存在时钟误差,则第二设备可能会在495ms至505ms的范围内执行中断任务。Wherein, the interrupt parameter acquiring command is used to acquire the interrupt period and period deviation of the second device. The interrupt period refers to a period in which the second device executes the interrupt task. In order to describe more clearly and concisely, in the following, the interruption cycle is uniformly represented by N, and the cycle deviation is represented by o. For example, the interruption period may be the interruption period of the sensor of the second device, and the interruption task is the task of reading sensor data, that is, the second device periodically reads and processes the data collected by the sensor according to the interruption period of the sensor. The second device may have multiple interrupt cycles, which are respectively used to execute different interrupt tasks. The period offset o refers to the clock error of the second device. For example, when the period deviation o of the second device is 5ms and the interrupt period is 500ms, the second device should execute the interrupt task at 500ms, but because of the clock error, the second device may execute the interrupt task in the range of 495ms to 505ms Execute the interrupt task within.
在一些实施例中,步骤S502是第一设备在工作模式下执行的。第一设备在执行完步骤S502之后,就直接控制第二设备进入工作模式。例如,第一设备向第二设备发送进入工作模式的请求,第二设备响应进入工作模式的请求,进入工作模式。有关工作模式的相关描述可参见前述对工作模式的相关技术介绍,此处不再赘述。第一设备可以是在工作模式下的任意时刻执行步骤S502。在工作模式下执行步骤S502的时机本申请实施例不做限制。In some embodiments, step S502 is performed by the first device in the working mode. After executing step S502, the first device directly controls the second device to enter the working mode. For example, the first device sends a request to enter the working mode to the second device, and the second device enters the working mode in response to the request to enter the working mode. For related descriptions of the working modes, refer to the foregoing technical introduction to the working modes, and will not be repeated here. The first device may execute step S502 at any time in the working mode. The timing of executing step S502 in the working mode is not limited in this embodiment of the present application.
在一些实施例中,中断参数获取命令可以是一种应答协议(echo)私有命令,即是一种基于逻辑链路控制和适配协议(Logical Link Control andAdaptation Protocol,L2CAP)的echo消息进行交互的私有命令。中断参数获取命令内部携带有特定的ID,该特定的ID是第一设备和第二设备均预先定义好的。在一些实施例中,echo私有命令的格式为由服务ID、命令ID以及有效载荷组成的格式。中断参数获取命令的格式中的服务ID和命令ID是特定的,用于定义获取中断周期N和周期偏差o。In some embodiments, the interrupt parameter acquisition command can be a private command of the response protocol (echo), that is, an echo message based on the Logical Link Control and Adaptation Protocol (Logical Link Control and Adaptation Protocol, L2CAP) for interaction. private command. The interrupt parameter acquisition command carries a specific ID inside, and the specific ID is pre-defined by both the first device and the second device. In some embodiments, the format of the echo private command is a format consisting of a service ID, a command ID, and a payload. The service ID and command ID in the format of the interrupt parameter acquisition command are specific, and are used to define the acquisition interrupt cycle N and cycle deviation o.
S503、第二设备响应中断参数获取命令,返回与中断参数获取命令对应的响应信息至第一设备。S503. The second device responds to the interrupt parameter acquisition command, and returns response information corresponding to the interrupt parameter acquisition command to the first device.
其中,第二设备如果能成功响应中断参数获取命令,即可以将第二设备的所有中断周期N以及周期偏差o携带在响应信息里面,返回给第一设备。第二设备如果不能成功响应中断参数获取命令,可以不返回响应信息,或者返回的响应信息中不携带中断周期N以及周期偏差o。需要说明的是,第二设备内部的中断周期可能有一个或者多个。不同中断周期对应不同中断任务。例如,当第二设备为手环时,具有加速度传感器对应的中断中期和陀螺仪传感器对应的中断周期,在加速度传感器的中断周期来临时,手环读取并处理加速度传感器的数据。当陀螺仪传感器对应的中断周期来临时,手环读取并处理陀螺仪传感器的数据。Wherein, if the second device can successfully respond to the interrupt parameter acquisition command, it can carry all the interrupt cycles N and cycle deviation o of the second device in the response information and return them to the first device. If the second device fails to respond successfully to the interrupt parameter acquisition command, it may not return response information, or the returned response information does not carry the interrupt period N and the period deviation o. It should be noted that there may be one or more interrupt cycles inside the second device. Different interrupt periods correspond to different interrupt tasks. For example, when the second device is a wristband, there is an interruption period corresponding to the acceleration sensor and an interruption period corresponding to the gyroscope sensor. When the interruption period of the acceleration sensor comes, the wristband reads and processes the data of the acceleration sensor. When the interrupt period corresponding to the gyroscope sensor comes, the wristband reads and processes the data of the gyroscope sensor.
在一些实施例中,中断参数获取命令是基于echo协议的私有命令。第二设备能够成功响应该命令的场景为:中断参数获取命令在第二设备内部被预定义过,第二设备可以通过命令中特有的ID标识,解析出该命令是用于获取中断周期N以及周期偏差o的命令,进而能够成功响应命令,将自身的中断周期N以及周期偏差o携带到响应信息里返回给第一设备。而第二设备无法成功响应该命令的场景为:1、第二设备不支持私有命令。当第二设备不支持私有命令时,无法解析中断参数获取命令,进而无法响应,不会返回任何数据给第一设备。此时第一设备无法收到响应信息。2、第二设备内没有预定义该命令。若第一设备发送的中断参数获取命令中的ID,没有在第二设备内部找到定义,第二设备就无法解析出该命令用于获取中断周期N以及周期偏差o,进而第二设备回复的响应信息可能是乱码。In some embodiments, the interrupt parameter acquisition command is a private command based on the echo protocol. The scenario where the second device can successfully respond to the command is: the interrupt parameter acquisition command is predefined inside the second device, and the second device can parse out that the command is used to obtain the interrupt period N and The command of the period deviation o can then successfully respond to the command, carry its own interrupt period N and the period deviation o into the response information and return it to the first device. The scenario where the second device cannot successfully respond to the command is as follows: 1. The second device does not support the private command. When the second device does not support the private command, it cannot parse the interrupt parameter acquisition command, and thus cannot respond, and will not return any data to the first device. At this time, the first device cannot receive the response information. 2. The command is not predefined in the second device. If the ID in the interrupt parameter acquisition command sent by the first device does not find a definition inside the second device, the second device cannot parse out that the command is used to obtain the interrupt cycle N and cycle deviation o, and then the response returned by the second device Information may be garbled.
在一些实施例中,第二设备在执行步骤S503之后,若后续出现中断周期有变动的情况下,可以主动上报给第一设备。例如,第二设备可以使用echo私有命令上报中断周期。然后第一设备再重新存储新的中断周期N,后续执行步骤S509时,使用新的中断周期N进行计算SN。In some embodiments, after the second device executes step S503, if there is a subsequent change in the interruption period, it may actively report to the first device. For example, the second device may use the echo private command to report the interruption period. Then the first device stores the new interruption period N again, and uses the new interruption period N to calculate SN when step S509 is executed subsequently.
可替换地,第二设备也可以主动向第一设备上报中断周期,而不需要在第一设备执行步骤S502之后,才向第一设备上报。即第二设备上报中断周期可不需要第一设备的命令或请求触发。Alternatively, the second device may also actively report the interruption period to the first device, without reporting to the first device after the first device performs step S502. That is, the reporting of the interrupt period by the second device may not be triggered by a command or request from the first device.
S504、第一设备判断是否成功获取到中断周期N和周期偏差o。S504. The first device judges whether the interruption period N and the period deviation o are successfully obtained.
具体的,第一设备可以是解析并读取接收到的中断参数获取命令对应的响应信息,判断响应信息中是否有中断周期N和周期偏差o。如果响应信息中回复了中断周期N和周期偏差o,则执行步骤S505。如果响应信息中没有回复中断周期N和周期偏差o,例如回复了乱码,则执行步骤S506。Specifically, the first device may parse and read the response information corresponding to the received interrupt parameter acquisition command, and judge whether there is an interrupt period N and a period deviation o in the response information. If the interruption period N and the period deviation o are returned in the response information, step S505 is performed. If the response information does not reply the interruption cycle N and the cycle deviation o, for example, a garbled code is returned, then step S506 is executed.
在另一些实施例中,若第一设备在预设时长内都没有收到第二设备返回的响应信息,则也是判断出没有成功获取到中断周期N和周期偏差o,执行步骤S506。In other embodiments, if the first device does not receive the response information returned by the second device within the preset time period, it also judges that the interruption period N and the period deviation o have not been successfully obtained, and step S506 is executed.
S505、第一设备将获取到的中断周期N和周期偏差o进行存储。S505. The first device stores the acquired interrupt period N and period deviation o.
第一设备将从响应信息中读取到的N和o参数均进行存储,等待第一设备和第二设备进入监听模式时使用。The first device stores both the N and o parameters read from the response information for use when the first device and the second device enter the monitoring mode.
在一些实施例中,第一设备可以通过第一设备中的蓝牙协议栈执行步骤S505。蓝牙协议栈的相关描述可参考图4的相关部分,此处不再赘述。In some embodiments, the first device may execute step S505 through the Bluetooth protocol stack in the first device. For the relevant description of the Bluetooth protocol stack, reference may be made to the relevant part in FIG. 4 , which will not be repeated here.
S506、第一设备将中断周期N设置为特殊值。S506. The first device sets the interrupt period N as a special value.
当中断周期N没有成功获取到时,可以将中断周期N设置为特殊值,例如以0、-1或 者其他的负数作为特殊值,以标识第一设备没有获取到中断周期参数和周期偏差参数。When the interrupt cycle N is not obtained successfully, the interrupt cycle N can be set to a special value, such as 0, -1 or other negative numbers as the special value, to indicate that the first device has not obtained the interrupt cycle parameter and the cycle deviation parameter.
在另一些实施例中,还可以是专门使用一个额外的获取结果状态参数K,来标识是否有成功获取到中断周期参数和周期偏差参数。例如,当成功获取到中断周期N和周期偏差o时,还可以将K设置为1,表征第一设备成功获取到中断周期N和周期偏差o,后续第二设备进入监听模式时,第一设备读取到K为1时,即可使用步骤S505中存储的中断周期N和周期偏差o。若没有成功获取到中断周期N和周期偏差o时,还可以将K设置为-1,表征第一设备没有获取中断周期N和周期偏差o,后续第二设备进入监听模式时,第一设备读取到K为-1时,就不再去读取以及使用中断周期N和周期偏差o。In some other embodiments, an additional acquisition result status parameter K may also be specially used to identify whether the interruption period parameter and the period deviation parameter have been successfully acquired. For example, when the interruption period N and the period deviation o are successfully obtained, K can also be set to 1, which means that the first device successfully obtains the interruption period N and the period deviation o, and when the second device enters the monitoring mode, the first device When it is read that K is 1, the interrupt period N and period deviation o stored in step S505 can be used. If the interruption period N and period deviation o are not obtained successfully, K can also be set to -1, indicating that the first device has not obtained the interruption period N and period deviation o, and when the second device enters the monitoring mode, the first device reads When K is -1, no longer read and use the interrupt cycle N and cycle deviation o.
S507、第一设备确定其与第二设备之间无数据交互。S507. The first device determines that there is no data interaction between it and the second device.
在执行步骤S507之前,第一设备和第二设备工作于工作模式,第二设备在每一个slot中都进行监听。当第一设备确定出当前已经没有与第二设备之间进行数据交互的需求了,或者说已经没有需要第二设备执行的业务了,那么可以确定出了其与第二设备之间无数据交互。Before step S507 is executed, the first device and the second device work in the working mode, and the second device monitors in each slot. When the first device determines that there is no need for data interaction with the second device at present, or that there is no business that needs to be performed by the second device, then it can be determined that there is no data interaction between it and the second device .
S508、第一设备判断中断周期N是否为正数。S508. The first device judges whether the interruption period N is a positive number.
执行步骤S508的目的在于判断第一设备是否成功获取了中断周期N。The purpose of executing step S508 is to determine whether the first device successfully acquires the interruption period N.
当第一设备在前述步骤S503中成功获取到了中断周期N,那么经过步骤S505的处理,读取到的中断周期N就会是正数,即判断出中断周期N是正数,执行步骤S509。需要说明的是,若步骤S503中成功获取到了中断周期N,中断周期N也可能不止有一个,且都为正数。When the first device successfully obtains the interruption period N in the aforementioned step S503, after the processing of step S505, the read interruption period N will be a positive number, that is, it is judged that the interruption period N is a positive number, and step S509 is executed. It should be noted that, if the interrupt cycle N is successfully obtained in step S503, there may be more than one interrupt cycle N, and all of them are positive numbers.
当第一设备没有成功获取到中断周期N,那么经过步骤S506的处理,步骤S508中读取到的中断周期N就会是-1,即判断出N不为正数,执行步骤S510。When the first device fails to obtain the interruption period N, after the processing of step S506, the interruption period N read in step S508 will be -1, that is, it is determined that N is not a positive number, and step S510 is executed.
S509、第一设备根据中断周期N,计算出第二设备的监听周期。S509. The first device calculates the monitoring period of the second device according to the interruption period N.
其中,第一设备计算出的第二设备的监听周期为第二设备在监听模式下所使用的监听周期。为了描述方便,以下统一将监听周期用SN表示,其中第二设备的监听周期SN不与中断周期N重合。Wherein, the listening period of the second device calculated by the first device is the listening period used by the second device in the listening mode. For the convenience of description, the monitoring period is collectively denoted by SN below, wherein the monitoring period SN of the second device does not coincide with the interruption period N.
第一设备计算出的监听周期SN是一个不会与中断周期N重合的周期。进而能够保障第二设备不会遇到中断任务与心跳包回复的任务冲突的情况。The listening period SN calculated by the first device is a period that will not overlap with the interruption period N. Furthermore, it can be ensured that the second device will not encounter a conflict between the interruption task and the heartbeat packet reply task.
其中,通过计算得到的监听周期都属于非默认的监听周期。而原本预配置好的监听周期则称为默认的监听周期,为了描述简洁清楚,以下统一用SD来表示默认的监听周期。在一些实施例中,SN满足处于[SD-L,SD+L]的范围内的条件。其中,L为预设偏差值,例如L可以取100ms。在一些实施例中,第一设备针对不同的第二设备,默认监听周期的值也会适应性的不同。默认监听周期是通过试验所得出的,是第二设备在监听模式下比较适合的监听周期,能够满足第二设备在监听模式下的性能要求。因此,当SN处于[SD-L,SD+L]的范围内时,SN与SD接近,第二设备的监听周期设定的比较合理,能满足第二设备在监听模式下的性能要求。Wherein, the monitoring periods obtained through calculation all belong to non-default monitoring periods. The originally pre-configured monitoring period is called the default monitoring period. In order to describe concisely and clearly, SD is used to represent the default monitoring period. In some embodiments, the SN satisfies the condition of being in the range of [SD-L, SD+L]. Wherein, L is a preset deviation value, for example, L may be 100ms. In some embodiments, the value of the default listening period of the first device is adaptively different for different second devices. The default monitoring period is obtained through experiments, and is a relatively suitable monitoring period for the second device in the monitoring mode, and can meet the performance requirements of the second device in the monitoring mode. Therefore, when SN is in the range of [SD-L, SD+L], SN is close to SD, and the monitoring period of the second device is set reasonably, which can meet the performance requirements of the second device in the monitoring mode.
在一些实施例中,SN还满足与SD之间的差值大于周期偏差o的条件。由于第二设备存在时钟延迟的问题,导致中断周期可能存在偏差。周期偏差o代表如果中断周期是N那 么实际运行时的中断周期可能是N±o。例如如果中断周期N是300ms,周期偏差o为10ms,那么实际运行时的中断周期为300±10ms的范围内,因此,为了避免引时钟延迟导致计算出的SN还是会与中断周期重合,SN与SD之间的差值还可以大于周期偏差o。In some embodiments, SN also satisfies the condition that the difference from SD is greater than the periodic deviation o. Due to the problem of clock delay in the second device, there may be a deviation in the interrupt period. The cycle deviation o means that if the interrupt cycle is N, the interrupt cycle in actual operation may be N±o. For example, if the interrupt period N is 300ms, and the period deviation o is 10ms, then the actual interrupt period during operation is within the range of 300±10ms. Therefore, in order to avoid clock delays, the calculated SN will still coincide with the interrupt period. SN and The difference between SD can also be greater than the periodic deviation o.
在一些实施例中,当中断周期N只有一个时,SN可以等于中断周期N的X倍与偏移值A的和,即SN=N×X+A。其中,偏移值A为整数,A代表了SN与中断周期N之间的偏差值,A既可以为正整数,也可以为负整数,X是特定倍数,为正整数。在一些实施例中,X和A可以被任意选取,在另一些实施例中,A可以被选取为奇数且为质数的值,从而降低与中断周期N重合的可能性。通过SN=N×X+A可以看出,SN不与中断周期N重合,相较于中断周期N偏差了A。需要说明的是,SN=N×X+A仅仅是根据中断周期N、特定倍数X以及偏移值A计算监听周期SN的一种具体的算法,还可以使用其他的算法计算得到监听周期SN,本申请对于计算出监听周期SN的算法不做限制。In some embodiments, when there is only one interruption period N, SN may be equal to the sum of X times the interruption period N and the offset value A, that is, SN=N×X+A. Wherein, the offset value A is an integer, A represents the deviation value between the SN and the interrupt period N, A can be a positive integer or a negative integer, X is a specific multiple, and is a positive integer. In some embodiments, X and A can be selected arbitrarily, and in other embodiments, A can be selected as an odd and prime value, so as to reduce the possibility of overlapping with the interrupt period N. It can be seen from SN=N×X+A that SN does not coincide with the interruption period N, and is deviated by A compared with the interruption period N. It should be noted that SN=N×X+A is only a specific algorithm for calculating the monitoring period SN according to the interruption period N, a specific multiple X and the offset value A, and other algorithms can be used to calculate the monitoring period SN, The present application does not limit the algorithm for calculating the listening period SN.
在另一些实施例中,可以通过调整X和A的取值,以使得SN满足处于[SD-L,SD+L]的范围内的条件,和/或,与SD之间的差值大于周期偏差o的条件。例如,图6为根据本申请实施例的第一设备计算监听周期SN的流程示意图。参阅图6,在步骤S5091中,第一设备任意选取X和A,其中,X为正整数,A为正数。在步骤S5092中,第一设备通过SN=N×X+A,计算出SN。在步骤S5093时,第一设备判断是否满足SN处于[SD-L,SD+L]的范围内、且SN与SD之间的差值大于周期偏差o,若不满足,重新返回至步骤S5091,即重新选取X和A,若满足,则执行步骤S5094,输出SN。In other embodiments, the values of X and A can be adjusted so that SN satisfies the condition of being in the range of [SD-L, SD+L], and/or, the difference with SD is greater than the period Conditions for deviation o. For example, FIG. 6 is a schematic flowchart of calculating the listening period SN by the first device according to an embodiment of the present application. Referring to FIG. 6, in step S5091, the first device randomly selects X and A, where X is a positive integer and A is a positive number. In step S5092, the first device calculates SN by SN=N×X+A. In step S5093, the first device judges whether the SN is within the range of [SD-L, SD+L] and the difference between SN and SD is greater than the period deviation o, if not, return to step S5091, That is, select X and A again, and if they are satisfied, execute step S5094 and output SN.
举例说明,当中断周期N为300ms,SD为500ms,周期偏差o为30ms,且L为100ms时,通过执行图6,最终当X取1,A取101时,通过SN=N×X+A,输出SN=401ms,401ms满足处于[400,600]的范围内,且SN与SD的差值大于30ms的条件。For example, when the interrupt period N is 300ms, SD is 500ms, period deviation o is 30ms, and L is 100ms, by executing Figure 6, when X is 1 and A is 101, SN=N×X+A , the output SN=401ms, 401ms satisfies the condition that it is in the range of [400, 600], and the difference between SN and SD is greater than 30ms.
在一些实施例中,当中断周期N有多个时,执行步骤S508的方式为:计算出多个中断周期N的公倍数Z,例如Z可以是最小公倍数;然后令SN等于Z的X倍与偏移值的和,即SN=Z×X+A。其中,偏移值A为整数,A代表了SN与中断周期N之间的偏差值,A既可以为正整数,也可以为负整数,X为正整数。Z为多个中断周期N的公倍数。例如,多个中断周期N分别为200ms和300ms,则Z可以为600ms。而X与A的取值方式可以与前述提及的当中断周期N只有一个时的取值方式相同,此处不再赘述。In some embodiments, when there are multiple interruption periods N, the way to execute step S508 is: calculate the common multiple Z of the plurality of interruption periods N, for example, Z can be the least common multiple; then make SN equal to X times Z and the partial The sum of shifted values, that is, SN=Z×X+A. Wherein, the offset value A is an integer, and A represents the deviation value between the SN and the interrupt period N, A can be a positive integer or a negative integer, and X is a positive integer. Z is a common multiple of multiple interrupt periods N. For example, if the multiple interruption periods N are 200ms and 300ms respectively, then Z may be 600ms. The values of X and A may be the same as those mentioned above when there is only one interrupt period N, and will not be repeated here.
在另一些实施例中,当中断周期N有多个时,执行步骤S508的方式还可以是,选取出多个中断周期N的最大值M,然后令SN等于M的X倍与偏移值的和,即SN=M×X+A。其中,偏移值A为整数,A代表了SN与中断周期N之间的偏差值,A既可以为正整数,也可以为负整数数,X表示特定倍数,为正整数。M为多个中断周期N的最大值。例如,多个中断周期N分别为200ms和300ms,则M为300ms。而X与A的取值方式可以与前述提及的当中断周期N只有一个时的取值方式相同,此处不再赘述。In some other embodiments, when there are multiple interrupt periods N, the way to execute step S508 can also be to select the maximum value M of the multiple interrupt periods N, and then make SN equal to X times M and the offset value And, that is, SN=M×X+A. Wherein, the offset value A is an integer, A represents the deviation value between SN and the interrupt period N, A can be either a positive integer or a negative integer, X represents a specific multiple, and is a positive integer. M is the maximum value of multiple interruption periods N. For example, if the multiple interruption periods N are 200ms and 300ms respectively, then M is 300ms. The values of X and A may be the same as those mentioned above when there is only one interrupt period N, and will not be repeated here.
同样的,在另一些实施例中,当中断周期N有多个时,也可以通过X和A的取值,以使得SN满足处于[SD-L,SD+L]的范围内的条件,和/或,与SD之间的差值大于周期偏差o的条件。具体的调整过程可参考图6示出的流程,只是计算SN的公式与图6中的 不同。Similarly, in other embodiments, when there are multiple interrupt periods N, the values of X and A may also be used so that SN satisfies the condition within the range of [SD-L, SD+L], and /or, the condition that the difference from SD is greater than the period deviation o. For the specific adjustment process, refer to the flow shown in Figure 6, but the formula for calculating SN is different from that in Figure 6.
由前述描述可知,步骤S509在计算SN的过程中,也可以不使用周期偏差参数o,因此,在步骤S502中的中断参数获取命令,也可以只用于获取中断参数N,相应的,步骤S504中则可以只判断是否成功获取到中断周期N,步骤S505中也可以只存储中断周期N。It can be seen from the foregoing description that the period deviation parameter o may not be used in the process of calculating the SN in step S509. Therefore, the interrupt parameter acquisition command in step S502 may only be used to acquire the interrupt parameter N. Correspondingly, step S504 In this case, it may only be judged whether the interruption period N is successfully obtained, or only the interruption period N may be stored in step S505.
S510、第一设备将SN的值设置为SD。S510. The first device sets the value of SN to SD.
由于第一设备没有成功获取到中断周期N,因此将第二设备的监听周期SN设置为第二设备的默认的监听周期SD。Since the first device fails to acquire the interruption period N, the monitoring period SN of the second device is set as the default monitoring period SD of the second device.
由前述内容可知,步骤S508至步骤S510其实是设置SN的过程。而设置SN的过程除了可以是在步骤S507之后触发,也可以是在步骤S506之后,即完成了中断周期N的设置之后再触发,设置SN的过程只需发生在进入监听模式之前即可。It can be seen from the foregoing content that step S508 to step S510 are actually a process of setting the SN. The process of setting the SN can be triggered after step S507, or after step S506, that is, after completing the setting of the interrupt period N. The process of setting the SN only needs to occur before entering the monitoring mode.
S511、第一设备向第二设备发送关于SN的信息。S511. The first device sends information about the SN to the second device.
在一些实施例中,关于SN的信息可以是进入监听模式的请求,其中进入监听模式的请求中携带有SN。In some embodiments, the information about the SN may be a request to enter the monitoring mode, wherein the request to enter the monitoring mode carries the SN.
第一设备设置完第二设备的监听周期SN之后,就把SN携带在进入监听模式的请求中,发送给第二设备,以使得第二设备能够进入监听模式,在监听模式下按照SN的周期运行。After the first device sets the monitoring period SN of the second device, it carries the SN in the request to enter the monitoring mode and sends it to the second device so that the second device can enter the monitoring mode. run.
S512、第二设备响应进入监听模式的请求,进入监听模式,按照SN的周期监听并回复第一设备发送的心跳包。S512. The second device responds to the request to enter the monitoring mode, enters the monitoring mode, monitors and replies the heartbeat packet sent by the first device according to the period of the SN.
第二设备响应进入监听模式的请求,从请求中可以获取到第一设备发送的SN,进而可确定自身在监听模式下的监听周期为SN,然后进入监听模式的运行状态。在监听模式下,第一设备按照SN的周期给第二设备发送至少一个心跳包,第二设备则按照SN的周期醒来,在t1时段监听心跳包,在监听到心跳包后,向第一设备发送心跳包响应,以通知第一设备自己还在线,相应地蓝牙连接依然有效。关于监听模式的描述,可参见前述图1c部分的介绍以及的相关技术可参见前述对蓝牙通信方案下的相关技术的简要介绍的相关部分,此处不再赘述。In response to the request to enter the monitoring mode, the second device can obtain the SN sent by the first device from the request, and then determine that the monitoring period of itself in the monitoring mode is SN, and then enter the operating state of the monitoring mode. In the monitoring mode, the first device sends at least one heartbeat packet to the second device according to the cycle of the SN, and the second device wakes up according to the cycle of the SN, listens to the heartbeat packet during the t1 period, and sends the heartbeat packet to the first device after listening to the heartbeat packet. The device sends a heartbeat packet response to notify the first device that it is still online, and accordingly the Bluetooth connection is still valid. For the description of the listening mode, please refer to the introduction of the aforementioned part of FIG. 1 c and for the related technologies, please refer to the relevant parts of the aforementioned brief introduction to the related technologies under the Bluetooth communication scheme, and will not be repeated here.
当第二设备所使用的SN是第一设备通过步骤S509所设置得到的时候,第二设备的监听周期不会与自身的中断周期重合,不会出现中断任务和心跳包回复任务重合的情况。举例说明,图7为根据本申请实施例的手环20在中断周期和监听周期下的场景示意图,如图7所示,使用图6示出的流程计算出SN=401ms,中断周期N=300ms,偏移值A=101ms,以其中一个中断周期N与一个SN周期为例,可以看出,中断周期N与SN补充和,偏差了101ms,而在中断周期N来临时,手环20只执行中断任务,而在监听周期SN来临时,它只需执行心跳包回复任务,即在t1时段监听并回复心跳包。When the SN used by the second device is obtained by the first device through step S509, the monitoring period of the second device will not coincide with its own interruption period, and the interruption task and the heartbeat packet reply task will not overlap. For example, Fig. 7 is a schematic diagram of the scene of the wristband 20 under the interruption period and the monitoring period according to the embodiment of the present application. As shown in Fig. 7, SN = 401ms and the interruption period N = 300ms are calculated using the flow shown in Fig. 6 , the offset value A=101ms, taking one of the interruption period N and one SN period as an example, it can be seen that the supplementary sum of the interruption period N and SN deviates by 101ms, and when the interruption period N comes, the wristband 20 only executes Interrupt task, and when the monitoring period SN comes, it only needs to execute the heartbeat packet reply task, that is, monitor and reply the heartbeat packet during the t1 period.
本申请实施例中,在第一设备能够通过步骤S503能够获取到第二设备的中断周期的情况下,第一设备所设置的SN不会与第二设备的中断周期重合,因此第二设备按照SN的周期进行监听时,不会因执行中断任务而无法回复心跳包,进而不会因无法回复心跳包而产生断连。In this embodiment of the application, when the first device can obtain the interrupt period of the second device through step S503, the SN set by the first device will not coincide with the interrupt period of the second device, so the second device follows When the SN monitors periodically, it will not be unable to reply to the heartbeat packet due to the execution of the interrupt task, and will not be disconnected due to the inability to reply to the heartbeat packet.
S513、第一设备在监听模式下记录断连次数。S513. The first device records the disconnection times in the monitoring mode.
断连次数指的是第一设备和第二设备之间的蓝牙通信的断连次数,为了描述简洁,本申请中将断连次数以DN表示。第一设备在通过前述方式完成对SN的设置之后,可以验 证第二设备按照SN周期进行监听后,还有没有频繁断连现象发生。因此,第一设备在进入监听模式的请求之后,在监听模式下从0开始记录断连次数DN。监听模式下的断连是由于第二设备未回复心跳包导致的。The number of disconnections refers to the number of disconnections of the Bluetooth communication between the first device and the second device. For the sake of brevity, the number of disconnections is represented by DN in this application. After the first device finishes setting the SN in the aforementioned manner, it can verify whether the second device is frequently disconnected after monitoring according to the SN cycle. Therefore, after the request to enter the listening mode, the first device records the disconnection times DN from 0 in the listening mode. The disconnection in listening mode is caused by the second device not replying the heartbeat packet.
在一些实施例中,步骤S513的执行方式为:判断监听模式下是否发生断连,如果发生断连则令DN加1。In some embodiments, step S513 is executed in the following manner: judging whether disconnection occurs in the listening mode, and if disconnection occurs, increment DN by 1.
需要说明的是,步骤S513是在实时重复执行的步骤,即在监听模式下一直在执行步骤S513。It should be noted that step S513 is a step that is repeatedly executed in real time, that is, step S513 is always executed in the monitoring mode.
S514、第一设备判断监听模式下断连次数DN是否大于或等于断连阈值。S514. The first device judges whether the disconnection count DN in the monitoring mode is greater than or equal to a disconnection threshold.
其中,断连阈值可任意设定,示例性的断连阈值可根据经验设置为3。当DN大于或等于断连阈值时,说明第一设备和第二设备之间频繁断连。在监听模式下发生断连的主要原因是第二设备长时间不回复心跳包。具体的,在一些实施例中,执行步骤S501之后,第一设备可以向第二设备发送链接超时监控时间,当第二设备超过链接超时监控时间的时长都没有给第一设备回复心跳包,第一设备可以认为第二设备不在线,从而主动断开蓝牙连接。Wherein, the disconnection threshold can be set arbitrarily, and an exemplary disconnection threshold can be set to 3 according to experience. When the DN is greater than or equal to the disconnection threshold, it indicates frequent disconnection between the first device and the second device. The main reason for the disconnection in the listening mode is that the second device does not reply the heartbeat packet for a long time. Specifically, in some embodiments, after step S501 is executed, the first device may send a link timeout monitoring time to the second device, and when the second device does not reply a heartbeat packet to the first device for a period exceeding the link timeout monitoring time, the second A device may consider that the second device is not online, so as to actively disconnect the Bluetooth connection.
本申请实施例中,通过前述步骤S509的设置方式下已经避开了中断周期,减小了第二设备不回复心跳包现象出现的概率。在该情况下,还出现频繁断连的原因,可能是监听模式下的监听时长过短导致的。在监听时长过短的情况下,第二设备可能会监听不到心跳包,进而不能够回复心跳包。在一些实施例中,第二设备当前的监听模式下的监听时长可以是在第一设备执行步骤S511时,通过携带在进入监听模式的请求中,而被发送给第二设备的。因此,当DN大于或等于断连阈值时,可以执行步骤S515来对第二设备的监听模式下的监听时长进行调整。而如果DN小于断连阈值,则说明当前还没有发生频繁断连的现象,只需继续返回执行步骤S513。In the embodiment of the present application, the interruption period has been avoided through the setting method of step S509, which reduces the probability that the second device does not reply the heartbeat packet. In this case, the reason for frequent disconnection may be that the listening time in listening mode is too short. When the monitoring time is too short, the second device may not be able to monitor the heartbeat packet, and thus cannot reply the heartbeat packet. In some embodiments, the listening duration of the second device's current listening mode may be sent to the second device by being included in the request for entering the listening mode when the first device executes step S511. Therefore, when the DN is greater than or equal to the disconnection threshold, step S515 may be executed to adjust the listening duration of the second device in the listening mode. And if the DN is smaller than the disconnection threshold, it means that there is no frequent disconnection at present, and it only needs to continue to return to step S513.
其中,链接超时监控时间和监听模式下的监听时长的相关技术可参见前述对蓝牙通信方案下的相关技术的简要介绍的相关部分,此处不再赘述。Wherein, for the related technologies of the link timeout monitoring time and the monitoring duration in the monitoring mode, please refer to the relevant part of the brief introduction of the related technologies under the bluetooth communication solution, and will not be repeated here.
需要说明的是,步骤S514是在持续执行的,直到步骤S514判断出DN大于或等于断连阈值之后,再结束步骤S514的执行,进入到S515中。It should be noted that step S514 is continuously executed until it is determined in step S514 that the DN is greater than or equal to the disconnection threshold, and then the execution of step S514 is ended and the process enters into S515.
S515、第一设备将监听时长的值翻倍,得到更新后的监听时长。S515. The first device doubles the value of the listening duration to obtain an updated listening duration.
即第一设备将原本的监听时长的值增加了原本的一倍,得到更新后的监听时长。更新后的监听时长比原本的监听时长更大。例如原本的监听时长值为5ms,更新后的监听时长为10ms。That is, the first device doubles the original listening duration to obtain an updated listening duration. The updated listen duration is longer than the original listen duration. For example, the original listening duration is 5ms, and the updated listening duration is 10ms.
在另一些实施例中,第一设备也可以采用其他的方式提高监听时长的值。例如步骤S515也可以是将监听时长的值增加预设值。例如可以将预设值设置为3ms,原本的监听时长为5ms,增加预设值后变为了3ms。In some other embodiments, the first device may also use other methods to increase the value of the listening duration. For example, step S515 may also be to increase the value of the listening duration by a preset value. For example, the preset value can be set to 3ms, the original monitoring time is 5ms, and after increasing the preset value, it becomes 3ms.
因此,步骤S515的目的实际上是提高监听时长的值。具体提高监听时长的值的规则和方式,本申请实施例可不做限制。Therefore, the purpose of step S515 is actually to increase the value of the listening duration. The specific rules and methods for increasing the value of the listening duration may not be limited in this embodiment of the present application.
在另一些实施例中,还可以在执行步骤S515之后,将DN清零,重新返回至步骤S514中,若再次判断出DN大于或等于断连阈值,则再次执行步骤S515,即再次增大监听时长。In some other embodiments, after step S515 is executed, the DN can be cleared, and then return to step S514. If it is judged again that the DN is greater than or equal to the disconnection threshold, step S515 is executed again, that is, the monitoring value is increased again. duration.
在一些实施例中,为了保障第二设备能够低功耗运行,可以限制监听时长的值不大于监听时长阈值。例如,当步骤S515翻倍后的值大于监听时长阈值的话,可以将监听时长设 定为监听时长阈值。其中监听时长阈值可以根据SN的值设置,例如可以是SN的一半。In some embodiments, in order to ensure that the second device can operate with low power consumption, the listening duration may be limited to a value not greater than a listening duration threshold. For example, when the doubled value in step S515 is greater than the listening duration threshold, the listening duration can be set as the listening duration threshold. The listening duration threshold can be set according to the value of the SN, for example, it can be half of the SN.
S516、第一设备将更新后的监听时长发送给第二设备。S516. The first device sends the updated listening duration to the second device.
在一些实施例中,第一设备执行步骤S516的方式为,重新发送进入监听模式的请求给第二设备,请求中携带更新后的监听时长和SN。第二设备接收到更新后的监听时长之后,使用更新后的监听时长执行监听操作。即每一个监听周期来临时,监听的时间长度为更新后的监听时长。由于更新后的监听时长更大,需要进行监听的时间长度更大了,因此第二设备能够监听到心跳包的概率就更大了,发生断连的可能性会有所降低。In some embodiments, the first device performs step S516 by resending a request to enter the listening mode to the second device, and the request carries the updated listening duration and SN. After receiving the updated monitoring duration, the second device uses the updated monitoring duration to perform a monitoring operation. That is, when each monitoring cycle comes, the length of the monitoring time is the updated monitoring time length. Since the updated monitoring time is longer, the time required for monitoring is longer, so the probability that the second device can monitor the heartbeat packet is greater, and the possibility of disconnection will be reduced.
在另一些实施例中,执行步骤S516之后,第一设备还可以判断是否发生断连,若还是发生断连,则重新返回到步骤S515中,重新调整监听时长,直至不再发生断连为止。In some other embodiments, after step S516 is executed, the first device may also determine whether disconnection occurs, and if disconnection still occurs, return to step S515 to readjust the monitoring duration until no disconnection occurs.
S517、第一设备在退出监听模式之后,将DN清零。S517. After exiting the monitoring mode, the first device clears the DN to zero.
其中,步骤S517的退出监听模式,指的是正常结束监听模式,如果是因为断连等异常导致的退出监听模式,则不将DN清零,而是继续将DN加1。Wherein, the exit of the monitoring mode in step S517 refers to the normal termination of the monitoring mode. If the exit of the monitoring mode is caused by an abnormality such as a disconnection, the DN will not be cleared to zero, but the DN will continue to be increased by 1.
第一设备在正常结束监听模式之后,将DN清零,等到下一次再进入监听模式的时候,再重新记录DN。在一些实施例中,第一设备退出监听模式的方式为:第一设备向第二设备发送退出监听模式的请求,第二设备响应退出监听模式的请求,退出监听模式,不再按照监听周期进行监听。第一设备则在发送退出监听模式的请求之后,将DN清零。After the first device ends the monitoring mode normally, it clears the DN, and waits until it enters the monitoring mode next time, and then records the DN again. In some embodiments, the way for the first device to exit the listening mode is: the first device sends a request for exiting the listening mode to the second device, and the second device responds to the request for exiting the listening mode, exits the listening mode, and no longer follows the monitoring cycle. monitor. The first device clears the DN to zero after sending the request to exit the listening mode.
在另一些实施例中,也可以不执行步骤S513至步骤S517,即不对监听时长做调整。In some other embodiments, steps S513 to S517 may not be performed, that is, the listening duration is not adjusted.
由前述对图5的描述可知,步骤S502至步骤S506的目的是使得第一设备获取第二设备的中断周期,而具体获取第二设备的中断周期的实现方式以及过程,本申请实施例不做限制。It can be seen from the foregoing description of FIG. 5 that the purpose of steps S502 to S506 is to enable the first device to obtain the interrupt period of the second device, and the implementation method and process of obtaining the interrupt period of the second device are not discussed in this embodiment of the present application. limit.
步骤S508至步骤S510用于判断是否将SN的值设置为默认的监听周期SD。在图5中,成功获取到中断周期N,则不将SN设置为SD,而是使用中断周期N来计算SN,以使得SN不与N重合;而在没有成功获取到N时,才将SN的值设置为SD。在另一些实施例中,还可以使用其他的条件用于判断是否需要将SN的值设置为SD,本申请实施例对此不作限制。Steps S508 to S510 are used to determine whether to set the value of SN as the default monitoring period SD. In Figure 5, if the interrupt cycle N is successfully obtained, SN is not set to SD, but the interrupt cycle N is used to calculate SN, so that SN does not overlap with N; and when N is not successfully obtained, SN The value of is set to SD. In other embodiments, other conditions may also be used to determine whether the value of SN needs to be set to SD, which is not limited in this embodiment of the present application.
在步骤S509中,在计算SN的过程中,也可以不使用周期偏差参数o,因此,在步骤S502中的中断参数获取命令,也可以只用于获取中断参数N。相应的,在步骤S504中可以只判断是否成功获取到中断周期N,在步骤S505中也可以只存储中断周期N。In step S509, the period deviation parameter o may not be used in the process of calculating SN, therefore, the interrupt parameter acquisition command in step S502 may also be used only to acquire the interrupt parameter N. Correspondingly, in step S504, it may only be judged whether the interruption period N is successfully obtained, and in step S505, only the interruption period N may be stored.
步骤S513至S517的目的是在DN大于或等于断连阈值时,增大监听时长。步骤S515仅为增大监听时长的值的一种方式,本申请对于增大监听时长的值的方式不做限制。The purpose of steps S513 to S517 is to increase the listening duration when the DN is greater than or equal to the disconnection threshold. Step S515 is only one way of increasing the value of the listening duration, and the present application does not limit the way of increasing the value of the listening duration.
在一些实施例中,图5中第一设备需执行的步骤可以通过第一设备中的蓝牙协议栈执行,而图2示出的无线通信模块260可作为硬件支持,第二设备执行的步骤则可以通过第二设备中的蓝牙协议栈执行,而图2示出的蓝牙通信模块203A可作为硬件支持。其中,蓝牙协议栈的相关描述可参考图4的相关部分,此处不再赘述。In some embodiments, the steps to be performed by the first device in FIG. 5 can be performed by the Bluetooth protocol stack in the first device, and the wireless communication module 260 shown in FIG. 2 can be used as hardware support, and the steps performed by the second device can be It can be executed through the Bluetooth protocol stack in the second device, and the Bluetooth communication module 203A shown in FIG. 2 can be used as hardware support. Wherein, for the related description of the Bluetooth protocol stack, reference may be made to relevant parts in FIG. 4 , which will not be repeated here.
还需要说明的是,本申请实施例中,针对不同的第二设备,第一设备下发的监听周期、链接超时监控时间、监听时长的默认值可以适应性的不同。It should also be noted that, in the embodiment of the present application, for different second devices, default values of the monitoring period, link timeout monitoring time, and monitoring duration issued by the first device may be adaptively different.
本申请实施例中,在第一设备能够通过步骤S503能够获取到第二设备的中断周期的情况下,第一设备所设置的SN不会与第二设备的中断周期N重合,因此第二设备按照SN 的周期进行监听时,不会因执行中断任务而无法回复心跳包,进而不会因无法回复心跳包而产生断连。In this embodiment of the application, when the first device can obtain the interrupt period of the second device through step S503, the SN set by the first device will not coincide with the interrupt period N of the second device, so the second device When monitoring according to the cycle of the SN, it will not be unable to reply the heartbeat packet due to the execution of the interrupt task, and will not be disconnected due to the inability to reply the heartbeat packet.
实施例二Embodiment two
图8为根据本申请实施例的用于配置监听周期的方法的又一流程示意图。参阅图8,基于前述所提及的第一设备和第二设备,本申请实施例针对第一设备和第二设备为不同厂家的电子设备,第一设备和第二设备之间无法通过私有命令交互的场景,提出了另一种用于配置监听周期的方法,由第一设备和第二设备相互配合执行。具体包括以下步骤:Fig. 8 is another schematic flowchart of a method for configuring a monitoring period according to an embodiment of the present application. Referring to Figure 8, based on the first device and the second device mentioned above, the embodiment of the present application aims at the first device and the second device being electronic devices of different manufacturers, and the private command cannot be passed between the first device and the second device. In an interaction scenario, another method for configuring a monitoring period is proposed, which is executed by the cooperation of the first device and the second device. Specifically include the following steps:
S801、第一设备与第二设备之间建立蓝牙连接。S801. Establish a Bluetooth connection between the first device and the second device.
其中步骤S801的执行原理和过程可参考步骤S501,此处不再赘述。For the execution principle and process of step S801, reference may be made to step S501, which will not be repeated here.
S802、第一设备确定出与第二设备之间无数据交互,向第二设备发送进入监听模式的请求,其中进入监听模式的请求中携带的监听周期SN的值为默认的监听周期SD。S802. The first device determines that there is no data interaction with the second device, and sends a request to enter the monitoring mode to the second device, wherein the value of the monitoring period SN carried in the request to enter the monitoring mode is a default monitoring period SD.
其中,步骤S802中确定出与第二设备之间无数据交互的执行过程和原理可参考步骤S507,此处不再赘述。而发送进入监听模式的请求的过程可参考步骤S511。但步骤S802与步骤S511不同的是,第一设备首次请求进入监听模式时,使用的SN的值是默认的值SD。For the execution process and principle of determining no data interaction with the second device in step S802, reference may be made to step S507, which will not be repeated here. For the process of sending a request to enter the listening mode, reference may be made to step S511. However, step S802 is different from step S511 in that when the first device requests to enter the monitoring mode for the first time, the value of SN used is the default value SD.
S803、第二设备响应进入监听模式的请求,进入监听模式,按照SN的周期监听并回复第一设备发送的心跳包。S803. The second device responds to the request to enter the monitoring mode, enters the monitoring mode, monitors and replies the heartbeat packet sent by the first device according to the period of the SN.
步骤S803的执行过程和原理可参考步骤S512,主要区别点在于步骤S512中使用的SN可能是通过步骤S509的方式设置得到的,而步骤S803中的SN是默认值SD。For the execution process and principle of step S803, please refer to step S512. The main difference is that the SN used in step S512 may be obtained by setting in step S509, while the SN in step S803 is the default value SD.
S804、第一设备在监听模式下记录断连次数DN。S804. The first device records the disconnection times DN in the monitoring mode.
其中,步骤S804的执行过程和原理可参考步骤S513,此处不再赘述。Wherein, for the execution process and principle of step S804, reference may be made to step S513, which will not be repeated here.
S805、第一设备判断DN是否大于或等于断连阈值。S805. The first device determines whether the DN is greater than or equal to the disconnection threshold.
其中,断连阈值可任意设定,例如可根据经验设置为3。当DN大于或等于断连阈值时,就说明第一设备和第二设备之间频繁断连。在监听模式下发生断连的主要原因是第二设备长时间不回复心跳包。而由于在前述步骤S803中,第二设备使用的SN是一个默认值SD,因此可以分析出出现频繁断连现象的原因,可能是因为当前的SN为默认值SD时,SN会与第二设备的中断周期重合,因此可以重新设置一下SN,即执行步骤S806。Wherein, the disconnection threshold can be set arbitrarily, for example, it can be set to 3 according to experience. When the DN is greater than or equal to the disconnection threshold, it indicates frequent disconnection between the first device and the second device. The main reason for the disconnection in the listening mode is that the second device does not reply the heartbeat packet for a long time. And because in the aforementioned step S803, the SN used by the second device is a default value SD, the reason for the frequent disconnection phenomenon can be analyzed, which may be because when the current SN is the default value SD, the SN will be connected to the second device The interruption period of the two overlaps, so the SN can be reset, that is, step S806 is executed.
而当DN小于断连阈值时,则说明当前还没有出现频繁断连的现象,SN不需要重新设置,第二设备继续按照SN为默认值SD的周期,进行监听。When the DN is less than the disconnection threshold, it means that there is no frequent disconnection at present, the SN does not need to be reset, and the second device continues to monitor according to the cycle in which the SN is the default value SD.
需要说明的是,步骤S805是在持续执行的,直到步骤S805判断出DN大于或等于断连阈值之后,再结束步骤S805的执行,进入到S806中。It should be noted that step S805 is continuously executed until it is determined in step S805 that the DN is greater than or equal to the disconnection threshold, and then the execution of step S805 is ended and the process enters into S806.
S806、第一设备将SN与偏移值A的和,作为更新后的SN。S806. The first device uses the sum of the SN and the offset value A as the updated SN.
即第一设备重新设置SN,重新设置后的SN(即更新后的SN)是原本的SN(即SD)的值加上偏移值A的和。其中,偏移值A可以根据个人经验设置(例如可以选择奇数且为质数的值作为偏移值A),也可以是根据通常经验下第二设备的周期偏差(即时钟偏差)、中断周期等因素,来设定A。设定A的方式有很多,本申请实施例对此不作限制。That is, the first device resets the SN, and the reset SN (that is, the updated SN) is the sum of the value of the original SN (that is, the SD) plus the offset value A. Wherein, the offset value A can be set according to personal experience (for example, an odd number and a prime number can be selected as the offset value A), or it can be based on the cycle deviation (that is, the clock deviation) and the interruption period of the second device based on common experience. factor, to set A. There are many ways to set A, which is not limited in this embodiment of the present application.
S807、第一设备发送更新后的SN至第二设备。S807. The first device sends the updated SN to the second device.
在一些实施例中,第一设备执行步骤S807的方式为,发送进入监听模式的请求给第二设备,请求中携带更新后的SN。In some embodiments, the first device performs step S807 by sending a request to enter the monitoring mode to the second device, and the request carries the updated SN.
S808、第二设备按照更新后的SN的周期监听并回复第一设备的心跳包。S808. The second device monitors and responds to the heartbeat packet of the first device according to the period of the updated SN.
第二设备在监听模式下,按照更新后的SN的周期监听心跳包,并在监听到心跳包之后回复第一设备的心跳包。In the monitoring mode, the second device monitors the heartbeat packet according to the period of the updated SN, and returns the heartbeat packet of the first device after monitoring the heartbeat packet.
由于更新后的SN其实是SD与偏移值A的和,原本的SN可能是因为与中断周期重合,导致第二设备的中断任务和回复心跳包的任务冲突了,优先执行了中断任务,没有回复心跳包,进而产生断连。而更新后的SN在原来的SN的基础上偏移了A,因此不会与中断周期重合,进而不会因心跳包回复任务与中断任务冲突而导致断连。Since the updated SN is actually the sum of the SD and the offset value A, the original SN may be due to coincidence with the interrupt cycle, resulting in a conflict between the interrupt task of the second device and the task of replying the heartbeat packet, and the interrupt task is executed first. Reply the heartbeat packet, resulting in a disconnection. The updated SN is offset by A on the basis of the original SN, so it will not coincide with the interrupt cycle, and will not cause disconnection due to the conflict between the heartbeat packet reply task and the interrupt task.
S809、第一设备判断是否发生断连。S809. The first device determines whether a disconnection occurs.
第一设备在执行完步骤S807之后,可以判断是否还是产生了断连。如果在SN已经更新的情况下,依然发生了断连,则说明可能是因为监听模式下的监听时长监听时长过短造成的。其中,第二设备当前的监听时长可以是携带在步骤S803中的进入监听模式的请求中的。即第一设备在执行步骤S803时,还将监听时长也携带在请求中发送给了第二设备。在监听时长过短的情况下,可能会没有监听到心跳包就进入了休眠,因此没有回复心跳包。因此,当步骤S809判断出发生断连时,就执行步骤S810,以增大监听时长的值。After step S807 is executed, the first device may determine whether a disconnection still occurs. If the disconnection still occurs even though the SN has been updated, it may be because the listening time in the listening mode is too short. Wherein, the current listening duration of the second device may be carried in the request for entering the listening mode in step S803. That is, when the first device executes step S803, it also includes the listening duration in the request and sends it to the second device. When the monitoring time is too short, it may go to sleep without listening to the heartbeat packet, so there is no reply to the heartbeat packet. Therefore, when it is determined in step S809 that a disconnection occurs, step S810 is executed to increase the value of the listening duration.
在另一些实施例中,当步骤S809判断出仍然发生断连后,还可以通过返回步骤S806,即再次更新调整SN的方式,以达到不再发生断连的目的。In some other embodiments, when it is determined in step S809 that the disconnection still occurs, it is also possible to return to step S806, that is, to update and adjust the SN mode again, so as to achieve the purpose of no further disconnection.
如果判断出没有发生断连,则说明当前使用更新后的SN不再出现频繁断连的现象,不需要执行任何操作。If it is judged that disconnection does not occur, it means that the current updated SN no longer suffers from frequent disconnection, and no operation is required.
需要说明是,步骤S809是持续执行的,在判断出没有发生断连之后,仍然需要继续执行步骤S809,直到判断出发生了断连,或者退出监听模式为止,才结束执行步骤S809。It should be noted that step S809 is continuously executed. After it is judged that there is no disconnection, step S809 still needs to be executed until it is judged that disconnection occurs, or the monitoring mode is exited, and the execution of step S809 is not completed.
S810、第一设备将监听时长的值翻倍,得到更新后的监听时长。S810. The first device doubles the value of the listening duration to obtain an updated listening duration.
其中,步骤S810的执行过程和原理可参考步骤S515,此处不再赘述。For the execution process and principle of step S810, reference may be made to step S515, which will not be repeated here.
S811、第一设备将更新后的监听时长发送给第二设备。S811. The first device sends the updated listening duration to the second device.
其中,步骤S811的执行过程和原理可参考步骤S516,此处不再赘述。Wherein, for the execution process and principle of step S811, reference may be made to step S516, which will not be repeated here.
S812、第一设备退出监听模式之后,将DN清零。S812. After the first device exits the monitoring mode, it clears the DN to zero.
其中,步骤S812的执行过程和原理可参考步骤S517,此处不再赘述。Wherein, for the execution process and principle of step S812, reference may be made to step S517, which will not be repeated here.
在一些实施例中,也可以不执行步骤S809至步骤S811,即不对监听时长的值进行更新调整。In some embodiments, steps S809 to S811 may not be performed, that is, the value of the listening duration is not updated and adjusted.
在一些实施例中,图8中第一设备需执行的步骤可以通过第一设备中的蓝牙协议栈执行,而图2示出的无线通信模块260可作为硬件支持。第二设备执行的步骤则可以通过第二设备中的蓝牙协议栈执行,而图2示出的蓝牙通信模块203A可作为硬件支持。其中,蓝牙协议栈的相关描述可参考图4的相关部分,此处不再赘述。In some embodiments, the steps to be performed by the first device in FIG. 8 can be performed by the Bluetooth protocol stack in the first device, and the wireless communication module 260 shown in FIG. 2 can be used as hardware support. The steps executed by the second device can be executed by the Bluetooth protocol stack in the second device, and the Bluetooth communication module 203A shown in FIG. 2 can be used as hardware support. Wherein, for the related description of the Bluetooth protocol stack, reference may be made to relevant parts in FIG. 4 , which will not be repeated here.
还需要说明的是,本申请实施例中,针对不同的第二设备,第一设备下发的监听周期、链接超时监控时间、监听时长的默认值可以适应性的不同。It should also be noted that, in the embodiment of the present application, for different second devices, default values of the monitoring period, link timeout monitoring time, and monitoring duration issued by the first device may be adaptively different.
本申请实施例中,当DN大于或等于断连阈值时,认为第二设备的中断周期与当前的SN重合,因此第一设备将当前的SN与偏移值A的和,作为更新后的SN。然后将更新后的SN发送给了第二设备,让第二设备在监听模式下以更新后的SN的周期进行监听。由于更新后的SN相较于原本的SN偏移了偏移值A,降低了与中断周期重合的可能,进而第二 设备不会因中断任务与心跳包回复任务冲突,而出现不回复心跳包的情况,减少了频繁断连现象的发生。In the embodiment of this application, when the DN is greater than or equal to the disconnection threshold, it is considered that the interruption period of the second device coincides with the current SN, so the first device uses the sum of the current SN and the offset value A as the updated SN . Then, the updated SN is sent to the second device, so that the second device monitors at the period of the updated SN in the monitoring mode. Since the updated SN is offset by the offset value A compared with the original SN, the possibility of coincidence with the interrupt cycle is reduced, and the second device will not respond to the heartbeat packet due to the conflict between the interrupt task and the heartbeat packet reply task. In this case, the occurrence of frequent disconnection is reduced.
基于前述图5和图8示出的用于配置监听周期的方法可知,本申请实施例中所提及的第一设备中的监听周期SN均指的是第一设备中存储的用于第二设备的监听周期。而步骤S502至步骤S508中,使用默认的监听周期SD的条件为未成功获取到中断周期,而步骤S802至S805中,使用默认的监听周期SD的条件为监听模式下的第一设备与第二设备之间的蓝牙通信的断连次数小于断连阈值。因此步骤S502至S508、以及步骤S802至S805,都是第一设备用于判断是否满足使用默认的监听周期SD的条件的具体实施方式,且当异地设备判断出不满足使用默认的监听周期的条件时,就说明使用默认的监听周期具有与第二设备的中断周期重合的可能性。Based on the methods for configuring the listening period shown in Figure 5 and Figure 8 above, it can be known that the listening period SN in the first device mentioned in the embodiment of this application refers to the information stored in the first device for the second The monitoring period of the device. In steps S502 to S508, the condition for using the default monitoring period SD is that the interrupt period has not been successfully obtained, and in steps S802 to S805, the condition for using the default monitoring period SD is that the first device and the second device in the monitoring mode The disconnection times of the Bluetooth communication between devices is less than the disconnection threshold. Therefore, steps S502 to S508 and steps S802 to S805 are specific implementation methods for the first device to determine whether the condition for using the default monitoring period SD is satisfied, and when the remote device determines that the condition for using the default monitoring period is not met , it means that the default monitoring period may coincide with the interruption period of the second device.
当判断出不满足使用默认的监听周期SD的条件时,在图5中,通过步骤S509的方式重新计算了监听周期SN,该计算出的监听周期SN是根据中断周期计算得到的,为非默认的监听周期,该非默认的监听周期不与中断周期重合,因此能够促使第二设备按照非默认的监听周期监听时可正常回复心跳包。而在图8中,当判断出不满足使用默认的监听周期SD的条件时,说明第二设备使用默认的监听周期SD时会出现无法正常回复心跳包的问题,因默认的监听周期SD可能与中断周期重合,因此通过步骤S806重新计算了监听周期SN,该计算出的监听周期SN是根据默认的监听周期以及偏移值A计算得到的,为非默认的监听周期,非默认的监听周期不与中断周期重合,也能够促使第二设备按照非默认的监听周期监听时可正常回复心跳包。因此,步骤S806和步骤S509都是在判断出不满足使用默认的监听周期的条件时,则将第二设备的监听周期确定为非默认的监听周期的一种实施方式。其中,非默认的监听周期指的是需要计算处理而得到的监听周期,而不是直接默认使用的监听周期。When it is judged that the condition of using the default monitoring period SD is not satisfied, in FIG. 5, the monitoring period SN is recalculated by means of step S509, and the calculated monitoring period SN is calculated according to the interruption period, which is non-default The non-default monitoring period does not coincide with the interrupt period, so it can prompt the second device to normally reply the heartbeat packet when monitoring according to the non-default monitoring period. In Figure 8, when it is judged that the conditions for using the default monitoring period SD are not met, it means that the second device cannot normally reply to the heartbeat packet when using the default monitoring period SD, because the default monitoring period SD may be different from the The interruption period coincides, so the monitoring period SN is recalculated through step S806. The calculated monitoring period SN is calculated according to the default monitoring period and the offset value A, and is a non-default monitoring period. The non-default monitoring period does not Coincident with the interruption period, it can also prompt the second device to normally reply the heartbeat packet when monitoring according to the non-default monitoring period. Therefore, both step S806 and step S509 are an implementation manner of determining the monitoring period of the second device as a non-default monitoring period when it is determined that the condition for using the default monitoring period is not met. Wherein, the non-default monitoring period refers to a monitoring period that needs to be calculated and processed, rather than a monitoring period that is directly used by default.
因此,图5和图8示出的用于配置监听周期的方法,均通过在判断出不满足使用默认的监听周期的条件,则将第二设备的监听周期确定为非默认的监听周期,而非默认的监听周期是用于第二设备在监听模式下监听第一设备发送的心跳包的、并且与第二设备的中断周期不重合的监听周期,因此向第二设备发送关于非默认的监听周期的信息,可以使得第二设备按照非默认的监听周期进行监听,不会再受中断任务冲突影响,可正常回复心跳包,进而不再产生断连。Therefore, the methods for configuring the monitoring period shown in FIG. 5 and FIG. 8 all determine that the monitoring period of the second device is a non-default monitoring period after judging that the condition for using the default monitoring period is not met, and The non-default monitoring period is a monitoring period for the second device to monitor the heartbeat packet sent by the first device in the monitoring mode and does not coincide with the interruption period of the second device, so the non-default monitoring period is sent to the second device The information of the period can make the second device monitor according to the non-default monitoring period, and will not be affected by the conflict of the interrupt task, and can reply the heartbeat packet normally, so that no disconnection will occur.
在另一些实施例中,也可以是不执行判断是否满足使用默认的监听周期的条件的步骤,而直接将第一设备中存储的用于第二设备的监听周期设置为非默认的监听周期。示例性的,判断是否满足使用默认的监听周期的条件的步骤可以由第一设备之外的其他设备执行。In some other embodiments, the step of judging whether the condition of using the default monitoring period is satisfied may be performed, and the monitoring period stored in the first device for the second device is directly set as a non-default monitoring period. Exemplarily, the step of judging whether the condition of using a default listening period is satisfied may be performed by other devices than the first device.
本实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中包括指令,当上述指令在电子设备上运行时,使得该电子设备执行图5中第一设备的相关方法步骤、图5中的第二设备的相关方法步骤、图8中第二设备的相关方法步骤、或者图8中第二设备的相关方法步骤,以实现上述实施例中的方法。This embodiment also provides a computer-readable storage medium, the computer-readable storage medium includes instructions, and when the above-mentioned instructions are run on the electronic device, the electronic device is made to execute the relevant method steps of the first device in FIG. 5 , The related method steps of the second device in FIG. 5 , the related method steps of the second device in FIG. 8 , or the related method steps of the second device in FIG. 8 , so as to implement the methods in the foregoing embodiments.
本实施例还提供了一种包含指令的计算机程序产品,当该计算机程序产品在电子设备上运行时,使得该电子设备执行图5中第一设备的相关方法步骤、图5中的第二设备的相关方法步骤、图8中第二设备的相关方法步骤、或者图8中第二设备的相关方法步骤,以 实现上述实施例中的方法。This embodiment also provides a computer program product containing instructions. When the computer program product is run on the electronic device, the electronic device is made to execute the relevant method steps of the first device in FIG. 5 and the second device in FIG. 5 , the related method steps of the second device in FIG. 8 , or the related method steps of the second device in FIG. 8 , so as to implement the methods in the foregoing embodiments.
本实施例还提供了一种控制设备,所述控制设备包括处理器和存储器,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,当所述处理器执行所述计算机指令时,所述控制设备执行图5中第一设备的相关方法步骤、图5中的第二设备的相关方法步骤、图8中第二设备的相关方法步骤、或者图8中第二设备的相关方法步骤,以实现上述实施例中的方法。该控制设备可以是一个集成电路IC,也可以是一个片上系统SOC。其中集成电路可以是通用集成电路,也可以是一个现场可编程门阵列FPGA,也可以是一个专用集成电路ASIC。This embodiment also provides a control device, the control device includes a processor and a memory, the memory is used to store computer program codes, the computer program codes include computer instructions, when the processor executes the computer instructions , the control device executes the related method steps of the first device in FIG. 5, the related method steps of the second device in FIG. 5, the related method steps of the second device in FIG. 8, or the related method steps of the second device in FIG. Method steps to implement the methods in the above embodiments. The control device can be an integrated circuit IC, or a system-on-chip SOC. The integrated circuit can be a general integrated circuit, a field programmable gate array FPGA, or an application specific integrated circuit ASIC.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated according to needs It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working process of the above-described system, device, and unit, reference may be made to the corresponding process in the foregoing method embodiments, and details are not repeated here.
在本实施例所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this embodiment, it should be understood that the disclosed system, device and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本实施例各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of this embodiment may be integrated into one processing unit, or each unit may physically exist separately, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:快闪存储器、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium In, several instructions are included to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor execute all or part of the steps of the method described in each embodiment. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk, and other various media capable of storing program codes.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only a specific implementation of the application, but the protection scope of the application is not limited thereto, and any changes or replacements within the technical scope disclosed in the application should be covered within the protection scope of the application . Therefore, the protection scope of the present application should be determined by the protection scope of the claims.

Claims (32)

  1. 一种由第一设备执行的用于配置监听周期的方法,其特征在于,所述第一设备和第二设备处于蓝牙连接状态,所述方法包括:A method for configuring a listening period performed by a first device, wherein the first device and the second device are in a Bluetooth connection state, and the method includes:
    将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期,其中所述非默认的监听周期是用于所述第二设备在监听模式下监听所述第一设备发送的心跳包的、并且与所述第二设备的中断周期不重合的监听周期;以及Setting the monitoring period for the second device stored in the first device as a non-default monitoring period, wherein the non-default monitoring period is for the second device to monitor the A monitoring period of the heartbeat packet sent by the first device that does not coincide with the interruption period of the second device; and
    向所述第二设备发送关于所述非默认的监听周期的信息。sending information about the non-default listening period to the second device.
  2. 根据权利要求1所述的方法,其特征在于,The method according to claim 1, characterized in that,
    在将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期之前,所述方法还包括:Before setting the listening period stored in the first device for the second device as a non-default listening period, the method further includes:
    判断是否满足使用默认的监听周期的条件;Determine whether the conditions for using the default monitoring period are met;
    其中,将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期包括:Wherein, setting the listening period stored in the first device for the second device as a non-default listening period includes:
    当不满足所述使用默认的监听周期的条件时,将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期。When the condition for using the default listening period is not satisfied, the listening period stored in the first device for the second device is set as a non-default listening period.
  3. 根据权利要求2所述的方法,其特征在于,所述使用默认的监听周期的条件为所述第一设备未成功获取到所述第二设备的中断周期。The method according to claim 2, wherein the condition for using the default monitoring period is that the first device fails to obtain the interruption period of the second device.
  4. 根据权利要求3所述的方法,其特征在于,The method according to claim 3, characterized in that,
    在所述判断是否满足使用默认的监听周期的条件之前,所述方法还包括:Before the judging whether the condition of using the default monitoring period is satisfied, the method further includes:
    向所述第二设备发送中断参数获取命令,其中所述中断参数获取命令用于获取所述第二设备的中断周期;sending an interrupt parameter acquisition command to the second device, where the interrupt parameter acquisition command is used to acquire an interrupt period of the second device;
    其中所述判断是否满足使用默认的监听周期的条件包括:The conditions for judging whether the default monitoring period is met include:
    当接收到与所述中断参数获取命令对应的响应信息,且所述响应信息中携带有所述第二设备的中断周期时,判断出满足所述使用默认的监听周期的条件;以及When the response information corresponding to the interrupt parameter acquisition command is received, and the response information carries the interrupt period of the second device, it is determined that the condition of using the default monitoring period is satisfied; and
    当未接收到与所述中断参数获取命令对应的响应信息,或者,所述响应信息中未携带有所述第二设备的中断周期时,判断出不满足所述使用默认的监听周期的条件。When the response information corresponding to the interruption parameter acquisition command is not received, or the response information does not carry the interruption period of the second device, it is determined that the condition of using the default monitoring period is not satisfied.
  5. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, characterized in that the method further comprises:
    至少根据所述第二设备的中断周期确定所述非默认的监听周期。The non-default listening period is determined according to at least an interruption period of the second device.
  6. 根据权利要求5所述的方法,其特征在于,所述至少根据所述第二设备的中断周期确定所述非默认的监听周期包括:The method according to claim 5, wherein the determining the non-default monitoring period at least according to the interruption period of the second device comprises:
    当接收到的第二设备的中断周期为一个时,根据所接收到的中断周期、特定倍数、以及偏移值,计算得到所述非默认的监听周期;When the received interruption period of the second device is one, calculate the non-default monitoring period according to the received interruption period, specific multiple, and offset value;
    当接收到的第二设备的中断周期为多个时,根据所接收到的多个中断周期的最小公倍数、特定倍数、以及偏移值,计算得到所述非默认的监听周期,或者,根据所接收到的多个中断周期中的最大值、特定倍数、以及偏移值,计算得到所述非默认的监听周期;其中,所述特定倍数为正整数,所述偏移值为整数。When multiple interrupt periods of the second device are received, the non-default listening period is calculated according to the least common multiple, specific multiple, and offset value of the multiple received interrupt periods, or, according to the The non-default monitoring period is obtained by calculating the maximum value, a specific multiple, and an offset value among the multiple received interruption periods; wherein, the specific multiple is a positive integer, and the offset value is an integer.
  7. 根据权利要求6所述的方法,其特征在于,所述非默认的监听周期的值满足处于预设范围内的条件;其中所述预设范围是根据所述默认的监听周期设定的。The method according to claim 6, wherein the value of the non-default monitoring period satisfies the condition of being within a preset range; wherein the preset range is set according to the default monitoring period.
  8. 根据权利要求7所述的方法,其特征在于,所述预设范围为所述非默认的监听周期与所述默认的监听周期的差值小于或等于预设偏差值的范围。The method according to claim 7, wherein the preset range is a range in which the difference between the non-default listening period and the default listening period is less than or equal to a preset deviation value.
  9. 根据权利要求8所述的方法,其特征在于,所述中断参数获取命令还用于获取所述第二设备的周期偏差;所述非默认的监听周期的值还满足所述非默认的监听周期与所述默认的监听周期的差值大于所述周期偏差的条件。The method according to claim 8, wherein the interrupt parameter acquisition command is also used to acquire the cycle deviation of the second device; the value of the non-default listening cycle also satisfies the non-default listening cycle A condition that the difference from the default listening period is greater than the period deviation.
  10. 根据权利要求3至9任一所述的方法,其特征在于,在向所述第二设备发送关于非默认的监听周期的信息之后,所述方法还包括:The method according to any one of claims 3 to 9, wherein after sending the information about the non-default listening period to the second device, the method further comprises:
    当监听模式下所述第一设备与所述第二设备之间的蓝牙通信的断连次数大于或等于断连阈值时,将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长;When the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is greater than or equal to the disconnection threshold, the value of the listening duration of the second device is increased to a preset value, so as to Determine the updated monitoring duration;
    向所述第二设备发送关于所述更新后的监听时长的信息。sending information about the updated listening duration to the second device.
  11. 根据权利要求2所述的方法,其特征在于,所述使用默认的监听周期的条件为监听模式下所述第一设备与所述第二设备之间的蓝牙通信的断连次数小于断连阈值。The method according to claim 2, wherein the condition for using the default listening period is that the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is less than a disconnection threshold .
  12. 根据权利要求11所述的方法,其特征在于,The method according to claim 11, characterized in that,
    在所述判断是否满足使用默认的监听周期的条件之前,还包括:Before the judgment of whether the condition of using the default monitoring period is met, it also includes:
    向所述第二设备发送关于所述默认的监听周期的信息;sending information about the default listening period to the second device;
    其中所述第二设备以所述默认的监听周期来监听所述第一设备发送的心跳包。Wherein the second device monitors the heartbeat packet sent by the first device in the default monitoring period.
  13. 根据权利要求12所述的方法,其特征在于,所述非默认的监听周期为所述默认的监听周期与偏移值的和,其中所述偏移值为整数。The method according to claim 12, wherein the non-default monitoring period is the sum of the default monitoring period and an offset value, wherein the offset value is an integer.
  14. 根据权利要求13所述的方法,其特征在于,所述非默认的监听周期的值满足处于预设范围内的条件;其中,所述预设范围是根据所述默认的监听周期设定的。The method according to claim 13, wherein the value of the non-default monitoring period satisfies the condition of being within a preset range; wherein the preset range is set according to the default monitoring period.
  15. 根据权利要求11至14任一所述的方法,其特征在于,在向所述第二设备发送关于非默认的监听周期的信息之后,所述方法还包括:The method according to any one of claims 11 to 14, characterized in that, after sending the information about the non-default listening period to the second device, the method further comprises:
    当所述第一设备和所述第二设备之间的蓝牙通信断连时,将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长;When the Bluetooth communication between the first device and the second device is disconnected, increasing the value of the listening duration of the second device to a preset value to determine an updated listening duration;
    向所述第二设备发送关于所述更新后的监听时长的信息。sending information about the updated listening duration to the second device.
  16. 根据权利要求10所述的方法,其特征在于,在将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长之后,所述方法还包括:The method according to claim 10, characterized in that, after increasing the value of the listening duration of the second device to a preset value to determine the updated listening duration, the method further comprises:
    向所述第二设备发送退出监听模式的请求,并将所述断连次数清零。Sending a request to exit the listening mode to the second device, and clearing the number of times of disconnection.
  17. 一种电子设备,其特征在于,所述电子设备包括:通信模块,所述通信模块包括无线通信模块;所述无线通信模块用于执行如权利要求1至16任一所述的由第一设备执行的用于配置监听周期的方法。An electronic device, characterized in that the electronic device comprises: a communication module, the communication module includes a wireless communication module; The method implemented to configure the listening period.
  18. 一种由第一设备执行的用于配置监听周期的方法,其特征在于,所述第一设备和第二设备处于蓝牙连接状态,所述方法包括:A method for configuring a listening period performed by a first device, wherein the first device and the second device are in a Bluetooth connection state, and the method includes:
    将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期,其中所述非默认的监听周期是用于所述第二设备在监听模式下监听所述第一设备发送的心跳包的、并且与所述第二设备的中断周期不重合的监听周期;所述非默认的监听周期至少根据所述第二设备的中断周期和偏移值计算得到,或者,所述非默认的监听周期至少根据默认的监听周期和偏移值计算得到;以及Setting the monitoring period for the second device stored in the first device as a non-default monitoring period, wherein the non-default monitoring period is for the second device to monitor the The monitoring period of the heartbeat packet sent by the first device and not coincident with the interruption period of the second device; the non-default monitoring period is at least calculated according to the interruption period and offset value of the second device, or , the non-default listening period is at least calculated according to the default listening period and an offset value; and
    向所述第二设备发送关于所述非默认的监听周期的信息。sending information about the non-default listening period to the second device.
  19. 根据权利要求18所述的方法,其特征在于,The method of claim 18, wherein,
    在将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期之前,所述方法还包括:Before setting the listening period stored in the first device for the second device as a non-default listening period, the method further includes:
    判断是否满足使用默认的监听周期的条件;Determine whether the conditions for using the default monitoring period are met;
    其中,将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期包括:Wherein, setting the listening period stored in the first device for the second device as a non-default listening period includes:
    当不满足所述使用默认的监听周期的条件时,将所述第一设备中存储的用于所述第二设备的监听周期设置为非默认的监听周期。When the condition for using the default listening period is not met, the listening period stored in the first device for the second device is set as a non-default listening period.
  20. 根据权利要求19所述的方法,其特征在于,所述使用默认的监听周期的条件为所述第一设备未成功获取到所述第二设备的中断周期。The method according to claim 19, wherein the condition for using the default monitoring period is that the first device fails to obtain the interruption period of the second device.
  21. 根据权利要求20所述的方法,其特征在于,The method of claim 20, wherein
    在所述判断是否满足使用默认的监听周期的条件之前,所述方法还包括:Before the judging whether the condition of using the default monitoring period is satisfied, the method further includes:
    向所述第二设备发送中断参数获取命令,其中所述中断参数获取命令用于获取所述第二设备的中断周期;sending an interrupt parameter acquisition command to the second device, where the interrupt parameter acquisition command is used to acquire an interrupt period of the second device;
    其中所述判断是否满足使用默认的监听周期的条件包括:The conditions for judging whether the default monitoring period is met include:
    当接收到与所述中断参数获取命令对应的响应信息,且所述响应信息中携带有所述第二设备的中断周期时,判断出满足所述使用默认的监听周期的条件;以及When the response information corresponding to the interrupt parameter acquisition command is received, and the response information carries the interrupt period of the second device, it is determined that the condition of using the default monitoring period is satisfied; and
    当未接收到与所述中断参数获取命令对应的响应信息,或者,所述响应信息中未携带有所述第二设备的中断周期时,判断出不满足所述使用默认的监听周期的条件。When the response information corresponding to the interruption parameter acquisition command is not received, or the response information does not carry the interruption period of the second device, it is determined that the condition of using the default monitoring period is not satisfied.
  22. 根据权利要求21所述的方法,其特征在于,所述至少根据所述第二设备的中断周期和偏移值计算得到所述非默认的监听周期的过程,包括:The method according to claim 21, wherein the process of calculating the non-default listening period at least according to the interruption period and offset value of the second device includes:
    当接收到的第二设备的中断周期为一个时,根据所接收到的中断周期、特定倍数、以及偏移值,计算得到所述非默认的监听周期;When the received interruption period of the second device is one, calculate the non-default monitoring period according to the received interruption period, specific multiple, and offset value;
    当接收到的第二设备的中断周期为多个时,根据所接收到的多个中断周期的最小公倍数、特定倍数、以及偏移值,计算得到所述非默认的监听周期,或者,根据所接收到的多个中断周期中的最大值、特定倍数、以及偏移值,计算得到所述非默认的监听周期;其中,所述特定倍数为正整数,所述偏移值为整数。When multiple interrupt periods of the second device are received, the non-default listening period is calculated according to the least common multiple, specific multiple, and offset value of the multiple received interrupt periods, or, according to the The non-default monitoring period is obtained by calculating the maximum value, a specific multiple, and an offset value among the multiple received interruption periods; wherein, the specific multiple is a positive integer, and the offset value is an integer.
  23. 根据权利要求22所述的方法,其特征在于,所述非默认的监听周期的值满足处于预设范围内的条件;其中所述预设范围是根据所述默认的监听周期设定的。The method according to claim 22, wherein the value of the non-default monitoring period satisfies the condition of being within a preset range; wherein the preset range is set according to the default monitoring period.
  24. 根据权利要求23所述的方法,其特征在于,所述预设范围为所述非默认的监听周期与所述默认的监听周期的差值小于或等于预设偏差值的范围。The method according to claim 23, wherein the preset range is a range in which the difference between the non-default listening period and the default listening period is less than or equal to a preset deviation value.
  25. 根据权利要求24所述的方法,其特征在于,所述中断参数获取命令还用于获取所述第二设备的周期偏差;所述非默认的监听周期的值还满足所述非默认的监听周期与所述默认的监听周期的差值大于所述周期偏差的条件。The method according to claim 24, wherein the interrupt parameter acquisition command is also used to acquire the cycle deviation of the second device; the value of the non-default listening cycle also satisfies the non-default listening cycle A condition that the difference from the default listening period is greater than the period deviation.
  26. 根据权利要求20至25任一所述的方法,其特征在于,在向所述第二设备发送关于非默认的监听周期的信息之后,所述方法还包括:The method according to any one of claims 20 to 25, characterized in that, after sending the information about the non-default listening period to the second device, the method further comprises:
    当监听模式下所述第一设备与所述第二设备之间的蓝牙通信的断连次数大于或等于断 连阈值时,将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长;When the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is greater than or equal to the disconnection threshold, the value of the listening duration of the second device is increased to a preset value, so as to Determine the updated monitoring duration;
    向所述第二设备发送关于所述更新后的监听时长的信息。sending information about the updated listening duration to the second device.
  27. 根据权利要求19所述的方法,其特征在于,所述使用默认的监听周期的条件为监听模式下所述第一设备与所述第二设备之间的蓝牙通信的断连次数小于断连阈值。The method according to claim 19, wherein the condition for using the default listening cycle is that the number of disconnections of the Bluetooth communication between the first device and the second device in the listening mode is less than a disconnection threshold .
  28. 根据权利要求27所述的方法,其特征在于,The method of claim 27, wherein,
    在所述判断是否满足使用默认的监听周期的条件之前,还包括:Before the judgment of whether the condition of using the default monitoring period is met, it also includes:
    向所述第二设备发送关于所述默认的监听周期的信息;sending information about the default listening period to the second device;
    其中所述第二设备以所述默认的监听周期来监听所述第一设备发送的心跳包。Wherein the second device monitors the heartbeat packet sent by the first device in the default monitoring period.
  29. 根据权利要求28所述的方法,其特征在于,所述非默认的监听周期为所述默认的监听周期与偏移值的和,其中所述偏移值为整数。The method according to claim 28, wherein the non-default monitoring period is the sum of the default monitoring period and an offset value, wherein the offset value is an integer.
  30. 根据权利要求29所述的方法,其特征在于,所述非默认的监听周期的值满足处于预设范围内的条件;其中,所述预设范围是根据所述默认的监听周期设定的。The method according to claim 29, wherein the value of the non-default monitoring period satisfies the condition of being within a preset range; wherein the preset range is set according to the default monitoring period.
  31. 根据权利要求27至30任一所述的方法,其特征在于,在向所述第二设备发送关于非默认的监听周期的信息之后,所述方法还包括:The method according to any one of claims 27 to 30, characterized in that, after sending the information about the non-default listening period to the second device, the method further comprises:
    当所述第一设备和所述第二设备之间的蓝牙通信断连时,将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长;When the Bluetooth communication between the first device and the second device is disconnected, increasing the value of the listening duration of the second device to a preset value to determine an updated listening duration;
    向所述第二设备发送关于所述更新后的监听时长的信息。sending information about the updated listening duration to the second device.
  32. 根据权利要求26所述的方法,其特征在于,在将所述第二设备的监听时长的值增加至预设值,以确定更新后的监听时长之后,所述方法还包括:The method according to claim 26, wherein after increasing the value of the listening duration of the second device to a preset value to determine an updated listening duration, the method further comprises:
    向所述第二设备发送退出监听模式的请求,并将所述断连次数清零。Sending a request to exit the listening mode to the second device, and clearing the number of times of disconnection.
PCT/CN2022/115426 2021-11-11 2022-08-29 Method for configuring sniff interval and corresponding electronic device WO2023082778A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111330141.6 2021-11-11
CN202111330141.6A CN113783758B (en) 2021-11-11 2021-11-11 Method for configuring monitoring period and corresponding electronic equipment

Publications (1)

Publication Number Publication Date
WO2023082778A1 true WO2023082778A1 (en) 2023-05-19

Family

ID=78873722

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/115426 WO2023082778A1 (en) 2021-11-11 2022-08-29 Method for configuring sniff interval and corresponding electronic device

Country Status (2)

Country Link
CN (1) CN113783758B (en)
WO (1) WO2023082778A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113783758B (en) * 2021-11-11 2022-04-15 荣耀终端有限公司 Method for configuring monitoring period and corresponding electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150126257A1 (en) * 2013-11-05 2015-05-07 Electronics And Telecommunications Research Institute Method and system for providing sleep state of network-accessible terminal
US20170026906A1 (en) * 2015-07-26 2017-01-26 Qualcomm Incorporated Methods, systems, and apparatus for saving power by synchronizing wakeup intervals
CN106793044A (en) * 2017-02-28 2017-05-31 飞天诚信科技股份有限公司 A kind of method and bluetooth security equipment for realizing bluetooth security equipment low-power consumption standby
CN111226186A (en) * 2018-03-16 2020-06-02 华为技术有限公司 Wake-up management method, timer management method and terminal equipment
CN112822663A (en) * 2019-10-31 2021-05-18 华为技术有限公司 Bluetooth connection method and related device
CN113783758A (en) * 2021-11-11 2021-12-10 荣耀终端有限公司 Method for configuring monitoring period and corresponding electronic equipment

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7102504B2 (en) * 2004-05-27 2006-09-05 Lawrence Kates Wireless sensor monitoring unit
EP1788748B1 (en) * 2005-11-18 2009-02-11 Nokia Siemens Networks Gmbh & Co. Kg Method of operating a device in a radio access network of a radio communication system as well as radio access network and device
US8171322B2 (en) * 2008-06-06 2012-05-01 Apple Inc. Portable electronic devices with power management capabilities
US8730853B2 (en) * 2008-09-05 2014-05-20 Mediatek Inc. Methods for responding to co-located coexistence (CLC) request from a mobile electronic device and communications apparatuses capable of controlling multi-radio coexistence
US8731560B2 (en) * 2012-03-16 2014-05-20 Qualcomm Incorporated Access point synchronization with cooperative mobile devices
US9408149B2 (en) * 2013-03-18 2016-08-02 Mediatek Inc. Method of managing communication traffic for multiple communication technologies and communication device thereof
JP6578705B2 (en) * 2015-03-31 2019-09-25 富士通株式会社 Distribution system, distribution method, distribution apparatus, and distribution program
CN107960148A (en) * 2015-05-14 2018-04-24 英特尔Ip公司 The measuring method of carrier aggregation and asynchronous biconnectivity
CN109792688B (en) * 2016-07-27 2022-03-15 瑞典爱立信有限公司 Managing sleep cycles in a wireless communication system
WO2018125233A1 (en) * 2016-12-30 2018-07-05 Agerstam Mats Mechanism for efficient data reporting in iiot wsn
US10694562B2 (en) * 2017-09-18 2020-06-23 Apple Inc. Off grid radio service system design
JP7246860B2 (en) * 2018-03-30 2023-03-28 キヤノン株式会社 Communications equipment and programs
WO2019191996A1 (en) * 2018-04-04 2019-10-10 华为技术有限公司 Data transmission method and device
CN108566687A (en) * 2018-04-25 2018-09-21 成都西谷曙光数字技术有限公司 LDSW ultra-low power consumption wireless self-organizing network system and communication means
CN109614240A (en) * 2018-12-13 2019-04-12 锐捷网络股份有限公司 Memory application method, equipment and storage medium
CN111955049B (en) * 2020-06-24 2023-12-22 北京小米移动软件有限公司 State control method, device, communication equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150126257A1 (en) * 2013-11-05 2015-05-07 Electronics And Telecommunications Research Institute Method and system for providing sleep state of network-accessible terminal
US20170026906A1 (en) * 2015-07-26 2017-01-26 Qualcomm Incorporated Methods, systems, and apparatus for saving power by synchronizing wakeup intervals
CN106793044A (en) * 2017-02-28 2017-05-31 飞天诚信科技股份有限公司 A kind of method and bluetooth security equipment for realizing bluetooth security equipment low-power consumption standby
CN111226186A (en) * 2018-03-16 2020-06-02 华为技术有限公司 Wake-up management method, timer management method and terminal equipment
CN112822663A (en) * 2019-10-31 2021-05-18 华为技术有限公司 Bluetooth connection method and related device
CN113783758A (en) * 2021-11-11 2021-12-10 荣耀终端有限公司 Method for configuring monitoring period and corresponding electronic equipment

Also Published As

Publication number Publication date
CN113783758B (en) 2022-04-15
CN113783758A (en) 2021-12-10

Similar Documents

Publication Publication Date Title
WO2020211733A1 (en) Bluetooth connection method, device and system
US9414311B2 (en) Systems and methods for power savings in wireless communications
WO2021036835A1 (en) Bluetooth search method and system, and related apparatus
KR101576250B1 (en) Power save mechanism for peer-to-peer communication networks
US9699593B2 (en) Scanning enhancements for short-range wireless devices
CN113366439B (en) Method and device for connecting Bluetooth device
WO2018000134A1 (en) Bluetooth connection method and terminal
US11375569B2 (en) Method and device for reconnecting Bluetooth communication
CN104584677A (en) Processor-independent communication of network availability
TWI812868B (en) Method of establishing communication for exchanging ranging information
WO2021043219A1 (en) Bluetooth reconnection method and related apparatus
EP4199562A1 (en) Method for transmitting data and electronic device
WO2021043198A1 (en) Bluetooth pairing method, and related device
US10159105B1 (en) Performing proprietary link manager feature discovery and exchange with a peer proprietary device
KR20150114845A (en) Method for reconnecting master device and slave device
WO2023082778A1 (en) Method for configuring sniff interval and corresponding electronic device
WO2021043250A1 (en) Bluetooth communication method, and related device
US11330468B2 (en) Low power techniques for bluetooth low energy in scanning state
WO2014024175A2 (en) Managing timers
EP3709717A1 (en) Communication device, communication system, and program
US20090100281A1 (en) Communication device and communication method
WO2022037368A1 (en) Sleep control method for mobile routing device, and mobile routing device
WO2024022256A1 (en) Method for managing connection between devices, and device and system
WO2023142993A1 (en) Detection method, related electronic device and system
EP4187984A1 (en) Bluetooth low energy connection power consumption

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22891583

Country of ref document: EP

Kind code of ref document: A1