Method and device for determining connection state of equipment, chip and storage medium

CN119605311APending Publication Date: 2025-03-11GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280098579.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The existing technology makes it difficult to determine whether the connection between communication devices enters an idle connection state, resulting in communication failure.

Method used

By sending data packets and determining the connection status based on the identification of the data packet, the message queue status and the response message type, it ensures that the results of both communicating parties are consistent.

Benefits of technology

Reduce communication failures caused by inconsistent connection status determination and improve the reliability of the communication system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119605311A_ABST
    Figure CN119605311A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for determining the connection state of equipment, a chip and a storage medium. The method comprises: when a connection is established between a first device and a second device, the first device sending a first data packet to the second device (S510); when a first condition is satisfied, the first device configures the connection between the first device and the second device to an idle connection state (S520), the first condition being associated with one or more of the following information: an identifier of the first data packet; a condition of a message queue of the first device; the first response message is used for indicating the second equipment to confirm to receive the first data packet. In the embodiment of the application, both the first device and the second device can configure the connection of both communication parties to be in the idle connection state according to the first condition, so that the determination results of the first device and the second device are consistent, and the reduction of communication failures caused by inconsistent determination results of the first device and the second device is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Method, device, chip and storage medium for determining the connection status of a device Technical Field

[0001] The present application relates to the field of communication technologies, and more specifically, to a method, apparatus, chip, and storage medium for determining a connection status of a device. Background Art

[0002] Communication devices can transmit data over a connection established between them (e.g., a Bluetooth connection). Later, if neither party has data to send, they can place the connection between them into an idle state. In this idle state, the two parties can send keep-alive messages to each other to maintain the connection. However, how the two parties determine when the connection between them enters the idle state remains a challenge.

[0003] Summary of the Invention

[0004] The present application provides a method, apparatus, chip, and storage medium for determining the connection status of a device. The following describes various aspects of the present application.

[0005] In a first aspect, a method for determining the connection status of a device is provided, comprising: when a connection is established between a first device and a second device, the first device sends a first data packet to the second device; when a first condition is met, the first device configures the connection between the first device and the second device to an idle connection state, the first condition being associated with one or more of the following information: an identifier of the first data packet; a status of a message queue of the first device; and a message type of a first response message, the first response message being used to indicate that the second device confirms receipt of the first data packet.

[0006] In a second aspect, a method for determining the connection status of a device is provided, including: when a connection is established between a first device and a second device, the second device receives a first data packet sent by the first device; when a first condition is met, the second device configures the connection between the first device and the second device to an idle connection state, and the first condition is associated with one or more of the following information: an identifier of the first data packet; a status of a message queue of the second device; and a message type of a first response message, wherein the first response message is used to indicate that the second device confirms receipt of the first data packet.

[0007] According to a third aspect, a device for determining the connection status of a device is provided, wherein the device is configured on a first device, and comprises: a first sending module for sending a first data packet to the second device when a connection is established between the first device and the second device; a configuration module for configuring the connection between the first device and the second device to an idle connection state when a first condition is met, wherein the first condition is associated with one or more of the following information: an identifier of the first data packet; a status of a message queue of the first device; and a message type of a first response message, wherein the first response message is used to indicate that the second device confirms receipt of the first data packet.

[0008] In a fourth aspect, a device for determining the connection status of a device is provided, which is configured on a second device, and includes: a first receiving module, used to receive a first data packet sent by the first device when a connection is established between the first device and the second device; a configuration module, used to configure the connection between the first device and the second device to an idle connection state when a first condition is met, and the first condition is associated with one or more of the following information: an identifier of the first data packet; the status of the message queue of the second device; and a message type of a first response message, wherein the first response message is used to indicate that the second device confirms receipt of the first data packet.

[0009] In a fifth aspect, a communication device is provided, comprising a processor, a memory, and a communication interface, wherein the memory is used to store one or more computer programs, and the processor is used to call the computer program in the memory so that the communication device executes part or all of the steps in the methods of the first aspect to the second aspect.

[0010] In a sixth aspect, an embodiment of the present application provides a communication system, which includes the first device and / or the second device described above. In another possible design, the system may also include other devices that interact with the first device or the second device in the solution provided in the embodiment of the present application.

[0011] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a communication device to execute part or all of the steps in the methods of the above aspects.

[0012] In an eighth aspect, embodiments of the present application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a communication device to perform some or all of the steps of the methods described in each of the above aspects. In some implementations, the computer program product may be a software installation package.

[0013] In a ninth aspect, an embodiment of the present application provides a chip comprising a memory and a processor, wherein the processor can call and run a computer program from the memory to implement some or all of the steps described in the methods of the above aspects.

[0014] In an embodiment of the present application, the first device and the second device can both configure the connection between the communicating parties (i.e., the first device and the second device) to an idle connection state according to the first condition, so that the results determined by the first device and the second device are consistent, which is conducive to reducing communication failures caused by inconsistent results determined by the first device and the second device. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] FIG1 is a diagram illustrating an example of a system architecture of a wireless communication system to which an embodiment of the present application may be applied.

[0016] Figure 2 is an example diagram of the BLE protocol stack.

[0017] FIG3 is a diagram showing an example of a PDU message structure.

[0018] FIG4 is an example diagram of communication between a GATT client and a GATT server based on a receive window.

[0019] FIG5 is a flowchart of a method for determining a connection status of a device provided in an embodiment of the present application.

[0020] FIG6 is a flowchart of a method for determining a connection status of a device provided in another embodiment of the present application.

[0021] FIG7 is a flowchart of a method for determining the connection status of a device provided in yet another embodiment of the present application.

[0022] FIG8 is a flowchart of a method for determining the connection status of a device provided in yet another embodiment of the present application.

[0023] FIG9 is a schematic structural diagram of an apparatus for determining a connection status of a device provided in an embodiment of the present application.

[0024] FIG10 is a schematic structural diagram of an apparatus for determining a connection status of a device provided in another embodiment of the present application.

[0025] FIG11 is a schematic structural diagram of a communication device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] Communication system architecture

[0027] The technical solutions provided in the embodiments of the present application can be applied to various communication systems, such as: fifth generation (5G) system or new radio (NR) system, long term evolution (LTE) system, LTE frequency division duplex (FDD) system, LTE time division duplex (TDD) system, LTE on unlicensed spectrum (LTE-U) system, NR on unlicensed spectrum (NR-based access to unlicensed spectrum, NR-U) system, non-terrestrial networks (NTN) system, universal mobile telecommunication system (UMTS), wireless local area network (WLAN) system, Bluetooth system, wireless fidelity (Wi-Fi) system, etc. The technical solutions provided in the present application can also be applied to future communication systems, such as sixth generation mobile communication systems, satellite communication systems, and so on. Below, in conjunction with Figure 1, an exemplary description of the wireless communication system to which the embodiments of the present application can be applied is given.

[0028] FIG1 is an example diagram of the architecture of a wireless communication system 100 applicable to an embodiment of the present application. As shown in FIG1 , the wireless communication system 100 may include a first device 110 and a second device 120. The first device 110 and the second device 120 both have a wireless connection function. The wireless connection may be, for example, a Bluetooth low energy (BLE) connection, a classic Bluetooth connection, a Wi-Fi connection, a point-to-point (P2P) connection, a Thread connection, or the like.

[0029] The technical solution provided in the embodiments of the present application can be applied to a scenario in which a wireless communication connection is established between the first device 110 and the second device 120.

[0030] FIG1 exemplarily shows a first device 110 and a second device 120, but the embodiments of the present application are not limited thereto. Optionally, the wireless communication system 100 may include multiple first devices and / or second devices. For example, a first device may maintain a connection with multiple second devices simultaneously to communicate with the multiple second devices simultaneously, for example, the first device may simultaneously transmit data to multiple second devices.

[0031] In some embodiments, the first device 110 and the second device 120 can be divided into a client and a server (or service node) from a logical functional perspective. The client can, for example, control the server through a connection between the client and the server, or exchange data with the server through a connection between the client and the server. In the embodiment of the present application, the first device 110 can be a client or a server, and correspondingly, the second device 120 can be a server or a client, which is not limited in the embodiment of the present application.

[0032] In some embodiments, the first device and the second device in the embodiments of the present application may be referred to as a first terminal device and a second terminal device, respectively. The terminal device may also be referred to as user equipment (UE), access terminal, subscriber unit, subscriber station, mobile station, mobile station (MS), mobile terminal (MT), remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device.

[0033] The first device and the second device in the embodiments of the present application may be devices that provide voice and / or data connectivity to users and can be used to connect people, objects, and machines, such as handheld devices and vehicle-mounted devices with wireless connection functions. For example, the first device and the second device in the embodiments of the present application may be mobile phones, tablet computers, laptop computers, PDAs, mobile internet devices (MIDs), wearable devices, Internet of Things devices, virtual reality (VR) devices, augmented reality (AR) devices, etc.

[0034] As an example and not a limitation, in an embodiment of the present application, the first device and / or the second device may be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are fully functional, large in size, and can achieve complete or partial functions without relying on smartphones, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

[0035] By way of example and not limitation, in the embodiments of the present application, the first device and / or the second device may be an IoT device. In some embodiments, the IoT device may be a smart home device, such as a smart air conditioner, a smart refrigerator, a washing machine, an electric rice cooker, a robot vacuum, or the like. In some embodiments, the IoT device may be a smart monitoring device, such as a surveillance camera, a temperature sensor, a sound sensor, or the like, although this embodiment of the present application does not specifically limit this.

[0036] In the embodiments of the present application, there is no limitation on the scenarios in which the first device and the second device are located. For example, the first device and the second device can be deployed on land, including indoors or outdoors, handheld or vehicle-mounted.

[0037] It should be understood that all or part of the functions of the communication device in this application can also be implemented through software functions running on hardware, or through virtualization functions instantiated on a platform (such as a cloud platform).

[0038] For ease of understanding, some relevant technical knowledge involved in the embodiments of this application is first introduced. The following related technologies can be combined with the technical solutions of the embodiments of this application as optional solutions, and they all fall within the scope of protection of the embodiments of this application. The embodiments of this application include at least part of the following contents.

[0039] Protocol Stack

[0040] A protocol stack can be understood as a unit or module that processes data using a protocol. Data generated by the protocol stack is processed by lower layers before being transmitted. For example, data from the application layer may be processed by the transport layer before being transmitted. In some embodiments, a protocol stack can also be simply understood as a unit or module within a communication device that processes data using a protocol.

[0041] Taking the BLE protocol stack as an example, Figure 2 shows a schematic diagram of the BLE protocol stack. As shown in Figure 2, the BLE protocol stack includes at least the application layer, the BLE message transport protocol (BMTP) layer, and the generic attribute profile (GATT) layer.

[0042] In some embodiments, the BMTP layer can be understood as a reliable, connection-oriented data transmission layer similar to TCP provided by the Bluetooth transport protocol (BTP) on top of the GATT layer. The BMTP layer can be called an intermediate layer between the application layer and the GATT layer.

[0043] For the sender of the message, the message of the application layer needs to be passed to the lower GATT layer for sending, that is, the service data unit (SDU) of the application layer needs to be sent through the protocol data unit (PDU) of the GATT layer.

[0044] In some embodiments, when application layer data needs to be transmitted over the GATT layer, the application layer SDU needs to be decomposed into one or more GATT PDUs for transmission, as the size of the SDU packet may be greater than or equal to the size of the PDU packet. In this case, BMTP can decompose (or split) a single SDU packet into multiple PDU packets.

[0045] In some embodiments, after an SDU data packet is decomposed into multiple PDU data packets, each PDU data packet can be understood as a segment of the SDU data packet.

[0046] PDU message structure

[0047] Figure 3 shows an example of the PDU message format. As shown in Figure 3, a PDU message consists of an 8-bit header and one or more optional fields. The following is an example description of each field in the PDU message.

[0048] H bit: H represents the handshake bit and can be set to "0" for a normal PDU data packet. When this bit is set, it can indicate a BTP handshake message for establishing a session. In some embodiments, the BTP handshake message for establishing a session can have different message formats.

[0049] M bit: M represents the management message bit and can be used to indicate whether the Management Opcode field exists. For example, a 1 in the M bit indicates the presence of the Management Opcode field, while a 0 in the M bit indicates the absence of the Management Opcode field. It should be understood that for multiple PDU packets corresponding to an SDU packet (i.e., multiple PDU packets derived from decomposing an SDU packet), this bit should be set to the same value for each PDU packet. In other words, all segments of an SDU packet should have this bit set to the same value.

[0050] A bit: A represents the acknowledgement bit, which can be used to indicate whether the PDU data packet is a response message. In some embodiments, to ensure the reliability of message transmission, this bit can always be set to true, or always set to 1 to indicate that a response message is required.

[0051] B bit: B represents the beginning segment bit. In some embodiments, when this bit is set to 1, it indicates that the PDU packet is the first segment (beginning segment) of the SDU packet. When it is set to 0, it indicates that the PDU packet is a segment other than the first segment of the SDU packet, for example, the second segment, an intermediate segment, or the last segment. In other words, if the SDU packet is decomposed into multiple PDU packets, a 1 bit can indicate that the PDU packet is the first of the multiple PDU packets.

[0052] E bit: E stands for the ending segment bit. In some embodiments, when this bit is set to 1, it indicates that the PDU packet is the last segment (ending segment) of the SDU packet. When it is set to 0, it indicates that the PDU packet is a segment other than the last segment of the SDU packet, for example, the first segment, the second segment, or other intermediate segments. In other words, if the SDU packet is decomposed into multiple PDU packets, a 1 bit can indicate that the PDU packet is the last one of the multiple PDU packets.

[0053] Packet sequence number: The packet sequence number can be used to identify different packets. All PDU packets (BTP messages) should be sent with the packet sequence number, regardless of whether they contain SDU segments (for example, acknowledgment packets may not have additional segment payloads).

[0054] In some embodiments, the packet sequence number may be defined as an unsigned 8-bit integer value that monotonically increases by 1 for each packet sent by the packet sender and wraps around to 0 when the value exceeds 255.

[0055] In some embodiments, after a connection is established between communication devices through handshake, the data packet sequence number of the first data packet sent by the data packet sender starts from 0.

[0056] In some embodiments, packet sequence numbers should be defined separately for both communicating parties. For example, the first PDU packet sent by a client device (e.g., the first device) after completing a BTP session handshake has a packet sequence number of 0, and the packet sequence numbers of subsequent PDU packets sent by the client are incremented by 1. The PDU packet corresponding to the handshake response sent by a server device (e.g., the second device) has a packet sequence number of 0, and the packet sequence numbers of subsequent PDU packets sent by the server are incremented by 1.

[0057] Acknowledgement number (Ack number): The acknowledgment number can be used to indicate whether the data packet associated with the data packet sequence number has been received. For example, if the value of the acknowledgment number field in the PDU data packet sent by the client device to the server device is 1, it means that the client device has confirmed receipt of the data packet with data packet sequence number 1 sent by the server device.

[0058] It should be noted that the purpose of both the packet sequence number and the acknowledgment sequence number is to support the receive window of both communicating parties. The receive window of both communicating parties is introduced below.

[0059] receive window

[0060] Due to the design limitations of the chip, the processing power of the processor is limited. Therefore, in some scenarios (for example, BLE transmission scenarios), a receiving window can be defined for each communicating party in units of PDU. The purpose of this receiving window is to enable flow control at the session layer for both communicating parties. The size of the receiving window can indicate the number of PDU data packets that the communication device can reliably receive and store without confirmation from the session layer. For example, when the size of the receiving window corresponding to the first device is 4, it means that the first device can receive up to 4 PDU data packets without confirmation from the session layer. In some embodiments, the size of the receiving window can be represented by a slot. For example, if the size of the receiving window corresponding to the first device is 4 slots, the first device can receive up to 4 PDU data packets.

[0061] In some embodiments, the slot of the receiving window may use a data packet sequence number to indicate that the communication device has received the data packet associated with the data packet sequence number.

[0062] In some embodiments, both communicating parties can use a counter to reflect the current receive window size. When the communication device writes a data packet, the counter decreases, and when the packet sent by the communication device is acknowledged, the counter increases.

