CN108540966A - A kind of method and communication device of Bluetooth communication - Google Patents

A kind of method and communication device of Bluetooth communication Download PDF

Info

Publication number
CN108540966A
CN108540966A CN201810220916.6A CN201810220916A CN108540966A CN 108540966 A CN108540966 A CN 108540966A CN 201810220916 A CN201810220916 A CN 201810220916A CN 108540966 A CN108540966 A CN 108540966A
Authority
CN
China
Prior art keywords
data
communication device
sent
bluetooth equipment
operation data
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.)
Granted
Application number
CN201810220916.6A
Other languages
Chinese (zh)
Other versions
CN108540966B (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.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co 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 Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201810220916.6A priority Critical patent/CN108540966B/en
Publication of CN108540966A publication Critical patent/CN108540966A/en
Application granted granted Critical
Publication of CN108540966B publication Critical patent/CN108540966B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0056Systems characterized by the type of code used
    • H04L1/0067Rate matching
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/12Arrangements for detecting or preventing errors in the information received by using return channel
    • H04L1/16Arrangements for detecting or preventing errors in the information received by using return channel in which the return channel carries supervisory signals, e.g. repetition request signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/20Manipulation of established connections
    • H04W76/28Discontinuous transmission [DTX]; Discontinuous reception [DRX]

Landscapes

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

Abstract

The present invention relates to the communications fields more particularly to the method and communication device of a kind of Bluetooth communication, this method to include:Communication device waits for the calling of upper layer application, and the operation data that upper layer application is sent is received when data interaction interface is called, the operation data is sent to bluetooth equipment by no response mode;Communication device judges whether successfully receiving the operating result that the bluetooth equipment returns, and is that the operating result received is returned to upper layer application;Otherwise by there is response mode that the operation data is sent to bluetooth equipment, judge whether to be successfully transmitted operation data, when judgement is successfully transmitted operation data, the operating result of bluetooth equipment return is judged whether successfully receiving, is that the operating result received is returned into upper layer application;Otherwise communication failure;The present invention, with the mode transmission data for having response mode to be combined, increases the stability of Bluetooth communication by using no response mode.

Description

A kind of method and communication device of Bluetooth communication
Technical field
The present invention relates to the communications field more particularly to the methods and communication device of a kind of Bluetooth communication.
Background technology
Currently, mobile terminal Bluetooth communication mainly uses two ways, there is response mode and without response mode.Without response mode The speed of transmission data is probably have response mode transmission data speed two times.During existing Bluetooth communication, normal conditions Under can all use the mode transmission data of no response, in the case that transmission data amount is big, using no response mode transmission data When be susceptible to Bluetooth slave devices receive ability saturation so as to cause blue-teeth data packet loss, receive the abnormal feelings such as data time-out Condition affects the stability of Bluetooth communication.In view of the above problems, there is an urgent need for the technical sides for the Bluetooth communication stabilization that gives one's hand for industry Case.
Invention content
In order to solve the above technical problems, the present invention provides a kind of methods of Bluetooth communication, including:
Step S1, communication device waits for the calling of upper layer application, and upper layer application is received when data interaction interface is called The operation data of transmission executes step S2;
Step S2, operation data is sent to bluetooth equipment by communication device by no response mode;
Step S3, communication device judges whether successfully receiving the operating result of bluetooth equipment return, is that will receive Operating result return to upper layer application, terminate;It is no to then follow the steps S4;
Step S4, communication device judges whether successfully to send out by there is response mode that operation data is sent to bluetooth equipment Operation data is sent, is to then follow the steps S5;Otherwise communication failure terminates;
Step S5, communication device judges whether successfully receiving the operating result of bluetooth equipment return, is that will receive Operating result return to upper layer application, terminate;Otherwise communication failure terminates.
The present invention provides a kind of communication devices, including:
Receiving module, the calling for waiting for upper layer application receive upper layer application hair when data interaction interface is called The operation data sent;
Sending module, for the operation data that receiving module receives to be sent to bluetooth equipment by no response mode;
First judgment module, for being sent out by the operation data that no response mode receives receiving module when sending module After giving bluetooth equipment, the operating result of bluetooth equipment return is judged whether successfully receiving;
Sending module is additionally operable to when the judgement of the first judgment module is successfully received the operating result of bluetooth equipment return, The operating result received is returned into upper layer application;It is additionally operable to set when the judgement of the first judgment module is not successfully receiving bluetooth When the standby operating result returned, by there is response mode that operation data is sent to bluetooth equipment;
Second judgment module, for work as sending module by have response mode by operating result be sent to bluetooth equipment it Afterwards, judge whether to be successfully transmitted operation data;
Third judgment module, for after the judgement of the second judgment module is successfully transmitted operation data, judging whether success Receive the operating result of bluetooth equipment return;
Sending module is additionally operable to when the judgement of third judgment module is successfully received the operating result of bluetooth equipment return, The operating result received is returned into upper layer application.
Beneficial effects of the present invention are:The present invention is sent out by using no response mode with the mode for having response mode to be combined Data are sent, that is, ensure that traffic rate, also increase the stability of Bluetooth communication, provide better experience to the user.
Description of the drawings
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 technology description to be briefly described, 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 Obtain other attached drawings according to these attached drawings.
Fig. 1 is a kind of flow chart of the method for Bluetooth communication that the embodiment of the present invention 1 provides;
Fig. 2 is a kind of flow chart of the method for Bluetooth communication that the embodiment of the present invention 2 provides;
Fig. 3 is a kind of block diagram for communication device that the embodiment of the present invention 3 provides.
Specific implementation mode
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 describes, 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, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
Embodiment 1
The present embodiment provides a kind of methods of Bluetooth communication, referring to Fig. 1, including:
Step S1, communication device waits for the calling of upper layer application, and upper layer application is received when data interaction interface is called The operation data of transmission executes step S2;
Step S2, operation data is sent to bluetooth equipment by communication device by no response mode;
Step S3, communication device judges whether successfully receiving the operating result of bluetooth equipment return, is that will receive Operating result return to upper layer application, terminate;It is no to then follow the steps S4;
Step S4, communication device judges whether successfully to send out by there is response mode that operation data is sent to bluetooth equipment Operation data is sent, is to then follow the steps S5;Otherwise communication failure terminates;
Step S5, communication device judges whether successfully receiving the operating result of bluetooth equipment return, is that will receive Operating result return to upper layer application, terminate;Otherwise communication failure terminates.
Optionally, after step S2, further include before step S3:The first preset duration of communication device suspend mode.
Optionally, after step S2, further include before step S3:Communication device obtains bluetooth signal intensity, according to bluetooth Signal strength determines the first sleep time, carries out suspend mode.
It should be noted that when bluetooth signal intensity is stronger, the first sleep time determined is shorter.
Preferably, in step S3, communication device judgement is not successfully receiving after the operating result of bluetooth equipment return, Further include before executing step S4:Communication device update without response transmission times, and judge without respond transmission times whether be more than First preset value is to then follow the steps S4, otherwise return to step S2.
Further, after step S2, further include before step S3:Communication device determines the according to without response transmission times Two sleep times carry out suspend mode.
It should be noted that more without response transmission times, the second sleep time is longer;
Optionally, communication device judgement is successfully transmitted after operation data in step S4, further includes before step S5:Communication The second preset duration of device suspend mode;
Optionally, communication device judgement is successfully transmitted after operation data in step S4, further includes before step S5:Communication Device obtains bluetooth signal intensity, determines third sleep time according to bluetooth signal intensity, carries out suspend mode.
It should be noted that when bluetooth signal intensity is stronger, determining third sleep time is shorter.
Optionally, in step S4, communication device judgement is not successfully transmitted after operation data, further includes:Communication device Update has a response transmission times, and judges have response transmission times whether more than the second preset value, is then communication failure, end, Otherwise return to step S4;
In step S5, communication device judgement is not successfully receiving after the operating result of bluetooth equipment return, further includes: Communication device update has response transmission times, and judges have response transmission times whether more than the second preset value, is to communicate mistake End is lost, otherwise return to step S4.
Further, communication device judgement is successfully transmitted after operation data, further includes before step S5:Communication device According to there is response transmission times to determine the 4th sleep time, suspend mode is carried out.
It should be noted that there is response transmission times more, the 4th sleep time is longer;
The present embodiment after sending operation data by increase sleep time, increase Bluetooth slave devices receive data when Between, to ensure that communication is stablized;Sleep time is determined especially by following manner:1) suspend mode preset duration;2) according to current blue Tooth signal strength determines sleep time;3) sleep time is determined according to the number for sending operation data.
Preferably, in step S3, communication device judgement is not successfully receiving after the operating result of bluetooth equipment return, Further include before executing step S4:
Step A1, communication device obtains bluetooth signal intensity, judges whether bluetooth signal intensity is more than preset value, is to hold Row step A2;It is no to then follow the steps S4;
Step A2, whether communication device update judges default more than third without response transmission times without response transmission times Value, is to then follow the steps S4, otherwise return to step S2.
Specifically, step S2 is specifically included:
Step B1, communication device obtains current packetized data according to single packet maximum length to operation data sequence subpackage, leads to It crosses no response mode and current packetized data is sent to bluetooth equipment;
Step B2, communication device judges in operation data whether to also have the data not sent, is then return to step B1, no Then follow the steps S3.
Further, in step S3, communication device judgement is not successfully receiving the operating result of bluetooth equipment return Later, before step S4, further include:
Step C1, communication device obtains currently the data order subpackage not sent in operation data according to preset length Packetized data, by there is response mode that current packetized data is sent to bluetooth equipment;
Step C2, communication device judges in operation data whether to also have the data not sent, is then return to step C1, no Then follow the steps S3;
It should be noted that preset length is less than the data length of communication equipment last time transmission.
Specifically, being specifically included in step S4:
Step D1, communication device obtains current packetized data according to single packet maximum length to operation data sequence subpackage, leads to It has crossed response mode and current packetized data is sent to bluetooth equipment;
Step D2, communication device judges whether the transmission data that succeeded, and is to then follow the steps D3, otherwise communication failure, knot Beam;
Step D3, communication device judges in operation data whether to also have the data not sent, is then return to step D1, no Then follow the steps S5.
Further, in step D2, when communication device judgement is not successfully transmitted data, further include:
Step E1, communication device obtains currently the data order subpackage not sent in operation data according to preset length Packetized data, by there is response mode that current packetized data is sent to bluetooth equipment;
Step E2, communication device judges whether the transmission data that succeeded, and is to then follow the steps E3, otherwise communication failure, knot Beam;
Step E3, communication device judges in operation data whether to also have the data not sent, is then return to step E1, no Then follow the steps S5;
It should be noted that preset length is less than the data length of communication equipment last time transmission.
The above method reduces single bag data length after communication failure, ensures that communication is stablized;
Specifically, the operating result that communication device judges whether successfully receiving bluetooth equipment return specifically includes:
Step F1, communication device judges whether to receive the operating result of bluetooth equipment return, is to then follow the steps F2, no Then judgement is not successfully receiving the operating result that the bluetooth equipment returns;
Step F2, communication device judges whether the operating result received is complete, is, judgement is successfully received bluetooth and sets The standby operating result returned, otherwise judgement are not successfully receiving the operating result of bluetooth equipment return.
Step E2 is specifically included:
Step F2-1, communication device obtains protocol data length and message check value from operating result, judges operation knot Whether the length of fruit matches with the length of protocol data, is to then follow the steps E2-2;Otherwise decision result is imperfect;
Step F2-2, communication device according to message check value verification operation as a result, if being verified decision result Completely, otherwise decision result is imperfect.
Preferably, after communication device receives the operation data that upper layer application is sent, further include before step S2:Communication dress Acquisition bluetooth signal intensity is set, judges whether bluetooth signal intensity is more than preset value, is to then follow the steps S2;It is no to then follow the steps S4。
Preferably, in step S3, after communication device judges to be successfully received the operating result of bluetooth equipment return Further include:Communication device records currently transmitted mode as no response mode;
In step S5, when communication device judges that the after of being successfully received the operating result of bluetooth equipment return further includes: It is to have response mode that communication device, which records currently transmitted mode,;
After receiving the operation data that upper layer application is sent, further include before step S2:Communication device judges currently transmitted Mode, when currently transmitted mode to execute step S2 when no response mode;When currently transmitted mode is to have response mode, execute Step S4.
Further, after communication device receives the operation data that upper layer application is sent, communication device judges current hair It send before mode and further includes:Communication device judges whether the duration being called apart from last time data interaction interface is default more than third Value, is to then follow the steps S2, otherwise executes communication device and judges currently transmitted mode.
Embodiment 2
The present embodiment provides a kind of methods of Bluetooth communication, referring to Fig. 2, including:
Step 101, communication device receive the calling of upper layer application, when scan interface is called, execute step 102;When When connecting interface is called, step 103 is executed;When disconnect interface it is called when, execute step 104;When data interaction connects When mouth is called, step 105 is executed;
Step 102, communication device scan surrounding bluetooth equipment, and the bluetooth equipment information of the bluetooth equipment scanned are returned Back to upper layer application;Return to step 101;
Specifically, communication device calls the [_ manager of CBCentralManager objects scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"12340001-0001-00c3- 0000-465453414645"]]options:@{CBCentralManagerScanOptionAllowDuplicatesKey:@ YES }] bluetooth equipment around interface scans, the value of the first parameter NSArray* of the interface function is service identifiers;When scanning is arrived The didDiscoverPeripheral of CBCentralManager objects is triggered when surrounding bluetooth equipment: advertisementData:RSSI:Interface acquisition has scanned the bluetooth equipment information to match with service identifiers;
Step 103, communication device receive the bluetooth equipment information that the user that issues of upper layer application chooses, and with the indigo plant chosen The corresponding bluetooth equipment of tooth facility information establishes connection;Return to step 101;
Specifically, (void) connectPeripheral of communication device by calling CBCentralManager objects: (CBPeripheral*)peripheral options:(nullable NSDictionary<NSString*,id>*) Options interfaces are established with bluetooth equipment and are connected;
Step 104, communication device are disconnected with the bluetooth equipment currently connecting, return to step 101;
Specifically, communication device calls the cancelPeripheralConnection of CBCentralManager objects: (CBPeripheral*) peripheral interfaces are disconnected with the bluetooth equipment currently connecting;
Step 105, communication device receive the operation data that upper layer application is sent;
Step 106, communication device obtain current packetized data according to single packet maximum length to operation data sequence subpackage, and By no response mode current packetized data is sent to bluetooth equipment;
Specifically, communication device obtains the maximum packet length of single packet of bluetooth data communication, according to it is single wrap maximum packet it is long successively from Packetized data is obtained in operation data, and packetized data is sent to bluetooth equipment;
It should be noted that communication device calls (void) writeValue:(NSData*)data forCharacteristic:(CBCharacteristic*)characteristic type: (CBCharacteristicWriteType) type interfaces send data to be sent;Wherein data is data to be sent, type It is transmission types;
It should be noted that Type transmission types can be CBCharacteristicWriteWithResponse types, There are response mode and CBCharacteristicWriteWithoutResponse types, i.e., without response mode;Wherein when Type can trigger the peripheral of CBPeriphera methods when being CBCharacteristicWriteWithResponse: (CBPeripheral)peripheral didWriteValueForCharacteristic:(CBCharacteristic) characteristic error:(NSError*) error interfaces, when error be sky then succeed, otherwise fail;When type is The method will not be triggered when CBCharacteristicWriteWithoutResponse.
In the present embodiment, the operation data that communication device receives is: 12345678900987654321ABCDEFFEDCBA0123456789012345678901234567;The length of operation data is 30 bytes;The single packet for the bluetooth data communication that communication device is got is maximum to wrap a length of 20 byte, and communication device obtains behaviour first Make preceding 17 byte in data as current packetized data 12345678900987654321ABCDEFFEDCBA01, and by data First 0400, first packetized data 01 and current packetized data 12345678900987654321ABCDEFFEDCBA01 sequences are spelled It connects to obtain data to be sent, and data to be sent is sent to bluetooth equipment by no response mode;
Further, in the present embodiment, communication device calls (void) writeValue:(NSData*)040001 12345678900987654321ABCDEFFEDCBA01 forCharacteristic:(CBCharacteristic*) characteristic type:(CBCharacteristicWriteType) CBCharacteristicWriteWithoutResponse interfaces send data to be sent to bluetooth equipment;
It should be noted that further including before step 106:Communication device starts timing;
Further include in step 106 to step 107:When whether the value that communication device monitors current timer in real time is more than default It is long, it is to then follow the steps 110, otherwise continues;
Step 107, communication device judge in operation data whether to also have the data not sent, are then return to step 106, It otherwise waits for receiving the operating result that bluetooth equipment returns;Step 108 is executed,
It is in more detail:
When operation data length is less than or equal to single packet maximum length, step 106 is specially:Communication device will operate Data generate data to be sent as current packetized data, according to current packetized data, and are set to bluetooth by no response mode Preparation send data to be sent;
When operation data length is more than single packet maximum length, step 106 to step 107 specifically includes:
Step X1, communication device sequentially obtains the data that length is single packet maximum length from operation data and divides as current Bag data;
Step X2, communication device sends current packetized data by no response mode to bluetooth equipment;Update deviant;Sentence Whether updated deviant of breaking is equal to the length of operation data, is to then follow the steps 108, no to then follow the steps X3;
It should be noted that the initial value of deviant is 0;Communication device updates deviant specifically, communication device will work as Preceding deviant is added to obtain updated deviant with the length of current packetized data;
Step X3, communication device judges whether the length for the data not sent in operation data is more than single packet and most greatly enhances Degree is then return to step X1, otherwise using the data not sent in operation data as current packetized data, return to step X2;
Step 108, communication device judge whether to receive the operating result of bluetooth equipment return in preset time, are then Step 109 is executed, it is no to then follow the steps 110;
Step 109, communication device judge whether the operating result received is complete, is to return the operating result received Back to upper layer application;Return to step 101;It is no to then follow the steps 110;
Optionally, in the present embodiment, step 109 specifically includes:
Step 109-1, communication device obtains protocol data length from the data head of operating result, and judge to receive Whether the length of operating result matches with protocol data length, is to then follow the steps 109-2, no to then follow the steps 110;
Step 109-2, communication device obtains message check value from operating result, according to message check value verification operation knot The operating result received is returned to upper layer application, return to step 101 is no to then follow the steps 110 by fruit if being verified;
Step 110, communication device obtain current Bluetooth signal strength, and it is pre- to judge whether current Bluetooth signal strength is more than It is to then follow the steps 111 if value, it is no to then follow the steps 113;
Specifically, Bluetooth communication device, which calls (void) readRSSI of CBPeripheral objects to receive, obtains current indigo plant Tooth signal strength;This method triggers (void) peripheral:(CBPeripheral*)peripheral didReadRSSI: (NSNumber*)RSSI error:(nullable NSError*)error;When error be sky then succeed, otherwise fail;Its Middle RSSI is bluetooth signal intensity;
Step 111, communication device obtain current packetized data according to single packet maximum length to operation data sequence subpackage, and By no response mode packetized data, suspend mode preset duration are sent to bluetooth equipment;
Specifically, communication device calls (void) writeValue:(NSData*)0400 01 12345678900987654321ABCDEFFEDCBA01 forCharacteristic:(CBCharacteristic*) characteristic type:(CBCharacteristicWriteType) CBCharacteristicWriteWithoutResponse interfaces send packetized data to bluetooth equipment;
Communication device triggers (void) sleepForTimeInterval of NSThread objects:(NSTimeInterval) Time interface suspend mode preset durations;Wherein time is preset duration;
Optionally, step 111 is specially:Communication device works as operation data sequence subpackage according to single packet maximum length Preceding packetized data, and packetized data is sent to bluetooth equipment by no response mode, bluetooth signal intensity is obtained, is believed according to bluetooth Number intensity determines the first sleep time, carries out suspend mode;
It should be noted that when bluetooth signal intensity is stronger, the first sleep time determined is shorter.
Step 112, communication device judge in operation data whether to also have the data not sent, are then return to step 111, It otherwise waits for receiving the operating result that bluetooth equipment returns, executes step 116;
Step 113, communication device obtain current packetized data according to single packet maximum length to operation data sequence subpackage, and By there is response mode to send current packetized data to bluetooth equipment;
Specifically, communication device calls (void) writeValue:(NSData*)0400 01 12345678900987654321ABCDEFFEDCBA01forCharacteristic:(CBCharacteristic*) characteristic type:(CBCharacteristicWriteType) CBCharacteristicWriteWithResponse interfaces send data to be sent to bluetooth equipment;This method triggers The peripheral of CBPeriphera methods:(CBPeripheral)peripheral didWriteValueForCharacteristic:(CBCharacteristic)characteristic error: (NSError*) error interfaces;
Step 114, communication device judge whether to be successfully transmitted data, are to then follow the steps 115, otherwise by there is responder Formula retransmits current packetized data to bluetooth equipment, executes step 114;
Specifically, communication device calls (void) writeValue:(NSData*)0400 01 12345678900987654321ABCDEFFEDCBA01forCharacteristic:(CBCharacteristic*) characteristic type:(CBCharacteristicWriteType) CBCharacteristicWriteWithResponse interfaces send data to be sent to bluetooth equipment;This method triggers The peripheral of CBPeriphera methods:(CBPeripheral)peripheral didWriteValueForCharacteristic:(CBCharacteristic)characteristic error: (NSError*) error interfaces;When error be sky then succeed, otherwise fail;
Communication device triggers (void) sleepForTimeInterval of NSThread objects:(NSTimeInterval) Time interface suspend mode preset durations;
It should be noted that further including respectively before step 111 and step 113:Communication device starts timing;
Further include in the step 111 to step 112:Whether the value that communication device monitors current timer in real time is more than pre- If duration, it is to then follow the steps 118, otherwise continues;
Further include in the step 113 to step 115:Whether the value that communication device monitors current timer in real time is more than pre- If duration, it is to then follow the steps 118, otherwise continues;
Step 115, communication device judge in operation data whether to also have the data not sent, are then return to step 113, It otherwise waits for receiving the operating result that bluetooth equipment returns, executes step 116;
It is in more detail:
When operation data length is less than or equal to single packet maximum length, step 113 is specially:Communication device will operate Data send data to be sent as current packetized data, and by no response mode to bluetooth equipment;
When operation data length is more than single packet maximum length, step 113 to step 115 specifically includes:
Step R1, communication device obtains data that length is single packet maximum length as current subpackage number from operation data According to;
Step R2, communication device is by there is response mode to send current packetized data to bluetooth equipment;Judge whether to have become Work(sends packetized data, is to then follow the steps R3, otherwise continues to execute step R2;
Step R3, communication device updates deviant, judges whether updated deviant is equal to the length of operation data, is The operating result that then etc. bluetooth equipment to be received returns executes step 116, no to then follow the steps R4;
It should be noted that the initial value of deviant is 0;Communication device updates deviant specifically, communication device will work as Preceding deviant is added to obtain updated deviant with the length of current packetized data;
Step R4, communication device judges whether the length for the data not sent in operation data is more than single packet and most greatly enhances Degree is then return to step R1, otherwise using the data not sent in operation data as current packetized data, return to step R2;
Step 116, communication device judge whether to receive the operating result of bluetooth equipment return in preset time, are then Step 117 is executed, it is no to then follow the steps 118;
Step 117, communication device judge whether the operating result received is complete, is to return the operating result received Back to upper layer application;Return to step 101;It is no to then follow the steps 118;
Step 118, communication device obtain current packetized data according to single packet maximum length to operation data sequence subpackage, and By there is response mode to send current packetized data, suspend mode preset time to bluetooth equipment;
Communication device triggers (void) sleepForTimeInterval of NSThread objects:(NSTimeInterval) Time interface suspend mode preset durations;
Optionally, step 118 is specially:Communication device works as operation data sequence subpackage according to single packet maximum length Preceding packetized data, and packetized data is sent to bluetooth equipment by no response mode, bluetooth signal intensity is obtained, is believed according to bluetooth Number intensity determines the second sleep time, carries out suspend mode;
It should be noted that when bluetooth signal intensity is stronger, the second sleep time determined is shorter.
Step 119, communication device judge whether to be successfully transmitted data, are to then follow the steps 120, otherwise by there is responder Formula retransmits current packetized data, executes step 119;
It should be noted that further including before step 118:Communication device starts timing;
Further include in the step 118 to step 120:Whether the value that communication device monitors current timer in real time is more than pre- It is that then otherwise communication failure, end continue if duration;
Step 120, communication device judge in operation data whether to also have the data not sent, are then return to step 118, It otherwise waits for receiving the operating result that bluetooth equipment returns, executes step 121;
Step 121, communication device judge whether to receive the operating result of bluetooth equipment return in preset time, are then Step 122 is executed, otherwise communication failure, terminated;
Step 122, communication device judge whether the operating result received is complete, is to return the operating result received Back to upper layer application;Return to step 101;Otherwise communication failure terminates.
Preferably, in the step 121 when communication device be not received by preset time bluetooth equipment return at When work(receives data response, communication device carries out subpackage to the data not sent in operation data according to preset length and is worked as Preceding packetized data, and by there is response mode to the current packetized data of bluetooth equipment, suspend mode preset time;
It should be noted that preset length is less than single packet maximum length, further, preset length was sent less than last time Data in packetized data length;
It is in more detail,
When operation data length is less than or equal to preset length, communication device is using operation data as current subpackage number According to, and data to be sent are sent to bluetooth equipment by no response mode;
When operation data length is more than preset length,
Step V1, communication device obtained successively from operation data length be preset length data as current subpackage number According to;
Step V2, communication device is by there is response mode to send current packetized data to bluetooth equipment;Judge whether to have become Work(sends packetized data, is to then follow the steps V3, otherwise continues to execute step V2;
Step V3, communication device updates deviant, judges whether updated deviant is equal to the length of operation data, is The operating result that then etc. bluetooth equipment to be received returns executes step 121, no to then follow the steps V4;
It should be noted that the initial value of deviant is 0;Communication device updates deviant specifically, communication device will work as Preceding deviant is added to obtain updated deviant with the length of current packetized data;
Step V4, communication device judges whether the length for the data not sent in operation data is more than preset length, is Then return to step V1, otherwise using the data not sent in operation data as current packetized data, return to step V2;
Above-mentioned prioritization scheme has the beneficial effect that, communication device is by reducing the length of single transmission data, to ensure indigo plant The stability of tooth communication.
Embodiment 3
The present embodiment provides a kind of communication devices, referring to Fig. 3, including:
Receiving module 11, the calling for waiting for upper layer application receive upper layer application when data interaction interface is called The operation data of transmission;
Sending module 12 is set for the operation data that receiving module 11 receives to be sent to bluetooth by no response mode It is standby;
First judgment module 13, the operation for being received receiving module 11 by no response mode when sending module 12 Data are sent to after bluetooth equipment, judge whether successfully receiving the operating result of bluetooth equipment return;
Sending module 12 is additionally operable to be successfully received the operating result of bluetooth equipment return when the judgement of the first judgment module 13 When, the operating result received is returned into upper layer application;It is additionally operable to be not successfully receiving when the judgement of the first judgment module 13 When the operating result that bluetooth equipment returns, by there is response mode that operation data is sent to bluetooth equipment;
Second judgment module 14, for working as sending module 12 by there is response mode that operating result is sent to bluetooth equipment Later, judge whether to be successfully transmitted operation data;
Third judgment module 15, for after the judgement of the second judgment module 14 is successfully transmitted operation data, judging whether It is successfully received the operating result of bluetooth equipment return;
Sending module 12 is additionally operable to judge the operating result for being successfully received bluetooth equipment return when third judgment module 15 When, the operating result received is returned into upper layer application.
Optionally, the first judgment module 13 is specifically used for receiving module 11 when sending module 12 through no response mode The operation data received is sent to after bluetooth equipment, and the first preset duration of suspend mode judges whether successfully receiving bluetooth and sets The standby operating result returned.
Optionally, the first judgment module 13 is specifically used for receiving module 11 when sending module 12 through no response mode The operation data received is sent to after bluetooth equipment, obtains bluetooth signal intensity, first is determined according to bluetooth signal intensity Sleep time carries out suspend mode, judges whether successfully receiving the operating result of bluetooth equipment return.
It should be noted that when bluetooth signal intensity is stronger, the first sleep time determined is shorter.
Preferably, the 4th judgment module, for being returned when the judgement of the first judgment module 13 is not successfully receiving bluetooth equipment After the operating result returned, whether update judges without response transmission times without response transmission times more than the first preset value;
Sending module 12 is specifically used for when the judgement of the 4th judgment module is more than the first preset value without response transmission times, By there is response mode that operation data is sent to bluetooth equipment;It is additionally operable to when the judgement of the 4th judgment module is without response transmission times When being not above the first preset value, operation data is sent to by bluetooth equipment by no response mode.
Further, the first judgment module 13 will receive mould specifically for working as sending module 12 by no response mode The operation data that block 11 receives is sent to after bluetooth equipment, and the second sleep time is determined according to without response transmission times, into Row suspend mode judges whether successfully receiving the operating result of bluetooth equipment return.
It should be noted that more without response transmission times, the second sleep time is longer;
Optionally, third judgment module 15, specifically for when the second judgment module 14 judgement be successfully transmitted operation data it Afterwards, the second preset duration of suspend mode judges whether successfully receiving the operating result of bluetooth equipment return.
Optionally, third judgment module 15, specifically for when the second judgment module 14 judgement be successfully transmitted operation data it Afterwards, bluetooth signal intensity is obtained, third sleep time is determined according to bluetooth signal intensity, suspend mode is carried out, judges whether successfully to connect Receive the operating result of bluetooth equipment return.
It should be noted that when bluetooth signal intensity is stronger, determining third sleep time is shorter.
Preferably, communication device further includes:
5th judgment module, for after the judgement of the second judgment module 14 is not successfully transmitted operation data, update to have Transmission times is responded, and judges have response transmission times whether more than the second preset value;It is additionally operable to sentence when third judgment module 15 Surely it is not successfully receiving after the operating result of bluetooth equipment return, update has response transmission times, and judges have response to send out Send number whether more than the second preset value;
Sending module 12 is additionally operable to be not above the second preset value when the 5th judgment module is determined with response transmission times When, by there is response mode that operation data is sent to bluetooth equipment.
Further, third judgment module 15, specifically for being successfully transmitted operand when the judgement of the second judgment module 14 According to later, according to there is response transmission times to determine the 4th sleep time, suspend mode is carried out, bluetooth equipment is judged whether successfully receiving The operating result of return.
It should be noted that more without response transmission times, the 4th sleep time is longer;
Preferably, communication device further includes:
6th judgment module, the operation for being not successfully receiving bluetooth equipment return when the judgement of the first judgment module 13 When as a result, judge whether bluetooth signal intensity is more than third preset value;
7th judgment module is used for when the 6th judgment module judgement Bluetooth information intensity is more than third preset value, more Newly without response transmission times, judge whether be more than the 4th preset value without response transmission times;
Sending module 12 is specifically used for when the judgement of the 7th judgment module is more than four preset values without response transmission times, By there is response mode that operation data is sent to bluetooth equipment;It is additionally operable to judge bluetooth signal intensity not when the 6th judgment module When more than third preset value, by there is response mode that operation data is sent to bluetooth equipment, it is additionally operable to when the 7th judgment module When judgement is not more than four preset values without response transmission times, operation data is sent to by bluetooth equipment by no response mode.
Specifically, sending module 12 specifically includes:
First packetized units, the operation data sequence subpackage for being received to receiving module 11 according to single packet maximum length Current packetized data is obtained, current packetized data is sent to by bluetooth equipment by no response mode;
First judging unit is additionally operable to judge in operation data whether also have the data not sent;
First packetized units are additionally operable to when the judgement of the first judging unit also has the data not sent, most according to single packet Long length obtains current packetized data to the operation data sequence subpackage that receiving module 11 receives, and will be worked as by no response mode Preceding packetized data is sent to bluetooth equipment;
First judgment module 13, for when there is no the data not sent in the first judging unit decision data, Judge whether successfully receiving the operating result of bluetooth equipment return.
Preferably, sending module 12 further includes:Second packetized units, for not succeeding when the judgement of the first judgment module 13 When receiving the operating result of bluetooth equipment return, the data order subpackage according to preset length to not sent in operation data Current packetized data is obtained, by there is response mode that current packetized data is sent to bluetooth equipment;
Second judgment unit, for when the second packetized units are by there is response that current packetized data was sent to bluetooth at that time After equipment, judge whether the data not sent also;
Second packetized units are additionally operable to when second judgment unit judgement also has the data not sent, according to default length Degree obtains current packetized data to the data order subpackage not sent in operation data, by there is response mode by current subpackage Data are sent to bluetooth equipment;
First judgment module 13 is additionally operable to do not have the data not sent in second judgment unit decision data When, judge whether successfully receiving the operating result of bluetooth equipment return;
Preset length is less than the data length sent communication equipment last time.
Specifically, sending module 12 specifically includes:
Third packetized units, for returning to operation knot when the judgement of the first judgment module 13 is not successfully receiving bluetooth equipment When fruit, current packetized data is obtained to operation data sequence subpackage according to single packet maximum length, by there is response mode will be current Packetized data is sent to bluetooth equipment;
Second judgment module 14, specifically for work as third packetized units by current packetized data be sent to bluetooth equipment it Afterwards, judge whether to be successfully transmitted data;
Third judging unit, for judging operation data after the judgement of the second judgment module 14 is successfully transmitted operation data In whether also have the data that are not sent;
Third packetized units are additionally operable to when there is the data not sent in third judging unit decision data, Current packetized data is obtained to operation data sequence subpackage according to single packet maximum length, by there is response mode by current subpackage number According to being sent to bluetooth equipment.
Preferably, sending module 12 further includes:4th packetized units, for not succeeding when the judgement of the second judgment module 14 When transmission data, current packetized data is obtained to the data order subpackage not sent in operation data according to preset length, is led to It has crossed response mode and current packetized data is sent to bluetooth equipment;
Second judgment module 14, specifically for when the 4th packetized units are by there is response at that time to send current packetized data After bluetooth equipment, judge whether to be successfully transmitted data;
4th judging unit, for after the judgement of the second judgment module 14 is successfully transmitted data, judging in operation data Whether the data not sent are also had;
4th packetized units are additionally operable to when there is the data not sent in the 4th judging unit decision data, Current packetized data is obtained to the data order subpackage not sent in operation data according to preset length, by there is response mode Current packetized data is sent to bluetooth equipment;
Preset length is less than the data length sent communication equipment last time;
Third judgment module 15, for also have in the 4th judging unit decision data data not sent it Afterwards, the operating result of bluetooth equipment return is judged whether successfully receiving.
Specifically, the first judgment module 13 specifically includes:
5th judging unit, for passing through without the response operand that at that time received receiving module 11 when sending module 12 After being sent to bluetooth equipment, judge whether the operating result for receiving bluetooth equipment return;
6th judging unit, for when the judgement of the 5th judging unit receives the operating result that bluetooth equipment returns, sentencing Whether the operating result that disconnecting receives is complete;
Sending module 12 is specifically used for when the 6th judging unit decision result is complete, the operation knot that will be received Fruit returns to upper layer application;Specifically for being not received by the operating result of bluetooth equipment return when the judgement of the 5th judging unit When, by there is response mode that operation data is sent to bluetooth equipment;Specifically for when the 6th judging unit decision result When imperfect, crossing has response mode that operation data is sent to bluetooth equipment.
Third judgment module 15 specifically includes:
7th judging unit, for after the judgement of the second judgment module 14 is successfully transmitted operation data, judging whether to connect Receive the operating result of bluetooth equipment return;
8th judging unit, for when the judgement of the 7th judging unit receives bluetooth equipment and returns to operating result, judging Whether the operating result received is complete;
Sending module 12 is specifically used for when the 8th judging unit decision result is complete, the operation knot that will be received Fruit returns to upper layer application.
In more detail, the 8th judging unit specifically includes:
First judgment sub-unit judges to operate for obtaining protocol data length and message check value from operating result Whether length as a result matches with the length of protocol data;
Second judgment sub-unit, the length for length and protocol data when the first judgment sub-unit decision result When matching, according to message check value verification operation result;
Sending module 12, specifically for when the second judgment sub-unit is verified, the operating result received is returned To upper layer application;
Preferably, communication device further includes:
8th judgment module, for when receiving module 11 receives the operation data that upper layer application is sent, obtaining bluetooth Signal strength, judges whether bluetooth signal intensity is more than preset value;
Sending module 12 is specifically used for, when the 8th judgment module judgement bluetooth signal intensity is more than preset value, passing through nothing The operation data that receiving module 11 receives is sent to bluetooth equipment by response mode;It is additionally operable to when the judgement of the 8th judgment module is blue When tooth signal is not more than preset value, by there is response mode that operation data is sent to bluetooth equipment.
Preferably, communication device further includes:
Logging modle, for when the first judgment module 13 judgement be successfully received bluetooth equipment return operating result when, Currently transmitted pattern is recorded as no response mode;It is additionally operable to be successfully received bluetooth equipment return when the judgement of third judgment module 15 Operating result when, record currently transmitted pattern be have response mode;
Sending module 12, specifically for when receiving module 11 receives the operation data that upper layer application is sent, judging to work as Preceding sending mode, when currently transmitted pattern for no response mode when, operation data is sent to by bluetooth by no response mode and is set It is standby, when currently transmitted pattern is to have response mode, by there is response mode that operation data is sent to bluetooth equipment.
Further, communication device further includes:
9th judgment module, for when receiving module 11 receive upper layer application transmission operation data when, communication device Judge whether the duration being called apart from last time data interaction interface is more than third preset value;
It is super to be specifically used for the duration that the judgement of the 9th judgment module is called apart from last time data interaction interface for sending module 12 When crossing third preset value, operation data is sent to by bluetooth equipment by no response mode, is additionally operable to sentence when the 9th judgment module When the called duration of set a distance last time data interaction reception is not above third preset value, currently transmitted pattern is judged;When working as Preceding sending mode for no response mode when, operation data is sent to by bluetooth equipment by no response mode, when currently transmitted mould Formula is when having response mode, by there is response mode that operation data is sent to bluetooth equipment.
The foregoing is only a preferred embodiment of the present invention, but scope of protection of the present invention is not limited thereto, Any one 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 the claims Subject to.

Claims (38)

1. a kind of method of Bluetooth communication, which is characterized in that including:
Step S1, communication device waits for the calling of upper layer application, and upper layer application is received when data interaction interface is called and is sent Operation data, execute step S2;
The operation data is sent to bluetooth equipment by step S2, the described communication device by no response mode;
Step S3, the described communication device judges whether successfully receiving the operating result that the bluetooth equipment returns, and is that will connect The operating result received returns to upper layer application, terminates;It is no to then follow the steps S4;
Step S4, the described communication device is judged whether by there is response mode that the operation data is sent to bluetooth equipment Work(sends the operation data, is to then follow the steps S5;Otherwise communication failure terminates;
Step S5, the described communication device judges whether successfully receiving the operating result of bluetooth equipment return, is that will receive The operating result return to upper layer application, terminate;Otherwise communication failure terminates.
2. the method as described in claim 1, which is characterized in that after the step S2, further include before the step S3:Institute State the first preset duration of communication device suspend mode.
3. the method as described in claim 1, which is characterized in that after the step S2, further include before the step S3:Institute It states communication device and obtains bluetooth signal intensity, the first sleep time is determined according to the bluetooth signal intensity, carries out suspend mode.
4. the method as described in claim 1, which is characterized in that in the step S3, the communication device judgement does not succeed After receiving the operating result that the bluetooth equipment returns, further include before executing step S4:The communication device updates nothing Transmission times is responded, and judges without response transmission times, whether more than the first preset value, to be to then follow the steps S4, otherwise return to step Rapid S2.
5. method as claimed in claim 4, which is characterized in that after the step S2, further include before the step S3:Institute It states communication device and determines the second sleep time according to without response transmission times, carry out suspend mode.
6. the method as described in claim 1, which is characterized in that communication device judgement be successfully transmitted the operation data it Afterwards, further include before the step S5:Second preset duration of communication device suspend mode.
7. the method as described in claim 1, which is characterized in that communication device judgement be successfully transmitted the operation data it Afterwards, further include before the step S5:The communication device obtains bluetooth signal intensity, is determined according to the bluetooth signal intensity Third sleep time carries out suspend mode.
8. the method as described in claim 1, which is characterized in that
In the step S4, the communication device judgement is not successfully transmitted after the operation data, further includes:The communication Device update has a response transmission times, and judges have response transmission times whether more than the second preset value, is then communication failure, ties Beam, otherwise return to step S4;
In the step S5, the communication device judgement is not successfully receiving after the operating result of bluetooth equipment return, also Including:The communication device update has response transmission times, and judges have response transmission times whether more than the second preset value, is Then communication failure terminates, otherwise return to step S4.
9. method as claimed in claim 8, which is characterized in that communication device judgement be successfully transmitted the operation data it Afterwards, further include before the step S5:The communication device is stopped according to there is response transmission times to determine the 4th sleep time It sleeps.
10. the method as described in claim 1, which is characterized in that in the step S3, the communication device judgement does not succeed After receiving the operating result that the bluetooth equipment returns, further include before executing step S4:
Step A1, the described communication device obtains bluetooth signal intensity, judges whether the bluetooth signal intensity is default more than third Value, is to then follow the steps A2;It is no to then follow the steps S4;
Step A2, communication device update is without response transmission times, judge it is described without response transmission times whether more than the 4th Preset value is to then follow the steps S4, otherwise return to step S2.
11. the method as described in claim 1, which is characterized in that the step S2 is specifically included:
Step B1, the described communication device obtains current packetized data according to single packet maximum length to operation data sequence subpackage, leads to It crosses no response mode and the current packetized data is sent to the bluetooth equipment;
Step B2, the described communication device judges in the operation data whether to also have the data not sent, is then return to step B1, it is no to then follow the steps S3.
12. method as claimed in claim 11, which is characterized in that in the step S3, communication device judgement not at After work(receives the operating result that the bluetooth equipment returns, before the step S4, further include:
Step C1, the described communication device obtains the data order subpackage not sent in the operation data according to preset length Current packetized data, by there is response mode that the current packetized data is sent to the bluetooth equipment;
Step C2, the described communication device judges in the operation data whether to also have the data not sent, is then return to step C1, it is no to then follow the steps S3;
The preset length is less than the data length sent the communication equipment last time.
13. the method as described in claim 1, which is characterized in that the step S4 is specifically included:
Step D1, the described communication device obtains current subpackage number according to single packet maximum length to the operation data sequence subpackage According to by there is response mode that the current packetized data is sent to the bluetooth equipment;
Step D2, the described communication device judges whether the transmission data that succeeded, and is to then follow the steps D3, otherwise communication failure, knot Beam;
Step D3, the described communication device judges in the operation data whether to also have the data not sent, is then return to step D1, it is no to then follow the steps S5.
14. method as claimed in claim 13, which is characterized in that in the step D2, communication device judgement not at When work(transmission data, further include:
Step E1, the described communication device obtains the data order subpackage not sent in the operation data according to preset length Current packetized data, by there is response mode that the current packetized data is sent to the bluetooth equipment;
Step E2, the described communication device judges whether the transmission data that succeeded, and is to then follow the steps E3, otherwise communication failure, knot Beam;
Step E3, the described communication device judges in the operation data whether to also have the data not sent, is then return to step E1, it is no to then follow the steps S5;
The preset length is less than the data length sent the communication equipment last time.
15. the method as described in claim 1, which is characterized in that the communication device judges whether successfully receiving the indigo plant The operating result that tooth equipment returns specifically includes:
Step F1, the described communication device judges whether to receive the operating result that the bluetooth equipment returns, and is to then follow the steps F2, otherwise judgement are not successfully receiving the operating result that the bluetooth equipment returns;
Step F2, the described communication device judges whether the operating result received is complete, is, judgement is successfully received institute The operating result of bluetooth equipment return is stated, otherwise judgement is not successfully receiving the operating result that the bluetooth equipment returns.
16. method as claimed in claim 15, which is characterized in that the step F2 is specifically included:
Step F2-1, the described communication device obtains protocol data length and message check value from the operating result, judges institute Whether the length for stating operating result matches with the length of the protocol data, is to then follow the steps E2-2;Otherwise judge the behaviour It is imperfect to make result;
Step F2-2, the described communication device verifies the operating result according to the message check value, judges if being verified Operating result is complete, and otherwise decision result is imperfect.
17. the method as described in claim 1, which is characterized in that after the operation data for receiving upper layer application transmission, institute Further include before stating step S2:The communication device obtains bluetooth signal intensity, judges whether the bluetooth signal intensity is more than Preset value is to then follow the steps S2;It is no to then follow the steps S4.
18. the method as described in claim 1, which is characterized in that
In the step S3, after the communication device judges to be successfully received the operating result of the bluetooth equipment return Further include:The communication device records currently transmitted mode as no response mode;
In the step S5, after the communication device judges to be successfully received the operating result of the bluetooth equipment return Further include:It is to have response mode that the communication device, which records currently transmitted mode,;
After the operation data for receiving upper layer application transmission, further include before the step S2:The communication device judges Currently transmitted mode, when currently transmitted mode to execute step S2 when no response mode;When currently transmitted mode is to have responder When formula, step S4 is executed.
19. method as claimed in claim 18, which is characterized in that after the operation data for receiving upper layer application transmission, The communication device judges:The communication device judges apart from last time data interaction interface quilt The duration of calling whether be more than third preset value, be to then follow the steps S2, otherwise execute the communication device judge it is currently transmitted Mode.
20. a kind of communication device, which is characterized in that including:
Receiving module, the calling for waiting for upper layer application receive what upper layer application was sent when data interaction interface is called Operation data;
Sending module is set for the operation data that the receiving module receives to be sent to bluetooth by no response mode It is standby;
First judgment module, the behaviour for being received the receiving module by no response mode when the sending module After data are sent to bluetooth equipment, the operating result that the bluetooth equipment returns is judged whether successfully receiving;
The sending module is additionally operable to be successfully received the operation that the bluetooth equipment returns when first judgment module judgement When as a result, the operating result received is returned into upper layer application;It is additionally operable to not have when first judgment module judgement When being successfully received the operating result that the bluetooth equipment returns, by there is response mode that the operation data is sent to bluetooth Equipment;
Second judgment module, for working as the sending module by there is response mode that the operating result is sent to bluetooth equipment Later, judge whether to be successfully transmitted the operation data;
Third judgment module judges after being successfully transmitted the operation data for working as second judgment module, judges whether It is successfully received the operating result of bluetooth equipment return;
The sending module is additionally operable to be successfully received the operating result of bluetooth equipment return when third judgment module judgement When, the operating result received is returned into upper layer application.
21. communication device as claimed in claim 20, which is characterized in that first judgment module is specifically used for when described After the operation data that the receiving module receives is sent to bluetooth equipment by sending module by no response mode, not It sleeps the first preset duration, judges whether successfully receiving the operating result that the bluetooth equipment returns.
22. communication device as claimed in claim 20, which is characterized in that first judgment module is specifically used for when described After the operation data that the receiving module receives is sent to bluetooth equipment by sending module by no response mode, obtain Bluetooth signal intensity is taken, the first sleep time is determined according to the bluetooth signal intensity, suspend mode is carried out, judges whether to be properly received The operating result returned to the bluetooth equipment.
23. communication device as claimed in claim 20, which is characterized in that further include:
4th judgment module, for being not successfully receiving the behaviour that the bluetooth equipment returns when first judgment module judgement After making result, whether update judges without response transmission times without response transmission times more than the first preset value;
The sending module is specifically used for when the 4th judgment module judgement being more than the first preset value without response transmission times When, by there is response mode that the operation data is sent to bluetooth equipment;It is additionally operable to judge nothing when the 4th judgment module When response transmission times is not above the first preset value, the operation data is sent to by bluetooth equipment by no response mode.
24. communication device as claimed in claim 23, which is characterized in that first judgment module is specifically used for when described After the operation data that the receiving module receives is sent to bluetooth equipment by sending module by no response mode, root The second sleep time is determined according to without response transmission times, carries out suspend mode, is judged whether successfully receiving the bluetooth equipment and is returned Operating result.
25. communication device as claimed in claim 20, which is characterized in that the third judgment module is specifically used for when described The judgement of second judgment module is successfully transmitted after the operation data, and the second preset duration of suspend mode judges whether successfully receiving The operating result that bluetooth equipment returns.
26. communication device as claimed in claim 20, which is characterized in that the third judgment module is specifically used for when described The judgement of second judgment module is successfully transmitted after the operation data, obtains bluetooth signal intensity, strong according to the Bluetooth signal Degree determines third sleep time, carries out suspend mode, judges whether successfully receiving the operating result of bluetooth equipment return.
27. communication device as claimed in claim 20, which is characterized in that further include:
5th judgment module judges for working as second judgment module after not being successfully transmitted the operation data, update There is response transmission times, and judges have response transmission times whether more than the second preset value;It is additionally operable to judge mould when the third Block judgement is not successfully receiving after the operating result of bluetooth equipment return, and update has response transmission times, and judges there is sound Answer transmission times whether more than the second preset value;
The sending module is additionally operable to be not above the second preset value when the 5th judgment module is determined with response transmission times When, by there is response mode that the operation data is sent to bluetooth equipment.
28. communication device as claimed in claim 27, which is characterized in that the third judgment module is specifically used for when described Second judgment module judgement be successfully transmitted after the operation data, according to have response transmission times determine the 4th sleep time, Suspend mode is carried out, the operating result of bluetooth equipment return is judged whether successfully receiving.
29. communication device as claimed in claim 20, which is characterized in that further include:6th judgment module, for when described the When the judgement of one judgment module is not successfully receiving the operating result of bluetooth equipment return, whether the bluetooth signal intensity is judged More than third preset value;
7th judgment module, for judging that the Bluetooth information intensity is more than third preset value when the 6th judgment module When, update without response transmission times, judge it is described without response transmission times whether more than the 4th preset value;
The sending module is specifically used for when the 7th judgment module judgement is described default more than the 4th without response transmission times When value, by there is response mode that the operation data is sent to bluetooth equipment;It is additionally operable to judge when the 6th judgment module When the bluetooth signal intensity is not more than third preset value, by there is response mode that the operation data is sent to the bluetooth Equipment, be additionally operable to when the 7th judgment module judgement it is described without response transmission times be not more than four preset values when, pass through nothing The operation data is sent to bluetooth equipment by response mode.
30. communication device as claimed in claim 20, which is characterized in that the sending module specifically includes:
First packetized units, the operation data sequence point for being received to the receiving module according to single packet maximum length Packet obtains current packetized data, and the current packetized data is sent to the bluetooth equipment by no response mode;
First judging unit is additionally operable to judge in the operation data whether also have the data not sent;
First packetized units are additionally operable to when first judging unit judgement also has the data not sent, according to list Packet maximum length obtains current packetized data to the operation data sequence subpackage that the receiving module receives, and passes through no sound Answer mode that the current packetized data is sent to the bluetooth equipment;
First judgment module judges not sent in the operation data specifically for working as first judging unit Data when, judge whether successfully receiving the operating result that the bluetooth equipment returns.
31. communication device as claimed in claim 30, which is characterized in that the sending module further includes:Second packetized units, For when first judgment module judgement is not successfully receiving the operating result that the bluetooth equipment returns, according to default Length obtains current packetized data to the data order subpackage not sent in the operation data, by there is response mode by institute It states current packetized data and is sent to the bluetooth equipment;
Second judgment unit, for working as second packetized units by there is response to be at that time sent to the current packetized data After bluetooth equipment, judge whether the data not sent also;
Second packetized units are additionally operable to when second judgment unit judgement also has the data not sent, according to pre- If length obtains current packetized data to the data order subpackage not sent in the operation data, by there is response mode will The current packetized data is sent to the bluetooth equipment;
First judgment module is additionally operable to when the second judgment unit judges the data not sent, and judgement is The no operating result for being successfully received the bluetooth equipment and returning;
The preset length is less than the data length sent the communication equipment last time.
32. communication device as claimed in claim 20, which is characterized in that the sending module specifically includes:
Third packetized units are not successfully receiving the bluetooth equipment return operation for working as the first judgment module judgement When as a result, current packetized data is obtained to the operation data sequence subpackage according to single packet maximum length, by there is response mode The current packetized data is sent to the bluetooth equipment;
The current packetized data is sent to the indigo plant by second judgment module specifically for working as the third packetized units After tooth equipment, judge whether to be successfully transmitted data;
Third judging unit judges that be successfully transmitted the operation data judges the behaviour later for working as second judgment module Make whether also have the data not sent in data;
The third packetized units are additionally operable to not sent when the third judging unit judges to also have in the operation data When data, current packetized data is obtained to the operation data sequence subpackage according to single packet maximum length, by there is response mode The current packetized data is sent to the bluetooth equipment.
33. communication device as claimed in claim 32, which is characterized in that the sending module further includes:4th packetized units, For when second judgment module judgement be not successfully transmitted data when, according to preset length in the operation data not by The data order subpackage of transmission obtains current packetized data, described by there is response mode to be sent to the current packetized data Bluetooth equipment;
Second judgment module, specifically for working as the 4th packetized units by there is response at that time by the current subpackage number After being sent to bluetooth equipment, judge whether to be successfully transmitted data;
4th judging unit judges after being successfully transmitted data for working as second judgment module, judges the operation data In whether also have the data that are not sent;
4th packetized units are additionally operable to not sent when the 4th judging unit judges to also have in the operation data When data, current packetized data is obtained to the data order subpackage not sent in the operation data according to preset length, is led to It has crossed response mode and the current packetized data is sent to the bluetooth equipment;
The preset length is less than the data length sent the communication equipment last time;
The third judgment module judges not sent also in the operation data specifically for working as the 4th judging unit Data after, judge whether successfully receiving bluetooth equipment return operating result.
34. communication device as claimed in claim 20, which is characterized in that
First judgment module specifically includes:
5th judging unit, for passing through without the response behaviour that at that time received the receiving module when the sending module After data are sent to bluetooth equipment, judge whether to receive the operating result that the bluetooth equipment returns;
6th judging unit, for receiving the operating result that the bluetooth equipment returns when the 5th judging unit judgement When, judge whether the operating result received is complete;
The sending module is specifically used for when the 6th judging unit judges that the operating result is complete, by what is received The operating result returns to upper layer application;Judge that being not received by bluetooth equipment returns specifically for working as the 5th judging unit When the operating result returned, by there is response mode that the operation data is sent to bluetooth equipment;Specifically for working as the described 6th When judging unit judges that the operating result is imperfect, crossing has response mode that the operation data is sent to bluetooth equipment;
The third judgment module specifically includes:
7th judging unit judges after being successfully transmitted the operation data for working as second judgment module, judges whether Receive the operating result that the bluetooth equipment returns;
8th judging unit, for when the 7th judging unit judgement receives the bluetooth equipment and returns to operating result, Judge whether the operating result received is complete;
The sending module is specifically used for when the 8th judging unit judges that the operating result is complete, by what is received The operating result returns to upper layer application.
35. communication device as claimed in claim 34, which is characterized in that the 8th judging unit specifically includes:
First judgment sub-unit, for obtaining protocol data length and message check value from the operating result, described in judgement Whether the length of operating result matches with the length of the protocol data;
Second judgment sub-unit, the length for judging the operating result when first judgment sub-unit and the agreement number According to length matching when, the operating result is verified according to the message check value;
The sending module, specifically for the operation knot that when second judgment sub-unit is verified, will be received Fruit returns to upper layer application.
36. communication device as claimed in claim 20, which is characterized in that further include:8th judgment module, for being connect when described When receipts module receives the operation data of upper layer application transmission, bluetooth signal intensity is obtained, judges that the bluetooth signal intensity is It is no to be more than preset value;
The sending module is specifically used for when the 8th judgment module judges that the bluetooth signal intensity is more than preset value, The operation data that the receiving module receives is sent to bluetooth equipment by no response mode;It is additionally operable to when described the When eight judgment modules judge that the Bluetooth signal is not more than preset value, by there is response mode that the operation data is sent to indigo plant Tooth equipment.
37. communication device as claimed in claim 20, which is characterized in that further include:Logging modle is sentenced for working as described first When disconnected module judgement is successfully received the operating result that the bluetooth equipment returns, currently transmitted pattern is recorded as no responder Formula;It is additionally operable to, when third judgment module judgement is successfully received the operating result of bluetooth equipment return, record current hair It is to have response mode to send pattern;
The sending module, specifically for when the receiving module receives the operation data that upper layer application is sent, judging to work as Preceding sending mode, when currently transmitted pattern for no response mode when, the operation data is sent to by indigo plant by no response mode Tooth equipment is set when currently transmitted pattern is to have response mode by there is response mode that the operation data is sent to bluetooth It is standby.
38. communication device as claimed in claim 37, which is characterized in that further include:
9th judgment module, for when the receiving module receives the operation data that upper layer application is sent, the communication to fill It sets and judges whether the duration being called apart from last time data interaction interface is more than third preset value;
The sending module is specifically used for the duration that the 9th judgment module judgement is called apart from last time data interaction interface When more than third preset value, the operation data is sent to by bluetooth equipment by no response mode, is additionally operable to work as the described 9th When judgment module judgement is not above third preset value apart from the called duration of last time data interaction reception, judge currently transmitted Pattern;When currently transmitted pattern for no response mode when, the operation data is sent to by bluetooth equipment by no response mode, When currently transmitted pattern is to have response mode, by there is response mode that the operation data is sent to bluetooth equipment.
CN201810220916.6A 2018-03-16 2018-03-16 Bluetooth communication method and communication device Active CN108540966B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810220916.6A CN108540966B (en) 2018-03-16 2018-03-16 Bluetooth communication method and communication device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810220916.6A CN108540966B (en) 2018-03-16 2018-03-16 Bluetooth communication method and communication device

Publications (2)

Publication Number Publication Date
CN108540966A true CN108540966A (en) 2018-09-14
CN108540966B CN108540966B (en) 2021-04-06

Family

ID=63484648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810220916.6A Active CN108540966B (en) 2018-03-16 2018-03-16 Bluetooth communication method and communication device

Country Status (1)

Country Link
CN (1) CN108540966B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111542040A (en) * 2020-07-07 2020-08-14 飞天诚信科技股份有限公司 Method and device for enhancing Bluetooth connection stability

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1305286A (en) * 1999-11-26 2001-07-25 三星电子株式会社 Method of operation personal temporary network between blue tooth equipment
CN201138798Y (en) * 2007-07-05 2008-10-22 王明俊 Theft preventing apparatus for Bluetooth or ZIGBEE
CN104135741A (en) * 2014-07-08 2014-11-05 福建联迪商用设备有限公司 Method of Bluetooth low energy communication, Bluetooth devices and system
CN104469658A (en) * 2014-11-10 2015-03-25 福建联迪商用设备有限公司 Method and device for improving compatibility between POS machine and mobile terminal Bluetooth part
CN105188023A (en) * 2015-10-15 2015-12-23 飞天诚信科技股份有限公司 Bluetooth communication method and communication device
CN106408871A (en) * 2016-09-30 2017-02-15 福建工程学院 Accidental fall monitoring method and system
WO2017214490A1 (en) * 2016-06-10 2017-12-14 The Regents Of The University Of California Wearable emotional feedback apparatus for autism spectrum disorder

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1305286A (en) * 1999-11-26 2001-07-25 三星电子株式会社 Method of operation personal temporary network between blue tooth equipment
CN201138798Y (en) * 2007-07-05 2008-10-22 王明俊 Theft preventing apparatus for Bluetooth or ZIGBEE
CN104135741A (en) * 2014-07-08 2014-11-05 福建联迪商用设备有限公司 Method of Bluetooth low energy communication, Bluetooth devices and system
CN104469658A (en) * 2014-11-10 2015-03-25 福建联迪商用设备有限公司 Method and device for improving compatibility between POS machine and mobile terminal Bluetooth part
CN105188023A (en) * 2015-10-15 2015-12-23 飞天诚信科技股份有限公司 Bluetooth communication method and communication device
WO2017214490A1 (en) * 2016-06-10 2017-12-14 The Regents Of The University Of California Wearable emotional feedback apparatus for autism spectrum disorder
CN106408871A (en) * 2016-09-30 2017-02-15 福建工程学院 Accidental fall monitoring method and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ZMICIER ZALEZNICENKA: "CoreBluetooth CBCharacteristicWriteWithoutResponse: Do requests return instantly or after write?", 《STACKOVERFLOW》 *
帅帅无可复制: "iOS 蓝牙4.0 开发体会", 《CSDN》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111542040A (en) * 2020-07-07 2020-08-14 飞天诚信科技股份有限公司 Method and device for enhancing Bluetooth connection stability

Also Published As

Publication number Publication date
CN108540966B (en) 2021-04-06

Similar Documents

Publication Publication Date Title
CN105245531B (en) One kind goes offline detection method, device and server
CN106454713B (en) A kind of method and device that mobile device is synchronous with bluetooth equipment pairing
CN108234084A (en) A kind of receiving/transmission method of data, device and equipment
JPH10502227A (en) Packet data protocol for wireless communication
CN105491686B (en) Data transmission method, network element device and communication system
CN102255898A (en) Method for ensuring stability of large data stream by tcp (Transmission Control Protocol)/udp (User Datagram Protocol) double-mode communication
CN107360027A (en) The distribution method, apparatus and intelligent appliance of a kind of intelligent appliance
CN105183687B (en) A kind of timesharing serial port communication method and system
CN106681774A (en) Software upgrading method of Bluetooth loudspeaker and intelligent terminal
CN107396297A (en) Intelligent networking system and its method of controlling security based on bluetooth
WO2016008077A1 (en) Method and apparatus for interconnecting intelligent terminal and vehicle terminal
CN109714757A (en) A kind of shared method and device for preparing eSIM card
CN108540966A (en) A kind of method and communication device of Bluetooth communication
CN108696846A (en) A kind of method that Star Network is accessed from equipment and device
CN106301488B (en) A kind of Bluetooth adapter and its working method
JPS63262935A (en) Communication equipment
CN110162340A (en) ID configuration method, series circuit and the relevant device of series circuit
US6996167B2 (en) Modem identification and diagnostics
CN105553762A (en) Communication method and communication system between domestic appliance and mobile terminal and corresponding devices
CN108234494A (en) A kind of interaction live broadcasting method and system
WO2006058490A1 (en) A method for negotiating the bandwidth of data communication channel automatically
CN107872379A (en) A kind of terminal control method and device based on RCS message
CN108260147A (en) A kind of configuration method of the network configuration parameters of mesh network nodes
CN106791243A (en) A kind of function setting method and device based on Bluetooth protocol
CN108848015A (en) Connect method, apparatus, smart machine and the user terminal of network

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