Method and device for data transmission based on Bluetooth broadcast and Bluetooth equipment
Technical Field
The embodiment of the specification relates to the technical field of data processing, in particular to a method and a device for data transmission based on Bluetooth broadcast and Bluetooth equipment.
Background
In the prior art, a bluetooth device, for example, a mobile phone carrying a bluetooth communication module, may send a broadcast message with a connectable broadcast type on a designated broadcast channel, and another bluetooth device may discover the broadcast message by scanning the designated broadcast channel, that is, discover a connectable bluetooth device, and then the another bluetooth device may send a connection request to the connectable bluetooth device. After the Bluetooth connection is established between the two Bluetooth devices, the two Bluetooth devices can transmit data through Bluetooth broadcasting.
Therefore, in the prior art, it is a necessary condition that two bluetooth devices can perform data transmission through bluetooth broadcast to establish bluetooth connection, and the two bluetooth devices perform data transmission through one bluetooth broadcast.
Disclosure of Invention
In view of the above technical problems, embodiments of the present specification provide a method, an apparatus, and a bluetooth device for data transmission based on bluetooth broadcast, where the technical scheme is as follows:
according to a first aspect of embodiments herein, there is provided a method for data transmission based on bluetooth broadcast, the method including:
splitting data to be sent into N data segments, wherein N is a natural number greater than 0;
for any data segment in the N data segments, packaging the data segment serving as broadcast data into a Bluetooth broadcast data packet to obtain N Bluetooth broadcast data packets;
and starting N Bluetooth broadcasts, and broadcasting and sending the N Bluetooth broadcast data packets by utilizing the N Bluetooth broadcasts respectively.
According to a second aspect of embodiments herein, there is provided a method for data transmission based on bluetooth broadcast, the method comprising:
scanning Bluetooth broadcast in a set channel range;
when a Bluetooth broadcast with a specified service UUID is scanned, acquiring a Bluetooth broadcast data packet broadcast and sent by the Bluetooth broadcast;
analyzing the Bluetooth broadcast data packet aiming at any one acquired Bluetooth broadcast data packet to obtain broadcast data packaged by the Bluetooth broadcast data packet;
the resulting broadcast data is combined.
According to a third aspect of embodiments herein, there is provided an apparatus for data transmission based on bluetooth broadcast, the apparatus comprising:
the device comprises a splitting module, a receiving module and a sending module, wherein the splitting module is used for splitting data to be sent into N data segments, and N is a natural number greater than 0;
the encapsulation module is used for encapsulating the data segment serving as broadcast data into a Bluetooth broadcast data packet aiming at any data segment in the N data segments to obtain N Bluetooth broadcast data packets;
and the transmission module is used for starting N Bluetooth broadcasts and respectively broadcasting and sending the N Bluetooth broadcast data packets by utilizing the N Bluetooth broadcasts.
According to a fourth aspect of embodiments herein, there is provided an apparatus for data transmission based on bluetooth broadcast, the apparatus comprising:
the scanning module is used for scanning the Bluetooth broadcast in a set channel range;
the system comprises an acquisition module, a service acquisition module and a service selection module, wherein the acquisition module is used for acquiring a Bluetooth broadcast data packet broadcast and sent by a Bluetooth broadcast when the Bluetooth broadcast with a specified service UUID is scanned;
the analysis module is used for analyzing any one acquired Bluetooth broadcast data packet to obtain broadcast data packaged by the Bluetooth broadcast data packet;
and the combination module is used for combining the obtained broadcast data.
According to a fifth aspect of the embodiments of the present specification, there is provided a bluetooth device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement any of the methods for data transmission based on bluetooth broadcast provided by the embodiments of the present specification.
According to the technical scheme provided by the embodiment of the specification, data to be sent is divided into N data segments, and any data segment is packaged into a Bluetooth broadcast data packet as broadcast data to obtain N Bluetooth broadcast data packets; n Bluetooth broadcasts are started, and the N Bluetooth broadcasts are utilized to broadcast and send N Bluetooth broadcast data packets respectively, so that the efficiency of data transmission based on the Bluetooth broadcasts can be improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of embodiments of the invention.
In addition, any one of the embodiments in the present specification is not required to achieve all of the effects described above.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present specification, and other drawings can be obtained by those skilled in the art according to the drawings.
Fig. 1 is a flowchart of an embodiment of a method for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure;
fig. 2 is a flowchart of another embodiment of a method for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure;
fig. 3 is a block diagram of an embodiment of an apparatus for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure;
fig. 4 is a block diagram of another embodiment of an apparatus for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure;
fig. 5 shows a more specific hardware structure diagram of a bluetooth device provided in an embodiment of the present specification.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present specification, the technical solutions in the embodiments of the present specification will be described in detail below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of protection.
In the prior art, it is a necessary condition that two bluetooth devices can perform data transmission through bluetooth broadcasting to establish a bluetooth connection, and the two bluetooth devices perform data transmission through one bluetooth broadcasting, which results in low efficiency of data transmission, and especially for large data, it takes a long time to perform data transmission through only one bluetooth broadcasting.
In order to solve the above problem, an embodiment of the present disclosure provides a method for data transmission based on bluetooth broadcast, and with the method, data transmission can be performed between two bluetooth devices without establishing a bluetooth connection, and larger data can be transmitted through a plurality of bluetooth broadcasts, thereby improving data transmission efficiency.
As follows, a method for data transmission based on bluetooth broadcast provided in the embodiments of the present specification is described separately from both sides of a data transmitting side and a data receiving side.
First, a method for transmitting data by bluetooth broadcasting will be described, in which:
referring to fig. 1, a flowchart of an embodiment of a method for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure is provided, where the method may include the following steps:
step 102: and splitting data to be sent into N data segments, wherein N is a natural number greater than 0.
Step 104: and for any data segment in the N data segments, packaging the data segment serving as broadcast data into a Bluetooth broadcast data packet to obtain N Bluetooth broadcast data packets.
Step 102 and step 104 are explained as follows:
in this embodiment of the present specification, data to be transmitted may be split based on a specified byte length, for example, 30 bytes, to obtain N data segments, where the length of any data segment does not exceed the specified byte length, for example, for data to be transmitted, each 30 bytes may be split into one data segment, and for example, on the premise that the length of any data segment does not exceed the specified byte length, data to be transmitted may be split randomly.
Further, in this embodiment of the present specification, an arrangement sequence number may be set for the N data segments according to an arrangement sequence of the N data segments in the data to be sent, for example, the data to be sent is split into 5 data segments, and the arrangement sequence numbers of the 5 data segments are 0 to 4 in sequence.
In this embodiment, for any data segment of the N data segments, the data segment is encapsulated as broadcast data into one bluetooth broadcast data packet, so far, N bluetooth broadcast data packets are obtained.
Step 106: and starting N Bluetooth broadcasts, and broadcasting and sending the N Bluetooth broadcast data packets by utilizing the N Bluetooth broadcasts respectively.
In this embodiment of the present disclosure, a virtual bluetooth technology may be used to virtualize N bluetooth broadcasts, and the N bluetooth broadcasts are used to broadcast and transmit the N bluetooth broadcast packets obtained in step 104, respectively.
It should be noted that the virtualized N bluetooth broadcasts have the same service UUID (universal unique Identifier).
According to the technical scheme provided by the embodiment of the specification, data to be sent is divided into N data segments, and any data segment is packaged into a Bluetooth broadcast data packet as broadcast data to obtain N Bluetooth broadcast data packets; n Bluetooth broadcasts are started, and the N Bluetooth broadcasts are utilized to broadcast and send N Bluetooth broadcast data packets respectively, so that the efficiency of data transmission based on the Bluetooth broadcasts can be improved.
Next, a method for transmitting data by bluetooth broadcasting will be described, in which:
referring to fig. 2, a flowchart of another embodiment of a method for data transmission based on bluetooth broadcast according to an exemplary embodiment of the present disclosure is provided, where the method may include the following steps:
step 202: bluetooth broadcasts are scanned within a set channel range.
Step 204: when the Bluetooth broadcast with the specified service UUID is scanned, the Bluetooth broadcast data packet broadcast and sent by the Bluetooth broadcast is acquired.
Step 202 and step 204 are explained as follows:
in this embodiment, as a data receiver, the bluetooth device may scan a bluetooth broadcast in a set channel range, for example, channel 37 to channel 39, and filter the scanned bluetooth broadcast based on a specified service UUID, that is, when a bluetooth broadcast with the specified service UUID is scanned, obtain a bluetooth broadcast packet broadcast by the bluetooth broadcast.
It should be noted that, in conjunction with the embodiment illustrated in fig. 1, the service UUID specified in this step may be the same as the service UUIDs of the N bluetooth broadcasts described in step 106 of the embodiment illustrated in fig. 1.
In one embodiment, the specified service UUID may be determined based on a user action. For example, after scanning the bluetooth broadcast, the bluetooth device may display the scanned bluetooth broadcast on the display interface, for example, display an identifier of the scanned bluetooth broadcast, and the user may select the bluetooth broadcast intended for communication based on the identifier of the bluetooth broadcast, and may determine the specified service UUID through a selection operation of the user.
Step 206: and analyzing the Bluetooth broadcast data packet according to any one of the acquired Bluetooth broadcast data packets to obtain broadcast data packaged by the Bluetooth broadcast data packet.
Step 208: the resulting broadcast data is combined.
Step 206 and step 208 are explained as follows:
in this embodiment of the present specification, as a data receiver, a bluetooth device may parse any acquired bluetooth broadcast data packet according to a format specification of the bluetooth broadcast data packet to obtain broadcast data encapsulated therein, and then combine the obtained broadcast data to obtain original data to be sent, which is sent by a data sender.
In an embodiment, as can be seen from the description in the embodiment shown in fig. 1, as a data sending party, after splitting data to be sent, a bluetooth device may set an arrangement sequence number for a data segment obtained by splitting according to an arrangement sequence of the data segment in the data to be sent, and based on this, in step 208, broadcast data may be combined according to the arrangement sequence number of the broadcast data.
According to the technical scheme provided by the embodiment of the specification, the Bluetooth broadcast is scanned in the set channel range, when the Bluetooth broadcast with the specified service UUID is scanned, the Bluetooth broadcast data packet broadcast and sent by the Bluetooth broadcast is acquired, the Bluetooth broadcast data packet is analyzed according to any one acquired Bluetooth broadcast data packet, broadcast data packaged by the Bluetooth broadcast data packet is acquired, the acquired broadcast data is combined, and the efficiency of data transmission based on the Bluetooth broadcast can be improved.
Corresponding to the method embodiment illustrated in fig. 1, an embodiment of the present specification further provides an apparatus for performing data transmission based on bluetooth broadcast, and referring to fig. 3, a block diagram of an embodiment of an apparatus for performing data transmission based on bluetooth broadcast according to an exemplary embodiment of the present specification is provided, where the apparatus may include: a splitting module 31, an encapsulation module 32, and a transmission module 33.
The splitting module 31 may be configured to split data to be sent into N data segments, where N is a natural number greater than 0;
the encapsulation module 32 may be configured to encapsulate, as broadcast data, the data segment into one bluetooth broadcast data packet for any one of the N data segments, so as to obtain N bluetooth broadcast data packets;
the transmission module 33 may be configured to start N bluetooth broadcasts, and broadcast and send the N bluetooth broadcast data packets by using the N bluetooth broadcasts respectively.
In an embodiment, the splitting module 31 may include (not shown in fig. 3):
the processing submodule is used for splitting data to be sent based on the specified byte length to obtain N data segments, wherein the length of any data segment does not exceed the specified byte length;
and the numbering submodule is used for setting an arrangement sequence number for the N data segments according to the arrangement sequence of the N data segments in the data to be sent.
In one embodiment, the N bluetooth broadcasts have the same service UUID.
It should be understood that the splitting module 31, the encapsulating module 32, and the transmitting module 33 may be configured in the apparatus at the same time as shown in fig. 3, or may be configured in the apparatus separately, and therefore the structure shown in fig. 3 should not be construed as a limitation to the embodiment of the present specification.
Corresponding to the method embodiment illustrated in fig. 2, another apparatus for performing data transmission based on bluetooth broadcast is further provided in the embodiment of this specification, and referring to fig. 4, a block diagram of an embodiment of another apparatus for performing data transmission based on bluetooth broadcast provided in an exemplary embodiment of this specification may include: a scanning module 41, an acquisition module 42, an analysis module 43, and a combination module 44.
The scanning module 41 may be configured to scan a bluetooth broadcast within a set channel range;
the obtaining module 42 may be configured to, when a bluetooth broadcast with a specified UUID is scanned, obtain a bluetooth broadcast data packet broadcast and sent by the bluetooth broadcast;
the analyzing module 43 may be configured to analyze any acquired bluetooth broadcast data packet to obtain broadcast data encapsulated by the bluetooth broadcast data packet;
a combining module 44 may be used to combine the resulting broadcast data.
In an embodiment, the combining module 44 may be specifically configured to:
and combining the broadcast data according to the sequence number of the obtained broadcast data.
It should be understood that the scanning module 41, the obtaining module 42, the analyzing module 43, and the combining module 44 may be configured in the apparatus at the same time as shown in fig. 4 or separately as four independent modules, and therefore the structure shown in fig. 4 should not be construed as limiting the embodiment of the present specification.
In addition, the implementation process of the functions and actions of each module in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
An embodiment of the present specification further provides a bluetooth device, which at least includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the program to implement the foregoing method for data transmission based on bluetooth broadcast, and the method at least includes: splitting data to be sent into N data segments, wherein N is a natural number greater than 0; for any data segment in the N data segments, packaging the data segment serving as broadcast data into a Bluetooth broadcast data packet to obtain N Bluetooth broadcast data packets; and starting N Bluetooth broadcasts, and broadcasting and sending the N Bluetooth broadcast data packets by utilizing the N Bluetooth broadcasts respectively.
The embodiments of the present specification further provide another bluetooth device, which at least includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the program to implement the foregoing method for data transmission based on bluetooth broadcast, and the method at least includes: scanning Bluetooth broadcast in a set channel range; when a Bluetooth broadcast with a specified UUID is scanned, acquiring a Bluetooth broadcast data packet broadcast and sent by the Bluetooth broadcast; analyzing the Bluetooth broadcast data packet aiming at any one acquired Bluetooth broadcast data packet to obtain broadcast data packaged by the Bluetooth broadcast data packet; the resulting broadcast data is combined.
Fig. 5 is a schematic diagram illustrating a more specific hardware structure of a bluetooth device according to an embodiment of the present disclosure, where the bluetooth device may include: a processor 510, a memory 520, an input/output interface 530, a communication interface 540, and a bus 550. Wherein processor 510, memory 520, input/output interface 530, and communication interface 540 are communicatively coupled to each other within the device via bus 550.
The processor 510 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present specification.
The Memory 520 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random access Memory), a static storage device, a dynamic storage device, or the like. The memory 520 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 520 and called by the processor 510 for execution.
The input/output interface 530 is used for connecting an input/output module to realize information input and output. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The communication interface 540 is used for connecting a communication module (not shown in the figure) to realize communication interaction between the device and other devices. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, Bluetooth and the like).
Bus 550 includes a pathway to transfer information between various components of the device, such as processor 510, memory 520, input/output interface 530, and communication interface 540.
It should be noted that although the above-mentioned device only shows the processor 510, the memory 520, the input/output interface 530, the communication interface 540 and the bus 550, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.
Embodiments of the present specification also provide a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the foregoing method for data transmission based on bluetooth broadcast. The method at least comprises the following steps: splitting data to be sent into N data segments, wherein N is a natural number greater than 0; for any data segment in the N data segments, packaging the data segment serving as broadcast data into a Bluetooth broadcast data packet to obtain N Bluetooth broadcast data packets; and starting N Bluetooth broadcasts, and broadcasting and sending the N Bluetooth broadcast data packets by utilizing the N Bluetooth broadcasts respectively.
Embodiments of the present specification also provide another computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the foregoing method for data transmission based on bluetooth broadcast. The method at least comprises the following steps: scanning Bluetooth broadcast in a set channel range; when a Bluetooth broadcast with a specified UUID is scanned, acquiring a Bluetooth broadcast data packet broadcast and sent by the Bluetooth broadcast; analyzing the Bluetooth broadcast data packet aiming at any one acquired Bluetooth broadcast data packet to obtain broadcast data packaged by the Bluetooth broadcast data packet; the resulting broadcast data is combined.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include transitory computer readable media (transmyedia) such as modulated data signals and carrier waves.
From the above description of the embodiments, it is clear to those skilled in the art that the embodiments of the present disclosure can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the embodiments of the present specification may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments of the present specification.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described apparatus embodiments are merely illustrative, and the modules described as separate components may or may not be physically separate, and the functions of the modules may be implemented in one or more software and/or hardware when implementing the embodiments of the present disclosure. And part or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The foregoing is only a specific embodiment of the embodiments of the present disclosure, and it should be noted that, for those skilled in the art, a plurality of modifications and decorations can be made without departing from the principle of the embodiments of the present disclosure, and these modifications and decorations should also be regarded as the protection scope of the embodiments of the present disclosure.