[0063] The following takes the establishment of a BLE connection between a first device and a second device (ie, the first device and the second device are a GATT client and a GATT server, respectively) as an example to introduce the receiving window.

[0064] Figure 4 shows an example of a GATT client and a GATT server communicating based on a receive window. As shown in Figure 4, when a BLE connection is established between the GATT client and the GATT server, the GATT client and the GATT server can communicate.

[0065] Specifically, the GATT client may send a first message to the GATT server, where the data packet sequence number of the first message is 0. After receiving the first message, the GATT server updates the receiving window corresponding to the GATT server and places the identifier of the data packet sequence number 0 into the receiving window.

[0066] The GATT client may send a second message, and the data packet sequence number of the second message is 1. After receiving the second message, the GATT server places the corresponding identifier of the data packet sequence number 1 into the receiving window.

[0067] The GATT server detects that only two slots remain in the current receive window. Therefore, the GATT server can send a stand-alone ACK message to the GATT client. The ACK sequence number in this stand-alone ACK message is the packet sequence number of the most recently received message. For example, if the most recently received message is the second message, and its corresponding packet sequence number is 1, the ACK sequence number in this stand-alone ACK message should be 1. As a specific example, the packet sequence number of this stand-alone ACK message is 1, and the ACK sequence number is 1.

[0068] When the GATT server sends a standalone response message to the GATT client, the GATT server clears the receive window on the GATT server side. After receiving the standalone response message, the GATT client updates the receive window on the GATT client side.

[0069] The GATT client then sends the last of the multiple PDU packets decomposed from the SDU packet. This packet has a sequence number of 2 and an acknowledgment number of 1. This acknowledgment number is the sequence number of the independent response message sent by the GATT server to the GATT client in the previous step, indicating that the independent response message from the previous GATT server has been received. Similarly, upon receiving the message, the GATT server updates its corresponding receive window. After the GATT server determines that this is the last PDU packet, it reassembles the packet and sends it to the application layer.

[0070] When the send-acknowledgement timer of the GATT server expires, it sends a standalone acknowledgment message to the GATT client. After receiving the standalone acknowledgment message, the GATT client also processes its receive window.

[0071] Afterwards, if neither party has data to send, the two parties can put the connection between the communication devices into an idle state. In the idle state, the two parties can also send keep-alive messages (e.g., independent response messages) to each other to maintain the connection. The keep-alive messages still need to meet the above requirements of the receive window.

[0072] However, how the communicating parties determine whether the connection between the communication devices enters the idle connection state is a problem that needs to be solved. If the communicating parties disagree on whether the connection enters the idle connection state, the communication between the communicating parties may fail.

[0073] To solve the above problems, the present invention provides a method, apparatus, chip, and storage medium for determining the connection status of a device. The method for determining the connection status of a device provided by the present invention is described in detail below with reference to the accompanying drawings.

[0074] Figure 5 is a flow chart of a method for determining a device connection status according to an embodiment of the present application. The method shown in Figure 5 is described from the perspective of interaction between a first device and a second device, which may be, for example, the first device 110 and the second device 120 shown in Figure 1 , respectively.

[0075] The method of FIG5 may include step S510 and step S520, which are described in detail below.

[0076] In step S510, when a connection is established between a first device and a second device, the first device sends a first data packet to the second device.

[0077] The embodiment of the present application does not specifically limit the type of connection between the first device and the second device. For example, the communication between the first device and the second device can be short-range communication, and the connection between them can be a connection method supported by short-range communication. For example, the connection type between the first device and the second device can be a Bluetooth connection (e.g., a BLE connection, a classic Bluetooth connection), a Wi-Fi connection, a Thread connection, etc.

[0078] In an embodiment of the present application, the first device is the transmitter of the first data packet, and the second device is the receiver of the first data packet. In terms of logical function division, the first device can be a client or a server; correspondingly, the second device can be a server or a client. In other words, if the first device is a client, the second device is a server; if the first device is a server, the second device is a client. Taking the BLE connection between the first device and the second device as an example, the first device can be understood as a GATT client, and the second device can be understood as a GATT server; alternatively, the first device can also be understood as a GATT server, and the second device can be understood as a GATT client.

[0079] In some embodiments, the first data packet refers to a PDU data packet. The first data packet may be one of multiple PDU data packets obtained by decomposing an SDU data packet, for example, the first data packet among the multiple PDU data packets obtained by decomposing an SDU data packet, or the second, third, etc. intermediate data packet among the multiple PDU data packets, or the last data packet among the multiple PDU data packets, which is not limited in the embodiments of the present application.

[0080] In some embodiments, the multiple PDU data packets obtained by decomposing the SDU data packet may also be referred to as a packet sequence, and the first data packet may be any data packet in the packet sequence.

[0081] In step S520, when a first condition is met, the first device configures the connection between the first device and the second device to an idle connection state.

[0082] The idle connection state can be understood as a connection maintained between the first device and the second device, and the connection is currently in an idle state, that is, the first device and the second device will not transmit a large amount of data in the idle connection state, and may only transmit keep-alive signaling to maintain the connection between the first device and the second device. In other words, the idle connection state can be understood as when the communicating parties (the first device and the second device) have no data to send, keep-alive messages will still be exchanged in each send confirmation interval. Taking the BLE connection between the first device and the second device as an example, when either party in the BTP session has no data to send, BTP messages will still be exchanged in each send confirmation interval.

[0083] Each time the first device sends a PDU data packet, it can determine whether the connection between the first device and the second device has entered an idle connection state based on the first condition. If it is determined that the connection between the first device and the second device has entered an idle connection state, the connection between the first device and the second device can be configured (or set, configured, etc.) to be in an idle connection state; otherwise, the connection between the first device and the second device can be considered to be in a connected state. In some embodiments, when the connection between the first device and the second device is in a connected state, it can be considered that there are still PDU data packets obtained by decomposing the SDU to be transmitted between the first device and the second device.

[0084] As an implementation method, the first device determines whether the connection between the first device and the second device enters an idle connection state based on the first condition, which may mean that the first device can determine whether the first condition is met, and if the first condition is met, the first device can configure the connection between the first device and the second device to an idle connection state.

[0085] The first condition may be associated with one or more types of information, which is not limited in the present embodiment. For example, the first condition may be associated with one or more types of the following information.

[0086] Information 1: Identification of the first data packet

[0087] In some embodiments, the identifier of the first data packet can be used to indicate the position of the first data packet in a packet sequence (i.e., multiple PDU data packets obtained by decomposing an SDU data packet). For example, the identifier of the first data packet can be used to indicate whether the first data packet is the first, second, or last of the multiple PDU data packets.

[0088] In some embodiments, the identifier of the first data packet may refer to the ending segment bit of the first data packet, which is used to identify whether the first data packet is the last of multiple PDU data packets. Taking the message structure of the PDU shown in Figure 2 as an example, referring to Figure 2, the identifier of the first data packet may refer to the E bit. When this bit is set to 1, it can indicate that the first data packet is the last of multiple PDU data packets. When this bit is set to 0, it can indicate that the first data packet is the first or one of the middle PDU data packets.

[0089] However, the embodiment of the present application is not limited thereto, and the identifier of the first data packet may also include other identifiers, such as the data packet serial number of the first data packet and other identifiers.

[0090] Information 2: Status of the message queue of the first device

[0091] Considering that message queues have the characteristics of transmitting messages of different lengths and message boundaries do not need to be managed by users, message queues can be used to communicate between tasks in some embedded devices. In the embodiment of the present application, the first device and the second device can communicate using message queues.

[0092] In some embodiments, the message queue of the first device may contain one or more messages to be sent. In some embodiments, the message queue of the first device may contain no messages to be sent.

[0093] Information 3: Message type of the first response message

[0094] Considering both the reliability of message transmission and the limited receive window, some communication systems can use acknowledgment messages to ensure both the reliability of message transmission and the availability of the receive window. To this end, after a first device sends a first data packet to a second device, the second device can send a first acknowledgment message to the first device. This first acknowledgment message indicates that the second device has acknowledged receipt of the first data packet.

[0095] The first response message may include multiple message types. For example, the first response message may include a stand-alone ACK message and a piggyback ACK message.

