WO2020132878A1 - 一种蓝牙服务的查询方法及电子设备 - Google Patents

一种蓝牙服务的查询方法及电子设备 Download PDF

Info

Publication number
WO2020132878A1
WO2020132878A1 PCT/CN2018/123556 CN2018123556W WO2020132878A1 WO 2020132878 A1 WO2020132878 A1 WO 2020132878A1 CN 2018123556 W CN2018123556 W CN 2018123556W WO 2020132878 A1 WO2020132878 A1 WO 2020132878A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
bluetooth
bluetooth service
service information
uuid
Prior art date
Application number
PCT/CN2018/123556
Other languages
English (en)
French (fr)
Inventor
唐能福
国珊珊
牛永民
李哲
索亚运
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201880098126.3A priority Critical patent/CN112789934B/zh
Priority to PCT/CN2018/123556 priority patent/WO2020132878A1/zh
Publication of WO2020132878A1 publication Critical patent/WO2020132878A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W74/00Wireless channel access, e.g. scheduled or random access
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Definitions

  • This application relates to the field of communication technology, and in particular, to a Bluetooth service query method and an electronic device.
  • the Bluetooth service is identified by a universally unique identifier (UUID).
  • UUID universally unique identifier
  • the Bluetooth services identified by different UUIDs are different.
  • electronic devices such as mobile phones and tablet computers need to query the Bluetooth service UUID list (service UUID list) of the peer Bluetooth device to determine which Bluetooth services the peer Bluetooth device supports.
  • the service UUID list of the peer Bluetooth device includes at least one UUID, and each UUID in the at least one UUID is used to identify a Bluetooth service supported by a peer Bluetooth device.
  • the service UUID list of the Bluetooth headset includes UUID1 and UUID2.
  • UUID1 is used to identify the Bluetooth audio transmission model agreement (advanced audio distribution profile, A2DP)
  • UUID2 is used to identify the hands-free profile (hands-free profile, HFP).
  • A2DP refers to a Bluetooth headset and a mobile phone connected via Bluetooth, which can be used as a microphone and earpiece of the mobile phone to make a voice call, or as a playback device of the mobile phone to play audio files on the mobile phone.
  • HFP means that after the Bluetooth headset and the mobile phone are connected via Bluetooth, they can control to answer, reject or hang up the call on the mobile phone, or control the use of the mobile phone to make calls.
  • the mobile phone queries the service UUID list of the peer Bluetooth device through application programs (such as system applications, third-party applications, etc.).
  • application programs such as system applications, third-party applications, etc.
  • the application sends a request to the Bluetooth chip in the mobile phone to query the Bluetooth service of the peer Bluetooth device.
  • the Bluetooth chip in the mobile phone After receiving the request to query the Bluetooth service of the peer Bluetooth device, the Bluetooth chip in the mobile phone The end Bluetooth device sends the query command of the Bluetooth service.
  • the Bluetooth chip of the peer Bluetooth device obtains the service UUID list, and returns the obtained service UUID list to the Bluetooth chip in the mobile phone.
  • the Bluetooth chip returns the received service UUID list from the peer Bluetooth device to the application.
  • the peer Bluetooth device may simultaneously receive the query command of the Bluetooth service from multiple applications, resulting in exceeding The processing capability of its own Bluetooth chip, which leads to abnormal connection between the mobile phone and the peer Bluetooth device.
  • the Bluetooth service query command may be frequently sent to the Bluetooth chip of the peer Bluetooth device, which may cause the peer Bluetooth device to disconnect from the phone for self-protection. Bluetooth connection.
  • this method of directly issuing a query command to the peer Bluetooth device to query the Bluetooth service is likely to cause an abnormal Bluetooth connection and reduce user experience.
  • Embodiments of the present application provide a Bluetooth service query method and an electronic device, which help to reduce the number of Bluetooth service queries to the peer Bluetooth device directly, thereby reducing the possibility of abnormal Bluetooth connection and improving user experience.
  • a method for querying a Bluetooth service provided by an embodiment of the present application is applied to a first electronic device, the first electronic device has a Bluetooth function enabled, and a first application program is installed; the method includes:
  • the first electronic device receives a scan result sent by at least one Bluetooth-enabled electronic device, and each scan result includes a device identification and at least one universal unique identification code UUID; each UUID is used to identify the electronic device identified by the device identification A Bluetooth service supported by the device; save the device identification and at least one UUID included in the received scan result as the first Bluetooth service information.
  • the first electronic device queries the Bluetooth service supported by the second electronic device from the first Bluetooth service information according to the identifier of the second electronic device .
  • the first electronic device since the first electronic device can query the Bluetooth service of the second electronic device from the stored first Bluetooth service information when requesting to query the Bluetooth service of the second electronic device, it helps to reduce the direct The number of times that the second electronic device queries the Bluetooth service through the chip transparent transmission, thereby helping to reduce the possibility that the Bluetooth connection may cause an abnormality due to too many queries to the second electronic device for the Bluetooth service.
  • the first Bluetooth service information is stored in the form of a database.
  • a database For example uuid.db. Helps simplify implementation.
  • the first electronic device when the first electronic device receives the scan result sent by the electronic device again, it receives The scan result sent by the electronic device updates the first Bluetooth service information. Thereby, it helps to improve the integrity of the stored first Bluetooth service information.
  • the scan result is an expanded demand result extended; result; and/or, when the Bluetooth-enabled electronic device is a low-power Bluetooth device , The scan result is a broadcast packet. Helps simplify implementation.
  • the first electronic device sends a pairing request to the electronic devices to be paired among the at least one Bluetooth-enabled electronic device; and receives the electronic device to be paired After the pairing request, a pairing success response is sent, where the pairing success response includes the identification of the electronic device to be paired and at least one UUID; then, the identification and at least one UUID of the electronic device to be paired included in the pairing successful response is saved Is the second Bluetooth service information.
  • the second Bluetooth service information is stored in the form of a configuration file.
  • bt_config.conf It is helpful to reduce the complexity of storing the second Bluetooth service information, and is easy to implement.
  • the first electronic device when the first electronic device detects that the first application program requests to query the Bluetooth service of the second electronic device, it may also query the Bluetooth supported by the second electronic device from the second Bluetooth service information Service; and the Bluetooth service supported by the second electronic device is queried from the first Bluetooth service information, and the Bluetooth service supported by the second electronic device is queried from the second Bluetooth service information to obtain the first 2. Bluetooth service supported by electronic devices. Therefore, the possibility that the first electronic device queries the Bluetooth service supported by the second electronic device from the pre-stored Bluetooth service information is increased.
  • the second electronic device and the first electronic device are in a paired state.
  • the Bluetooth service supported by the second electronic device is queried from the first Bluetooth service information according to the identifier of the third electronic device. It helps to save invalid signaling interaction inside electronic equipment.
  • the first application program is a third-party application.
  • the first electronic device when the first electronic device detects that the system application requests to query the Bluetooth service of the second electronic device, it queries the second electronic device from the second Bluetooth service information according to the identifier of the second electronic device Bluetooth service supported by the device.
  • the first electronic device when it does not query the Bluetooth service supported by the second electronic device from the first Bluetooth service information, or the first Bluetooth service information and the second Bluetooth service information, it may The second electronic device sends a query command of the Bluetooth service, or it can determine whether to send the query command of the Bluetooth service to the second electronic device according to the pairing state of the second electronic device and the first electronic device.
  • an embodiment of the present application provides a first electronic device, where the first electronic device has Bluetooth enabled; wherein, the first electronic device includes at least one processor, at least one memory, and a transceiver;
  • the memory stores a first application program and code instructions; the transceiver is used to receive or send data; when the processor invokes the code instructions stored in the memory, it executes in conjunction with the transceiver:
  • each scan result includes a device identifier and at least one universal unique Identification code UUID; each UUID is used to identify a Bluetooth service supported by the electronic device identified by the device identification.
  • the first Bluetooth service information is stored in the form of a database.
  • the code instruction further includes: for one of the at least one Bluetooth-enabled electronic device, when the scan result sent by the electronic device is received again, according to Receiving the scan result sent by the electronic device again, and updating the instruction of the first Bluetooth service information.
  • the scan result is an expanded demand result extended; result; and/or, when the Bluetooth-enabled electronic device is a low-power Bluetooth device , The scan result is a broadcast packet.
  • the code instruction further includes: an instruction for sending a pairing request to an electronic device to be paired among the at least one Bluetooth-enabled electronic device; for receiving the to-be-paired After receiving the pairing request, the electronic device sends an instruction of a pairing success response, where the pairing success response includes an identifier of the electronic device to be paired and at least one UUID; used for the pairing success received by the communication interface In response to the instruction including the identifier of the electronic device to be paired and at least one UUID saved as the second Bluetooth service information.
  • the second Bluetooth service information is stored in the form of a configuration file.
  • At least one memory includes a first memory and a second memory, wherein the first memory is used to store first Bluetooth service information, and the second memory is used to store second Bluetooth service information.
  • the first memory and the second memory may be the same memory or different memories, which is not limited.
  • the code instruction further includes: when it is detected that the first application request to query the Bluetooth service of the second electronic device, query the second electronic device for support from the second Bluetooth service information Instruction of the Bluetooth service of the server; and query the Bluetooth service supported by the second electronic device from the first Bluetooth service information, and query the Bluetooth service supported by the second electronic device from the second Bluetooth service information to take a union, Get an instruction of a Bluetooth service supported by the second electronic device.
  • the second electronic device and the first electronic device are in a paired state.
  • the code instructions further include: when it is detected that the first application requests to query the Bluetooth service of the third electronic device, if the third electronic device and the first electronic device are in In the unpaired state or the pairing state, according to the identifier of the third electronic device, an instruction of a Bluetooth service supported by the second electronic device is queried from the first Bluetooth service information.
  • the first application program is a third-party application.
  • the code instruction further includes: when detecting that the system application requests to query the Bluetooth service of the second electronic device, according to the identifier of the second electronic device, from the second Bluetooth service information Query the instruction of the Bluetooth service supported by the second electronic device.
  • the code instruction further includes: when the processor does not query the second electronic device for support from the first Bluetooth service information, or the first Bluetooth service information and the second Bluetooth service information During the Bluetooth service, send the instruction of the query command of the Bluetooth service to the second electronic device. Or, it is used to search for the Bluetooth service supported by the second electronic device from the first Bluetooth service information, or the first Bluetooth service information and the second Bluetooth service information, according to the location of the second electronic device and the first electronic device To determine whether to send an instruction of a Bluetooth service query command to the second electronic device through the communication interface.
  • an embodiment of the present application further provides a chip, and the interface is configured to receive code instructions and transmit the received code instructions to the processor;
  • the processor is configured to execute the received code instruction sent by the interface and execute:
  • Receive scan results sent by at least one Bluetooth-enabled electronic device each scan result includes the device ID and at least one universal unique identification code UUID; each UUID is used to identify a Bluetooth service supported by the electronic device identified by the device ID ;
  • the first Bluetooth service information is stored in the form of a database.
  • the code instruction further includes: for one of the at least one Bluetooth-enabled electronic device, when the scan result sent by the electronic device is received again, according to Receiving the scan result sent by the electronic device again, and updating the instruction of the first Bluetooth service information.
  • the scan result is an expanded demand result extended; result; and/or, when the Bluetooth-enabled electronic device is a low-power Bluetooth device , The scan result is a broadcast packet.
  • the code instruction further includes: an instruction for sending a pairing request to an electronic device to be paired among the at least one Bluetooth-enabled electronic device; for receiving the to-be-paired After receiving the pairing request, the electronic device sends an instruction of a pairing success response, where the pairing success response includes an identifier of the electronic device to be paired and at least one UUID; used for the pairing success received by the communication interface In response to the instruction including the identifier of the electronic device to be paired and at least one UUID saved as the second Bluetooth service information.
  • the second Bluetooth service information is stored in the form of a configuration file.
  • At least one memory includes a first memory and a second memory, wherein the first memory is used to store first Bluetooth service information, and the second memory is used to store second Bluetooth service information.
  • the first memory and the second memory may be the same memory or different memories, which is not limited.
  • the code instructions further include: for querying the second electronic device from the second Bluetooth service information when receiving the request of the first application to acquire the Bluetooth service of the second electronic device An instruction of a supported Bluetooth service; and querying for the Bluetooth service supported by the second electronic device from the first Bluetooth service information and querying the Bluetooth service supported by the second electronic device from the second Bluetooth service information To obtain the instruction of the Bluetooth service supported by the second electronic device.
  • the second electronic device and the first electronic device are in a paired state.
  • the code instruction further includes: when the first application receives a request to acquire the Bluetooth service of the third electronic device, if the third electronic device and the first electronic device In the unpaired state or the pairing state, according to the identifier of the third electronic device, query the Bluetooth service instruction supported by the second electronic device from the first Bluetooth service information.
  • the first application program is a third-party application.
  • the code instruction further includes: when receiving a request from the system application to acquire the Bluetooth service of the second electronic device, according to the identifier of the second electronic device, from the second Bluetooth service information To query the instruction of the Bluetooth service supported by the second electronic device.
  • the code instruction further includes: when the processor does not query the second electronic device for support from the first Bluetooth service information, or the first Bluetooth service information and the second Bluetooth service information During the Bluetooth service, send the instruction of the query command of the Bluetooth service to the second electronic device. Or, it is used to search for the Bluetooth service supported by the second electronic device from the first Bluetooth service information, or the first Bluetooth service information and the second Bluetooth service information, according to the location of the second electronic device and the first electronic device To determine whether to send an instruction of a Bluetooth service query command to the second electronic device through the communication interface.
  • a computer storage medium is also provided in an embodiment of the present application, and the computer storage medium stores program instructions, and the program instructions can implement the first aspect or any one of the first aspect when running on an electronic device Design the method provided.
  • FIG. 1 is a schematic flowchart of a query method for Bluetooth service in the prior art
  • FIG. 2 is an architecture diagram of a communication system according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a user interface according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of another user interface according to an embodiment of the present application.
  • FIG. 5 is a schematic diagram of an application scenario according to an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of a method for pre-storing a Bluetooth service according to an embodiment of the present application
  • FIG. 7 is a schematic flowchart of a method for inquiring a Bluetooth service according to an embodiment of the present application
  • FIG. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a chip according to an embodiment of the present application.
  • At least one refers to one or more, and “multiple” refers to two or more than two.
  • “And/or” describes the relationship of the related objects, indicating that there can be three relationships.
  • a and/or B can represent the following three relationships: A exists alone, A and B exist simultaneously, and B exists alone.
  • a and B can be singular or plural.
  • the character “/” generally indicates that the related object is a "or” relationship.
  • “At least one (item) of the following” or similar expressions refer to any combination of these items, including any combination of a single item (s) or a plurality of items (s).
  • At least one (a) of a, b, or c may represent: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c It can be single or multiple.
  • the embodiments of the present application can be applied to electronic devices that support the Bluetooth function.
  • the following describes an electronic device, a graphical user interface (GUI) for such an electronic device, and an embodiment for using such an electronic device.
  • the electronic device may be a portable electronic device, such as a mobile phone, a tablet computer, a wearable device with a wireless communication function (such as a smart watch), an in-vehicle device, and the like.
  • Exemplary embodiments of portable electronic devices include, but are not limited to Or portable electronic devices of other operating systems.
  • the above-mentioned portable electronic device may also be, for example, a laptop computer with a touch-sensitive surface (for example, a touch panel) or the like. It should also be understood that, in other embodiments of the present application, the electronic device may also be a desktop computer or the like with a touch-sensitive surface (such as a touch panel).
  • the electronic device 100 includes a processor 110, an internal memory 121, an external memory interface 122, an antenna 1, a mobile communication module 131, an antenna 2, a wireless communication module 132, an audio module 140, a speaker 140A, a receiver 140B, and a microphone 140C , Headset interface 140D, display screen 151, subscriber identification module (subscriber identification module, SIM) card interface 152, camera 153, button 154, sensor module 160, universal serial bus (USB) interface 170, charging management module 180. Power management module 181 and battery 182.
  • the electronic device 100 may further include a motor, an indicator, and the like.
  • the processor 110 may include an application processor (AP), a modem, a graphics processor (GPU), an image signal processor (ISP), a baseband processor, and a video codec , Digital signal processor (digital signal processor, DSP), neural network processor (neural-network processing unit, NPU), etc.
  • AP application processor
  • GPU graphics processor
  • ISP image signal processor
  • baseband processor a baseband processor
  • video codec Digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • different processing units may be independent devices, or may be integrated into one or more devices.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in the processor 110 may be a cache memory.
  • the memory may be used to store instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Therefore, it helps to avoid repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area may store an operating system, at least one function required application programs (such as sound playback function, image playback function) and so on.
  • the storage data area may store data (such as audio data, phone book) created during the use of the electronic device 100 and the like.
  • the application processor may call programs such as an operating system stored in the storage program area, thereby enabling the electronic device 100 to realize various functions and data processing.
  • the internal memory 121 may be a high-speed random access memory or a non-volatile memory, such as at least one disk storage device, flash memory device, universal flash memory (Universal Flash Storage (UFS), etc.).
  • the external memory interface 122 may be used to connect an external memory card (for example, a Micro SD card) to achieve expansion of the storage capacity of the electronic device 100.
  • an external memory card for example, a Micro SD card
  • Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the mobile communication module 131 may provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the electronic device 100.
  • the mobile communication module 131 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), and so on.
  • the mobile communication module 131 can receive the electromagnetic wave signal from the antenna 1 and filter, amplify, etc. the received electromagnetic wave signal, and transmit it to the modem for demodulation.
  • the mobile communication module 131 can also amplify the signal modulated by the modem and radiate it into an electromagnetic wave signal via the antenna 1.
  • the modem may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be transmitted into a high-frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low-frequency baseband signal is processed by the baseband processor and then passed to the application processor.
  • the application processor outputs a sound signal through an audio device (not limited to a speaker 140A, a receiver 140B, etc.), or displays an image or video through a display screen 151.
  • the wireless communication module 132 may provide a Bluetooth (BT) wireless communication solution applied to the electronic device 100.
  • the wireless communication module 132 can also provide wireless local area network (wireless local area network, WLAN) (such as wireless fidelity (WiFi) network), global navigation satellite system (global navigation satellite system, GNSS) that are applied to the electronic device 100 ), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR) and other wireless communication solutions.
  • the wireless communication module 132 may be a chip or module that integrates at least one wireless communication technology including Bluetooth. Among them, it should be noted that the chip or module used to implement the Bluetooth wireless communication technology may be simply referred to as a Bluetooth chip.
  • the Bluetooth chip may also be integrated in the processor 110, or some functions of the Bluetooth chip may be integrated in the processor 110.
  • the wireless communication module 132 receives the electromagnetic wave signal via the antenna 2, frequency-modulates and filters the electromagnetic wave signal, and sends the processed signal to the processor 110.
  • the wireless communication module 132 can also receive the signal to be transmitted from the processor 110, perform frequency modulation and amplification on it, and convert it to an electromagnetic wave signal via the antenna 2 to radiate it out.
  • the antenna 1 of the electronic device 100 and the mobile communication module 131 are coupled, and the antenna 2 and the wireless communication module 132 are coupled so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global mobile communication system (global system for mobile communications, GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division division multiple access, TD-SCDMA), long-term evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • GSM global system for mobile communications
  • GPRS general packet radio service
  • code division multiple access code division multiple access
  • CDMA broadband Code division multiple access
  • WCDMA wideband code division multiple access
  • time division code division multiple access time-division code division division multiple access
  • TD-SCDMA time-division code
  • the GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a beidou navigation system (BDS), and a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite-based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS beidou navigation system
  • QZSS quasi-zenith satellite system
  • SBAS satellite-based augmentation systems
  • the electronic device 100 may implement audio functions through an audio module 140, a speaker 140A, a receiver 140B, a microphone 140C, a headphone interface 140D, an application processor, and the like. For example, music playback, recording, etc.
  • the audio module 140 may be used to convert digital audio information into an analog audio signal output, and also used to convert an analog audio input into a digital audio signal.
  • the audio module 140 can also be used to encode and decode audio signals.
  • the audio module 140 may be disposed in the processor 110, or some functional modules of the audio module 140 may be disposed in the processor 110.
  • the speaker 140A also known as a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 140A or answer hands-free calls.
  • the receiver 140B also known as "handset" is used to convert audio electrical signals into sound signals.
  • the user uses the electronic device 100 to answer a call, the user can answer the voice received through the mobile communication module 131 or the wireless communication module 132 by bringing the human ear close to the receiver 140B.
  • the microphone 140C also called “microphone”, “microphone”, is used to convert sound signals into electrical signals.
  • the user uses the electronic device 100 to make a call or send a voice, the user can make the sound close to the microphone 140C, so that the microphone 140C can be used to collect the user's voice, and then convert the user's voice into an electrical signal.
  • the electronic device 100 may be provided with at least one microphone 140C. In some embodiments, the electronic device 100 may be provided with two microphones 140C. In addition to collecting sound signals, it may also implement a noise reduction function. In other embodiments, the electronic device 100 may also be provided with three, four, or more microphones 140C, to achieve sound signal collection, noise reduction, and also to identify the sound source, to achieve the directional recording function, and so on.
  • the headset interface 140D is used to connect wired headsets.
  • the earphone interface 140D may be a USB interface 170, or a 3.5mm open mobile electronic device 100 platform (open mobile terminal) platform (OMTP) standard interface, the American cellular telecommunications industry association (cellular telecommunications industry association of the United States, CTIA) standard interface Wait.
  • OMTP open mobile electronic device 100 platform
  • CTIA American cellular telecommunications industry association of the United States, CTIA
  • the electronic device 100 can realize a display function through a GPU, a display screen 151, an application processor, and the like.
  • the GPU is a microprocessor for image processing, and connects the display screen 151 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations, and is used for graphics rendering.
  • the processor 110 may include one or more GPUs that execute code instructions to generate or change display information.
  • the display screen 151 can be used to display images, videos, and the like.
  • the display screen 151 may include a display panel.
  • the display panel may use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active matrix organic light-emitting diode (active-matrix organic light) emitting diodes (AMOLED), flexible light-emitting diodes (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (QLED), etc.
  • the electronic device 100 may include 1 or N display screens 151, where N is a positive integer greater than 1.
  • the electronic device 100 can realize a shooting function through an ISP, a camera 153, a video codec, a GPU, a display screen 151, an application processor, and the like.
  • the key 154 may include a power-on key, a volume key, and the like.
  • the key 154 may be a mechanical key. It can also be a touch button.
  • the electronic device 100 can receive key input and generate key signal input related to user settings and function control of the electronic device 100.
  • the sensor module 160 may include one or more sensors. For example, touch sensor 160A, fingerprint sensor 160B, gyro sensor 160C, pressure sensor 160D, acceleration sensor 160E, and the like. In some embodiments, the sensor module 160 may further include an environment sensor, a distance sensor, a proximity light sensor, a bone conduction sensor, and the like.
  • the touch sensor 160A may be disposed on the display screen 151, and the touch sensor 160A and the display screen 151 constitute a touch screen, also referred to as a "touch screen".
  • the touch sensor 160A is used to detect a touch operation acting on or near it.
  • the touch sensor 160A may pass the detected touch operation to the application processor to determine the type of touch event.
  • the visual output related to the touch operation can be provided through the display screen 151.
  • the touch sensor 160A may also be disposed on the surface of the electronic device 100, which is different from the location where the display screen 151 is located.
  • the fingerprint sensor 160B can be used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access to application locks, fingerprint taking pictures, fingerprint answering calls, and the like.
  • the gyro sensor 160C may be used to determine the movement posture of the electronic device 100, to shoot anti-shake, navigation, somatosensory game scenes, and the like.
  • the pressure sensor 160D is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the pressure sensor 160D may be provided on the display screen 151.
  • the acceleration sensor 160E can detect the magnitude of the acceleration of the terminal in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used for recognizing the posture of the electronic device 100, and used in applications such as horizontal and vertical screen switching, pedometers and the like.
  • the processor 110 may also include one or more interfaces.
  • the interface may be a SIM card interface 152.
  • the interface may also be a USB interface 170.
  • the interface may also be an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit integrated audio (inter-integrated circuit, sound, I2S) interface, a pulse code modulation (pulse code modulation (PCM) interface, a universal asynchronous transceiver transmission (Universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry interface), general-purpose input/output (GPIO) interface, etc.
  • the processor 110 may be connected to different modules of the electronic device 100 through an interface, so that the electronic device 100 can implement different functions. For example, taking pictures and processing. It should be noted that the embodiment of the present application does not limit the connection method of the interface in the electronic device 100.
  • the SIM card interface 152 may be used to connect a SIM card.
  • the SIM card can be inserted into or removed from the SIM card interface 152 to achieve contact and separation with the electronic device 100.
  • the electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 152 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 152 at the same time. The types of the multiple cards may be the same or different.
  • the SIM card interface 152 can also be compatible with different types of SIM cards.
  • the SIM card interface 152 can also be compatible with external memory cards.
  • the electronic device 100 interacts with the network through a SIM card to realize functions such as call and data communication.
  • the electronic device 100 may also use eSIM, that is, an embedded SIM card.
  • eSIM embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
  • the electronic device 100 can access a cellular network through the SIM card inserted in the SIM card interface 152.
  • the electronic device 100 can access a cellular network through the two SIM cards inserted in the SIM card interface 152, respectively.
  • the USB interface 170 is an interface conforming to the USB standard specification.
  • the USB interface 170 may include a Mini USB interface, a Micro USB interface, a USB Type C interface, and so on.
  • the USB interface 170 can be used to connect a charger to charge the electronic device 100, can also be used to transfer data between the electronic device 100 and peripheral devices, and can also be used to connect a headset to play audio through the headset.
  • the charging management module 180 is used to receive charging input from the charger.
  • the charger can be a wireless charger or a wired charger.
  • the charging management module 180 may receive the charging input of the wired charger through the USB interface 170.
  • the charging management module 180 may receive wireless charging input through the wireless charging coil of the electronic device 100. While the charging management module 180 charges the battery 182, it can also supply power to the electronic device 100 through the power management module 181.
  • the power management module 181 is used to connect the battery 182, the charging management module 180, and the processor 110.
  • the power management module 181 receives input from the battery 182 and/or the charging management module 180, and supplies power to the processor 110, internal memory 121, external memory, display screen 151, camera 153, mobile communication module 131, wireless communication module 132, and the like.
  • the power management module 181 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters.
  • the power management module 181 may also be disposed in the processor 110.
  • the power management module 181 and the charging management module 180 may also be set in the same device.
  • the hardware structure of the electronic device 100 shown in FIG. 2 is only an example.
  • the electronic device of the embodiment of the present application may have more or less components than shown in the figure, may combine two or more components, or may have different component configurations.
  • the various components shown in the figures may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
  • the following takes the hardware structure of the electronic device 100 shown in FIG. 2 as an example to describe in detail the embodiments of the present application.
  • the electronic device 100 generally provides various functions to users through application programs.
  • the application program may be a system application (also called a native application) or a third-party application.
  • system application also called a native application
  • third-party application For example, drawing, presentation, word processing, games, phone, video player, music player, email, instant messaging, photo management, camera, browser, calendar, clock, payment, application market, desktop and health management, etc. application.
  • the electronic device 100 in the embodiment of the present application may simultaneously run multiple application programs.
  • FIG. 3a is a schematic diagram of a graphical user interface according to an embodiment of the present application.
  • the graphical user interface is simply referred to as a user interface.
  • the electronic device 100 displays the user interface through the display screen 151.
  • the user interface may be a main interface, a negative one screen, or a user interface of an application.
  • the main interface may be the user interface 300 shown in FIG. 3a.
  • the user interface 300 may include a status bar 301, a time and weather Widget 302, a hideable navigation bar 303, and icons of multiple applications such as a setting icon 304.
  • the status bar 301 may include the name of the operator (China Mobile), mobile network (for example, 4G), time and remaining power. In some other embodiments of the present application, the status bar 301 may include the name of the operator (China Mobile), the signal strength of the mobile network, time, and remaining power. In some other embodiments of the present application, the status bar 301 may further include one or more of a Bluetooth icon, a WiFi icon, a screen lock icon, an external device icon, and so on. For example, taking the Bluetooth icon as an example, in the embodiment of the present application, the electronic device 100 may display the Bluetooth icon in the status bar 301 after the Bluetooth function is turned on, and may not display the Bluetooth icon in the status bar 301 when the Bluetooth function is turned off.
  • the navigation bar 303 may include a back button, a home button, and a historical task viewing button (menu button). It can also be understood that, in some other embodiments, the user interface 300 may further include a Dock bar.
  • the Dock bar can include icons of commonly used applications, such as phone icons, short message icons, mail icons, and weather icons. It should be understood that the user can set the icons of frequently used applications in the Dock bar according to their own needs.
  • the electronic device 100 may further include a home screen key 305.
  • the home screen key 305 may be a physical key or a virtual key.
  • the home screen key 305 is used to return the user interface of an application displayed on the display screen 151 or the negative one screen and other user interfaces to the main interface according to the user's operation, so that the user can easily view the main interface at any time Controls (such as icons, etc.) to operate.
  • the above operation may specifically be that the user presses the home screen key 305.
  • the home screen key 305 may also integrate a fingerprint sensor 160B, so that when the user presses the home screen key 305, the electronic device 100 can collect fingerprints to confirm the user's identity.
  • the electronic device 100 may not include the home screen key 305.
  • the electronic device 100 may display the system setting interface on the display screen 151 in response to the user's touch operation on the setting icon 304.
  • the system setting interface includes various function buttons for setting the electronic device 100 accordingly.
  • the system setting interface may be a user interface 310 as shown in FIG. 3b, including a Bluetooth button 311.
  • the user interface 310 may also include function buttons such as account login, cloud backup activation, and screen lock.
  • the electronic device 100 may display the Bluetooth setting interface on the display screen 151 in response to the user's operation of the Bluetooth button 311.
  • the Bluetooth setting interface is used to turn on or off the Bluetooth function.
  • the Bluetooth setting interface may be the user interface 320 shown in FIG. 3c.
  • the user interface 320 includes a Bluetooth button 321, and the Bluetooth button 321 is in an OFF state.
  • the Bluetooth button 321 is in the off state, the Bluetooth function of the electronic device 100 is not turned on.
  • the electronic device 100 may turn on the Bluetooth button 321 in response to the user operating the Bluetooth button 321, thereby turning on the Bluetooth function.
  • the electronic device 100 may also respond to the user's pull-down or pull-up operation when the display screen 151 displays a certain user interface (for example, the user interface 300) after locking or unlocking.
  • the screen 151 displays a quick setting user interface.
  • the shortcut setting interface includes shortcut buttons for setting various functions, such as shortcut buttons for turning on or off the Bluetooth function, and so on.
  • the quick setting user interface may be the user interface 400 shown in FIG. 4.
  • the user interface 400 includes a Bluetooth button 401.
  • the electronic device 100 may turn on or off the Bluetooth function in response to the user's operation of the Bluetooth button 401.
  • the Bluetooth function is not turned on
  • the electronic device 100 can turn on the Bluetooth function in response to the user's operation of the Bluetooth button 401.
  • the Bluetooth function when the Bluetooth function is turned on, the electronic device 100 may turn off the Bluetooth function in response to the user's operation of the Bluetooth button 401.
  • the user interface 400 may also include function buttons such as WiFi, personal hotspot, flight mode, do not disturb, ringing, mobile data, brightness adjustment, etc., so that the user can quickly set the corresponding function.
  • function buttons such as WiFi, personal hotspot, flight mode, do not disturb, ringing, mobile data, brightness adjustment, etc.
  • the electronic device 100 may also turn on or off the Bluetooth function through other methods, such as voice commands, shortcut gesture operations, etc., which is not limited.
  • the electronic device 100 can be used as a slave device to be discovered by a nearby electronic device with the Bluetooth function turned on, or as a master device to find a nearby electronic device with the Bluetooth function turned on .
  • the electronic device 100 and the electronic device 200 can scan and discover each other, thereby establishing Bluetooth connection.
  • the following takes the electronic device 100 as a master device and the electronic device 200 as a slave device as an example to describe the process of establishing a Bluetooth connection between the electronic device 100 and the electronic device 200.
  • the electronic device 100 After the Bluetooth function is turned on, the electronic device 100 performs a device scanning process to find nearby electronic devices with the Bluetooth function turned on.
  • the user interface 320 displayed on the display screen 151 may include prompt information, a list of available devices, and the like of the electronic device 100 currently discoverable by nearby Bluetooth devices.
  • the list of available devices includes at least one device identifier, and each device identifier is used to identify an electronic device that has been turned on by the electronic device 100 and has a Bluetooth function turned on nearby, thereby helping to prompt the user.
  • the device identification may include one or more of a device name, device type, or media access control (media access control (MAC) address, etc.
  • MAC media access control
  • device types may include mobile phones, Bluetooth headsets, Bluetooth mice, tablet computers, laptop computers, desktop computers, display screens, Bluetooth keyboards, Bluetooth printers, Bluetooth fax machines, and so on.
  • the device type may be presented to the user in the available device list 322 in the form of graphics or text.
  • the device name may be a device model or a user setting, which is not limited. For example, if the electronic device 100 scans and finds the electronic device a, the electronic device 200, and the electronic device b, where the identification of the electronic device a is Sql, the identification of the electronic device 200 is 200, and the identification of the electronic device b is Watch, the electronic device 100 displays The user interface 320 may be as shown in FIG. 3d, and the available device list 322 includes Sql, 200, and Watch.
  • the available device list 322 can be updated according to the electronic devices found by the electronic device 100 in scanning.
  • the electronic device 100 may perform the device scanning process in the following manner:
  • Method 1 The electronic device 100 as the master device broadcasts the scan request after the Bluetooth function is turned on, and the nearby electronic device with the Bluetooth function turned on (for example, the electronic device 200) as the slave device can send the scan request to the electronic device 100 after receiving the scan request The response is scanned, so that the electronic device 100 finds a nearby electronic device with the Bluetooth function turned on.
  • the nearby electronic device with the Bluetooth function turned on for example, the electronic device 200
  • Method 2 As the master device, after the Bluetooth function is turned on, the electronic device 100 can receive a broadcast message from a nearby electronic device (slave device) with the Bluetooth function turned on, without sending a scan request.
  • nearby electronic devices with Bluetooth enabled can periodically broadcast messages, which is helpful for other electronic devices with Bluetooth enabled.
  • the electronic device 100 receives a broadcast message from the electronic device 200, and scans to find the electronic device 200.
  • the electronic device 100 establishes a physical link with the electronic device 200 when the electronic device 200 is found by scanning.
  • the electronic device 100 after scanning and discovering the electronic device 200, the electronic device 100 performs a device pairing process to pair with the electronic device 200. Specifically, after scanning and discovering the electronic device 200, the electronic device 100 may send a pairing request to the electronic device 200. After receiving the pairing request from the electronic device 100, the electronic device 200 performs device authentication on the electronic device 100 and passes the device authentication After that, the pairing success response is sent to the electronic device 100, so that the electronic device 100 establishes a logical link control and adaptation protocol (L2CAP) channel with the electronic device 200. For example, if the electronic device 100 has not established a Bluetooth connection with the electronic device 200, it may send a pairing request to the electronic device 200 in response to the user selecting the identification of the electronic device 200 in the list of available devices.
  • L2CAP logical link control and adaptation protocol
  • the electronic device 100 may automatically send a pairing request to the electronic device 200.
  • the electronic device 100 may also be triggered to send a pairing request to the electronic device 200 in other ways, which is not limited.
  • the electronic device 100 may stop the device scanning process in response to triggering the operation of sending a pairing request to the electronic device 200, or may continue to perform the device scan after the electronic device 100 has turned on the Bluetooth function In the process, until the electronic device 100 turns off the Bluetooth function, the device scanning process is no longer performed.
  • the Bluetooth service supported by the electronic device 200 needs to be queried to enable the establishment of the Bluetooth connection between the electronic device 100 and the electronic device 200 .
  • the Bluetooth services supported by different types of electronic devices in the embodiments of the present application may be the same or different.
  • the supported Bluetooth services may include A2DP, HFP, and audio/video remote control protocol (audio/video remote control profile, AVRCP), headset application model (headset profile, HSP), and so on.
  • the electronic device 100 interacts with the electronic device 200 through a service discovery protocol (SDP), so that the electronic device 100 can directly send Bluetooth to the Bluetooth chip of the electronic device 200 through its own Bluetooth chip
  • SDP service discovery protocol
  • the query command of the service to obtain the service UUID list of the electronic device 200.
  • This method of querying the Bluetooth service through transparent transmission of the chip may easily cause an abnormality in the Bluetooth connection between the electronic device 100 and the electronic device 200.
  • the embodiment of the present application provides a method for querying the Bluetooth service, which can be
  • the information of the Bluetooth service supported by the electronic device in the electronic device 100 is stored in advance, so that when an application installed in the electronic device 100 requests to query the Bluetooth service supported by an electronic device, the application stored in the electronic device 100 can
  • the Bluetooth service information supported by the device is queried, which helps to reduce the number of times that the peer electronic device is directly queried for the Bluetooth service, and to a certain extent, it also helps to improve the efficiency of the Bluetooth service query.
  • a method for pre-storing Bluetooth service information of an electronic device includes the following steps.
  • Step 601 after the Bluetooth function is enabled on the electronic device 100, at least one scan result is received, wherein each scan result is sent by the electronic device with the Bluetooth function enabled near the electronic device 100, and the scan result includes information on the Bluetooth service supported by the electronic device 100 .
  • the information of the Bluetooth service supported by the electronic device includes a device identification and at least one UUID.
  • the device identification is information used to identify the electronic device, such as one or more of device type, device name, media access control (media access control (MAC) address, and other information.
  • the scan result sent by the electronic device 200 includes Bluetooth service information supported by the electronic device 200, such as the identification of the electronic device 200, and at least one UUID supported by the electronic device 200. It should be understood that, when the electronic device 100 receives the scan result sent by the electronic device 200, the electronic device 100 scans and discovers the electronic device 200, and the identifier of the electronic device 200 may be added to the list of available devices and presented to the user.
  • the scan result may be a message already in the device scanning process, such as a scan response, a broadcast message, and so on.
  • the implementation form of the scan result may also be different.
  • the scan result may be an extended demand result (Extended Inquiry Results)
  • extended Inquiry Results Extended Inquiry Results
  • BLE low-power Bluetooth
  • the scan result may be a broadcast packet.
  • the scan result can also be a newly defined message.
  • the processor 110 detects that the Bluetooth function is turned on, it sends a device scan command to the wireless communication module 132 (for example, Bluetooth chip).
  • the wireless communication module 132 receives Scan results sent by at least one electronic device.
  • the wireless communication module 132 may also broadcast a scan request.
  • Some electronic devices in the at least one nearby electronic device may send the scan result to the wireless communication module 132 in response to receiving the scan request.
  • Some of the at least one nearby electronic device can also broadcast the scan result without receiving the scan request after the Bluetooth function is turned on.
  • At least one nearby electronic device may periodically broadcast the scan result.
  • the period of broadcasting scan results can be set according to the actual situation. Therefore, it is helpful to be scanned and found by other electronic devices with the Bluetooth function turned on.
  • the electronic device 100 obtains and saves information of at least one Bluetooth service supported by the electronic device from at least one scan result.
  • the information of the Bluetooth service supported by at least one electronic device can be stored in the form of a database.
  • the information of the Bluetooth service supported by at least one electronic device can be saved as a database uuid.db, or it can be saved in other storage forms. limited.
  • the wireless communication module 132 obtains the information of the Bluetooth service supported by the at least one electronic device from the at least one scan result, and stores the information of the Bluetooth service supported by the at least one electronic device in a corresponding storage form Store to the corresponding memory.
  • the wireless communication module 132 may store the information of the Bluetooth service supported by at least one electronic device in the internal memory 121, the external memory connected to the external memory interface 122, the memory provided in the functional module such as the processor 110 or the wireless communication module 132, etc. In one or more memories.
  • the electronic device 100 receives the scan result 1, the scan result 2, and the scan result 3, wherein the scan result 1 includes information of the Bluetooth service supported by the electronic device a, such as the device identification a, UUID1 and UUID2, and the scan result 2 includes the electronic
  • the scan result 3 includes the information of the Bluetooth service supported by the electronic device c, such as the device identifier c, UUID2.
  • UUID1, UUID2, and UUID3 are respectively used to indicate a Bluetooth service, then the electronic device 100 obtains and saves information of at least one Bluetooth service supported by the electronic device from the scan result 1, the scan result 2, and the scan result 3 as shown in the table 1 shown.
  • the electronic device 100 when the electronic device 100 receives the scan result sent by the electronic device 200 again, it can update the saved information of at least one Bluetooth service supported by the electronic device according to the scan result sent by the electronic device 200 received again.
  • Information of the Bluetooth service supported by the electronic device 200 For example, if the scan result sent by the electronic device 200 received by the electronic device 100 again includes the device identifier b, UUID1, UUID3, and UUID4, you can update the electronics shown in Table 1 by adding UUID1 and UUID4 to service UUID list2 Information about the Bluetooth service supported by the device.
  • the information of the Bluetooth service supported by the updated electronic device may be as shown in Table 2.
  • the electronic device 100 after saving the information of the Bluetooth service supported by the electronic device shown in Table 1, if the electronic device 100 receives the scan result sent by the electronic device d, it can update the saved electronic device according to the scan result sent by the electronic device d Supported Bluetooth service information. For example, if the scan result sent by the electronic device d includes the device identifier 4, UUID1, and UUID4, the information of the Bluetooth service supported by the electronic device d can be added to the information of the Bluetooth service supported by the electronic device as shown in Table 1. The information of the Bluetooth service supported by the updated electronic device may be as shown in Table 3.
  • Step 603 The electronic device 100 sends a pairing request to one or more electronic devices in at least one electronic device discovered by scanning, wherein the electronic device 100 triggers sending a pairing request to one or more electronic devices in at least one electronic device discovered by scanning
  • the electronic device 100 triggers sending a pairing request to one or more electronic devices in at least one electronic device discovered by scanning
  • Step 604 One or more of the at least one electronic device found in the scan receives the pairing request sent by the electronic device 100, and then authenticates the electronic device 100. After the authentication is passed, a pairing success response is sent to the electronic device 100.
  • the pairing success response includes information of the Bluetooth service supported by the electronic device.
  • the information of the Bluetooth service supported by the electronic device includes the device identification and at least one UUID.
  • Step 605 After receiving at least one pairing success response, the electronic device 100 obtains and saves information of at least one Bluetooth service supported by the electronic device from the at least one pairing success response.
  • the processor 110 sends a pairing notification with the electronic device 200 to the wireless communication module 132, and after receiving the pairing notification with the electronic device 200, the wireless communication module 132 sends a notification to the electronic device 200 Send a pairing request.
  • the electronic device 200 authenticates the electronic device 100 and sends a pairing success response to the electronic device 100 after the authentication is passed.
  • the pairing success response includes information of at least one Bluetooth service supported by the electronic device 200.
  • the pairing success response includes the identification of the electronic device 200 and at least one UUID.
  • Each UUID is used to identify a Bluetooth service supported by an electronic device 200.
  • the wireless communication module 132 obtains information of at least one Bluetooth service supported by the electronic device 200 from the pairing success response, and stores it in a corresponding storage in a corresponding memory.
  • the electronic device 100 may acquire the information of at least one Bluetooth service supported by the electronic device 200 from the pairing success response in the form of a configuration file (for example, bt_config.conf) to the internal memory 121 and the external memory connected to the external memory interface 122 , One or more of the memories provided in the processor 110 or the wireless communication module 132.
  • a configuration file for example, bt_config.conf
  • the information of the Bluetooth service supported by the electronic device 200 is stored in the electronic device 100.
  • the electronic device 100 can be received
  • the information of the Bluetooth service supported by the electronic device 200 is no longer obtained from the pairing success response, and the information of the Bluetooth service supported by the electronic device 200 may continue to be obtained from the pairing success response and may be obtained according to
  • the information of the Bluetooth service supported by the electronic device 200 updates the stored information of the Bluetooth service supported by the electronic device 200.
  • the stored information of the Bluetooth service supported by the electronic device 200 is shown in Table 4.
  • the device identifier b is the identifier of the electronic device 200, and UUID1, UUID2, and UUID3 are respectively used to indicate a Bluetooth service supported by the electronic device 200.
  • the pairing successful response sent by the electronic device 200 is received. If the pairing successful response still includes the device identifier b, UUID1, UUID2, and UUID3, the stored electronic device 200 is not supported.
  • the Bluetooth service information is updated. If the device ID b, UUID1, UUID2, and UUID4 are still included in the successful pairing response, the stored information of the Bluetooth service supported by the electronic device 200 is updated, and specifically, UUID4 is added to the stored Bluetooth service supported by the electronic device 200 In the information, the information of the Bluetooth service supported by the updated electronic device 200 may be as shown in Table 5.
  • the method for pre-storing the Bluetooth service information of the electronic device shown in FIG. 6 is only an example.
  • the electronic device 100 may also save only the Bluetooth service supported by the electronic device included in the scan result. Information, without saving the information of the Bluetooth service supported by the electronic device included in the pairing success response; or, the electronic device 100 may not save the information of the Bluetooth service supported by the electronic device included in the scan result, but only save the information included in the pairing success response Information of Bluetooth services supported by your electronic device.
  • the electronic device 100 when the electronic device 100 saves both the information of the Bluetooth service supported by the electronic device included in the scan result and the information of the Bluetooth service supported by the electronic device included in the pairing success response, the electronic device 100 may scan The result includes information about the Bluetooth service supported by the electronic device and information about the Bluetooth service supported by the electronic device included in the pairing success response. It should be understood that when the scan result includes the information of the Bluetooth service supported by the electronic device and the information of the Bluetooth service supported by the electronic device included in the pairing success response, the Bluetooth service information and the pairing supported by the electronic device included in the scan result The information storage location and storage form of the Bluetooth service supported by the electronic device included in the successful response are the same.
  • the electronic device 100 receives the scan result sent by the electronic device 200, and the scan result includes the device identifier b, UUID1, and UUID2.
  • the electronic device 100 saves the information of the Bluetooth service supported by the electronic device 200 according to the scan result as shown in Table 6.
  • the electronic device 100 receives the pairing success response of the electronic device 200, and the pairing success response includes the device identifier b, UUID1, UUID2, UUID3, and UUID4, the electronic device 100 updates the table 6 according to the pairing success response of the electronic device 200.
  • the information of the Bluetooth service supported by the electronic device 200 and the updated information of the Bluetooth service supported by the electronic device 200 are shown in Table 7.
  • the electronic device 100 when the electronic device 100 saves both the information of the Bluetooth service supported by the electronic device included in the scan result and the information of the Bluetooth service supported by the electronic device included in the pairing success response, the electronic device 100
  • the information of the Bluetooth service supported by the electronic device included in the scan result and the information of the Bluetooth service supported by the electronic device included in the pairing success response may be stored separately.
  • the electronic device 100 receives the scan result sent by the electronic device 200, and the scan result includes the device identifier b, UUID1, and UUID2.
  • the electronic device 100 saves the information of the Bluetooth service supported by the electronic device 200 according to the scan result as shown in Table 8.
  • the electronic device 100 receives the pairing success response of the electronic device 200, and the pairing success response includes the device identifier b, UUID1, UUID2, UUID3, and UUID4, the electronic device 100 saves the Bluetooth service supported by the electronic device 200 according to the pairing success response
  • the information is shown in Table 9.
  • the information of the Bluetooth service supported by the electronic device 200 shown in Table 8 may be stored in the memory 1 in the first storage form
  • the information of the Bluetooth service supported by the electronic device 200 shown in Table 9 may be stored in the second storage form In memory 2.
  • the first storage form and the second storage form may be different.
  • the first storage form may be a database
  • the second storage form may be a configuration file
  • the first storage form and the second storage form may also be the same.
  • the memory 1 and the memory 2 may be the same or different.
  • the information of the Bluetooth service supported by the electronic device pre-stored in the electronic device 100 may also be stored before the electronic device 100 leaves the factory.
  • the information of the Bluetooth service supported by the electronic device device pre-stored in the electronic device 100 may include the device type and at least one UUID corresponding to the device type.
  • the information of the Bluetooth service supported by the electronic device pre-stored in the electronic device 100 may be as shown in Table 10.
  • an embodiment of the present application provides a method for querying a Bluetooth service.
  • FIG. 7 it is a schematic flowchart of a method for querying a Bluetooth service provided by an embodiment of the present application. It includes the following steps.
  • step 701 the electronic device 100 detects that the first application requests to obtain the Bluetooth service of the electronic device 200.
  • step 702 the electronic device 100 queries the Bluetooth service supported by the electronic device 200 from pre-stored information of the Bluetooth service supported by the electronic device according to the identifier of the electronic device 200.
  • the first application program may be a system application (such as system settings, etc.) or a third-party application (such as WeChat, Youku video, etc.), which is not limited. In other embodiments, the first application is a third-party application.
  • the system application requests to obtain the Bluetooth service of the electronic device 200
  • the electronic device 100 may use the query method of the Bluetooth service in the prior art to obtain.
  • the processor 110 for example, an application processor
  • the processor 110 may call the interface of the first application program and send the acquired electronic device to the wireless communication module 132 (for example, a Bluetooth chip). Request for Bluetooth service of device 200.
  • the wireless communication module 132 receives the request for acquiring the Bluetooth service of the electronic device 200 sent by the processor 110 through the interface of the first application program, and then according to the identification of the electronic device 200, the Bluetooth service supported by the electronic device pre-stored in the corresponding memory In the information, the Bluetooth service of the electronic device 200 is acquired, and the acquired Bluetooth service of the electronic device 200 is returned to the processor 110 through the interface of the first application program.
  • the electronic device 100 may first detect the pairing state of the electronic device 200 and the electronic device 100.
  • step 702 is performed again.
  • the electronic device 200 and the electronic device 100 are in a pairing state, they can wait for the electronic device 200 and the electronic device 100 to be paired successfully, and then perform step 702 .
  • the step of querying the Bluetooth service supported by the electronic device 200 may no longer be performed, thereby helping to reduce signaling processing of the electronic device 100.
  • the wireless communication module 132 may first detect the pairing status of the electronic device 100 and the electronic device 200, and then The pairing state between the electronic device 100 and the electronic device 200 determines whether to perform the step of querying the Bluetooth service supported by the electronic device 200.
  • the electronic device 100 may send a query command of the Bluetooth service to the electronic device 200 when the Bluetooth service of the electronic device 200 is not acquired from the information of the Bluetooth service supported by the electronic device pre-stored in the corresponding memory. Therefore, it is helpful to increase the possibility that the electronic device 100 obtains the Bluetooth service supported by the electronic device 200 successfully.
  • the query command of the Bluetooth service sent by the electronic device 100 to the electronic device 200 may be an SDP command.
  • the wireless communication module 132 when it does not acquire the Bluetooth service of the electronic device 200 from the information of the Bluetooth service supported by the electronic device pre-stored in the corresponding memory, it may directly send the inquiry command of the Bluetooth service to the electronic device 200, or A notification of query failure is sent to the processor 110 through the interface of the first application program, and the processor 110 determines whether the wireless communication module 132 sends a query command of the Bluetooth service to the electronic device 200.
  • the strategy for the processor 110 to determine whether the wireless communication module 132 sends the Bluetooth query command to the electronic device 200 can be set according to actual conditions.
  • the electronic device 100 uses the method shown in FIG. 6 to pre-store the information of the Bluetooth service supported by the electronic device, and the scan result and the information of the Bluetooth service supported by the electronic device included in the pairing success response are stored separately, in During specific implementation, the electronic device 100 may also query the Bluetooth service of the electronic device 200 in other ways.
  • the first application program requests to query the Bluetooth service of the electronic device 200 for detailed description.
  • the electronic device 100 detects that the first application requests to obtain the Bluetooth service of the electronic device 200, and determines whether to query from uuid.d or bt_config.conf according to the pairing state of the electronic device 200 and the electronic device 100 Bluetooth service supported by the electronic device 200.
  • the first application program may be a system application or a third-party application, which is not limited.
  • the electronic device 100 detects that the first application requests to obtain the Bluetooth service of the electronic device 200
  • the first application is a third-party application, according to the electronic device 200 and the electronic device 100 In the pairing state, it is determined whether to query the Bluetooth service supported by the electronic device 200 from uuid.d or bt_config.conf.
  • the electronic device 100 detects that the first application requests to obtain the Bluetooth service of the electronic device 200, if the first application is a system application, it can directly query the Bluetooth service supported by the electronic device 200 from bt_config.conf .
  • the electronic device 100 determines whether to query the Bluetooth service supported by the electronic device 200 from uuid.d or bt_config.conf according to the pairing state of the electronic device 200 and the electronic device 100.
  • the electronic device 100 can query the Bluetooth service supported by the electronic device 200 from uuid.db and the Bluetooth service supported by the electronic device 200 from bt_config.conf when the electronic device 200 and the electronic device 100 are in a paired state, and The Bluetooth service supported by the electronic device 200 queried from uuid.db and the Bluetooth service supported by the electronic device 200 from bt_config.conf are combined to obtain the Bluetooth service supported by the electronic device 200.
  • the wireless communication module 132 can query the Bluetooth service supported by the electronic device 200 from uuid.db and the Bluetooth service supported by the electronic device 200 from bt_config.conf , And the Bluetooth service supported by the electronic device 200 queried from uuid.db, and the Bluetooth service supported by the electronic device 200 from bt_config.conf, and then the union of the electronic device 200 after the union
  • the Bluetooth service is returned to the processor 110.
  • the wireless communication module 132 may return the Bluetooth service supported by the electronic device 200 after the union is returned to the processor 110 through the interface of the first application program, or the wireless communication module 132 may acquire the unionized service through intent broadcast.
  • the processor 110 calls the interface of the first application program to monitor the intent broadcast to receive the Bluetooth service supported by the electronic device 200 after the union.
  • the electronic device 100 may query the bluetooth service supported by the electronic device 200 from uuid.db.
  • the wireless communication module 132 may query the bluetooth service supported by the electronic device 200 from uuid.db, and then query the electronic device through the interface of the first application program.
  • the Bluetooth service supported by 200 is returned to the processor 110.
  • the Bluetooth service supported by the electronic device 200 is not queried from uuid.db, and then processed through the interface of the first application program.
  • the device 110 returns a notification that the query has failed.
  • the electronic device 100 may query the Bluetooth service supported by the electronic device 200 from uuid.db.
  • the wireless communication module 132 may query the bluetooth service supported by the electronic device 200 from uuid.db, and then search the electronic device through the interface of the first application program.
  • the Bluetooth service supported by 200 is returned to the processor 110.
  • the Bluetooth service supported by the electronic device 200 is not queried from uuid.db, and then the interface of the first application program
  • the processor 110 returns that the electronic device 200 and the electronic device 100 are in a pairing state.
  • the current mode is determined to be busy mode, and the electronic device 200 and the electronic device 100 can be paired successfully before passing the first application
  • the interface of the program sends a request to the wireless communication module 132 to acquire the Bluetooth service of the electronic device 200.
  • the current mode is determined to be the busy mode, and the electronic device 200 may be sent to the wireless communication module 132 through the interface of the first application program The device 200 and the electronic device 100 are successfully paired and then query the notification of the Bluetooth service of the electronic device 200.
  • the method provided by the embodiments of the present application is introduced from the perspective of an electronic device as an execution subject.
  • the electronic device may include a hardware structure and/or a software module, and implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above functions is executed in a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application of the technical solution and design constraints.
  • FIG. 8 shows an electronic device 800 provided by the present application.
  • the electronic device 800 includes at least one processor 810, at least one memory 830, and a transceiver 820.
  • the processor 810 is coupled to the transceiver 820 and the memory 830.
  • the coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units, or modules, which may be electrical, mechanical, or other forms used for devices , Information exchange between units or modules.
  • the transceiver 820 is used to receive or send data.
  • the transceiver 820 may be used to receive a scan result, or a pairing success response, or send a pairing request.
  • the memory 830 stores data related to the first application program and code instructions. It should be understood that the memory for storing the first application program and the memory for storing code instructions may be the same or different, which is not limited.
  • the memory 830 further includes a first memory and a second memory, where the first memory is used to store Bluetooth service information supported by the electronic device obtained from the scan results, and the second memory is used to store the successful pairing The Bluetooth service information supported by the electronic device obtained in the response. It should be understood that the first memory and the second memory may be the same memory or two different memories, which is not limited.
  • the memory 830 may be the internal memory 121 shown in FIG. 2, or a memory connected to the external memory interface 122, or may be a memory provided in the processor 110 or the wireless communication module 132.
  • the processor 810 is used to call code instructions and other related data stored in the memory 830, and in combination with the transceiver 820, execute the method for querying the Bluetooth service provided by the embodiments of the present application of the present application. For example, saving the Bluetooth service information supported by the electronic device included in the scan result and/or the information of the Bluetooth service supported by the electronic device included in the pairing success response, and querying the Bluetooth service supported by the electronic device from the saved Bluetooth service information.
  • the electronic device 800 may be used to implement the Bluetooth service query method according to an embodiment of the present application.
  • the electronic device 800 may be used to implement the Bluetooth service query method according to an embodiment of the present application.
  • the method section and details are not described here.
  • the functions of the processor 810 and the transceiver 820 may be integrated, for example, the wireless communication module 132 shown in FIG. 2, or the functions of the processor 810 may be integrated in FIG. 2
  • the processor 110 for example, an application processor
  • the functions of the transceiver 820 are integrated in the wireless communication module 132 shown in FIG. 2
  • part of the functions of the processor 810 can be integrated in the processor shown in FIG. 2
  • another part of functions are integrated in the wireless communication module 132.
  • a chip 900 provided by the present application.
  • the chip 900 includes at least one processor 910 and an interface 920.
  • the interface 920 is used to receive code instructions and send the received code instructions to the processor 910.
  • the processor 910 runs the received code instructions sent by the interface and executes the Bluetooth service query method according to the embodiment of the present application.
  • the specific query method of the Bluetooth service reference may be made to the embodiment in the method section, and details are not described herein again.
  • Computer-readable media includes computer storage media and communication media, where communication media includes any medium that facilitates transfer of a computer program from one place to another.
  • a storage medium may be any available medium that can be accessed by a computer.
  • computer-readable media may include RAM, ROM, electrically erasable programmable read-only memory (electrically erasable programmable read only memory, EEPROM), compact disc read-only memory (CD- ROM) or other optical disk storage, magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.
  • RAM random access memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • CD- ROM compact disc read-only memory
  • Any connection can become a computer-readable medium as appropriate.
  • disks and discs include compact discs (CDs), laser discs, optical discs, digital video discs (DVDs), floppy disks, and Blu-ray discs, where Disks usually copy data magnetically, while disks use lasers to copy data optically.
  • CDs compact discs
  • DVDs digital video discs
  • floppy disks floppy disks
  • Blu-ray discs where Disks usually copy data magnetically, while disks use lasers to copy data optically.

Abstract

一种蓝牙服务的查询方法及电子设备,涉及通信技术领域,用以降低蓝牙连接出现异常的可能性。其中,该方法应用于第一电子设备,第一电子设备开启了蓝牙功能,且安装有第一应用程序。具体包括:第一电子设备接收至少一个开启了蓝牙功能的电子设备发送的扫描结果,每个扫描结果中包括设备标识和至少一个UUID;每个UUID用于标识一个蓝牙服务;并将扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。这种技术方案有助于降低直接向对端蓝牙设备查询蓝牙服务的次数,从而降低蓝牙连接出现异常的可能性,提高用户体验。

Description

一种蓝牙服务的查询方法及电子设备 技术领域
本申请涉及通信技术领域,尤其涉及一种蓝牙服务的查询方法及电子设备。
背景技术
目前,通过通用唯一识别码(universally unique identifier,UUID)来标识蓝牙服务。其中,不同的UUID标识的蓝牙服务不同。手机、平板电脑等电子设备使用对端蓝牙设备提供的蓝牙服务之前,需要查询对端蓝牙设备的蓝牙服务UUID列表(service UUID list),来确定对端蓝牙设备支持哪些蓝牙服务。具体的,对端蓝牙设备的service UUID list中包括至少一个UUID,至少一个UUID中的每个UUID用于标识一个对端蓝牙设备所支持的蓝牙服务。
以蓝牙耳机为例,例如,蓝牙耳机的service UUID list包括UUID1和UUID2。其中,UUID1用于标识蓝牙音频传输模型协定(advanced audio distribution profile,A2DP),UUID2用于标识免提协定(hands-free profile,HFP)。A2DP指的是蓝牙耳机与手机通过蓝牙连接后,可以作为手机的麦克风和听筒,进行语音通话,也可以作为手机的播放设备,播放手机上的音频文件。HFP指的是蓝牙耳机与手机通过蓝牙连接后,可以控制接听、拒接或挂断手机上的来电、或者,控制使用手机拨打电话等。
实际应用中,手机是通过应用程序(例如系统应用、第三方应用等)来查询对端蓝牙设备的service UUID list的。具体的,如图1所示,应用程序向手机中的蓝牙芯片发送查询对端蓝牙设备的蓝牙服务的请求,手机中的蓝牙芯片接收到查询对端蓝牙设备的蓝牙服务的请求后,向对端蓝牙设备发送蓝牙服务的查询命令,对端蓝牙设备的蓝牙芯片在接收到查询命令后,获取service UUID list,并将获取到的service UUID list返回给手机中的蓝牙芯片,然后由手机中的蓝牙芯片将接收到的来自对端蓝牙设备的service UUID list返回给应用程序。通过上述蓝牙服务的查询方式,当手机上需要查询对端蓝牙设备的蓝牙服务的应用程序较多时,可能会使得对端蓝牙设备同时接收到来自多个应用程序的蓝牙服务的查询命令,导致超出自身蓝牙芯片的处理能力,从而导致手机与对端蓝牙设备的连接异常。另外,对于手机上安装的一些第三方应用,还可能会频繁地向对端蓝牙设备的蓝牙芯片发送蓝牙服务的查询命令,导致对端蓝牙设备出于自我保护,也可能会断开与手机之间的蓝牙连接。
综上所述,现有技术中这种直接向对端蓝牙设备下发查询命令,来查询蓝牙服务的方法,容易导致蓝牙连接出现异常,降低用户体验。
发明内容
本申请实施例提供了一种蓝牙服务的查询方法及电子设备,有助于降低直接向对端蓝牙设备查询蓝牙服务的次数,从而降低蓝牙连接出现异常的可能性,提高用户体验。
第一方面,本申请实施例提供的一种蓝牙服务的查询方法,应用于第一电子设备,所述第一电子设备开启了蓝牙功能,且安装有第一应用程序;所述方法包括:
所述第一电子设备接收至少一个开启了蓝牙功能的电子设备发送的扫描结果,每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识 所标识的电子设备支持的一个蓝牙服务;并将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息。所述第一电子设备当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
本申请实施例中,由于第一电子设备能够当请求查询第二电子设备的蓝牙服务时,可以从保存的第一蓝牙服务信息中查询第二电子设备的蓝牙服务,因此有助于降低直接向第二电子设备通过芯片透传的方式查询蓝牙服务的次数,从而有助于降低蓝牙连接因向第二电子设备查询蓝牙服务的次数过多导致出现异常的可能性。
在一种可能的设计中,所述第一蓝牙服务信息是以数据库的形式存储的。例如uuid.db。有助于简化实现方式。
在一种可能的设计中,针对所述至少一个开启了蓝牙功能的电子设备中的一个电子设备,所述第一电子设备当再次接收到所述电子设备发送的扫描结果,则根据再次接收到所述电子设备发送的扫描结果,更新所述第一蓝牙服务信息。从而有助于提高保存的第一蓝牙服务信息的完整性。
在一种可能的设计中,当开启了蓝牙功能的电子设备为经典蓝牙设备时,扫描结果为扩展需求结果extended inquiry result;和/或,当开启了蓝牙功能的电子设备为低功耗蓝牙设备时,扫描结果为广播包。有助于简化实现方式。
在一种可能的设计中,所述第一电子设备向所述至少一个开启了蓝牙功能的电子设备中的待配对的电子设备发送配对请求;并接收所述待配对的电子设备接收到所述配对请求后,发送的配对成功响应,所述配对成功响应包括待配对的电子设备的标识和至少一个UUID;然后,将所述配对成功响应包括的待配对的电子设备的标识和至少一个UUID保存为所述第二蓝牙服务信息。
在一种可能的设计中,所述第二蓝牙服务信息是以配置文件的形式存储的。例如,bt_config.conf。有助于降低保存第二蓝牙服务信息的复杂性,便于实现。
在一种可能的设计中,所述第一电子设备检测到第一应用程序请求查询第二电子设备的蓝牙服务时,还可以从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务;并将从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务、以及从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务取并集,得到所述第二电子设备支持的蓝牙服务。从而提高第一电子设备从预先存储的蓝牙服务信息中查询到第二电子设备支持的蓝牙服务的可能性。
在一种可能的设计中,所述第二电子设备与所述第一电子设备处于已配对状态。
在一种可能的设计中,所述第一电子设备检测到第一应用程序请求查询第三电子设备的蓝牙服务时,若所述第三电子设备与所述第一电子设备处于未配对状态或者正在配对状态,则根据第三电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。有助于节省电子设备内部的无效信令交互。
在一种可能的设计中,所述第一应用程序为第三方应用。
在一种可能的设计中,所述第一电子设备检测到系统应用请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
在一种可能的设计中,所述第一电子设备当从第一蓝牙服务信息、或者第一蓝牙服务 信息和第二蓝牙服务信息中未查询到第二电子设备支持的蓝牙服务时,可以向第二电子设备发送蓝牙服务的查询命令,也可以根据第二电子设备与第一电子设备所处的配对状态,判断是否向第二电子设备发送蓝牙服务的查询命令。通过上述技术方案,有助于提高第一电子设备查询到第二电子设备支持的蓝牙服务的可能性。
第二方面,本申请实施例提供了一种第一电子设备,所述第一电子设备开启了蓝牙功能;其中,所述第一电子设备包括至少一个处理器、至少一个存储器和收发器;
所述存储器存储有第一应用程序和代码指令;所述收发器用于接收或发送数据;所述处理器当调用所述存储器中存储的所述代码指令时,结合所述收发器执行:
接收至少一个开启了蓝牙功能的电子设备发送的扫描结果,并将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;以及当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务;其中,每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识所标识的电子设备支持的一个蓝牙服务。
在一种可能的设计中,所述第一蓝牙服务信息以数据库的形式存储。
在一种可能的设计中,所述代码指令还包括:用于针对所述至少一个开启了蓝牙功能的电子设备中的一个电子设备,当再次接收到所述电子设备发送的扫描结果,则根据再次接收到所述电子设备发送的扫描结果,更新所述第一蓝牙服务信息的指令。
在一种可能的设计中,当开启了蓝牙功能的电子设备为经典蓝牙设备时,扫描结果为扩展需求结果extended inquiry result;和/或,当开启了蓝牙功能的电子设备为低功耗蓝牙设备时,扫描结果为广播包。
在一种可能的设计中,所述代码指令还包括:用于向所述至少一个开启了蓝牙功能的电子设备中的待配对的电子设备发送配对请求的指令;用于接收所述待配对的电子设备接收到所述配对请求后,发送的配对成功响应的指令,所述配对成功响应包括待配对的电子设备的标识和至少一个UUID;用于将所述通信接口接收到的所述配对成功响应包括的待配对的电子设备的标识和至少一个UUID保存为所述第二蓝牙服务信息的指令。
在一种可能的设计中,所述第二蓝牙服务信息是以配置文件的形式存储的。
在一种可能的设计中,至少一个存储器包括第一存储器和第二存储器,其中所述第一存储器用于保存第一蓝牙服务信息,第二存储器用于存储第二蓝牙服务信息。第一存储器和第二存储器可以为同一个存储器,也可以为不同的存储器,对此不作限定。
在一种可能的设计中,所述代码指令还包括:用于当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令;以及将从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务、以及从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务取并集,得到所述第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述第二电子设备与所述第一电子设备处于已配对状态。
在一种可能的设计中,所述代码指令还包括:用于当检测到第一应用程序请求查询第三电子设备的蓝牙服务时,若所述第三电子设备与所述第一电子设备处于未配对状态或者正在配对状态,则根据第三电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述第一应用程序为第三方应用。
在一种可能的设计中,所述代码指令还包括:用于当检测到系统应用请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述代码指令还包括:用于当所述处理器从第一蓝牙服务信息、或者第一蓝牙服务信息和第二蓝牙服务信息中未查询到第二电子设备支持的蓝牙服务时,向第二电子设备发送蓝牙服务的查询命令的指令。或者,用于当从第一蓝牙服务信息、或者第一蓝牙服务信息和第二蓝牙服务信息中未查询到第二电子设备支持的蓝牙服务时,根据第二电子设备与第一电子设备所处的配对状态,判断通过所述通信接口是否向第二电子设备发送蓝牙服务的查询命令的指令。
第三方面,本申请实施例中还提供了一种芯片,所述接口,用于接收代码指令,并将接收的所述代码指令传输至所述处理器;
所述处理器,用于运行接收到的所述接口发送的所述代码指令,执行:
接收至少一个开启了蓝牙功能的电子设备发送的扫描结果;每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识所标识的电子设备支持的一个蓝牙服务;
将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;
当接收到第一应用程序获取第二电子设备的蓝牙服务的请求时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
在一种可能的设计中,所述第一蓝牙服务信息以数据库的形式存储。
在一种可能的设计中,所述代码指令还包括:用于针对所述至少一个开启了蓝牙功能的电子设备中的一个电子设备,当再次接收到所述电子设备发送的扫描结果,则根据再次接收到所述电子设备发送的扫描结果,更新所述第一蓝牙服务信息的指令。
在一种可能的设计中,当开启了蓝牙功能的电子设备为经典蓝牙设备时,扫描结果为扩展需求结果extended inquiry result;和/或,当开启了蓝牙功能的电子设备为低功耗蓝牙设备时,扫描结果为广播包。
在一种可能的设计中,所述代码指令还包括:用于向所述至少一个开启了蓝牙功能的电子设备中的待配对的电子设备发送配对请求的指令;用于接收所述待配对的电子设备接收到所述配对请求后,发送的配对成功响应的指令,所述配对成功响应包括待配对的电子设备的标识和至少一个UUID;用于将所述通信接口接收到的所述配对成功响应包括的待配对的电子设备的标识和至少一个UUID保存为所述第二蓝牙服务信息的指令。
在一种可能的设计中,所述第二蓝牙服务信息是以配置文件的形式存储的。
在一种可能的设计中,至少一个存储器包括第一存储器和第二存储器,其中所述第一存储器用于保存第一蓝牙服务信息,第二存储器用于存储第二蓝牙服务信息。第一存储器和第二存储器可以为同一个存储器,也可以为不同的存储器,对此不作限定。
在一种可能的设计中,所述代码指令还包括:用于当接收到第一应用程序获取第二电子设备的蓝牙服务的请求时,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令;以及将从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务、以及从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务取并集,得到所述第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述第二电子设备与所述第一电子设备处于已配对状态。
在一种可能的设计中,所述代码指令还包括:用于当接收到第一应用程序获取第三电子设备的蓝牙服务的请求时,若所述第三电子设备与所述第一电子设备处于未配对状态或者正在配对状态,则根据第三电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述第一应用程序为第三方应用。
在一种可能的设计中,所述代码指令还包括:用于当接收到系统应用获取第二电子设备的蓝牙服务的请求时,根据第二电子设备的标识,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
在一种可能的设计中,所述代码指令还包括:用于当所述处理器从第一蓝牙服务信息、或者第一蓝牙服务信息和第二蓝牙服务信息中未查询到第二电子设备支持的蓝牙服务时,向第二电子设备发送蓝牙服务的查询命令的指令。或者,用于当从第一蓝牙服务信息、或者第一蓝牙服务信息和第二蓝牙服务信息中未查询到第二电子设备支持的蓝牙服务时,根据第二电子设备与第一电子设备所处的配对状态,判断通过所述通信接口是否向第二电子设备发送蓝牙服务的查询命令的指令。
第四方面,本申请实施例中还提供一种计算机存储介质,该计算机存储介质中存储有程序指令,该程序指令在电子设备上运行时可实现第一方面或上述第一方面的任意一种设计提供的方法。
另外,第二方面至第四方面中任一种可能设计方式所带来的技术效果可参见方法部分相关中不同设计方式所带来的技术效果,此处不再赘述。
附图说明
图1为现有技术中蓝牙服务的查询方法的流程示意图;
图2为本申请实施例的一种通信系统架构图;
图3为本申请实施例的一种用户界面的示意图;
图4为本申请实施例的另一种用户界面的示意图;
图5为本申请实施例的一种应用场景的示意图;
图6为本申请实施例预先存储蓝牙服务的方法的流程示意图;
图7为本申请实施例蓝牙服务的查询方法的流程示意图
图8为本申请实施例的一种电子设备的结构示意图;
图9为本申请实施例的一种芯片的结构示意图。
具体实施方式
应理解,本申请实施例中“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系。例如,A和/或B,可以表示以下三种关系:单独存在A,同时存在A和B,单独存在B。其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一(项)个”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a、b或c中的至少一项(个),可以表示:a,b,c,a和b,a和c,b和c,或a、b和c,其中a、b、c可以是单个,也可以是多个。
本申请实施例可以应用于支持蓝牙功能的电子设备。以下介绍电子设备、用于这样的电子设备的图形用户界面(graphical user interface,GUI)、和用于使用这样的电子设备的实施例。在本申请的一些实施例中,电子设备可以为便携式电子设备,诸如手机、平板电脑、具备无线通讯功能的可穿戴设备(如智能手表)、车载设备等。便携式电子设备的示例性实施例包括但不限于搭载
Figure PCTCN2018123556-appb-000001
或者其它操作系统的便携式电子设备。上述便携式电子设备也可以是诸如具有触敏表面(例如触控面板)的膝上型计算机(Laptop)等。还应当理解的是,在本申请的另一些实施例中,电子设备还可以为具有触敏表面(例如触控面板)的台式计算机等。
示例的,如图2所示,为本申请实施例的一种电子设备的硬件结构示意图。如图所示,电子设备100包括处理器110、内部存储器121、外部存储器接口122、天线1、移动通信模块131、天线2、无线通信模块132、音频模块140、扬声器140A、受话器140B、麦克风140C、耳机接口140D、显示屏151、用户标识模块(subscriber identification module,SIM)卡接口152、摄像头153、按键154、传感器模块160、通用串行总线(universal serial bus,USB)接口170、充电管理模块180、电源管理模块181和电池182。在另一些实施例中,电子设备100还可以包括马达、指示器等。
其中,处理器110可以包括应用处理器(application processor,AP)、调制解调器、图形处理器(graphics processing unit,GPU)、图像信号处理器(image signal processor,ISP)、基带处理器、视频编解码器、数字信号处理器(digital signal processor,DSP)、神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个器件中。
在一些实施例中,处理器110中还可以设置存储器,用于存储指令和数据。示例的,处理器110中的存储器可以为高速缓冲存储器。该存储器可以用于保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从该存储器中直接调用。从而有助于避免重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能、图像播放功能)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据、电话本)等。应用处理器可以通过调用存储程序区存储的操作系统等程序,从而使得电子设备100能够实现各种功能以及数据处理等。应理解,内部存储器121可以为高速随机存取存储器,也可以为非易失性存储器,例如至少一个磁盘存储器件、闪存器件、通用闪存存储器(universal flash storage,UFS)等。
外部存储器接口122可以用于连接外部存储卡(例如,Micro SD卡),实现扩展电子设备100的存储能力。
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。
移动通信模块131可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块131可以包括至少一个滤波器、开关、功率放大器、低噪声放大器(low noise amplifier,LNA)等。移动通信模块131可以由天线1接收电磁波信号,并对接收的电磁波信号进行滤波、放大等处理,传送至调制解调器进行解调。移动通信模块131 还可以对经调制解调器调制后的信号放大,经天线1转为电磁波信号辐射出去。
调制解调器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器140A、受话器140B等)输出声音信号,或通过显示屏151显示图像或视频。
无线通信模块132可以提供应用在电子设备100上的蓝牙(bluetooth,BT)无线通信的解决方案。此外,无线通信模块132还可以提供应用在电子设备100上的包括无线局域网(wireless lan,WLAN)(如无线保真(wireless fidelity,WiFi)网络)、全球导航卫星系统(global navigation satellite system,GNSS)、调频(frequency modulation,FM)、近距离无线通信技术(near field communication,NFC)、红外技术(infrared,IR)等无线通信的解决方案。无线通信模块132可以为集成包括蓝牙在内的至少一种无线通信技术的芯片或模块。其中,需要说明的是,用于实现蓝牙无线通信技术的芯片或模块,可以简称为蓝牙芯片。在另一些实施例中,蓝牙芯片还可以集成在处理器110中,也可以将蓝牙芯片的部分功能集成在处理器110中。无线通信模块132经由天线2接收电磁波信号,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块132还可以从处理器110接收待发送的信号,对其进行调频、放大,经天线2转为电磁波信号辐射出去。
在一些实施例中,电子设备100的天线1和移动通信模块131耦合,天线2和无线通信模块132耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM)、通用分组无线服务(general packet radio service,GPRS)、码分多址接入(code division multiple access,CDMA)、宽带码分多址(wideband code division multiple access,WCDMA)、时分码分多址(time-division code division multiple access,TD-SCDMA)、长期演进(long term evolution,LTE)、BT、GNSS、WLAN、NFC、FM、和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS)、全球导航卫星系统(global navigation satellite system,GLONASS)、北斗卫星导航系统(beidou navigation satellite system,BDS)、准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
电子设备100可以通过音频模块140、扬声器140A、受话器140B、麦克风140C、耳机接口140D以及应用处理器等实现音频功能。例如音乐播放、录音等。
音频模块140可以用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块140还可以用于对音频信号编码和解码。在一些实施例中,音频模块140可以设置于处理器110中,或将音频模块140的部分功能模块设置于处理器110中。
扬声器140A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器140A收听音乐、或接听免提通话。
受话器140B,也称“听筒”,用于将音频电信号转换成声音信号。用户当使用电子设备100接听电话时,可以通过将人耳靠近受话器140B,来接听通过移动通信模块131或者无线通信模块132接收到的语音。
麦克风140C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。用户当使用电 子设备100拨打电话或发送语音时,可以通过将人嘴靠近麦克风140C发声,从而使得麦克风140C可以用于采集用户的声音,然后,将用户的声音转换为电信号。电子设备100可以设置至少一个麦克风140C。在一些实施例中,电子设备100可以设置两个麦克风140C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个、四个或更多麦克风140C,实现声音信号采集、降噪、还可以识别声音来源,实现定向录音功能等。
耳机接口140D用于连接有线耳机。耳机接口140D可以是USB接口170,也可以是3.5mm的开放移动电子设备100平台(open mobile terminal platform,OMTP)标准接口、美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口等。
电子设备100可以通过GPU、显示屏151、以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏151和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行代码指令以生成或改变显示信息。
显示屏151可以用于显示图像、视频等。显示屏151可以包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD)、有机发光二极管(organic light-emitting diode,OLED)、有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED)、柔性发光二极管(flex light-emitting diode,FLED)、Miniled、MicroLed、Micro-oLed、量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏151,N为大于1的正整数。
电子设备100可以通过ISP、摄像头153、视频编解码器、GPU、显示屏151以及应用处理器等实现拍摄功能。
按键154可以包括开机键、音量键等。按键154可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。
传感器模块160可以包括一个或多个传感器。例如,触摸传感器160A、指纹传感器160B、陀螺仪传感器160C、压力传感器160D、加速度传感器160E等。在一些实施例中,传感器模块160还可以包括环境传感器、距离传感器、接近光传感器、骨传导传感器等。
触摸传感器160A可以设置于显示屏151,由触摸传感器160A与显示屏151组成触摸屏,也称“触控屏”。触摸传感器160A用于检测作用于其上或附近的触摸操作。触摸传感器160A可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏151提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器160A也可以设置于电子设备100的表面,与显示屏151所处的位置不同。
指纹传感器160B可以用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁、访问应用锁、指纹拍照、指纹接听来电等。
陀螺仪传感器160C可以用于确定电子设备100的运动姿态、拍摄防抖、导航、体感游戏场景等。
压力传感器160D用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器160D可以设置于显示屏151。压力传感器160D的种类很多,如电阻式压力传感器、电感式压力传感器、电容式压力传感器等。
加速度传感器160E可检测终端在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备100的姿态,应用于横竖屏切换、计步器等应用。
在另一些实施例中,处理器110还可以包括一个或多个接口。例如,接口可以为SIM卡接口152。又例如,接口还可以为USB接口170。再例如,接口还可以为集成电路(inter-integrated circuit,I2C)接口、集成电路内置音频(inter-integrated circuit sound,I2S)接口、脉冲编码调制(pulse code modulation,PCM)接口、通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口、移动产业处理器接口(mobile industry processor interface,MIPI)、通用输入输出(general-purpose input/output,GPIO)接口等。可以理解的是,本申请实施例处理器110可以通过接口连接电子设备100的不同模块,从而使得电子设备100能够实现不同的功能。例如拍照、处理等。需要说明的是,本申请实施例对电子设备100中接口的连接方式不作限定。
其中,SIM卡接口152可以用于连接SIM卡。SIM卡可以通过插入SIM卡接口152,或从SIM卡接口152拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口152可以支持Nano SIM卡、Micro SIM卡、SIM卡等。同一个SIM卡接口152可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口152也可以兼容不同类型的SIM卡。SIM卡接口152也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100还可以采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。例如,当SIM卡接口152只能插入一张SIM卡时,则电子设备100可以通过SIM卡接口152中插入的SIM卡接入一个蜂窝网络。再例如,当SIM卡接口152能够插入两张SIM卡时,则电子设备100可以通过SIM卡接口152中插入的两张SIM卡分别接入一个蜂窝网络。
USB接口170是符合USB标准规范的接口。例如,USB接口170可以包括Mini USB接口、Micro USB接口、USB Type C接口等。USB接口170可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据,也可以用于连接耳机,通过耳机播放音频。
充电管理模块180用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块180可以通过USB接口170接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块180可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块180为电池182充电的同时,还可以通过电源管理模块181为电子设备100供电。
电源管理模块181用于连接电池182、充电管理模块180与处理器110。电源管理模块181接收电池182和/或充电管理模块180的输入,为处理器110、内部存储器121、外部存储器、显示屏151、摄像头153、移动通信模块131和无线通信模块132等供电。电源管理模块181还可以用于监测电池容量、电池循环次数、电池健康状态(漏电、阻抗)等参数。在其他一些实施例中,电源管理模块181也可以设置于处理器110中。在另一些实施例中,电源管理模块181和充电管理模块180也可以设置于同一个器件中。
应理解,图2所示的电子设备100的硬件结构仅是一个示例。本申请实施例的电子设备可以具有比图中所示出的更多的或者更少的部件,可以组合两个或更多的部件,或者可以 具有不同的部件配置。图中所示出的各种部件可以在包括一个或多个信号处理和/或专用集成电路在内的硬件、软件、或硬件和软件的组合中实现。
下面以图2所示的电子设备100的硬件结构为例,对本申请实施例进行详细说明。
应理解,本申请实施例中电子设备100通常是通过应用程序为用户提供各种功能的。示例的,应用程序可以为系统应用(又可称之为原生应用),也可以为第三方应用。例如,绘图、演示、字处理、游戏、电话、视频播放器、音乐播放器、电子邮件、即时消息收发、照片管理、相机、浏览器、日历、时钟、支付、应用市场、桌面和健康管理等应用程序。示例的,本申请实施例中的电子设备100可以同时运行多个应用程序。
示例性地,图3a为本申请实施例的一种图形用户界面的示意图。以下将图形用户界面简称为用户界面。其中,电子设备100是通过显示屏151显示用户界面的。具体的,用户界面可以为主界面、负一屏或者某一应用的用户界面等。例如,主界面可以如图3a所示的用户界面300。如图所示用户界面300可以包括状态栏301、时间和天气Widget302、可隐藏的导航栏303,还有多个应用的图标例如设置图标304等。其中,状态栏301可以包括运营商的名称(中国移动)、移动网络(例如4G)、时间和剩余电量。在本申请的其它一些实施例中,状态栏301可以包括运营商的名称(中国移动)、移动网络的信号强度、时间和剩余电量。在本申请的其它一些实施例中,状态栏301还可以包括蓝牙图标、WiFi图标、屏幕锁定图标、外接设备图标等中的一个或多个。例如,以蓝牙图标为例,本申请实施例中电子设备100可以在开启了蓝牙功能后,在状态栏301中显示蓝牙图标,当关闭了蓝牙功能后,在状态栏301中不显示蓝牙图标。导航栏303可以包括后退按钮(back button)、主屏幕键按钮(home button)和历史任务查看按钮(menu button)。还可以理解的是,在其他一些实施例中,用户界面300还可以包括Dock栏。Dock栏中可以包括常用应用的图标,例如电话图标、短消息图标、邮件图标和天气图标等。应理解,用户可以根据自身的需求设置Dock栏中的常用应用的图标。
在其他一些实施例中,如图3a所示,电子设备100还可以包括主屏幕键305。其中,主屏幕键305可以是实体按键,也可以是虚拟按键。主屏幕键305用于根据用户的操作,将显示屏151上显示的某一应用的用户界面或者负一屏等用户界面返回到主界面,这样可以方便用户随时查看主界面,并对主界面上的控件(例如图标等)进行操作。上述操作具体可以是用户按下主屏幕键305。在本申请其他一些实施例中,主屏幕键305还可以集成指纹传感器160B,这样用户可以在按下主屏幕键305的时候,电子设备100可以进行指纹采集,进而对用户身份进行确认。在另一些实施例中,电子设备100可以不包括主屏幕键305。
示例的,电子设备100当显示屏151显示用户界面300时,可以响应于用户对设置图标304的触摸操作,在显示屏151显示系统设置界面。其中,系统设置界面包括各种功能按钮,用于对电子设备100进行相应的设置。例如,系统设置界面可以为如图3b中所示的用户界面310,包括蓝牙按钮311。此外,用户界面310还可以包括账号登录、开启云备份、屏幕锁定等功能按钮。电子设备100可以响应于用户对蓝牙按钮311的操作,在显示屏151显示蓝牙设置界面。其中,蓝牙设置界面用于开启或关闭蓝牙功能。示例的,电子设备100当蓝牙功能未开启时,蓝牙设置界面可以为如图3c所示的用户界面320。如图3c所示,用户界面320包括蓝牙按钮321,且蓝牙按钮321处于关闭(OFF)状态。当蓝牙按钮321处于关闭状态时,电子设备100的蓝牙功能是未开启的。电子设备100可以响应于用户对蓝牙按钮321操作,将蓝牙按钮321置于开启(ON),从而开启蓝牙功能。此外,在另一些实施例中,电子设 备100还可以当显示屏151在锁定或解锁后显示某一用户界面(例如用户界面300)时,可以响应于用户的下拉操作或上拉操作,在显示屏151显示快捷设置用户界面。具体的,快捷设置界面上包括用于设置各种功能的快捷按钮,例如开启或关闭蓝牙功能的快捷按钮等。例如,快捷设置用户界面可以为如图4所示的用户界面400。其中,用户界面400上包括蓝牙按钮401。电子设备100可以响应于用户对蓝牙按钮401的操作,开启或关闭蓝牙功能。例如,电子设备100当蓝牙功能未开启时,可以响应于用户对蓝牙按钮401的操作,开启蓝牙功能。再例如,电子设备100当开启了蓝牙功能时,可以响应于用户对蓝牙按钮401的操作,关闭蓝牙功能。此外,在一些实施例中,用户界面400还可以包括WiFi、个人热点、飞行模式、免打扰、响铃、移动数据、亮度调节等功能按钮,从而可以实现用户对相应功能的快速设置。需要说明的是,本申请实施例中电子设备100还可以通过其它方式开启或关闭蓝牙功能,例如语音指令、快捷手势操作等,对此不作限定。
应理解,电子设备100当开启了蓝牙功能后,可以作为从设备(slave)被附近开启了蓝牙功能的电子设备扫描发现,也可以作为主设备(master)扫描发现附近开启了蓝牙功能的电子设备。示例的,如图5所示,若电子设备100和电子设备200均开启了蓝牙功能,且电子设备200位于电子设备100的附近,则电子设备100和电子设备200可以相互扫描发现,从而可以建立蓝牙连接。
下面以电子设备100为主设备,电子设备200为从设备为例,对电子设备100和电子设备200建立蓝牙连接的过程进行介绍。
电子设备100当开启了蓝牙功能后,执行设备扫描过程,以发现附近开启了蓝牙功能的电子设备。此外,电子设备100当开启了蓝牙功能后,在显示屏151显示的用户界面320可以包括电子设备100当前可被附近蓝牙设备发现的提示信息、可用设备列表等。其中,可用设备列表中包括至少一个设备标识,每个设备标识用于标识一个电子设备100扫描发现的附近开启了蓝牙功能的电子设备,从而有助于提示用户。在一些实施例中,设备标识可以包括设备名称、设备类型、或媒体接入控制(media access control,MAC)地址等中的一个或多个。例如,设备类型可以包括手机、蓝牙耳机、蓝牙鼠标、平板电脑、笔记本电脑、台式机、显示屏、蓝牙键盘、蓝牙打印机、蓝牙传真机等。设备类型可以以图形或者文字等形式在可用设备列表322中呈现给用户。另外,需要说明的是,本申请实施例中设备名称可以为设备型号,也可以为用户设置的,对此不作限定。例如,电子设备100扫描发现电子设备a、电子设备200和电子设备b,其中,电子设备a的标识为Sql、电子设备200的标识为200、电子设备b的标识为Watch,则电子设备100显示的用户界面320可以如图3d所示,可用设备列表322包括Sql、200和Watch。其中,可用设备列表322可以根据电子设备100扫描发现的电子设备进行更新。
在一些实施例中,电子设备100可以按照下列方式执行设备扫描过程:
方式一:电子设备100作为主设备在开启了蓝牙功能后,广播扫描请求,附近开启了蓝牙功能的电子设备(例如电子设备200)作为从设备可以在接收到扫描请求后,向电子设备100发送扫描响应,从而使得电子设备100发现附近开启了蓝牙功能的电子设备。
方式二:电子设备100作为主设备可以在开启了蓝牙功能后,接收附近开启了蓝牙功能的电子设备(从设备)的广播消息,而不会发送扫描请求。其中,附近开启了蓝牙功能的电子设备可以周期性广播消息,有助于其它开启了蓝牙功能的电子设备扫描发现。例如,电子设备100在开启了蓝牙功能后,接收到电子设备200的广播消息,从而扫描发现电子设 备200。
需要说明的是,电子设备100当扫描发现电子设备200后,则与电子设备200建立了物理链路。
本申请实施例中电子设备100在扫描发现电子设备200后,执行设备配对过程,与电子设备200进行配对。具体的,电子设备100可以在扫描发现电子设备200后,向电子设备200发送配对请求,电子设备200在接收到电子设备100的配对请求后,对电子设备100进行设备认证,并在设备认证通过后,向电子设备100发送配对成功响应,从而使得电子设备100建立与电子设备200之间的逻辑链路控制和适配协议(logical link control and adaptation protocol,L2CAP)信道。例如,电子设备100若未与电子设备200建立过蓝牙连接,则可以响应于用户在可用设备列表中选中电子设备200的标识,向电子设备200发送配对请求。再例如,电子设备100若与电子设备200建立过蓝牙连接,则可以当扫描发现电子设备200后,可以自动向电子设备200发送配对请求。除此之外,本申请实施例中还可以通过其它方式触发电子设备100向电子设备200发送配对请求,对此不作限定。
需要说明的是,本申请实施例中,电子设备100可以响应于触发向电子设备200发送配对请求的操作,停止设备扫描过程,也可以在电子设备100开启了蓝牙功能后,一直持续执行设备扫描过程,直至电子设备100关闭蓝牙功能后,不再执行设备扫描过程。
需要说明的是,本申请实施例中电子设备100与电子设备200配对完成后,还需要查询到电子设备200支持的蓝牙服务,才能够使得电子设备100与电子设备200之间完成蓝牙连接的建立。应理解,本申请实施例中不同类型的电子设备支持的蓝牙服务可以相同,也可以不同。例如,对于蓝牙耳机来说,支持的蓝牙服务可以包括A2DP、HFP和音频视频远距离控制协定(audio/video remote control profile,AVRCP)、耳机应用模型(head set profile,HSP)等。
在一些实施例中,电子设备100通过与电子设备200之间进行服务发现协议(service discovery protocol,SDP)交互操作,使得电子设备100可以通过自身的蓝牙芯片直接向电子设备200的蓝牙芯片发送蓝牙服务的查询命令,来获取电子设备200的service UUID list。这种通过芯片透传来查询蓝牙服务的方式,容易导致电子设备100和电子设备200之间的蓝牙连接出现异常,有鉴于此,本申请实施例提供了一种蓝牙服务的查询方法,可以通过在电子设备100中预先存储的电子设备支持的蓝牙服务的信息,使得电子设备100中安装的应用程序当请求查询某个电子设备支持的蓝牙服务时,可以从预先存储的电子设备100中的电子设备支持的蓝牙服务信息进行查询,从而有助于降低直接向对端电子设备查询蓝牙服务的次数,在一定程度上还有助于提高蓝牙服务查询的效率。
示例的,如图6所示,本申请实施例的一种预先存储电子设备的蓝牙服务的信息的方法,包括以下步骤。
步骤601,电子设备100开启了蓝牙功能后,接收至少一个扫描结果,其中,每个扫描结果是电子设备100附近开启了蓝牙功能的电子设备发送的,扫描结果包括电子设备支持的蓝牙服务的信息。示例的,电子设备支持的蓝牙服务的信息包括设备标识、和至少一个UUID。具体的,设备标识为用于标识电子设备的信息,例如设备类型、设备名称、媒体接入控制(media access control,MAC)地址等信息中的一个或多个。
以电子设备100接收到电子设备200发送的扫描结果为例,电子设备200发送的扫描结果包括电子设备200支持的蓝牙服务信息,例如电子设备200的标识、以及电子设备200 支持的至少一个UUID。应理解,电子设备100接收到电子设备200发送的扫描结果,则电子设备100扫描发现电子设备200,可以将电子设备200的标识增加到可用设备列表中呈现给用户。
需要说明的是,本申请实施例中扫描结果可以为设备扫描过程中已有的消息,例如扫描响应、广播消息等。示例的,对于不同的电子设备,扫描结果的实现形式也可以不同。例如对于经典蓝牙(BR/EDR)设备来说,扫描结果可以为扩展需求结果(Extended Inquiry Result),对于低功耗蓝牙(BLE)设备来说,扫描结果可以为广播包。此外,扫描结果还可以为新定义的消息。
以图2所示的电子设备100的结构为例。具体的,处理器110(例如应用处理器)检测到开启了蓝牙功能,则向无线通信模块132(例如蓝牙芯片)发送设备扫描命令,无线通信模块132接收到设备扫描命令后,接收来自附近的至少一个电子设备发送的扫描结果。例如,无线通信模块132接收到设备扫描命令后,还可以广播扫描请求。附近的至少一个电子设备中的部分电子设备可以响应于接收到扫描请求,向无线通信模块132发送扫描结果。附近的至少一个电子设备中部分电子设备还可以在开启了蓝牙功能后,可以无需接收扫描请求,直接广播扫描结果。在一些实施例中,附近的至少一个电子设备在开启了蓝牙功能后,可以周期性广播扫描结果。其中广播扫描结果的周期可以根据实际情况进行设定。从而有助于被其它开启了蓝牙功能的电子设备扫描发现。
步骤602,电子设备100从至少一个扫描结果中获取并保存至少一个电子设备支持的蓝牙服务的信息。其中,至少一个电子设备支持的蓝牙服务的信息可以以数据库的形式保存,例如将至少一个电子设备支持的蓝牙服务的信息保存为一个数据库uuid.db,也可以以其它存储形式进行保存,对比不作限定。
以图2所示的电子设备100的结构为例。具体的,无线通信模块132接收到至少一个扫描结果后,从至少一个扫描结果中获取至少一个电子设备支持的蓝牙服务的信息,并将至少一个电子设备支持的蓝牙服务的信息以相应的存储形式存储到相应的存储器中。例如,无线通信模块132可以将至少一个电子设备支持的蓝牙服务的信息存储到内部存储器121、与外部存储器接口122连接外部存储器、处理器110或者无线通信模块132等功能模块中设置的存储器等中的一个或多个存储器中。
例如,电子设备100接收到扫描结果1、扫描结果2、扫描结果3,其中,扫描结果1中包括电子设备a支持的蓝牙服务的信息,例如设备标识a、UUID1和UUID2、扫描结果2包括电子设备200支持的蓝牙服务的信息,例如设备标识b、UUID3,扫描结果3包括电子设备c支持的蓝牙服务的信息,例如设备标识c、UUID2。其中,UUID1、UUID2和UUID3分别用于指示一种蓝牙服务,则电子设备100从扫描结果1、扫描结果2和扫描结果3中获取并保存的至少一个电子设备支持的蓝牙服务的信息可以如表1所示。
表1
Figure PCTCN2018123556-appb-000002
以表1为例,电子设备100当再次接收到电子设备200发送的扫描结果时,则可以根 据再次接收到的电子设备200发送的扫描结果更新保存的至少一个电子设备支持的蓝牙服务的信息中电子设备200的支持的蓝牙服务的信息。例如,电子设备100再次接收到的电子设备200发送的扫描结果包括设备标识b、UUID1、UUID3和UUID4,则可以通过将UUID1和UUID4增加到service UUID list2中,来更新如表1所示的电子设备支持的蓝牙服务的信息。其中,更新后的电子设备支持的蓝牙服务的信息可以如表2所示。
表2
Figure PCTCN2018123556-appb-000003
再例如,电子设备100当保存表1所示的电子设备支持的蓝牙服务的信息后,若接收到电子设备d发送的扫描结果时,则可以根据电子设备d发送的扫描结果更新保存的电子设备支持的蓝牙服务的信息。例如,电子设备d发送的扫描结果包括设备标识4、UUID1和UUID4,则可以通过在如表1所示的电子设备支持的蓝牙服务的信息中增加电子设备d支持的蓝牙服务的信息。其中,更新后的电子设备支持的蓝牙服务的信息可以如表3所示。
表3
Figure PCTCN2018123556-appb-000004
步骤603,电子设备100向扫描发现的至少一个电子设备中的一个或多个电子设备发送配对请求,其中电子设备100触发向扫描发现的至少一个电子设备中的一个或多个电子设备发送配对请求的方式可以参见上述实施例中电子设备100触发向电子设备200发送配对请求的方式,在此不再赘述。
步骤604,扫描发现的至少一个电子设备中的一个或多个电子设备接收到电子设备100发送的配对请求后,对电子设备100进行认证,当认证通过后,向电子设备100发送配对成功响应。其中配对成功响应中包括电子设备支持的蓝牙服务的信息。例如,电子设备支持的蓝牙服务的信息包括设备标识、和至少一个UUID。
步骤605,电子设备100接收到至少一个配对成功响应后,从至少一个配对成功响应中获取并保存至少一个电子设备支持的蓝牙服务的信息。
以图2所示的电子设备100的结构、且电子设备100与电子设备200配对为例。具体的,处理器110响应于触发与电子设备200配对的操作,向无线通信模块132发送与电子设备200的配对通知,无线通信模块132接收到与电子设备200的配对通知后,向电子设 备200发送配对请求。电子设备200接收到配对请求后,对电子设备100进行认证,并在认证通过后,向电子设备100发送配对成功响应。配对成功响应中包括电子设备200支持的至少一个蓝牙服务的信息。例如配对成功响应中包括电子设备200的标识、和至少一个UUID。每个UUID用于标识一个电子设备200支持的蓝牙服务。无线通信模块132接收到配对成功响应后,从配对成功响应中获取电子设备200支持的至少一个蓝牙服务的信息,并以相应的存储形式存储到相应的存储器中。例如,电子设备100可以将从配对成功响应中获取电子设备200支持的至少一个蓝牙服务的信息以配置文件(例如bt_config.conf)的形式存储到内部存储器121、与外部存储器接口122连接的外部存储器、处理器110或者无线通信模块132中设置的存储器中的一个或多个存储器中。
应理解,当电子设备100与电子设备200首次配对成功后,则电子设备100中存储有电子设备200支持的蓝牙服务的信息,当电子设备200再次与电子设备100配对时,可以在接收到电子设备200发送的配对成功响应后,不再从配对成功响应中获取电子设备200支持的蓝牙服务的信息,也可以继续从配对成功响应中获取电子设备200支持的蓝牙服务的信息,并可以根据获取的电子设备200支持的蓝牙服务的信息更新已存储的电子设备200支持的蓝牙服务的信息。
例如,电子设备100与电子设备200首次配对成功后,存储的电子设备200支持的蓝牙服务的信息如表4所示。其中,设备标识b为电子设备200的标识,UUID1、UUID2和UUID3分别用于指示电子设备200支持的一种蓝牙服务。
表4
Figure PCTCN2018123556-appb-000005
当电子设备100再次与电子设备200配对时,接收到电子设备200发送的配对成功响应,若配对成功响应中还是包括设备标识b、UUID1、UUID2和UUID3,则不对已存储的电子设备200支持的蓝牙服务的信息进行更新。若配对成功响应中还是包括设备标识b、UUID1、UUID2、和UUID4,则更新已存储的电子设备200支持的蓝牙服务的信息,具体的将UUID4增加到已存储的电子设备200支持的蓝牙服务的信息中,更新后的电子设备200支持的蓝牙服务的信息可以如表5所示。
表5
Figure PCTCN2018123556-appb-000006
需要说明的是,图6所示的预先存储电子设备的蓝牙服务的信息的方法仅为一个示例,本申请实施例中电子设备100还可以只保存扫描结果中包括的电子设备支持的蓝牙服务的信息,而不保存配对成功响应中包括的电子设备支持的蓝牙服务的信息;或者,电子设备100还可以不保存扫描结果中包括的电子设备支持的蓝牙服务的信息,只保存配对成功响应中包括的电子设备支持的蓝牙服务的信息。
此外,在本申请实施例中,电子设备100当既保存扫描结果中包括的电子设备支持的蓝牙服务的信息,又保存配对成功响应中包括的电子设备支持的蓝牙服务的信息时,可以将扫描结果中包括电子设备支持的蓝牙服务信息和配对成功响应中包括的电子设备支持的蓝牙服务的信息保存在一起。应理解,当扫描结果中包括电子设备支持的蓝牙服务信息和配对成功响应中包括的电子设备支持的蓝牙服务的信息保存在一起时,则扫描结果中包括的电子设备支持的蓝牙服务信息和配对成功响应中包括的电子设备支持的蓝牙服务的信息存储位置和存储形式相同。
以电子设备200为例,电子设备100接收到电子设备200发送的扫描结果,扫描结果中包括设备标识b、UUID1和UUID2。电子设备100根据扫描结果,保存电子设备200支持的蓝牙服务的信息如表6所示。
表6
Figure PCTCN2018123556-appb-000007
例如,电子设备100接收到电子设备200的配对成功响应,配对成功响应中包括设备标识b、UUID1、UUID2、UUID3和UUID4,则电子设备100根据电子设备200的配对成功响应更新表6所示的电子设备200支持的蓝牙服务的信息,更新后的电子设备200支持的蓝牙服务的信息如表7所示。
表7
Figure PCTCN2018123556-appb-000008
在本申请另一些实施例中,电子设备100当既保存扫描结果中包括的电子设备支持的蓝牙服务的信息,又保存配对成功响应中包括的电子设备支持的蓝牙服务的信息时,电子设备100对扫描结果中包括的电子设备支持的蓝牙服务的信息、和配对成功响应中包括的电子设备支持的蓝牙服务的信息可以单独存储。例如,以电子设备200为例,电子设备100接收到电子设备200发送的扫描结果,扫描结果中包括设备标识b、UUID1和UUID2。电子设备100根据扫描结果,保存电子设备200支持的蓝牙服务的信息如表8所示。
表8
Figure PCTCN2018123556-appb-000009
例如,电子设备100接收到电子设备200的配对成功响应,配对成功响应中包括设备标识b、UUID1、UUID2、UUID3和UUID4,则电子设备100根据配对成功响应,保存电 子设备200支持的蓝牙服务的信息如表9所示。
表9
Figure PCTCN2018123556-appb-000010
示例的,表8所示的电子设备200支持的蓝牙服务的信息可以以第一存储形式存储在存储器1中,表9所示的电子设备200支持的蓝牙服务的信息可以以第二存储形式存储在存储器2中。其中,第一存储形式和第二存储形式可以不同,例如第一存储形式可以为数据库,第二存储形式可以为配置文件,第一存储形式和第二存储形式也可以相同。存储器1和存储器2可以相同,也可以不同。
在另外一些实施例中,电子设备100中预先存储的电子设备支持的蓝牙服务的信息还可以为电子设备100出厂之前存储的。例如,电子设备100中预先存储的电子设备设备支持的蓝牙服务的信息可以包括设备类型、以及与设备类型对应的至少一个UUID。示例的,电子设备100中预先存储的电子设备支持的蓝牙服务的信息可以如表10所示。
表10
Figure PCTCN2018123556-appb-000011
基于上述电子设备100存储电子设备支持的蓝牙服务的方法,本申请实施例提供了一种蓝牙服务的查询方法。示例的,如图7所示,为本申请实施例提供的一种蓝牙服务的查询方法的流程示意图。包括以下步骤。
步骤701,电子设备100检测到第一应用程序请求获取电子设备200的蓝牙服务。
步骤702,电子设备100根据电子设备200的标识,从预先存储的电子设备支持的蓝牙服务的信息中,查询电子设备200支持的蓝牙服务。
需要说明的是,在一些实施例中,第一应用程序可以为系统应用(例如系统设置等),可以为第三方应用(例如微信、优酷视频等),对此不作限定。在另一些实施例中,第一应用程序为第三方应用。电子设备100当系统应用请求获取电子设备200的蓝牙服务时,可以采用现有技术中蓝牙服务的查询方式来获取。
以图2所示的电子设备100的结构为例。具体的,处理器110(例如应用处理器)检测到第一应用程序请求获取电子设备200的蓝牙服务时,可以调用第一应用程序的接口, 向无线通信模块132(例如蓝牙芯片)发送获取电子设备200的蓝牙服务的请求。无线通信模块132通过第一应用程序的接口接收到处理器110发送的获取电子设备200的蓝牙服务的请求,则根据电子设备200的标识,从预先存储在相应存储器的电子设备支持的蓝牙服务的信息中,获取电子设备200的蓝牙服务,并将获取的电子设备200的蓝牙服务通过第一应用程序的接口返回给处理器110。
然而,由于第一应用程序请求查询电子设备200的蓝牙服务时,电子设备200与电子设备100所处于配对状态可能是已配对,也可能是正在配对,还有可能是未配对,因此,在一些具体的实施例中,电子设备100可以在检测到第一应用程序请求获取电子设备200的蓝牙服务后,先检测电子设备200与电子设备100所处的配对状态。当电子设备200与电子设备100处于已配对状态时,再执行步骤702,当电子设备200与电子设备100处于正在配对状态时,可以等待电子设备200与电子设备100配对成功后,在执行步骤702。当电子设备200与电子设备100处于未配对状态时,可以不再执行查询电子设备200支持的蓝牙服务的步骤,从而有助于减少电子设备100的信令处理。
示例的,无线通信模块132通过第一应用程序的接口接收到处理器110发送的获取电子设备200的蓝牙服务的请求后,可以先检测电子设备100与电子设备200所处的配对状态,然后根据电子设备100与电子设备200所处的配对状态,判断是否执行查询电子设备200支持的蓝牙服务的步骤。
在另一些实施例中,电子设备100当从预先存储在相应存储器的电子设备支持的蓝牙服务的信息中未获取到电子设备200的蓝牙服务时,可以向电子设备200发送蓝牙服务的查询命令。从而有助于提高电子设备100获取电子设备200支持的蓝牙服务成功的可能性。需要说明的是,电子设备100向电子设备200发送的蓝牙服务的查询命令可以为SDP命令。
示例的,无线通信模块132当从预先存储在相应存储器的电子设备支持的蓝牙服务的信息中未获取到电子设备200的蓝牙服务时,可以直接向电子设备200发送蓝牙服务的查询命令,也可以通过第一应用程序的接口向处理器110发送查询失败的通知,由处理器110决定是否由无线通信模块132向电子设备200发送蓝牙服务的查询命令。具体的,本申请实施例对处理器110判断是否由无线通信模块132向电子设备200发送蓝牙查询命令的策略可以根据实际情况需要进行设定。
特别的,在电子设备100采用图6所示的方法来预先存储电子设备支持的蓝牙服务的信息,且扫描结果和配对成功响应中包括的电子设备支持的蓝牙服务的信息分开存储情况下,在具体实现时,电子设备100还可以通过其它方式查询电子设备200的蓝牙服务。
下面以步骤602中电子设备100将至少一个电子设备支持的蓝牙服务的信息存储为uuid.db、步骤605中电子设备100将电子设备支持的蓝牙服务的信息存储为bt_config.conf文件为例,对第一应用程序请求查询电子设备200的蓝牙服务进行详细说明。
在一些实施例中,电子设备100检测到第一应用程序请求获取电子设备200的蓝牙服务,根据电子设备200与电子设备100所处的配对状态,确定从uuid.d还是从bt_config.conf中查询电子设备200支持的蓝牙服务。
需要说明的是,第一应用程序可以为系统应用,也可以为第三方应用,对此不作限定。另外,在本申请实施例中,电子设备100还可以在检测到第一应用程序请求获取电子设备200的蓝牙服务时,若第一应用程序为第三方应用,则根据电子设备200与电子设备100 所处的配对状态,确定从uuid.d还是从bt_config.conf中查询电子设备200支持的蓝牙服务。在一些实施例中,电子设备100检测到第一应用程序请求获取电子设备200的蓝牙服务时,若第一应用程序为系统应用,则可以直接从bt_config.conf中查询电子设备200支持的蓝牙服务。
下面对电子设备100根据电子设备200与电子设备100所处的配对状态,确定从uuid.d还是从bt_config.conf中查询电子设备200支持的蓝牙服务进行详细说明。
例如,电子设备100当电子设备200与电子设备100处于已配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务,以及从bt_config.conf中查询电子设备200支持的蓝牙服务,并对分别从uuid.db中查询到的电子设备200支持的蓝牙服务、和从bt_config.conf中查询电子设备200支持的蓝牙服务取并集,得到电子设备200支持的蓝牙服务。
以如图2所示的电子设备100的硬件结构为例。具体的,无线通信模块132当电子设备200与电子设备100处于已配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务,以及从bt_config.conf中查询电子设备200支持的蓝牙服务,并对分别从uuid.db中查询到的电子设备200支持的蓝牙服务、和从bt_config.conf中查询电子设备200支持的蓝牙服务取并集,然后将取并集后的电子设备200支持的蓝牙服务返回给处理器110。示例的,无线通信模块132可以通过第一应用程序的接口,将取并集后的电子设备200支持的蓝牙服务返回给处理器110,也可以由无线通信模块132通过intent广播取并集后的电子设备200支持的蓝牙服务,处理器110调用第一应用程序的接口来监测到intent广播,来接收取并集后的电子设备200支持的蓝牙服务。
再例如,电子设备100当电子设备200与电子设备100处于未配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务。
以如图2所示的电子设备100的硬件结构为例。具体的,无线通信模块132当电子设备200与电子设备100处于未配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务,然后通过第一应用程序的接口将查询到的电子设备200支持的蓝牙服务返回给处理器110。在一些实施例中,无线通信模块132当电子设备200与电子设备100处于未配对状态时,从uuid.db中未查询到电子设备200支持的蓝牙服务,则通过第一应用程序的接口向处理器110返回查询失败的通知。
又例如,电子设备100当电子设备200与电子设备100处于正在配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务。
以如图2所示的电子设备100的硬件结构为例。具体的,无线通信模块132当电子设备200与电子设备100处于正在配对状态时,可以从uuid.db中查询电子设备200支持的蓝牙服务,然后通过第一应用程序的接口将查询到的电子设备200支持的蓝牙服务返回给处理器110。在另一些实施例中,无线通信模块132当电子设备200与电子设备100处于正在配对状态时,从uuid.db中未查询到电子设备200支持的蓝牙服务,则通过第一应用程序的接口向处理器110返回电子设备200与电子设备100处于正在配对的状态。处理器110通过第一应用程序的接口接收到电子设备200与电子设备100处于正在配对的状态后,确定当前为busy模式,可以等电子设备200与电子设备100配对成功后,再通过第一应用程序的接口向无线通信模块132发送获取电子设备200的蓝牙服务的请求。此外,处理器110通过第一应用程序的接口接收到电子设备200与电子设备100处于正在配对的状态后,确定当前为busy模式,可以通过第一应用程序的接口向无线通信模块132发送等待电子设 备200与电子设备100配对成功再查询电子设备200的蓝牙服务的通知。
上述各个实施例可以单独使用,也可以相互结合使用,以达到不同的技术效果。
上述本申请提供的实施例中,从电子设备作为执行主体的角度对本申请实施例提供的方法进行了介绍。为了实现上述本申请实施例提供的方法中的各功能,电子设备可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。
基于相同的构思,图8所示为本申请提供的一种电子设备800。电子设备800包括至少一个处理器810、至少一个存储器830和收发器820。其中,处理器810与收发器820、存储器830耦合,本申请实施例中的耦合是装置、单元或模块之间的间接耦合或通信连接,可以是电性,机械或其它的形式,用于装置、单元或模块之间的信息交互。
具体的,收发器820用于接收或发送数据。例如,收发器820可以用于接收扫描结果、或者配对成功响应,或者发送配对请求等。
存储器830存储有第一应用程序和代码指令的相关数据。应理解,用于存储第一应用程序的存储器和用于存储代码指令的存储器可以相同,也可以不同,对此不作限定。此外,在一些实施例中,存储器830还包括第一存储器和第二存储器,其中第一存储器用于存储从扫描结果中获取的电子设备支持的蓝牙服务信息,第二存储器用于存储从配对成功响应中获取的电子设备支持的蓝牙服务信息。应理解,第一存储器和第二存储器可以为同一个存储器,也可以为两个不同的存储器,对此不作限定。存储器830可以为图2所示的内部存储器121,也可以为与外部存储器接口122连接的存储器,还可以为处理器110或者无线通信模块132中设置的存储器等。
处理器810用于调用存储器830存储的代码指令等相关数据,结合收发器820执行本申请本申请实施例提供的蓝牙服务的查询方法。例如保存扫描结果中包括的电子设备支持的蓝牙服务信息和/或配对成功响应中包括的电子设备支持的蓝牙服务的信息,以及从保存的蓝牙服务信息中,查询电子设备支持的蓝牙服务等。
应理解,该电子设备800可以用于实现本申请实施例蓝牙服务的查询方法,相关特征可以参照方法部分,此处不再赘述。
需要说明的是,本申请实施例中处理器810和收发器820的功能可以集成在一起,例如图2所示的无线通信模块132,也可以将处理器810的功能的集成在图2所示的处理器110(例如应用处理器)中,将收发器820的功能集成在图2所示的无线通信模块132中,又可以将处理器810的部分功能的集成在图2所示的处理器110(例如应用处理器)中,另一部分功能集成在无线通信模块132中。
示例的,如图9所示,本申请提供的一种芯片900。芯片900包括至少一个处理器910、接口920。其中,接口920用于接收代码指令,并将接收的代码指令发送至处理器910,处理器910运行接收到的所述接口发送的所述代码指令,执行本申请实施例蓝牙服务的查询方法,具体的蓝牙服务的查询方式可以参见方法部分的实施例,在此不再赘述。
所属领域的技术人员可以清楚地了解到本申请实施例可以用硬件实现,或固件实现,或它们的组合方式来实现。当使用软件实现时,可以将上述功能存储在计算机可读介质中或作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的 任何介质。存储介质可以是计算机能够存取的任何可用介质。以此为例但不限于:计算机可读介质可以包括RAM、ROM、电可擦可编程只读存储器(electrically erasable programmable read only memory,EEPROM)、只读光盘(compact disc read-Only memory,CD-ROM)或其他光盘存储、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质。此外。任何连接可以适当的成为计算机可读介质。例如,如果软件是使用同轴电缆、光纤光缆、双绞线、数字用户线(digital subscriber line,DSL)或者诸如红外线、无线电和微波之类的无线技术从网站、服务器或者其他远程源传输的,那么同轴电缆、光纤光缆、双绞线、DSL或者诸如红外线、无线和微波之类的无线技术包括在所属介质的定影中。如本申请实施例所使用的,盘(disk)和碟(disc)包括压缩光碟(compact disc,CD)、激光碟、光碟、数字通用光碟(digital video disc,DVD)、软盘和蓝光光碟,其中盘通常磁性的复制数据,而碟则用激光来光学的复制数据。上面的组合也应当包括在计算机可读介质的保护范围之内。
总之,以上所述仅为本申请的实施例而已,并非用于限定本申请的保护范围。凡根据本申请的揭露,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种蓝牙服务的查询方法,其特征在于,应用于第一电子设备,所述第一电子设备开启了蓝牙功能,且安装有第一应用程序;所述方法包括:
    所述第一电子设备接收至少一个开启了蓝牙功能的电子设备发送的扫描结果,每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识所标识的电子设备支持的一个蓝牙服务;
    所述第一电子设备将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;
    所述第一电子设备检测到第一应用程序请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
  2. 如权利要求1所述的方法,其特征在于,所述方法还包括:
    针对所述至少一个开启了蓝牙功能的电子设备中的一个电子设备,所述第一电子设备当再次接收到所述电子设备发送的扫描结果,则根据再次接收到所述电子设备发送的扫描结果,更新所述第一蓝牙服务信息。
  3. 如权利要求1或2所述的方法,其特征在于,所述方法还包括:
    所述第一电子设备向所述至少一个开启了蓝牙功能的电子设备中的待配对的电子设备发送配对请求;
    所述第一电子设备接收所述待配对的电子设备接收到所述配对请求后,发送的配对成功响应,所述配对成功响应包括待配对的电子设备的标识和至少一个UUID;
    所述第一电子设备将所述配对成功响应包括的待配对的电子设备的标识和至少一个UUID保存为所述第二蓝牙服务信息。
  4. 如权利要求3所述的方法,其特征在于,所述第一电子设备检测到第一应用程序请求查询第二电子设备的蓝牙服务时,还包括:
    所述电子设备从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务;
    所述电子设备将从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务、以及从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务取并集,得到所述第二电子设备支持的蓝牙服务。
  5. 如权利要求1至4任一所述的方法,其特征在于,所述第二电子设备与所述第一电子设备处于已配对状态。
  6. 如权利要求5所述的方法,其特征在于,所述方法还包括:
    所述第一电子设备检测到第一应用程序请求查询第三电子设备的蓝牙服务时,若所述第三电子设备与所述第一电子设备处于未配对状态或者正在配对状态,则根据第三电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
  7. 如权利要求1至6任一所述的方法,其特征在于,所述第一应用程序为第三方应用。
  8. 如权利要求3至7任一所述的方法,其特征在于,所述方法还包括:
    所述第一电子设备检测到系统应用请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
  9. 一种第一电子设备,其特征在于,所述第一电子设备开启了蓝牙功能;其中,所 述第一电子设备包括处理器、存储器和收发器;
    所述存储器,存储有第一应用程序和代码指令;
    所述收发器,用于接收或发送数据;
    所述处理器,用于调用所述存储器存储的代码指令,结合所述收发器执行:
    接收至少一个开启了蓝牙功能的电子设备发送的扫描结果;每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识所标识的电子设备支持的一个蓝牙服务;
    将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;
    当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
  10. 如权利要求9所述的第一电子设备,其特征在于,所述第一蓝牙服务信息以数据库的形式存储。
  11. 如权利要求9或10所述的第一电子设备,其特征在于,所述代码指令还包括:用于针对所述至少一个开启了蓝牙功能的电子设备中的一个电子设备,当再次接收到所述电子设备发送的扫描结果,则根据再次接收到所述电子设备发送的扫描结果,更新所述第一蓝牙服务信息的指令。
  12. 如权利要求9至11任一所述的第一电子设备,其特征在于,当开启了蓝牙功能的电子设备为经典蓝牙设备时,扫描结果为扩展需求结果extended inquiry result;和/或,当开启了蓝牙功能的电子设备为低功耗蓝牙设备时,扫描结果为广播包。
  13. 如权利要求9至12任一所述的第一电子设备,其特征在于,所述代码指令还包括:
    用于向所述至少一个开启了蓝牙功能的电子设备中的待配对的电子设备发送配对请求的指令;
    用于接收所述待配对的电子设备接收到所述配对请求后,发送的配对成功响应的指令,所述配对成功响应包括待配对的电子设备的标识和至少一个UUID;
    用于将所述通信接口接收到的所述配对成功响应包括的待配对的电子设备的标识和至少一个UUID保存为所述第二蓝牙服务信息的指令。
  14. 如权利要求13所述的第一电子设备,其特征在于,所述第二蓝牙服务信息是以配置文件的形式存储的。
  15. 如权利要求13或14所述的第一电子设备,其特征在于,所述代码指令还包括:
    用于当检测到第一应用程序请求查询第二电子设备的蓝牙服务时,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令;以及用于将从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务、以及从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务取并集,得到所述第二电子设备支持的蓝牙服务的指令。
  16. 如权利要求9至15任一所述的第一电子设备,其特征在于,所述第二电子设备与所述第一电子设备处于已配对状态。
  17. 如权利要求16所述的第一电子设备,其特征在于,所述代码指令还包括:
    用于当检测到第一应用程序请求查询第三电子设备的蓝牙服务时,若所述第三电子设备与所述第一电子设备处于未配对状态或者正在配对状态,则根据第三电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
  18. 如权利要求9至17任一所述的第一电子设备,其特征在于,所述第一应用程序为第三方应用。
  19. 如权利要求13至18任一所述的第一电子设备,其特征在于,所述代码指令还包括:用于当检测到系统应用请求查询第二电子设备的蓝牙服务时,根据第二电子设备的标识,从所述第二蓝牙服务信息中查询第二电子设备支持的蓝牙服务的指令。
  20. 一种芯片,其特征在于,所述芯片包括处理器和接口;
    所述接口,用于接收代码指令,并将接收的所述代码指令传输至所述处理器;
    所述处理器,用于运行接收到的所述接口发送的所述代码指令,执行:
    接收至少一个开启了蓝牙功能的电子设备发送的扫描结果;每个扫描结果中包括设备标识和至少一个通用唯一识别码UUID;每个UUID用于标识设备标识所标识的电子设备支持的一个蓝牙服务;
    将接收到的扫描结果中包括的设备标识和至少一个UUID保存为第一蓝牙服务信息;
    当接收到第一应用程序获取第二电子设备的蓝牙服务的请求时,根据第二电子设备的标识,从所述第一蓝牙服务信息中查询第二电子设备支持的蓝牙服务。
