CN110177357B - Bluetooth management method, mobile terminal and computer storage medium - Google Patents

Bluetooth management method, mobile terminal and computer storage medium Download PDF

Info

Publication number
CN110177357B
CN110177357B CN201910413498.7A CN201910413498A CN110177357B CN 110177357 B CN110177357 B CN 110177357B CN 201910413498 A CN201910413498 A CN 201910413498A CN 110177357 B CN110177357 B CN 110177357B
Authority
CN
China
Prior art keywords
peripheral device
target
mobile terminal
bluetooth
application protocol
Prior art date
Legal status (The legal status 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 status listed.)
Expired - Fee Related
Application number
CN201910413498.7A
Other languages
Chinese (zh)
Other versions
CN110177357A (en
Inventor
方攀
陈岩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201910413498.7A priority Critical patent/CN110177357B/en
Publication of CN110177357A publication Critical patent/CN110177357A/en
Application granted granted Critical
Publication of CN110177357B publication Critical patent/CN110177357B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/50Service provisioning or reconfiguring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. Transmission Power Control [TPC] or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0225Power saving arrangements in terminal devices using monitoring of external events, e.g. the presence of a signal
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Telephone Function (AREA)

Abstract

本申请公开了一种蓝牙管理方法、移动终端以及计算机存储介质,该蓝牙管理方法包括:移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。通过上述方式,能够降低蓝牙应用程序的功耗和内存占用。

Figure 201910413498

The present application discloses a Bluetooth management method, a mobile terminal and a computer storage medium. The Bluetooth management method includes: when the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are enabled; and the target application protocol supported by the target peripheral device is determined; The target peripheral device is one or more peripheral devices that perform Bluetooth communication with the mobile terminal; the service classes corresponding to application protocols other than the target application protocol are closed. In the above manner, the power consumption and memory occupation of the Bluetooth application can be reduced.

Figure 201910413498

Description

一种蓝牙管理方法、移动终端以及计算机存储介质A Bluetooth management method, mobile terminal and computer storage medium

技术领域technical field

本申请涉及蓝牙技术领域,特别是涉及一种蓝牙管理方法、移动终端以及计算机存储介质。The present application relates to the field of Bluetooth technology, and in particular, to a Bluetooth management method, a mobile terminal and a computer storage medium.

背景技术Background technique

蓝牙是一种被广泛使用的短距离通信技术。基于蓝牙技术,可以实现多种不同的功能,例如免提电话、音频流传输、文件传输等,这些所谓的功能被称为蓝牙profile(应用协议),例如,上述提到的三种功能对应的profile分别是HFP(免提协议)、A2DP(音频传输协议)、OPP(目标推送协议)。尽管所有profile都是基于蓝牙L2CAP(逻辑链路控制适配协议,是蓝牙的基础协议)来实现的,但是每个profile都具有各自完全不同的逻辑。Bluetooth is a widely used short-range communication technology. Based on Bluetooth technology, a variety of different functions can be implemented, such as hands-free calling, audio streaming, file transfer, etc. These so-called functions are called Bluetooth profiles (application protocols). For example, the three functions mentioned above correspond to The profiles are HFP (Hands-Free Protocol), A2DP (Audio Transmission Protocol), and OPP (Object Push Protocol). Although all profiles are implemented based on Bluetooth L2CAP (Logical Link Control Adaptation Protocol, which is the basic protocol of Bluetooth), each profile has its own completely different logic.

发明内容SUMMARY OF THE INVENTION

本申请采用的一个技术方案是:提供一种蓝牙管理方法,该方法包括:当移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。A technical solution adopted in the present application is to provide a Bluetooth management method, the method includes: when the mobile terminal starts Bluetooth, enabling service classes corresponding to all application protocols; determining the target application protocol supported by the target peripheral device; wherein, The target peripheral device is one or more peripheral devices that perform Bluetooth communication with the mobile terminal; the service classes corresponding to application protocols other than the target application protocol are closed.

本申请采用的另一个技术方案是:提供一种移动终端,该移动终端包括处理器以及与处理器连接的蓝牙模组和存储器;其中,蓝牙模组用于与外围设备配对进行蓝牙通信,存储器用于存储程序数据,处理器用于执行程序数据以实现如下方法:移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。Another technical solution adopted in the present application is to provide a mobile terminal, the mobile terminal includes a processor, a Bluetooth module connected to the processor, and a memory; wherein the Bluetooth module is used for pairing with peripheral devices for Bluetooth communication, and the memory It is used to store program data, and the processor is used to execute the program data to realize the following method: when the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are opened; the target application protocol supported by the target peripheral device is determined; wherein, the target peripheral device is One or more peripheral devices that perform Bluetooth communication with the mobile terminal; close the service classes corresponding to application protocols other than the target application protocol.

本申请采用的另一个技术方案是:提供一种计算机存储介质,该计算机存储介质中存储有程序数据,程序数据在被处理器执行时,用以实现如下方法:移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。Another technical solution adopted in the present application is to provide a computer storage medium, in which program data is stored, and when the program data is executed by the processor, the following method is implemented: when the mobile terminal starts Bluetooth, the Service classes corresponding to all application protocols; determine the target application protocols supported by the target peripheral device; wherein, the target peripheral device is one or more peripheral devices that perform Bluetooth communication with the mobile terminal; close all application protocols except the target application protocol. the corresponding service class.

本申请提供的蓝牙管理方法包括:移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。通过上述方式,根据配对的外围设备所支持的应用协议,对蓝牙应用程序中与profile对应的Service类进行动态的开关,避免了所有Service类都开启的情况下功耗较大以及内存占用较高的问题,能够降低蓝牙应用程序的功耗和内存占用。The Bluetooth management method provided by the present application includes: when the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are enabled; the target application protocol supported by the target peripheral device is determined; wherein, the target peripheral device is a device that performs Bluetooth communication with the mobile terminal. or multiple peripheral devices; close the service class corresponding to the application protocol other than the target application protocol. Through the above method, according to the application protocol supported by the paired peripheral device, dynamically switch the Service class corresponding to the profile in the Bluetooth application program to avoid high power consumption and high memory occupation when all Service classes are turned on. The problem can reduce the power consumption and memory usage of the Bluetooth application.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。其中:In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort. in:

图1是本申请实施例提供的蓝牙管理方法的第一流程示意图;FIG. 1 is a first schematic flowchart of a Bluetooth management method provided by an embodiment of the present application;

图2是本申请实施例提供的确定目标应用协议的流程示意图;2 is a schematic flowchart of determining a target application protocol provided by an embodiment of the present application;

图3是本申请实施例提供的蓝牙管理方法的第二流程示意图;3 is a second schematic flowchart of a Bluetooth management method provided by an embodiment of the present application;

图4是本申请实施例提供的移动终端与外围设备配对示意图;4 is a schematic diagram of pairing a mobile terminal and a peripheral device provided by an embodiment of the present application;

图5是本申请实施例提供的蓝牙管理方法的第三流程示意图;5 is a third schematic flowchart of a Bluetooth management method provided by an embodiment of the present application;

图6是本申请实施例提供的移动终端的结构示意图;6 is a schematic structural diagram of a mobile terminal provided by an embodiment of the present application;

图7是本申请实施例提供的计算机存储介质的结构示意图。FIG. 7 is a schematic structural diagram of a computer storage medium provided by an embodiment of the present application.

具体实施方式Detailed ways

参阅图1,图1是本申请实施例提供的蓝牙管理方法的第一流程示意图,该方法包括:Referring to FIG. 1, FIG. 1 is a first schematic flowchart of a Bluetooth management method provided by an embodiment of the present application, and the method includes:

步骤101:当移动终端在启动蓝牙时,开启所有应用协议对应的服务类。Step 101 : when the mobile terminal starts the Bluetooth, the service classes corresponding to all the application protocols are started.

蓝牙(Bluetooth)是一种无线技术标准,可实现固定设备、移动设备和楼宇个人域网之间的短距离数据交换(使用2.4—2.485GHz的ISM 波段的UHF无线电波)。Bluetooth (Bluetooth) is a wireless technology standard that can realize short-distance data exchange between fixed devices, mobile devices and building personal area networks (UHF radio waves in the ISM band of 2.4-2.485GHz).

蓝牙中的L2CAP(Logical Link Control and Adaptation Protocol)协议也称为逻辑链路控制和适配协议,是蓝牙系统中的核心协议,负责适配基带中的上层协议。The L2CAP (Logical Link Control and Adaptation Protocol) protocol in Bluetooth is also called the Logical Link Control and Adaptation Protocol. It is the core protocol in the Bluetooth system and is responsible for adapting the upper layer protocol in the baseband.

通过下表对蓝牙的上层应用协议进行列举:The upper-layer application protocols of Bluetooth are listed in the following table:

HFPHFP 免提协议hands-free protocol Hands Free ProtocolHands Free Protocol A2DPA2DP 音频传输协议audio transmission protocol Advanced Audio Distribution ProfileAdvanced Audio Distribution Profile OPPOPP 目标推送协议target push protocol Object Push ProtocolObject Push Protocol AVRCPAVRCP 音视频远程控制协议Audio and video remote control protocol Audio Video Remote Control ProtocolAudio Video Remote Control Protocol GATTGATT 通用属性协议Common Attribute Protocol Generic AttributeGeneric Attribute PANPAN 个人范围局域网协议Personal Area Local Area Network Protocol Personal Area NetworkPersonal Area Network PBAPPBAP 电话本访问协议Phone Book Access Agreement Phone Book Access ProtocolPhone Book Access Protocol HIDHID 人体输入设备协议Human Input Device Protocol Human Input Device Human Input Device

在Android(安卓)系统中,蓝牙功能被集成于一个蓝牙应用程序(Bluetooth.apk)中,而每个profile的逻辑在Bluetooth.apk通过一个 Service类(服务类)来实现(这些Service类都是继承自 android.app.Service类)。In the Android (Android) system, the Bluetooth function is integrated into a Bluetooth application (Bluetooth.apk), and the logic of each profile is implemented in Bluetooth.apk through a Service class (service class) (these Service classes are all Inherited from the android.app.Service class).

当开启蓝牙功能时,Bluetooth.apk中会通过解析一个配置文件,来获取当前手机当前所支持的蓝牙profile,并根据所支持的profile来开启所有与之对应的Service类。常用的蓝牙profile以及其在Bluetooth.apk 中对应的Service类之间的对应关系如下表所示:When the Bluetooth function is enabled, the Bluetooth.apk will parse a configuration file to obtain the Bluetooth profile currently supported by the current mobile phone, and open all the corresponding Service classes according to the supported profile. The correspondence between the commonly used Bluetooth profiles and their corresponding Service classes in Bluetooth.apk is shown in the following table:

Figure BDA0002063578360000031
Figure BDA0002063578360000031

Figure BDA0002063578360000041
Figure BDA0002063578360000041

当这些profile对应的Service类被开启后,各profile就处于可用状态。当关闭蓝牙功能时,上述的Service都会被关闭。When the Service classes corresponding to these profiles are enabled, each profile is available. When the Bluetooth function is turned off, the above Services will be turned off.

步骤102:确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备。Step 102: Determine the target application protocol supported by the target peripheral device; wherein, the target peripheral device is one or more peripheral devices that perform Bluetooth communication with the mobile terminal.

在一些实施例中,该外围设备可以是蓝牙耳机、蓝牙音箱、蓝牙对讲机等蓝牙功能性设备,也可以是其他移动终端,如手机、平板电脑、可穿戴设备等。In some embodiments, the peripheral device may be a Bluetooth functional device such as a Bluetooth headset, a Bluetooth speaker, or a Bluetooth walkie-talkie, or other mobile terminals, such as a mobile phone, a tablet computer, a wearable device, and the like.

在一些实施例中,可以默认移动终端支持所有的应用协议,那么,可以认为只要是外围设备所支持的应用协议,移动终端也支持。所以,可以直接获取目标外围设备所支持的应用协议作为目标应用协议。In some embodiments, it can be assumed that the mobile terminal supports all application protocols by default. Then, it can be considered that as long as the application protocols supported by the peripheral device are supported by the mobile terminal, the mobile terminal also supports. Therefore, the application protocol supported by the target peripheral device can be directly obtained as the target application protocol.

可以理解地,若目标外围设备所支持的某一个应用协议移动终端不支持,那么,移动终端与该外围设备就没有建立蓝牙连接的意义了。Understandably, if a certain application protocol supported by the target peripheral device is not supported by the mobile terminal, then there is no meaning of establishing a Bluetooth connection between the mobile terminal and the peripheral device.

在另一些实施例中,如图2所示,图2是本申请实施例提供的确定目标应用协议的流程示意图,步骤101可以具体包括:In other embodiments, as shown in FIG. 2 , which is a schematic flowchart of determining a target application protocol provided by an embodiment of the present application, step 101 may specifically include:

步骤1021:确定移动终端所支持的第一应用协议,以及确定目标外围设备所支持的第二应用协议。Step 1021: Determine the first application protocol supported by the mobile terminal, and determine the second application protocol supported by the target peripheral device.

其中,移动终端自身所支持的第一应用协议可以轻易获取,这里不再赘述,而确定目标外围设备所支持的第二应用协议可以具体采用以下方式:采用服务发现协议(SDP协议,Service Discovery Protocol)获取目标外围设备所支持的第二应用协议。Wherein, the first application protocol supported by the mobile terminal itself can be easily obtained, which will not be repeated here, and the following methods may be specifically adopted to determine the second application protocol supported by the target peripheral device: using the Service Discovery Protocol (SDP, Service Discovery Protocol). ) to obtain the second application protocol supported by the target peripheral device.