[0096] A standalone acknowledgment message is one that may contain only an ACK packet, without other data or payload. For example, a BTP packet between a first device and a second device may contain only an ACK packet, without other data or payload (a stand-alone ack—that is, a BTP packet that contains a packet receipt acknowledgement value but no buffer segment payload). In some embodiments, after a first device sends a first data packet to a second device, the second device may send a standalone acknowledgment message to the first device to indicate that the second device has received the first data packet.

[0097] In some embodiments, the independent response message can also be understood as a PDU data packet. The message structure of the PDU corresponding to the independent response message may only include an 8-bit header, an optional field [data packet sequence number] and an optional field [confirmation sequence number], but not a payload.

[0098] Piggybacking an ACK message can be understood as merging an ACK packet into other packets and sending them together. In other words, if the party sending the ACK packet needs to send other packets for other purposes, the ACK packet can be merged into the other packet and sent to the other party in the communication. For example, after a first device sends a first packet to a second device, the second device itself needs to send a second packet to the first device. The second device can merge the ACK packet corresponding to the first ACK message into the second packet and send them together to the first device.

[0099] Correspondingly, after receiving the first data packet, the second device can also determine whether the connection between the first device and the second device has entered an idle connection state based on the first condition. When the second device determines whether the connection between the first device and the second device has entered an idle connection state based on the first condition, the first condition may include one or more of the following information: the identifier of the first data packet, the status of the message queue of the second device, and the message type of the first response message. This information is similar to the reference information determined by the first device. For a detailed description of this information, please refer to the description of information 1 to information 3 above and will not be repeated here.

[0100] In an embodiment of the present application, the first device and the second device can both determine that the connection between the communicating parties (i.e., the first device and the second device) enters an idle connection state based on the first condition, so that the results determined by the first device and the second device are consistent, which is conducive to reducing communication failures caused by inconsistent results determined by the first device and the second device.

[0101] In some embodiments, the first condition may include one or more of the following conditions.

[0102] Condition 1: The identifier of the first data packet indicates that the first data packet is the last of multiple PDU data packets, or in other words, the identifier of the first data packet indicates that the first data packet is the last of a subpacket sequence, wherein the multiple PDU data packets or subpacket sequence are decomposed from the first SDU data packet. The first SDU data packet can be understood as any SDU data packet corresponding to the application layer of the first device, and the first device needs to send the first SDU data packet to the second device after processing by the lower layer.

[0103] If the first data packet is the last of multiple PDU data packets, it means that after the first data packet is sent, the first SDU data packet is sent, and the first device may not transmit a large amount of data to the second device for a short period of time. In this case, to save energy, the connection between the first device and the second device can be set to an idle connection state.

[0104] Condition 2: There are no pending messages in the first device's message queue. If there are no pending messages in the first device's message queue, this means the first device has no data to send to the second device at the current time. In this case, to save energy, the connection between the first and second devices can be set to an idle state.

[0105] Condition 3: The message type of the first response message is a standalone response message. If the message type of the first response message is a standalone response message, this means that the second device currently has no data to send to the first device. In this case, to save energy, the connection between the first and second devices can be set to an idle connection state.

[0106] It should be understood that in the embodiments of the present application, the first condition may include any one or more of the above conditions. For example, the first condition may only include condition 1, that is, as long as the first device determines that the first data packet is the last one of multiple PDU data packets, the first device can configure the connection between the first device and the second device to an idle connection state. Alternatively, the first condition may include condition 1 and condition 2, that is, the first device determines that the first data packet is the last one of multiple PDU data packets, and the first device itself has no other messages that need to be sent to the second device, then the first device can configure the connection between the first device and the second device to an idle connection state. Alternatively, the first condition may include condition 1, condition 2 and condition 3, that is, when the first device itself has no messages that need to be sent to the second device, and the second device has no need to send messages to the first device, the first device can configure the connection between the first device and the second device to an idle connection state. For a more detailed description, please refer to Examples 1 to 3 below.

[0107] In some embodiments, the first device side may correspond to a timer for sending a response message and a timer for receiving a response message, respectively, to indicate the time interval at which the first device expects to send a response message and the time interval at which the first device expects to receive a response message.

[0108] Specifically, after the first device sends a message, it can start a timer for receiving a reply message to indicate that the first device expects to receive a reply message to the message within the time interval corresponding to the timer. After the first device receives a message, it can start a timer for sending a reply message to indicate that the first device expects to send a reply message to the message within the time interval corresponding to the timer.

[0109] Correspondingly, the second device side may also correspond to a timer for sending a response message and a timer for receiving a response message.

[0110] In some embodiments, the time interval of the timer for sending the reply message corresponding to the reply message sender may be equal to the time interval of the timer for receiving the reply message corresponding to the reply message receiver, so as to ensure that the reply message receiver can receive the reply message within the expected time. However, the embodiments of the present application are not limited to this. In some embodiments, the time interval of the timer for sending the reply message corresponding to the reply message sender may be less than the time interval of the timer for receiving the reply message corresponding to the reply message receiver, which can also ensure that the reply message receiver can receive the reply message within the expected time.

[0111] In some embodiments, after the connection between the first device and the second device enters an idle connection state, the first device and the second device may sequentially send keep-alive signaling to each other, where the keep-alive signaling is used to maintain the connection between the first device and the second device. Optionally, the keep-alive signaling may be a response message, such as an independent response message.

[0112] In some embodiments, after the connection between the first device and the second device enters the idle connection state, the time intervals corresponding to the timers corresponding to the first device and the second device (including the timer for sending a response message and the timer for receiving a response message) can be set larger to reduce power consumption.

[0113] As an implementation method, taking the timer for receiving a response message of the first device as an example, assuming that before the connection between the first device and the second device enters the idle connection state, the time interval of the timer for receiving a response message of the first device is set to the first time interval, then after the connection between the first device and the second device enters the idle connection state, the time interval of the timer for receiving a response message of the first device can be set to the second time interval, wherein the second time interval is greater than the first time interval, for example, the second time interval can be N (N ≥ 2) times the first time interval. In some embodiments, N can be a positive integer. Correspondingly, the timer for sending a response message of the second device can also be set to a larger value, for example, to the second time interval.

[0114] Regarding the implementation method of setting the time interval of the timer for sending a response message of the first device and the timer for receiving a response message of the second device, you can refer to the implementation method of the time interval of the timer for receiving a response message of the first device and the timer for sending a response message of the second device, which will not be repeated here.

[0115] In some embodiments, if the second device receives the first data packet sent by the first device and determines that the first data packet is the last of multiple PDU data packets, the second device can reassemble the multiple PDU data packets into SDU data packets and send them to the application layer of the second device.

[0116] The following describes the implementation process of the technical solution of the present application in conjunction with several specific embodiments. It should be understood that the steps listed in the following embodiments are for illustrative purposes only and are not intended to limit the order in which all steps must be performed. In other words, some of the steps listed in the following embodiments may not be performed; or the order in which some steps are performed may be swapped, or some steps may be performed simultaneously, and this application does not limit this.

[0117] Example 1:

[0118] FIG6 is a flow chart of a method for determining the connection status of a device according to another embodiment of the present application. As shown in FIG6 , the method may include steps S610 to S680. These steps are described below.

[0119] In step S610, the first device sends a first data packet to the second device. The first data packet is the last one of multiple PDU data packets obtained by decomposing an SDU data packet.

[0120] In step S620, the first device starts a first timer, where the first timer is used to indicate a time interval at which the first device expects to receive a first response message.

[0121] The timing duration of the first timer is equal to the first time interval, that is, the first device expects to receive the first response message within the first time interval.

[0122] In step S630, after receiving the first data packet sent by the first device, the second device, when determining that the first data packet is the last one of multiple PDU data packets, reassembles the multiple data packets and reports them to the application layer of the second device.

[0123] In step S640, the second device starts a first timer, which is used to indicate the time interval at which the second device expects to send the first response message. In some embodiments, the timing duration of the first timer is equal to the first time interval. In some embodiments, the timing duration of the first timer can be less than the first time interval.

[0124] In step S650, the second device sends a first response message to the first device. The first response message is sent within a first time interval.