PCT/CN2018/123556 2018-12-25 2018-12-25 一种蓝牙服务的查询方法及电子设备 WO2020132878A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880098126.3A CN112789934B (zh) 2018-12-25 2018-12-25 一种蓝牙服务的查询方法及电子设备
PCT/CN2018/123556 WO2020132878A1 (zh) 2018-12-25 2018-12-25 一种蓝牙服务的查询方法及电子设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/123556 WO2020132878A1 (zh) 2018-12-25 2018-12-25 一种蓝牙服务的查询方法及电子设备

Publications (1)

Publication Number Publication Date
WO2020132878A1 true WO2020132878A1 (zh) 2020-07-02

Family

ID=71127305

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/123556 WO2020132878A1 (zh) 2018-12-25 2018-12-25 一种蓝牙服务的查询方法及电子设备

Country Status (2)

Country Link
CN (1) CN112789934B (zh)
WO (1) WO2020132878A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113950034A (zh) * 2021-10-14 2022-01-18 北京鲸鲮信息系统技术有限公司 蓝牙行为的模拟方法、装置和设备
CN116033333A (zh) * 2022-08-31 2023-04-28 荣耀终端有限公司 确定位置信息的方法、电子设备及可读存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114466339B (zh) * 2021-06-18 2023-05-23 荣耀终端有限公司 蓝牙配对的方法、系统、存储介质及芯片
CN114143765B (zh) * 2022-02-08 2022-07-08 荣耀终端有限公司 蓝牙回连方法、装置和存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060135065A1 (en) * 2004-12-17 2006-06-22 Samsung Electronics Co., Ltd. Bluetooth device and method for providing service determined according to bluetooth pin
CN104540190A (zh) * 2014-12-30 2015-04-22 广州视源电子科技股份有限公司 与蓝牙设备配对的方法和系统
CN105792094A (zh) * 2014-12-22 2016-07-20 中兴通讯股份有限公司 一种实现一卡多机的方法及装置
CN106788612A (zh) * 2016-12-15 2017-05-31 青岛海信电器股份有限公司 一种基于a2dp协议的蓝牙模式调整方法及蓝牙设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101382200B1 (ko) * 2011-12-21 2014-04-07 전남대학교산학협력단 블루투스 디바이스 검색 방법
CN103840860B (zh) * 2014-02-27 2016-08-17 天地融科技股份有限公司 一种蓝牙通信方法和装置
CN105187878B (zh) * 2015-09-07 2018-11-16 深圳Tcl数字技术有限公司 电视蓝牙连接方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060135065A1 (en) * 2004-12-17 2006-06-22 Samsung Electronics Co., Ltd. Bluetooth device and method for providing service determined according to bluetooth pin
CN105792094A (zh) * 2014-12-22 2016-07-20 中兴通讯股份有限公司 一种实现一卡多机的方法及装置
CN104540190A (zh) * 2014-12-30 2015-04-22 广州视源电子科技股份有限公司 与蓝牙设备配对的方法和系统
CN106788612A (zh) * 2016-12-15 2017-05-31 青岛海信电器股份有限公司 一种基于a2dp协议的蓝牙模式调整方法及蓝牙设备

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113950034A (zh) * 2021-10-14 2022-01-18 北京鲸鲮信息系统技术有限公司 蓝牙行为的模拟方法、装置和设备
CN113950034B (zh) * 2021-10-14 2024-04-26 北京字节跳动网络技术有限公司 蓝牙行为的模拟方法、装置和设备
CN116033333A (zh) * 2022-08-31 2023-04-28 荣耀终端有限公司 确定位置信息的方法、电子设备及可读存储介质
CN116033333B (zh) * 2022-08-31 2023-10-17 荣耀终端有限公司 确定位置信息的方法、电子设备及可读存储介质