SDP协议让移动终端发现配对的外围设备提供的服务以及这些服务的属性。SDP只提供发现服务的机制,不提供使用这些服务的方法。每个蓝牙设备都需要一个SDP协议。SDP协议中的每一个Service用ServiceRecord来表示(具有唯一的32bit的Handle),每一个ServiceRecord 由若干ServiceAttribute组成,ServiceAttribute由Attribute ID和Attribute Valuel两个部分。通过SDP request可以访问这些record,以此来获取外围设备的服务信息,从而获取外围设备所支持的应用协议。The SDP protocol allows mobile terminals to discover the services provided by paired peripherals and the attributes of those services. SDP only provides a mechanism for discovering services, not a method for using these services. Every bluetooth device needs an SDP protocol. Each Service in the SDP protocol is represented by a ServiceRecord (with a unique 32-bit Handle), each ServiceRecord is composed of several ServiceAttributes, and the ServiceAttribute is composed of two parts: Attribute ID and Attribute Valuel. These records can be accessed through the SDP request to obtain the service information of the peripheral device, so as to obtain the application protocol supported by the peripheral device.

步骤1022:确定第一应用协议和第二应用协议的交集作为目标应用协议。Step 1022: Determine the intersection of the first application protocol and the second application protocol as the target application protocol.

