GATT SERVICE DISCOVERY PROCEDURE FOR TWO OR MORE DEVICES

20230239672 · 2023-07-27

Assignee

Inventors

Cpc classification

International classification

Abstract

The present invention provides a control method of an electronic device, wherein the control method includes the steps of: wirelessly connecting to a first device; performing a service discovery to the first device to retrieve a plurality of attribute handles from the first device; storing the plurality of attribute handles of the first device into a database cache; wirelessly connecting to a second device; determining whether the second device and the first device have the same attribute handles; and in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, for using services of the second device.

Claims

1. A control method of an electronic device, comprising: wirelessly connecting to a first device; performing a service discovery to the first device to retrieve a plurality of attribute handles from the first device; storing the plurality of attribute handles of the first device into a database cache; wirelessly connecting to a second device; determining whether the second device and the first device have the same attribute handles; and in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, for using services of the second device.

2. The control method of claim 1, wherein the step of in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, for using services of the second device comprises: in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, without performing the service discovery to the second device, for using services of the second device.

3. The control method of claim 1, wherein the step of performing the service discovery to the first device to retrieve the plurality of attribute handles from the first device comprise: performing the service discovery to the first device to retrieve all the attribute handles of the first device.

4. The control method of claim 1, further comprising: in response to the second device not having the same attribute handles as the first device, performing the service discovery to the second device to retrieve a plurality of attribute handles of the second device; and storing the plurality of attribute handles of the second device into the database cache.

5. The control method of claim 1, wherein the first device and the second device are Bluetooth devices.

6. The control method of claim 5, wherein the first device and the second device are a pair of earphones.

7. The control method of claim 5, wherein the plurality of attribute handles comprise services, characteristics and descriptors of a Generic Attribute (GATT) profile.

8. A circuitry of an electronic device, configured to perform the steps of: wirelessly connecting to a first device; performing a service discovery to the first device to retrieve a plurality of attribute handles from the first device; storing the plurality of attribute handles of the first device into a database cache; wirelessly connecting to a second device; determining whether the second device and the first device have the same attribute handles; and in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, for using services of the second device.

9. The circuitry of claim 8, wherein the step of in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, for using services of the second device comprises: in response to the second device having the same attribute handles as the first device, directly using the plurality of attribute handles of the first device stored in the database cache, without performing the service discovery to the second device, for using services of the second device.

10. The circuitry of claim 8, wherein the step of performing the service discovery to the first device to retrieve the plurality of attribute handles from the first device comprise: performing the service discovery to the first device to retrieve all the attribute handles of the first device.

11. The circuitry of claim 8, further comprising: in response to the second device not having the same attribute handles as the first device, performing the service discovery to the second device to retrieve a plurality of attribute handles of the second device; and storing the plurality of attribute handles of the second device into the database cache.

12. The circuitry of claim 8, wherein the first device and the second device are Bluetooth devices.

13. The circuitry of claim 12, wherein the first device and the second device are a pair of earphones.

14. The circuitry of claim 12, wherein the plurality of attribute handles comprise services, characteristics and descriptors of a Generic Attribute (GATT) profile.

15. An electronic device, comprising: a wireless network module; and a storage device; wherein the wireless network module wirelessly connects to a first device, performs a service discovery to the first device to retrieve a plurality of attribute handles from the first device, and stores the plurality of attribute handles of the first device into the storage device; and the wireless network module wirelessly connects to a second device, and determines whether the second device and the first device have the same attribute handles; and in response to the second device having the same attribute handles as the first device, the wireless network module directly uses the plurality of attribute handles of the first device stored in the storage device, for using services of the second device.

16. The electronic device of claim 15, wherein in response to the second device having the same attribute handles as the first device, the wireless network module directly uses the plurality of attribute handles of the first device stored in the storage device, without performing the service discovery to the second device, for using services of the second device.