[0125] In some embodiments, the first response message may be an independent response message. If the first response message is an independent response message, it can be considered that the second device has no other data to send to the first device, that is, there are no other messages in the message queue of the second device.

[0126] In some embodiments, if there are no other messages in the message queue of the second device and a first timer corresponding to the second device expires, the second device sends an independent response message to the first device when the first timer expires.

[0127] In step S660, when the second device determines that there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to an idle connection state.

[0128] Furthermore, after the second device configures the connection between the first device and the second device to be in an idle connection state, the second device may also start a second timer. The second timer is used to indicate a time interval at which the second device expects to receive keep-alive messages.

[0129] The keep-alive message can be used to maintain the connection between the first device and the second device. For example, the keep-alive message can be an independent response message. In some embodiments, the keep-alive message can also be called keep-alive signaling. That is, after the second device sends the first response message to the first device, the second device can start a second timer to limit the receipt of the keep-alive message sent by the first device within the time interval corresponding to the second timer. In some embodiments, the keep-alive message can refer to the second response message sent by the first device to the second device, and the second response message is used to indicate that the first device has received the first response message. In some embodiments, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval. For example, the second time interval can be N times (such as 2 times, 2.5 times, etc.) of the first time interval. The second time interval refers to the timing duration of the timer set after the second device configures the connection between the first device and the second device to the idle connection state, and the first time interval refers to the timing duration of the timer set before the second device configures the connection between the first device and the second device to the idle connection state.

[0130] In some embodiments, the second timer can be the same timer as the first timer, which is not limited in the embodiments of the present application. It should be understood that when the second timer and the first timer are the same timer, the time interval setting value (i.e., the second time interval) of the timer after the connection between the first device and the second device is configured as an idle connection state can be greater than the time interval setting value (i.e., the first time interval) before the connection is configured as the idle connection state.

[0131] In step S670, after the first device receives the first response message sent by the second device, if it is confirmed that the first response message is an independent response message and there is no message to be sent in the message queue of the first device, the first device can configure the connection between the first device and the second device to an idle connection state.

[0132] In step S680, the first device starts a second timer, where the second timer is used to indicate a time interval at which the first device expects to send a keep-alive message, for example, a time interval for sending a second response message.

[0133] In some embodiments, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval. For example, the second time interval may be twice the first time interval.

[0134] At this point, the connection between the first device and the second device enters an idle connection state. The first device and the second device can send keep-alive messages to each other at a time interval corresponding to a timer after entering the idle connection state to keep the connection alive.

[0135] Example 2:

[0136] Compared with Example 1, the technical solution provided in Example 2 determines that the connection between the first device and the second device enters the idle connection state through two rounds of response messages (for example, two rounds of independent response messages), which is more reliable.

[0137] FIG7 is a flow chart of a method for determining the connection status of a device according to another embodiment of the present application. As shown in FIG7 , the method may include steps S701 to S711. These steps are described below.

[0138] In step S701, a first device sends a first data packet to a second device. The first data packet is the last one of multiple PDU data packets obtained by decomposing an SDU data packet.

[0139] In step S702, the first device starts a first timer, where the first timer is used to indicate a time interval at which the first device expects to receive a first response message.

[0140] The timing duration of the first timer is equal to the first time interval, that is, the first device expects to receive the first response message within the first time interval.

[0141] In step S703, after receiving the first data packet sent by the first device, the second device, if determining that the first data packet is the last one of multiple PDU data packets, reassembles the multiple data packets and reports them to the application layer of the second device.

[0142] In step S704, the second device starts a first timer, which is used to indicate the time interval at which the second device expects to send the first response message. In some embodiments, the timing duration of the first timer is equal to the first time interval. In some embodiments, the timing duration of the first timer can be less than the first time interval.

[0143] In step S705, the second device sends a first response message to the first device. The first response message is sent within a first time interval.

[0144] In some embodiments, the first response message may be an independent response message.In some embodiments, the first response message is sent by the second device to the first device when the first timer expires.

[0145] In some embodiments, after receiving the first response message, the first device may start a timer for sending a response message, where the timer indicates the time interval at which the first device expects to send a second response message, and the second response message indicates that the first device confirms receipt of the first response message.

[0146] In some embodiments, the time interval corresponding to the timer for sending the response message may be a first time interval.

[0147] In step S706, when the second device determines that there is no message to be sent in the message queue of the second device, the second device starts a second timer, which is used to indicate a time interval at which the second device expects to receive a second response message.

[0148] In some embodiments, the timing duration of the second timer is equal to the first time interval, where the first time interval refers to the timing duration of the timer set before the second device configures the connection between the first device and the second device to an idle connection state.

[0149] In step S707, the first device sends a second response message to the second device. The first response message is sent within the first time interval.

[0150] In some embodiments, the second response message may be an independent response message.In some embodiments, the second response message is sent by the first device to the second device when a timer for sending the second response message expires.

[0151] In step S708, when the first device determines that there is no message to be sent in the message queue of the first device, the first device configures the connection between the first device and the second device to an idle connection state.

[0152] In step S709, the first device starts a third timer. The third timer is used to indicate a time interval at which the first device expects to receive a keep-alive message.

[0153] The keep-alive message is used to maintain the connection between the first device and the second device. That is, after the first device sends the second response message to the second device, the first device may start a third timer to limit the time interval corresponding to the third timer to receive the keep-alive message sent by the second device. For example, the keep-alive message may be a third response message, which indicates that the second device has received the second response message.

[0154] In some embodiments, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval. For example, the third time interval may be N times the first time interval. The third time interval refers to the timing duration of the timer set after the first device configures the connection between the first device and the second device to an idle connection state, and the first time interval refers to the timing duration of the timer set before the first device configures the connection between the first device and the second device to an idle connection state.

[0155] In some embodiments, the third timer can be the same timer as the first timer, which is not limited in the embodiments of the present application. It should be understood that when the third timer and the first timer are the same timer, the timer may have a set value (i.e., the third time interval) after the connection between the first device and the second device is configured as an idle connection state, which may be greater than the set value (i.e., the first time interval) of the time interval before the connection is configured as an idle connection state.

[0156] In some embodiments, the third time interval may be equal to the second time interval, indicating that for the first device or the second device, the time interval at which it expects to send a response message and the time interval at which it expects to receive a response message are consistent.

[0157] In step S710, when the second device determines that there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to an idle connection state.

[0158] In step S711, the second device starts a third timer, where the third timer is used to indicate a time interval at which the second device expects to send a keep-alive message.

[0159] In some embodiments, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval. For example, the third time interval may be twice the first time interval.

[0160] At this point, the connection between the first device and the second device enters an idle connection state. The first device and the second device can send keep-alive messages to each other at a time interval corresponding to a timer after entering the idle connection state to keep the connection alive.

[0161] Example 3:

[0162] FIG8 is a flow chart of a method for determining the connection status of a device according to another embodiment of the present application. As shown in FIG8 , the method may include steps S810 to S870. These steps are described below.

[0163] In step S810, the first device sends a first data packet to the second device. The first data packet is the last one of multiple PDU data packets obtained by decomposing an SDU data packet.

[0164] In step S820 , the first device checks whether there is a message to be sent in the message queue of the first device.

[0165] In step S830, when there is no message to be sent in the message queue of the first device, the first device configures the connection between the first device and the second device to an idle connection state.

[0166] In step S840, the first device starts a fourth timer, where the fourth timer is used to indicate a time interval at which the first device expects to receive a keep-alive message. For example, the keep-alive message may be a first response message.

[0167] In some embodiments, the timing duration of the fourth timer is equal to the fourth time interval. The fourth time interval is greater than the fifth time interval. For example, the fourth time interval may be N times the fifth time interval. The fourth time interval refers to the timing duration of the timer set after the first device configures the connection between the first device and the second device to an idle connection state, and the fifth time interval refers to the timing duration of the timer set before the first device configures the connection between the first device and the second device to an idle connection state.

[0168] In some embodiments, the fourth timer and the fifth timer may be the same timer, which is not limited in the embodiments of the present application. It should be understood that when the fourth timer and the fifth timer are the same timer, after the connection between the first device and the second device is configured as an idle connection state, the set value of the time interval (i.e., the fourth time interval) may be greater than the set value of the time interval before the connection is configured as the idle connection state (i.e., the fifth time interval).

