Bluetooth data transmission architecture, method, equipment and device based on Android system
By setting up data processing, transmission and protocol modules at the hal layer of the Android system, the problem of data transmission through Bluetooth after cutting Java virtual machines is solved, and Bluetooth data transmission without Java virtual machines is realized, reducing system burden and cost.
Patent Information
- Application Number
- CN202211149422.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-21
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2042-09-21
AI Technical Summary
Because the Java virtual machine in the Android system is cut off, the device cannot achieve data transmission through Bluetooth.
The data processing module, data transmission module and protocol module are set up in the hal layer. After extracting the data in the file descriptor, parsing, processing and encapsulating it, the data is written to the file descriptor to realize Bluetooth data transmission.
Bluetooth data transmission is achieved without using Java virtual machines, reducing system burden and R&D costs.
Smart Images

Figure CN115633105B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to an Android-based Bluetooth data transmission architecture, method, equipment and device. Background Art
[0002] With the rapid development of Android system, Android system has been applied in more and more fields and has become the mainstream operation of smart devices.
[0003] In the Android system, human-computer interaction is achieved through the Java virtual machine. However, in order to save costs or meet the needs of the product itself, many products will cut out the Java virtual machine in the Android system. Since the Bluetooth transmission protocol is all in the Java virtual machine, the device will not be able to operate Bluetooth, let alone send and receive data via Bluetooth.
[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present invention is to provide a Bluetooth data transmission architecture, method, device and apparatus based on the Android system, aiming to solve the technical problem that data transmission cannot be achieved via Bluetooth due to cutting out the Java virtual machine in the Android system.
[0006] To achieve the above object, the present invention provides a Bluetooth data transmission architecture based on the Android system, the architecture includes: a hal layer, and the hal layer includes: a data processing module, a protocol module and a data transmission module;
[0007] The data transmission module is used to extract the data in the file descriptor and transmit the data to the protocol module;
[0008] The protocol module is used to parse the data according to the flag bit and transmit the parsed data to the data processing module;
[0009] The data processing module is used to process the parsed data and transmit the processed data to the protocol module upon receiving a data sending instruction;
[0010] The protocol module is further used to encapsulate the processed data according to the Bluetooth transmission protocol and transmit the encapsulated data to the data transmission module;
[0011] The data transmission module is further used to write the encapsulated data into the file descriptor.
[0012] To achieve the above object, the present invention further proposes a Bluetooth data transmission method based on the Bluetooth data transmission architecture of the Android system, characterized in that the method comprises the following steps:
[0013] Extracting data from the file descriptor and parsing the data according to the flag bit;
[0014] Process the parsed data and encapsulate the processed data according to the Bluetooth transmission protocol;
[0015] Write the encapsulated data to the file descriptor.
[0016] Optionally, the step of processing the parsed data and encapsulating the processed data according to the Bluetooth transmission protocol includes:
[0017] When the data in the file descriptor is file type data, the parsed data is written into the target file in sequence and the target file is stored in the target path;
[0018] Upon receiving a data transmission instruction, converting the data in the target file into an array and transmitting the array in batches according to preset bytes;
[0019] The array is encapsulated by a flag bit, data size, and connection ID according to the Bluetooth transmission protocol.
[0020] Optionally, the step of processing the parsed data and encapsulating the processed data according to the Bluetooth transmission protocol further includes:
[0021] When the data in the file descriptor is information data, converting the parsed data into a character string;
[0022] When the data sending instruction is received, the character string is converted into binary data and the binary data is encapsulated through a flag bit, data size and connection ID according to the Bluetooth transmission protocol.
[0023] Optionally, the step of extracting data from the file descriptor and parsing the data according to the flag bit includes:
[0024] Loop to extract the data in the file descriptor;
[0025] When the data in the file descriptor is file type data, the plain text data corresponding to the data is acquired in batches according to the flag bit.
[0026] Optionally, the step of writing the encapsulated data into the file descriptor comprises:
[0027] Upon receiving the data sending instruction, obtaining the file descriptor through the Bluetooth interface;
[0028] The encapsulated data is written to the file descriptor in batches.
[0029] Optionally, before the step of extracting the data in the file descriptor and parsing the data according to the flag bit, the step further includes:
[0030] When establishing a connection with the target device, obtaining the file descriptor;
[0031] Acquire data transmitted by the target device, and write the data into the file descriptor.
[0032] In addition, to achieve the above-mentioned purpose, the present invention also proposes a Bluetooth data transmission device, which includes a memory, a processor, and a Bluetooth data transmission program stored in the memory and run on the processor, and the Bluetooth data transmission program is configured to implement the Bluetooth data transmission method described above.
[0033] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a Bluetooth data transmission program is stored, and when the Bluetooth data transmission program is executed by a processor, the Bluetooth data transmission method as described above is implemented.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also proposes a Bluetooth data transmission device, which includes: a data parsing module, a data processing module and a data storage module;
[0035] The data parsing module is used to extract the data in the file descriptor and parse the data according to the flag bit;
[0036] The data processing module is used to process the parsed data and encapsulate the processed data according to the Bluetooth transmission protocol;
[0037] The data storage module is used to write the encapsulated data into the file descriptor.
[0038] The present invention extracts data in a file descriptor through a data transmission module and transmits the data to a protocol module; the protocol module parses the data according to a flag bit and transmits the parsed data to a data processing module; the data processing module processes the parsed data and transmits the processed data to the protocol module when receiving a data sending instruction; the protocol module encapsulates the processed data according to a Bluetooth transmission protocol and transmits the encapsulated data to the data transmission module; the data transmission module writes the encapsulated data into a file descriptor. The present invention sets a data processing module, a data transmission module and a protocol module at the hal layer, the protocol module parses the data, and the data processing module processes the parsed data, so that data transmission via Bluetooth can be realized without using the framework layer of a Java virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a structural diagram of an embodiment of a Bluetooth data transmission architecture based on an Android system of the present invention;
[0040] Figure 2 A schematic diagram of a flow chart of a first embodiment of a Bluetooth data transmission method according to the present invention;
[0041] Figure 3 A schematic diagram of a flow chart of a second embodiment of a Bluetooth data transmission method according to the present invention;
[0042] Figure 4 A schematic diagram of a flow chart of a third embodiment of a Bluetooth data transmission method according to the present invention;
[0043] Figure 5 It is a structural block diagram of the first embodiment of the Bluetooth data transmission device of the present invention.
[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the phase position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture is changed, the directional indication will also change accordingly.
[0047] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0048] Reference Figure 1 , Figure 1 This is a structural diagram of an embodiment of a Bluetooth data transmission architecture based on an Android system of the present invention.
[0049] like Figure 1 The Bluetooth data transmission architecture based on the Android system includes: a HAL layer, and the HAL layer includes: a data processing module 30, a protocol module 40 and a data transmission module 50.
[0050] The data transmission module 30 is used to extract the data in the file descriptor and transmit the data to the protocol module 40 .
[0051] It should be understood that with the rapid development of the Android system, the Android system has been applied to more and more fields and has become the mainstream operating system for smart devices. At the same time, according to the different needs of smart devices, manufacturers will tailor the Android system according to the functions of the products. For example, smart speakers, smart water cups, and some car systems do not need to interact with users through the screen, but only through simple indicator lights and buttons. The main role of the Java virtual machine in the Android system is to allow users to have friendly interactions with devices and facilitate users to operate the devices. However, in some smart devices, the entire Java virtual machine is enabled only for a few indicator lights and buttons. This undoubtedly increases the burden on the system, increases R&D costs, and increases the cost of the product itself, which is obviously not cost-effective. However, cutting out the entire Java virtual machine of the Android system means that users cannot interact with the device, and only convenient information transmission is required, and users cannot actively operate the system. For example, for smart Bluetooth speakers, users can only simply turn on and off Bluetooth through buttons, and then use other devices (such as mobile phones) to connect to it. The speaker cannot actively connect to the mobile phone or scan nearby devices. This is a one-sided operating system. Of course, for Bluetooth speakers, the above methods are sufficient to meet the system functions. But for other smart devices, such as the dashcam with Android system, it does not need to have too much interaction with the user, and the Java virtual machine of the Android system can be cut off, but the recorded video files need to be transmitted to other devices, or the dashcam's own status information needs to be sent to other devices. At this time, the dashcam cannot wirelessly transmit the files and status information to other devices via Bluetooth. For another example, some devices are composed of multiple sub-devices, and the systems of these sub-devices may be Android system, Linux system or even computer. When a device with Android system needs to transmit data to other devices via Bluetooth wirelessly, or receive data sent by other devices, the Java virtual machine of the Android system must be enabled. The entire Java virtual machine consumes a lot of power and resources. It is obviously not cost-effective to enable the Java virtual machine just for sending and receiving data. Without the Java virtual machine, Bluetooth transmission cannot be realized because the relevant Bluetooth transmission protocols are all in the Java virtual machine.
[0052] In order to overcome the above-mentioned defects, this embodiment extracts the data in the file descriptor through the data transmission module 50, and transmits the data to the protocol module 40. After receiving the data, the protocol module 40 parses the data according to the flag bit, and then transmits the parsed data to the data processing module 30. The data processing module 30 processes the parsed data, and after receiving the data sending instruction, transmits the processed data to the protocol module 40 again. The protocol module 40 encapsulates the processed data, and then transmits the encapsulated data to the data transmission module 50, and the data transmission module 50 writes the encapsulated data into the file descriptor.
[0053] It should be noted that the Android system is divided into application layer, application framework layer, system runtime layer, hal layer and kernel layer. Many products do not implement much human-computer interaction, so the application framework layer and above will be deleted, and the Bluetooth transmission protocol is stored in the application framework layer. Deleting the application framework layer will make simple data transmission impossible. This embodiment adds various modules in the hal layer and writes the Bluetooth transmission protocol to the hal layer. Data can be transmitted via Bluetooth even in a virtual machine without an Android system.
[0054] It should be noted that the present embodiment includes not only a data processing module 30, a protocol module 40 and a data transmission module 50, but also an operation module 10 and a Bluetooth monitoring module 20. The operation module 10 can switch Bluetooth on and off, scan attached Bluetooth devices, connect Bluetooth devices, display connected devices, disconnect connected devices, device Bluetooth visibility, restore Bluetooth to factory settings and send data, and the Bluetooth monitoring module 20 can monitor whether surrounding devices are connected to itself and respond, and after establishing a connection with the device, when receiving data sent by the device, obtain a file descriptor, and then transmit the file descriptor to the data transmission module.
[0055] It can be understood that the data transmission module 50 is used to receive the file descriptor transmitted by the Bluetooth monitoring module 20 and transmit it to the protocol module 40, and write the data encapsulated by the protocol module 40 into the file descriptor.
[0056] It should be noted that when acquiring or creating a new file, the kernel in the Android system will return a file descriptor, and the file descriptor is also needed to specify the file to be read or written when reading or writing a file. The file descriptor can be regarded as a channel. When the Bluetooth monitoring module 20 acquires the data sent by the device, the data is transmitted to the data transmission module 50 through the file descriptor, and the data transmission module 50 extracts the data in the file descriptor.
[0057] It is understandable that the data in the file descriptor can be a file or information. The file can be a picture, audio, video, etc., and the information can be text, etc., which is not limited in this embodiment.
[0058] It is understandable that the data transmission module 50 will cyclically extract the data in the file descriptor until all the data in the file descriptor are extracted.
[0059] The protocol module 40 is used to parse the data according to the flag bit and transmit the parsed data to the data processing module 30 .
[0060] It should be noted that the flag bit can be used to obtain relevant information in the data, and different flag bits correspond to different information in the data. For example, the data size, data type or data content corresponding to the flag bit can be obtained according to the flag bit.
[0061] It is understandable that the protocol module 40 parses the data according to the flag bit to obtain binary data.
[0062] It should be noted that the parsing method of the protocol module 40 is different for different data types. For example, if the parsed data is file type data, the data will be parsed in batches, and the data will be sent to the data processing module 30 each time it is parsed. If the parsed data is information data, all the data will be parsed at one time and sent to the data processing module 30.
[0063] The data processing module 30 is used to process the parsed data and transmit the processed data to the protocol module 40 upon receiving a data sending instruction.
[0064] It should be noted that the data processing module 30 processes data differently for different data types. For example, if file type data is received, the parsed data will be written to the file in sequence and the file will be saved. If information data is received, the data will be converted into a string, which can be sent to other modules or printed out.
[0065] It is understandable that the data processing module 30 needs to process both the received data and the data sent to the protocol module 40 .
[0066] It should be noted that after receiving the data sending instruction, if the data to be sent is file type data, the data stored in the file will be converted into binary data and transmitted to the protocol module 40 in batches until the data transmission is completed. If the data to be sent is information data, the data will also be converted into binary data and then transmitted to the protocol module 40 at one time.
[0067] The protocol module 40 is further configured to encapsulate the processed data according to the Bluetooth transmission protocol and transmit the encapsulated data to the data transmission module 50 .
[0068] It is understandable that the Bluetooth transmission protocol is stored in the protocol module 40, and when data needs to be encapsulated, the data will be encapsulated according to the Bluetooth transmission protocol.
[0069] It should be noted that the Bluetooth transmission protocol in the protocol module 40 is not equivalent to the Bluetooth transmission protocol in the application framework layer. The Bluetooth transmission protocol in the protocol module 40 is a brand new transmission protocol written by itself without the help of any library.
[0070] In a specific implementation, a corresponding flag bit, data size, connection ID, etc. are added to the data, the data is encapsulated according to the Bluetooth transmission protocol, namely, the obex protocol, and the encapsulated data is then transmitted to the data transmission module 50 .
[0071] The data transmission module 50 is further configured to write the encapsulated data into the file descriptor.
[0072] It should be noted that when the operating module 10 sends a data sending instruction, the data transmission module 50 will write the encapsulated data into the file descriptor.
[0073] It is understandable that each time the protocol module 40 transmits data, the data transmission module 50 will write the data into the file descriptor.
[0074] In this embodiment, the data in the file descriptor is extracted by the data transmission module and the data is transmitted to the protocol module; the protocol module parses the data according to the flag bit and transmits the parsed data to the data processing module; the data processing module processes the parsed data and transmits the processed data to the protocol module when receiving the data sending instruction; the protocol module encapsulates the processed data according to the Bluetooth transmission protocol and transmits the encapsulated data to the data transmission module; the data transmission module writes the encapsulated data into the file descriptor. The present invention sets a data processing module, a data transmission module and a protocol module at the hal layer. The protocol module parses the data, and the data processing module processes the parsed data, so that data transmission via Bluetooth can be realized without using the framework layer of the Java virtual machine.
[0075] In addition, the embodiment of the present invention also provides a Bluetooth data transmission method. Figure 2 , Figure 2 The first embodiment of the Bluetooth data transmission method of the present invention is a flowchart of the first embodiment of the Bluetooth data transmission method of the present invention.
[0076] In this embodiment, the Bluetooth data transmission method includes the following steps:
[0077] Step S10: extract the data in the file descriptor, and parse the data according to the flag bit.
[0078] It should be noted that the execution subject of this embodiment can be a computer software device with data processing, network communication and program running functions, such as a mobile phone, a computer, etc., or other electronic devices that can achieve the same or similar functions. This embodiment does not impose any restrictions on this.
[0079] It can be understood that after establishing a connection with the device, a file descriptor will be obtained, and the device will transfer data to the file descriptor.
[0080] It should be understood that the device extracts data from the file descriptor each time it transmits until the data extraction in the file descriptor is completed.
[0081] Furthermore, in order to allow the computer to process data, step S10 in this embodiment may include:
[0082] Loop to extract the data in the file descriptor;
[0083] When the data in the file descriptor is file type data, the plain text data corresponding to the data is acquired in batches according to the flag bit.
[0084] It should be noted that the corresponding data content is obtained according to the flag bit. The data not only includes the content of the data, but also the data type, data size, etc., which can all be obtained according to the corresponding flag bit.
[0085] It is understandable that different data types correspond to different parsing methods. If it is file type data, the data is parsed in batches, that is, different data is obtained in batches according to the flag bit and plain text data is obtained.
[0086] Furthermore, in order to obtain the data to be transmitted, step S10 of this embodiment may further include:
[0087] When establishing a connection with the target device, obtaining the file descriptor;
[0088] Acquire data transmitted by the target device, and write the data into the file descriptor.
[0089] It is understandable that before establishing a connection with a target device, it is necessary to scan nearby Bluetooth devices, and when a device is detected to be connected, a connection is established with it.
[0090] It should be noted that when the device sends data, it will obtain the file descriptor and write the data into the file descriptor.
[0091] Step S20: Process the parsed data and encapsulate the processed data according to the Bluetooth transmission protocol.
[0092] It should be noted that different data types have different data processing methods. When the data type is file type data, the data is written into the file in order and the file is saved to the specified path. When a data sending instruction is received, the data in the file is converted into binary data and the binary data is encapsulated through the Bluetooth transmission protocol. When the file type data is information data, the data is converted into a string. When a data sending instruction is received, the string is converted into binary data and the binary data is encapsulated according to the Bluetooth transmission protocol.
[0093] It should be noted that the processed data is encapsulated according to the Bluetooth transmission protocol, that is, information such as a flag bit, data size, and connection ID are added to the processed data, and then encapsulated according to the Bluetooth transmission protocol.
[0094] Step S30: writing the encapsulated data into the file descriptor.
[0095] It can be understood that the encapsulated data can be transmitted to the device through the file descriptor to realize data transmission.
[0096] It can be understood that each time the data is encapsulated, the encapsulated book needs to be written into the file descriptor.
[0097] Furthermore, in order to achieve data transmission via Bluetooth, step S30 in this embodiment may include:
[0098] Upon receiving the data sending instruction, obtaining the file descriptor through the Bluetooth interface;
[0099] The encapsulated data is written to the file descriptor in batches.
[0100] It is understandable that, since the data is packaged in batches, the packaged data needs to be written into the file descriptor each time it is packaged.
[0101] This embodiment extracts data from the file descriptor, parses the data according to a flag bit, processes the parsed data, encapsulates the processed data according to a Bluetooth transmission protocol, and writes the encapsulated data into the file descriptor; this embodiment parses the data according to a flag bit, encapsulates the parsed data through a Bluetooth transmission protocol, and writes the encapsulated data into the file descriptor, and can transmit data via Bluetooth without using the framework layer of a Java virtual machine.
[0102] Reference Figure 3 , Figure 3 This is a flow chart of a second embodiment of a Bluetooth data transmission method according to the present invention. Figure 2 The first embodiment shown provides a second embodiment of the Bluetooth data transmission method of the present invention.
[0103] In the second embodiment, the step 20 includes:
[0104] Step S201: when the data in the file descriptor is file type data, the parsed data is written into a target file in sequence and the target file is stored in a target path.
[0105] It is understandable that different data types correspond to different data processing methods, and the file type database can be pictures, videos, audios, etc., which is not limited in this embodiment.
[0106] It is understandable that the target file and target path can be specified or stored by the system itself.
[0107] Step S202: upon receiving a data transmission instruction, converting the data in the target file into an array and transmitting the array in batches according to preset bytes.
[0108] It should be understood that the data sending instruction is sent by the operation module of the hal layer.
[0109] It is understandable that the preset bytes can be specified, for example, 8030 bytes are transmitted, and this embodiment does not limit this.
[0110] It is understandable that, since the transmission is performed according to the preset bytes, the preset bytes may not be able to contain all the data at once, so it needs to be transmitted in batches.
[0111] It should be noted that if the preset number of bytes is not reached during the last transmission, the preset number of bytes may be modified according to the actual number of bytes.
[0112] Step S203: encapsulating the array through a flag bit, data size and connection ID according to the Bluetooth transmission protocol.
[0113] It is understandable that the flag is added to facilitate the acquisition of relevant data information when the data is parsed again.
[0114] In this embodiment, when the data in the file descriptor is file type data, the parsed data is written into the target file in order and the target file is stored in the target path. When a data sending instruction is received, the data in the target file is converted into an array and the array is transmitted in batches according to preset bytes, and the array is encapsulated according to the Bluetooth transmission protocol through a flag bit, data size, and connection ID. In this embodiment, the parsed data is written into the target file for storage, the data in the target file is converted into an array for batch transmission, and the array is encapsulated according to the Bluetooth transmission protocol. Since different data processing methods are adopted for different data types, the efficiency of data processing is improved.
[0115] Reference Figure 4 , Figure 4 This is a flow chart of a third embodiment of a Bluetooth data transmission method according to the present invention. Figure 2 The first embodiment shown provides a third embodiment of the Bluetooth data transmission method of the present invention.
[0116] In the third embodiment, the step 20 further includes:
[0117] Step S201': when the data in the file descriptor is information data, convert the parsed data into a character string.
[0118] It is understandable that the information data may be text, and is written into the file descriptor in the form of text.
[0119] It should be noted that the information data is parsed to obtain binary data, which needs to be converted into a string.
[0120] It should be noted that the converted character string can be processed and transmitted to the protocol module, or it can be printed out.
[0121] Step S202 ′: upon receiving the data sending instruction, convert the character string into binary data and encapsulate the binary data through a flag bit, data size and connection ID according to the Bluetooth transmission protocol.
[0122] It can be understood that after the character string is converted into binary data, the binary data is transmitted at one time.
[0123] It is understandable that, since the binary data is transmitted at one time, the binary data is also encapsulated at one time according to the Bluetooth transmission protocol through the flag bit, data size and connection ID.
[0124] In this embodiment, when the data in the file descriptor is information data, the parsed data is converted into a string, and when the data sending instruction is received, the string is converted into binary data and the binary data is encapsulated according to the Bluetooth transmission protocol through a flag, data size, and connection ID. In this embodiment, the parsed data is converted into a string, and when the data is transmitted, the string is converted into binary data and the binary data is encapsulated according to the Bluetooth transmission protocol. Since different data processing methods are adopted for different data types, the efficiency of data processing is improved.
[0125] In addition, an embodiment of the present invention further provides a storage medium, on which a Bluetooth data transmission program is stored. When the Bluetooth data transmission program is executed by a processor, the Bluetooth data transmission method as described above is implemented.
[0126] In addition, refer to Figure 5 , the embodiment of the present invention further provides a Bluetooth data transmission device, the Bluetooth data transmission device comprising: a data parsing module 10, a data processing module 20 and a data storage module 30;
[0127] The data parsing module 10 is used to extract the data in the file descriptor and parse the data according to the flag bit;
[0128] The data processing module 20 is used to process the parsed data and encapsulate the processed data according to the Bluetooth transmission protocol;
[0129] The data storage module 30 is used to write the encapsulated data into the file descriptor.
[0130] This embodiment extracts data from the file descriptor, parses the data according to a flag bit, processes the parsed data, encapsulates the processed data according to a Bluetooth transmission protocol, and writes the encapsulated data into the file descriptor; this embodiment parses the data according to a flag bit, encapsulates the parsed data through a Bluetooth transmission protocol, and writes the encapsulated data into the file descriptor, and can transmit data via Bluetooth without using the framework layer of a Java virtual machine.
[0131] Based on the above-mentioned first embodiment of the Bluetooth data transmission device of the present invention, a second embodiment of the Bluetooth data transmission device of the present invention is proposed.
[0132] In this embodiment, the data processing module 20 is used to write the parsed data into the target file in sequence and store the target file in the target path when the data in the file descriptor is file type data.
[0133] Furthermore, the data processing module 20 is also used to convert the data in the target file into an array and transmit the array in batches according to preset bytes when receiving a data sending instruction.
[0134] Furthermore, the data processing module 20 is further configured to encapsulate the array through a flag bit, data size and connection ID according to the Bluetooth transmission protocol.
[0135] Furthermore, the data processing module 20 is also used to convert the parsed data into a character string when the data in the file descriptor is information data.
[0136] Furthermore, the data processing module 20 is further configured to convert the character string into binary data and encapsulate the binary data through a flag bit, data size and connection ID according to the Bluetooth transmission protocol when receiving the data sending instruction.
[0137] Furthermore, the data parsing module 10 is also used to cyclically extract data in the file descriptor.
[0138] Furthermore, the data parsing module 10 is also used to obtain the plain text data corresponding to the data in batches according to the flag bit when the data in the file descriptor is file type data.
[0139] Furthermore, the data storage module 30 is further configured to obtain the file descriptor via a Bluetooth interface when receiving the data sending instruction.
[0140] Furthermore, the data storage module 30 is also used to write the encapsulated data into the file descriptor in batches.
[0141] Furthermore, the data parsing module 10 is also used to obtain the file descriptor when establishing a connection with the target device.
[0142] Furthermore, the data parsing module 10 is also used to obtain the data transmitted by the target device and write the data into the file descriptor.
[0143] Other embodiments or specific implementations of the Bluetooth data transmission device of the present invention may refer to the above-mentioned method embodiments, which will not be described in detail here.
[0144] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0145] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0147] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A Bluetooth data transmission device based on Android system, characterized in that: The device comprises: a hal layer, and the hal layer comprises: a data processing module, a protocol module and a data transmission module; The data transmission module is used to extract the data in the file descriptor and transmit the data to the protocol module; The protocol module is used to parse the data according to the flag bit and transmit the parsed data to the data processing module; The data processing module is used to process the parsed data and transmit the processed data to the protocol module upon receiving a data sending instruction; The protocol module is further used to encapsulate the processed data according to the Bluetooth transmission protocol and transmit the encapsulated data to the data transmission module; The data transmission module is further used to write the encapsulated data into the file descriptor.
2. A Bluetooth data transmission method based on the Android-based Bluetooth data transmission device according to claim 1, characterized in that: The method comprises the following steps: Extracting data from the file descriptor and parsing the data according to the flag bit; Process the parsed data and encapsulate the processed data according to the Bluetooth transmission protocol; Write the encapsulated data to the file descriptor.
3. The Bluetooth data transmission method according to claim 2, characterized in that: The step of processing the parsed data and encapsulating the processed data according to the Bluetooth transmission protocol includes: When the data in the file descriptor is file type data, the parsed data is written into the target file in sequence and the target file is stored in the target path; Upon receiving a data transmission instruction, converting the data in the target file into an array and transmitting the array in batches according to preset bytes; The array is encapsulated by a flag bit, data size, and connection ID according to the Bluetooth transmission protocol.
4. The Bluetooth data transmission method according to claim 2, characterized in that: The step of processing the parsed data and encapsulating the processed data according to the Bluetooth transmission protocol also includes: When the data in the file descriptor is information data, converting the parsed data into a character string; When the data sending instruction is received, the character string is converted into binary data and the binary data is encapsulated through a flag bit, data size and connection ID according to the Bluetooth transmission protocol.
5. The Bluetooth data transmission method according to claim 2, characterized in that: The step of extracting the data in the file descriptor and parsing the data according to the flag bit includes: Loop to extract the data in the file descriptor; When the data in the file descriptor is file type data, the plain text data corresponding to the data is acquired in batches according to the flag bit.
6. The Bluetooth data transmission method according to claim 2, characterized in that: The step of writing the encapsulated data into the file descriptor comprises: Upon receiving the data sending instruction, obtaining the file descriptor through the Bluetooth interface; The encapsulated data is written to the file descriptor in batches.
7. The Bluetooth data transmission method according to any one of claims 2 to 6, characterized in that: Before the step of extracting the data in the file descriptor and parsing the data according to the flag bit, the method further includes: When establishing a connection with the target device, obtaining the file descriptor; Acquire data transmitted by the target device, and write the data into the file descriptor.
8. A Bluetooth data transmission device, characterized in that: The Bluetooth data transmission setting includes: a memory, a processor, and a Bluetooth data transmission program stored in the memory and executable on the processor. When the Bluetooth data transmission program is executed by the processor, the steps of the Bluetooth data transmission method according to any one of claims 2 to 7 are implemented.
9. A storage medium, characterized in that: The storage medium stores a Bluetooth data transmission program, and when the Bluetooth data transmission program is executed by the processor, the steps of the Bluetooth data transmission method according to any one of claims 2 to 7 are implemented.
Citation Information
Patent Citations
Method for porting android Bluetooth protocol stack to Mint17 system
CN105893038A
Method enabling Android smart device to quickly connect with Bluetooth
CN106412656A