CN105517110B - A kind of method and device connecting bluetooth equipment - Google Patents
A kind of method and device connecting bluetooth equipment Download PDFInfo
- Publication number
- CN105517110B CN105517110B CN201510824405.1A CN201510824405A CN105517110B CN 105517110 B CN105517110 B CN 105517110B CN 201510824405 A CN201510824405 A CN 201510824405A CN 105517110 B CN105517110 B CN 105517110B
- Authority
- CN
- China
- Prior art keywords
- bluetooth
- terminal
- feature
- low energy
- mark
- 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.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W48/00—Access restriction; Network selection; Access point selection
- H04W48/16—Discovering, processing access restriction or access information
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/11—Allocation or use of connection identifiers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/80—Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W48/00—Access restriction; Network selection; Access point selection
- H04W48/08—Access restriction or access information delivery, e.g. discovery data delivery
- H04W48/10—Access restriction or access information delivery, e.g. discovery data delivery using broadcasted information
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The present invention discloses a kind of method and device for connecting bluetooth equipment, belong to communication field, the described method includes: judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark, it is to extract bluetooth device name from Bluetooth broadcast data corresponding with preset service mark, otherwise prompt scanning failure, terminates;Judge whether the bluetooth device name extracted is identical as target Bluetooth devices title, is, according to the bluetooth device name extracted, is connected with corresponding bluetooth equipment, otherwise continue to judge whether terminal scans Bluetooth broadcast data corresponding with preset service mark.Using technical solution of the present invention, after split type bluetooth equipment is connect with the terminal of IOS system, when split type bluetooth equipment replaces different functional modules, when terminal and new functional module are attached, terminal can not depend on caching and the mark for the new functional module that timely updates, and then terminal successful scan and connect new functional module.
Description
Technical field
The present invention relates to the communications field more particularly to a kind of method and devices for connecting bluetooth equipment.
Background technique
Split type bluetooth equipment is made of bluetooth module and functional module two parts, and bluetooth module is functional module and terminal
Between establish the bridge of connection, functional module is the formant for executing split type bluetooth equipment function, and a bluetooth module can
To connect multiple and different functional modules.
In the prior art, after split type bluetooth equipment is connect with the terminal of IOS system, when split type bluetooth equipment is replaced
When different functional modules, terminal and new functional module are attached, what is saved in the caching of terminal is still to have connected originally
The address Mac of connection function module, what terminal was read out is to have connected the mark of functional module originally, and it is new to timely update
The mark of functional module scans and connects the operation failure of new functional module so as to cause terminal.
Summary of the invention
The purpose of the invention is to overcome the deficiencies of the prior art and provide a kind of method and dress for connecting bluetooth equipment
It sets.
The present invention provides a kind of method for connecting bluetooth equipment, comprising:
Step S1: judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark, is to execute step
Rapid S2, otherwise prompt scanning failure, terminates;
Step S2: extracting bluetooth device name from the Bluetooth broadcast data corresponding with preset service mark, judgement
Whether the bluetooth device name extracted is identical as target Bluetooth devices title, is to then follow the steps S3, otherwise return step S1;
Step S3: it according to the bluetooth device name extracted, is connected with corresponding bluetooth equipment.
Optionally, the step S1 specifically: judge whether to receive the scanning success notification from the terminal, if
It is, it is determined that Bluetooth broadcast data corresponding with preset service mark are arrived in the terminal scanning;Otherwise, it determines the terminal does not have
It scans preset service and identifies corresponding Bluetooth broadcast data;
Alternatively,
The Bluetooth broadcast data that the terminal is got are received, whether are wrapped in the Bluetooth broadcast data got described in judgement
Containing Bluetooth broadcast data corresponding with preset service mark, if it is, determining that the terminal scanning is identified to preset service
Corresponding Bluetooth broadcast data;Otherwise, it determines the terminal does not scan Bluetooth broadcast number corresponding with preset service mark
According to.
The scanning success notification, specifically: the notice of the first function interface of the system readjustment of the terminal.
Optionally, before the step S1, further includes:
Judge whether the internal environment of the terminal supports Bluetooth Low Energy, is that the preset service mark is set, it is no
It then prompts not supporting the Bluetooth Low Energy, terminate.
Whether the internal environment for judging the terminal supports Bluetooth Low Energy, specifically:
Execute at least one in following operation:
Judge whether to obtain the authorization of the Bluetooth Low Energy;
Judge whether the hardware of the terminal supports the Bluetooth Low Energy;
Judge whether the system of the terminal supports the Bluetooth Low Energy;
Judge whether the terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of the terminal supports the low function of the bluetooth
Consumption, otherwise, it determines the internal environment of the terminal does not support the Bluetooth Low Energy.
Optionally, before whether the internal environment for judging the terminal supports Bluetooth Low Energy, comprising: described in monitoring
The state of the internal environment of terminal.
The state of the internal environment for monitoring the terminal, specifically: letter is monitored in registration in the system of the terminal
Number instantiates Bluetooth Low Energy central manager, and registers eavesdropping target to supervise in real time into Bluetooth Low Energy central manager
Listen the state of the internal environment of the terminal.
The authorization for judging whether to obtain the Bluetooth Low Energy, specifically: it detects whether to receive the monitoring letter
The first several return values is not obtain the authorization of the Bluetooth Low Energy, otherwise obtains the authorization of the Bluetooth Low Energy;
Whether the hardware for judging the terminal supports the Bluetooth Low Energy, specifically: it detects whether to receive institute
The second return value for monitoring function is stated, is the hardware of the terminal does not support the Bluetooth Low Energy, otherwise the terminal
Bluetooth Low Energy described in hardware supported;
Whether the system for judging the terminal supports the Bluetooth Low Energy, specifically: it detects whether to receive institute
The third return value for monitoring function is stated, is the system of the terminal does not support the Bluetooth Low Energy, otherwise the terminal
System supports the Bluetooth Low Energy;
It is described to judge whether the terminal opens Bluetooth function, specifically: detect returning for the monitoring function received
The type of value is returned, if the 4th return value, then the terminal has turned on Bluetooth function, if the 5th return value, then the terminal
Bluetooth function is not opened.
Optionally, before the setting preset service mark, further includes:
Step B1: judging whether the terminal has connected bluetooth equipment, is to then follow the steps B2, is otherwise arranged described default
Service identifiers;
Step B2: whether the title that bluetooth equipment is had connected described in judgement is identical as the target Bluetooth devices title, is
Successful connection is then prompted, is terminated, otherwise has connected bluetooth equipment described in disconnection, the preset service mark is set.
Optionally, the step S3 includes:
Step C1: according to the bluetooth device name extracted, the service of corresponding bluetooth equipment is connected;
Step C2: according to the bluetooth device name extracted, under the service for scanning the corresponding bluetooth equipment
Feature;
Step C3: when the feature scanned is to receive data characteristics, the feature that writing scan is arrived is the reception data
Feature is marked as writing feature, and when the feature scanned is to send data characteristics, the feature that writing scan is arrived is the hair
Data characteristics is sent, is marked as reading feature.
The step C1 specifically: receive terminal system detect it is corresponding with the bluetooth device name extracted
After the notice of the service of bluetooth equipment, according to the bluetooth device name extracted, the service of corresponding bluetooth equipment is connected.
The step C2 specifically: receive terminal and detect bluetooth corresponding with the bluetooth device name extracted
After the notice of feature under the service of equipment, according to the bluetooth device name extracted, corresponding bluetooth equipment is scanned
Feature under service.
The step C3 specifically:
Step C3-1: the mark of the feature scanned is extracted;
Step C3-2: judge identifying whether as default reception Data Identification and/or default transmission number for the feature extracted
C3-3 is thened follow the steps if the default reception Data Identification according to mark, if the default transmission Data Identification, is then held
Row step C3-4, it is no to then follow the steps C3-5;
Step C3-3: the corresponding feature of the mark for the feature extracted described in record is the reception data characteristics, by it
Labeled as feature is write, step C3-5 is executed;
Step C3-4: the corresponding feature of the mark for the feature extracted described in record is the transmission data characteristics, by it
Labeled as feature is read, step C3-5 is executed;
Step C3-5: judging whether the reception data characteristics and the transmission data characteristics have recorded, and is to prompt
Successful connection terminates, no to then follow the steps C3-6;
Step C3-6: whether the corresponding feature of the mark for the feature extracted described in judgement is the last one feature, is then
Connection failure is prompted, terminates, otherwise extracts the mark of next feature scanned, return step C3-2.
The present invention also provides a kind of devices for connecting bluetooth equipment, comprising:
First judgment module, for judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark;
Extraction module, for judging terminal scanning to bluetooth corresponding with preset service mark when the first judgment module
When broadcast data, bluetooth device name is extracted from the Bluetooth broadcast data corresponding with preset service mark;
Cue module, for judging that terminal does not scan indigo plant corresponding with preset service mark when the first judgment module
When tooth broadcast data, scanning failure is prompted, is terminated;
Second judgment module, for judging bluetooth device name that the extraction module extracts and target Bluetooth devices name
Whether identical claim;
Link block, for when second judgment module judge bluetooth device name that the extraction module extracts with
When the target Bluetooth devices title is identical, according to the bluetooth device name that the extraction module extracts, with corresponding bluetooth
Equipment connection;
The first judgment module is also used to the bluetooth device name extracted described in second judgment module judgement
When with the target Bluetooth devices title difference, judge whether terminal scans Bluetooth broadcast number corresponding with preset service mark
According to.
Optionally, the first judgment module, specifically for judging whether to receive the scanning success from the terminal
Notice, if it is, determining that Bluetooth broadcast data corresponding with preset service mark are arrived in the terminal scanning;Otherwise, it determines institute
It states terminal and does not scan Bluetooth broadcast data corresponding with preset service mark;
Alternatively,
The Bluetooth broadcast data that the terminal is got are received, whether are wrapped in the Bluetooth broadcast data got described in judgement
Containing Bluetooth broadcast data corresponding with preset service mark, if it is, determining that the terminal scanning is identified to preset service
Corresponding Bluetooth broadcast data;Otherwise, it determines the terminal, which does not scan preset service, identifies corresponding Bluetooth broadcast data.
The first judgment module, specifically for judging whether to receive the first letter of the system readjustment from the terminal
The notice of number interface.
Optionally, described device further include:
Third judgment module, for judging whether the internal environment of the terminal supports Bluetooth Low Energy;
Setup module, for judging that the internal environment of the terminal supports the Bluetooth Low Energy when the third module
When, the preset service mark is set;
The cue module is also used to when to judge that the internal environment of the terminal is not supported described for the third judgment module
When Bluetooth Low Energy, prompts not supporting the Bluetooth Low Energy, terminate.
The third judgment module, specifically for executing at least one in following operation:
Judge whether to obtain the authorization of the Bluetooth Low Energy;
Judge whether the hardware of the terminal supports the Bluetooth Low Energy;
Judge whether the system of the terminal supports the Bluetooth Low Energy;
Judge whether the terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of the terminal supports the low function of the bluetooth
Consumption, otherwise, it determines the internal environment of the terminal does not support the Bluetooth Low Energy.
Optionally, described device further include:
Monitor module, the state of the internal environment for monitoring the terminal.
The monitoring module instantiates Bluetooth Low Energy specifically for the registration monitoring function in the system of the terminal
Central manager, and eavesdropping target is registered into Bluetooth Low Energy central manager to monitor the internal environment of the terminal in real time
State.
The third judgment module specifically includes:
First detection sub-module is not obtain for detecting whether receiving first return value for monitoring function
Otherwise the authorization of the Bluetooth Low Energy obtains the authorization of the Bluetooth Low Energy;
Second detection sub-module is then end for detecting whether receiving second return value for monitoring function
The hardware at end does not support the Bluetooth Low Energy, otherwise Bluetooth Low Energy described in the hardware supported of the terminal;
Third detection sub-module is then end for detecting whether receiving the third return value for monitoring function
The system at end does not support the Bluetooth Low Energy, and otherwise the system of the terminal supports the Bluetooth Low Energy;
4th detection sub-module, the type of the return value for detecting the monitoring function received, is returned if the 4th
Value is returned, then the terminal has turned on Bluetooth function, and if the 5th return value, then the terminal does not open Bluetooth function.
Optionally, described device further include:
4th judgment module, for judging whether the terminal has connected bluetooth equipment;
5th judgment module, for judging when the 4th judgment module judges that the terminal has connected bluetooth equipment
Whether the title for having connected bluetooth equipment and the target Bluetooth devices title are identical;
Module is disconnected, for working as the title and the target that have connected bluetooth equipment described in the 5th judgment module judgement
When bluetooth device name difference, bluetooth equipment is had connected described in disconnection, triggers the setup module
The setup module is specifically used for when the 4th judgment module judges that the terminal is not connected with bluetooth equipment,
The preset service mark is set;
The cue module, also had connected described in judging when the 5th judgment module title of bluetooth equipment with it is described
When target Bluetooth devices title is identical, successful connection is prompted.
Optionally, the link block includes:
Submodule is connected, the bluetooth device name for extracting according to connects the service of corresponding bluetooth equipment;
Submodule is scanned, the bluetooth device name for extracting according to scans the corresponding bluetooth equipment
Feature under service;
Record sub module, for when the feature scanned is to receive data characteristics, the feature that writing scan is arrived to be described
Data characteristics is received, is marked as writing feature;For when the feature scanned be send data characteristics when, what writing scan was arrived
Feature is the transmission data characteristics, is marked as reading feature.
The connection submodule detects and the bluetooth device name extracted specifically for receiving terminal system
After the notice of the service of corresponding bluetooth equipment, according to the bluetooth device name extracted, corresponding bluetooth equipment is connected
Service.
The scanning submodule detects and the bluetooth equipment extracted specifically for receiving the terminal system
After the notice of feature under the service of the corresponding bluetooth equipment of title, according to the bluetooth device name extracted, scanning pair
Feature under the service for the bluetooth equipment answered.
The record sub module includes:
Extraction unit, for extracting the mark of the feature scanned;
First judging unit, for judging the identifying whether as the default Data Identification and/or pre- of receiving of the feature extracted
If sending Data Identification;
The record sub module, the mark specifically for working as the feature extracted described in first judging unit judgement are
When the default reception Data Identification, the corresponding feature of mark for the feature extracted described in record is that the reception data are special
Sign is marked as described writing feature;
The record sub module, the mark specifically for working as the feature extracted described in first judging unit judgement are
When the default transmission Data Identification, the corresponding feature of mark for the feature extracted described in record is that the transmission data are special
Sign, is marked as the reading feature;
Second judgment unit, for judging whether the reception data characteristics and the transmission data characteristics have recorded;
The cue module is also used to judge the reception data characteristics and the transmission number when the second judgment unit
When having recorded according to feature, successful connection is prompted;
Third judging unit, for judging the reception data characteristics and the transmission data when the second judgment unit
When feature does not record all, whether the corresponding feature of the mark for the feature extracted described in judgement is the last one feature;
The mark of the cue module, the feature for being also used to extract described in third judging unit judgement is corresponding
When being characterized in the last one feature, connection failure is prompted;
The extraction unit is also used to the corresponding spy of signature identification extracted described in third judging unit judgement
When sign is not the last one feature, the mark of next feature scanned is extracted.
Technical solution of the present invention has the beneficial effect that after split type bluetooth equipment is connect with the terminal of IOS system, when point
Body formula bluetooth equipment replaces different functional modules, and when terminal and new functional module are attached, terminal can not depend on slow
It deposits and the mark for the new functional module that timely updates, and then terminal successful scan and connects new functional module.
Detailed description of the invention
Illustrate the embodiment of the present invention or technical solution in the prior art in order to clearer, to embodiment or will show below
There is attached drawing needed in technical description to do simple introduction, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
It obtains other drawings based on these drawings.
Fig. 1 is a kind of method flow diagram for connection bluetooth equipment that the embodiment of the present invention one provides;
Fig. 2 is a kind of method flow diagram for connecting bluetooth equipment provided by Embodiment 2 of the present invention;
Fig. 3 is a kind of device block diagram for connection bluetooth equipment that the embodiment of the present invention three provides.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those skilled in the art's every other implementation obtained without making creative work
Example, shall fall within the protection scope of the present invention.
After split type bluetooth equipment opens power supply, before not connect with terminal, the bluetooth of the automatic commercials packet form of meeting
Broadcast data makes terminal pass through Bluetooth broadcast Data Detection to bluetooth equipment;The information for including in Bluetooth broadcast data has bluetooth
The current service and service identifiers of the title of equipment, the current connection state of bluetooth equipment, bluetooth equipment.
Embodiment one
The embodiment of the present invention one provides a kind of method for connecting bluetooth equipment, as shown in Figure 1, comprising:
Step 101: judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark, execute step
102, otherwise prompt scanning failure, terminates;
Specifically, it can be determined that the scanning success notification for carrying out self terminal whether is received, if it is, determining terminal scanning
To Bluetooth broadcast data corresponding with preset service mark;Otherwise, it determines terminal do not scan preset service mark it is corresponding
Bluetooth broadcast data;Also the Bluetooth broadcast data that terminal is got be can receive, judge be in the Bluetooth broadcast data got
No includes Bluetooth broadcast data corresponding with preset service mark, if it is, determining that terminal scanning is identified to preset service
Corresponding Bluetooth broadcast data;Otherwise, it determines terminal, which does not scan preset service, identifies corresponding Bluetooth broadcast data;
In the present embodiment, success notification is scanned, specifically: the first function interface notification of the system readjustment of terminal;
It in the present embodiment, receives before carrying out the scanning success notification of self terminal, further includes: terminal obtains Bluetooth broadcast number
According to, and judge that the Bluetooth broadcast data got include Bluetooth broadcast data corresponding with preset service mark;
In the present embodiment, before step 101 further include: judge whether the internal environment of terminal supports Bluetooth Low Energy,
It is that preset service mark is set, otherwise prompts not support Bluetooth Low Energy, terminate;
In the present embodiment, bluetooth low energy device includes three parts: service (Service), feature
(Characteristic), descriptor (Descriptor), three parts are by identifying come uniquely tagged;It is corresponding under service more
A feature is characterized in that terminal and bluetooth low energy device carry out the data of information exchange;
Further, judge whether the internal environment of terminal supports Bluetooth Low Energy specifically:
Execute at least one in following operation:
Judge whether the authorization of acquisition Bluetooth Low Energy;
Judge whether the hardware of terminal supports Bluetooth Low Energy;
Judge whether the system of terminal supports Bluetooth Low Energy;
Judge whether terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of terminal supports Bluetooth Low Energy, otherwise, really
The internal environment for determining terminal does not support Bluetooth Low Energy;
In the present embodiment, judge whether the internal environment of terminal supports that before Bluetooth Low Energy include: to be in terminal
Function is monitored in registration in system, instantiates Bluetooth Low Energy central manager, and prison is registered into Bluetooth Low Energy central manager
Listen the state of the internal environment of the real-time monitor terminal of object;
Judge whether to obtain Bluetooth Low Energy authorization, specifically: it detects whether to receive the first return value for monitoring function,
It is not obtain the authorization of Bluetooth Low Energy, otherwise obtains the authorization of Bluetooth Low Energy;
Judge whether the hardware of terminal supports Bluetooth Low Energy, specifically: it detects whether to receive and monitors the second of function
Return value is that the hardware of terminal does not support Bluetooth Low Energy, otherwise the hardware supported Bluetooth Low Energy of terminal;
Judge whether the system of terminal supports Bluetooth Low Energy, specifically: it detects whether to receive the third for monitoring function
Return value is that the system of terminal does not support Bluetooth Low Energy, and otherwise the system of terminal supports Bluetooth Low Energy;
Judge whether terminal opens Bluetooth function, specifically: the type of the return value of the monitoring function received is detected, if
For the 4th return value, then terminal has turned on Bluetooth function, and if the 5th return value, then terminal does not open Bluetooth function;
Preferably, the first return value is CBCentralManagerStateUnauthorized;
Second return value is CBCentralManagerStateUnsupported;
Third return value is CBCentralManagerStateUnsupported;
4th return value is CBCentralManagerStatePoweredOn;
5th return value is CBCentralManagerStatePoweredOff;
In the present embodiment, the bluetooth low energy device to be connected is target Bluetooth devices, and setting preset service identifies it
Before include:
Step B1: judging whether terminal has connected bluetooth equipment, is to then follow the steps B2, and preset service mark is otherwise arranged
Know;
Step B2: whether the title that judgement has connected bluetooth equipment is identical as target Bluetooth devices title, is the company of prompt
It is connected into function, is terminated, otherwise disconnects and has connected bluetooth equipment, setting preset service identifies;
Preferably, preset service mark=46540001-0001-00c3-0000-465453414645 is set, default,
Reception data characteristics mark=46540001-0002-00c3-0000-465453414645, transmission data characteristics mark=
46540001-0003-00c3-0000-465453414645。
Step 102: extracting bluetooth device name from Bluetooth broadcast data corresponding with preset service mark, judge to extract
Whether the bluetooth device name arrived is identical as target Bluetooth devices title, is to then follow the steps 103, otherwise return step 101;
In the present embodiment, the information for including in Bluetooth broadcast data has bluetooth device name, bluetooth equipment currently to connect
The current service of state, bluetooth equipment and service identifiers, extract bluetooth device name, judge the bluetooth device name extracted with
Whether target Bluetooth devices title is identical.
Step 103: according to the bluetooth device name extracted, being connected with corresponding bluetooth equipment.
It in the present embodiment, include: that basis mentions with the connection of corresponding bluetooth equipment according to the bluetooth device name extracted
The bluetooth device name got connects the spy under the service of corresponding bluetooth equipment and the service of the corresponding bluetooth equipment of scanning
Sign, record receive data characteristics and send data characteristics, and are respectively labeled as writing feature and read feature.
Embodiment two
Second embodiment of the present invention provides a kind of methods for connecting bluetooth equipment, as shown in Fig. 2, when terminal receives user's
When triggering information, step 201 is executed:
Step 201: judging whether that (full name in English: Bluetooth Low Energy, Chinese name: bluetooth is low by acquisition BLE
Power consumption) authorization, be to then follow the steps 202, otherwise prompt unauthorized, terminate;
In the present embodiment, before step 201, further includes: function is monitored in registration in the system of terminal, instantiates BLE
Central manager, and registration eavesdropping target carrys out the state of the internal environment of real-time monitor terminal into BLE central manager;
Judge whether to obtain the authorization of BLE specifically: detect whether to receive the first return value for monitoring function, be then table
Show the authorization for not obtaining BLE, otherwise indicates the authorization for obtaining BLE;
Preferably, the first return value is CBCentralManagerStateUnauthorized;
In the present embodiment, BLE bluetooth equipment, including three parts: service (Service), feature
(Characteristic), descriptor (Descriptor), three parts are by identifying come uniquely tagged;It is corresponding under service more
A feature, a feature may include multiple descriptors, be characterized in that terminal and bluetooth equipment carry out the data of information exchange.
Step 202: judge whether the hardware of terminal supports BLE, is to then follow the steps 203, otherwise prompts not support BLE,
Terminate;
Specifically, it detects whether to receive the second return value for monitoring function, is to indicate that the hardware of terminal is not supported
Otherwise BLE indicates the hardware supported BLE of terminal;
Preferably, the second return value is CBCentralManagerStateUnsupported.
Step 203: judge whether the system of terminal supports BLE, is to then follow the steps 204, otherwise prompts not support BLE,
Terminate;
Specifically, it detects whether to receive the third return value for monitoring function, is that the system for indicating terminal is not supported
BLE, the system for otherwise indicating terminal support BLE;
In the present embodiment, the system for supporting the terminal of BLE is IOS system;
Preferably, third return value is CBCentralManagerStateUnsupported.
Step 204: judge whether terminal opens Bluetooth function, is to then follow the steps 206, it is no to then follow the steps 205;
Specifically, the type of the return value of Anti-Sniffer function, the return value for such as monitoring function is the 4th return value, then eventually
End has turned on Bluetooth function, and when the return value for such as monitoring function is five return value, then terminal does not open Bluetooth function;
Preferably, the 4th return value is CBCentralManagerStatePoweredOn, and the 5th return value is
CBCentralManagerStatePoweredOff。
Step 205: whether the duration of the Bluetooth function to be opened such as judgement is to terminate, otherwise more than the first preset duration
Bluetooth function, return step 204 are opened in prompt;
Step 206: judging whether terminal has connected bluetooth equipment identical with target Bluetooth devices title, be the company of prompt
It is connected into function, it is no to then follow the steps 207;
In the present embodiment, the BLE bluetooth equipment to be connected is target Bluetooth devices;
Before step 206 further include: judge whether terminal has connected bluetooth equipment, be to then follow the steps 206, otherwise execute
Step 207;When being judged as NO in step 206 before execution step 207 further include: disconnection has connected bluetooth equipment.
Step 207: preset service being set in the system of terminal and is identified;
In the present embodiment, the corresponding mark of the service of bluetooth equipment, referred to as service identifiers;Under the service of bluetooth equipment
The corresponding mark of each feature, be referred to as signature identification;The corresponding reception of reception data characteristics under the service of bluetooth equipment
Data Identification;The corresponding transmission Data Identification of transmission data characteristics under the service of bluetooth equipment;
Specifically, preset service is arranged in the system of terminal to identify, for example, setting preset service mark=
46540001-0001-00c3-0000-465453414645, default, receive Data Identification=46540001-0002-00c3-
0000-465453414645 sends Data Identification=46540001-0003-00c3-0000-465453414645;
Further, it is arranged in the system of terminal after preset service mark, terminal obtains Bluetooth broadcast data, according to
The Bluetooth broadcast data that preset service mark scanning is got;
In the present embodiment, the information for including in Bluetooth broadcast data has bluetooth device name, bluetooth equipment currently to connect
The current service of state, bluetooth equipment and service identifiers;
In this embodiment, the Bluetooth broadcast data got according to preset service mark scanning specifically: according to default clothes
The current service identifiers of bluetooth equipment in the Bluetooth broadcast data that business mark scanning is got.
Step 208: judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark, be to execute step
Rapid 210, it is no to then follow the steps 209;
Specifically, the notice for detecting whether to receive the first function interface of terminal system readjustment is that terminal scanning is arrived
Bluetooth broadcast data corresponding with preset service mark, otherwise terminal does not scan Bluetooth broadcast corresponding with preset service mark
Data.
Step 209: whether judging sweep time more than the second preset duration, be to prompt scanning time-out, terminate, otherwise return
Return step 208;
Step 210: extracting bluetooth device name from Bluetooth broadcast data corresponding with preset service mark;
In the present embodiment, the information for including in Bluetooth broadcast data has bluetooth device name, bluetooth equipment currently to connect
The current service of state, bluetooth equipment and service identifiers extract the bluetooth device name in Bluetooth broadcast data.
Step 211: judging whether the bluetooth device name extracted is identical as target Bluetooth devices title, is, executes step
Rapid 212, otherwise return step 209;
Step 212: according to the bluetooth device name extracted, connecting corresponding bluetooth equipment;
Specifically, when the bluetooth device name of extraction is identical as target Bluetooth devices title, second function interface is called,
Connect bluetooth equipment corresponding with the bluetooth device name extracted, second function interface are as follows:
-(void)connectPeripheral:(CBPeripheral*)peripheral options:(nullable
NSDictionary<NSString*,id>*)options。
Step 213: judge bluetooth equipment corresponding with the bluetooth device name extracted whether successful connection, be to execute
Step 214, connection failure is otherwise prompted, is terminated;
Step 213 specifically: the function interface type of detection terminal system readjustment, the function interface adjusted back such as terminal system
Type is third function interface, then bluetooth equipment successful connection corresponding with the bluetooth device name extracted, such as terminal system
The function interface type of readjustment is the 4th function interface, then bluetooth equipment connection corresponding with the bluetooth device name extracted is lost
It loses;
Specifically, in the present embodiment, third function interface are as follows:
-(void)centralManager:(CBCentralManager*)central
didConnectPeripheral:(CBPeripheral*)peripheral;
4th function interface are as follows:
-(void)centralManager:(CBCentralManager*)central
didFailToConnectPeripheral:(CBPeripheral*)aPeripheral error:(NSError*)error。
Step 214: the service for the bluetooth equipment that connection currently connects;
In the present embodiment, before the service for the bluetooth equipment that connection currently connects further include: receive terminal system readjustment
5th function interface notice, the 5th function interface are as follows:
-(void)peripheral:(CBPeripheral*)peripheral didDiscoverServices:
(nullable NSError*)error;
Step 214 specifically: it receives after terminal sets system detection to the notice of the service of the bluetooth equipment currently connected,
Connect the service of the bluetooth equipment currently connected.
Step 215: judge whether connection service succeeds, is to then follow the steps 217, it is no to then follow the steps 216;
Specifically, after connection services successfully, by the feature under the service for removing to scan the bluetooth equipment currently connected automatically, i.e.,
Execute step 217.
Step 216: judging whether the Connection Time is more than third preset duration, be to prompt connection time-out, terminate, otherwise return
Return step 208;
Step 217: the feature under the service for the bluetooth equipment that scanning currently connects;
In the present embodiment, the feature under the service of bluetooth equipment include bluetooth device name, bluetooth equipment connection status,
Bluetooth device address, reception data, transmission data etc.;
In the present embodiment, before the feature under the service for the bluetooth equipment that scanning currently connects further include: receive terminal
The 6th function interface notice of system readjustment, the 6th function interface are as follows:
-(void)peripheral:(CBPeripheral*)aPeripheral didDiscoverCharacterist
icsForService:(CBService*)service error:(NSError*)error;
Step 217 specifically: receive the notice for the feature that terminal detects under the service of the bluetooth equipment currently connected
Afterwards, the feature under the service for the bluetooth equipment that scanning currently connects;
In the present embodiment, the feature under the service of bluetooth equipment is scanned specifically: the feature array under traverse service.
Step 218: judging whether to scan through all features under the service of the bluetooth equipment currently connected, be to execute step
Rapid 220, it is no to then follow the steps 219;
In the present embodiment, step 218 specifically: judge whether to have traversed the feature array under service, be to scan through
All features under the service of the bluetooth equipment currently connected, under the service for otherwise not scanning through the bluetooth equipment currently connected
All features.
Step 219: whether judging sweep time more than the 4th preset duration, be to prompt scanning time-out, terminate, otherwise return
Return step 217;
Step 220: extracting the mark of all features, and using first feature as current signature;
Specifically, feature array records each feature and the mark of each feature, correspondingly, when feature is arrived in scanning
When feature in array, the mark of the feature scanned is extracted.
Step 221: judging identifying whether as default reception Data Identification for current signature, be to then follow the steps 222, otherwise
Execute step 223;
Specifically, the service identifiers of the target Bluetooth devices in the present embodiment are preset, such as by target Bluetooth devices
Reception Data Identification be set as 46540001-0002-00c3-0000-465453414645, step 221 specifically: judgement work as
Preceding feature identifies whether to be to then follow the steps 222, otherwise hold for 46540001-0002-00c3-0000-465453414645
Row step 223.
Step 222: record current signature is to receive data, by current signature labeled as feature is write, executes step 225;
In the present embodiment, data are received and refer to that bluetooth equipment receives data, is i.e. terminal sends data, note to bluetooth equipment
Recording current signature is to receive data, and be marked as writing feature, subsequent to send data to bluetooth equipment by this feature,
Current signature can be realized by following codes labeled as writing feature specifically:
if([aChar.UUID isEqual:[CBUUIDUUIDWithString:UUIDSTR_C3_TRANS_RX]]){
[myPeripheral setTransparentDataWriteChar:aChar]。
Step 223: judging identifying whether as default transmission Data Identification for current signature, be to then follow the steps 224, otherwise
Using next feature as current signature, return step 221;
Specifically, the service identifiers of the target Bluetooth devices in the present embodiment are preset, such as by target Bluetooth devices
Transmission Data Identification be set as 46540001-0003-00c3-0000-465453414645, step 223 specifically: judgement mention
Identifying whether as 46540001-0003-00c3-0000-465453414645 for the feature taken, is to then follow the steps 224, otherwise
Using next feature as current signature, return step 221.
Step 224: record current signature is to send data, by current signature labeled as feature is read, executes step 225;
In the present embodiment, data are sent and refer to that terminal receives data, is i.e. bluetooth equipment sends data to terminal, and record is current
Feature is to send data, and be marked as reading feature, and subsequent terminal will receive data by this feature, by current signature mark
Being denoted as reading feature can specifically be realized by following codes:
Step 225: judge to receive data characteristics and send whether data characteristics has recorded, is to prompt successful connection,
Terminate, it is no to then follow the steps 226;
In the present embodiment, judge to receive data characteristics and send whether data characteristics has recorded specifically: judgement is
No be marked writes feature and reading feature.
Step 226: judging whether current signature is the last one feature, be to prompt to connect unsuccessful, end, otherwise general
Next feature is as current signature, return step 221.
It should be noted that above-mentioned steps 207 to step 216 can replace in another implementation of the invention
Are as follows:
Step A1: the Bluetooth broadcast data that terminal is got are received;
In the present embodiment, before step A1 further include: terminal obtains Bluetooth broadcast data.
Step A2: setting preset service identifies;
Step A3: the Bluetooth broadcast data received according to preset service mark scanning;
In the present embodiment, the information for including in Bluetooth broadcast data has bluetooth device name, bluetooth equipment currently to connect
The current service of state, bluetooth equipment and service identifiers;
In the present embodiment, step A3 specifically: arrive Bluetooth broadcast data according to the scanning of preset service identifiers is received
The current service identifiers of middle bluetooth equipment.
Step A4: judging whether that scanning is to then follow the steps A6 to Bluetooth broadcast data corresponding with preset service mark,
It is no to then follow the steps A5;
In the present embodiment, step A4 specifically: judge whether that scanning identifies identical bluetooth equipment to preset service
Current service identifiers are then scanning to Bluetooth broadcast data corresponding with preset service mark, execute step A6, otherwise do not sweep
Bluetooth broadcast data corresponding with preset service mark are retouched, step A5 is executed.
Whether step A5: judging sweep time more than the second preset duration, is to prompt scanning time-out, terminates, otherwise return
Return step A3;
Step A6: bluetooth device name is extracted from Bluetooth broadcast data corresponding with preset service mark, judges to extract
Whether the bluetooth device name arrived is identical as target Bluetooth devices title, is to then follow the steps A7, otherwise return step A5;
Step A7: according to the bluetooth device name extracted, corresponding bluetooth equipment is connected;
Step A8: judge the corresponding bluetooth equipment of the bluetooth device name extracted whether successful connection, be to execute step
Otherwise rapid A9 prompts connection failure, terminate;
Step A9: the service for the bluetooth equipment that connection currently connects judges whether connection service succeeds, is to then follow the steps
218, it is no to then follow the steps A10;
In the present embodiment, step A9 specifically: receive the clothes that terminal system detects the bluetooth equipment currently connected
After the notice of business, the service of the bluetooth equipment currently connected is connected.
Step A10: judging whether the Connection Time is more than third preset duration, is to prompt connection time-out, terminates, otherwise return
Return step A3.
Embodiment three
The embodiment of the present invention three provides a kind of device for connecting bluetooth equipment, as shown in Figure 3, comprising:
First judgment module 301, for judging whether terminal scans Bluetooth broadcast number corresponding with preset service mark
According to;
Extraction module 302, for judging terminal scanning to indigo plant corresponding with preset service mark when first judgment module 301
When tooth broadcast data, bluetooth device name is extracted from Bluetooth broadcast data corresponding with preset service mark;
Cue module 303, for judge that terminal does not scan corresponding with preset service mark when first judgment module 301
When Bluetooth broadcast data, scanning failure is prompted, is terminated;
Second judgment module 304, for judging bluetooth device name that extraction module extracts and target Bluetooth devices name
Whether identical claim;
Link block 305, for judging the bluetooth device name and mesh that extraction module extracts when the second judgment module 304
When mark bluetooth device name is identical, the bluetooth device name extracted according to extraction module is connected with corresponding bluetooth equipment;
In the present embodiment, first judgment module 301 are also used to judge the bluetooth extracted when the second judgment module 304
When device name and target Bluetooth devices title difference, it is wide with the corresponding bluetooth of preset service mark to judge whether terminal scans
Multicast data.
In the present embodiment, first judgment module 301, specifically for judging whether to receive the scanning for carrying out self terminal success
Notice, if it is, determining that Bluetooth broadcast data corresponding with preset service mark are arrived in terminal scanning;Otherwise, it determines terminal does not have
There is scanning to Bluetooth broadcast data corresponding with preset service mark;
Alternatively,
The Bluetooth broadcast data that terminal is got are received, judge whether include and preset in the Bluetooth broadcast data got
The corresponding Bluetooth broadcast data of service identifiers, if it is, it is wide with the corresponding bluetooth of preset service mark to determine that terminal scanning is arrived
Multicast data;Otherwise, it determines terminal, which does not scan preset service, identifies corresponding Bluetooth broadcast data.
In the present embodiment, first judgment module, specifically for judging whether to receive the system for carrying out self terminal readjustment
The notice of first function interface.
The device of the present embodiment further include:
Third judgment module, for judging whether the internal environment of terminal supports Bluetooth Low Energy;
When for judging that the internal environment of terminal supports Bluetooth Low Energy when third module, default clothes are arranged in setup module
Business mark;
In the present embodiment, cue module 303 are also used to judge that the internal environment of terminal is not supported when third judgment module
When Bluetooth Low Energy, prompts not support Bluetooth Low Energy, terminate.
In the present embodiment, third judgment module is specifically used for executing following operation:
Judge whether the authorization of acquisition Bluetooth Low Energy;
Judge whether the hardware of terminal supports Bluetooth Low Energy;
Judge whether the system of terminal supports Bluetooth Low Energy;
Judge whether terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of terminal supports Bluetooth Low Energy, otherwise, really
The internal environment for determining terminal does not support Bluetooth Low Energy.
The device of the present embodiment further include:
Monitor module, the state of the internal environment for monitor terminal.
In the present embodiment, module is monitored, specifically for the registration monitoring function in the system of terminal, it is low to instantiate bluetooth
Power consumption central manager, and registration eavesdropping target carrys out the internal environment of real-time monitor terminal into Bluetooth Low Energy central manager
State.
Further, in the present embodiment, third judgment module specifically includes:
First detection sub-module is not obtain bluetooth for detecting whether receiving the first return value for monitoring function
Otherwise the authorization of low-power consumption obtains the authorization of Bluetooth Low Energy;
Second detection sub-module is the hardware of then terminal for detecting whether receiving the second return value for monitoring function
Do not support Bluetooth Low Energy, otherwise the hardware supported Bluetooth Low Energy of terminal;
Third detection sub-module is the system of then terminal for detecting whether receiving the third return value for monitoring function
Do not support Bluetooth Low Energy, otherwise the system of terminal supports Bluetooth Low Energy;
4th detection sub-module, the type of the return value for detecting the monitoring function received, if the 4th return value,
Then terminal has turned on Bluetooth function, and if the 5th return value, then terminal does not open Bluetooth function.
The device of the present embodiment further include:
4th judgment module, for judging whether terminal has connected bluetooth equipment;
In the present embodiment, setup module is also used to when the 4th judgment module judges that terminal is not connected with bluetooth equipment, if
Set preset service mark;
5th judgment module, for when the 4th judgment module judges that terminal has connected bluetooth equipment, judgement to have connected indigo plant
Whether the title of tooth equipment is identical as target Bluetooth devices title;
In the present embodiment, cue module 303, also with the title for judge to have connected bluetooth equipment when the 5th judgment module and
When target Bluetooth devices title is identical, successful connection is prompted;
Module is disconnected, for having connected the title and target Bluetooth devices title of bluetooth equipment when the judgement of the 5th judgment module
When different, disconnection has connected bluetooth equipment, trigger setup module.
In the present embodiment, link block 305 includes:
Submodule is connected, for connecting the service of corresponding bluetooth equipment according to the bluetooth device name extracted;
Submodule is scanned, for the bluetooth device name that basis is extracted, under the service for scanning corresponding bluetooth equipment
Feature;
Record sub module, for when the feature scanned is to receive data characteristics, the feature that writing scan is arrived to be to receive
Data characteristics is marked as writing feature;For the feature that when the feature scanned is to send data characteristics, writing scan is arrived
To send data characteristics, it is marked as reading feature.
In the present embodiment, submodule is connected, is set specifically for receiving the bluetooth that terminal system is detected and extracted
After the notice of the service of the standby corresponding bluetooth equipment of title, according to the bluetooth device name extracted, connects corresponding bluetooth and set
Standby service.
In the present embodiment, submodule is scanned, is set specifically for receiving the bluetooth that terminal system is detected and extracted
After the notice of feature under the service of the standby corresponding bluetooth equipment of title, according to the bluetooth device name extracted, scanning is corresponded to
Bluetooth equipment service under feature.
In the present embodiment, record sub module includes:
Extraction unit, for extracting the mark of the feature scanned;
First judging unit, for judging the identifying whether as the default Data Identification and/or pre- of receiving of the feature extracted
If sending Data Identification;
In the present embodiment, record sub module, specifically for the mark for the feature extracted when the judgement of the first judging unit
When being default reception Data Identification, the corresponding feature of mark for the feature extracted is recorded to receive data characteristics, is marked
To write feature;
In the present embodiment, record sub module, specifically for the mark for the feature extracted when the judgement of the first judging unit
When being default transmission Data Identification, the corresponding feature of mark for the feature extracted is recorded to send data characteristics, is marked
To read feature;
Second judgment unit, for judging to receive data characteristics and sending whether data characteristics has recorded;
In the present embodiment, cue module 303 are also used to receive data characteristics when second judgment unit judgement and send number
When having recorded according to feature, successful connection is prompted;
Third judging unit, for not remembering all when second judgment unit judgement receives data characteristics and sends data characteristics
When record, judge whether the corresponding feature of the mark for the feature extracted is the last one feature;
In the present embodiment, cue module 303 are also used to judge the mark pair for the feature extracted when third judging unit
It answers when being characterized in the last one feature, prompts connection failure;
In the present embodiment, extraction unit, the signature identification for being also used to extract when the judgement of third judging unit are corresponding
When feature is not the last one feature, the mark of the feature scanned is extracted.
According to the technical solution of the present invention, after split type bluetooth equipment is connect with terminal, when split type bluetooth equipment more
Different functional modules is changed, when terminal and new functional module are attached, terminal can not depend on caching and timely update new
Functional module mark, and then terminal successful scan and connect new functional module.
The foregoing is only a preferred embodiment of the present invention, but scope of protection of the present invention is not limited thereto,
Anyone skilled in the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, all
It is covered by the protection scope of the present invention.Therefore, protection scope of the present invention is answered described with scope of protection of the claims
Subject to.
Claims (22)
1. a kind of method for connecting bluetooth equipment characterized by comprising
Step S0: judging whether the internal environment of terminal supports Bluetooth Low Energy, is to then follow the steps B1, otherwise prompts not support
The Bluetooth Low Energy terminates;
Step B1: judging whether the terminal has connected bluetooth equipment, is to then follow the steps B2, and preset service mark is otherwise arranged
Know, executes step S1;
Step B2: whether the title that bluetooth equipment is had connected described in judgement is identical as target Bluetooth devices title, is the company of prompt
It is connected into function, is terminated, otherwise has connected bluetooth equipment described in disconnection, the preset service mark is set;
Step S1: judging whether the terminal scans Bluetooth broadcast data corresponding with preset service mark, is to hold
Row step S2, otherwise prompt scanning failure, terminates;
Step S2: bluetooth device name is extracted from the Bluetooth broadcast data corresponding with preset service mark, judges to extract
Whether the bluetooth device name arrived is identical as target Bluetooth devices title, is to then follow the steps S3, otherwise return step S1;
Step S3: it according to the bluetooth device name extracted, is connected with corresponding bluetooth equipment.
2. the method according to claim 1, wherein
The step S1 specifically: judge whether to receive the scanning success notification from the terminal, if it is, determining institute
Terminal scanning is stated to Bluetooth broadcast data corresponding with preset service mark;It is preset otherwise, it determines the terminal does not scan
The corresponding Bluetooth broadcast data of service identifiers;
Alternatively,
Receive the Bluetooth broadcast data that the terminal is got, in the Bluetooth broadcast data got described in judgement whether comprising with
Preset service identifies corresponding Bluetooth broadcast data, if it is, it is corresponding with preset service mark to determine that the terminal scanning is arrived
Bluetooth broadcast data;Otherwise, it determines the terminal does not scan Bluetooth broadcast data corresponding with preset service mark.
3. according to the method described in claim 2, it is characterized in that, the scanning success notification, specifically: the terminal is
The notice of the first function interface of system readjustment.
4. the method according to claim 1, wherein whether the internal environment for judging the terminal supports indigo plant
Tooth low-power consumption, specifically:
Judge whether to obtain the authorization of the Bluetooth Low Energy;
Judge whether the hardware of the terminal supports the Bluetooth Low Energy;
Judge whether the system of the terminal supports the Bluetooth Low Energy;
Judge whether the terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of the terminal supports the Bluetooth Low Energy, no
Then, determine that the internal environment of the terminal does not support the Bluetooth Low Energy.
5. according to the method described in claim 4, it is characterized in that, whether the internal environment for judging the terminal supports indigo plant
Before tooth low-power consumption, comprising: monitor the state of the internal environment of the terminal.
6. according to the method described in claim 5, it is characterized in that, the state of the internal environment for monitoring the terminal, tool
Body are as follows: function is monitored in registration in the system of the terminal, instantiates Bluetooth Low Energy central manager, and to Bluetooth Low Energy
Eavesdropping target is registered in central manager to monitor the state of the internal environment of the terminal in real time.
7. according to the method described in claim 6, it is characterized in that, described judge whether to obtain awarding for the Bluetooth Low Energy
Power, specifically: it detects whether to receive first return value for monitoring function, is not obtain awarding for the Bluetooth Low Energy
Power, otherwise obtains the authorization of the Bluetooth Low Energy;
Whether the hardware for judging the terminal supports the Bluetooth Low Energy, specifically: it detects whether to receive the prison
The second return value for listening function is that the hardware of the terminal does not support the Bluetooth Low Energy, otherwise the hardware of the terminal
Support the Bluetooth Low Energy;
Whether the system for judging the terminal supports the Bluetooth Low Energy, specifically: it detects whether to receive the prison
The third return value for listening function is that the system of the terminal does not support the Bluetooth Low Energy, otherwise the system of the terminal
Support the Bluetooth Low Energy;
It is described to judge whether the terminal opens Bluetooth function, specifically: detect the return value of the monitoring function received
Type, if the 4th return value, then the terminal has turned on Bluetooth function, and if the 5th return value, then the terminal is not opened
Open Bluetooth function.
8. the method according to claim 1, wherein the step S3 includes:
Step C1: according to the bluetooth device name extracted, the service of corresponding bluetooth equipment is connected;
Step C2: according to the bluetooth device name extracted, the feature under the service of the corresponding bluetooth equipment is scanned;
Step C3: when the feature scanned is to receive data characteristics, the feature that writing scan is arrived is the reception data characteristics,
It is marked as writing feature, when the feature scanned is to send data characteristics, the feature that writing scan is arrived is the transmission number
According to feature, it is marked as reading feature.
9. according to the method described in claim 8, it is characterized in that, the step C1 specifically: receive terminal system detection
To after the notice of the service of bluetooth equipment corresponding with the bluetooth device name extracted, according to the bluetooth extracted
Device name connects the service of corresponding bluetooth equipment.
10. according to the method described in claim 8, it is characterized in that, the step C2 specifically: receive terminal system detection
After the notice of feature under to the service of bluetooth equipment corresponding with the bluetooth device name extracted, according to the extraction
The bluetooth device name arrived scans the feature under the service of corresponding bluetooth equipment.
11. according to the method described in claim 8, it is characterized in that, the step C3 specifically:
Step C3-1: the mark of the feature scanned is extracted;
Step C3-2: judge identifying whether as default reception Data Identification and/or default transmission data mark for the feature extracted
Know, if the default reception Data Identification, thens follow the steps C3-3, if the default transmission Data Identification, then execute step
Rapid C3-4, it is no to then follow the steps C3-5;
Step C3-3: the corresponding feature of the mark for the feature extracted described in record is the reception data characteristics, is marked
To write feature, step C3-5 is executed;
Step C3-4: the corresponding feature of the mark for the feature extracted described in record is the transmission data characteristics, is marked
To read feature, step C3-5 is executed;
Step C3-5: judging whether the reception data characteristics and the transmission data characteristics have recorded, and is to prompt to connect
Success terminates, no to then follow the steps C3-6;
Step C3-6: whether the corresponding feature of the mark for the feature extracted described in judgement is the last one feature, is to prompt
Connection failure terminates, otherwise extracts the mark of next feature scanned, return step C3-2.
12. a kind of device for connecting bluetooth equipment characterized by comprising
First judgment module, for judging whether terminal scans Bluetooth broadcast data corresponding with preset service mark;
Second judgment module, for judge bluetooth device name that extraction module extracts and target Bluetooth devices title whether phase
Together;
Third judgment module, for judging whether the internal environment of the terminal supports Bluetooth Low Energy;
4th judgment module, for judging whether the terminal has connected bluetooth equipment;
5th judgment module, for when the 4th judgment module judges that the terminal has connected bluetooth equipment, described in judgement
Whether title and the target Bluetooth devices title for having connected bluetooth equipment are identical;
Setup module, for judging that the internal environment of the terminal supports the Bluetooth Low Energy when the third judgment module
When, the preset service mark is set;For when the 4th judgment module judge the terminal be not connected with bluetooth equipment when, if
Set the preset service mark;
The extraction module, for judging terminal scanning to bluetooth corresponding with preset service mark when the first judgment module
When broadcast data, bluetooth device name is extracted from the Bluetooth broadcast data corresponding with preset service mark;
Cue module, for judge that terminal does not scan wide with the corresponding bluetooth of preset service mark when the first judgment module
When multicast data, scanning failure is prompted, is terminated;For judging that the internal environment of the terminal is not supported when the third judgment module
When the Bluetooth Low Energy, prompts not supporting the Bluetooth Low Energy, terminate;Described in judging when the 5th judgment module
Have connected bluetooth equipment title it is identical as the target Bluetooth devices title when, prompt successful connection;
Link block, for when second judgment module judge bluetooth device name that the extraction module extracts with it is described
When target Bluetooth devices title is identical, according to the bluetooth device name that the extraction module extracts, with corresponding bluetooth equipment
Connection;
The first judgment module, the bluetooth device name for being also used to extract described in second judgment module judgement and institute
When stating target Bluetooth devices title difference, judge whether terminal scans Bluetooth broadcast data corresponding with preset service mark;
Module is disconnected, for working as the title for having connected bluetooth equipment described in the 5th judgment module judgement and the target Bluetooth
When device name difference, bluetooth equipment is had connected described in disconnection, triggers the setup module.
13. device according to claim 12, which is characterized in that the first judgment module, specifically for judging whether
The scanning success notification from the terminal is received, if it is, determining that the terminal scanning is arrived and preset service mark pair
The Bluetooth broadcast data answered;Otherwise, it determines the terminal does not scan Bluetooth broadcast data corresponding with preset service mark;
Alternatively,
Receive the Bluetooth broadcast data that the terminal is got, in the Bluetooth broadcast data got described in judgement whether comprising with
Preset service identifies corresponding Bluetooth broadcast data, if it is, it is corresponding with preset service mark to determine that the terminal scanning is arrived
Bluetooth broadcast data;Otherwise, it determines the terminal, which does not scan preset service, identifies corresponding Bluetooth broadcast data.
14. device according to claim 13, which is characterized in that the first judgment module, specifically for judging whether
Receive the notice of the first function interface of the system readjustment from the terminal.
15. device according to claim 12, which is characterized in that the third judgment module is specifically used for executing following
Operation:
Judge whether to obtain the authorization of the Bluetooth Low Energy;
Judge whether the hardware of the terminal supports the Bluetooth Low Energy;
Judge whether the system of the terminal supports the Bluetooth Low Energy;
Judge whether the terminal opens Bluetooth function;
If the result of the judgement executed is to be, it is determined that the internal environment of the terminal supports the Bluetooth Low Energy, no
Then, determine that the internal environment of the terminal does not support the Bluetooth Low Energy.
16. device according to claim 15, which is characterized in that further include:
Monitor module, the state of the internal environment for monitoring the terminal.
17. device according to claim 16, which is characterized in that the monitoring module, specifically in the terminal
Function is monitored in registration in system, instantiates Bluetooth Low Energy central manager, and register into Bluetooth Low Energy central manager
Eavesdropping target monitors the state of the internal environment of the terminal in real time.
18. device according to claim 17, which is characterized in that the third judgment module specifically includes:
First detection sub-module, for detecting whether receive first return value for monitoring function, be do not obtain it is described
Otherwise the authorization of Bluetooth Low Energy obtains the authorization of the Bluetooth Low Energy;
Second detection sub-module is the then terminal for detecting whether receiving second return value for monitoring function
Hardware does not support the Bluetooth Low Energy, otherwise Bluetooth Low Energy described in the hardware supported of the terminal;
Third detection sub-module is the then terminal for detecting whether receiving the third return value for monitoring function
System does not support the Bluetooth Low Energy, and otherwise the system of the terminal supports the Bluetooth Low Energy;
4th detection sub-module, the type of the return value for detecting the monitoring function received, if the 4th return value,
Then the terminal has turned on Bluetooth function, and if the 5th return value, then the terminal does not open Bluetooth function.
19. device according to claim 12, which is characterized in that the link block includes:
Submodule is connected, the bluetooth device name for extracting according to connects the service of corresponding bluetooth equipment;
Submodule is scanned, the bluetooth device name for extracting according to scans the service of the corresponding bluetooth equipment
Under feature;
Record sub module, for when the feature scanned is to receive data characteristics, the feature that writing scan is arrived to be the reception
Data characteristics is marked as writing feature;For the feature that when the feature scanned is to send data characteristics, writing scan is arrived
For the transmission data characteristics, it is marked as reading feature.
20. device according to claim 19, which is characterized in that the connection submodule, specifically for receiving terminal
After system detection to the notice of the service of bluetooth equipment corresponding with the bluetooth device name extracted, according to the extraction
The bluetooth device name arrived connects the service of corresponding bluetooth equipment.
21. device according to claim 19, which is characterized in that the scanning submodule, specifically for receiving terminal
After the notice of feature under system detection to the service of bluetooth equipment corresponding with the bluetooth device name extracted, according to
The bluetooth device name extracted, scans the feature under the service of corresponding bluetooth equipment.
22. device according to claim 19, which is characterized in that the record sub module includes:
Extraction unit, for extracting the mark of the feature scanned;
First judging unit, for judge the feature extracted identify whether receive Data Identification and/or default hair to be default
Send Data Identification;
The record sub module, the mark of the feature specifically for extracting when first judging unit judgement are described default
When receiving Data Identification, the corresponding feature of mark for the feature extracted described in record is the reception data characteristics, is marked
It is denoted as and writes feature;
The record sub module, the mark of the feature specifically for extracting when first judging unit judgement are described default
When sending Data Identification, the corresponding feature of mark for the feature extracted described in record is the transmission data characteristics, is marked
It is denoted as reading feature;
Second judgment unit, for judging whether the reception data characteristics and the transmission data characteristics have recorded;
The cue module is also used to judge that the reception data characteristics and the transmission data are special when the second judgment unit
When sign has recorded, successful connection is prompted;
Third judging unit, for judging the reception data characteristics and the transmission data characteristics when the second judgment unit
When not recording all, whether the corresponding feature of mark for the feature extracted described in judgement is the last one feature;
The cue module, the corresponding feature of mark for the feature for being also used to extract described in third judging unit judgement
When being the last one feature, connection failure is prompted;
The extraction unit, the corresponding feature of signature identification for being also used to extract described in third judging unit judgement is not
When being the last one feature, the mark of next feature scanned is extracted.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510824405.1A CN105517110B (en) | 2015-11-24 | 2015-11-24 | A kind of method and device connecting bluetooth equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510824405.1A CN105517110B (en) | 2015-11-24 | 2015-11-24 | A kind of method and device connecting bluetooth equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105517110A CN105517110A (en) | 2016-04-20 |
CN105517110B true CN105517110B (en) | 2019-03-29 |
Family
ID=55724660
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510824405.1A Active CN105517110B (en) | 2015-11-24 | 2015-11-24 | A kind of method and device connecting bluetooth equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105517110B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106211355B (en) * | 2016-06-15 | 2019-12-20 | 飞天诚信科技股份有限公司 | Equipment and system for controlling data interaction and working method thereof |
CN106131810B (en) * | 2016-06-20 | 2020-06-02 | 飞天诚信科技股份有限公司 | Method and device for connecting Bluetooth dual-mode equipment |
US9973922B1 (en) | 2017-03-23 | 2018-05-15 | Honda Motor Co., Ltd. | User identification from user data associated with a mobile communication device |
CN110267248B (en) * | 2019-06-28 | 2020-07-28 | 阿里巴巴集团控股有限公司 | B L E communication method, device, equipment and storage medium |
US10856347B2 (en) | 2019-06-28 | 2020-12-01 | Advanced New Technologies Co., Ltd. | Wireless communications method, apparatus, device, and storage medium |
CN111542040B (en) * | 2020-07-07 | 2020-10-13 | 飞天诚信科技股份有限公司 | Method and device for enhancing Bluetooth connection stability |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102654831A (en) * | 2011-03-04 | 2012-09-05 | 百度在线网络技术(北京)有限公司 | Device and method for intensively controlling WEB page event and state |
CN204231671U (en) * | 2014-09-29 | 2015-03-25 | 樊明延 | A kind of Bluetooth beacon device and WLAN terminal authentication connecting system |
CN104539324A (en) * | 2014-12-25 | 2015-04-22 | 惠州Tcl移动通信有限公司 | Bluetooth low-power-consumption networking interconnecting method and system |
CN104540190A (en) * | 2014-12-30 | 2015-04-22 | 广州视源电子科技股份有限公司 | Bluetooth device matching method and system |
-
2015
- 2015-11-24 CN CN201510824405.1A patent/CN105517110B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102654831A (en) * | 2011-03-04 | 2012-09-05 | 百度在线网络技术(北京)有限公司 | Device and method for intensively controlling WEB page event and state |
CN204231671U (en) * | 2014-09-29 | 2015-03-25 | 樊明延 | A kind of Bluetooth beacon device and WLAN terminal authentication connecting system |
CN104539324A (en) * | 2014-12-25 | 2015-04-22 | 惠州Tcl移动通信有限公司 | Bluetooth low-power-consumption networking interconnecting method and system |
CN104540190A (en) * | 2014-12-30 | 2015-04-22 | 广州视源电子科技股份有限公司 | Bluetooth device matching method and system |
Also Published As
Publication number | Publication date |
---|---|
CN105517110A (en) | 2016-04-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105517110B (en) | A kind of method and device connecting bluetooth equipment | |
CN100536403C (en) | Method and equipment of intelligent patrol detection for communication network | |
CN108429629A (en) | Equipment fault restoration methods and device | |
CN101656974A (en) | SIM card compatibility automated test method and device | |
CN106713036B (en) | Fault processing method and system for mobile terminal payment system | |
CN103517375B (en) | A kind of to multiple mobile equipment identification, the method for communication and device | |
CN107404522A (en) | The cluster virtual machine high availability implementation method and device of a kind of cross-node | |
CN102457403B (en) | Method and device for detecting network connection faults | |
CN106209503A (en) | RPC interface test method and system | |
CN103888597B (en) | A kind of communication means, device and electronic equipment | |
CN106028309A (en) | Method and device for recovering master SIM (Subscriber Identity Module Card) in dual SIM dual standby terminal to data network | |
CN107547550A (en) | Authentication method and device | |
CN105491603B (en) | Network communicating function abnormal processing method, application processor and mobile terminal | |
CN105376094B (en) | Processing method, modem and the mobile terminal of network communicating function exception | |
CN106059787A (en) | State obtaining method and device of miniature machine servers | |
CN106506212A (en) | Abnormal information acquisition methods and user terminal | |
CN103051484B (en) | Session service processing method, system and Session Border Controll | |
CN106646021B (en) | A kind of Kato detection method and device | |
CN108307414A (en) | Wi-Fi connection abnormality eliminating method, device, terminal and the storage medium of application program | |
CN107820265A (en) | Handle the method and system of radio POS terminal failure | |
CN105338562B (en) | Service state reports abnormal restoration methods, device and the mobile terminal for causing interim card | |
CN105988882B (en) | A kind of application software fault repairing method and terminal device | |
CN105357050B (en) | Network communicating function abnormal processing method, application processor and mobile terminal | |
CN101145965A (en) | A method and device for automatic login to telecommunication network management | |
CN109257268A (en) | A kind of network attack test system and method across vlan |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |