CN107889089B - Mobile terminal and method for processing Bluetooth data - Google Patents

Mobile terminal and method for processing Bluetooth data Download PDF

Info

Publication number
CN107889089B
CN107889089B CN201711099974.XA CN201711099974A CN107889089B CN 107889089 B CN107889089 B CN 107889089B CN 201711099974 A CN201711099974 A CN 201711099974A CN 107889089 B CN107889089 B CN 107889089B
Authority
CN
China
Prior art keywords
uplink
data
submodule
response
downlink
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711099974.XA
Other languages
Chinese (zh)
Other versions
CN107889089A (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 CN201711099974.XA priority Critical patent/CN107889089B/en
Publication of CN107889089A publication Critical patent/CN107889089A/en
Application granted granted Critical
Publication of CN107889089B publication Critical patent/CN107889089B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The invention discloses a mobile terminal and a method for processing Bluetooth data thereof, wherein the method comprises the following steps: the data processing module acquires legal uplink data from the Bluetooth data in the receiving buffer area; judging the type of uplink data, if the type of the uplink data is uplink response, putting the uplink response or the uplink response effective data into an uplink response buffer area, and removing the uplink response in the receiving buffer area; if the command is an uplink command, obtaining an uplink command result according to the uplink command, sending the uplink command result to the application module, and removing the uplink command in the receiving buffer. The invention can actively send the downlink instruction to the Bluetooth equipment and receive the uplink response from the Bluetooth equipment when the mobile terminal communicates with the same Bluetooth equipment, and passively respond to the uplink instruction from the Bluetooth equipment and communicate with the Bluetooth equipment, thereby ensuring the accuracy and reliability of data in the data processing process, realizing the beneficial effects of reducing the power consumption of the mobile terminal and optimizing the performance of the mobile terminal.

Description

Mobile terminal and method for processing Bluetooth data
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a mobile terminal and a method for processing bluetooth data thereof.
Background
In the prior art, in the process of communication between a mobile terminal serving as a master device and a bluetooth device, the mobile terminal needs to send a downlink instruction to the bluetooth device and then wait for receiving an uplink response returned from the bluetooth device, thereby completing one-time communication with the bluetooth device. Therefore, in some application scenarios, when the mobile terminal acquires a certain data returned by the bluetooth device, it may need to send a plurality of downlink commands to the bluetooth device to perform multiple communications with the bluetooth device to acquire the corresponding data (for example, after the mobile terminal sends a downlink command for acquiring user key information to the bluetooth POS, the bluetooth POS receives the corresponding downlink command and returns an uplink response to the received downlink command to the mobile terminal, and then continues to wait for the user key, and when the mobile terminal acquires the user key information returned by the bluetooth POS, it needs to send a downlink query command to the bluetooth POS without interruption and interact with the bluetooth POS to determine whether the bluetooth device has acquired the user key information), so that power consumption of the mobile terminal is fast.
Disclosure of Invention
The invention provides a mobile terminal and a method for processing Bluetooth data thereof, which solve the technical problems.
The invention provides a method for processing Bluetooth data by a mobile terminal, wherein the mobile terminal comprises a data processing module, an application module and an operating system, a receiving buffer area of the data processing module is used for storing Bluetooth data received by the data processing module and coming from Bluetooth equipment of the operating system, and the method comprises the following steps:
step A1: the data processing module acquires legal uplink data from the Bluetooth data in the receiving buffer area;
step A2: the data processing module judges the type of the uplink data, if the uplink data is an uplink response, the uplink response or uplink response effective data in the uplink response is put into an uplink response buffer area, and the uplink response in the receiving buffer area is removed; and if the uplink data is an uplink instruction, obtaining an uplink instruction result according to the uplink instruction, sending the uplink instruction result to the application module, and removing the uplink instruction in the receiving buffer.
The invention also provides a mobile terminal, which comprises a data processing module, an application module and an operating system;
the data processing module comprises: the device comprises a first obtaining submodule, a first judging submodule, a first storage submodule, a first removing submodule, a second obtaining submodule, a first sending submodule, a second removing submodule and a second storage submodule;
the second storage submodule is used for putting the Bluetooth data received by the data processing module from the Bluetooth device of the operating system into a receiving buffer area;
the first obtaining submodule is used for obtaining legal uplink data from the Bluetooth data in the receiving buffer area;
the first judging submodule is used for judging the type of the uplink data acquired by the first acquiring submodule;
the first storage submodule is configured to, after the first judgment submodule judges that the uplink data is an uplink response, place the uplink response or uplink response valid data in the uplink response into an uplink response buffer;
the first removing submodule is configured to remove the uplink response in the receiving buffer after the first storage submodule places the uplink response or the uplink response valid data in the uplink response into the uplink response buffer;
the second obtaining submodule is used for obtaining an uplink instruction result according to the uplink instruction after the first judging submodule judges that the uplink data is the uplink instruction;
the first sending submodule is used for sending the uplink instruction result obtained by the second obtaining submodule to the application module;
the second removing submodule is configured to remove the uplink instruction in the receiving buffer after the first sending submodule sends the uplink instruction result obtained by the second obtaining submodule to the application module.
The invention has the beneficial effects that: the mobile terminal and the method for processing the Bluetooth data thereof provided by the invention can actively send the downlink instruction to the Bluetooth device and receive the uplink response from the Bluetooth device when the mobile terminal communicates with the same Bluetooth device, and passively respond to the uplink instruction from the Bluetooth device and communicate with the Bluetooth device, thereby ensuring the accuracy and reliability of data of the mobile terminal in the data processing process, and achieving the beneficial effects of reducing the power consumption of the mobile terminal and optimizing the performance of the mobile terminal.
Drawings
Fig. 1 is a flowchart of a method for processing bluetooth data by a mobile terminal according to embodiment 1 of the present invention;
fig. 2-1, fig. 2-2 and fig. 2-3 are flowcharts of a method for processing bluetooth data by a mobile terminal according to embodiment 2 of the present invention;
fig. 3 is a detailed diagram of step 302 in a method for processing bluetooth data by a mobile terminal according to embodiment 2 of the present invention;
fig. 4 is a block diagram of a mobile terminal according to embodiment 3 of the present invention.
Detailed description of the invention
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
The embodiment provides a method for processing Bluetooth data by a mobile terminal, wherein the mobile terminal comprises a data processing module, an application module and an operating system, and the data processing module and the application module can be arranged on an application program of the mobile terminal. The operating system of the mobile terminal may be an Android or IOS operating system. The method is shown in fig. 1 and comprises the following steps:
step A1: the data processing module acquires legal uplink data from the Bluetooth data in the receiving buffer area;
in this embodiment, the receiving buffer of the data processing module is used for storing the bluetooth data received by the data processing module from the bluetooth device of the operating system.
Preferably, the data processing module stores the received bluetooth data from the bluetooth device of the operating system in the receive buffer in series.
Step a1 specifically includes:
step A11: the data processing module acquires data at a first position in the receiving buffer area, judges whether the data at the first position in the receiving buffer area conforms to a protocol header of a preset protocol or not, and if so, executes the step A12; otherwise, removing the data at the first position in the receiving buffer and returning to the step A11;
preferably, the data at the first position is data at the first byte in the data of the receiving buffer.
Step A12: the data processing module acquires current data to be verified and current check bit data from the receiving buffer area, judges whether the current data to be verified and the current check bit data conform to a preset protocol or not, if so, takes data between data at a first position in the receiving buffer area and the current check bit data as legal uplink data, and executes the step A2; otherwise, the data at the first position in the receive buffer is removed, returning to step a 11.
In this embodiment, after removing the data at the first position in the receiving buffer, before returning to step a11, the data processing module regards the data at the next position after the first position in the receiving buffer as the data at the first position.
Step A2: the data processing module judges the type of the uplink data, if the uplink data is an uplink response, the uplink response or the uplink response effective data in the uplink response is put into an uplink response buffer area, and the uplink response in the receiving buffer area is removed; and if the uplink data is an uplink instruction, obtaining an uplink instruction result according to the uplink instruction, sending the uplink instruction result to the application module, and removing the uplink instruction in the receiving buffer area.
In this embodiment, the method may further include: the data processing module receives Bluetooth data from the Bluetooth device of the operating system and puts the Bluetooth data into a receiving buffer area;
correspondingly, step a1 is preceded by:
step A0: the data processing module judges whether data exists in the receiving buffer area, if so, the step A1 is executed; otherwise, when the data processing module puts the bluetooth data into the receiving buffer, returning to step a0 or returning to step a 1;
in the step a2, after removing the uplink response in the receiving buffer, returning to the step a 0;
in step A2, after removing the uplink command from the receive buffer, the process returns to step A0.
Further, step a1 specifically includes: the data processing module starts to acquire uplink data from a first position in the receiving buffer area, judges whether legal uplink data is acquired or not, and executes the step A2 if the legal uplink data is acquired; otherwise, the data at the first position in the receive buffer is removed, returning to step a 0.
In this embodiment, step a1 may further include: the data processing module receives the Bluetooth data from the Bluetooth device of the operating system and puts the Bluetooth data into a receiving buffer.
Further, step a1 specifically includes: the data processing module acquires uplink data in the receiving buffer area, judges whether legal uplink data is acquired or not, and executes the step A2 if the legal uplink data is acquired; otherwise, the data in the receive buffer is removed.
In this embodiment, the data processing module receives bluetooth data from a bluetooth device of the operating system, specifically: the data processing module receives Bluetooth data from Bluetooth equipment of an operating system through a first callback function;
sending the uplink instruction result to an application module, specifically: and the data processing module sends the uplink instruction result to the application module through the second callback function.
In this embodiment, the method may further include:
step S1: the data processing module waits for receiving the application data from the application module, and if a request for sending a downlink instruction is received from the application module, step S2 is executed; if a request for sending a downlink response is received from the application module, step S3 is executed;
step S2: the data processing module obtains a downlink instruction according to the request for sending the downlink instruction, sends the downlink instruction to the Bluetooth device through the operating system, judges whether data exists in the uplink response buffer area, obtains an uplink response result according to the data in the uplink response buffer area if the data exists in the uplink response buffer area, returns the uplink response result to the application module, and returns to the step S1; otherwise, reporting an error;
in step S2, before sending the downlink instruction to the bluetooth device through the operating system, the method may further include: and emptying the uplink response buffer.
Step S3: and the data processing module obtains a downlink response according to the downlink response sending request, sends the downlink response to the Bluetooth device through the operating system, and returns to the step S1.
Further, before the data processing module receives a request for sending a downlink instruction from the application module, the method further includes: the application module sends a request for sending a downlink instruction to the data processing module; after the data processing module returns the uplink instruction result to the application module, the method further comprises the following steps: and the application module sends a downlink response sending request to the data processing module.
In this embodiment, after the determining the type of the uplink data in step a2, the method may further include: and if the uplink data is the uplink notification, obtaining an uplink notification result according to the uplink notification, sending the uplink notification result to the application module, and removing the uplink notification in the receiving buffer.
Wherein, sending the uplink notification result to the application module specifically comprises: and the data processing module sends the uplink notification result to the application module through a third callback function.
The obtaining of the uplink notification result according to the uplink notification specifically includes: and the data processing module acquires the effective data in the uplink notification and takes the effective data in the uplink notification as an uplink notification result.
In this embodiment, after the determining the type of the uplink data in step a2, the method may further include: if the uplink data is an uplink delay application, the uplink delay application is put into an uplink delay application buffer zone or uplink delay time is obtained according to the uplink delay application, and the uplink delay application time is put into the uplink delay application buffer zone; removing the uplink delay application in the receiving buffer area; correspondingly:
after the data processing module sends the downlink command to the bluetooth device through the operating system in step S2, before determining whether there is data in the uplink response buffer, the method further includes:
step T1: the data processing module judges whether the time is overtime according to the overtime time, and if so, an overtime error is returned to the application module; otherwise, go to step T2;
step T2: the data processing module judges whether data exists in the uplink delay buffer area, if so, the step T3 is executed; otherwise, the data processing module judges whether the uplink response buffer area has data or not and continues;
step T3: the data processing module obtains the uplink delay time according to the data in the uplink delay buffer, resets the timeout time according to the uplink delay time, empties the uplink delay buffer, and returns to step T1.
In this embodiment, the mobile terminal may reset the timeout time for acquiring the uplink response according to the uplink delay application sent by the bluetooth device, thereby enhancing the applicability of the mobile device.
In this embodiment, step S1 may further include: if receiving the request for sending the downlink delay application from the application module, the data processing module obtains the downlink delay application according to the request for sending the downlink delay application, sends the downlink delay application to the bluetooth device through the operating system, and returns to step S1.
Further, after the application module receives the result of the uplink instruction and before sending a request for sending a downlink response to the data processing module, the method further comprises sending a request for sending a downlink delay application to the data processing module.
In this embodiment, the data processing module obtains the downlink instruction according to the request for sending the downlink instruction, and may specifically be: the data processing module obtains downlink instruction effective data from the downlink instruction sending request and organizes the downlink instruction comprising the downlink instruction effective data according to a preset protocol; the data processing module obtains the downlink response according to the downlink response sending request, which may specifically be: the data processing module obtains downlink response effective data from the downlink response sending request and organizes downlink responses including the downlink response effective data according to a preset protocol; obtaining an uplink instruction result according to the uplink instruction may specifically be: the data processing module acquires effective data in the uplink instruction, and takes the effective data in the uplink instruction as an uplink instruction result; obtaining an uplink response result according to data in the uplink response buffer may specifically be: and the data processing module takes the uplink response effective data in the uplink response as an uplink response result.
In this embodiment, the data processing module obtains the downlink instruction according to the request for sending the downlink instruction, and may further specifically be: the data processing module obtains a downlink instruction from the downlink instruction sending request; the data processing module obtains the downlink response according to the downlink response sending request, and may specifically be: the data processing module obtains a downlink response from the downlink response sending request; obtaining an uplink instruction result according to the uplink instruction, which may further be specifically: the data processing module takes the uplink instruction as an uplink instruction result; if the data processing module in step a2 puts the uplink response into the uplink response buffer, obtaining the uplink response result according to the data in the uplink response buffer may further specifically be: and the data processing module takes the uplink response in the uplink response buffer area as an uplink response result.
According to the method for processing the Bluetooth data by the mobile terminal, when the mobile terminal communicates with the same Bluetooth device, the mobile terminal can actively send a downlink instruction to the Bluetooth device and receive an uplink response from the Bluetooth device, and can passively respond to the uplink instruction from the Bluetooth device and communicate with the Bluetooth device, so that the accuracy and reliability of data of the mobile terminal in a data processing process can be ensured, and the beneficial effects of reducing the power consumption of the mobile terminal and optimizing the performance of the mobile terminal are achieved.
Example 2
The method for processing bluetooth data by a mobile terminal provided by the embodiment includes the operations shown in fig. 2-1, fig. 2-2 and fig. 2-3:
in this embodiment, the mobile terminal includes an application module, a data processing module, and an operating system, where the data processing module and the application module may be set on an application program of the mobile terminal. The operating system of the mobile terminal may be an Android or IOS operating system.
In the method for processing bluetooth data of a mobile terminal provided in this embodiment, a data processing module waits to receive bluetooth data from an operating system in a data receiving thread, and if the bluetooth data from a bluetooth device of the operating system is received, executes an operation shown in step 101 in fig. 2-1; waiting for application data from the application module to be received in the data sending thread, and executing the operation shown in the figure 2-2; the operations shown in fig. 2-3 are performed in a data processing thread.
Step 101: the data processing module adds the Bluetooth data from the Bluetooth device to a receiving buffer area by using a serial queue, and sets a data adding flag bit.
In this embodiment, specifically, if the data processing module receives bluetooth data from the bluetooth device of the operating system through its own first callback function in the data receiving thread, step 101 is executed;
for example: the first callback function is: void callBack (unidentified char data, unidentified intdataLen); the parameter data comprises Bluetooth data from Bluetooth equipment of an operating system;
before the data processing module receives the bluetooth data from the bluetooth device of the operating system through its own first callback function, the method further includes: the data processing module registers a first callback function with the operating system, and accordingly: and after the operating system receives the Bluetooth data from the Bluetooth equipment, the operating system sends the received Bluetooth data from the Bluetooth equipment to the data processing module through the first callback function.
More specifically, before the data processing module receives the bluetooth data from the bluetooth device through the first callback function of the data processing module, the data processing module registers the first callback function in a system receiving function of the operating system; and after the system receiving function of the operating system receives the Bluetooth data from the Bluetooth equipment, the operating system sends the received Bluetooth data from the Bluetooth equipment to the data processing module through the first callback function.
If the operating system is an Android system, the system receiving function may specifically be: public voidon Characteriodchanged (Bluetooth Gatt gatt, Bluetooth Gattcharacteriodicitic);
if the operating system is an IOS system, the system receiving function may specifically be: -
(void)peripheral:(CBPeripheral*)peripheraldidUpdateValueForCharacteristic:(CBCharacteristic*)characteristic error:(nullable NSError*)error;
Step 201: the data processing module waits for receiving application data from the application module; if a request for sending a downlink instruction from the application module is received, executing step 202; if a request for sending a downlink response is received from the application module, go to step 211;
specifically, the data processing module waits for receiving data from the application module in the data sending thread: if a request for sending a downlink instruction from the application module is received through a first receiving interface of the data sending thread, executing step 202; if the data sending thread receives a downlink response sending request from the application module through its second receiving interface, step 211 is executed.
For example: the first receiving interface is: unknown int sendOrder
Figure GDA0002376654530000091
Figure GDA0002376654530000101
The second receiving interface is unscented int sendAsk
Figure GDA0002376654530000102
Step 202: the data processing module judges whether the downlink instruction mutual exclusion lock is locked, if so, the step 202 is returned to; otherwise, locking the downlink instruction mutual exclusion lock, and executing step 203;
step 203: the data processing module obtains a downlink instruction according to the downlink instruction sending request;
specifically, the data processing module obtains the downlink instruction effective data from the downlink instruction sending request, and organizes the downlink instruction including the downlink instruction effective data according to a preset protocol.
More specifically, the data processing module obtains downlink instruction effective data from a downlink instruction sending request, sets a sixth preset value on a first byte in the downlink instruction according to a preset protocol, sets a fourth preset value on a second byte of the downlink instruction, sets data on a third byte and a fourth byte of the downlink instruction according to the length of the downlink instruction effective data, sets the downlink instruction effective data behind the fourth byte, calculates data between the second byte and the downlink instruction effective data in the downlink instruction according to a preset algorithm to obtain a downlink instruction check value, and sets the downlink instruction check value behind the downlink instruction effective data to obtain the downlink instruction comprising the downlink instruction effective data.
For example: the data processing module obtains downlink instruction valid data 0102 from a downlink instruction sending request, sets a sixth preset value A5 on a first byte in a downlink instruction according to a preset protocol, sets a fourth preset value 02 on a second byte of the downlink instruction, sets data on a third byte and a fourth byte of the downlink instruction according to a length 2 byte of the downlink instruction valid data, sets the downlink instruction valid data behind the fourth byte, calculates a downlink instruction check value 03 from the second byte to the data "0200020102" between the downlink instruction valid data in the downlink instruction according to a preset algorithm, and sets the downlink instruction check value behind the downlink instruction valid data to obtain a downlink instruction "A5020002010203" including the downlink instruction valid data.
Step 204: the data processing module judges whether there is data in the uplink response buffer, if yes, step 205 is executed; otherwise, sending a downlink instruction to the bluetooth device through the operating system, and executing step 206;
in this embodiment, the downlink instruction is sent to the bluetooth device through the operating system, which specifically includes: and sending a downlink instruction to the Bluetooth device through the operating system by using the serial queue.
Step 205: the data processing module empties the data in the uplink response buffer, sends a downlink instruction to the bluetooth device through the operating system, and executes step 206;
specifically, the data processing module empties data in the uplink response buffer, and calls a system sending function of the operating system to send a downlink instruction to the bluetooth device.
For example: the data processing module empties the data in the uplink response buffer, calls a first system sending function public laptop setValue (byte [ ] value) of the Android operating system to put a downlink instruction into the feature, and calls a second system sending function public laptop magnetic characteristic (Bluetooth gateway characterised by the characteristic) to send the downlink instruction in the feature to the Bluetooth device.
Another example is: the data processing module empties the data in the uplink response buffer and calls a system sending function (void) write value (NSData) data for charateristic (CBcharateristic) type of the IOS system; and sending a downlink instruction to the Bluetooth equipment.
Step 206: the data processing module judges whether the time is overtime according to the overtime time, if not, the step 207 is executed: if yes, returning a timeout error to the application module, and returning to the step 201;
before the step 206 is executed for the first time, the method further includes: the data processing module obtains response overtime time from the downlink instruction sending request, and sets the overtime time of the data processing module according to the response overtime time.
Step 207: the data processing module judges whether data exists in the uplink delay application buffer area, if so, step 210 is executed; otherwise, go to step 208;
step 208: the data processing module judges whether the uplink response buffer has data, if yes, step 209 is executed; otherwise, return to step 206;
step 209: and the data processing module obtains an uplink response result according to the data in the uplink response buffer, returns the uplink response result to the application module, unlocks the downlink instruction mutual exclusion lock, and returns to the step 201.
In this embodiment, if in step 304, the data processing module puts the uplink response valid data in the uplink response into the uplink response buffer, step 209 specifically includes: the data processing module takes the data in the uplink response buffer area as an uplink response result, returns the uplink response result to the application module, unlocks the downlink instruction mutual exclusion lock, and returns to step 201.
If, in step 304, the data processing module puts the uplink response into the uplink response buffer, step 209 may specifically be: the data processing module analyzes the uplink response in the uplink response buffer to obtain the uplink response valid data in the uplink response, uses the uplink response valid data in the uplink response as an uplink response result, returns the uplink response result to the application module, unlocks the downlink instruction mutual exclusion lock, and returns to step 201.
Step 210: the data processing module obtains the uplink delay application time according to the data in the uplink delay application buffer, resets the timeout time according to the uplink delay application time, clears the uplink delay application buffer, and returns to step 206;
step 211: the data processing module obtains a downlink response according to the request for sending the downlink response, sends the downlink response to the bluetooth device through the operating system, and returns to step 201.
Specifically, the data processing module obtains downlink response valid data from a downlink response sending request, organizes a downlink response including the downlink response valid data according to a preset protocol, and calls a system sending function of an operating system to send the downlink response to the bluetooth device.
Specifically, the data processing module obtains downlink response valid data from a downlink response sending request, sets a seventh preset value on a first byte in the downlink response according to a preset protocol, sets a fourth preset value on a second byte in the downlink response, sets the length of the downlink response valid data on a third byte and a fourth byte in the downlink response, sets the downlink response valid data behind the fourth byte, calculates data between the second byte and the downlink response valid data in the downlink response according to a preset algorithm to obtain a downlink response check value, sets the downlink response check value behind the downlink response valid data to obtain a downlink response including the downlink response valid data, and sends the downlink response to the bluetooth device by using a serial queue.
For example: the data processing module obtains downlink response valid data 04 from a downlink response sending request, sets a seventh preset value 3C on a first byte in the downlink response according to a preset protocol, sets a fourth preset value 02 on a second byte in the downlink response, sets data on a third byte and a fourth byte of the downlink response according to 1 byte of the downlink response valid data, sets the downlink response valid data behind the fourth byte, calculates data '02000104' between the second byte and the downlink response valid data in the downlink response according to a preset algorithm to obtain a downlink response check value 07, sets the downlink response check value behind the downlink response valid data to obtain a downlink response '3C 0200010407' comprising the downlink response valid data, and the data processing module sends the downlink response to the Bluetooth device by using a serial queue.
Step 301: the data processing module judges whether data exists in the receiving buffer area, if so, the step 302 is executed, otherwise, the step 308 is executed;
step 302: the data processing module starts to acquire uplink data from a first position in the receiving buffer area, judges whether legal uplink data is acquired, and executes step 303 if the legal uplink data is acquired; otherwise, removing the data at the first position in the receiving buffer, and returning to step 301;
preferably, the data of the first position in the receive buffer is the data on the first byte in the receive buffer.
Step 302 is shown in fig. 3, and specifically includes:
step 3021: the data processing module acquires data on a first byte in the receiving buffer area, judges whether the data on the first byte in the data in the receiving buffer area conforms to a protocol header of a preset protocol or not, and if so, executes step 3022; otherwise, removing the data on the first byte in the data in the receiving buffer, and returning to step 301;
in this embodiment, data on a first byte of a protocol header of uplink data specified by a preset protocol is a first preset value, a second preset value, or a third preset value. Preferably, the first preset value is 5A; the second preset value is C3; the third preset value is 53.
Specifically, the data processing module acquires data on a first byte in the receiving buffer, and determines whether the data on the first byte in the data in the receiving buffer is a first preset value, a second preset value or a third preset value, and if so, determines that the data on the first byte in the uplink data conforms to a protocol header of a preset protocol; otherwise, judging that the data on the first byte in the uplink data does not conform to the protocol header of the preset protocol.
For example: the data processing module determines that the data "00" on the first byte in the data "005 a 02000104075A F2B 84A" in the receiving buffer does not conform to the protocol header of the preset protocol, removes the data "00" on the first byte in the data "005 a 02000104075A F2B 84A" in the receiving buffer, and returns to step 301; when the determination in step 301 is yes, the data processing module determines that the data "5A" on the first byte in the data "5A 02000104075A F2B 84A" in the receiving buffer is the first preset value, and then determines that the data on the first byte in the data in the receiving buffer conforms to the protocol header of the preset protocol.
Step 3022: the data processing module acquires current data to be verified and current check bit data from the data in the receiving buffer, judges whether the data to be verified and the current check bit data conform to a preset protocol, if so, takes the data between the data on the first byte in the receiving buffer and the data on the current check bit as legal uplink data, and executes step 303; otherwise, the data on the first byte in the data in the receiving buffer is removed, and the step 301 is returned.
Specifically, the data processing module obtains current data to be verified and current check bit data from data in the receiving buffer according to a preset protocol, performs operation on the current data to be verified according to a preset algorithm to obtain a first operation value, determines whether the first operation value is matched with the current check bit data, and if so, takes data between a first byte and the current check bit data as legal uplink data, and executes step 303; otherwise, the data on the first byte in the data in the receiving buffer is removed, and the step 301 is returned.
For example: the data processing module obtains current data to be verified "02000104" and current check bit data "07" from data "5 a 02000104075A F2B 84A" in the receiving buffer according to a preset protocol, performs xor operation from the beginning of the data to be verified "02" to the end of the data "04" according to a preset algorithm to obtain a first operation value "07", determines that the first operation value "07" matches the current check bit data "07", determines that data after a first byte in the receiving buffer includes data meeting the preset protocol, and performs step 303 by using the data "5 a 0200010407" between the first byte and the current check bit data as uplink data.
The data processing module acquires current data to be verified and current check bit data from data in the receiving buffer according to a preset protocol, and the method specifically comprises the following steps: the data processing module judges the type of the data on the first byte of the data in the receiving buffer, and if the data on the first byte of the receiving buffer is a first preset value, the step h1 is executed; if the data on the first byte in the receiving buffer is the second preset value or the third preset value, executing step h 2;
step h 1: the data processing module judges the type of the data on the second byte of the data in the receiving buffer, if the data on the second byte of the data in the receiving buffer is a fourth preset value, if yes, the step h2 is executed; if the data on the second byte in the data in the receiving buffer is the fifth preset value, executing step h 3;
preferably, the fourth preset value is 02 and the fifth preset value F2.
Step h 2: the data processing module acquires data on a third byte and a fourth byte in the data in the receiving buffer area, and takes the data as the byte length of current effective data, acquires data after the fourth byte and with the data length being the byte length of the current effective data, and takes the data as the current effective data, takes the data on the second byte, the third byte and the fourth byte and the current effective data as current data to be verified, and takes the data on a first byte after the effective data as current check bit data.
Step h 3: the data processing module acquires the data length after the first byte and takes the data length as data with a first preset length, the data on the last byte in the acquired data is taken as current check bit data, and the acquired data except the current check bit data is taken as current data to be verified.
Preferably, the first preset length is 3 bytes.
For example: if the data in the receiving buffer is "5A 02000104075A F2B 84A", the data processing module determines that the data "5A" on the first byte in the data "5A 02000104075A F2B 84A" in the receiving buffer is the first preset value, the data processing module continues to execute step h1, determines that the data on the second byte in the data in the receiving buffer is the fourth preset value 02, and continues to execute step h 2; the data processing module acquires data "0001" on the third and fourth bytes in the data in the receiving buffer, and the data "0001" on the third and fourth bytes is used as the byte length of the currently valid data, acquires data after the fourth byte "01" and having the data length of the currently valid data byte (namely, one byte), that is, acquires data "04", and requests "04" as the currently valid data, takes data "02", "00", "01" and the currently valid data "04" on the second byte, the third byte and the fourth byte as data to be verified, and takes data "07" on the first byte after the currently valid data "04" as current check bit data.
If the data in the receiving buffer is "5A F2B 84A", the data processing module determines that the data "5A" on the first byte in the data "5A F2B 84A" in the receiving buffer is the first preset value, the data processing module continues to execute step h1, determines that the data on the second byte in the data in the receiving buffer is the fifth preset value F2, and continues to execute step h 3; the data processing module acquires data with a data length of a first preset length (i.e., 3 bytes) after the data "5A" on the first byte, takes the data "4A" on the last byte in the acquired data "F2B 84A" as the current parity data, and takes the acquired data "F2B 8" except the current parity data as the current data to be verified.
Step 303: the data processing module judges the type of the uplink data, and if the uplink data is an uplink response, step 304 is executed; if the uplink data is an uplink delay application, go to step 305; if the uplink data is an uplink command, go to step 306; if the uplink data is the uplink notification, go to step 307;
specifically, the data processing module determines a type of data on a first byte in the uplink data, determines a type of data on a second byte in the uplink data if the data on the first byte in the uplink data is a first preset value, determines the uplink data as an uplink response if the data on the second byte in the uplink data is a fourth preset value, and determines the uplink data as an uplink delay application if the data on the second byte in the uplink data is a fifth preset value; if the data on the first byte in the uplink data is a second preset value, the uplink data is an uplink instruction; and if the data on the first byte in the uplink data is the third preset value, the uplink data is the uplink notification.
For example: if the uplink data acquired by the data processing module is "5A 0200010407", the data processing module judges that the data on the first byte in the uplink data "5A 0200010407" is the first preset value "5A", judges the type of the data on the second byte in the uplink data, and judges that the data on the second byte in the uplink data "5A 0200010407" is the fourth preset value "02", and judges that the uplink data "5A 0200010407" is an uplink response;
if the uplink data acquired by the data processing module is "5A F2B 84A", the data processing module judges that the data on the first byte in the uplink data "5A F2B 84A" is a first preset value "5A", judges the type of the data on the second byte in the uplink data, and judges that the uplink data "5A F2B 84A" is an uplink delay application if the data "F2" on the second byte in the uplink data "5A F2B 84A" is a fifth preset value;
if the uplink data acquired by the data processing module is "C3020002010203", the data processing module determines that the data on the first byte in the uplink data "C3020002010203" is the second preset value "C3", and determines that the uplink data "C3020002010203" is an uplink instruction;
if the uplink data acquired by the data processing module is "530200010103", the data processing module determines that the data on the first byte in the uplink data "530200010103" is the third preset value "53", and determines that the uplink data "530200010103" is the uplink notification.
Step 304: the data processing module puts the uplink response or the uplink response valid data in the uplink response into the uplink response buffer area, removes the uplink response in the receiving buffer area, and returns to step 301;
if the data processing module puts the uplink response valid data in the uplink response into the uplink response buffer, step 304 specifically includes: the data processing module analyzes the uplink response, acquires uplink response valid data in the uplink response, puts the uplink response valid data in the uplink response into an uplink response buffer, removes the uplink response in the receiving buffer, and returns to step 301.
More specifically, the data processing module parses the uplink response, obtains data on the third byte and the fourth byte in the uplink response, and uses the data as the byte length of the uplink response valid data, obtains data after the fourth byte and with the data length being the byte length of the uplink response valid data, and uses the data as the uplink response valid data, puts the uplink response valid data into the uplink response buffer, removes the uplink response in the receiving buffer, and returns to step 301.
For example: the data processing module analyzes the uplink response "5 a 0200010407", acquires data "0001" on the third and fourth bytes in the uplink response, takes the data as the byte length of the uplink response valid data, acquires data "04" after the fourth byte and with the data length of 1 byte, takes the data as the uplink response valid data, takes the uplink response valid data as the uplink response result, puts the uplink response valid data "04" into the uplink response buffer, removes the uplink response in the receiving buffer, and returns to step 301.
Step 305: the data processing module obtains uplink delay application time according to the uplink delay application, puts the uplink delay application time into an uplink delay application buffer, removes the uplink delay application in the receiving buffer, and returns to step 301;
for example: the data processing module obtains the uplink delay application time as a first preset time according to the uplink delay application "5A F2B 84A", the first preset time is put into the uplink delay application buffer, the uplink delay application in the receiving buffer is removed, and the step 301 is returned to.
Preferably, the first preset time is 3 seconds.
This step can also be replaced by: the data processing module puts the uplink delay application into the uplink delay application buffer, removes the uplink delay application in the receiving buffer, and returns to step 301;
correspondingly, step 210 specifically includes: the data processing module obtains the uplink delay application time according to the uplink delay application in the uplink delay application buffer, resets the timeout time according to the uplink delay application time, and returns to step 206.
Step 306: the data processing module obtains an uplink instruction result according to the uplink instruction, sends the uplink instruction result to the application module, removes the uplink instruction in the receiving buffer area, and returns to the step 301;
specifically, the data processing module analyzes the uplink instruction, obtains effective data in the uplink instruction, uses the effective data in the uplink instruction as an uplink instruction result, returns the uplink instruction result to the application module through the second callback function, removes the uplink instruction in the receiving buffer, and returns to step 301.
More specifically, the data processing module parses the uplink instruction, obtains data on the third byte and the fourth byte in the uplink instruction, and takes the data as the byte length of the effective data in the uplink instruction, obtains data with the data length being the byte length of the effective data in the uplink instruction from the fourth byte, and takes the data as the effective data in the uplink instruction, takes the effective data in the uplink instruction as the result of the uplink instruction, and returns the result of the uplink instruction to the application module through the second callback function, removes the uplink instruction in the receiving buffer, and returns to step 301.
For example: the data processing module analyzes the uplink instruction "C3020002010203", acquires data "0002" on the third and fourth bytes in the uplink instruction, and uses the data "0002" as the byte length of the valid data in the uplink instruction, acquires data "0102" with a data length of 2 bytes from the fourth byte onward, and uses the data "0102" as the valid data in the uplink instruction, and uses the valid data in the uplink instruction as the result of the uplink instruction, and returns the result of the uplink instruction to the application module through the second callback function, removes the uplink instruction in the receiving buffer, and returns to step 301.
It should be noted that, before the data processing module returns the result of the uplink instruction to the application module through the second callback function, the method further includes: the application module registers a second callback function with the data processing module, and accordingly: and when the data processing module analyzes the uplink instruction, effective data in the uplink instruction is obtained, and the effective data in the uplink instruction is used as an uplink instruction result, and the uplink instruction result is returned to the application module through the second callback function.
Step 307: the data processing module obtains an uplink notification result according to the uplink notification, returns the uplink notification result to the application module, removes the uplink notification in the receiving buffer, and returns to step 301;
specifically, the data processing module analyzes the uplink notification, acquires the valid data in the uplink notification, uses the valid data in the uplink notification as an uplink notification result according to the valid data in the uplink notification, and returns the uplink notification result to the application module through the third callback function.
More specifically, the data processing module analyzes the uplink notification, acquires data on the third and fourth bytes in the uplink notification, and uses the data as the byte length of the valid data, acquires data with the data length being the byte length of the valid data from the fourth byte, and uses the data as the valid data, and returns the valid data to the application module through the third callback function.
For example, the data processing module parses the upstream notification "530200010103," obtains the data "0001" in the third and fourth bytes in the upstream notification, takes it as the byte length of the valid data, obtains the data "01" whose data length is the byte length of the valid data from the fourth byte onward, takes it as the valid data, and passes the valid data "01" through the third callback function dwdevent _ handle (dword dweventid); and returning the data to the application module, and acquiring a notification event 'low electric quantity' corresponding to the effective data '01' by the application module.
It should be noted that before the data processing module returns the notification event corresponding to the valid data to the application module through the third callback function, the method further includes: the application module registers a third callback function with the data processing module, and accordingly: and when the data processing module analyzes the uplink notification and acquires the effective data in the uplink notification, returning the effective data to the application module through a third callback function.
Step 308: the data processing module detects whether the data adding flag bit is set, if so, the data adding flag bit is reset, and the step 301 or 302 is returned; otherwise, return to step 308;
in this embodiment, step 203 may further specifically be: the data processing module obtains a downlink instruction from the request for sending the downlink instruction, and the data processing module sends the downlink instruction to the Bluetooth device through the operating system by using the serial queue; step 304 may also be replaced with: the data processing module takes the uplink response as an uplink response result, puts the uplink response result into an uplink response buffer area, removes the uplink response in the receiving buffer area, and returns to the step 301; step 209 may also specifically be: the data processing module takes the data in the uplink response buffer area as an uplink response result, returns the uplink response result to the application module, unlocks the downlink instruction mutual exclusion lock, and returns to step 201; step 306 may also specifically be: the data processing module takes the uplink instruction as an uplink instruction result, sends the uplink instruction result to the application module, removes the uplink instruction in the receiving buffer area, and returns to the step 301; step 211 may also specifically be: the data processing module obtains the downlink response from the downlink response request, sends the downlink response to the bluetooth device through the operating system, and returns to step 201. Step 307 may further specifically be: the data processing module takes the uplink notification as an uplink notification result, returns the uplink notification result to the application module, removes the uplink notification in the receiving buffer, and returns to step 301.
In this embodiment, if the data processing module receives the bluetooth data from the bluetooth device of the operating system in the data receiving thread, the data processing module continues to execute step 301 in the data receiving thread after adding the bluetooth data from the bluetooth device to the receiving buffer by using the serial queue; after the determination in step 301 is negative, the data reception thread continues to wait for the reception of bluetooth data from the bluetooth device of the operating system.
Accordingly, step 302 may also be: the data processing module acquires uplink data from the receiving buffer area, judges whether legal uplink data is acquired or not, and executes step 303 if the legal uplink data is acquired; otherwise, the data in the receiving buffer is removed, and the data receiving thread is continuously waited for receiving the Bluetooth data from the Bluetooth device of the operating system.
In this embodiment, step 208 may also be performed after step 206; accordingly, step 303 is replaced with: the data processing module judges the type of the uplink data, and if the uplink data is an uplink response, step 304 is executed; if the uplink data is an uplink command, go to step 306; if the uplink data is the uplink notification, go to step 307.
In this embodiment, after the data processing module sends the uplink instruction to the application module, the application module may also send a request for sending a downlink delay application to the data processing module; accordingly, step 201 may further include: if receiving a request for sending a downlink delay application from the application module, the data processing module organizes the downlink delay application, sends the downlink delay application to the bluetooth device, and returns to step 201.
Specifically, after the data processing module receives a request for sending a downlink delay application from the application module through its own third receiving interface in the data sending thread, the data processing module organizes the downlink delay application, sends the downlink delay application to the bluetooth device, and returns to step 201.
For example: specifically, after the data processing module receives a downlink delay application sending request from the application module through its own third receiving interface assigned int sendTimeout in the data sending thread, the data processing module organizes the downlink delay application "3C F2B 84A", sends the downlink delay application to the bluetooth device, and returns to step 201.
In the method for processing bluetooth data by a mobile terminal provided by this embodiment, after receiving bluetooth data from a bluetooth device of an operating system, a data processing module in the mobile terminal puts the received bluetooth data into a receiving buffer in sequence, and parses the received data according to a byte situation, if it is determined by a preset protocol that data in a first byte or a protocol data format behind the first byte is incorrect, the byte data in the first byte is discarded, and the judgment is performed backwards in sequence until uplink data conforming to the preset protocol is found and the type of the data is distinguished: if the uplink data is the uplink response, the uplink response or the uplink response effective data in the uplink response is put into an uplink response buffer zone; if a downlink instruction sending request from the application module is received, obtaining a downlink instruction according to the downlink instruction request, sending the downlink instruction to the Bluetooth equipment through the operating system, then detecting whether data exist in the uplink response buffer area, if so, obtaining an uplink response result according to the data in the uplink response buffer area, and returning the uplink response result to the application module; if the uplink data is an uplink instruction, adopting a callback mode according to an uplink instruction result obtained by the uplink instruction, namely returning the uplink instruction result to the application module through a second callback function, obtaining a downlink response corresponding to the uplink instruction according to a downlink response sending request of the application module, and sending the downlink response to the Bluetooth equipment through the operating system; if the uplink data is the uplink notification, an uplink notification result is obtained according to the uplink notification, and a callback mode is adopted, namely the uplink notification result is returned to the application module through a third callback function, so that the mobile terminal can actively send a downlink instruction to the Bluetooth device, receive an uplink response from the Bluetooth device, passively respond to the uplink instruction from the Bluetooth device and send a corresponding downlink response to the Bluetooth device, the accuracy and reliability of the data of the mobile terminal in the data processing process can be ensured, and the beneficial effects of reducing the power consumption of the mobile terminal and optimizing the performance of the mobile terminal are achieved.
Example 3
The embodiment provides a mobile terminal, as shown in fig. 4, including a data processing module, an application module, and an operating system, where a receiving buffer of the data processing module is used to store bluetooth data received by the data processing module from a bluetooth device of the operating system;
wherein the data processing module and the application module may be provided on an application of the mobile terminal. The operating system of the mobile terminal may be an Android or IOS operating system.
Wherein, the data processing module includes: the system comprises a second storage submodule 00, a first obtaining submodule 01, a first judging submodule 02, a first storage submodule 03, a first removing submodule 04, a second obtaining submodule 05, a first sending submodule 06 and a second removing submodule 07;
the second storage submodule 00 is configured to put bluetooth data, which is received by the data processing module and is from a bluetooth device of the operating system, into the receiving buffer;
the first obtaining submodule 01 is used for obtaining legal uplink data from the Bluetooth data in the receiving buffer area;
in this embodiment, the first obtaining sub-module 01 specifically includes: the device comprises a first acquisition unit, a first judgment unit, a first removal unit, a second acquisition unit and a second judgment unit;
a first acquisition unit configured to acquire data at a first position of the reception buffer;
the first judging unit is used for judging whether the data on the first position acquired by the first acquiring unit conforms to a protocol header of a preset protocol or not;
the second obtaining unit is used for obtaining the current data to be verified and the current check bit data from the receiving buffer area after the first judging unit judges that the data to be verified and the current check bit data are the same;
the second judging unit is used for judging whether the current data to be verified and the current check bit data acquired by the second acquiring unit conform to a preset protocol or not, and if so, taking the data between the data at the first position in the receiving buffer and the current check bit data as legal uplink data;
the first removing unit is used for removing the data at the first position in the receiving buffer area after the first judging unit judges that the data is not received; when the second judging unit judges that the data is not received, the data at the first position in the receiving buffer area is removed.
In this embodiment, the first removing unit is further configured to: when the data at the first position in the reception buffer is removed, the data at the next position after the first position in the reception buffer is taken as the data at the first position.
The first judgment submodule 02 is configured to judge the type of the uplink data acquired by the first acquisition submodule 01;
the first storage submodule 03 is configured to, after the first judgment submodule 02 judges that the uplink data is an uplink response, place the uplink response or uplink response valid data in the uplink response into an uplink response buffer;
the first removing submodule 04 is configured to remove the uplink response in the receiving buffer after the first storage submodule 03 puts the uplink response or the uplink response valid data in the uplink response into the uplink response buffer;
the second obtaining submodule 05 is configured to obtain an uplink instruction result according to the uplink instruction after the first determining submodule 02 determines that the uplink data is the uplink instruction;
the first sending submodule 06 is configured to send the uplink instruction result obtained by the second obtaining submodule 05 to the application module;
and the second removing submodule 07 is configured to remove the uplink instruction in the receiving buffer after the first sending submodule 06 sends the uplink instruction result obtained by the second obtaining submodule 05 to the application module.
In this embodiment, the data processing module may further include a first receiving sub-module and a second determining sub-module;
the first receiving submodule is used for receiving Bluetooth data from the Bluetooth equipment of the operating system;
the second storage submodule 00 is specifically configured to put the bluetooth data received by the first receiving submodule into a receiving buffer;
a second judgment submodule, configured to judge whether there is data in the receiving buffer before the first obtaining submodule 01 obtains legal uplink data from the bluetooth data in the receiving buffer, when the first removing submodule 04 removes an uplink response in the receiving buffer, when the second removing submodule 07 removes an uplink instruction in the receiving buffer, and when the second judgment submodule judges that there is no data in the receiving buffer;
the first obtaining sub-module 01 is specifically configured to obtain legal uplink data from the bluetooth data in the receiving buffer after the second determining module determines that the uplink data is valid.
Further, the first obtaining sub-module 01 is specifically configured to obtain uplink data from data at a first position of the receive buffer; judging whether legal uplink data is acquired or not, and if so, judging that the legal uplink data is acquired; otherwise, removing the data at the first position in the receiving buffer;
the first judgment submodule 02 is specifically configured to, when the first obtaining submodule 01 judges that the uplink data obtained by the first obtaining submodule 01 is the uplink data, judge the type of the uplink data obtained by the first obtaining submodule 01;
the second determining submodule is specifically configured to determine whether there is data in the receiving buffer before the first obtaining submodule 01 obtains the uplink data from the bluetooth data in the receiving buffer, after the first obtaining submodule 01 removes data at the first position in the receiving buffer, when the first removing submodule 04 removes an uplink response in the receiving buffer, when the second removing submodule 07 removes an uplink instruction in the receiving buffer, and when the second determining submodule determines that the data is not present.
In this embodiment, the data processing module may further include: a first receiving submodule;
the first receiving submodule is used for receiving Bluetooth data from the Bluetooth equipment of the operating system;
the second storage submodule 00 is specifically configured to put the bluetooth data received by the second receiving submodule into the receiving buffer.
Further, the first obtaining sub-module 01 is specifically configured to obtain uplink data in the receiving buffer, determine whether legal uplink data is obtained, and if so, determine that legal uplink data is obtained; otherwise, the data in the receive buffer is removed.
In this embodiment, the first receiving submodule is specifically configured to receive, through the first callback function, bluetooth data from a bluetooth device of the operating system; the first sending submodule 06 is specifically configured to send the uplink instruction result to the application module through the second callback function.
In this embodiment, the data processing module may further include: the second receiving submodule, the second sending submodule, the third obtaining submodule, the fourth obtaining submodule, the third judging submodule and the error reporting submodule;
the second receiving submodule is used for receiving a downlink instruction sending request from the application module and receiving a downlink response sending request from the application module;
the third obtaining submodule is used for obtaining a downlink instruction according to the downlink instruction sending request received by the second receiving submodule; obtaining a downlink response according to a downlink response sending request received by the second receiving submodule;
the second sending submodule is used for sending the downlink instruction acquired by the third acquisition module to the Bluetooth equipment through the operating system and sending the downlink response acquired by the third acquisition module to the Bluetooth equipment through the operating system;
the third judgment submodule is used for judging whether the uplink response buffer area has data or not;
the error reporting submodule is used for reporting an error when the third judgment submodule judges that the third judgment submodule is negative;
the fourth obtaining submodule is used for obtaining an uplink response result according to the data in the uplink response buffer area after the third judging submodule judges that the data in the uplink response buffer area is positive;
the first sending submodule 06 is further configured to return the uplink response result to the application module.
Correspondingly, the application module comprises: a third sending submodule and a third receiving submodule;
the third sending submodule is used for sending a downlink instruction sending request and a downlink response sending request to the data processing module;
and the third receiving submodule is used for receiving the uplink instruction result and the uplink response result from the data processing module.
Further, the data processing module may further include: a first purge submodule;
and the first emptying submodule is used for emptying the uplink response buffer before the second sending submodule sends the downlink instruction acquired by the third acquisition module to the Bluetooth equipment through the operating system.
In this embodiment, the data processing module may further include: a fifth obtaining submodule and a third removing submodule;
the fifth obtaining submodule is configured to obtain an uplink notification result according to the uplink notification after the first determining submodule 02 determines that the uplink data is an uplink response;
the fifth obtaining sub-module is specifically configured to, after the first determining sub-module 02 determines that the uplink data is the uplink response, obtain the valid data in the uplink notification, and use the valid data in the uplink notification as the uplink notification result.
The first sending submodule 06 is further configured to send the uplink notification result obtained by the fifth obtaining submodule to the application module;
and the third removing submodule is used for removing the uplink notification in the receiving buffer after the first sending submodule 06 sends the uplink notification result to the application module.
Further, the first transmission submodule 06 includes a first transmission unit and a second transmission unit;
the first sending unit is used for sending the uplink instruction result to the application module;
and the second sending unit is used for sending the uplink notification result to the application module through a third callback function.
In this embodiment, if the data processing module includes: the device comprises a second storage submodule 00, a first obtaining submodule 01, a first judging submodule 02, a first storage submodule 03, a first removing submodule 04, a second obtaining submodule 05, a first sending submodule 06, a second removing submodule 07, a second receiving submodule, a second sending submodule, a third obtaining submodule, a fourth obtaining submodule, a third judging submodule and an error reporting submodule; the data processing module may further include: the first storage submodule, the second removal submodule, the fourth judgment submodule, the fifth judgment submodule, the sixth acquisition submodule, the first reset submodule and the second emptying submodule are connected in series;
a third storage sub-module, configured to, after the first determining sub-module 02 determines that the type of the uplink data is an uplink delay application, place the uplink delay application into an uplink delay application buffer or obtain an uplink delay time according to the uplink delay application, and place the uplink delay application time into the uplink delay application buffer;
the fourth removal submodule is used for removing the uplink delay application in the receiving buffer area after the third storage submodule puts the uplink delay application or the uplink delay application time into the uplink delay application buffer area;
the fourth judgment submodule is used for judging whether the downlink instruction is overtime or not according to the overtime time after the second sending submodule sends the downlink instruction to the Bluetooth equipment through the operating system; after the second emptying submodule empties the uplink delay buffer area, judging whether the time is overtime according to overtime time;
the fifth judgment submodule is used for judging whether data exists in the uplink delay buffer area or not after the fourth judgment submodule judges that the data does not exist in the uplink delay buffer area;
the error reporting submodule is also used for returning an overtime error to the application module when the fourth judgment submodule judges that the result is positive;
the third judgment submodule is specifically used for judging whether data exist in the uplink response buffer area or not after the fifth judgment submodule judges that the data do not exist in the uplink response buffer area;
the sixth obtaining submodule is used for obtaining the uplink delay time according to the data in the uplink delay buffer area after the fifth judging submodule judges that the uplink delay time is up;
and the first resetting submodule is used for resetting the timeout time according to the uplink delay time.
And the second emptying submodule is used for emptying the uplink delay buffer after the first resetting submodule resets the timeout time.
In this embodiment, if the data processing module includes: the device comprises a second storage submodule 00, a first obtaining submodule 01, a first judging submodule 02, a first storage submodule 03, a first removing submodule 04, a second obtaining submodule 05, a first sending submodule 06, a second removing submodule 07, a second receiving submodule, a second sending submodule, a third obtaining submodule, a fourth obtaining submodule, a third judging submodule and an error reporting submodule; the data processing module may further include: a seventh obtaining submodule;
the second receiving submodule is also used for receiving a request for sending the downlink delay application from the application module;
a seventh obtaining sub-module, configured to obtain a downlink delay application according to the downlink delay application request;
and the second sending submodule is also used for sending the downlink delay application acquired by the seventh acquiring submodule to the Bluetooth device through the operating system.
Correspondingly, the application module comprises: a third sending submodule and a third receiving submodule;
the third sending submodule is used for sending a downlink instruction sending request and a downlink response sending request to the data processing module;
the third receiving submodule is used for receiving an uplink instruction result and an uplink response result from the data processing module;
and the third sending submodule is also used for sending a request for sending the downlink delayed application to the data processing module after the third receiving submodule receives the uplink instruction result and before sending a request for sending the downlink response to the data processing module.
In this embodiment, the third obtaining sub-module may be specifically configured to obtain the downlink instruction valid data from the downlink instruction sending request received by the second receiving sub-module, and organize the downlink instruction including the downlink instruction valid data according to a preset protocol; obtaining downlink response effective data from a downlink response sending request received by the second receiving submodule, and organizing downlink responses including the downlink response effective data according to a preset protocol;
the second obtaining submodule 05 may be specifically configured to obtain effective data in the uplink instruction after the first determining submodule 02 determines that the uplink data is the uplink instruction, and use the effective data in the uplink instruction as an uplink instruction result;
the fourth obtaining sub-module may be specifically configured to, after the third determining sub-module determines that the uplink response valid data in the uplink response is the uplink response result.
In this embodiment, the third obtaining sub-module may be further specifically configured to obtain a downlink instruction from the downlink instruction sending request received by the second receiving sub-module; obtaining a downlink response from a downlink response sending request received by the second receiving submodule;
the second obtaining submodule 05 may be further specifically configured to obtain valid data in the uplink instruction after the first determining submodule 02 determines that the uplink data is the uplink instruction, and use the uplink instruction as an uplink instruction result;
if the first storage submodule 03 puts the uplink response into the uplink response buffer, the fourth obtaining submodule may be further configured to, after the third determining submodule determines that the uplink response is positive, use the uplink response in the uplink response buffer as the uplink response result.
According to the mobile terminal provided by the embodiment, when the mobile terminal communicates with the same Bluetooth device, the mobile terminal can actively send a downlink instruction to the Bluetooth device and receive an uplink response from the Bluetooth device, and can passively respond to the uplink instruction from the Bluetooth device to communicate with the Bluetooth device, so that the accuracy and reliability of data of the mobile terminal in a data processing process can be ensured, the power consumption of the mobile terminal is saved, and the performance of the mobile terminal is optimized.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (34)

1. A method for processing Bluetooth data by a mobile terminal is characterized in that the mobile terminal comprises a data processing module, an application module and an operating system, a receiving buffer area of the data processing module is used for storing Bluetooth data received by the data processing module from Bluetooth equipment of the operating system, and the method comprises the following steps:
step A1: the data processing module acquires legal uplink data from the Bluetooth data in the receiving buffer area;
step A2: the data processing module judges the type of the uplink data, if the uplink data is an uplink response, the uplink response or uplink response effective data in the uplink response is put into an uplink response buffer area, and the uplink response in the receiving buffer area is removed; if the uplink data is an uplink instruction, obtaining an uplink instruction result according to the uplink instruction, sending the uplink instruction result to the application module, and removing the uplink instruction in the receiving buffer;
step S1: the data processing module waits for receiving the application data from the application module, and if a request for sending a downlink instruction from the application module is received, step S2 is executed; if a request for sending a downlink response is received from the application module, executing step S3;
step S2: the data processing module obtains a downlink instruction according to the request for sending the downlink instruction, sends the downlink instruction to the bluetooth device through the operating system, judges whether data exists in an uplink response buffer area, obtains an uplink response result according to the data in the uplink response buffer area if the data exists in the uplink response buffer area, returns the uplink response result to the application module, and returns to the step S1; otherwise, reporting an error;
step S3: and the data processing module obtains a downlink response according to the downlink response sending request, sends the downlink response to the Bluetooth device through the operating system, and returns to the step S1.
2. The method of claim 1, further comprising: the data processing module receives Bluetooth data from a Bluetooth device of an operating system and puts the Bluetooth data into the receiving buffer area;
the step a1 further includes:
step A0: the data processing module judges whether data exists in the receiving buffer area, if so, the step A1 is executed; otherwise, when the data processing module puts the bluetooth data into the receiving buffer, returning to step a 0;
after removing the uplink response in the receiving buffer, returning to step a 0;
and returning to the step A0 after the upstream instruction in the receiving buffer is removed.
3. The method according to claim 2, wherein step a1 is specifically: the data processing module starts to acquire uplink data from a first position in the receiving buffer area, judges whether legal uplink data is acquired or not, and executes the step A2 if the legal uplink data is acquired; otherwise, the data at the first position in the receiving buffer is removed, and the procedure returns to step a 0.
4. The method of claim 1, wherein step a1 is preceded by: the data processing module receives Bluetooth data from a Bluetooth device of an operating system and places the Bluetooth data into a receiving buffer.
5. The method according to claim 4, wherein the step A1 is specifically: the data processing module acquires uplink data in the receiving buffer area, judges whether legal uplink data is acquired or not, and executes the step A2 if the legal uplink data is acquired; otherwise, removing the data in the receiving buffer.
6. The method according to claim 2 or 4, wherein the data processing module receives bluetooth data from a bluetooth device of an operating system, specifically: the data processing module receives Bluetooth data from Bluetooth equipment of an operating system through a first callback function;
the sending of the uplink instruction result to an application module specifically includes: and the data processing module sends the uplink instruction result to an application module through a second callback function.
7. The method according to claim 1, wherein before the data processing module receives the request for sending the downlink command from the application module, the method further comprises: the application module sends the request for sending the downlink instruction to the data processing module;
after the data processing module returns the uplink instruction result to the application module, the method further includes: and the application module sends the downlink response sending request to the data processing module.
8. The method of claim 1, wherein before sending the downlink command to the bluetooth device via the operating system, the method further comprises: and emptying the uplink response buffer.
9. The method according to claim 1, 3 or 5, wherein the step A1 specifically comprises:
step A11: the data processing module acquires data at a first position in the receiving buffer area, judges whether the acquired data at the first position conform to a protocol header of a preset protocol, and if so, executes step A12; otherwise, removing the data at the first position in the receiving buffer and returning to the step A11;
step A12: the data processing module acquires current data to be verified and current check bit data from the receiving buffer area, judges whether the current data to be verified and the current check bit data conform to a preset protocol or not, if so, takes data between data at a first position in the receiving buffer area and the current check bit data as legal uplink data, and executes the step A2; otherwise, the data at the first position in the receiving buffer is removed, and the procedure returns to step a 11.
10. The method of claim 1, wherein after determining the type of uplink data, the method further comprises: and if the uplink data is the uplink notification, obtaining an uplink notification result according to the uplink notification, sending the uplink notification result to the application module, and removing the uplink notification in the receiving buffer.
11. The method according to claim 10, wherein the sending the uplink notification result to the application module specifically includes:
and the data processing module sends the uplink notification result to the application module through a third callback function.
12. The method according to claim 10, wherein the obtaining of the uplink notification result according to the uplink notification specifically includes: and the data processing module acquires the effective data in the uplink notification and takes the effective data in the uplink notification as an uplink notification result.
13. The method of claim 1, wherein after determining the type of uplink data, the method further comprises: if the uplink data is an uplink delay application, the uplink delay application is put into an uplink delay application buffer zone or uplink delay time is obtained according to the uplink delay application, and the uplink delay application time is put into the uplink delay buffer zone; removing the uplink delay application in the receiving buffer area;
after the downlink instruction is sent to the bluetooth device through the operating system, the data processing module determines whether there is data in the uplink response buffer before, further comprising:
step T1: the data processing module judges whether the time is overtime according to the overtime time, and if so, an overtime error is returned to the application module; otherwise, go to step T2;
step T2: the data processing module judges whether data exists in the uplink delay buffer area, if so, the step T3 is executed; otherwise, the data processing module judges whether the uplink response buffer area has data or not and continues;
step T3: and the data processing module obtains the uplink delay time according to the data in the uplink delay buffer, resets the overtime time according to the uplink delay time, empties the uplink delay buffer, and returns to the step T1.
14. The method according to claim 1, wherein the step S1 further comprises: and if receiving a downlink delay application sending request from the application module, the data processing module obtains a downlink delay application according to the downlink delay application sending request, sends the downlink delay application to the Bluetooth device through the operating system, and returns to the step S1.
15. The method according to claim 14, wherein after the application module receives the result of the uplink instruction and before the application module sends the request for sending the downlink response to the data processing module, the method further comprises: and the application module sends the request for sending the downlink delay application to the data processing module.
16. The method according to claim 1, wherein the data processing module obtains a downlink instruction according to the request for sending the downlink instruction, and specifically comprises: the data processing module obtains downlink instruction effective data from the downlink instruction sending request and organizes a downlink instruction comprising the downlink instruction effective data according to a preset protocol;
the data processing module obtains a downlink response according to the downlink response sending request, and specifically comprises the following steps: the data processing module obtains downlink response effective data from the downlink response sending request and organizes downlink response comprising the downlink response effective data according to a preset protocol;
the obtaining of the uplink instruction result according to the uplink instruction specifically includes: the data processing module acquires effective data in the uplink instruction, and takes the effective data in the uplink instruction as a result of the uplink instruction;
the obtaining of the uplink response result according to the data in the uplink response buffer area specifically includes: and the data processing module takes the uplink response effective data in the uplink response as an uplink response result.
17. The method according to claim 1, wherein the data processing module obtains a downlink instruction according to the request for sending the downlink instruction, and specifically comprises: the data processing module obtains a downlink instruction from the downlink instruction sending request;
the data processing module obtains a downlink response according to the downlink response sending request, and specifically comprises the following steps: the data processing module obtains a downlink response from the downlink response sending request;
the obtaining of the uplink instruction result according to the uplink instruction specifically includes: the data processing module takes the uplink instruction as the result of the uplink instruction;
if the data processing module in step a2 puts the uplink response into the uplink response buffer, obtaining an uplink response result according to the data in the uplink response buffer specifically includes: and the data processing module takes the uplink response in the uplink response buffer area as the uplink response result.
18. A mobile terminal is characterized by comprising a data processing module, an application module and an operating system;
the data processing module comprises: the device comprises a first obtaining submodule, a first judging submodule, a first storage submodule, a first removing submodule, a second obtaining submodule, a first sending submodule, a second removing submodule and a second storage submodule;
the second storage submodule is used for putting the Bluetooth data received by the data processing module from the Bluetooth device of the operating system into a receiving buffer area;
the first obtaining submodule is used for obtaining legal uplink data from the Bluetooth data in the receiving buffer area;
the first judging submodule is used for judging the type of the uplink data acquired by the first acquiring submodule;
the first storage submodule is configured to, after the first judgment submodule judges that the uplink data is an uplink response, place the uplink response or uplink response valid data in the uplink response into an uplink response buffer;
the first removing submodule is configured to remove the uplink response in the receiving buffer after the first storage submodule places the uplink response or the uplink response valid data in the uplink response into the uplink response buffer;
the second obtaining submodule is used for obtaining an uplink instruction result according to the uplink instruction after the first judging submodule judges that the uplink data is the uplink instruction;
the first sending submodule is used for sending the uplink instruction result obtained by the second obtaining submodule to the application module;
the second removing submodule is configured to remove the uplink instruction in the receiving buffer after the first sending submodule sends the uplink instruction result obtained by the second obtaining submodule to the application module;
the data processing module further comprises: the second receiving submodule, the second sending submodule, the third obtaining submodule, the fourth obtaining submodule, the third judging submodule and the error reporting submodule;
the second receiving submodule is used for receiving a downlink instruction sending request from the application module and receiving a downlink response sending request from the application module;
the third obtaining submodule is used for obtaining a downlink instruction according to the downlink instruction sending request received by the second receiving submodule; obtaining a downlink response according to the downlink response sending request received by the second receiving submodule;
the second sending submodule is configured to send the downlink instruction obtained by the third obtaining submodule to the bluetooth device through the operating system and send the downlink response obtained by the third obtaining submodule to the bluetooth device through the operating system;
the third judging submodule is used for judging whether data exists in the uplink response buffer area;
the error reporting submodule is used for reporting an error when the third judgment submodule judges that the error is negative;
the fourth obtaining submodule is used for obtaining an uplink response result according to the data in the uplink response buffer area when the third judging submodule judges that the data in the uplink response buffer area is positive;
the first sending submodule is further configured to return the uplink response result to the application module.
19. The mobile terminal of claim 18, wherein the data processing module further comprises a first receiving sub-module and a second determining sub-module;
the first receiving submodule is used for receiving Bluetooth data from a Bluetooth device of the operating system;
the second storage submodule is specifically configured to put the bluetooth data received by the first receiving submodule into a receiving buffer;
the second determining submodule is configured to determine whether data exists in the receiving buffer before the first obtaining submodule obtains legal uplink data from the bluetooth data in the receiving buffer, when the first removing submodule removes an uplink response in the receiving buffer, when the second removing submodule removes an uplink instruction in the receiving buffer, and when the second determining submodule determines that the data does not exist;
the first obtaining sub-module is specifically configured to obtain legal uplink data from the bluetooth data in the receiving buffer after the second determining module determines that the uplink data is valid.
20. The mobile terminal according to claim 19, wherein the first obtaining sub-module is specifically configured to obtain uplink data from data at a first position of a receive buffer; judging whether legal uplink data is acquired, and if so, acquiring the legal uplink data; otherwise, removing the data at the first position in the receiving buffer;
the first determining submodule is specifically configured to determine, when the first obtaining submodule determines that the uplink data obtained by the first obtaining submodule is of the uplink data type;
the second determining submodule is specifically configured to determine whether there is data in the receive buffer before the first obtaining submodule obtains uplink data from the bluetooth data in the receive buffer, after the first obtaining submodule removes data at a first position in the receive buffer, when the first removing submodule removes an uplink response in the receive buffer, when the second removing submodule removes an uplink instruction in the receive buffer, and when the second determining submodule determines that the data is not present.
21. The mobile terminal of claim 18, wherein the data processing module further comprises: a first receiving submodule;
the first receiving submodule is used for receiving Bluetooth data from a Bluetooth device of an operating system;
the second storage submodule is specifically configured to place the bluetooth data received by the first receiving submodule into a receiving buffer.
22. The mobile terminal according to claim 21, wherein the first obtaining sub-module is specifically configured to obtain uplink data in a receiving buffer, determine whether legal uplink data is obtained, and if so, obtain legal uplink data; otherwise, removing the data in the receiving buffer.
23. The mobile terminal according to claim 19 or 21, wherein the first receiving submodule is specifically configured to receive bluetooth data from a bluetooth device of the operating system through a first callback function;
the first sending submodule is specifically configured to send the uplink instruction result to the application module through a second callback function.
24. The mobile terminal of claim 18, wherein the application module comprises: a third sending submodule and a third receiving submodule;
the third sending submodule is configured to send the downlink instruction sending request and the downlink response sending request to the data processing module;
and the third receiving submodule is used for receiving the uplink instruction result and the uplink response result from the data processing module.
25. The mobile terminal of claim 18, wherein the data processing module further comprises: a first purge submodule;
the first clearing submodule is configured to clear an uplink response buffer before the second sending submodule sends the downlink instruction obtained by the third obtaining submodule to the bluetooth device through the operating system.
26. The mobile terminal according to claim 18, 20 or 22, wherein the first obtaining sub-module specifically comprises: the device comprises a first acquisition unit, a first judgment unit, a first removal unit, a second acquisition unit and a second judgment unit;
the first obtaining unit is used for obtaining data at a first position of the receiving buffer area;
the first judging unit is used for judging whether the data on the first position acquired by the first acquiring unit conforms to a protocol header of a preset protocol or not;
the second obtaining unit is configured to obtain current data to be verified and current check bit data from the receiving buffer when the first determining unit determines that the data is positive;
the second judging unit is configured to judge whether the current data to be verified and the current check bit data acquired by the second acquiring unit conform to a preset protocol, and if so, take data from the data at the first position in the receiving buffer to the current check bit data as legal uplink data;
the first removing unit is used for removing the data at the first position in the receiving buffer area when the first judging unit judges that the data is not received; and when the second judgment unit judges that the data is not received, removing the data at the first position in the receiving buffer area.
27. The mobile terminal of claim 18, wherein the data processing module further comprises: a fifth obtaining submodule and a third removing submodule;
the fifth obtaining submodule is configured to obtain an uplink notification result according to the uplink notification when the first judging submodule judges that the uplink data is the uplink notification;
the first sending submodule is further configured to send the uplink notification result obtained by the fifth obtaining submodule to an application module;
and the third removing submodule is used for removing the uplink notification in the receiving buffer after the first sending submodule sends the uplink notification result to the application module.
28. The mobile terminal of claim 27, wherein the first transmission sub-module comprises a first transmission unit and a second transmission unit;
the first sending unit is used for sending the uplink instruction result to an application module;
and the second sending unit is used for sending the uplink notification result to an application module through a third callback function.
29. The mobile terminal according to claim 27, wherein the fifth obtaining sub-module is specifically configured to, after the first determining sub-module determines that the uplink data is the uplink notification, obtain valid data in the uplink notification, and use the valid data in the uplink notification as an uplink notification result.
30. The mobile terminal of claim 18, wherein the data processing module further comprises: the first storage submodule, the second removal submodule, the fourth judgment submodule, the fifth judgment submodule, the sixth acquisition submodule, the first reset submodule and the second emptying submodule are connected in series;
the third storage submodule is configured to, when the first judgment submodule judges that the type of the uplink data is an uplink delay application, place the uplink delay application into an uplink delay application buffer or obtain uplink delay time according to the uplink delay application, and place the uplink delay application time into the uplink delay application buffer;
the fourth removing submodule is configured to remove the uplink delay application in the receiving buffer after the third storage submodule places the uplink delay application or the uplink delay application time in the uplink delay application buffer;
the fourth judging submodule is configured to judge whether the downlink instruction is overtime according to the overtime time after the second sending submodule sends the downlink instruction to the bluetooth device through the operating system; after the second emptying submodule empties the uplink delay buffer area, judging whether the time is overtime according to overtime time;
the fifth judging submodule is used for judging whether data exists in the uplink delay buffer area or not when the fourth judging submodule judges that the data does not exist in the uplink delay buffer area;
the error reporting submodule is further configured to return an overtime error to the application module when the fourth judgment submodule judges that the result is yes;
the third judging submodule is specifically configured to judge whether there is data in the uplink response buffer area when the fifth judging submodule judges that the uplink response buffer area does not have data;
the sixth obtaining submodule is configured to, when the fifth judging submodule judges that the uplink delay time is greater than the first threshold, obtain uplink delay time according to data in the uplink delay buffer;
the first resetting submodule is used for resetting the timeout time according to the uplink delay time;
and the second emptying submodule is used for emptying the uplink delay buffer after the first resetting submodule resets the timeout time.
31. The mobile terminal of claim 18, wherein the data processing module further comprises: a seventh obtaining submodule;
the second receiving submodule is also used for receiving a request for sending a downlink delay application from the application module;
the seventh obtaining sub-module is configured to obtain a downlink delay application according to the downlink delay application request;
and the second sending submodule is further configured to send the downlink delay application acquired by the seventh acquiring submodule to the bluetooth device through an operating system.
32. The mobile terminal of claim 31, wherein the application module comprises: a third sending submodule and a third receiving submodule;
the third sending submodule is configured to send the downlink instruction sending request and the downlink response sending request to the data processing module;
the third receiving submodule is configured to receive the uplink instruction result and the uplink response result from the data processing module;
and the third sending submodule is further configured to send the downlink delayed application sending request to the data processing module.
33. The mobile terminal according to claim 18, wherein the third obtaining sub-module is specifically configured to obtain downlink instruction valid data from the downlink instruction sending request received by the second receiving sub-module, and organize a downlink instruction including the downlink instruction valid data according to a preset protocol; obtaining downlink response effective data from the downlink response sending request received by the second receiving submodule, and organizing a downlink response comprising the downlink response effective data according to a preset protocol;
the second obtaining submodule is specifically configured to, when the first judging submodule judges that the uplink data is the uplink instruction, obtain valid data in the uplink instruction, and use the valid data in the uplink instruction as the uplink instruction result;
the fourth obtaining submodule is specifically configured to, when the third determining submodule determines that the uplink response result is the uplink response result, use the uplink response valid data in the uplink response as the uplink response result.
34. The mobile terminal according to claim 18, wherein the third obtaining sub-module is specifically configured to obtain a downlink instruction from the downlink instruction sending request received by the second receiving sub-module; obtaining a downlink response from the downlink response sending request received by the second receiving submodule;
the second obtaining submodule is specifically configured to, when the first judging submodule judges that the uplink data is the uplink instruction, obtain valid data in the uplink instruction, and use the uplink instruction as the uplink instruction result;
and if the first storage submodule puts the uplink response into an uplink response buffer, the fourth obtaining submodule is specifically configured to, when the third judging submodule judges that the uplink response is in the uplink response buffer, use the uplink response in the uplink response buffer as the uplink response result.
CN201711099974.XA 2017-11-09 2017-11-09 Mobile terminal and method for processing Bluetooth data Active CN107889089B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711099974.XA CN107889089B (en) 2017-11-09 2017-11-09 Mobile terminal and method for processing Bluetooth data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711099974.XA CN107889089B (en) 2017-11-09 2017-11-09 Mobile terminal and method for processing Bluetooth data

Publications (2)

Publication Number Publication Date
CN107889089A CN107889089A (en) 2018-04-06
CN107889089B true CN107889089B (en) 2020-06-02

Family

ID=61779961

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711099974.XA Active CN107889089B (en) 2017-11-09 2017-11-09 Mobile terminal and method for processing Bluetooth data

Country Status (1)

Country Link
CN (1) CN107889089B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111542034B (en) * 2020-04-27 2022-05-13 江苏联著实业股份有限公司 Collaborative management method and device for binary configuration teleconference

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102868802A (en) * 2011-07-08 2013-01-09 北京龙光科技有限公司 Data processing device, data processing adapting device and communication system
CN104182681A (en) * 2014-08-28 2014-12-03 北京软安科技有限公司 Hook-based iOS (iPhone operating system) key behavior detection device and detection method thereof
US9141504B2 (en) * 2012-06-28 2015-09-22 Apple Inc. Presenting status data received from multiple devices
CN105005540A (en) * 2015-05-22 2015-10-28 飞天诚信科技股份有限公司 CCID equipment with Bluetooth interface and working method of CCID equipment
CN106686535A (en) * 2017-01-23 2017-05-17 飞天诚信科技股份有限公司 Method and device for achieving low-power Bluetooth communication on IOS (iphone operation system)

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102868802A (en) * 2011-07-08 2013-01-09 北京龙光科技有限公司 Data processing device, data processing adapting device and communication system
US9141504B2 (en) * 2012-06-28 2015-09-22 Apple Inc. Presenting status data received from multiple devices
CN104182681A (en) * 2014-08-28 2014-12-03 北京软安科技有限公司 Hook-based iOS (iPhone operating system) key behavior detection device and detection method thereof
CN105005540A (en) * 2015-05-22 2015-10-28 飞天诚信科技股份有限公司 CCID equipment with Bluetooth interface and working method of CCID equipment
CN106686535A (en) * 2017-01-23 2017-05-17 飞天诚信科技股份有限公司 Method and device for achieving low-power Bluetooth communication on IOS (iphone operation system)

Also Published As

Publication number Publication date
CN107889089A (en) 2018-04-06

Similar Documents

Publication Publication Date Title
WO2019228369A1 (en) Message processing method and related product
CN110267314B (en) Method and device for switching network slices
TW200904139A (en) Providing event-controlled continuous logging for a mobile operating environment
US9876744B2 (en) Information sending method and information sending apparatus
CN109495875B (en) SIM card selection method and device, electronic equipment and storage medium
US20150363182A1 (en) Smart device, wearable device and method for pushing &receiving installation package
US20190150041A1 (en) Access point handover method and device
CN110505516A (en) A kind of throwing screen control method, device and system
CN107889089B (en) Mobile terminal and method for processing Bluetooth data
CN109728879B (en) Synchronous error correction method for serial burst access application layer SLIP protocol message
CN110098884A (en) Determine exception clock
US20090077665A1 (en) Method and applications for detecting computer viruses
CN104239790B (en) Treatment method of virus and device
CN103152464B (en) Equipment, method and system of obtaining fixed phone calling information through wireless way
CN111371536B (en) Control instruction sending method and device
CN112565105A (en) Method, device and equipment for reducing time-sensitive frame forwarding time delay
CN105704210B (en) Charging pile information updating method and system
US8451993B2 (en) Dial-up connection method and device of mobile data terminal
CN109766347B (en) Data updating method, device, system, computer equipment and storage medium
EP3573306A1 (en) Data processing method and device utilized in client terminal
CN101778055B (en) Message processing method and network entity
EP2916523B1 (en) Data stream and data packet transmission method and device
US11435999B2 (en) Method and apparatus for upgrading software
CN115348254B (en) File packing and downloading method and device, electronic equipment and storage medium
WO2015100662A1 (en) Data processing method, device and system

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