Search

US-12628083-B2 - Communication method and apparatus

US12628083B2US 12628083 B2US12628083 B2US 12628083B2US-12628083-B2

Abstract

A communication method and apparatus are provided, to resolve a problem that timeliness of data transmission is affected because a communication connection is not established in time. A network protocol stack is deployed for each of a service processing unit and a wireless communication unit in a first communication apparatus. In this way, before the service processing unit enters a working mode, the wireless communication unit may establish a transmission channel with a second communication apparatus based on the deployed network protocol stack. After the service processing unit enters the working mode, the service processing unit exchanges data with the second communication apparatus through the transmission channel based on the deployed network protocol stack.

Inventors

  • Fengxi Liu
  • Hua Ming

Assignees

  • HUAWEI TECHNOLOGIES CO., LTD.

Dates

Publication Date
20260512
Application Date
20220916

Claims (20)

  1. 1 . A communication method, applied to a first communication apparatus powered by a battery, wherein the first communication apparatus comprises a service processing chip and a wireless communication chip, and the method comprises: before the service processing chip enters a working mode, establishing, by the wireless communication chip, a transmission channel with a second communication apparatus; sending, by the service processing chip, an occupation notification to the wireless communication chip, wherein the occupation notification indicates that the service processing chip is to occupy the transmission channel; after receiving the occupation notification, suspending, by the wireless communication chip, use of the transmission channel to send network data; and then sending, by the service processing chip, a to-be-sent first network data packet to the second communication apparatus through the transmission channel after the service processing chip enters the working mode.
  2. 2 . The method according to claim 1 , wherein the second communication apparatus is a terminal device, and the transmission channel is a peer-to-peer P2P channel; and establishing, by the wireless communication chip, the transmission channel with the second communication apparatus comprises: establishing, by the wireless communication chip, the P2P channel with the second communication apparatus through P2P hole punching.
  3. 3 . The method according to claim 1 , wherein suspending, by the wireless communication chip, use of the transmission channel comprises: allocating, by the wireless communication chip, a port used for communicating with the second communication apparatus through the transmission channel to the service processing chip.
  4. 4 . The method according to claim 1 , wherein after the service processing chip enters the working mode, the method further comprises: modifying, by the wireless communication chip, a first mapping relationship in a stored mapping relationship to a second mapping relationship; or adding, by the wireless communication chip, a first mapping relationship to a stored mapping relationship, wherein the second mapping relationship is an association relationship between first parameter information and an identifier of the service processing chip, the second mapping relationship is used for determining that a communication data packet carrying the first parameter information is processed by the service processing chip, the first mapping relationship is an association relationship between second parameter information and an identifier of the wireless communication chip, and the first mapping relationship is used for determining that a network data packet carrying the second parameter information is processed by the wireless communication chip.
  5. 5 . The method according to claim 4 , wherein after the service processing chip enters the working mode, the method further comprises: receiving, by the wireless communication chip, a second network data packet sent by the second communication apparatus through the transmission channel, wherein the second network data packet carries the first parameter information; determining, by the wireless communication chip based on the first parameter information and the second mapping relationship, that the second network data packet is processed by the service processing chip, and sending the second network data packet to the service processing chip; and decapsulating, by the service processing chip, the second network data packet by using the first network protocol stack.
  6. 6 . The method according to claim 5 , wherein sending, by the wireless communication chip, the second network data packet to the service processing chip comprises: translating, by the wireless communication chip, a destination address of the second network data packet from address information of the wireless communication chip into address information of the service processing chip, and sending, based on a translated destination address, the second network data packet having the translated destination address to the service processing chip.
  7. 7 . The method according to claim 4 , wherein the first parameter information comprises one or more of a port number used by the service processing chip to communicate with the second communication apparatus, the IP address of the second communication apparatus, or the port number of the second communication apparatus; and the second parameter information comprises one or more of a port number used by the wireless communication chip to communicate with the second communication apparatus, the IP address of the second communication apparatus, or the port number of the second communication apparatus.
  8. 8 . The method according to claim 1 , wherein after sending, by the service processing chip, the occupation notification to the wireless communication chip, the method further comprises: sending, by the service processing chip, an occupation release notification to the wireless communication chip, wherein the occupation release notification is used for notifying the wireless communication chip that the service processing chip has stopped using the transmission channel; and after the wireless communication chip receives the occupation release notification, resume using the transmission channel to send the network data packet generated by the wireless communication chip to the second communication apparatus.
  9. 9 . The method according to claim 1 , wherein sending, by the service processing chip, the to-be-sent first network data packet to the second communication apparatus comprises: encapsulating, by the service processing chip, to-be-sent service data into first-format data that comprises data type information that indicates a data type of the to-be-sent service data; encapsulating, by the service processing chip, the first-format data into the first network data packet based on channel information of the transmission channel by using a first network protocol stack, and sending the first network data packet to the wireless communication chip; and sending, by the wireless communication chip, the first network data packet to the second communication apparatus.
  10. 10 . The method according to claim 9 , wherein the channel information of the transmission channel comprises one or more of an IP address of the service processing chip, a port number used by the first communication apparatus to communicate with the second communication apparatus, a protocol type, an IP address of the second communication apparatus, or a port number of the second communication apparatus.
  11. 11 . The method according to claim 10 , wherein the IP address of the service processing chip is the same as the IP address of the wireless communication chip.
  12. 12 . The method according to claim 9 , wherein sending, by the wireless communication chip, the first network data packet to the second communication apparatus comprises: translating a source address of the first network data packet from address information of the service processing chip into address information of the wireless communication chip, and sending, by the wireless communication chip, the first network data packet having a translated address to the second communication apparatus.
  13. 13 . The method according to claim 1 , wherein before the service processing chip enters the working mode, the method further comprises: receiving, by the wireless communication chip, a second network data packet sent by the second communication apparatus through the transmission channel, wherein the second network data packet carries second parameter information; determining, based on the second parameter information and the first mapping relationship, that the second network data packet has been processed by the wireless communication chip and decapsulating, by the wireless communication chip, the second network data packet by using a second network protocol stack.
  14. 14 . The method according to claim 1 , further comprising: encapsulating, by the wireless communication chip, to-be-sent first communication information into a second network data packet based on the channel information of the transmission channel by using a second network protocol stack, and sending the second network data packet to the second communication apparatus, wherein the first communication information is used for communicating with the second communication apparatus.
  15. 15 . A battery-powered communication apparatus having a working mode and a standby mode, the communication apparatus comprising: a service processing chip and a wireless communication chip, wherein the wireless communication chip is configured to, before the service processing chip enters the working mode, establish a transmission channel with a second communication apparatus; wherein the service processing chip is configured to send an occupation notification to the wireless communication chip, wherein the occupation notification indicates that the service processing chip is to occupy the transmission channel; wherein the wireless communication chip is further configured to, after receiving the occupation notification, suspend use of the transmission channel to send network data; and wherein the service processing chip is further configured to, after entering the working mode and after sending the occupation notification, send a to-be-sent first network data packet to the second communication apparatus through the transmission channel.
  16. 16 . The battery-powered communication apparatus of claim 15 , wherein the second communication apparatus is a terminal device, and the transmission channel is a peer-to-peer P2P channel; and the wireless communication chip is configured to establish the transmission channel with the second communication apparatus by establishing the P2P channel with the second communication apparatus through P2P hole punching.
  17. 17 . The battery-powered communication apparatus of claim 15 , wherein the wireless communication chip is further configured to, after the service processing chip enters the working mode, modify a first mapping relationship in a stored mapping relationship to a second mapping relationship; or add a first mapping relationship to a stored mapping relationship, wherein the second mapping relationship is an association relationship between first parameter information and an identifier of the service processing chip, the second mapping relationship is used for determining that a communication data packet carrying the first parameter information is processed by the service processing chip, the first mapping relationship is an association relationship between second parameter information and an identifier of the wireless communication chip, and the first mapping relationship is used for determining that a network data packet carrying the second parameter information is processed by the wireless communication chip.
  18. 18 . The battery-powered communication apparatus of claim 15 , wherein the wireless communication chip is further configured to, before the service processing chip enters the working mode, receive a second network data packet sent by the second communication apparatus through the transmission channel, wherein the second network data packet carries the second parameter information; and decapsulate the second network data packet by using a second network protocol stack.
  19. 19 . The battery-powered communication apparatus of claim 15 , wherein the service processing chip is further configured to, after sending the occupation notification, send an occupation release notification to the wireless communication chip, wherein the occupation release notification notifies the wireless communication chip that the service processing chip has stopped using the transmission channel; and the wireless communication chip is further configured to, after receiving the occupation release notification, resume using the transmission channel to send the network data packet generated by the wireless communication chip to the second communication apparatus.
  20. 20 . The battery-powered communication apparatus of claim 15 , wherein the service processing chip is configured to send the to-be-sent first network data packet to the second communication apparatus by encapsulating to-be-sent service data into first-format data that comprises data type information that indicates a data type of the to-be-sent service data; encapsulating the first-format data into the first network data packet based on channel information of the transmission channel by using a first network protocol stack, and sending the first network data packet to the wireless communication chip; and sending, by the wireless communication chip, the first network data packet to the second communication apparatus.