一般来说,移动终端所支持的第一应用协议的数量是远大于外围设备所支持的第二应用协议的数量的。Generally speaking, the number of the first application protocol supported by the mobile terminal is much larger than the number of the second application protocol supported by the peripheral device.

例如,移动终端所支持的第一应用协议包括HFP协议、A2DP协议、 OPP协议、AVRCP(Controller)协议、GATT协议、PAN协议、PBAP协议、HID协议,假设该外围设备为蓝牙耳机,其支持的第二应用协议包括HFP协议和A2DP协议,那么,第一应用协议和第二应用协议的交集的目标应用协议则包括HFP协议和A2DP协议。For example, the first application protocol supported by the mobile terminal includes HFP protocol, A2DP protocol, OPP protocol, AVRCP (Controller) protocol, GATT protocol, PAN protocol, PBAP protocol, and HID protocol. Assuming that the peripheral device is a Bluetooth headset, it supports The second application protocol includes the HFP protocol and the A2DP protocol. Then, the target application protocol of the intersection of the first application protocol and the second application protocol includes the HFP protocol and the A2DP protocol.

步骤103:关闭除目标应用协议之外的应用协议所对应的服务类。Step 103: Close the service classes corresponding to the application protocols other than the target application protocol.

在一些实施例中,当目标外围设备与移动终端取消蓝牙配对时,查询除目标应用协议之外的应用协议对应的第二服务类的状态;若第二服务类是开启状态,则关闭第二服务类;若第二服务类是关闭状态,则保持关闭状态。In some embodiments, when the target peripheral device and the mobile terminal cancel the Bluetooth pairing, the state of the second service class corresponding to the application protocol other than the target application protocol is queried; if the second service class is on, the second service class is turned off. Service class; if the second service class is closed, keep it closed.

以上述的例子来说明,第一应用协议包括HFP协议、A2DP协议、 OPP协议、AVRCP(Controller)协议、GATT协议、PAN协议、PBAP协议、HID协议,假设该外围设备为蓝牙耳机,其支持的第二应用协议包括HFP协议和A2DP协议,那么,第一应用协议和第二应用协议的交集的目标应用协议则包括HFP协议和A2DP协议。那么,开启的服务器为 HFP协议、A2DP协议对应的服务器类,关闭的服务类则为OPP协议、 AVRCP(Controller)协议、GATT协议、PAN协议、PBAP协议、HID协议对应的服务类。Taking the above example to illustrate, the first application protocol includes HFP protocol, A2DP protocol, OPP protocol, AVRCP (Controller) protocol, GATT protocol, PAN protocol, PBAP protocol, HID protocol, assuming that the peripheral device is a Bluetooth headset, it supports The second application protocol includes the HFP protocol and the A2DP protocol. Then, the target application protocol of the intersection of the first application protocol and the second application protocol includes the HFP protocol and the A2DP protocol. Then, the open server is the server class corresponding to the HFP protocol and A2DP protocol, and the closed service class is the service class corresponding to the OPP protocol, AVRCP (Controller) protocol, GATT protocol, PAN protocol, PBAP protocol, and HID protocol.

另外,在步骤103之后,还可以包括:开启目标应用协议所对应的服务类。In addition, after step 103, it may further include: enabling the service class corresponding to the target application protocol.

可以理解地,在一般情况下,移动终端在开启蓝牙后,会默认开启所有支持的应用协议所对应的服务器类,但是在基于本实施例的蓝牙应用过程中,会根据建立蓝牙连接的目标外围设备的情况,对一些服务类进行关闭,所以,在一些应用场景下,也会对关闭的服务类进行开启。It is understandable that in general, after the mobile terminal turns on Bluetooth, the server classes corresponding to all supported application protocols will be turned on by default. In the case of the device, some service classes are closed, so in some application scenarios, the closed service classes are also opened.

在一些实施例中,当有新的外围设备与移动终端建立蓝牙配对时,重新确定目标外围设备所支持的目标应用协议;或当已与移动终端建立配对的目标外围设备,与移动终端取消蓝牙配对时,重新确定目标外围设备所支持的目标应用协议。In some embodiments, when a new peripheral device establishes a Bluetooth pairing with the mobile terminal, the target application protocol supported by the target peripheral device is re-determined; or when a target peripheral device that has been paired with the mobile terminal, cancels the Bluetooth connection with the mobile terminal When pairing, re-determine the target application protocol supported by the target peripheral.