[0169] In step S850, after receiving the first data packet sent by the first device, the second device, when determining that the first data packet is the last one of multiple PDU data packets, reassembles the multiple data packets and reports them to the application layer of the second device.

[0170] In step S860, the second device sends a first response message to the first device. The first response message is sent within a fourth time interval.

[0171] In some embodiments, the first response message may be an independent response message. In some embodiments, the first response message is sent by the second device to the first device when a timer for sending the first response message expires.

[0172] In step S870, when it is determined that there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to an idle connection state.

[0173] Furthermore, after the second device configures the connection between the first device and the second device to an idle connection state, the second device may also start a fourth timer. The fourth timer is used to indicate the time interval at which the second device expects to receive a keep-alive message. For example, the keep-alive message may be a second response message, which indicates to the first device that it has acknowledged receipt of the first response message.

[0174] In some embodiments, the timing duration of the fourth timer is equal to the fourth time interval, and the fourth time interval is greater than the fifth time interval. For example, the fourth time interval may be twice the fifth time interval. The fourth time interval refers to the timing duration of the timer set after the second device configures the connection between the first device and the second device to an idle connection state, and the fifth time interval refers to the timing duration of the timer set before the second device configures the connection between the first device and the second device to an idle connection state.

[0175] At this point, the connection between the first device and the second device enters an idle connection state. The first device and the second device can send keep-alive messages to each other at a time interval corresponding to a timer after entering the idle connection state to keep the connection alive.

[0176] The method embodiment of the present application is described in detail above in conjunction with Figures 1 to 8 . The device embodiment of the present application is described in detail below in conjunction with Figures 9 to 11 . It should be understood that the description of the method embodiment corresponds to the description of the device embodiment. Therefore, for portions not described in detail, reference can be made to the above method embodiment.

[0177] FIG9 is a schematic diagram of an apparatus for determining a connection status of a device according to an embodiment of the present application. The apparatus 900 shown in FIG9 may include a first sending module 910 and a configuration module 920.

[0178] The first sending module 910 may be configured to send a first data packet to a second device when a connection is established between the first device and the second device.

[0179] The configuration module 920 can be used to configure the connection between the first device and the second device to an idle connection state when a first condition is met, and the first condition is associated with one or more of the following information: an identifier of the first data packet; a status of a message queue of the first device; and a message type of a first response message, wherein the first response message is used to indicate that the second device confirms receipt of the first data packet.

[0180] Optionally, the first condition includes one or more of the following conditions: the identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit PDU data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit SDU data packet; there are no messages to be sent in the message queue of the first device; and the message type of the first response message is an independent response message.

[0181] Optionally, the first data packet is the last of multiple PDU data packets, and the device also includes: a first starting module, used to start a first timer, the first timer is used to indicate the time interval at which the first device expects to receive the first response message, and the timing duration of the first timer is equal to the first time interval; a receiving module, used to receive the first response message sent by the second device, and the first response message is received within the first time interval.

[0182] Optionally, the configuration module is further used to: when the first response message is an independent response message and there is no message to be sent in the message queue of the first device, configure the connection between the first device and the second device to an idle connection state.

[0183] Optionally, the device 900 also includes: a second starting module, used to start a second timer, the second timer is used to indicate the time interval at which the first device expects to send a keep-alive message; wherein the keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

[0184] Optionally, the second time interval is N times the first time interval, where N≥2.

[0185] Optionally, the apparatus 900 further includes: a second sending module, configured to send a second response message to the second device, wherein the second response message is configured to instruct the first device to confirm receipt of the first response message.

[0186] Optionally, the configuration module is further configured to: configure the connection between the first device and the second device to an idle connection state when there is no message to be sent in the message queue of the first device.

[0187] Optionally, the device 900 also includes: a third starting module, used to start a third timer, the third timer is used to indicate the time interval at which the first device expects to receive a keep-alive message; wherein the keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to the third time interval, and the third time interval is greater than the first time interval.

[0188] Optionally, the third time interval is N times the first time interval, where N≥2.

[0189] Optionally, the first data packet is the last of multiple PDU data packets, and the configuration module is further used to: when the first device determines that there are no messages to be sent in the message queue of the first device, configure the connection between the first device and the second device to an idle connection state.

[0190] Optionally, the device 900 also includes: a fourth starting module, used to start a fourth timer, the fourth timer is used to indicate the time interval at which the first device expects to receive a keep-alive message, and the keep-alive message is used to maintain the connection between the first device and the second device; wherein the timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval at which the first device expects to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

[0191] Optionally, the fourth time interval is N times the fifth time interval, where N≥2.

[0192] Optionally, the connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

[0193] FIG10 is a schematic diagram of the structure of an apparatus for determining the connection status of a device according to another embodiment of the present application. The apparatus 1000 shown in FIG10 may include a first receiving module 1010 and a configuration module 1020.

[0194] The first receiving module 1010 may be configured to receive a first data packet sent by the first device when a connection is established between the first device and the second device.

[0195] The configuration module 1020 can be used to configure the connection between the first device and the second device to an idle connection state when a first condition is met, and the first condition is associated with one or more of the following information: an identifier of the first data packet; a status of a message queue of the second device; and a message type of a first response message, wherein the first response message is used to indicate that the second device confirms receipt of the first data packet.

[0196] Optionally, the first condition includes one or more of the following conditions: the identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit PDU data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit SDU data packet; there are no messages to be sent in the message queue of the second device; and the message type of the first response message is an independent response message.

[0197] Optionally, the first data packet is the last of multiple PDU data packets, and the device 1000 also includes: a first starting module, used to start a first timer, the first timer is used to indicate the time interval at which the second device expects to send the first response message, and the timing duration of the first timer is equal to the first time interval; the second device sends the first response message to the first device, and the first response message is sent within the first time interval.

[0198] Optionally, the configuration module is further used to: when the first response message is an independent response message and there is no message to be sent in the message queue of the second device, configure the connection between the first device and the second device to an idle connection state.

[0199] Optionally, the device 1000 also includes: a second starting module, used to start a second timer, the second timer is used to indicate the time interval at which the second device expects to receive a keep-alive message; wherein the keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

[0200] Optionally, the second time interval is N times the first time interval, where N≥2.

[0201] Optionally, the apparatus 1000 further includes: a second receiving module, configured to receive a second response message sent by the first device, wherein the second response message is configured to indicate that the first device confirms receipt of the first response message.

[0202] Optionally, the configuration module is further configured to: configure the connection between the first device and the second device to an idle connection state when there is no message to be sent in the message queue of the second device.

[0203] Optionally, the device 1000 also includes: a third starting module, used to start a third timer, the third timer is used to indicate the time interval at which the second device expects to send a keep-alive message; wherein, the keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to the third time interval, and the third time interval is greater than the first time interval.

[0204] Optionally, the third time interval is N times the first time interval, where N≥2.

[0205] Optionally, the first data packet is the last of multiple PDU data packets, and the configuration module is further used to: configure the connection between the first device and the second device to an idle connection state when the second device determines that there is no message to be sent in the message queue of the second device.

[0206] Optionally, the device 1000 also includes: a fourth starting module, used to start a fourth timer, the fourth timer is used to indicate the time interval for the second device to expect to receive a keep-alive message, and the keep-alive message is used to maintain the connection between the first device and the second device; wherein the timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval for the second device to expect to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

[0207] Optionally, the fourth time interval is N times the fifth time interval, where N≥2.

[0208] Optionally, the connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

[0209] Figure 11 is a schematic block diagram of a communication device according to an embodiment of the present application. The dashed lines in Figure 11 indicate that the unit or module is optional. The device 1100 may be used to implement the method described in the above method embodiment. The device 1100 may be a chip, a terminal device, or a network device.

[0210] The device 1100 may include one or more processors 1110. The processor 1110 may support the device 1100 to implement the method described in the method embodiment above. The processor 1110 may be a general-purpose processor or a special-purpose processor. For example, the processor may be a central processing unit (CPU). Alternatively, the processor may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

[0211] The apparatus 1100 may further include one or more memories 1120. The memories 1120 store programs that can be executed by the processor 1110, causing the processor 1110 to perform the methods described in the above method embodiments. The memories 1120 may be independent of the processor 1110 or integrated into the processor 1110.

[0212] The apparatus 1100 may further include a transceiver 1130. The processor 1110 may communicate with other devices or chips via the transceiver 1130. For example, the processor 1110 may transmit and receive data with other devices or chips via the transceiver 1130.

[0213] The present application also provides a computer-readable storage medium for storing a program. The computer-readable storage medium can be applied to a terminal or network device provided in the present application, and the program enables a computer to execute the method performed by the terminal or network device in each embodiment of the present application.

[0214] The present application also provides a computer program product. The computer program product includes a program. The computer program product can be applied to a terminal or network device provided in the present application, and the program causes a computer to execute the method performed by the terminal or network device in each embodiment of the present application.

[0215] The embodiments of the present application also provide a computer program. The computer program can be applied to the terminal or network device provided in the embodiments of the present application, and the computer program enables a computer to execute the method performed by the terminal or network device in each embodiment of the present application.

[0216] It should be understood that the terms "system" and "network" in this application can be used interchangeably. In addition, the terms used in this application are only used to explain the specific embodiments of this application and are not intended to limit this application. The terms "first", "second", "third", and "fourth" in the specification and claims of this application and the accompanying drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.

[0217] In the embodiments of this application, the term "indication" may refer to a direct indication, an indirect indication, or an indication of an association. For example, "A indicates B" may refer to a direct indication of B, e.g., B can obtain information through A; it may refer to an indirect indication of B, e.g., A indicates C, e.g., B can obtain information through C; or it may refer to an association between A and B.

[0218] In the embodiment of the present application, "B corresponding to A" means that B is associated with A and B can be determined based on A. However, it should be understood that determining B based on A does not mean determining B based solely on A, but B can also be determined based on A and / or other information.

[0219] In the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between the two, or an association relationship between the two, or a relationship between indication and indication, configuration and configuration, etc.

[0220] In the embodiments of the present application, "pre-definition" or "pre-configuration" may be implemented by pre-storing corresponding codes, tables, or other methods that can be used to indicate relevant information in a device (e.g., a terminal device and a network device). The present application does not limit the specific implementation method. For example, pre-definition may refer to information defined in a protocol.

[0221] In the embodiments of the present application, the “protocol” may refer to a standard protocol in the communications field, for example, it may include an LTE protocol, an NR protocol, and related protocols used in future communication systems, and the present application does not limit this.

[0222] In the embodiments of this application, the term "and / or" is simply a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this document generally indicates that the related objects are in an "or" relationship.

[0223] In various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0224] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0225] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0226] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0227] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be read by a computer or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0228] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for determining the connection status of a device, characterized in that: include: When a connection is established between the first device and the second device, the first device sends a first data packet to the second device; When a first condition is met, the first device configures the connection between the first device and the second device to an idle connection state, where the first condition is associated with one or more of the following information: an identifier of the first data packet; Status of the message queue of the first device; as well as The message type of the first response message is used to indicate that the second device confirms receipt of the first data packet.

2. The method according to claim 1, characterized in that The first condition includes one or more of the following conditions: The identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit (PDU) data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit (SDU) data packet; There are no messages to be sent in the message queue of the first device; and The message type of the first response message is an independent response message.

3. The method according to claim 1 or 2, characterized in that The first data packet is the last of the multiple PDU data packets. Before the first device configures the connection between the first device and the second device to an idle connection state, the method further includes: The first device starts a first timer, where the first timer is used to indicate a time interval at which the first device expects to receive the first response message, and a timing duration of the first timer is equal to the first time interval; The first device receives the first response message sent by the second device, where the first response message is received within the first time interval.

4. The method according to claim 3, characterized in that When the first condition is met, the first device configuring the connection between the first device and the second device to an idle connection state includes: When the first response message is an independent response message and there is no message to be sent in the message queue of the first device, the first device configures the connection between the first device and the second device to be in an idle connection state.

5. The method according to claim 3 or 4, characterized in that After the first device configures the connection between the first device and the second device to an idle connection state, the method further includes: The first device starts a second timer, where the second timer is used to indicate a time interval at which the first device expects to send a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

6. The method according to claim 5, characterized in that The second time interval is N times the first time interval, where N≥2.

7. The method according to claim 3, characterized in that After the first device receives the first response message sent by the second device, the method further includes: The first device sends a second response message to the second device, where the second response message is used to indicate that the first device confirms receipt of the first response message.

8. The method according to claim 7, characterized in that When the first condition is met, the first device configuring the connection between the first device and the second device to an idle connection state includes: When there is no message to be sent in the message queue of the first device, the first device configures the connection between the first device and the second device to an idle connection state.

9. The method according to claim 7 or 8, characterized in that After the first device configures the connection between the first device and the second device to an idle connection state, the method further includes: The first device starts a third timer, where the third timer is used to indicate a time interval at which the first device expects to receive a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval.

10. The method according to claim 9, characterized in that The third time interval is N times the first time interval, where N≥2.

11. The method according to claim 1 or 2, characterized in that The first data packet is the last of the multiple PDU data packets, and when the first condition is met, the first device configures the connection between the first device and the second device to an idle connection state, including: When the first device determines that there is no message to be sent in the message queue of the first device, the first device configures the connection between the first device and the second device to be in an idle connection state.

12. The method according to claim 11, characterized in that After the first device configures the connection between the first device and the second device to an idle connection state, the method further includes: The first device starts a fourth timer, where the fourth timer is used to indicate a time interval at which the first device expects to receive a keep-alive message, where the keep-alive message is used to maintain a connection between the first device and the second device; The timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval in which the first device expects to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

13. The method according to claim 12, characterized in that The fourth time interval is N times the fifth time interval, where N≥2.

14. The method according to any one of claims 1 to 13, characterized in that The connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

15. A method for determining the connection status of a device, characterized in that: include: When a connection is established between the first device and the second device, the second device receives a first data packet sent by the first device; When a first condition is met, the second device configures the connection between the first device and the second device to an idle connection state, where the first condition is associated with one or more of the following information: an identifier of the first data packet; Status of the message queue of the second device; as well as The message type of the first response message is used to indicate that the second device confirms receipt of the first data packet.

16. The method according to claim 15, characterized in that The first condition includes one or more of the following conditions: The identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit (PDU) data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit (SDU) data packet; There is no message to be sent in the message queue of the second device; and The message type of the first response message is an independent response message.

17. The method according to claim 15 or 16, characterized in that The first data packet is the last of the multiple PDU data packets. Before the second device configures the connection between the first device and the second device to an idle connection state, the method further includes: The second device starts a first timer, where the first timer is used to indicate a time interval at which the second device expects to send the first response message, and a timing duration of the first timer is equal to the first time interval; The second device sends the first response message to the first device, where the first response message is sent within the first time interval.

18. The method according to claim 17, characterized in that When the first condition is met, the second device configures the connection between the first device and the second device to an idle connection state, including: When the first response message is an independent response message and there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to be in an idle connection state.

19. The method according to claim 17 or 18, characterized in that After the second device configures the connection between the first device and the second device to an idle connection state, the method further includes: The second device starts a second timer, where the second timer is used to indicate a time interval at which the second device expects to receive a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

20. The method according to claim 19, characterized in that The second time interval is N times the first time interval, where N≥2.

21. The method according to claim 17, wherein After the second device sends the first response message to the first device, the method further includes: The second device receives a second response message sent by the first device, where the second response message is used to indicate that the first device confirms receipt of the first response message.

22. The method according to claim 21, characterized in that When the first condition is met, the second device configures the connection between the first device and the second device to an idle connection state, including: When there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to be in an idle connection state.

23. The method according to claim 21 or 22, characterized in that After the second device configures the connection between the first device and the second device to an idle connection state, the method further includes: The first device starts a third timer, where the third timer is used to indicate a time interval at which the second device expects to send a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval.

24. The method according to claim 23, wherein The third time interval is N times the first time interval, where N≥2.