Description

CROSS-REFERENCE TO RELATED APPLICATIONS This application is a continuation of International Application No. PCT/CN2020/079791, filed on Mar. 17, 2020, the disclosure of which is hereby incorporated by reference in its entirety. TECHNICAL FIELD This application relates to the field of communication technologies, and in particular, to a communication method and apparatus. BACKGROUND Currently, a photography device powered by a battery generally includes a camera chip and a Wi-Fi chip. The camera chip is configured to capture, encode, and store audio/video. The Wi-Fi chip is configured to receive and send wireless network data. To reduce battery consumption, when the photography device is in a standby state, the camera chip is usually in a power-off state, and the Wi-Fi chip is usually in a working state. When the photography device changes from the standby state to the working state, the camera chip is in a power-on state, namely, the working state. To improve transmission efficiency between the photography device and a terminal device, a peer to peer (P2P) channel may be established between the photography device and the terminal device. However, when the P2P channel is created, a P2P hole punching process can be started only after a service processing unit is powered on, and the P2P hole punching process is complex. The service processing unit can perform data transmission with the terminal device only after hole punching succeeds. Consequently, timeliness of data transmission is affected. SUMMARY Embodiments of this application provide a communication method and apparatus, to resolve a problem that timeliness of data transmission is affected because a communication channel is not established in time. According to a first aspect, an embodiment of this application provides a communication method, applied to a first communication apparatus powered by a battery, where the first communication apparatus includes a service processing unit and a wireless communication unit. The method includes: Before the service processing unit enters a working mode, the wireless communication unit establishes a transmission channel with a second communication apparatus. After the service processing unit enters the working mode, the service processing unit exchanges data with the second communication apparatus through the transmission channel, for example, sends a to-be-sent first network data packet to the second communication apparatus. According to the foregoing solution, before the service processing unit enters the working mode, the wireless communication unit enables the transmission channel. In this way, after entering the working mode, the service processing unit may directly use (or inherit) the established transmission channel to exchange the data with the second communication apparatus. This avoids wasting time resources compared with triggering a hole punching process after the service processing unit enters the working mode, and ensures timeliness of data transmission. For example, the first communication apparatus may be a terminal device, and the second communication apparatus may be a terminal device or a server. For example, when the second communication apparatus is the terminal device, the transmission channel between the first communication apparatus and the second communication apparatus may be a directly connected transmission channel. In a possible design, when the second communication apparatus is the server, the first communication apparatus and the second communication apparatus create a transmission channel (which may also be referred to as a communication connection), for example, may be a message queuing telemetry transport (MQTT) protocol connection, a constrained application protocol (CoAP) connection, or a transmission control protocol (TCP) connection. In a possible design, the second communication apparatus is the terminal device, and the transmission channel between the first communication apparatus and the second communication apparatus may be a directly connected transmission channel. The transmission channel is a peer-to-peer P2P channel. That the wireless communication unit establishes a transmission channel with a second communication apparatus may be specifically implemented in the following manner: the wireless communication unit establishes the P2P channel with the second communication apparatus through P2P hole punching. In a possible design, before the service processing unit sends the to-be-sent first network data packet to the second communication apparatus through the transmission channel after entering the working mode, the method further includes: The service processing unit sends an occupation notification to the wireless communication unit, where the occupation notification indicates to the service processing unit to occupy the transmission channel. After receiving the occupation notification, the wireless communication unit suspends use of the transmission channel to send a net