Equipment connection method and device, electronic equipment and storage medium
By obtaining the Bluetooth service information of the second device from the locally stored preset files, the connection speed problem caused by the large number of interactions during the Bluetooth connection is solved, which improves the user experience and reduces power consumption.
Patent Information
- Application Number
- CN202311433315.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2025-05-02
AI Technical Summary
During the device interconnection process, when two electronic devices are connected through Bluetooth, they need to query the service information of the supported Bluetooth services from the counterpart device, resulting in a slow connection speed and affecting the user experience.
By obtaining the service information of the Bluetooth service supported by the second device from the locally stored preset file, the Bluetooth connection is directly completed without querying from the second device.
Reduces the number of interactions between devices, improves Bluetooth connection speed, improves user experience, and reduces device power consumption.
Smart Images

Figure CN119922756A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Bluetooth technology, and in particular to a device connection method, apparatus, electronic device and storage medium. Background Art
[0002] Bluetooth is one of the most widely used wireless communication protocols. Bluetooth communication is mainly for short-distance communication, with the characteristics of low power consumption and fast transmission speed. Bluetooth technology has been widely used in various electronic devices, whether in office, study or life, Bluetooth technology plays an important role.
[0003] In the related art, during the device interconnection process, when two electronic devices are connected via Bluetooth, it is necessary to query the service information of the supported Bluetooth services from the other device, which causes the interaction process between the two electronic devices to be time-consuming, affects the connection speed, and poor user experience. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a device connection method, an apparatus, an electronic device and a storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, a device connection method is provided, which is applied to a first device, and the method includes:
[0006] Initiate a Bluetooth connection request to a second device, wherein the Bluetooth connection request is used to request the first device to interconnect with the second device;
[0007] Obtaining service information of the Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store service information of the Bluetooth service supported by a preset device, and the preset device is a device that can be interconnected with the first device;
[0008] Complete the Bluetooth connection with the second device.
[0009] In some embodiments, acquiring service information of the Bluetooth service supported by the second device from a locally stored preset file includes:
[0010] The service information corresponding to the device attribute is queried from the preset file, where the device attribute includes at least one of a device address and a device type of the second device.
[0011] In some embodiments, before initiating a Bluetooth connection request to the second device, the method further includes:
[0012] When the first device discovers the second device through Bluetooth communication, the device attribute corresponding to the second device is configured.
[0013] In some embodiments, the preset file is a binary file; and obtaining service information of the Bluetooth service supported by the second device from the locally stored preset file includes:
[0014] Parsing the binary file to obtain a parsed file;
[0015] The service information is obtained from the parsed file.
[0016] In some embodiments, the method further comprises:
[0017] Sending a service acquisition request to the second device, where the service acquisition request is used to request to acquire a Bluetooth service supported by the second device;
[0018] receiving reply information returned by the second device, where the reply information is used to indicate the Bluetooth service supported by the second device;
[0019] The acquiring, from a locally stored preset file, service information of a Bluetooth service supported by the second device includes:
[0020] In response to receiving the reply information, the service information is obtained from the preset file.
[0021] In some embodiments, after receiving the reply information returned by the second device, the method further includes:
[0022] Determine, based on the reply information, a queue to be queried, where the queue to be queried includes at least one Bluetooth service supported by the second device, and the at least one Bluetooth service does not include an audio-related Bluetooth service;
[0023] Based on the queue to be queried, service information of the at least one Bluetooth service is obtained from the second device.
[0024] In some embodiments, initiating a Bluetooth connection request to the second device includes:
[0025] The Bluetooth connection request is initiated to the second device through a device interconnection application.
[0026] In some embodiments, the service information includes a plurality of attribute data and an attribute handle corresponding to each of the attribute data;
[0027] The attribute handle is an attribute handle allocated by the second device to the device interconnection application, the attribute handle is a fixed value, and the Bluetooth service supported by the second device is a service registered by the device interconnection application with the Bluetooth of the second device.
[0028] According to a second aspect of an embodiment of the present disclosure, there is provided a device connection apparatus, which is configured on a first device, and the apparatus includes:
[0029] a connection initiating module, configured to initiate a Bluetooth connection request to a second device, wherein the Bluetooth connection request is used to request the first device to interconnect with the second device;
[0030] A service information acquisition module, configured to acquire service information of a Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store service information of a Bluetooth service supported by a preset device, and the preset device is a device that can interconnect with the first device;
[0031] The connection completion module is configured to complete the Bluetooth connection with the second device.
[0032] In some embodiments, the service information acquisition module is configured to:
[0033] The service information corresponding to the device attribute is queried from the preset file, where the device attribute includes at least one of a device address and a device type of the second device.
[0034] In some embodiments, the apparatus further comprises:
[0035] The device attribute acquisition module is configured to configure the device attribute corresponding to the second device when the first device discovers the second device through Bluetooth communication.
[0036] In some embodiments, the preset file is a binary file; the service information acquisition module is configured to:
[0037] Parsing the binary file to obtain a parsed file;
[0038] The service information is obtained from the parsed file.
[0039] In some embodiments, the apparatus further comprises:
[0040] A service acquisition module, configured to send a service acquisition request to the second device, wherein the service acquisition request is used to request to acquire a Bluetooth service supported by the second device;
[0041] a reply information receiving module, configured to receive reply information returned by the second device, wherein the reply information is used to indicate the Bluetooth service supported by the second device;
[0042] The service information acquisition module is configured to:
[0043] In response to receiving the reply information, the service information is obtained from the preset file.
[0044] In some embodiments, the apparatus further comprises:
[0045] a queue determination module, configured to determine a queue to be queried based on the reply information, wherein the queue to be queried includes at least one Bluetooth service supported by the second device, and the at least one Bluetooth service does not include an audio-related Bluetooth service;
[0046] The service information acquisition module is further configured to acquire the service information of the at least one Bluetooth service from the second device based on the queue to be queried.
[0047] In some embodiments, the connection initiating module includes:
[0048] The Bluetooth connection request is initiated to the second device through a device interconnection application.
[0049] In some embodiments, the service information includes a plurality of attribute data and an attribute handle corresponding to each of the attribute data;
[0050] The attribute handle is an attribute handle allocated by the second device to the device interconnection application, the attribute handle is a fixed value, and the Bluetooth service supported by the second device is a service registered by the device interconnection application with the Bluetooth of the second device.
[0051] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0052] processor;
[0053] a memory for storing processor-executable instructions;
[0054] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.
[0055] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure.
[0056] The above method of the present disclosure has the following beneficial effects:
[0057] The method provided by the embodiment of the present disclosure initiates a Bluetooth connection request to the second device, obtains the service information of the Bluetooth service supported by the second device from a locally stored preset file, the preset file is used to store the service information of the Bluetooth service supported by the preset device, and the preset device is a device that can interconnect with the first device; completes the Bluetooth connection with the second device. When the first device and the second device are connected by Bluetooth, the first device can directly obtain the service information from the locally stored preset file without querying the service information from the second device, thereby reducing the number of interactions between the first device and the second device, speeding up the Bluetooth connection, and improving the user experience. In addition, when the number of interactions is reduced, the power consumption of the first device and the second device can be reduced.
[0058] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0060] Figure 1 is a flow chart showing a device connection method according to an exemplary embodiment;
[0061] Figure 2 is a flow chart showing a device connection method according to an exemplary embodiment;
[0062] Figure 3 is a flow chart showing a device connection method according to an exemplary embodiment;
[0063] Figure 4 is a flow chart showing a device connection method according to an exemplary embodiment;
[0064] Figure 5 is a block diagram of a device connection apparatus according to an exemplary embodiment;
[0065] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0067] In a related technology, during the device interconnection process, a non-binding method is used to connect via Bluetooth. When two electronic devices are connected via Bluetooth for the first time, the service information of the supported Bluetooth services can be queried from the other device, and then the queried service information can be cached locally. After that, when the Bluetooth connection is not made for the first time, the locally cached service information can be queried, which can improve the speed of the non-first connection, but the speed of the first connection cannot be improved. In addition, in some cases, after the service information is cached locally, if the service information of the other device changes, even if the two electronic devices are not connected via Bluetooth for the first time, the latest service information needs to be queried again.
[0068] There are also some electronic devices that do not support caching technology in non-bonded Bluetooth connections, and the speed of these devices cannot be improved unless they are connected for the first time.
[0069] In the above-mentioned related technologies, no matter what the situation is, two electronic devices need to interact for a long time when establishing a Bluetooth connection, which affects the connection speed and leads to a poor user experience.
[0070] The disclosed embodiment provides a new device connection method. When a first device and a second device are connected via Bluetooth, the first device can directly obtain service information from a locally stored preset file without querying the service information from the second device, thereby reducing the number of interactions between the first device and the second device, speeding up the Bluetooth connection, and improving the user experience. In addition, when the number of interactions is reduced, the power consumption of the first device and the second device can be reduced.
[0071] The device connection method provided by the embodiments of the present disclosure is applied to device interconnection scenarios, such as interconnection between a mobile phone and a tablet computer, interconnection between a mobile phone and a laptop computer, interconnection between a tablet computer and a laptop computer, etc.
[0072] The method provided in the embodiment of the present disclosure is executed by an electronic device, which may be a mobile phone, a tablet computer, a laptop computer, a wearable device, a Bluetooth headset, a keyboard, a smart home device, or other device with Bluetooth function.
[0073] Figure 1 is a flowchart of a device connection method according to an exemplary embodiment, which is executed by a first device, see Figure 1 , the method comprises the following steps:
[0074] Step S101: Initiate a Bluetooth connection request to a second device, where the Bluetooth connection request is used to request the first device to interconnect with the second device.
[0075] In the disclosed embodiment, the first device is equivalent to the client, and the second device is equivalent to the server. When the first device and the second device need to establish a Bluetooth connection, the first device initiates a Bluetooth connection request to the second device, and the Bluetooth connection request is used to request the first device and the second device to interconnect, that is, to request the first device and the second device to establish a Bluetooth connection. Wherein, Bluetooth refers to Bluetooth Low Energy (BLE).
[0076] Step S102, obtaining service information of the Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store service information of the Bluetooth service supported by a preset device, and the preset device is a device that can interconnect with the first device.
[0077] The preset file is a file stored locally on the first device. The preset file is a pre-configured file used to store service information of Bluetooth services supported by the preset device. Bluetooth services may include various Bluetooth protocols. For example, Bluetooth services include TQIN services (i.e., 0xFCC0), GATT services (i.e., 0x1801), GAP services (i.e., 0x1800), etc. The service information includes multiple attribute data and an attribute handle corresponding to each attribute data. The preset device is a device that can interconnect with the first device, and the second device is the preset device.
[0078] For the first device, after the first device initiates a Bluetooth connection request to the second device, it is necessary to obtain the service information of the Bluetooth service supported by the second device, and then the first device and the second device can complete the Bluetooth connection. In order to reduce the interaction between the first device and the second device when obtaining the service information, the embodiment of the present disclosure directly obtains the service information from a preset file stored locally.
[0079] Step S103, completing the Bluetooth connection with the second device.
[0080] Completing the Bluetooth connection with the second device means that the Bluetooth connection between the first device and the second device is established, and then the first device and the second device can communicate through the established Bluetooth connection.
[0081] According to the method provided by the embodiment of the present disclosure, when the first device and the second device are connected via Bluetooth, the first device can directly obtain service information from a preset file stored locally, without querying the service information from the second device, thereby reducing the number of interactions between the first device and the second device, speeding up the Bluetooth connection, and improving the user experience. Furthermore, when the number of interactions is reduced, the power consumption of the first device and the second device can be reduced.
[0082] Figure 2 is a flowchart of a device connection method according to an exemplary embodiment, which is executed by a first device, see Figure 2 , the method comprises the following steps:
[0083] Step S201: When the first device discovers the second device through Bluetooth communication, the first device configures the device attributes corresponding to the second device.
[0084] In the disclosed embodiment, before the first device establishes a connection with the second device, that is, before the Bluetooth of the first device is paired with the Bluetooth of the second device, the first device needs to first discover the second device, that is, the first device discovers the second device through Bluetooth communication. After the first device discovers the second device, if it is determined that the second device is a device that can be interconnected with the first device, or it is determined that the second device belongs to a preset device, the device attributes corresponding to the second device can be configured. The device attributes include at least one of the device address and device type of the second device.
[0085] In some embodiments, the device properties corresponding to the second device are configured through the device interconnection application, and the device properties are sent to the Bluetooth module through the device interconnection application, that is, the device properties corresponding to the second device are notified to the Bluetooth module, so that the subsequent Bluetooth module can query the corresponding service information according to the device properties. The device interconnection application is an application installed in the first device for device interconnection.
[0086] In one example, the data format of the device attributes is shown in Table 1 below:
[0087] Table 1
[0088] Property Name Data Format AAA [Device address]+[Device type] Device Address XX:XX:XX:XX:XX:XX Device Type PC / TV / phone / pad, etc.
[0089] As shown in Table 1, "AAA" refers to the attribute name of the device attribute, and the data format of the device attribute is [device address]+[device type]. The data format of the device address is XX:XX:XX:XX:XX:XX:XX, and the data format of the device type is pc / tv / phone / pad, etc.
[0090] It should be noted that the embodiments of the present disclosure do not limit the attribute names of device attributes.
[0091] Step S202: Initiate a Bluetooth connection request to the second device through the device interconnection application.
[0092] During the process of pairing the Bluetooth of the first device with the Bluetooth of the second device, a Bluetooth connection request is initiated to the second device through the device interconnection application, wherein the Bluetooth connection request is used to request the first device to interconnect with the second device.
[0093] It should be noted that this Bluetooth connection process may be the first connection between the first device and the second device, or may be a non-first connection between the first device and the second device, and the embodiments of the present disclosure do not limit this.
[0094] Step S203: query service information corresponding to the device attributes from the locally stored preset file.
[0095] For the second device, in the related art, the second device sequentially allocates a Handle corresponding to each application that can use Bluetooth. In this way, the Handle allocated to each application is not fixed at different times, and the allocation of the Handle is random. In this case, for the first device, since it is impossible to know the Handle fixedly allocated by the second device, it is necessary to query the latest Handle from the second device when making a Bluetooth connection.
[0096] In the disclosed embodiment, the premise that the first device can pre-store the preset file locally is that the service information of the Bluetooth service supported by the second device is fixed, and the device interconnection between the first device and the second device is implemented based on the device interconnection application. Therefore, for the second device, the second device assigns a fixed Handle to the device interconnection application, that is, the Handle is the Handle assigned by the second device to the device interconnection application, and the Handle is a fixed value, and the Bluetooth service supported by the second device is the service registered by the device interconnection application to the Bluetooth of the second device. For the first device, when the Handle assigned by the second device to the device interconnection application has been determined, a preset file can be configured in advance, and the preset file includes the service information of the Bluetooth service supported by the second device.
[0097] The service information of the Bluetooth service in the preset file may be stored in correspondence with the device type or the device address. Therefore, the service information corresponding to the device attribute may be queried from the preset file according to the device attribute corresponding to the second device.
[0098] In some embodiments, since audio-related Bluetooth services are not required during the device interconnection process, the preset file may not include service information of audio-related Bluetooth services.
[0099] In some embodiments, the first device opens a locally stored preset file through a file operation. For example, the storage path of the preset file is “ / directory 1 / directory 2 / directory 3 / file name of the preset file”.
[0100] In some embodiments, the service information is queried from a locally stored preset file through a Bluetooth module.
[0101] In some embodiments, if the preset file is not a binary file, the service information is queried from the preset file, including: parsing the binary file to obtain a parsed file, that is, parsing the binary file into a currently required format; and obtaining the service information from the parsed file.
[0102] Step S204: Complete the Bluetooth connection with the second device.
[0103] According to the method provided by the embodiment of the present disclosure, when the first device and the second device are connected via Bluetooth, the first device can directly obtain service information from a preset file stored locally, without querying the service information from the second device, thereby reducing the number of interactions between the first device and the second device, speeding up the Bluetooth connection, and improving the user experience. Furthermore, when the number of interactions is reduced, the power consumption of the first device and the second device can be reduced.
[0104] Furthermore, after the first device discovers the second device and before the first device starts connecting to the second device, the second device is first configured with corresponding attribute information to facilitate subsequent determination of which device needs to query the service information of the Bluetooth service supported by the device, thereby facilitating quick query of the service information and improving the speed of obtaining the service information.
[0105] Furthermore, the method provided by the embodiment of the present disclosure does not limit whether the current Bluetooth connection is the first connection. The above implementation can be used in both the first connection and non-first connection cases. Therefore, in both cases, a faster connection speed can be achieved.
[0106] Figure 3 is a flowchart of a device connection method according to an exemplary embodiment, which is executed by a first device, see Figure 3 , the method comprises the following steps:
[0107] Step S301: Initiate a Bluetooth connection request to a second device through a device interconnection application.
[0108] Step S302: Send a service acquisition request to the second device.
[0109] When the first device initiates a Bluetooth connection request to the second device, it will also send a service acquisition request to the second device, where the service acquisition request is used to request the Bluetooth service supported by the second device; wherein the service acquisition request can be sent together with the Bluetooth connection request, or the Bluetooth connection request can be sent first and then the service acquisition request.
[0110] In one example, the service acquisition request is ATT_READ_BY_TYPE_REQ, which is used to request a hash value from the second device. The requested hash value can be used to represent the Bluetooth service supported by the second device.
[0111] Step S303: receiving reply information returned by the second device.
[0112] For the second device, after receiving the service acquisition request, the second device responds to the service acquisition request and returns reply information to the second device based on the currently supported Bluetooth service, and the first device receives the reply information, wherein the reply information is used to represent the Bluetooth service supported by the second device.
[0113] In one example, the reply message is ATT_READ_BY_TYPE_RSP, and the reply message includes a hash value.
[0114] It should be noted that the embodiment of the present disclosure provides two different ways of obtaining service information, namely step S304 and steps S305-S306. After the first device receives the reply information returned by the second device, the first device can execute step S304 or steps S305-S306.
[0115] Step S304, in response to receiving the reply information, obtaining service information from a preset file.
[0116] In the embodiment of the present disclosure, the reply information serves as a trigger condition for obtaining the service information from the preset file. In response to receiving the reply information, the first device executes the step of obtaining the service information from the preset file.
[0117] In some embodiments, in response to receiving the reply information, service information corresponding to the device attribute is queried from a preset file.
[0118] Step S305: determining a queue to be queried based on the reply information, where the queue to be queried includes at least one Bluetooth service supported by the second device, and the at least one Bluetooth service does not include an audio-related Bluetooth service.
[0119] Step S306: Based on the queue to be queried, obtain service information of at least one Bluetooth service from the second device.
[0120] Compared with the method of obtaining service information in the above step S304, the method of obtaining service information in steps S305 and S306 is still to obtain from the second device. However, unlike the method of obtaining service information from the opposite device in the related art, in the embodiment of the present disclosure, it is considered that the Bluetooth service related to audio is not needed in the process of device interconnection, and the service information of the Bluetooth service related to audio usually has a large amount of data. It takes a long time to obtain the service information of the Bluetooth service related to audio from the opposite device. Therefore, the service information of the Bluetooth service related to audio is skipped, and the first device obtains the service information of at least one Bluetooth service other than the Bluetooth service related to audio from the second device. Among them, the Bluetooth service related to audio includes GMCS service (i.e. 0x1849), GTBS service (i.e. 0x184c), TMAS service (i.e. 0x1855), etc.
[0121] The reply information represents the Bluetooth services supported by the second device. When the reply information represents that the Bluetooth services supported by the second device include Bluetooth services related to audio, the Bluetooth services related to audio are skipped when determining the queue to be queried, that is, the queue to be queried does not include Bluetooth services related to audio. Afterwards, the first device sends a query request to the second device based on the queue to be queried, and the query request is used to query service information of other Bluetooth services except the Bluetooth services related to audio. The second device returns corresponding service information to the first device based on the received query request.
[0122] Step S307: Complete the Bluetooth connection with the second device.
[0123] In the disclosed embodiment, when the first device and the second device are connected via Bluetooth, two methods of obtaining service information are provided. One method is that the first device can directly obtain service information from a preset file stored locally without querying service information from the second device. Another method is that the first device queries the second device for service information of other Bluetooth services except audio-related Bluetooth services. By ignoring audio-related Bluetooth services, the amount of data that needs to be queried and the amount of data that needs to be transmitted during the interaction are reduced. Both methods reduce the number of interactions between the first device and the second device, speed up the Bluetooth connection, and improve the user experience. Moreover, when the number of interactions is reduced, the power consumption of the first device and the second device can be reduced.
[0124] Above Figure 3In the illustrated embodiment, two methods for obtaining service information are proposed. In some embodiments, different electronic devices may adopt one of the above two methods. For example, when the electronic device is a mobile phone or a tablet computer, the method shown in step S304 may be adopted. When the electronic device is a smart TV or a desktop computer, the method shown in steps S305 and S306 may be adopted. The following describes the situation in which different devices adopt different methods.
[0125] Figure 4 is a flowchart of a device connection method according to an exemplary embodiment, which is executed by a first device, see Figure 4 , the method comprises the following steps:
[0126] Step S401: initiate a Bluetooth connection request to a second device.
[0127] Step S402, determining whether the Bluetooth connection request is initiated by the device interconnection application, if the Bluetooth connection request is initiated by the device interconnection application, executing step S403, if the Bluetooth connection request is not initiated by the device interconnection application, executing step S407.
[0128] When it is determined that the Bluetooth connection request is initiated by the device interconnection application, the Bluetooth connection optimization control switch is enabled, and the subsequent step S403 is executed.
[0129] Step S403, determining whether the device attributes corresponding to the second device have been configured, if the device attributes corresponding to the second device have been configured, executing step S404, if the device attributes corresponding to the second device have not been configured, executing step S406.
[0130] If the device attribute corresponding to the second device is not configured, it means that the second device does not support ATT (attribute protocol, data interaction protocol) localization, and thus cannot directly query the service information from the locally stored preset file.
[0131] Step S404, determining whether the device type of the second device is a preset type, if the device type of the second device is a preset type, executing step S405, if the device type of the second device is not a preset type, executing step S406.
[0132] In one example, the preset type is a mobile phone or a tablet computer. When the first device is a mobile phone or a tablet computer, step S405 is executed, and when the mobile phone is a smart TV or a desktop computer, step S406 is executed.
[0133] Step S405: Obtain service information of the Bluetooth service supported by the second device from the preset file, and then execute step S408.
[0134] Step S406: query the service information of Bluetooth services other than audio-related Bluetooth services from the second device, and then execute step S408.
[0135] Step S407: query the service information of all Bluetooth services from the second device.
[0136] All Bluetooth services refer to all Bluetooth services supported by the second device. Compared with the above step S406, all Bluetooth services including audio-related Bluetooth services need to be queried.
[0137] Step S408: Complete the Bluetooth connection with the second device.
[0138] Figure 5 is a block diagram of a device connection apparatus according to an exemplary embodiment, which is configured in a first device, see Figure 5 , the device comprises:
[0139] The connection initiating module 501 is configured to initiate a Bluetooth connection request to the second device, where the Bluetooth connection request is used to request the first device to interconnect with the second device;
[0140] The service information acquisition module 502 is configured to acquire the service information of the Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store the service information of the Bluetooth service supported by a preset device, and the preset device is a device that can be interconnected with the first device;
[0141] The connection completion module 503 is configured to complete the Bluetooth connection with the second device.
[0142] In some embodiments, the service information acquisition module 502 is configured to:
[0143] The service information corresponding to the device attribute is queried from the preset file, where the device attribute includes at least one of a device address and a device type of the second device.
[0144] In some embodiments, the apparatus further comprises:
[0145] The device attribute acquisition module is configured to configure device attributes corresponding to the second device when the first device discovers the second device through Bluetooth communication.
[0146] In some embodiments, the preset file is a binary file; the service information acquisition module 502 is configured to:
[0147] Parse the binary file and obtain the parsed file;
[0148] Get the service information from the parsed file.
[0149] In some embodiments, the apparatus further comprises:
[0150] A service acquisition module, configured to send a service acquisition request to the second device, where the service acquisition request is used to request to acquire a Bluetooth service supported by the second device;
[0151] A reply information receiving module, configured to receive reply information returned by the second device, where the reply information is used to indicate the Bluetooth service supported by the second device;
[0152] The service information acquisition module 502 is configured to:
[0153] In response to receiving the reply information, the service information is obtained from the preset file.
[0154] In some embodiments, the apparatus further comprises:
[0155] a queue determination module, configured to determine a queue to be queried based on the reply information, wherein the queue to be queried includes at least one Bluetooth service supported by the second device, and the at least one Bluetooth service does not include an audio-related Bluetooth service;
[0156] The service information acquisition module 502 is further configured to acquire service information of at least one Bluetooth service from the second device based on the queue to be queried.
[0157] In some embodiments, the connection initiating module 501 includes:
[0158] A Bluetooth connection request is initiated to the second device through the device interconnection application.
[0159] In some embodiments, the service information includes a plurality of attribute data and an attribute handle corresponding to each attribute data;
[0160] The attribute handle is an attribute handle allocated by the second device to the device interconnection application, the attribute handle is a fixed value, and the Bluetooth service supported by the second device is a service registered by the device interconnection application with the Bluetooth of the second device.
[0161] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0162] An embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the device connection method in the above embodiment.
[0163] Figure 6 is a block diagram of an electronic device 600 according to an exemplary embodiment.
[0164] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0165] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0166] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0167] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0168] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0169] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0170] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0171] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0172] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0173] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0174] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0175] The embodiments of the present disclosure also provide a non-temporary computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the device connection method in the above embodiments.
[0176] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0177] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A device connection method, applied to a first device, characterized in that: The method comprises: Initiate a Bluetooth connection request to a second device, wherein the Bluetooth connection request is used to request the first device to interconnect with the second device; Obtaining service information of the Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store service information of the Bluetooth service supported by a preset device, and the preset device is a device that can be interconnected with the first device; Complete the Bluetooth connection with the second device.
2. The method according to claim 1, characterized in that The acquiring, from a locally stored preset file, service information of a Bluetooth service supported by the second device includes: The service information corresponding to the device attribute is queried from the preset file, where the device attribute includes at least one of a device address and a device type of the second device.
3. The method according to claim 2, characterized in that Before initiating a Bluetooth connection request to the second device, the method further includes: When the first device discovers the second device through Bluetooth communication, the device attribute corresponding to the second device is configured.
4. The method according to claim 1, characterized in that: The preset file is a binary file; The acquiring, from a locally stored preset file, service information of a Bluetooth service supported by the second device includes: Parsing the binary file to obtain a parsed file; The service information is obtained from the parsed file.
5. The method according to claim 1, characterized in that The method further comprises: Sending a service acquisition request to the second device, where the service acquisition request is used to request to acquire a Bluetooth service supported by the second device; receiving reply information returned by the second device, where the reply information is used to indicate the Bluetooth service supported by the second device; The acquiring, from a locally stored preset file, service information of a Bluetooth service supported by the second device includes: In response to receiving the reply information, the service information is obtained from the preset file.
6. The method according to claim 5, characterized in that After receiving the reply information returned by the second device, the method further includes: Based on the reply information, determining a queue to be queried, where the queue to be queried includes at least one Bluetooth service supported by the second device, and the at least one Bluetooth service does not include an audio-related Bluetooth service; Based on the queue to be queried, service information of the at least one Bluetooth service is obtained from the second device.
7. The method according to any one of claims 1 to 6, characterized in that The initiating a Bluetooth connection request to the second device includes: The Bluetooth connection request is initiated to the second device through a device interconnection application.
8. The method according to claim 7, characterized in that The service information includes a plurality of attribute data and an attribute handle corresponding to each of the attribute data; The attribute handle is an attribute handle allocated by the second device to the device interconnection application, the attribute handle is a fixed value, and the Bluetooth service supported by the second device is a service registered by the device interconnection application with the Bluetooth of the second device.
9. A device connection device, characterized in that: Configured in a first device, the apparatus comprises: A connection initiating module, configured to initiate a Bluetooth connection request to the second device; A service information acquisition module, configured to acquire service information of a Bluetooth service supported by the second device from a locally stored preset file; wherein the preset file is used to store service information of a Bluetooth service supported by a preset device, and the preset device is a device that can interconnect with the first device; The connection completion module is configured to complete the Bluetooth connection with the second device.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method as claimed in any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 8.