CN111885560A - Bluetooth communication method and device, storage medium and electronic device - Google Patents
Bluetooth communication method and device, storage medium and electronic device Download PDFInfo
- Publication number
- CN111885560A CN111885560A CN202010621879.7A CN202010621879A CN111885560A CN 111885560 A CN111885560 A CN 111885560A CN 202010621879 A CN202010621879 A CN 202010621879A CN 111885560 A CN111885560 A CN 111885560A
- Authority
- CN
- China
- Prior art keywords
- data
- bluetooth
- target terminal
- bluetooth communication
- communication middleware
- 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.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/80—Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L5/00—Arrangements affording multiple use of the transmission path
- H04L5/14—Two-way operation using the same type of signal, i.e. duplex
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Signal Processing (AREA)
- Computer Networks & Wireless Communication (AREA)
- Computer Security & Cryptography (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a Bluetooth communication method and device, a storage medium and an electronic device. Wherein, the method comprises the following steps: analyzing first data issued by a target terminal through a Bluetooth communication middleware; the Bluetooth communication middleware writes the first data into the Bluetooth equipment through the address indicated by the first data and acquires second data which is transmitted by the Bluetooth equipment and corresponds to the first data, wherein the second data is second data transmitted by the Bluetooth equipment according to the address indicated by the first data, the Bluetooth communication middleware is a communication interface for communicating between a target terminal and the Bluetooth equipment, and is used for analyzing the data transmitted from the target terminal to the Bluetooth equipment and analyzing the data transmitted from the Bluetooth equipment to the target terminal; and the Bluetooth communication middleware reports the second data to the target terminal. By adopting the technical scheme, the technical problems that the Bluetooth cannot be quickly docked for communication and the development difficulty of developers is high in the related technology are solved.
Description
Technical Field
The invention relates to the field of computers, in particular to a Bluetooth communication method and device, a storage medium and an electronic device.
Background
At present, with the communication mode of intelligent household appliances becoming richer and richer, bluetooth low energy (ble) communication starts to be used continuously on a large scale, however, the existing software communication architecture and communication model are based on a full-duplex single channel similar to socket communication. Therefore, the Bluetooth is accessed, so that the Bluetooth has multiple channels and a simplex communication channel, great impact on the existing software is caused, the difficulty of the existing software in butting Bluetooth ble is increased, and meanwhile, the development difficulty of developers is increased.
Therefore, the problem that in the related art, the bluetooth device cannot be quickly docked for communication, and the development difficulty of developers is high is solved.
Disclosure of Invention
The embodiment of the invention provides a Bluetooth communication method and device, a storage medium and an electronic device, which are used for at least solving the technical problems that Bluetooth equipment cannot be quickly docked for communication and developers have high development difficulty in the related technology.
According to an aspect of an embodiment of the present invention, there is provided a bluetooth communication method, including: the bluetooth communication middleware writes the first data into a bluetooth device through an address indicated by the first data, and acquires second data corresponding to the first data, wherein the second data is transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for communicating between the target terminal and the bluetooth device, the bluetooth communication middleware is used for analyzing data transmitted by the target terminal to the bluetooth device and analyzing data transmitted by the bluetooth device to the target terminal, and the bluetooth communication middleware is used for transmitting data transmitted by the target terminal to the bluetooth device and transmitting data transmitted by the bluetooth device to the target terminal; and the Bluetooth communication middleware reports the second data to the target terminal.
According to another aspect of the embodiments of the present invention, there is also provided a bluetooth communication apparatus, including: the first analysis unit is used for analyzing first data issued by the target terminal through the Bluetooth communication middleware; a first processing unit, configured to write the first data into a bluetooth device through an address indicated by the first data by the bluetooth communication middleware, and obtain second data corresponding to the first data transmitted by the bluetooth device, wherein the second data is the second data transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for the target terminal and the bluetooth device to communicate with each other, the bluetooth communication middleware is used for analyzing the data transmitted from the target terminal to the bluetooth device, the Bluetooth communication middleware is used for transmitting the data sent by the target terminal to the Bluetooth device and transmitting the data sent by the Bluetooth device to the target terminal; and a reporting unit, configured to report the second data to the target terminal by the bluetooth communication middleware.
According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having a computer program stored therein, wherein the computer program is configured to execute the above-mentioned bluetooth communication method when running.
According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the bluetooth communication method through the computer program.
In the embodiment of the invention, for the target terminal, the communication process with the Bluetooth equipment is completed only by sending the first data and receiving the second data reported by the Bluetooth communication middleware, and for the Bluetooth equipment, the purpose of transmitting the second data to the target terminal can be completed only by transmitting the second data to the Bluetooth communication middleware according to the address indicated by the first data. For the bluetooth communication middleware, as a communication interface for the target terminal and the bluetooth device to communicate, the bluetooth communication middleware has multiple functions of receiving first data issued by the target terminal, analyzing the first data, writing the first data into the bluetooth device, receiving second data transmitted by the bluetooth device, analyzing data transmitted by the target terminal to the bluetooth device, analyzing data transmitted by the bluetooth device to the target terminal, transmitting data transmitted by the target terminal to the bluetooth device, and transmitting data transmitted by the bluetooth device to the target terminal. In the conventional method, the bluetooth device has a plurality of channels, each channel represents a communication capability, and communicates in a simplex communication channel manner, when the bluetooth device needs to write data, a corresponding channel with the write capability needs to be selected from the plurality of channels to write the data, and when the bluetooth device needs to transmit the data, a corresponding channel with the transmission capability needs to be selected from the plurality of channels to transmit the data, which results in a complex communication manner between the target terminal and the bluetooth device. However, through the bluetooth communication middleware, the target terminal and the bluetooth device can communicate through the bluetooth communication middleware, and the communication between the target terminal and the bluetooth device can be changed into a full-duplex single channel like socket communication, so that the target terminal and the bluetooth device only need to be in butt joint with the bluetooth communication middleware, and the functions of data writing, data issuing, data transmission and the like can be completed. Correspond present software system, if butt joint bluetooth equipment, do one set of system again basically, coexist with original system, software development cost and later maintenance cost have been increased by a wide margin, and through the current middleware of bluetooth in this scheme, make the communication between target terminal and the bluetooth equipment become the full duplex single channel like socket communication, thereby can make target terminal can communicate according to socket communication mode, the quick butt joint bluetooth equipment communicates, developer's the development degree of difficulty has been reduced, and then in having solved relevant technology, the existence can't communicate to the bluetooth equipment of quick butt joint, and the technical problem that developer's development degree of difficulty is big.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a flow chart illustrating an alternative bluetooth communication method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart diagram of an alternative Bluetooth communication method in accordance with an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an alternative bluetooth communication device according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of another alternative bluetooth communication device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, with the increasing abundance of communication modes of intelligent household appliances, bluetooth ble communication is beginning to be used in the field of intelligent household appliances on a large scale. The existing software communication architecture and the communication model are basically based on a full-duplex single channel similar to socket communication. However, bluetooth ble communication has its particularity that a bluetooth device has multiple channels, each representing a communication capability. If the existing software system needs to be in butt joint with Bluetooth ble equipment, a set of system needs to be made again and coexists with the original system, and software development cost and later maintenance cost are greatly increased. Therefore, accessing such a multi-channel, simplex communication channel as bluetooth ble will cause a great impact on the existing software.
In order to solve the above problem, in the embodiment of the present invention, a middleware scheme is provided, where bluetooth ble communication is abstracted to a manner similar to socket communication through the middleware, so that difficulty in docking bluetooth ble by existing software can be greatly reduced.
Optionally, in this embodiment, as shown in fig. 1, a method of a bluetooth communication method is provided, which may specifically include the following steps:
step S102, first data issued by a target terminal is analyzed through a Bluetooth communication middleware;
step S104, the bluetooth communication middleware writes the first data into a bluetooth device through an address indicated by the first data, and obtains second data corresponding to the first data transmitted by the bluetooth device, where the second data is second data transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for communicating between the target terminal and the bluetooth device, the bluetooth communication middleware is configured to analyze data transmitted by the target terminal to the bluetooth device and analyze data transmitted by the bluetooth device to the target terminal, and the bluetooth communication middleware is configured to transmit data transmitted by the target terminal to the bluetooth device and transmit data transmitted by the bluetooth device to the target terminal;
and step S106, the Bluetooth communication middleware reports the second data to the target terminal.
Alternatively, the above-mentioned bluetooth communication method may be, but is not limited to, in the context of bluetooth communication.
It should be noted that the middleware is a separate system software or service program, by which the distributed application software shares resources among different technologies, and is located on the operating system of the client server, managing computing resources and network communications. Middleware is a large class of basic software, and belongs to the field of reusable software. The middleware is arranged above an operating system, a network and a database, and the application software is arranged at the lower layer, so that the overall effect is to provide an operation and development environment for the application software arranged at the upper layer, and help a user to flexibly and efficiently develop and integrate the complex application software. The bluetooth communication middleware is also a kind of middleware, and the bluetooth communication middleware can be used as a communication logic intermediary between the existing software system and the bluetooth ble.
For example, the visitor issues first data through the target terminal, the first data can be acquired through the bluetooth communication middleware and analyzed, then the bluetooth communication middleware writes the first data into the bluetooth device through an address indicated by the first data, acquires second data corresponding to the first data transmitted by the bluetooth device, and finally reports the second data to the target terminal through the bluetooth communication middleware.
According to the embodiment, for the target terminal, the communication process with the Bluetooth device is completed only by sending the first data and receiving the second data reported by the Bluetooth communication middleware, and for the Bluetooth device, the purpose of transmitting the second data to the target terminal can be completed only by transmitting the second data to the Bluetooth communication middleware according to the address indicated by the first data. For the bluetooth communication middleware, as a communication interface for the target terminal and the bluetooth device to communicate, the bluetooth communication middleware has multiple functions of receiving first data issued by the target terminal, analyzing the first data, writing the first data into the bluetooth device, receiving second data transmitted by the bluetooth device, analyzing data transmitted by the target terminal to the bluetooth device, analyzing data transmitted by the bluetooth device to the target terminal, transmitting data transmitted by the target terminal to the bluetooth device, and transmitting data transmitted by the bluetooth device to the target terminal. In the conventional method, the bluetooth device has a plurality of channels, each channel represents a communication capability, and communicates in a simplex communication channel manner, when the bluetooth device needs to write data, a corresponding channel with the write capability needs to be selected from the plurality of channels to write the data, and when the bluetooth device needs to transmit the data, a corresponding channel with the transmission capability needs to be selected from the plurality of channels to transmit the data, which results in a complex communication manner between the target terminal and the bluetooth device. However, through the bluetooth communication middleware, the target terminal and the bluetooth device can communicate through the bluetooth communication middleware, and the communication between the target terminal and the bluetooth device can be changed into a full-duplex single channel like socket communication, so that the target terminal and the bluetooth device only need to be in butt joint with the bluetooth communication middleware, and the functions of data writing, data issuing, data transmission and the like can be completed. Correspond present software system, if butt joint bluetooth equipment, do one set of system again basically, coexist with original system, software development cost and later maintenance cost have been increased by a wide margin, and through the current middleware of bluetooth in this scheme, make the communication between target terminal and the bluetooth equipment become the full duplex single channel like socket communication, thereby can make target terminal can communicate according to socket communication mode, the quick butt joint bluetooth equipment communicates, developer's the development degree of difficulty has been reduced, and then in having solved relevant technology, the existence can't communicate to the bluetooth equipment of quick butt joint, and the technical problem that developer's development degree of difficulty is big.
Optionally, the analyzing the first data sent by the target terminal through the bluetooth communication middleware includes: the bluetooth communication middleware analyzes the first data to obtain a first analysis result, wherein the first analysis result includes: a header of the first data, a first service data, the first service data being used to indicate a service type of the first data, the header of the first data being used to instruct the bluetooth communication middleware to write the first data into an address of the bluetooth device; the bluetooth communication middleware writes the first data into the bluetooth device through the address indicated by the first data, and includes: the bluetooth communication middleware writes the first data into the bluetooth device according to a generic attribute protocol GATT and an address indicated by a header of the first data.
In an optional embodiment, after the writing the first data to the bluetooth device, the method further includes: the bluetooth communication middleware obtains a report result of the bluetooth device, where the report result is used to indicate that the bluetooth device has written the first data into the bluetooth device, and the report result includes a data header of the first data.
In an optional embodiment, after the bluetooth communication middleware obtains the report result of the bluetooth device, the method further includes: the Bluetooth communication middleware analyzes the reported result to obtain a second analysis result, wherein the second analysis result comprises the data head; the bluetooth communication middleware sends a read request to the bluetooth device according to an address indicated by the data header, where the read request is used to request to read second service data corresponding to the first service data, the first data includes the first service data, and the second data includes the second service data.
Optionally, after the bluetooth communication middleware sends a read request to the bluetooth device according to the address indicated by the header, the method further includes: under the condition that the Bluetooth device replies the reading request according to the address indicated by the data header, acquiring the second data transmitted by the Bluetooth device, wherein the second data comprises: the data header, the second service data, and the second service data are used to indicate a service type of the second data.
Optionally, the step 106 may be implemented in a manner that the reporting, by the bluetooth communication middleware, the second data to the target terminal includes: and the Bluetooth communication middleware reports the second data to the target terminal according to the address indicated by the data head of the first data.
In an optional embodiment, before the step S102, there may be the following implementation manner, where before the analyzing, by the bluetooth communication middleware, the method further includes: the bluetooth communication middleware obtains the first data issued by the target terminal, wherein the first data includes: a header of the first data, and first service data, where the first service data is used to indicate a service type of the first data.
Optionally, the data header includes: bluetooth service UUID, bluetooth feature UUID.
It should be noted that, for a bluetooth device, each service has a UUID (Unique) corresponding to the bluetooth device, which is a universal Unique Identifier (UUID for short).
Bluetooth Service UUID, where Service (Service) can be understood as group leader and at least one or more properties (characteristics) within a group can be understood as group members. Different services (services) should have different UUIDs for distinguishing the different services (services).
The bluetooth feature UUID, the Property (charctertic) is attached to a Service (Service), which may be understood as group members, each group member having at least one number (UUID) and one or more properties (Property), each Property (charctertic) may have one or more properties at the same time. Wherein the attributes include: read attribute, notify attribute, write attribute.
The following describes a flow of a bluetooth communication method with reference to an alternative example, as shown in fig. 2, the method may include the following steps:
step 1, a target terminal corresponding to an accessor issues first data through a Bluetooth communication middleware, and the method comprises the following steps: data header format: bluetooth service UUID + Bluetooth feature UUID, data body format: first traffic data.
Step 2, the Bluetooth communication middleware acquires the first data and analyzes the data head format and the data body format of the first data; and obtaining the Bluetooth service UUID + Bluetooth feature UUID and first service data.
And 3, the Bluetooth communication middleware writes the first data into the Bluetooth equipment through a general Attribute protocol (GATT for short).
And step 4, the Bluetooth GATT driving layer writes the first service data into the Bluetooth equipment according to the service UUID and the characteristic UUID.
And step 5, the Bluetooth equipment determines that the first data is written in, reports the first data as a reporting result, and the data content comprises the service UUID + the characteristic UUID, which indicates that the address of the service UUID + the characteristic UUID needs to read data.
And 6, the GATT driving layer reports the report result of the Bluetooth equipment to the Bluetooth communication middleware.
And 7, the Bluetooth communication middleware analyzes the data to obtain the service UUID + the characteristic UUID.
And 8, the Bluetooth communication middleware initiates a reading operation (such as the reading request) to the GATT driving layer according to the service UUID and the characteristic UUID.
And 9, the GATT driving layer carries out reading communication to the Bluetooth device according to the service UUID and the characteristic UUID.
And step 10, the Bluetooth equipment replies a reading request and transmits the corresponding service UUID + characteristic UUID and second service data corresponding to the first service data to the GATT driving layer.
And step 11, replying second data (comprising the service UUID + the characteristic UUID and second service data) to the Bluetooth communication middleware by the GATT driving layer.
Step 12, the bluetooth communication middleware finally organizes the second data into a data header format: bluetooth service UUID + Bluetooth feature UUID, data body format: and transmitting the service data (second service data) uplink by the equipment to a target terminal corresponding to the visitor.
Through this embodiment, can become the mode of reading of bluetooth service UUID + characteristic UUID, writing in into single channel stream formula data stream, as the communication logic intermediary between current software system and bluetooth ble through bluetooth communication middleware, make current system accomplish and can visit bluetooth ble equipment like visiting traditional socket equipment to the degree of difficulty of visiting bluetooth ble equipment has been reduced by a wide margin.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to still another aspect of the embodiments of the present invention, there is also provided a bluetooth communication apparatus, as shown in fig. 3, the apparatus including:
a first parsing unit 302, configured to parse first data sent by a target terminal through a bluetooth communication middleware;
a first processing unit 304, configured to the bluetooth communication middleware write the first data into a bluetooth device through an address indicated by the first data, and obtain second data corresponding to the first data transmitted by the bluetooth device, wherein the second data is the second data transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for the target terminal and the bluetooth device to communicate with each other, the bluetooth communication middleware is used for analyzing the data transmitted from the target terminal to the bluetooth device, the Bluetooth communication middleware is used for transmitting the data sent by the target terminal to the Bluetooth device and transmitting the data sent by the Bluetooth device to the target terminal;
a reporting unit 306, configured to report the second data to the target terminal by the bluetooth communication middleware.
Optionally, the first parsing unit 302 may be configured to execute step S102, the first processing unit 304 may be configured to execute step S104, and the reporting unit 306 may be configured to execute step S106.
According to the embodiment, for the target terminal, the communication process with the Bluetooth device is completed only by sending the first data and receiving the second data reported by the Bluetooth communication middleware, and for the Bluetooth device, the purpose of transmitting the second data to the target terminal can be completed only by transmitting the second data to the Bluetooth communication middleware according to the address indicated by the first data. For the bluetooth communication middleware, as a communication interface for the target terminal and the bluetooth device to communicate, the bluetooth communication middleware has multiple functions of receiving first data issued by the target terminal, analyzing the first data, writing the first data into the bluetooth device, receiving second data transmitted by the bluetooth device, analyzing data transmitted by the target terminal to the bluetooth device, analyzing data transmitted by the bluetooth device to the target terminal, transmitting data transmitted by the target terminal to the bluetooth device, and transmitting data transmitted by the bluetooth device to the target terminal. In the conventional method, the bluetooth device has a plurality of channels, each channel represents a communication capability, and communicates in a simplex communication channel manner, when the bluetooth device needs to write data, a corresponding channel with the write capability needs to be selected from the plurality of channels to write the data, and when the bluetooth device needs to transmit the data, a corresponding channel with the transmission capability needs to be selected from the plurality of channels to transmit the data, which results in a complex communication manner between the target terminal and the bluetooth device. However, through the bluetooth communication middleware, the target terminal and the bluetooth device can communicate through the bluetooth communication middleware, and the communication between the target terminal and the bluetooth device can be changed into a full-duplex single channel like socket communication, so that the target terminal and the bluetooth device only need to be in butt joint with the bluetooth communication middleware, and the functions of data writing, data issuing, data transmission and the like can be completed. Correspond present software system, if butt joint bluetooth equipment, do one set of system again basically, coexist with original system, software development cost and later maintenance cost have been increased by a wide margin, and through the current middleware of bluetooth in this scheme, make the communication between target terminal and the bluetooth equipment become the full duplex single channel like socket communication, thereby can make target terminal can communicate according to socket communication mode, the quick butt joint bluetooth equipment communicates, developer's the development degree of difficulty has been reduced, and then in having solved relevant technology, the existence can't communicate to the bluetooth equipment of quick butt joint, and the technical problem that developer's development degree of difficulty is big.
As shown in fig. 4, as an optional technical solution, the first parsing unit is further configured to parse the first data by the bluetooth communication middleware to obtain a first parsing result, where the first parsing result includes: a header of the first data, a first service data, the first service data being used to indicate a service type of the first data, the header of the first data being used to instruct the bluetooth communication middleware to write the first data into an address of the bluetooth device;
the first processing unit: the bluetooth communication middleware is further configured to write the first data into the bluetooth device according to a generic attribute protocol GATT and an address indicated by a header of the first data.
As shown in fig. 4, as an optional technical solution, the apparatus further includes: a first obtaining unit 308, configured to obtain, by the bluetooth communication middleware, a report result of the bluetooth device, where the report result is used to indicate that the bluetooth device has written the first data into the bluetooth device, and the report result includes a data header of the first data.
As shown in fig. 4, as an optional technical solution, the apparatus further includes:
a second parsing unit 310, configured to, after the bluetooth communication middleware obtains the report result of the bluetooth device, parse the report result by the bluetooth communication middleware to obtain a second parsing result, where the second parsing result includes the data header;
a sending unit 312, configured to send, by the bluetooth communication middleware, a read request to the bluetooth device according to an address indicated by the header, where the read request is used to request to read second service data corresponding to the first service data, where the first data includes the first service data, and the second data includes the second service data.
As shown in fig. 4, as an optional technical solution, the apparatus further includes:
a second obtaining unit 314, configured to, after the bluetooth communication middleware sends a read request to the bluetooth device according to the address indicated by the header, obtain the second data transmitted by the bluetooth device when the bluetooth device replies to the read request according to the address indicated by the header, where the second data includes: the data header, the second service data, and the second service data are used to indicate a service type of the second data.
As an optional technical solution, the reporting unit 306 is further configured to, when the bluetooth device replies to the read request according to the address indicated by the data header, obtain the second data transmitted by the bluetooth device, where the second data includes: the data header, the second service data, and the second service data are used to indicate a service type of the second data.
As shown in fig. 4, as an optional technical solution, the apparatus further includes:
a third obtaining unit 316, configured to, before the bluetooth communication middleware analyzes first data sent by a target terminal, obtain, by the bluetooth communication middleware, the first data sent by the target terminal, where the first data includes: a header of the first data, and first service data, where the first service data is used to indicate a service type of the first data.
As an optional technical solution, the data header includes: bluetooth service UUID, bluetooth feature UUID.
According to a further aspect of embodiments of the present invention, there is also provided a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, analyzing the first data sent by the target terminal through the Bluetooth communication middleware;
s2, the bluetooth communication middleware writes the first data into a bluetooth device according to the address indicated by the first data, and obtains second data corresponding to the first data transmitted by the bluetooth device, where the second data is the second data transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for communicating between the target terminal and the bluetooth device, the bluetooth communication middleware is configured to analyze data transmitted by the target terminal to the bluetooth device and analyze data transmitted by the bluetooth device to the target terminal, and the bluetooth communication middleware is configured to transmit data transmitted by the target terminal to the bluetooth device and transmit data transmitted by the bluetooth device to the target terminal;
and S3, the Bluetooth communication middleware reports the second data to the target terminal.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, ROM (Read-Only Memory), RAM (Random Access Memory), magnetic or optical disks, and the like.
According to yet another aspect of the embodiments of the present invention, there is also provided an electronic device for implementing the bluetooth communication method, as shown in fig. 5, the electronic device includes a memory 502 and a processor 504, the memory 502 stores a computer program therein, and the processor 504 is configured to execute the steps in any one of the method embodiments through the computer program.
Optionally, in this embodiment, the electronic apparatus may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, analyzing the first data sent by the target terminal through the Bluetooth communication middleware;
s2, the bluetooth communication middleware writes the first data into a bluetooth device according to the address indicated by the first data, and obtains second data corresponding to the first data transmitted by the bluetooth device, where the second data is the second data transmitted by the bluetooth device according to the address indicated by the first data, the bluetooth communication middleware is a communication interface for communicating between the target terminal and the bluetooth device, the bluetooth communication middleware is configured to analyze data transmitted by the target terminal to the bluetooth device and analyze data transmitted by the bluetooth device to the target terminal, and the bluetooth communication middleware is configured to transmit data transmitted by the target terminal to the bluetooth device and transmit data transmitted by the bluetooth device to the target terminal;
and S3, the Bluetooth communication middleware reports the second data to the target terminal.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 5 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 5 is a diagram illustrating a structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 5, or have a different configuration than shown in FIG. 5.
The memory 502 may be used to store software programs and modules, such as program instructions/modules corresponding to the bluetooth communication method and apparatus in the embodiment of the present invention, and the processor 504 executes various functional applications and data processing by running the software programs and modules stored in the memory 502, that is, implements the bluetooth communication method. The memory 502 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 502 may further include memory located remotely from the processor 504, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. As an example, as shown in fig. 5, the memory 502 may include, but is not limited to, the first parsing unit 302, the first processing unit 304, and the reporting unit 306 of the bluetooth communication apparatus. In addition, other module units in the bluetooth communication apparatus may also be included, but are not limited to these, and are not described in this example again.
Optionally, the transmission device 506 is used for receiving or sending data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 506 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, the transmission device 506 is a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In addition, the electronic device further includes: a display 508; and a connection bus 510 for connecting the respective module parts in the above-described electronic apparatus.
In other embodiments, the terminal or the server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication form. Nodes can form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the Peer-To-Peer network.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially or partially implemented in the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, and including instructions for causing one or more computer devices (which may be personal computers, servers, or network devices) to execute all or part of the steps of the method according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is merely a division of a logic function, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should also be considered as the protection scope of the present invention.
Claims (10)
1. A bluetooth communication method, comprising:
analyzing first data issued by a target terminal through a Bluetooth communication middleware;
the Bluetooth communication middleware writes the first data into Bluetooth equipment through an address indicated by the first data and acquires second data which is transmitted by the Bluetooth equipment and corresponds to the first data, wherein the second data is the second data transmitted by the Bluetooth equipment according to the address indicated by the first data, the Bluetooth communication middleware is a communication interface for communicating between the target terminal and the Bluetooth equipment, the Bluetooth communication middleware is used for analyzing the data transmitted by the target terminal to the Bluetooth equipment and analyzing the data transmitted by the Bluetooth equipment to the target terminal, and the Bluetooth communication middleware is used for transmitting the data transmitted by the target terminal to the Bluetooth equipment and transmitting the data transmitted by the Bluetooth equipment to the target terminal;
and the Bluetooth communication middleware reports the second data to the target terminal.
2. The method of claim 1, wherein the parsing the first data sent by the target terminal through the bluetooth communication middleware comprises:
the bluetooth communication middleware analyzes the first data to obtain a first analysis result, wherein the first analysis result comprises: a data header of the first data, a first service data, where the first service data is used to indicate a service type of the first data, and the data header of the first data is used to instruct the bluetooth communication middleware to write the first data into an address of the bluetooth device;
the Bluetooth communication middleware writes the first data into a Bluetooth device through an address indicated by the first data, and comprises the following steps:
the Bluetooth communication middleware writes the first data to the Bluetooth device according to a generic Attribute protocol (GATT) and an address indicated by a data header of the first data.
3. The method of claim 1, wherein after the writing the first data to the Bluetooth device, the method further comprises:
the Bluetooth communication middleware acquires a reporting result of the Bluetooth device, wherein the reporting result is used for indicating that the Bluetooth device has written the first data into the Bluetooth device, and the reporting result includes a data header of the first data.
4. The method of claim 3, wherein after the Bluetooth communication middleware obtains the report result of the Bluetooth device, the method further comprises:
the Bluetooth communication middleware analyzes the reported result to obtain a second analysis result, wherein the second analysis result comprises the data head;
the Bluetooth communication middleware sends a reading request to the Bluetooth device according to the address indicated by the data header, wherein the reading request is used for requesting to read second service data corresponding to the first service data, the first service data comprises the first service data, and the second service data comprises the second service data.
5. The method of claim 4, wherein after the Bluetooth communication middleware sends a read request to the Bluetooth device according to the address indicated by the data header, the method further comprises:
under the condition that the Bluetooth device replies the reading request according to the address indicated by the data header, acquiring the second data transmitted by the Bluetooth device, wherein the second data comprises: the data header, the second service data, and the second service data are used to indicate a service type of the second data.
6. The method of claim 1, wherein the reporting of the second data to the target terminal by the bluetooth communication middleware comprises:
and the Bluetooth communication middleware reports the second data to the target terminal according to the address indicated by the data head.
7. The method of any of claims 1 to 6, wherein the data header comprises: bluetooth service UUID, bluetooth feature UUID.
8. A bluetooth communication device, comprising:
the first analysis unit is used for analyzing first data issued by the target terminal through the Bluetooth communication middleware;
a first processing unit, configured to write the first data into a bluetooth device through an address indicated by the first data by the bluetooth communication middleware, and acquire second data corresponding to the first data transmitted by the bluetooth device, wherein the second data is second data transmitted by the Bluetooth device according to an address indicated by the first data, the Bluetooth communication middleware is a communication interface for the target terminal and the Bluetooth device to communicate, the Bluetooth communication middleware is used for analyzing the data transmitted by the target terminal to the Bluetooth device, the Bluetooth communication middleware is used for transmitting the data sent by the target terminal to the Bluetooth device and transmitting the data sent by the Bluetooth device to the target terminal;
and the reporting unit is used for reporting the second data to the target terminal by the Bluetooth communication middleware.
9. A computer-readable storage medium, comprising a stored program, wherein the program is operable to perform the method of any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 7 by means of the computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010621879.7A CN111885560A (en) | 2020-07-01 | 2020-07-01 | Bluetooth communication method and device, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010621879.7A CN111885560A (en) | 2020-07-01 | 2020-07-01 | Bluetooth communication method and device, storage medium and electronic device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111885560A true CN111885560A (en) | 2020-11-03 |
Family
ID=73156673
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010621879.7A Pending CN111885560A (en) | 2020-07-01 | 2020-07-01 | Bluetooth communication method and device, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111885560A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112416617A (en) * | 2020-11-19 | 2021-02-26 | 青岛海尔科技有限公司 | Control method and device of Bluetooth equipment, storage medium and electronic device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101924582A (en) * | 2010-07-29 | 2010-12-22 | 上海慧翰信息技术有限公司 | Communication device and middleware thereof |
CN101944939A (en) * | 2010-07-29 | 2011-01-12 | 上海慧翰信息技术有限公司 | Communication equipment and communication method between mainframe thereof and Bluetooth module |
CN102137131A (en) * | 2010-01-27 | 2011-07-27 | 广州盛华信息技术有限公司 | System for realizing access of internet of things |
CN102833312A (en) * | 2012-07-22 | 2012-12-19 | 黄涛 | Network computer control system based on Bluetooth technology |
US20160269405A1 (en) * | 2015-03-12 | 2016-09-15 | Ricoh Company, Ltd. | Communication apparatus, communication control method, and computer-readable recording medium |
-
2020
- 2020-07-01 CN CN202010621879.7A patent/CN111885560A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102137131A (en) * | 2010-01-27 | 2011-07-27 | 广州盛华信息技术有限公司 | System for realizing access of internet of things |
CN101924582A (en) * | 2010-07-29 | 2010-12-22 | 上海慧翰信息技术有限公司 | Communication device and middleware thereof |
CN101944939A (en) * | 2010-07-29 | 2011-01-12 | 上海慧翰信息技术有限公司 | Communication equipment and communication method between mainframe thereof and Bluetooth module |
CN102833312A (en) * | 2012-07-22 | 2012-12-19 | 黄涛 | Network computer control system based on Bluetooth technology |
US20160269405A1 (en) * | 2015-03-12 | 2016-09-15 | Ricoh Company, Ltd. | Communication apparatus, communication control method, and computer-readable recording medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112416617A (en) * | 2020-11-19 | 2021-02-26 | 青岛海尔科技有限公司 | Control method and device of Bluetooth equipment, storage medium and electronic device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113411215B (en) | Time-sensitive network centralized user configuration method and system based on OPC UA | |
CN109862113A (en) | The wireless throwing screen system and its method of wide area network-oriented | |
CN105704252B (en) | Bluetooth low energy device data transmission method and device | |
CN111586145B (en) | Vehicle diagnosis method, system, electronic equipment and storage medium | |
CN109547524B (en) | User behavior storage method, device, equipment and storage medium based on Internet of things | |
CN114598735B (en) | Data processing method and system | |
CN111263338A (en) | Network distribution method of Bluetooth Mesh network and related network distribution equipment and system | |
CN104753989A (en) | Screen image transmission and playing method and device based on Web-based OS runtime environment | |
CN102594886B (en) | Method and device for direct communication between browsers, and communication system | |
CN101278274A (en) | Peer name resolution protocol simple application program interface | |
CN111885560A (en) | Bluetooth communication method and device, storage medium and electronic device | |
CN113630424A (en) | WebRTC communication method and system | |
CN107231275B (en) | Method for connection configuration of user equipment and household equipment | |
CN110430478B (en) | Networking communication method, device, terminal equipment and storage medium | |
CN111600883A (en) | Vehicle diagnosis method and system, electronic equipment and storage medium | |
CN111008209A (en) | Data account checking method, device and system, storage medium and electronic device | |
CN113434190B (en) | Data processing method and device, storage medium and electronic equipment | |
CN105429981A (en) | Game voice transmission method, terminal, voice service module and game system | |
CN112954658B (en) | Business card system suitable for data exchange of communication protocol layer and data exchange method | |
US20100274840A1 (en) | Cooperation apparatus using peer-to-peer and method thereof | |
CN110673799B (en) | Cluster partnership establishment method, system, equipment and computer medium | |
CN113347234A (en) | Network information acquisition method, device, system, computer equipment and storage medium | |
CN114079974A (en) | Network capability opening method and device, UPF entity and CPE network element | |
CN117544632B (en) | Method, system and application for direct interaction of browser pages in multiple terminals | |
EP3742775A1 (en) | Method and device for terminal to report information, and computer storage medium |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201103 |