17. The electronic device of claim 15, wherein the wireless network module performs the service discovery to the first device to retrieve all the attribute handles of the first device.

18. The electronic device of claim 15, wherein in response to the second device not having the same attribute handles as the first device, the wireless network module performs the service discovery to the second device to retrieve a plurality of attribute handles of the second device, and stores the plurality of attribute handles of the second device into the storage device.

19. The electronic device of claim 15, wherein the first device and the second device are Bluetooth devices.

20. The electronic device of claim 19, wherein the first device and the second device are a pair of earphones.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

[0009] FIG. 1 is a diagram illustrating an electronic device according to one embodiment of the present invention.

[0010] FIG. 2 shows a GATT profile.

[0011] FIG. 3 shows a structure of an attribute of the GATT profile.

[0012] FIG. 4 is a flowchart of a control method between the electronic device, the first device and the second device according to one embodiment of the present invention.

DETAILED DESCRIPTION

[0013] Certain terms are used throughout the following description and claims to refer to particular system components. As one skilled in the art will appreciate, manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following discussion and in the claims, the terms “including” and “comprising” are used in an open-ended fashion, and thus should be interpreted to mean “including, but not limited to ...”. The terms “couple” and “couples” are intended to mean either an indirect or a direct electrical connection. Thus, if a first device couples to a second device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.

[0014] FIG. 1 is a diagram illustrating an electronic device 100 according to one embodiment of the present invention. In this embodiment, the electronic device 100 may be a smartphone, a tablet, a notebook or any other electronic device that has a wireless communication function, and the electronic device 100 comprises an application processor 110, a wireless network module 120 and a storage device 130. The application processor 110 is arranged to execute applications running on a system of the electronic device 100. The wireless network module 120 is configured to wirelessly connect to other electronic devices. The storage device 130 may comprise a plurality of different storage elements, and stores data related to the application processor 110 and the wireless network module 120. In addition, part of the storage device 130 may be integrated into the wireless network module 120 or the application processor 110.

[0015] In this embodiment, the wireless network module 120 is a Bluetooth module that complies with BLE specification, and the electronic device 100 is able to use the wireless network module 120 to communicate to a first device 102_1 and a second device 102_2 shown in FIG. 1, wherein the first device 102_1 and the second device 102_2 may be a pair of earphones. In this embodiment, the electronic device 100 serves as a GATT client, and the first device 102_1 and the second device 102_2 serve as GATT servers. In a GATT profile shown in FIG. 2, the GATT profile comprises at least one service, each service comprises at least one characteristic, and each characteristic comprises attributes such as declaration, properties, value and descriptor. In addition, attributes are the smallest data entity defined by GATT, and each attribute comprises an attribute handle, an attribute type, an attribute value and attribute permissions as shown in FIG. 3. The attribute handle is a unique 16-bit identifier for each attribute on a particular GATT server, and it is the part of each attribute that makes it addressable, and it is guaranteed not to change between transactions or connections. The attribute type is a universally unique identifier (UUID) which can be 2 or 16 bytes, wherein the attribute type determines the kind of data present in the value of the attribute. The attribute value holds the actual data content of the attribute. The attribute permissions are metadata that specify which operations can be executed on each particular attribute and with which specific security requirements, for example, read only, no authentication, no authorization etc. It is noted that the GATT profile and the structure of the attribute are known by a person skilled in the art, the detailed descriptions about GATT profile and attribute are omitted here.

