Data sending/receiving method, electronic device, and computer-readable storage medium
This application provides a data sending/receiving method, an electronic device, and a computer-readable storage medium. In this application, a first device may receive, in a wakeup state, first data sent by a second device; after sending of the first data is completed, the first device enters a sleep state after a first duration; the first device wakes up again after a second duration; the first device may receive, in the wakeup state, second data sent by the second device; and after sending of the second data is completed, the first device enters a sleep mode after a third duration. In this process, the first duration is different from the third duration.
1 . A method comprising:
receiving, by a first device in a wakeup state, first data sent by a second device, wherein the first data is of a first application in a foreground of the first device;
waiting, by the first device in the wakeup state after completing receiving the first data, for a first duration;
sending, by the first device, sleep indication information after the first duration, wherein the sleep indication information indicates that the first device is to enter a sleep state, and the first duration is a duration between completing receiving the first data and entering the sleep state;
entering, by the first device, the sleep state after the first duration in response to completing receiving the first data;
entering, by the first device, the wakeup state after a second duration after the first device enters the sleep state;
receiving, by the first device in the wakeup state, second data sent by the second device, wherein the second data is of a second application in the foreground of the first device after the foreground is switched from the first application to the second application;
waiting, by the first device in the wakeup state after completing receiving the second data, for a third duration; and
entering, by the first device, the sleep state after the third duration in response to completing receiving the second data, wherein
the third duration is a duration between completing receiving the second data and entering the sleep state, the first duration is different from the third duration, the first duration is based on the first application, and the third duration is based on the second application.
2 . The method according to claim 1 , wherein a length of the first duration is further based on at least one of a service volume of the first device, signal strength, an occupation status of a shared antenna, an interference status, a delay requirement of the first application in the foreground of the first device, or a type of the second device; and
a length of the second duration depends on at least one of the service volume of the first device, the signal strength, the occupation status of the shared antenna, the interference status, a delay requirement of the second application in the foreground of the first device, or the type of the second device.
3 . The method according to claim 1 , wherein before the first device enters the sleep state after the third duration, the method further comprises:
sending, by the first device, additional sleep indication information, wherein the additional sleep indication information indicates that the first device is to enter the sleep state.
4 . The method according to claim 1 , wherein when the first device is in the sleep state, a wireless transmission capability of the first device is limited.
5 . The method according to claim 1 , wherein when the first device is in the sleep state, downlink data of the first device is buffered by the second device.
6 . The method according to claim 1 , wherein a length of the second duration is related to a beacon frame, and the beacon frame is periodically broadcast by the second device.
7 . The method according to claim 6 , wherein the method further comprises:
listening, by the first device, to the beacon frame at a timing end point of the second duration.
8 . The method according to claim 6 , wherein the method further comprises:
listening, by the first device, to the beacon frame after a fourth duration after a timing end point of the second duration.
9 . The method according to claim 6 , wherein the second duration comprises at least one period duration of the beacon frame.
10 . The method according to claim 6 , further comprising:
when the first device is connected to the second device, obtaining, by the first device, a transmission period of the beacon frame.
11 . The method according to claim 1 , further comprising:
when the first device is in the wakeup state, listening, by the first device, to a beacon frame periodically sent by the second device, wherein the beacon frame indicates whether there is downlink data buffered for the first device in the second device.
12 . The method according to claim 11 , further comprising:
when the beacon frame indicates that there is downlink data buffered for the first device in the second device, sending, by the first device, wakeup indication information indicating that the first device is currently in the wakeup state.
13 . The method according to claim 11 , further comprising:
when the beacon frame indicates that there is no downlink data buffered for the first device in the second device, entering, by the first device, the sleep state after a fifth duration.
14 . The method according to claim 1 , wherein the first data is data most recently received by the first device in a current wakeup period.
15 . The method according to claim 1 , wherein the first data is data first received by the first device in the wakeup state in a current wakeup period.
16 . The method according to claim 1 , further comprising:
after the entering, by the first device, the sleep state after the third duration in response to completing receiving of the second data, entering, by the first device, the wakeup state after a sixth duration;
sending, by the first device, third data to the second device; and
entering, by the first device, the sleep state after a seventh duration in response to completing sending the third data.
17 . The method according to claim 1 , further comprising:
after the entering, by the first device, the wakeup state after the second duration, and before the receiving, by the first device, the second data sent by the second device, sending, by the first device, fourth data to the second device;
entering, by the first device, the sleep state after an eighth duration in response to completing sending the fourth data; and
entering, by the first device, the wakeup state after a ninth duration.
18 . The method according to claim 1 , wherein the first device is a wireless station, and the second device is a wireless access point.
19 . A method comprising:
sending, by a first device in a wakeup state, first data to a second device;
waiting, by the first device in the wakeup state after completing sending of the first data, for a first duration;
sending, by the first device, sleep indication information after the first duration, wherein the sleep indication information indicates that the first device is to enter a sleep state, and the first duration is a duration between completing sending the first data and entering the sleep state;
entering, by the first device, a sleep state after the first duration in response to completing sending the first data;
entering, by the first device, the wakeup state after a second duration after the first device enters the sleep state;
sending, by the first device in the wakeup state, second data to the second device;
waiting, by the first device in the wakeup state after completing sending of the second data, for a third duration; and
entering, by the first device, the sleep state after the third duration in response to completing sending the second data, wherein:
the third duration is a duration between completing sending the second data and entering the sleep state, and the first duration is different from the third duration;
a length of the first duration depends on at least one of signal strength, an occupation status of a shared antenna, an interference status, a type of a current application in a foreground of the first device, or a type of the second device; and
a length of the second duration depends on at least one of the signal strength, the occupation status of the shared antenna, the interference status, the type of the current application in the foreground of the first device, or the type of the second device.
20 . The method according to claim 19 , further comprising:
sending, by the first device, additional sleep indication information after the third duration, wherein the additional sleep indication information indicates that the first device is to enter the sleep state.