例如,目标外围设备支持的HFP应用协议对应的服务类为 HeadsetService服务类。在移动终端初始开启蓝牙时,所有服务类(包括HeadsetService服务类)被开启,然后获取目标外围设备支持的HFP 应用协议对应的HeadsetService服务类,关闭除HeadsetService服务类之外的其他服务类。若该目标外围设备取消与移动终端的蓝牙连接,则关闭HeadsetService服务类,若该目标外围设备再次建立与移动终端的蓝牙连接,则开启HeadsetService服务类。For example, the service class corresponding to the HFP application protocol supported by the target peripheral device is the HeadsetService service class. When the mobile terminal initially turns on Bluetooth, all service classes (including the HeadsetService service class) are turned on, then the HeadsetService service class corresponding to the HFP application protocol supported by the target peripheral device is obtained, and other service classes except the HeadsetService service class are turned off. If the target peripheral device cancels the Bluetooth connection with the mobile terminal, the HeadsetService service class is turned off, and if the target peripheral device establishes the Bluetooth connection with the mobile terminal again, the HeadsetService service class is turned on.

本实施例提供的蓝牙管理方法包括:移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。通过上述方式,根据配对的外围设备所支持的应用协议,对Bluetooth.apk中与profile对应的Service类进行动态的开关,避免了所有Service类都开启的情况下功耗较大以及内存占用较高的问题,能够降低Bluetooth.apk的功耗和内存占用。The Bluetooth management method provided by this embodiment includes: when the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are enabled; the target application protocol supported by the target peripheral device is determined; wherein, the target peripheral device is a device that performs Bluetooth communication with the mobile terminal. Peripheral device; closes the service class corresponding to the application protocol other than the target application protocol. Through the above method, according to the application protocol supported by the paired peripheral device, dynamically switch the Service class corresponding to the profile in the Bluetooth.apk, which avoids high power consumption and high memory usage when all Service classes are turned on. The problem can reduce the power consumption and memory usage of Bluetooth.apk.

在一些实施例中,在蓝牙的使用过程中,会有新的外围设备与移动终端建立蓝牙连接,也会有已与移动终端建立蓝牙连接的外围设备与移动终端取消蓝牙连接。在具体应用过程中,若每次都检测移动终端以及目标外围设备共同支持的目标应用协议,相对较为繁琐。可以理解地,在与移动终端建立连接的多个外围设备中,可能存在着型号相同的两个设备,该两个设备所支持的应用协议相同。在本实施例中,可以通过判断是否有相同型号的设备来确定是否重新确定移动终端以及目标外围设备共同支持的目标应用协议。In some embodiments, during the use of Bluetooth, a new peripheral device may establish a Bluetooth connection with the mobile terminal, and a peripheral device that has established a Bluetooth connection with the mobile terminal may cancel the Bluetooth connection with the mobile terminal. In the specific application process, it is relatively cumbersome to detect the target application protocol jointly supported by the mobile terminal and the target peripheral device each time. It can be understood that, among the multiple peripheral devices connected with the mobile terminal, there may be two devices of the same model, and the two devices support the same application protocol. In this embodiment, whether to re-determine the target application protocol jointly supported by the mobile terminal and the target peripheral device can be determined by judging whether there are devices of the same model.

具体地,当有第一外围设备与移动终端建立蓝牙配对时,获取第一外围设备的型号;若一个或多个第一外围设备中存在第二外围设备,第二外围设备与目标外围设备中的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。Specifically, when a first peripheral device establishes a Bluetooth pairing with the mobile terminal, the model of the first peripheral device is obtained; if there is a second peripheral device in one or more first peripheral devices, the second peripheral device and the target peripheral device The model of each peripheral device is different, then re-determine the target application protocol supported by the target peripheral device.

例如,当有第一外围设备与移动终端建立蓝牙连接后,若第一外围设备中存在设备A,与目标外围设备中每个设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。若第一外围设备中的全部设备,均在目标设备中存在一个对之型号相同的设备,则无需再次确定目标外围设备所支持的目标应用协议。For example, after a first peripheral device establishes a Bluetooth connection with the mobile terminal, if device A exists in the first peripheral device, and the model of each device in the target peripheral device is different, the target peripheral device supported by the target peripheral device is re-determined. application protocol. If all the devices in the first peripheral device have a device of the same model in the target device, it is not necessary to determine the target application protocol supported by the target peripheral device again.

具体地,当目标外围设备中已与移动终端建立配对的第三外围设备,与移动终端取消蓝牙配对时,获取第三外围设备的型号;若一个或多个第三外围设备中存在第四外围设备,第四外围设备与目标外围设备中保持蓝牙配对的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。Specifically, when the third peripheral device in the target peripheral device that has been paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, the model of the third peripheral device is obtained; if there is a fourth peripheral device in one or more third peripheral devices device, the fourth peripheral device and the target peripheral device have different models of each peripheral device that maintains Bluetooth pairing, and the target application protocol supported by the target peripheral device is re-determined.

例如,当目标外围设备中已与移动终端建立配对的第三外围设备,与移动终端取消蓝牙配对时,若一个或多个第三外围设备中存在设备B,与目标外围设备中保持蓝牙配对的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。若第三外围设备中的全部设备,均在目标设备中存在一个对之型号相同的设备,则无需再次确定目标外围设备所支持的目标应用协议。For example, when the third peripheral device in the target peripheral device that has been paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, if there is Device B in one or more third peripheral devices, the device B remains paired with the target peripheral device. The model of each peripheral device is different, then re-determine the target application protocol supported by the target peripheral device. If all the devices in the third peripheral device have a device of the same model in the target device, there is no need to determine the target application protocol supported by the target peripheral device again.

参阅图3,图3是本申请实施例提供的蓝牙管理方法的第二流程示意图,该方法包括:Referring to FIG. 3, FIG. 3 is a second schematic flowchart of a Bluetooth management method provided by an embodiment of the present application. The method includes:

步骤301:当移动终端在启动蓝牙时,开启所有应用协议对应的服务类。Step 301 : when the mobile terminal starts the Bluetooth, the service classes corresponding to all application protocols are started.

步骤302:为每个应用协议建立对应的计数器。Step 302: Establish a corresponding counter for each application protocol.

其中,计数器的值标识已与移动终端配对且支持对应应用协议的外围设备的数量,计数器的初始值为0。The value of the counter identifies the number of peripheral devices that have been paired with the mobile terminal and support the corresponding application protocol, and the initial value of the counter is 0.

可以理解地,移动终端一般可以与多个外围设备形成蓝牙配对,如图4所示,图4是本申请实施例提供的移动终端与外围设备配对示意图,其中,移动终端41分别与第一外围设备42、第二外围设备43以及第三外围设备44形成配对。It can be understood that a mobile terminal can generally form a Bluetooth pairing with multiple peripheral devices, as shown in FIG. 4 , which is a schematic diagram of pairing between a mobile terminal and a peripheral device provided by an embodiment of the present application, wherein the mobile terminal 41 is respectively paired with the first peripheral device. The device 42, the second peripheral device 43 and the third peripheral device 44 form a pair.