[0016] The attributes are only in the GATT server, and the GATT client needs the attributes of the GATT server to have the service, so the GATT client needs to perform the service discovery to obtain all the attribute handles of the GATT server and stores the attribute handles into a database cache of the storage device 130. Then, after the service discovery is completed, the GATT client can start using the service of the GATT server, for example, sending an audio signal to the GATT server for playback, or sending a control signal to the GATT server to control its volume. In this embodiment, because the electronic device 100 needs services of the pair of earphones (i.e. the first device 102_1 and the second device 102_2), if it is determined that the first device 102_1 and the second device 102_2 have the same GATT services (i.e. all the attribute handles are the same in device 102_1 and device 102_2), the electronic device 100 can perform the service discovery to the first device 102_1 only to retrieve the attribute handles and stores the retrieved attribute handles into the database cache, then the electronic device 100 directly uses the attribute handles stored in the database cache, without performing the service discovery to the second device 102_2, for using the services of both the first device 102_1 and the second device 102_2. By using the above mechanism, latency of the electronic device 100 can be improved.

[0017] FIG. 4 is a flowchart of a control method between the electronic device 100, the first device 102_1 and the second device 102_2 according to one embodiment of the present invention. In Step 400, the flow starts, and the first device 102_1 and the second device 102_2 are powered on. In Step 402, the electronic device 100 uses the wireless network module 120 to scan surrounding Bluetooth devices, and the first device 102_1 is connected to the electronic device 100. In Step 404, the electronic device 100 performs the service discovery to the first device 102_1 to retrieve all the attribute handles of the first device 102_1. For example, the wireless network module 120 may send a request to the first device 102_1 to obtain a portion of the attribute handles, then send another request to the first device 102_1 to obtain another portion of the attribute handles, ... until the wireless network module 120 obtains all the attribute handles of the first device 102_1. In Step 406, the wireless network module 120 stores the attribute handles of the first device 102_1 into the database cache. In Step 408, the second device 102_2 starts to connect to the electronic device 100, and at this time, the second device 102_2 does not send any attribute of the GATT profile to the electronic device 100. In Step 410, the wireless network module 120 determines if the second device 102_2 and the first device 102_1 have the same GATT services structure, if yes, the flow enters Step 414; and if not, the flow enters Step 412. Specifically, the wireless network module 120 may read internal sniffer logs to determine if the second device 102_2 and the first device 102_1 have the same GATT services structure; or the first device 102_1 and the second device 102_2 may send a specific signal or specific identity to the wireless network module 120, for the wireless network module 120 knowing that the second device 102_2 and the first device 102_1 have the same GATT services structure; or the wireless network module 120 may ask the first device 102_1 and the second device 102_2 whether they have the same GATT services structure. In Step 412, if it is determined that the second device 102_2 and the first device 102_1 does not have the same GATT services structure, the wireless network module 120 performs the service discovery to the second device 102_2 to obtain all the attribute handles, and stores all the attribute handles of the second device 102_2 into the database cache. In Step 414, the wireless network module 120 searches the database cache to determine if the attribute handles of the first device 102_1 exist, if yes, the flow enters Step 416; and if not, the flow enters Step 412. In Step 416, the wireless network module 120 directly uses the attribute handles of the first device 102_1 stored in the database cache, without performing the service discovery to the second device 102_2, for using the services of both the first device 102_1 and the second device 102_2.

[0018] It is noted that a number of GATT servers in the present invention is not limited to two. In other embodiments, the electronic device 100 may connect to three or more GATT servers such as many speakers or several pairs of earphones. In one embodiment, after the Step 412 or the Step 416 is completely executed, if a third device is connected to the electronic device 100, the wireless network module 120 can determine whether the third device has the same GATT services structure as the first device 102_1 and/or the second device 102_2; and if the third device has the same GATT services structure as the first device 102_1 and/or the second device 102_2, the wireless network module 120 can directly use the attribute handles of the first device 102_1 or the attribute handles of the second device 102_2 stored in the database cache, without performing the service discovery to the third device, for using the service of the third device.

[0019] Briefly summarized, in the present invention, when the GATT client needs to use the service of two or more GATT servers having the same GATT services structure, the GATT client may perform the service discovery to only one GATT server to obtain attribute handles, and directly use the attribute handles to use services of two or more GATT servers. By using the control method of the present invention, the GATT client can preserve time and power for not doing other service discovery procedures.

[0020] Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.