25. The method according to claim 15 or 16, characterized in that The first data packet is the last of the multiple PDU data packets, and when the first condition is met, the second device configures the connection between the first device and the second device to an idle connection state, including: When the second device determines that there is no message to be sent in the message queue of the second device, the second device configures the connection between the first device and the second device to be in an idle connection state.

26. The method according to claim 25, characterized in that After the second device configures the connection between the first device and the second device to an idle connection state, the method further includes: The second device starts a fourth timer, where the fourth timer is used to indicate a time interval at which the second device expects to receive a keep-alive message, where the keep-alive message is used to maintain a connection between the first device and the second device; The timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval in which the second device expects to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

27. The method according to claim 26, characterized in that The fourth time interval is N times the fifth time interval, where N≥2.

28. The method according to any one of claims 15 to 27, characterized in that The connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

29. An apparatus for determining a connection status of a device, characterized in that: The apparatus is configured on a first device, and includes: A first sending module, configured to send a first data packet to a second device when a connection is established between the first device and the second device; a configuration module, configured to configure the connection between the first device and the second device to an idle connection state when a first condition is met, where the first condition is associated with one or more of the following information: an identifier of the first data packet; Status of the message queue of the first device; and The message type of the first response message is used to indicate that the second device confirms receipt of the first data packet.

30. The device according to claim 29, characterized in that The first condition includes one or more of the following conditions: The identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit (PDU) data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit (SDU) data packet; There are no messages to be sent in the message queue of the first device; and The message type of the first response message is an independent response message.

31. The device according to claim 29 or 30, characterized in that The first data packet is the last of multiple PDU data packets, and the device further includes: A first starting module, configured to start a first timer, where the first timer is configured to indicate a time interval at which the first device expects to receive the first response message, and a timing duration of the first timer is equal to the first time interval; The receiving module is configured to receive the first response message sent by the second device, where the first response message is received within the first time interval.

32. The device according to claim 31, characterized in that The configuration module is further configured to: When the first response message is an independent response message and there is no message to be sent in the message queue of the first device, the connection between the first device and the second device is configured to be in an idle connection state.

33. The device according to claim 31 or 32, characterized in that The device further comprises: A second starting module, configured to start a second timer, where the second timer is used to indicate a time interval at which the first device expects to send a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

34. The device according to claim 33, characterized in that The second time interval is N times the first time interval, where N≥2.

35. The device according to claim 31, characterized in that The device further comprises: The second sending module is used to send a second response message to the second device, where the second response message is used to instruct the first device to confirm receipt of the first response message.

36. The device according to claim 35, characterized in that The configuration module is further configured to: When there is no message to be sent in the message queue of the first device, the connection between the first device and the second device is configured to be in an idle connection state.

37. The device according to claim 35 or 36, characterized in that The device further comprises: A third starting module, configured to start a third timer, where the third timer is used to indicate a time interval at which the first device expects to receive a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval.

38. The device according to claim 37, characterized in that The third time interval is N times the first time interval, where N≥2.

39. The device according to claim 29 or 30, characterized in that The first data packet is the last of multiple PDU data packets, and the configuration module is further configured to: When the first device determines that there is no message to be sent in the message queue of the first device, the connection between the first device and the second device is configured to be in an idle connection state.

40. The device according to claim 39, characterized in that The device further comprises: a fourth starting module, configured to start a fourth timer, where the fourth timer is used to indicate a time interval at which the first device expects to receive a keep-alive message, where the keep-alive message is used to maintain a connection between the first device and the second device; The timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval in which the first device expects to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

41. The device according to claim 40, characterized in that The fourth time interval is N times the fifth time interval, where N≥2.

42. The device according to any one of claims 29 to 41, characterized in that The connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

43. An apparatus for determining a connection status of a device, characterized in that: The apparatus is configured on a second device, and includes: A first receiving module is configured to receive a first data packet sent by the first device when a connection is established between the first device and the second device; a configuration module, configured to configure the connection between the first device and the second device to an idle connection state when a first condition is met, where the first condition is associated with one or more of the following information: an identifier of the first data packet; Status of the message queue of the second device; and The message type of the first response message is used to indicate that the second device confirms receipt of the first data packet.

44. The device according to claim 43, characterized in that The first condition includes one or more of the following conditions: The identifier of the first data packet indicates that the first data packet is the last one of multiple protocol data unit (PDU) data packets, wherein the multiple PDU data packets are multiple PDU data packets obtained by decomposing a first service data unit (SDU) data packet; There is no message to be sent in the message queue of the second device; and The message type of the first response message is an independent response message.

45. The device according to claim 43 or 44, characterized in that The first data packet is the last of multiple PDU data packets, and the device further includes: A first starting module, configured to start a first timer, where the first timer is configured to indicate a time interval at which the second device expects to send the first response message, and a timing duration of the first timer is equal to the first time interval; The second device sends the first response message to the first device, where the first response message is sent within the first time interval.

46. ​​The device according to claim 45, characterized in that The configuration module is further configured to: When the first response message is an independent response message and there is no message to be sent in the message queue of the second device, the connection between the first device and the second device is configured to be in an idle connection state.

47. The device according to claim 45 or 46, characterized in that The device further comprises: A second starting module, configured to start a second timer, where the second timer is used to indicate a time interval at which the second device expects to receive a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the second timer is equal to the second time interval, and the second time interval is greater than the first time interval.

48. The device according to claim 47, characterized in that The second time interval is N times the first time interval, where N≥2.

49. The device according to claim 45, characterized in that The device further comprises: The second receiving module is configured to receive a second response message sent by the first device, where the second response message is used to indicate that the first device confirms receipt of the first response message.

50. The device according to claim 49, characterized in that The configuration module is further configured to: When there is no message to be sent in the message queue of the second device, the connection between the first device and the second device is configured to be in an idle connection state.

51. The device according to claim 49 or 50, characterized in that The device further comprises: A third starting module, configured to start a third timer, where the third timer is used to indicate a time interval at which the second device expects to send a keep-alive message; The keep-alive message is used to maintain the connection between the first device and the second device, the timing duration of the third timer is equal to a third time interval, and the third time interval is greater than the first time interval.

52. The device according to claim 51, characterized in that The third time interval is N times the first time interval, where N≥2.

53. The device according to claim 43 or 44, characterized in that The first data packet is the last of multiple PDU data packets, and the configuration module is further configured to: When the second device determines that there is no message to be sent in the message queue of the second device, the connection between the first device and the second device is configured to be in an idle connection state.

54. The device according to claim 53, characterized in that The device further comprises: a fourth starting module, configured to start a fourth timer, where the fourth timer is used to indicate a time interval at which the second device expects to receive a keep-alive message, where the keep-alive message is used to maintain a connection between the first device and the second device; The timing duration of the fourth timer is equal to the fourth time interval, the fourth time interval is greater than the fifth time interval, and the fifth time interval is the time interval in which the second device expects to receive a response message before configuring the connection between the first device and the second device to an idle connection state.

55. The device according to claim 54, characterized in that The fourth time interval is N times the fifth time interval, where N≥2.

56. The device according to any one of claims 43 to 55, characterized in that The connection between the first device and the second device is a Bluetooth Low Energy (BLE) connection.

57. A communication device, characterized in that The communication apparatus is configured in a first device, which includes a memory and a processor. The memory is used to store a program, and the processor is used to call the program in the memory so that the first device executes the method according to any one of claims 1 to 14.

58. A communication device, characterized in that The communication device is configured in a second device, and the second device includes a memory and a processor, the memory is used to store a program, and the processor is used to call the program in the memory so that the second device executes the method according to any one of claims 15 to 28.

59. A device, characterized in that The device comprises a processor configured to call a program from a memory so as to enable the device to execute the method according to any one of claims 1 to 28.

60. A chip, characterized in that: The device comprises a processor configured to call a program from a memory so that a device equipped with the chip executes the method according to any one of claims 1 to 28.

61. A computer-readable storage medium, characterized in that A program is stored thereon, the program causing a computer to execute the method according to any one of claims 1 to 28.

62. A computer program product, characterized in that The method comprises a program for causing a computer to execute the method according to any one of claims 1 to 28.

63. A computer program, characterized in that The computer program causes a computer to execute the method according to any one of claims 1 to 28.