Disclosure of Invention
The present invention is directed to solving at least one of the technical problems existing in the related art. Therefore, the invention provides a Bluetooth broadcasting two-way communication method, which can ensure the data receiving quality without repeatedly sending the broadcast data packet for many times by sending a scanning request packet carrying a target available interaction channel identifier and a target interaction time to a broadcasting device through a scanning device and sending an application data packet to the broadcasting device through a target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, thereby effectively improving the communication efficiency and the communication quality of Bluetooth broadcasting two-way communication.
The invention also provides a Bluetooth broadcasting two-way communication method.
The invention also provides a Bluetooth broadcasting two-way communication method.
The invention also provides a Bluetooth broadcasting two-way communication system.
The invention also provides a Bluetooth broadcasting two-way communication device.
The invention also provides a Bluetooth broadcasting two-way communication device.
The invention further provides electronic equipment.
The invention also proposes a non-transitory computer readable storage medium.
The invention also proposes a computer program product.
An embodiment of a bluetooth broadcast bidirectional communication method according to a first aspect of the present invention is applied to a scanning device, and includes:
based on the scanned broadcast data packet, obtaining an application data packet which is fed back to the broadcasting equipment corresponding to the broadcast data packet;
Determining a scanning request packet based on the broadcast data packet scanned after the preset times, wherein the scanning request packet comprises a target available interaction channel identifier and target interaction time for Bluetooth communication with the broadcasting equipment;
transmitting the scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier;
and sending the application data packet to the broadcasting equipment through the target available interaction channel based on the overtime identification of the target interaction time.
According to the Bluetooth broadcasting bidirectional communication method, a scanning device firstly acquires an application data packet fed back to a broadcasting device corresponding to a broadcasting data packet based on the scanned broadcasting data packet, and further determines a scanning request packet based on the broadcasting data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
According to one embodiment of the present invention, the determining the target available interactive channel identifier for bluetooth communication with the broadcasting device includes:
determining the detected available interactive channel identification in the preset duration;
And determining a target available interactive channel identifier for Bluetooth communication with the broadcasting equipment from the available interactive channel identifiers based on the number of the available interactive channel identifiers.
According to one embodiment of the present invention, the determining the target interaction time for bluetooth communication with the broadcasting device includes:
And determining target interaction time for Bluetooth communication with the broadcasting equipment based on a preset interaction time threshold, priority data of service data carried by the broadcasting data packet and preset random time.
According to one embodiment of the present invention, the sending the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time includes:
Transmitting the scanning request packet to the broadcasting equipment based on the broadcast data packet received again by the overtime identifier of the target interaction time;
And determining that the accumulated transmission times of the scanning request packet transmitted to the broadcasting equipment does not exceed the preset transmission times, and transmitting the application data packet to the broadcasting equipment through the target available interactive channel.
According to an embodiment of the present invention, the obtaining, based on the scanned broadcast data packet, an application data packet fed back to a broadcasting device corresponding to the broadcast data packet includes:
Acquiring target address information of broadcasting equipment corresponding to a broadcasting data packet and service data carried by the broadcasting data packet based on the scanned broadcasting data packet;
Determining application data replying to the broadcasting equipment based on the service data;
And acquiring an application data packet fed back to the broadcasting equipment based on the application data, the preset data head, the target address information and the equipment address information of the scanning equipment.
According to one embodiment of the present invention, the scan data packet includes target address information of a broadcasting device corresponding to the broadcast data packet and device address information of the scanning device, the target available interaction channel identifier, and the target interaction time.
According to one embodiment of the invention, the method further comprises:
And feeding back response data to the broadcasting equipment based on the broadcasting data packet scanned before the preset times, wherein the response data does not carry the application data packet.
According to a second aspect of the present invention, a bluetooth broadcast bidirectional communication method is applied to a broadcasting device, and includes:
Determining a broadcast data packet based on the detected service data update identifier;
transmitting the broadcast data packet to a scanning device;
determining a target available interaction channel identifier and target interaction time based on a received scanning request packet sent by the scanning equipment;
And receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
According to the Bluetooth broadcasting bidirectional communication method provided by the embodiment of the invention, the broadcasting equipment firstly updates the identification based on the detected service data, determines the broadcasting data packet to be sent to the scanning equipment, then extracts the target available interaction channel identification and the target interaction time from the received scanning request packet, and receives the application data packet sent by the scanning equipment on the target available interaction channel after the target interaction time is overtime, so that the Bluetooth bidirectional communication can be performed rapidly and reliably by sporadically performing a small amount of data interaction between the broadcasting equipment and the scanning equipment, the efficiency of the Bluetooth broadcasting bidirectional communication is effectively improved, and the application range is enlarged.
According to one embodiment of the invention, the method further comprises:
Matching the number of the application data packets with the number of the scanning devices;
updating the Bluetooth broadcasting state to a stopped Bluetooth broadcasting state based on the successful matching result of the number of the application data and the number of the scanning devices;
and updating the Bluetooth broadcasting state to a continuous broadcasting state based on the matching failure result of the number of the application data and the number of the scanning devices.
A bluetooth broadcast bi-directional communication system according to an embodiment of a third aspect of the present invention comprises a scanning device performing the method of the first aspect described above and a broadcasting device performing the method of the second aspect described above.
According to the Bluetooth broadcasting bidirectional communication system, a broadcasting device firstly updates an identifier based on detected service data, determines a broadcasting data packet to be sent to a scanning device, then extracts a target available interaction channel identifier and target interaction time from a received scanning request packet, and receives an application data packet sent by the scanning device on a target available interaction channel after the target interaction time is overtime, so that Bluetooth bidirectional communication can be performed rapidly and reliably by sporadically performing a small amount of data interaction between the broadcasting device and the scanning device, the efficiency of Bluetooth broadcasting bidirectional communication is effectively improved, the application range is enlarged, further, the scanning device firstly acquires the application data packet fed back to the broadcasting device corresponding to the broadcasting data packet based on the scanned broadcasting data packet, and further determines the scanning request packet based on the broadcasting data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
A bluetooth broadcast bi-directional communication device according to an embodiment of the fourth aspect of the present invention includes:
the acquisition module is used for acquiring an application data packet which is fed back to the broadcasting equipment corresponding to the broadcasting data packet based on the scanned broadcasting data packet;
the first determining module is used for determining a scanning request packet based on the broadcast data packet scanned after the preset times, wherein the scanning request packet comprises a target available interaction channel identifier and target interaction time for Bluetooth communication with the broadcasting equipment;
the first sending module is used for sending the scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier;
And the second sending module is used for sending the application data packet to the broadcasting equipment through the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
According to the Bluetooth broadcast bidirectional communication device, firstly, an application data packet fed back to broadcasting equipment corresponding to a broadcast data packet is acquired based on the scanned broadcast data packet, and further, a scanning request packet is determined based on the broadcast data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
A bluetooth broadcast bi-directional communication device according to an embodiment of the fifth aspect of the present invention includes:
the second determining module is used for determining a broadcast data packet based on the detected service data updating identification;
a third transmitting module, configured to transmit the broadcast data packet to a scanning device;
the second determining module is used for determining a target available interaction channel identifier and target interaction time based on the received scanning request packet sent by the scanning equipment;
And the receiving module is used for receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
According to the Bluetooth broadcasting bidirectional communication device provided by the embodiment of the invention, firstly, the broadcasting data packet to be sent to the scanning equipment is determined based on the detected service data updating identification, then the target available interaction channel identification and the target interaction time are extracted from the received scanning request packet, and the application data packet sent by the scanning equipment is received on the target available interaction channel after the target interaction time is overtime, so that the Bluetooth bidirectional communication can be performed quickly and reliably by sporadically carrying out a small amount of data interaction between the broadcasting equipment and the scanning equipment, the efficiency of the Bluetooth broadcasting bidirectional communication is effectively improved, and the application range is enlarged.
The one or more technical schemes in the embodiment of the invention have at least one of the following technical effects that the scanning device firstly acquires an application data packet fed back to the broadcasting device corresponding to the broadcasting data packet based on the scanned broadcasting data packet, and further determines a scanning request packet based on the broadcasting data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
Further, the broadcasting device firstly determines the broadcasting data packet to be sent to the scanning device based on the detected service data updating identification, then extracts the target available interaction channel identification and the target interaction time from the received scanning request packet, and receives the application data packet sent by the scanning device on the target available interaction channel after the target interaction time is overtime, so that the Bluetooth bidirectional communication can be performed rapidly and reliably by sporadically performing a small amount of data interaction between the broadcasting device and the scanning device, the efficiency of the Bluetooth broadcasting bidirectional communication is effectively improved, and the application range is enlarged.
Furthermore, the scanning device improves the accuracy and reliability of transmitting application data to the broadcasting device on the channel by determining the available interaction channel detected in the preset time period and then selecting the target available interaction channel from the available interaction channels, and lays a foundation for Bluetooth broadcasting bidirectional communication.
Still further, the scanning device determines the target interaction time by presetting the interaction time threshold, the priority of the service data and the random time, so that the reliability and the accuracy of the time when the scanning device sends the application data to the broadcasting device are improved, and the quality and the efficiency of the Bluetooth broadcasting bidirectional communication are ensured.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The bluetooth broadcast bidirectional communication method, apparatus, electronic device and storage medium of the present invention are described below with reference to fig. 1 to 6, where the main implementation body of the bluetooth broadcast bidirectional communication method may be a broadcast device, or may be a scanning device, where the broadcast device at least has a BLE connectable broadcast function, a scannable broadcast function, a broadcast data packet determining function, a timing function, a data receiving window opening function, a data updating function, a data recording function, a data processing function and a communication function, and the scanning device at least has a BLE connectable broadcast receiving function, a scannable broadcast function, a data parsing function, a monitoring function and a communication function, where the broadcast device and the scanning device may be BLE bluetooth devices, and the scanning device may be electronic devices such as a mobile phone and a tablet computer. The specific forms of the broadcasting apparatus and the scanning apparatus are not particularly limited by the present invention.
Referring to fig. 1, a flow chart of a bluetooth broadcast bidirectional communication method according to an embodiment of the present invention is shown, and an execution subject of the bluetooth broadcast bidirectional communication method shown in fig. 1 is a scanning device, where, as shown in fig. 1, the bluetooth broadcast bidirectional communication method includes the following steps:
Step 110, based on the scanned broadcast data packet, acquiring an application data packet fed back to the broadcasting device corresponding to the broadcast data packet.
The broadcast data packet carries the device address information of the broadcast device, the target address information of the scanning device, and the service data updated at the broadcast device end. And, the number of broadcasting devices that perform bluetooth two-way communication with the scanning device may be 1 or may be plural, for example, the number of broadcasting devices may be 127.
Specifically, the scanning device may instruct the scanning bluetooth protocol stack end to scan the broadcast data packet sent by at least one broadcast device, and instruct the scanning bluetooth protocol stack end to report both the scanned broadcast data packet and the target address information of the broadcast device corresponding to the broadcast data packet to the scanning service end through a pre-registered ms_link_ble_scan_cb callback function when the scanning bluetooth protocol stack end scans the broadcast data packet sent by at least one broadcast device, and then instruct the scanning service end to acquire the application data packet and the target address information of the corresponding broadcast device fed back to the broadcast data packet corresponding to the broadcast device, and then send the application data packet and the target address information of the corresponding broadcast device to the scanning bluetooth protocol stack end through a pre-registered ms_ble_conn_adv_rsp reporting function, so as to acquire the application data packet fed back to the broadcast device corresponding to the broadcast data packet.
Step 120, determining a scan request packet based on the broadcast data packet scanned after the preset times, where the scan request packet includes a target available interaction channel identifier and a target interaction time for bluetooth communication with the broadcasting device.
Specifically, the scanning device may instruct the bluetooth protocol stack end to continue scanning the broadcast data packet sent by the broadcast device in the process of acquiring the application data packet fed back to the broadcast device corresponding to the broadcast data packet, and if the broadcast data packet sent by the same broadcast device is scanned after the preset times, the scanning device may determine the scan request packet sent to the broadcast device, so as to determine different scan request packets required to be sent by the scanning device for different broadcast devices. When there are a plurality of broadcasting devices, the scanning device may receive the broadcast data packet sent by each broadcasting device, so there may be a plurality of determined scanning request packets, each scanning request packet may correspond to the target address information of one broadcasting device, and each target interaction time may also correspond to the target address information of one broadcasting device.
And 130, transmitting a scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier.
Specifically, the scanning device may instruct the scanning bluetooth protocol stack end to send the scanning request packet to the corresponding broadcasting device based on the target available interactive channel corresponding to the different target available interactive channel identifier based on the scanning request packet determined by the scanning bluetooth protocol stack end, so as to instruct the different broadcasting device to wait for receiving the application data packet sent by the scanning device based on the target available interactive channel corresponding to the target available interactive channel identifier carried by the received scanning request packet.
And 140, transmitting an application data packet to the broadcasting equipment through the target available interaction channel based on the overtime identification of the target interaction time.
Specifically, when the scanning device determines that the scanning request packet is scanned at the bluetooth protocol stack end, the scanning device may instruct the scanning bluetooth protocol stack end to start a timer according to the target interaction time corresponding to the target address information, where the timing time of the timer is the same as the target interaction time. Based on the above, the scanning device can instruct the scanning bluetooth protocol stack end to monitor the timing time of the timer, and instruct the scanning bluetooth protocol stack end to modulate frequency to the target available interactive channel to send the application data packet to the broadcasting device after the timing time of the timer is overtime. It should be noted that, the scanning device may instruct the scanning bluetooth protocol stack end to preset the hop count or calculate the timestamp in advance, and instruct the scanning bluetooth protocol stack end to monitor that the system hop count reaches the preset hop count, or determine that the target interaction time is overtime when the monitoring timestamp reaches the timestamp calculated in advance, besides determining that the target interaction time is overtime through the timer. The implementation of determining the target interaction time timeout is not particularly limited herein.
The Bluetooth broadcasting bidirectional communication method includes that a scanning device firstly acquires an application data packet fed back to broadcasting devices corresponding to the broadcasting data packet based on the scanned broadcasting data packet, and further determines a scanning request packet based on the broadcasting data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
It can be appreciated that, considering that the scanning bluetooth stack end may also reply to the broadcasting device when the target available interaction channel and the target interaction time are not determined. Based on this, the bluetooth broadcast bi-directional communication method may further include, prior to step 120:
and feeding back response data to the broadcasting equipment based on the broadcasting data packet scanned before the preset times, wherein the response data does not carry the application data packet.
Specifically, after determining the broadcast data packet, the broadcasting device may continuously send the broadcast data packet in a preset broadcast interval, and if the scanning device scans the broadcast data packet sent by the same broadcasting device before the preset times, it may be determined that response data that does not carry application data is fed back to the broadcasting device, that is, the fed back response data only contains device address information of the broadcasting device and target address information of the scanning device. For example, the preset number of times may be 3.
According to the Bluetooth broadcasting bidirectional communication method provided by the invention, the scanning equipment feeds back response data which does not carry application data packets to the broadcasting equipment aiming at the broadcasting data packets scanned before the preset times, so that the integrity and the reliability of Bluetooth broadcasting bidirectional communication are ensured.
It will be appreciated that since the interaction channels over which two devices may communicate bluetooth at different points in time are different, the available interaction channels for a certain period of time may be determined first, followed by the determination of the target available interaction channel. Based on this, the determining of the target available interactive channel identifier for bluetooth communication with the broadcasting device in step 120 includes:
The method comprises the steps of determining available interactive channel identifiers detected in a preset time period, and further determining target available interactive channel identifiers for Bluetooth communication with broadcasting equipment from the available interactive channel identifiers based on the number of the available interactive channel identifiers.
Specifically, the scanning device may instruct the scanning bluetooth protocol stack end to determine a target available interactive channel identifier for bluetooth communication with the broadcasting device, that is, the scanning bluetooth protocol stack end detects the first 15 channels with the minimum bluetooth communication times every preset time period, and determines the channel identifiers of the 15 channels, for example, the channel identifiers may be 15 channel identifiers of the 0 th channel, the 3 rd channel, the 5 th channel, the 7 th channel, etc., the preset time period may be 1s, each channel identifier may be respectively represented by using a bit of 16 system, when the bit value is 1, the channel identifier corresponding to the channel identifier is available, and when the bit value is 0, the channel identifier corresponding to the channel identifier is unavailable, at this time, the scanning bluetooth protocol stack end selects a bit corresponding to the pre-recorded used interactive channel identifier, and performs an or operation on the bit corresponding to the 15 channel identifiers, and the result of the operation is the available interactive channel identifier detected in the preset time period, and the target available channel identifier is determined by using a random number of interactive channel identifiers according to the number of available interactive channel identifiers. For example, when the detected available interactive channel identifiers in the preset duration are the 2 nd channel, the 5 th channel and the 30 th channel, the number of the available interactive channel identifiers is 3, the result of the random number modulo the number of the available interactive channel identifiers is 1, and at this time, the 5 th channel is determined to be the target available interactive channel identifier for bluetooth communication with the broadcasting device from the 2 nd channel, the 5 th channel and the 30 th channel.
According to the Bluetooth broadcasting bidirectional communication method, the scanning equipment improves the accuracy and reliability of transmitting application data to the broadcasting equipment on the channel by determining the available interaction channel detected in the preset time period and selecting the target available interaction channel from the available interaction channels, and lays a foundation for Bluetooth broadcasting bidirectional communication.
It can be understood that, considering that the scanning device can determine the priority of the service data carried by different broadcast data packets, the time from the scanning device to the broadcast data packets sent by different broadcast devices also has a sequence, so the target interaction time can be determined by different priorities and queuing mechanisms of the service data. Based on this, the determining process of the target interaction time for bluetooth communication with the broadcasting device in step 120 includes:
And determining the target interaction time for Bluetooth communication with the broadcasting equipment based on the preset interaction time threshold, the priority data of the service data carried by the broadcasting data packet and the preset random time.
Specifically, the scanning device may instruct the scanning bluetooth protocol stack end to determine the target interaction time of bluetooth communication with the broadcasting device, that is, the scanning bluetooth protocol stack end determines the time result obtained by [ (preset interaction time threshold-priority data×50ms) +preset random time ] as the target interaction time of bluetooth communication with the broadcasting device, the preset interaction time threshold may be default interval data set when no priority is set, for example, the preset interaction time threshold may be 300ms, the priority data may be data between 0 and 5, the greater the priority data, the shorter the determined target interaction time, when the priorities of service data carried by broadcast data packets sent by different broadcasting devices are different, the time when the scanning device correspondingly sends application data packets to different broadcasting devices is also different, that is, the scanning device preferentially sends application data packets to the broadcasting device with high priority, the preset random time may be time data between 0 and 50ms, when the recorded interaction time and (calculated by the preset interaction time threshold-priority data) are calculated, the preset random interaction time is prevented from collision between the random interaction time and 50ms when the random interaction time is calculated (calculated by the preset interaction time threshold-priority data), and the conflict between the preset random interaction time and 50ms is prevented from being calculated when the random interaction time is not determined to occur.
According to the Bluetooth broadcasting bidirectional communication method, the scanning equipment determines the target interaction time by presetting the interaction time threshold, the priority of the service data and the random time, so that the reliability and the accuracy of the time when the scanning equipment sends the application data to the broadcasting equipment are improved, and the quality and the efficiency of Bluetooth broadcasting bidirectional communication are ensured.
It can be appreciated that, considering the problem that the broadcasting device continues to transmit the broadcast data packet to the scanning device due to the network instability that the scanning request packet is not received, the scanning device may transmit the application data packet to the broadcasting device by repeatedly transmitting the scanning request packet. Based on this, the specific implementation procedure of step 140 includes:
firstly, a broadcast data packet which is received again based on the overtime identification of the target interaction time is sent to the broadcast equipment, and then the accumulated sending times of the scan request packet sent to the broadcast equipment are further determined not to exceed the preset sending times, and an application data packet is sent to the broadcast equipment through the target available interaction channel.
Specifically, the scanning device may instruct the scanning bluetooth protocol stack end to send the scanning request packet to the broadcasting device for the first time, may instruct whether the broadcasting device can scan the broadcasting data packet after the timing time of the timer is overtime, if the broadcasting data packet can be scanned after the timing time is overtime, the scanning device may instruct the scanning bluetooth protocol stack end to continue sending the scanning request packet to the broadcasting device, if it is determined that the cumulative number of times of sending the scanning request packet to the broadcasting device does not exceed the preset number of times of sending, the scanning device may be regarded as having received the scanning request packet, and at the moment, the scanning device may instruct the scanning bluetooth protocol stack end to send the application data packet to the broadcasting device through the target available interaction channel, otherwise, if it is determined that the cumulative number of times of sending the scanning request packet to the broadcasting device exceeds the preset number of times of sending, the network between the scanning device and the broadcasting device may be regarded as unstable and unable to perform bluetooth communication, and the bluetooth communication may be stopped, and the preset number of times of sending may be 3.
According to the Bluetooth broadcasting bidirectional communication method provided by the invention, under the condition that the scanning equipment scans the broadcasting data packet after overtime, the scanning equipment continuously sends the scanning request packet to the broadcasting equipment and counts the mode that the accumulated sending times of the scanning request packet do not exceed the preset sending times, and the application data packet is sent to the broadcasting equipment through the target available interactive channel, so that the purpose of Bluetooth broadcasting bidirectional communication is realized when the network stability and reliable communication are ensured.
It will be appreciated that, considering that the application data packet may carry address information and service data of two devices for bluetooth communication, the implementation of step 110 may include:
Firstly, acquiring target address information of broadcasting equipment corresponding to the broadcasting data packet and service data carried by the broadcasting data packet based on the scanned broadcasting data packet, determining application data of replying broadcasting equipment based on the service data, and further acquiring the application data packet fed back to the broadcasting equipment based on the application data, a preset data head, the target address information and equipment address information of the scanning equipment.
Specifically, the scanning device may instruct the scanning service end to perform a type length Value (TYPE LENGTH Value, TLV) format conversion on the broadcast data packet reported by the scanning bluetooth protocol stack end, so as to obtain the target address information of the broadcast data packet corresponding to the broadcast device and the service data carried by the broadcast data packet, and at this time, based on determining that the application data of the broadcast device is replied, the preset data header, the target address information and the device address information of the scanning device, obtain the application data packet fed back to the broadcast device, where the data structure of the application data packet may be as shown in table 1.
TABLE 1
According to the Bluetooth broadcasting bidirectional communication method, the scanning device analyzes service data carried by the broadcasting data packet, and then sets the mode that the application data packet comprises the preset data head, target address information of the broadcasting device, device address information of the scanning device and the service data, so that accuracy and reliability of acquiring the application data packet are improved.
It will be appreciated that the SCAN packet may be a scan_req or an aux_scan_req, and the SCAN packet may broadcast the target address information of the broadcast device and the device address information of the SCAN device, the target available interaction channel identifier, and the target interaction time, which are corresponding to the data packet, and the data structures thereof are shown in table 2.
TABLE 2
According to the Bluetooth broadcasting bidirectional communication method, the scanning data packet carries the target address information of the broadcasting equipment, the equipment address information of the scanning equipment, the target available interaction channel identification and the target interaction time, so that the content richness of the scanning request is improved, and the reliable guarantee is provided for the follow-up Bluetooth broadcasting bidirectional communication.
Referring to fig. 2, a flow chart of a bluetooth broadcast bidirectional communication method according to an embodiment of the present invention is shown, and an execution subject of the bluetooth broadcast bidirectional communication method shown in fig. 2 is a broadcasting device, and as shown in fig. 2, the bluetooth broadcast bidirectional communication method includes the following steps:
step 210, determining a broadcast data packet based on the detected service data update identifier.
Step 220, sending the broadcast data packet to the scanning device.
Step 230, determining a target available interaction channel identifier and a target interaction time based on a received scanning request packet sent by the scanning device;
Step 240, receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the timeout identifier of the target interaction time.
Specifically, when the broadcasting device detects that the service data is updated, sporadic data interaction between the broadcasting device and the scanning device can be performed according to the service data which is distributed and changed inside the broadcasting device, at this time, the broadcasting device can instruct the broadcasting service terminal to update BLE Bluetooth broadcast data to the broadcasting Bluetooth protocol stack terminal through a preset updating function ms_ble_start_conn_adv, send an updated broadcast data packet to the broadcasting Bluetooth protocol stack terminal, and the broadcasting data packet carries the service data updated at this time, and further instruct the broadcasting Bluetooth protocol stack terminal to send BLE connectable broadcast or connectable broadcast (ADV_IND or ADV_SCAN_IND) through Bluetooth protocol requirements, and simultaneously open a data receiving window according to a Bluetooth protocol. And the broadcasting device can instruct the broadcasting Bluetooth protocol stack end to send the broadcasting data packet to the scanning device in a mode of Bluetooth low energy (Bluetooth Low Energy, BLE) connectable broadcasting or scannable broadcasting, and the number of the scanning devices can be 1 or more. The number of scanning devices is not particularly limited herein.
In addition, the broadcasting device may instruct the broadcasting bluetooth protocol stack end to receive the scan request packet sent by the scanning device, instruct the broadcasting bluetooth protocol stack end to perform data analysis on the scan request packet according to a data format of the scan request packet, extract the target available interaction channel identifier and the target interaction time, and instruct the broadcasting device to wait for the scanning device to send the service data packet based on the target available interaction channel identifier and the target interaction time again at this time, that is, after the target interaction time is overtime, the broadcasting bluetooth protocol stack end receives the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier.
According to the Bluetooth broadcasting bidirectional communication method provided by the invention, the broadcasting equipment firstly updates the identification based on the detected service data, determines the broadcasting data packet to be sent to the scanning equipment, then extracts the target available interaction channel identification and the target interaction time from the received scanning request packet, and receives the application data packet sent by the scanning equipment on the target available interaction channel after the target interaction time is overtime, so that the Bluetooth bidirectional communication can be performed quickly and reliably by sporadically carrying out a small amount of data interaction between the broadcasting equipment and the scanning equipment, thereby effectively improving the efficiency of the Bluetooth broadcasting bidirectional communication and expanding the application range.
Referring to fig. 3, a schematic data interaction flow chart of the bluetooth broadcast bidirectional communication system provided by the invention is shown in fig. 3, where the bluetooth broadcast bidirectional communication system includes a scanning device and a broadcasting device, the scanning device executes the method of executing the main body as the scanning device in the foregoing embodiment, and the broadcasting device executes the method of executing the main body as the broadcasting device in the foregoing embodiment. The scanning device sends the application data packet to the broadcasting device, so that the broadcasting device is helped to sense the receiving condition of the broadcasting data packet, the redundant broadcasting quantity caused by the fact that the receiving condition of the broadcasting cannot be sensed is reduced, the power consumption of the broadcasting device is reduced, the signal interference source in Bluetooth broadcasting communication is reduced, meanwhile, the scanning device controls the broadcasting device, the efficiency of actively acquiring the service data of the broadcasting device side by the scanning device is also increased, the application range of Bluetooth broadcasting bidirectional communication is greatly improved, and the communication quality is also ensured. And will not be described in detail herein.
The Bluetooth broadcasting bidirectional communication system provided by the invention has the advantages that the broadcasting equipment firstly determines the broadcasting data packet to be sent to the scanning equipment based on the detected service data updating identification, then extracts the target available interaction channel identification and the target interaction time from the received scanning request packet, and receives the application data packet sent by the scanning equipment through the target available interaction channel after the target interaction time is overtime, so that the Bluetooth bidirectional communication can be performed rapidly and reliably by sporadically carrying out a small amount of data interaction between the broadcasting equipment and the scanning equipment, the efficiency of Bluetooth broadcasting bidirectional communication is effectively improved, the application range is enlarged, further, the scanning equipment firstly acquires the application data packet fed back to the broadcasting equipment corresponding to the broadcasting data packet based on the scanned broadcasting data packet, and further determines the scanning request packet based on the broadcasting data packet scanned after the preset times. Since the scan request packet includes the target available interaction channel identification and the target interaction time for bluetooth communication with the broadcasting device, the scanning device is able to transmit the scan request packet to the broadcasting device based on the target available interaction channel corresponding to the target available interaction channel identification, and is also able to transmit the application data packet to the broadcasting device through the target available interaction channel based on the timeout identification of the target interaction time. The scanning device sends the scanning request packet carrying the target available interaction channel identifier and the target interaction time to the broadcasting device, and the application data packet is sent to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier after the target interaction time is overtime, so that the data receiving quality can be ensured without repeatedly sending the broadcasting data packet, and the communication efficiency and the communication quality of Bluetooth broadcasting bidirectional communication are effectively improved.
It can be appreciated that, considering that when the broadcasting device transmits bluetooth broadcast to the plurality of scanning devices, there is a case that an application data packet of at least one scanning device is not received or a music data packet of the plurality of scanning devices can be received, the bluetooth broadcasting state can be adjusted by the monitored application data packet. Based on this, the bluetooth broadcast bidirectional communication method may further include:
Firstly, the number of application data packets is matched with the number of scanning devices, and then the Bluetooth broadcasting state is updated to be in a stopped Bluetooth broadcasting state based on the successful matching result of the number of application data packets and the number of scanning devices, or the Bluetooth broadcasting state is updated to be in a continuous broadcasting state based on the unsuccessful matching result of the number of application data packets and the number of scanning devices.
Specifically, when the same broadcasting device indicates that the broadcasting bluetooth protocol stack end sends BLE connectable broadcast or scannable broadcast to a plurality of scanning devices, the broadcasting bluetooth protocol stack may be indicated to receive an application data packet for each scanning device, and indicate that the broadcasting bluetooth protocol stack reports the application data packet to the broadcasting service end through an ms_link_ble_adv_cb callback function, at this time, the broadcasting device indicates the broadcasting service end to determine a bluetooth broadcasting state based on the number of application data packets, for example, the broadcasting device sends BLE connectable broadcast or scannable broadcast to 3 scanning devices, if the received application data packet is for the 3 scanning devices, it is determined that the number of application data packets is successfully matched with the number of scanning devices at this time, and the bluetooth broadcasting state is updated to stop the bluetooth broadcasting state, if the received application data packet is for 1 scanning device or 2 scanning devices in the 3 scanning devices, it is determined that the number of application data packets is failed to be matched with the number of scanning devices at this time, the broadcasting service end may be updated to the bluetooth broadcasting state, and the bluetooth broadcasting state may be continuously determined to be the bluetooth broadcasting state, and the bluetooth broadcasting state may be continuously represented to continuously send BLE connectable broadcast or scannable. Then, the broadcasting device may instruct the broadcasting service end to issue an update instruction of the bluetooth broadcast state to the broadcasting bluetooth protocol stack end, and instruct the broadcasting bluetooth protocol stack end to perform setting or updating of the related parameters based on the update instruction.
According to the Bluetooth broadcasting bidirectional communication method provided by the invention, the broadcasting equipment determines whether the Bluetooth broadcasting state is updated to be the stopped Bluetooth broadcasting state or the continuously Bluetooth broadcasting state by judging the matching relation between the number of the response data packets and the number of the scanning equipment, so that the flexibility and the reliability of Bluetooth broadcasting bidirectional communication are ensured, the efficiency of the Bluetooth broadcasting bidirectional communication is improved, and the application range is also enlarged.
Referring to fig. 4, a schematic structural diagram of a bluetooth broadcast bidirectional communication device according to the present invention is shown in fig. 4, and the bluetooth broadcast bidirectional communication device 400 includes:
An obtaining module 410, configured to obtain, based on the scanned broadcast data packet, an application data packet fed back to a broadcasting device corresponding to the broadcast data packet;
A first determining module 420, configured to determine, based on the broadcast data packet scanned after the preset number of times, a scan request packet, where the scan request packet includes a target available interaction channel identifier and a target interaction time for bluetooth communication with the broadcasting device;
a first transmitting module 430, configured to transmit a scan request packet to a broadcasting device based on a target available interactive channel identifier;
the second sending module 440 is configured to send, based on the timeout identifier of the target interaction time, an application data packet to the broadcasting device through the target available interaction channel corresponding to the target available interaction channel identifier.
It will be appreciated that the determining of the target available interactive channel identifier for bluetooth communication with the broadcasting device in the first determining module 420 includes determining the available interactive channel identifiers detected within a preset time period, and determining the target available interactive channel identifier for bluetooth communication with the broadcasting device from the available interactive channel identifiers based on the number of the available interactive channel identifiers.
It may be appreciated that the determining process of the target interaction time for bluetooth communication with the broadcasting device in the first determining module 420 includes determining the target interaction time for bluetooth communication with the broadcasting device based on a preset interaction time threshold, priority data of service data carried by the broadcasting data packet, and a preset random time.
It can be appreciated that the second sending module 440 may be specifically configured to send the scan request packet to the broadcasting device based on the received broadcast data packet again identified by the timeout of the target interaction time, and determine that the cumulative number of times of sending the scan request packet to the broadcasting device does not exceed the preset number of times of sending, and send the application data packet to the broadcasting device through the target available interaction channel.
It can be appreciated that the first sending module 410 may be specifically configured to obtain, based on the scanned broadcast data packet, the target address information of the broadcast device corresponding to the broadcast data packet and the service data carried by the broadcast data packet, determine, based on the service data, to reply to the application data of the broadcast device, and obtain, based on the application data, the preset data header, the target address information and the device address information of the scanning device, the application data packet fed back to the broadcast device.
It will be appreciated that the scan data packet in the first determining module 420 includes the target address information of the broadcast device and the device address information of the scan device corresponding to the broadcast data packet, the target available interaction channel identifier and the target interaction time.
Referring to fig. 5, a schematic structural diagram of a bluetooth broadcast bidirectional communication device according to the present invention is shown in fig. 5, and the bluetooth broadcast bidirectional communication device 500 includes:
A second determining module 510, configured to determine a broadcast data packet based on the detected service data update identifier;
a third transmitting module 520, configured to transmit the broadcast data packet to the scanning device;
A second determining module 530, configured to determine a target available interaction channel identifier and a target interaction time based on a received scan request packet sent by the scanning device;
And the receiving module 540 is configured to receive, based on the timeout identifier of the target interaction time, an application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier.
It can be understood that the bluetooth broadcast bidirectional communication device can further comprise an updating module, which can be specifically used for matching the number of application data packets with the number of scanning devices, updating the bluetooth broadcast state to a stopped bluetooth broadcast state based on the successful matching result of the number of application data packets with the number of scanning devices, and updating the bluetooth broadcast state to a continuous broadcast state based on the unsuccessful matching result of the number of application data packets with the number of scanning devices.
Fig. 6 illustrates a physical schematic diagram of an electronic device, which may include a processor 610, a communication interface Communications Interface, a memory 630, and a communication bus 640, as shown in fig. 6, where the processor 610, the communication interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 may call logic instructions in the memory 630 to perform the following methods:
Based on the scanned broadcast data packet, acquiring an application data packet fed back to the broadcasting equipment corresponding to the broadcast data packet;
Based on the broadcast data packet scanned after the preset times, determining a scanning request packet, wherein the scanning request packet comprises a target available interaction channel identifier and target interaction time for Bluetooth communication with broadcasting equipment;
Transmitting a scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier;
and transmitting the application data packet to the broadcasting equipment through the target available interaction channel based on the overtime identification of the target interaction time. And/or the number of the groups of groups,
Determining a broadcast data packet based on the detected service data update identifier;
Transmitting a broadcast data packet to a scanning device;
determining a target available interaction channel identifier and target interaction time based on a received scanning request packet sent by scanning equipment;
And receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
Further, the logic instructions in the memory 630 may be implemented in the form of software functional units and stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the related art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, an optical disk, or other various media capable of storing program codes.
In another aspect, embodiments of the present invention disclose a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, are capable of performing the methods provided by the above-described method embodiments, for example comprising:
Based on the scanned broadcast data packet, acquiring an application data packet fed back to the broadcasting equipment corresponding to the broadcast data packet;
Based on the broadcast data packet scanned after the preset times, determining a scanning request packet, wherein the scanning request packet comprises a target available interaction channel identifier and target interaction time for Bluetooth communication with broadcasting equipment;
Transmitting a scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier;
and transmitting the application data packet to the broadcasting equipment through the target available interaction channel based on the overtime identification of the target interaction time. And/or the number of the groups of groups,
Determining a broadcast data packet based on the detected service data update identifier;
Transmitting a broadcast data packet to a scanning device;
determining a target available interaction channel identifier and target interaction time based on a received scanning request packet sent by scanning equipment;
And receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
In yet another aspect, embodiments of the present invention further provide a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor is implemented to perform the transmission method provided in the above embodiments, for example, including:
Based on the scanned broadcast data packet, acquiring an application data packet fed back to the broadcasting equipment corresponding to the broadcast data packet;
Based on the broadcast data packet scanned after the preset times, determining a scanning request packet, wherein the scanning request packet comprises a target available interaction channel identifier and target interaction time for Bluetooth communication with broadcasting equipment;
Transmitting a scanning request packet to the broadcasting equipment based on the target available interactive channel corresponding to the target available interactive channel identifier;
and transmitting the application data packet to the broadcasting equipment through the target available interaction channel based on the overtime identification of the target interaction time. And/or the number of the groups of groups,
Determining a broadcast data packet based on the detected service data update identifier;
Transmitting a broadcast data packet to a scanning device;
determining a target available interaction channel identifier and target interaction time based on a received scanning request packet sent by scanning equipment;
And receiving the application data packet sent by the scanning device on the target available interaction channel corresponding to the target available interaction channel identifier based on the overtime identifier of the target interaction time.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on such understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the related art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that the above-mentioned embodiments are merely illustrative of the invention, and not limiting. While the invention has been described in detail with reference to the embodiments, those skilled in the art will appreciate that various combinations, modifications, or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and it is intended to be covered by the scope of the claims of the present invention.