Also Published As

Publication number Publication date
CN112789934A (zh) 2021-05-11
CN112789934B (zh) 2023-04-18

Similar Documents

Publication Publication Date Title
WO2021147686A1 (zh) 引导智能设备接入网络的方法、介质、控制终端及系统
WO2021036809A1 (zh) 一种sim模块的管理方法及电子设备
CN106030556B (zh) 操作电子装置的功能和资源的方法
US11310848B2 (en) Pairing method, unpairing method, terminal device, and externally-connected device
WO2020132878A1 (zh) 一种蓝牙服务的查询方法及电子设备
WO2021082829A1 (zh) 蓝牙连接方法及相关装置
WO2020151385A1 (zh) 一种控制智能家居设备连网的方法及设备
WO2020078330A1 (zh) 一种基于语音通话的翻译方法及电子设备
WO2021017894A1 (zh) 一种使用远程sim模块的方法及电子设备
US20150065053A1 (en) Method of controlling short-range wireless communication and apparatus supporting the same
CN113660650B (zh) 设备回连的方法及相关装置
WO2021104114A1 (zh) 一种提供无线保真WiFi网络接入服务的方法及电子设备
CN109327613B (zh) 一种基于语音通话翻译能力的协商方法及电子设备
CN116114239B (zh) 音量管理的方法及电子设备
WO2023065931A1 (zh) 一种电子设备的充电方法及电子设备
CN117014859A (zh) 基于通讯录的设备发现方法、音视频通信方法及电子设备
CN113853754A (zh) 在蓝牙tm网络环境中显示外部电子设备查询列表的电子设备和方法
JP7204902B2 (ja) ファイル転送方法および電子デバイス
WO2022042765A1 (zh) 一种显示方法及电子设备
CN114173321B (zh) 设备通信连接建立方法及设备通信系统
WO2021218544A1 (zh) 一种提供无线上网的系统、方法及电子设备
CN113810887A (zh) 蓝牙协议连接方法、装置、存储介质及相关设备
WO2023051204A1 (zh) 跨设备连接方法、电子设备及存储介质
WO2023029938A1 (zh) Tws耳机解耦分享方法、装置、设备及存储介质
WO2022052907A1 (zh) 一种显示方法及电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18944765

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18944765

Country of ref document: EP

Kind code of ref document: A1