参考下表,下表中表示了移动终端41和第一外围设备42、第二外围设备43以及第三外围设备44分别所支持的应用协议,以及对应的计数器的值。Referring to the table below, the table below shows the application protocols supported by the mobile terminal 41 and the first peripheral device 42 , the second peripheral device 43 and the third peripheral device 44 respectively, and the corresponding counter values.

移动终端mobile terminal 第一外围设备first peripheral 第二外围设备second peripheral 第三外围设备third peripheral 计数器counter HFPHFP HFPHFP 11 A2DPA2DP A2DPA2DP A2DPA2DP A2DPA2DP 33 OPPOPP OPPOPP OPPOPP 22 AVRCPAVRCP AVRCPAVRCP 11 GATTGATT 00 PANPAN 00 PBAPPBAP PBAPPBAP 11 HIDHID HIDHID 1 1

步骤303:确定目标外围设备所支持的目标应用协议。Step 303: Determine the target application protocol supported by the target peripheral device.

步骤304:将目标应用协议对应的计数器加1。Step 304: Add 1 to the counter corresponding to the target application protocol.

可以理解地,对新配对的外围设备,可以采用SDP协议去获取其支持的应用协议,然后对上述表格中对应的计数器的值进行增加,同时,若有外围设备与移动终端断开蓝牙配对,则对上述表格中对应的计数器的值进行减少。Understandably, for the newly paired peripheral device, the SDP protocol can be used to obtain the application protocol it supports, and then the value of the corresponding counter in the above table is increased. Then the value of the corresponding counter in the above table is decreased.

在步骤304之后,分别执行步骤305和步骤308。After step 304, step 305 and step 308 are performed, respectively.

步骤305:查询除目标应用协议之外的应用协议对应的第一服务类的状态。Step 305: Query the status of the first service class corresponding to application protocols other than the target application protocol.

步骤306:若第一服务类是开启状态,且目标应用协议对应的计数器的值为0,则关闭第一服务类。Step 306 : if the first service class is in an open state and the value of the counter corresponding to the target application protocol is 0, then close the first service class.

若目标应用协议中不包括PAN协议,根据上述表格中显示的计数器的值为0,同时检测PAN协议对应的Service类是否是开启状态,若是开启状态,则关闭PAN协议对应的Service类。If the target application protocol does not include the PAN protocol, according to the value of the counter shown in the above table, it is detected whether the Service class corresponding to the PAN protocol is in the open state. If it is in the open state, the Service class corresponding to the PAN protocol is closed.

若目标应用协议中不包括PAN协议,根据上述表格中显示的计数器的值为0,同时检测PAN协议对应的Service类是否是开启状态,若是关闭状态,则保持关闭状态。If the target application protocol does not include the PAN protocol, the value of the counter shown in the above table is 0, and at the same time, it is detected whether the Service class corresponding to the PAN protocol is in the open state, and if it is in the closed state, the closed state is maintained.

步骤307:若第一服务类是关闭状态,则保持关闭状态。Step 307: If the first service class is in the closed state, keep the closed state.

步骤308:查询目标应用协议对应的第二服务类的状态。Step 308: Query the status of the second service class corresponding to the target application protocol.

步骤309:若第二服务类是开启状态,则保持开启状态。Step 309: If the second service class is in the open state, keep the open state.

若目标应用协议中包括A2DP协议,根据上述表格中显示的计数器的值为3,在3的基础上加1,同时检测A2DP协议对应的Service类是否是开启状态,若是开启状态,则保持开启状态。If the target application protocol includes the A2DP protocol, according to the value of the counter shown in the above table, add 1 to 3, and check whether the Service class corresponding to the A2DP protocol is in the open state. If it is in the open state, keep it in the open state. .

步骤310:若第二服务类是关闭状态,则开启第二服务类。Step 310: If the second service class is in an off state, enable the second service class.

若目标应用协议中包括GATT协议,根据上述表格中显示的计数器的值为0,在0的基础上加1,同时检测GATT协议对应的Service类是否是开启状态,若是关闭状态,则开启GATT协议对应的Service类。If the target application protocol includes the GATT protocol, according to the value of the counter shown in the above table, add 1 to 0, and at the same time check whether the Service class corresponding to the GATT protocol is in the open state, if it is in the closed state, then open the GATT protocol The corresponding Service class.

参阅图5,图5是本申请实施例提供的移动终端的蓝牙管理方法的第三流程示意图,该方法包括:Referring to FIG. 5, FIG. 5 is a third schematic flowchart of a Bluetooth management method for a mobile terminal provided by an embodiment of the present application. The method includes:

步骤501:当移动终端在启动蓝牙时,开启所有应用协议对应的服务类。Step 501 : when the mobile terminal starts the Bluetooth, the service classes corresponding to all the application protocols are started.

步骤502:为每个应用协议建立对应的计数器。Step 502: Establish a corresponding counter for each application protocol.

其中,计数器的值标识已与移动终端配对且支持对应应用协议的外围设备的数量,计数器的初始值为0。The value of the counter identifies the number of peripheral devices that have been paired with the mobile terminal and support the corresponding application protocol, and the initial value of the counter is 0.

步骤503:确定目标外围设备所支持的目标应用协议。Step 503: Determine the target application protocol supported by the target peripheral device.

步骤504:将目标应用协议对应的计数器加1。Step 504: Add 1 to the counter corresponding to the target application protocol.

步骤505:若解除与目标外围设备的蓝牙配对,获取目标外围设备所支持的第二应用协议。Step 505: If the Bluetooth pairing with the target peripheral device is released, obtain the second application protocol supported by the target peripheral device.

步骤506:将第二应用协议对应的计数器的值减1。Step 506: Decrement the value of the counter corresponding to the second application protocol by 1.

继续参考下表,下表中表示了移动终端和第一外围设备、第二外围设备以及第三外围设备分别所支持的应用协议,以及对应的计数器的值。Continuing to refer to the following table, the table below shows the application protocols supported by the mobile terminal and the first peripheral device, the second peripheral device and the third peripheral device respectively, and the corresponding counter values.

Figure BDA0002063578360000091
Figure BDA0002063578360000091

Figure BDA0002063578360000101
Figure BDA0002063578360000101

若移动终端解除与第三外围设备的蓝牙配对,则对A2DP协议和 HID协议对应的计数器的值减1,具体如下:If the mobile terminal releases the Bluetooth pairing with the third peripheral device, the value of the counter corresponding to the A2DP protocol and the HID protocol is decremented by 1, as follows:

移动终端mobile terminal 第一外围设备first peripheral 第二外围设备second peripheral 计数器counter HFPHFP HFPHFP 11 A2DPA2DP A2DPA2DP A2DPA2DP 3-1=23-1=2 OPPOPP OPPOPP OPPOPP 22 AVRCPAVRCP AVRCPAVRCP 11 GATTGATT 00 PANPAN 00 PBAPPBAP PBAPPBAP 11 HIDHID 1-1=0 1-1=0

步骤507:检测第二应用协议对应的计数器的值是否为0。Step 507: Detect whether the value of the counter corresponding to the second application protocol is 0.

其中,检测A2DP协议和HID协议对应的计数器的值是否为0。Wherein, it is detected whether the value of the counter corresponding to the A2DP protocol and the HID protocol is 0.

步骤508:关闭第二应用协议对应的服务类。Step 508: Close the service class corresponding to the second application protocol.

检测到HID协议对应的计数器的值为0,那么则关闭HID协议对应的Service类。If it is detected that the value of the counter corresponding to the HID protocol is 0, then the Service class corresponding to the HID protocol is closed.

另外,在上述的实施例中,若移动终端关闭蓝牙,则同时关闭所有服务类,并将所有服务类对应的计数器的值清零。In addition, in the above-mentioned embodiment, if the mobile terminal turns off the Bluetooth, all service classes are turned off at the same time, and the values of the counters corresponding to all service classes are cleared to zero.

参阅图6,图6是本申请实施例提供的移动终端的结构示意图,该移动终端60包括处理器61以及与处理器61连接的蓝牙模组62和存储器63。Referring to FIG. 6 , FIG. 6 is a schematic structural diagram of a mobile terminal provided by an embodiment of the present application. The mobile terminal 60 includes a processor 61 , a Bluetooth module 62 connected to the processor 61 , and a memory 63 .

其中,蓝牙模组62又称蓝牙模块,一般由芯片、PCB(Printed Circuit Board)板、外围器件构成。The Bluetooth module 62 is also called a Bluetooth module, and is generally composed of a chip, a Printed Circuit Board (PCB), and peripheral devices.

可以理解地,该移动终端60可以是手机、平板电脑、可穿戴设备以及智能设备。Understandably, the mobile terminal 60 may be a mobile phone, a tablet computer, a wearable device and a smart device.

其中,存储器63用于存储程序数据,处理器61用于执行程序数据以实现如下的方法:Wherein, the memory 63 is used to store the program data, and the processor 61 is used to execute the program data to realize the following method:

移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的一个或多个外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。When the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are enabled; the target application protocol supported by the target peripheral device is determined; wherein, the target peripheral device is one or more peripheral devices that perform Bluetooth communication with the mobile terminal; Service classes corresponding to application protocols other than application protocols.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:采用服务发现协议确定目标外围设备所支持的目标应用协议。In some embodiments, the processor 61 is further configured to execute the program data to implement the method of determining the target application protocol supported by the target peripheral device using the service discovery protocol.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:当有新的外围设备与移动终端建立蓝牙配对时,重新确定目标外围设备所支持的目标应用协议;或当已与移动终端建立配对的目标外围设备,与移动终端取消蓝牙配对时,重新确定目标外围设备所支持的目标应用协议。In some embodiments, the processor 61 is further configured to execute the program data to implement the following method: when a new peripheral device establishes a Bluetooth pairing with the mobile terminal, re-determine the target application protocol supported by the target peripheral device; or when a new peripheral device establishes a Bluetooth pairing with the mobile terminal; When the target peripheral device that is paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, the target application protocol supported by the target peripheral device is re-determined.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:当有第一外围设备与移动终端建立蓝牙配对时,获取第一外围设备的型号;若一个或多个第一外围设备中存在第二外围设备,第二外围设备与目标外围设备中的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议In some embodiments, the processor 61 is further configured to execute the program data to implement the following method: when a first peripheral device establishes a Bluetooth pairing with the mobile terminal, obtain the model of the first peripheral device; There is a second peripheral device in the peripheral device, and the model of each peripheral device in the second peripheral device and the target peripheral device is different, then re-determine the target application protocol supported by the target peripheral device

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:当目标外围设备中已与移动终端建立配对的第三外围设备,与移动终端取消蓝牙配对时,获取第三外围设备的型号;若一个或多个第三外围设备中存在第四外围设备,第四外围设备与目标外围设备中保持蓝牙配对的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。In some embodiments, the processor 61 is further configured to execute the program data to implement the following method: when the third peripheral device in the target peripheral device that has been paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, obtain the third peripheral device The model of the device; if there is a fourth peripheral in one or more third peripherals, and the model of each peripheral that maintains Bluetooth pairing in the fourth peripheral is different from that of the target peripheral, then re-determine the type of the target peripheral. Supported target application protocols.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:当目标外围设备与移动终端取消蓝牙配对时,查询除目标应用协议之外的应用协议对应的第一服务类的状态;若第一服务类是开启状态,则关闭第一服务类;若第一服务类是关闭状态,则保持关闭状态。In some embodiments, the processor 61 is further configured to execute the program data to implement the following method: when the target peripheral device and the mobile terminal cancel the Bluetooth pairing, query the first service class corresponding to the application protocol other than the target application protocol. state; if the first service class is in the open state, the first service class is closed; if the first service class is in the closed state, the closed state is maintained.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:当有新的外围设备与移动终端建立蓝牙配对时,查询目标应用协议对应的第二服务类的状态;若第二服务类是开启状态,则保持开启状态;若第二服务类是关闭状态,则开启第二服务类。In some embodiments, the processor 61 is further configured to execute the program data to implement the following method: when a new peripheral device establishes a Bluetooth pairing with the mobile terminal, query the state of the second service class corresponding to the target application protocol; If the second service class is in the open state, the open state is maintained; if the second service class is in the closed state, the second service class is opened.

在一些实施例中,处理器61还用于执行程序数据以实现如下的方法:在启动蓝牙的设定时间段后,若没有外围设备与移动终端进行蓝牙通信,则关闭所有应用协议所对应的服务类。In some embodiments, the processor 61 is further configured to execute program data to implement the following method: after a set period of time when Bluetooth is enabled, if no peripheral device communicates with the mobile terminal via Bluetooth, close all application protocols corresponding to the service class.

参阅图7,图7是本申请实施例提供的计算机存储介质的结构示意图,该计算机存储介质70中存储有程序数据71,程序数据71在被处理器执行时,用以实现如下的方法:Referring to FIG. 7, FIG. 7 is a schematic structural diagram of a computer storage medium provided by an embodiment of the present application. The computer storage medium 70 stores program data 71, and when the program data 71 is executed by the processor, it is used to implement the following method:

移动终端在启动蓝牙时,开启所有应用协议对应的服务类;确定目标外围设备所支持的目标应用协议;其中,目标外围设备为与移动终端进行蓝牙通信的外围设备;关闭除目标应用协议之外的应用协议所对应的服务类。When the mobile terminal starts Bluetooth, the service classes corresponding to all application protocols are turned on; the target application protocol supported by the target peripheral device is determined; wherein, the target peripheral device is a peripheral device that performs Bluetooth communication with the mobile terminal; The service class corresponding to the application protocol.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:采用服务发现协议确定目标外围设备所支持的目标应用协议。In some embodiments, the program data 71, when executed by the processor, is also used to implement the following method: using the service discovery protocol to determine the target application protocol supported by the target peripheral device.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:当有新的外围设备与移动终端建立蓝牙配对时,重新确定目标外围设备所支持的目标应用协议;或当已与移动终端建立配对的目标外围设备,与移动终端取消蓝牙配对时,重新确定目标外围设备所支持的目标应用协议。In some embodiments, when executed by the processor, the program data 71 is further used to implement the following method: when a new peripheral device establishes a Bluetooth pairing with the mobile terminal, re-determining the target application protocol supported by the target peripheral device; Or when the target peripheral device that has been paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, the target application protocol supported by the target peripheral device is re-determined.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:当有第一外围设备与移动终端建立蓝牙配对时,获取第一外围设备的型号;若一个或多个第一外围设备中存在第二外围设备,第二外围设备与目标外围设备中的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。In some embodiments, when the program data 71 is executed by the processor, it is also used to implement the following method: when a first peripheral device establishes a Bluetooth pairing with the mobile terminal, obtain the model of the first peripheral device; if one or more There is a second peripheral device in each of the first peripheral devices, and the models of the second peripheral device and each peripheral device in the target peripheral device are different, and the target application protocol supported by the target peripheral device is re-determined.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:当目标外围设备中已与移动终端建立配对的第三外围设备,与移动终端取消蓝牙配对时,获取第三外围设备的型号;若一个或多个第三外围设备中存在第四外围设备,第四外围设备与目标外围设备中保持蓝牙配对的每个外围设备的型号均不相同,则重新确定目标外围设备所支持的目标应用协议。In some embodiments, when the program data 71 is executed by the processor, it is further used to implement the following method: when the third peripheral device in the target peripheral device that has been paired with the mobile terminal cancels the Bluetooth pairing with the mobile terminal, obtain The model of the third peripheral device; if there is a fourth peripheral device in one or more third peripheral devices, and the model of each peripheral device that maintains Bluetooth pairing in the fourth peripheral device and the target peripheral device is different, then re-determine the target The target application protocol supported by the peripheral device.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:当目标外围设备与移动终端取消蓝牙配对时,查询除目标应用协议之外的应用协议对应的第一服务类的状态;若第一服务类是开启状态,则关闭第一服务类;若第一服务类是关闭状态,则保持关闭状态。In some embodiments, the program data 71, when executed by the processor, is further used to implement the following method: when the target peripheral device cancels the Bluetooth pairing with the mobile terminal, query the first application protocol corresponding to the application protocol other than the target application protocol. The state of the service class; if the first service class is in the open state, the first service class is closed; if the first service class is in the closed state, the closed state is maintained.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:当有新的外围设备与移动终端建立蓝牙配对时,查询目标应用协议对应的第二服务类的状态;若第二服务类是开启状态,则保持开启状态;若第二服务类是关闭状态,则开启第二服务类。In some embodiments, when executed by the processor, the program data 71 is further used to implement the following method: when a new peripheral device establishes a Bluetooth pairing with the mobile terminal, query the state of the second service class corresponding to the target application protocol ; If the second service class is in the open state, keep the open state; if the second service class is in the closed state, open the second service class.

在一些实施例中,程序数据71在被处理器执行时,还用以实现如下的方法:在启动蓝牙的设定时间段后,若没有外围设备与移动终端进行蓝牙通信,则关闭所有应用协议所对应的服务类。In some embodiments, when the program data 71 is executed by the processor, it is also used to implement the following method: after a set period of time when Bluetooth is enabled, if no peripheral device communicates with the mobile terminal via Bluetooth, all application protocols are closed. the corresponding service class.

在本申请所提供的几个实施方式中,应该理解到,所揭露的方法以及设备,可以通过其它的方式实现。例如,以上所描述的设备实施方式仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed method and device may be implemented in other manners. For example, the device implementations described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other divisions. For example, multiple units or components may be Incorporation may either be integrated into another system, or some features may be omitted, or not implemented.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施方式方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this implementation manner.

另外,在本申请各个实施方式中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.

上述其他实施方式中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等) 或处理器(processor)执行本申请各个实施方式所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM, Read-Only Memory)、随机存取存储器(RAM,RandomAccess Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated units in the other embodiments described above are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes.

以上所述仅为本申请的实施方式,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above description is only an embodiment of the present application, and is not intended to limit the scope of the patent of the present application. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present application, or directly or indirectly applied to other related technologies Fields are similarly included within the scope of patent protection of this application.

Claims (6)

1. A bluetooth management method, comprising:
when the mobile terminal starts the Bluetooth, starting service classes corresponding to all application protocols;
establishing a corresponding counter for each application protocol;
determining a first application protocol supported by the mobile terminal, and determining a second application protocol supported by a target peripheral device by adopting a service discovery protocol; the target peripheral equipment is one or more peripheral equipment which carries out Bluetooth communication with the mobile terminal;
determining an intersection of the first application protocol and the second application protocol as a target application protocol; when a new peripheral device establishes Bluetooth pairing with the mobile terminal, re-determining a target application protocol supported by the target peripheral device; or when the target peripheral equipment which is paired with the mobile terminal is cancelled with the mobile terminal, the target application protocol supported by the target peripheral equipment is determined again;
adding 1 to a counter corresponding to the target application protocol;
inquiring the state of a first service class corresponding to the application protocol except the target application protocol;
if the first service class is in an open state and the value of a counter corresponding to the target application protocol is a preset threshold value, closing the first service class, and if the first service class is in a closed state, keeping the closed state;
querying the state of a second service class corresponding to the target application protocol;
if the second service class is in an open state, the second service class is kept in the open state, and if the second service class is in a closed state, the second service class is opened;
if the Bluetooth pairing with the target peripheral equipment is released, acquiring a second application protocol supported by the target peripheral equipment and subtracting 1 from the value of a counter corresponding to the second application protocol;
and when the value of the counter corresponding to the second application protocol is a preset threshold value, closing the service class corresponding to the second application protocol.
2. The method of claim 1,
the step of re-determining the target application protocol supported by the target peripheral device when the new peripheral device establishes bluetooth pairing with the mobile terminal includes:
when a first peripheral device establishes Bluetooth pairing with the mobile terminal, acquiring the model of the first peripheral device;
and if a second peripheral device exists in one or more first peripheral devices, and the model of each peripheral device in the second peripheral device is different from that of each peripheral device in the target peripheral device, re-determining the target application protocol supported by the target peripheral device.
3. The method of claim 1,
the step of re-determining the target application protocol supported by the target peripheral device when the target peripheral device paired with the mobile terminal cancels bluetooth pairing with the mobile terminal comprises:
when the Bluetooth pairing between a third peripheral device which is paired with the mobile terminal in the target peripheral device and the mobile terminal is cancelled, acquiring the model of the third peripheral device;
and if a fourth peripheral device exists in one or more third peripheral devices, and the model of each peripheral device which is paired with the target peripheral device by the Bluetooth is different from that of each peripheral device which is paired with the target peripheral device, re-determining the target application protocol supported by the target peripheral device.
4. The method of claim 1,
when the mobile terminal starts the bluetooth, after the step of starting the service classes corresponding to all the application protocols, the method further comprises the following steps:
and after the first preset time of starting the Bluetooth, if no peripheral equipment performs Bluetooth communication with the mobile terminal, closing the service classes corresponding to all application protocols.
5. A mobile terminal is characterized by comprising a processor, a Bluetooth module and a memory, wherein the Bluetooth module and the memory are connected with the processor;
wherein the bluetooth module is for bluetooth communication with a peripheral device pair, the memory is for storing program data, and the processor is for executing the program data to implement the method of any one of claims 1-4.
6. A computer storage medium, characterized in that program data are stored in the computer storage medium, which program data, when being executed by a processor, are adapted to carry out the method of any one of claims 1-4.
CN201910413498.7A 2019-05-17 2019-05-17 Bluetooth management method, mobile terminal and computer storage medium Expired - Fee Related CN110177357B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910413498.7A CN110177357B (en) 2019-05-17 2019-05-17 Bluetooth management method, mobile terminal and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910413498.7A CN110177357B (en) 2019-05-17 2019-05-17 Bluetooth management method, mobile terminal and computer storage medium

Publications (2)

Publication Number Publication Date
CN110177357A CN110177357A (en) 2019-08-27
CN110177357B true CN110177357B (en) 2022-06-07

Family

ID=67691506

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910413498.7A Expired - Fee Related CN110177357B (en) 2019-05-17 2019-05-17 Bluetooth management method, mobile terminal and computer storage medium

Country Status (1)

Country Link
CN (1) CN110177357B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111954039B (en) * 2020-07-02 2022-07-01 深圳市华曦达科技股份有限公司 Set top box Bluetooth configuration method and device, electronic equipment and storage medium
CN114630303A (en) * 2020-12-14 2022-06-14 深圳Tcl新技术有限公司 A Bluetooth connection method, system, intelligent terminal and computer storage medium
CN112948007B (en) * 2021-02-02 2023-06-16 歌尔科技有限公司 Initialization method and device of Bluetooth sound box and Bluetooth sound box
CN113676851B (en) * 2021-08-17 2022-06-28 深圳市芯中芯科技有限公司 Communication method and system of Bluetooth device and wireless interphone

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102378400A (en) * 2010-08-23 2012-03-14 中兴通讯股份有限公司 Management method and device of Bluetooth services
CN105487887A (en) * 2015-11-24 2016-04-13 惠州Tcl移动通信有限公司 Bluetooth starting method and Bluetooth device
CN106028268A (en) * 2016-06-27 2016-10-12 广东欧珀移动通信有限公司 Method and device for reducing power consumption of equipment
CN109089247A (en) * 2018-07-24 2018-12-25 深圳Tcl新技术有限公司 Using starting method, system, terminal device and computer readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6242051B2 (en) * 2013-01-23 2017-12-06 キヤノン株式会社 COMMUNICATION DEVICE, COMMUNICATION DEVICE CONTROL METHOD, PROGRAM

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102378400A (en) * 2010-08-23 2012-03-14 中兴通讯股份有限公司 Management method and device of Bluetooth services
CN105487887A (en) * 2015-11-24 2016-04-13 惠州Tcl移动通信有限公司 Bluetooth starting method and Bluetooth device
CN106028268A (en) * 2016-06-27 2016-10-12 广东欧珀移动通信有限公司 Method and device for reducing power consumption of equipment
CN109089247A (en) * 2018-07-24 2018-12-25 深圳Tcl新技术有限公司 Using starting method, system, terminal device and computer readable storage medium

Also Published As

Publication number Publication date
CN110177357A (en) 2019-08-27

Similar Documents

Publication Publication Date Title
CN110177357B (en) Bluetooth management method, mobile terminal and computer storage medium
CN107277754B (en) A method of bluetooth connection and bluetooth peripheral device
CN103518418B (en) Method and device for connection between bluetooth devices
US9112986B2 (en) Supplemental audio signal processing for a bluetooth audio link
EP2701313A1 (en) Method for pairing bluetooth accessory with bluetooth device, and bluetooth accessory
WO2021239032A1 (en) Bluetooth protocol connection method and apparatus, storage medium, and related device
CN107889092A (en) Bluetooth devices control method, device, terminal device and storage medium
WO2020143680A1 (en) Data transmission method and related apparatus
WO2020164349A1 (en) Data transmission control method and related product
CN106776036A (en) A resource allocation method and device
CN105228182A (en) The double card collocation method of multimode double-card mobile terminal and device
CN107947894A (en) Anti-interference method of electronic equipment and related product
CN108124056A (en) Anti-interference method of electronic equipment and related product
WO2020164351A1 (en) Link connection method and related apparatus
CN108924361A (en) Audio plays and collection control method, system and computer readable storage medium
CN107066324A (en) Method and device for controlling fingerprint processing resources
CN106535188A (en) Access control method and mobile terminal
CN106604204B (en) A method and system for remote bluetooth control terminal application
US10015314B2 (en) Call collision processing method for terminal device, and terminal device
CN110234169A (en) Communication Jamming adjusts control method and Related product
CN106776040A (en) A resource allocation method and device
CN106791243B (en) A kind of function setting method and device based on bluetooth protocol
CN111491278A (en) Method and terminal for playing audio through Bluetooth device
JP2023546564A (en) Electronic devices that support multiple sims and how they operate
TW201924465A (en) Wireless communication method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20220607