Flow control method, device and storage medium based on BLE GATT
By adopting a flow control method based on BLE GATT in the BLE Mesh network, classifying, deduplication and timing the GATT channel messages, solving the problem of unreliable and unreal-time messages in the BLE Mesh network, and realizing the reliability and real-time messages transmission.
Patent Information
- Application Number
- CN202111608428.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-12-24
AI Technical Summary
The message sending and receiving based on Gatt connections in the BLE Mesh network is not real-time and unreliable, especially when the device receiver can only process a limited number of PDUs per unit time, resulting in too many GATT channel messages causing channel congestion, resulting in message loss and real-time Sexual problems.
Using the flow control method based on BLE GATT, the Mqtt message sent by the terminal device is classified and deduplicated, and the message is requested regularly and sent to the filter. The filtered message is stored in the GATT channel message pool and passed through the GATT proxy. The device is forwarded to each Mesh network device.
It effectively solves the probabilistic message loss and message real-time problems caused by excessive GATT channel messages, ensuring that PDU sends and receives events in real time and reliably.
Smart Images

Figure CN114268934B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of BLE Mesh networks, and in particular to a flow control method, device and computer-readable storage medium based on BLE GATT. Background Art
[0002] There are many reasons why BLE (Bluetooth Low Energy) Mesh network messages on the GATT (Generic Attribute Profile Specification) channel are unreliable, such as BLE devices being interfered by other signals, or too many GATT channel messages causing congestion, which may cause GATT channel messages to be lost. Although BLE spread spectrum and adaptive frequency hopping design have solved most of the signal interference problems, the unreal-time Mesh messages on the GATT channel are mainly reflected in the fact that because the receiver can only process a limited number of PDUs (Protocol Data Units) per unit time, the number of GATT channel messages will be large, causing channel congestion and unreliable BLE Mesh messages. In other words, when users frequently issue commands on the client, the BLE Mesh network device receives too many messages in a short period of time, causing the user's state to be inconsistent with the state the user wants when using the BLE Mesh network device. Summary of the invention
[0003] The main purpose of the present invention is to provide a flow control method based on BLE GATT, aiming to solve the technical problem that the Ble Mesh message reception and transmission based on Gatt connection in the prior art is not real-time and unreliable.
[0004] To achieve the above object, the present invention provides a flow control method based on BLE GATT, and the flow control method based on BLE GATT includes:
[0005] receiving a first Mqtt message sent by a terminal device, and after classifying the first Mqtt message, performing deduplication processing on a second Mqtt message obtained by the classification;
[0006] Request and send the second Mqtt message to the filter at a fixed time, and store the filtered third Mqtt message in the GATT channel message pool;
[0007] Send the third Mqtt message in the GATT channel message pool to the GATT proxy device, so that the GATT proxy device forwards the third Mqtt message to each Mesh network device.
[0008] Optionally, the step of performing deduplication processing on the classified second MQTT message includes:
[0009] The second Mqtt message is stored in a Map, in which a deduplication process is performed using the serial number of the Mesh network device corresponding to the second Mqtt message as a key and the incremental entity class of the Mesh network device as a value.
[0010] Optionally, the step of regularly requesting and sending a second MQTT message to the filter further includes:
[0011] While receiving the second Mqtt message obtained by classification, notifying the scheduled task to request the second Mqtt message in the Map in real time, and sending the second Mqtt message to the filter;
[0012] If the number of the second Mqtt messages in the Map is greater than the threshold of the GATT channel message pool, sending the second Mqtt messages of the threshold number of the GATT channel message pool from the Map to the filter.
[0013] Optionally, after the step of timing the request and sending the second Mqtt message to the filter, the method further includes:
[0014] Determine whether the target distribution device corresponding to the second Mqtt message is a Mesh network device;
[0015] If the target distribution device corresponding to the second Mqtt message is not a Mesh network device, remove the second Mqtt message from the Map.
[0016] Optionally, after the step of determining whether the target distribution device corresponding to the second MQTT message is a Mesh network device, the step further includes:
[0017] If the target distribution device corresponding to the second Mqtt message is a Mesh network device, determine whether the monitored GATT proxy device is online;
[0018] If the GATT proxy device is not online, remove the second Mqtt message from the Map.
[0019] Optionally, after the step of determining whether the monitored GATT proxy device is online, the method further includes:
[0020] If the monitored GATT proxy device is online, determining whether the number of the third Mqtt message in the GATT channel message pool is greater than a threshold of the GATT channel message pool;
[0021] If the number of third Mqtt messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, then after the number of third Mqtt messages in the GATT channel message pool is less than the threshold of the GATT channel message pool, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is performed.
[0022] Optionally, after the step of determining whether the number of the third MQTT message in the GATT channel message pool is greater than the threshold of the GATT channel message pool, the method further includes:
[0023] If the number of the third Mqtt message in the GATT channel message pool is not greater than the threshold of the GATT channel message pool, determining whether the serial number keyword and the incremental entity class value of the third Mqtt message are equal to the serial number keyword and the incremental entity class value of the corresponding target Mesh network device;
[0024] If they are not equal, executing the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device;
[0025] If they are equal, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is not performed, and the second Mqtt message is removed from the Map.
[0026] Optionally, the BLE GATT-based flow control method further includes:
[0027] If one of the third Mqtt messages is sent to the GATT proxy device, the number of the third Mqtt messages in the GATT channel message pool is increased by one;
[0028] If the GATT channel message pool receives the same third Mqtt message from the Mesh network device after sending the third Mqtt message, the number of third Mqtt messages in the GATT channel message pool is reduced by one, and the corresponding Mqtt message is removed from the Map;
[0029] If the number of third Mqtt messages in the GATT channel message pool is equal to the GATT channel message pool threshold, stop sending the third Mqtt message.
[0030] In addition, to achieve the above-mentioned purpose, the present invention also provides a BLE GATT-based flow control device, wherein the BLE GATT-based flow control device comprises: a memory, a processor, and a BLE GATT-based flow control program stored in the memory and executable on the processor, wherein the BLE GATT-based flow control program implements the steps of the BLE GATT-based flow control method as described above when executed by the processor.
[0031] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a flow control program based on BLE GATT is stored. When the flow control program based on BLE GATT is executed by a processor, the steps of the flow control method based on BLE GATT as described above are implemented.
[0032] The embodiment of the present invention proposes a flow control method, device and computer-readable storage medium based on BLE GATT. First, after receiving the first Mqtt message sent by the terminal device, the first Mqtt message is classified and processed to obtain the second Mqtt message and deduplicate the second Mqtt message; then, the second Mqtt message is regularly requested and sent to the filter, and the third Mqtt message is filtered and stored in the GATT channel message pool; finally, the third Mqtt message in the GATT channel message pool is sent to the GATT proxy device, so that it forwards the third Mqtt message to each Mesh network device. Therefore, for the application scenario where the receiver can only process a limited number of PDUs per unit time, the flow control method is adopted to make corresponding processing for the unreliable and non-real-time situation of the GATT channel message, which can effectively solve the problem of probabilistic message loss caused by too many GATT channel messages and the real-time nature of the message, so that the PDU sending and receiving events can be effectively and reliably sent and received in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a schematic diagram of the structure of the operating device of the hardware operating environment involved in the embodiment of the present invention;
[0034] Figure 2 It is a flow chart of an embodiment of a flow control method based on BLE GATT of the present invention;
[0035] Figure 3 It is a schematic diagram of another embodiment of the flow control method based on BLE GATT of the present invention.
[0036] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0037] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0038] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of the operating equipment of the hardware operating environment involved in the embodiment of the present invention.
[0039] like Figure 1 As shown, the operating device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0040] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the operating device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0041] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and a flow control program based on BLE GATT.
[0042] exist Figure 1 In the running device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the running device of the present invention can be set in the running device, and the running device calls the BLEGATT-based flow control program stored in the memory 1005 through the processor 1001, and performs the following operations:
[0043] receiving a first Mqtt message sent by a terminal device, and after classifying the first Mqtt message, performing deduplication processing on a second Mqtt message obtained by the classification;
[0044] Request and send the second Mqtt message to the filter at a fixed time, and store the filtered third Mqtt message in the GATT channel message pool;
[0045] Send the third Mqtt message in the GATT channel message pool to the GATT proxy device, so that the GATT proxy device forwards the third Mqtt message to each Mesh network device.
[0046] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0047] The step of performing deduplication processing on the second Mqtt message obtained by classification includes:
[0048] The second Mqtt message is stored in a Map, in which a deduplication process is performed using the serial number of the Mesh network device corresponding to the second Mqtt message as a key and the incremental entity class of the Mesh network device as a value.
[0049] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0050] The step of timing requesting and sending the second Mqtt message to the filter also includes:
[0051] While receiving the second Mqtt message obtained by classification, notifying the scheduled task to request the second Mqtt message in the Map in real time, and sending the second Mqtt message to the filter;
[0052] If the number of the second Mqtt messages in the Map is greater than the threshold of the GATT channel message pool, sending the second Mqtt messages of the threshold number of the GATT channel message pool from the Map to the filter.
[0053] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0054] After the step of timing requesting and sending the second Mqtt message to the filter, the method further includes:
[0055] Determine whether the target distribution device corresponding to the second Mqtt message is a Mesh network device;
[0056] If the target distribution device corresponding to the second Mqtt message is not a Mesh network device, remove the second Mqtt message from the Map.
[0057] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0058] After the step of determining whether the target distribution device corresponding to the second MQTT message is a Mesh network device, the method further includes:
[0059] If the target distribution device corresponding to the second Mqtt message is a Mesh network device, determine whether the monitored GATT proxy device is online;
[0060] If the GATT proxy device is not online, remove the second Mqtt message from the Map.
[0061] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0062] After the step of determining whether the monitored GATT proxy device is online, the method further includes:
[0063] If the monitored GATT proxy device is online, determining whether the number of the third Mqtt message in the GATT channel message pool is greater than a threshold of the GATT channel message pool;
[0064] If the number of third Mqtt messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, then after the number of third Mqtt messages in the GATT channel message pool is less than the threshold of the GATT channel message pool, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is performed.
[0065] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0066] After the step of determining whether the number of the third MQTT messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, the method further includes:
[0067] If the number of the third Mqtt message in the GATT channel message pool is not greater than the threshold of the GATT channel message pool, determining whether the serial number keyword and the incremental entity class value of the third Mqtt message are equal to the serial number keyword and the incremental entity class value of the corresponding target Mesh network device;
[0068] If they are not equal, executing the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device;
[0069] If they are equal, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is not performed, and the second Mqtt message is removed from the Map.
[0070] Further, the processor 1001 may call a BLE GATT-based flow control program stored in the memory 1005, and further perform the following operations:
[0071] The BLE GATT-based flow control method further includes:
[0072] If one of the third Mqtt messages is sent to the GATT proxy device, the number of the third Mqtt messages in the GATT channel message pool is increased by one;
[0073] If the GATT channel message pool receives the same third Mqtt message from the Mesh network device after sending the third Mqtt message, the number of third Mqtt messages in the GATT channel message pool is reduced by one, and the corresponding Mqtt message is removed from the Map;
[0074] If the number of third Mqtt messages in the GATT channel message pool is equal to the GATT channel message pool threshold, stop sending the third Mqtt message.
[0075] The embodiment of the present invention provides a flow control method based on BLE GATT, referring to Figure 2 , Figure 2 The figure is a flow chart of a first embodiment of a flow control method based on BLE GATT of the present invention.
[0076] In this embodiment, the flow control method based on BLE GATT includes:
[0077] Step S10: receiving a first Mqtt message sent by a terminal device, and after classifying the first Mqtt message, performing deduplication processing on a second Mqtt message obtained by classification.
[0078] Many of the reliability issues that the Bluetooth protocol stack addresses stem from the fact that radio is used as a carrier for data. But there are other sources of reliability issues for wired communications. When one device sends data to another, it sends it in a series of packets. If the receiving device cannot process the packets quickly enough, it may be forced to start dropping packets and the data they contain when its buffer reaches capacity.
[0079] Flow control is the name of various strategies for ensuring that data is communicated at a rate that the receiving device or component can accommodate, and BLE (Bluetooth Low Energy) provides a simple form of flow control for the link layer. By not updating the NESN (Next Expected Sequence Number) device when sending a reply, the first device can resend the original data packet at a later time. Since the original data packet has already been received and processed, the retransmitted copy will be discarded, thus slowing down the arrival of new data packets that need to be fully processed. L2CAP (Logical Link Control and Adaptation Protocol) supports a variety of more complex flow control modes, such as enhanced credit flow control mode, which is used in conjunction with EATT (Enhanced Attribute Protocol).
[0080] Credit flow control is a special way to solve this problem. In general (in the prior art), it works as follows: the transmitting device knows the capacity of the receiving device, in terms of the number of PDUs (Protocol Data Units) it can process without losing data (for example, by overflowing its buffer). The transmitter sets a counter based on this receiver capacity limit. Every time the transmitter sends a PDU, the counter is decremented. When the value of the counter reaches zero, the transmitter knows that the receiver is full, so it temporarily stops sending further PDUs while the receiver processes the backlog of PDUs. After the receiver reads and processes one or more PDUs from its buffer, it sends the corresponding credit back to the transmitter, which uses this value to increment its counter. While the counter is non-zero, the transmitter can continue to send further PDUs.
[0081] In this embodiment, refer to Figure 3, Gateway (i.e. transmitter) will receive the first Mqtt (Message Queuing Telemetry Transport) message when each terminal such as Android, IOS and Google Assistant (Google Assistant, which supports voice recognition, artificial intelligence, natural speech understanding and other functions) accesses the Mesh network, and classifies and processes the first Mqtt message.
[0082] If the PDU sent to the receiver does not receive a response or does not carry a confirmation message, the transmitter can no longer send data to the receiver and can only wait for the PDU command to time out and be removed from the GATT channel message pool. In this way, the transmitter will have a serious delay when sending data. Figure 3 The Mqtt connection in: Gateway has already classified the messages when receiving the first Mqtt message (PDU message in this embodiment). The messages related to the Mesh network device will be stored in the Map and then go through the flow control channel, while the unconfirmed messages ( Figure 3 Other messages in the flow control channel will not go through the flow control channel. This ensures that the messages sent through the flow control channel are valid and reliable. Then, the second Mqtt message obtained by classification is deduplicated in the Map.
[0083] Step S20: regularly requesting and sending the second Mqtt message to the filter, and storing the filtered third Mqtt message in the GATT channel message pool.
[0084] To ensure the validity of the message, in this embodiment, the flow control creates a filter when sending data to the GATT proxy device to filter invalid PDU messages, such as Figure 3 As shown: There is a filter process set up. When the scheduled task requests the second Mqtt message in the Map, the second Mqtt message is sent to the filter. Figure 3 After filtering, the filter process in the filter obtains the third Mqtt message, sends the third Mqtt message to the GATT channel message pool, and then performs further forwarding operations.
[0085] Step S30: Send the third Mqtt message in the GATT channel message pool to the GATT proxy device, so that the GATT proxy device forwards the third Mqtt message to each Mesh network device.
[0086] In this embodiment, the third Mqtt message in the GATT channel message pool is sent to a node device in the Mesh network: a GATT proxy device, and the GATT proxy device forwards the third Mqtt message to other node devices in the Mesh network.
[0087] In this embodiment, first, after receiving the first Mqtt message sent by the terminal device, the first Mqtt message is classified and processed to obtain the second Mqtt message and deduplicate the second Mqtt message; then, the second Mqtt message is periodically requested and sent to the filter, and the third Mqtt message is filtered and stored in the GATT channel message pool; finally, the third Mqtt message in the GATT channel message pool is sent to the GATT proxy device, so that it forwards the third Mqtt message to each Mesh network device. Therefore, for the application scenario where the receiver can only process a limited number of PDUs per unit time, the flow control method is adopted to make corresponding processing for the unreliable and non-real-time situation of the GATT channel message, which can effectively solve the problem of probabilistic message loss caused by too many GATT channel messages and the real-time nature of the message, so that the PDU sending and receiving events can be effectively and reliably sent and received in real time.
[0088] Optionally, the step of performing deduplication processing on the classified second MQTT message includes:
[0089] The second Mqtt message is stored in a Map, in which a deduplication process is performed using the serial number of the Mesh network device corresponding to the second Mqtt message as a key and the incremental entity class of the Mesh network device as a value.
[0090] A buffer is temporary storage in a computer or microcontroller's memory. Because there is limited memory available, each protocol layer may need one or more buffers. Each buffer has a maximum size. When one device sends data to another, it sends the data in a series of confidential packets. Once these packets are received by the other device, they are typically placed temporarily in a buffer. The packets are then passed up through the layers of the protocol stack, and may temporarily stop at other buffers along the way. If packets arrive at a buffer faster than they can be removed from it, eventually the buffer will overflow and some packets will be dropped. When this happens, the data contained in those packets is lost and may be seen as a communication failure.
[0091] In this embodiment, the Map is regarded as the above-mentioned cache area. Figure 31: After Gateway receives the second Mqtt message, it will be stored in the Map. The Map will use the SN (Sequence Number) of the BLE Mesh network device as the key, and the incremental entity class generated by the command set of the BLE Mesh network device as the value. The command set includes control instructions for various messages, such as commands to control Mesh network devices, commands to obtain the version number of Mesh network devices, etc. The entity class can be regarded as a subset of the command set, which stores one or more or even all the commands in the command set. For example, when a switch command of a Mesh network device is stored in the Map, and a command to save the version number of a Mesh network device is also stored, it is equivalent to incremental processing of the command set, and saving these two command messages in the incremental entity class.
[0092] The specific deduplication processing steps are as follows: When the second Mqtt message of opening and closing a Mesh network device is received continuously in a short period of time, because the GATT channel message pool cannot consume it, or cannot consume it, the last second Mqtt message will overwrite the second Mqtt message of opening, closing, and opening with the same SN keyword received before, so only the data of the last second Mqtt message of closing the Mesh network device exists, so the last received message is used as the standard, thereby ensuring that each BLE Mesh network device in the memory has only one piece of data, thereby completing the deduplication processing. By adding a deduplication mechanism, when the client sends a large amount of data to the Gateway, the user can effectively and in real time get the expected results of the BLEMesh network device.
[0093] Optionally, the step of regularly requesting and sending a second MQTT message to the filter further includes:
[0094] While receiving the second Mqtt message obtained by classification, notifying the scheduled task to request the second Mqtt message in the Map in real time, and sending the second Mqtt message to the filter;
[0095] If the number of the second Mqtt messages in the Map is greater than the threshold of the GATT channel message pool, sending the second Mqtt messages of the threshold number of the GATT channel message pool from the Map to the filter.
[0096] In this embodiment, if Figure 32 places in it: The scheduled task is used to consume the second Mqtt message in the Map, and the Map is requested once per second. If there is a second Mqtt data, it will be consumed, and the filter process will continue, that is, the scheduled task will request the second Mqtt message in the Map in real time and send it to the filter process. When the Gateway receives the first Mqtt message, it will immediately notify the scheduled task to request a Map to ensure that the second Mqtt message in the Map is consumed in real time. If the number of second Mqtt messages received by the Map is greater than the threshold of the GATT channel message pool, then at the beginning, only the threshold number of messages in the GATT channel message pool can be consumed, and other messages need to wait for the GATT channel message pool to vacate before they can be sent.
[0097] Optionally, after the step of timing the request and sending the second Mqtt message to the filter, the method further includes:
[0098] Determine whether the target distribution device corresponding to the second Mqtt message is a Mesh network device;
[0099] If the target distribution device corresponding to the second Mqtt message is not a Mesh network device, remove the second Mqtt message from the Map.
[0100] In this embodiment, after the scheduled task requests and sends the second Mqtt message to the filter, it is determined whether the target distribution device corresponding to the second Mqtt message is a Mesh network device and whether a Mesh network corresponding to the Mqtt message is configured. That is, in the device-related message (i.e., the second Mqtt message obtained after classifying and deduplicating the first Mqtt message in step S10), it is determined whether the target distribution device corresponding to the second Mqtt message is a Mesh network device. If so, the subsequent judgment process is performed. If not, the second Mqtt message is removed from the Map.
[0101] Optionally, after the step of determining whether the target distribution device corresponding to the second MQTT message is a Mesh network device, the step further includes:
[0102] If the target distribution device corresponding to the second Mqtt message is a Mesh network device, determine whether the monitored GATT proxy device is online;
[0103] If the GATT proxy device is not online, remove the second Mqtt message from the Map.
[0104] In this embodiment, if the target distribution device corresponding to the second Mqtt message obtained after classification and deduplication is a Mesh network device, then it is determined whether the monitored GATT proxy device is online. That is, if the monitored GATT proxy device is online, that is, the GATT proxy device is connected to the Mesh network device and the GATT proxy device is online, the subsequent judgment process is performed. If not, the second Mqtt message is removed from the Map.
[0105] Optionally, after the step of determining whether the monitored GATT proxy device is online, the method further includes:
[0106] If the monitored GATT proxy device is online, determining whether the number of the third Mqtt message in the GATT channel message pool is greater than a threshold of the GATT channel message pool;
[0107] If the number of third Mqtt messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, then after the number of third Mqtt messages in the GATT channel message pool is less than the threshold of the GATT channel message pool, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is performed.
[0108] In this embodiment, if the target distribution device corresponding to the second Mqtt message obtained after classification and deduplication is a Mesh network device, and the monitored GATT proxy device is online, it is then determined whether the number of third Mqtt messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool.
[0109] The GATT channel message pool of the Gateway will set a threshold, which is set to 7 third MQTT messages in this embodiment. In other communication methods, such as not using GATT as the communication method of the carrier channel, but connecting to the MESH network via a serial port or HTTP, the threshold of the number of messages can be increased accordingly.
[0110] Optionally, after the step of determining whether the number of the third MQTT message in the GATT channel message pool is greater than the threshold of the GATT channel message pool, the method further includes:
[0111] If the number of the third Mqtt message in the GATT channel message pool is not greater than the threshold of the GATT channel message pool, determining whether the serial number keyword and the incremental entity class value of the third Mqtt message are equal to the serial number keyword and the incremental entity class value of the corresponding target Mesh network device;
[0112] If they are not equal, executing the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device;
[0113] If they are equal, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is not performed, and the second Mqtt message is removed from the Map.
[0114] In this embodiment, if the target distribution device corresponding to the second Mqtt message obtained after classification and deduplication is a Mesh network device, and the monitored GATT proxy device is online, and the number of the third Mqtt message in the GATT channel message pool is not greater than the threshold of the GATT channel message pool, then it is determined whether the serial number keyword and incremental entity class value of the third Mqtt message are equal to the serial number keyword and incremental entity class value of the corresponding target Mesh network device. That is, the sent value is equal to the current value of the device, that is, the sent value is a status message for turning on the device, and the current switch state of the device is in the on state, then there is no need to send the open state message again, and remove the corresponding second Mqtt message from the Map. Only when the sent value is a status message for turning on the device, and the current switch state of the device is in the off state, or the sent value is a status message for turning off the device, and the current switch state of the device is in the on state, it is necessary to send the open or closed state message to the device. If the serial number keyword and incremental entity class value of the third Mqtt message are not equal to the serial number keyword and incremental entity class value of the corresponding target Mesh network device, the third Mqtt message will not be processed, and the filter process will be performed on other Mqtt messages in the Map.
[0115] Optionally, the BLE GATT-based flow control method further includes:
[0116] If one of the third Mqtt messages is sent to the GATT proxy device, the number of the third Mqtt messages in the GATT channel message pool is increased by one;
[0117] If the GATT channel message pool receives the same third Mqtt message from the Mesh network device after sending the third Mqtt message, the number of third Mqtt messages in the GATT channel message pool is reduced by one, and the corresponding Mqtt message is removed from the Map;
[0118] If the number of third Mqtt messages in the GATT channel message pool is equal to the GATT channel message pool threshold, stop sending the third Mqtt message.
[0119] In this embodiment, when the Gateway (i.e., the transmitter) sends data to the GATT proxy device (i.e., the receiver) once, the GATT channel message pool will add one piece of data, but the message pool will only add one piece of data after sending data to the receiver once, that is, the position of one piece of data is vacated to receive the new third MQTT message. When the number of GATT channel message pools is equal to the set threshold, this data will no longer be sent; when any piece of data in the GATT channel message pool is returned from the receiver, this message will be removed from the message pool, so the number in the message pool will be reduced once. There will only be one message returned each time, and this message will retrieve the command in the entity class according to the SN sequence number, and then perform the overwriting process. At this time, the Gateway can send data to the GATT proxy device again. The more the number of data returned by the receiver or all of them are returned, the more data the transmitter can send. Until the message pool threshold is reached, in short, as long as it is not greater than the GATT channel message pool threshold, the transmitter can continue to send messages.
[0120] In addition, an embodiment of the present invention also provides a BLE GATT-based flow control device, which includes: a memory, a processor, and a BLE GATT-based flow control program stored in the memory and executable on the processor, wherein the BLE GATT-based flow control program implements the steps of the BLE GATT-based flow control method as described above when executed by the processor.
[0121] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a flow control program based on BLE GATT is stored. When the flow control program based on BLE GATT is executed by a processor, the steps of the flow control method based on BLE GATT as described above are implemented.
[0122] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0123] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0125] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A flow control method based on BLE GATT, characterized in that: The BLE GATT-based flow control method comprises the following steps: receiving a first Mqtt message sent by a terminal device, and after classifying the first Mqtt message, performing deduplication processing on a second Mqtt message obtained by the classification; Request and send the second Mqtt message to the filter at a fixed time, and store the filtered third Mqtt message in the GATT channel message pool; Sending the third Mqtt message in the GATT channel message pool to a GATT proxy device, so that the GATT proxy device forwards the third Mqtt message to each Mesh network device; The step of performing deduplication processing on the second Mqtt message obtained by classification includes: The second Mqtt message is stored in a Map, in which a deduplication process is performed using the serial number of the Mesh network device corresponding to the second Mqtt message as a key and the incremental entity class of the Mesh network device as a value; The BLE GATT-based flow control method further includes: If one of the third Mqtt messages is sent to the GATT proxy device, the number of the third Mqtt messages in the GATT channel message pool is increased by one; If the GATT channel message pool receives the same third Mqtt message from the Mesh network device after sending the third Mqtt message, the number of third Mqtt messages in the GATT channel message pool is reduced by one, and the corresponding Mqtt message is removed from the Map; If the number of third Mqtt messages in the GATT channel message pool is equal to the GATT channel message pool threshold, stop sending the third Mqtt message.
2. The flow control method based on BLE GATT as claimed in claim 1, characterized in that: The step of timing requesting and sending the second Mqtt message to the filter also includes: While receiving the second Mqtt message obtained by classification, notifying the scheduled task to request the second Mqtt message in the Map in real time, and sending the second Mqtt message to the filter; If the number of the second Mqtt messages in the Map is greater than the threshold of the GATT channel message pool, sending the second Mqtt messages of the threshold number of the GATT channel message pool from the Map to the filter.
3. The flow control method based on BLE GATT as claimed in claim 1, characterized in that: After the step of timing requesting and sending the second Mqtt message to the filter, the method further includes: Determine whether the target distribution device corresponding to the second Mqtt message is a Mesh network device; If the target distribution device corresponding to the second Mqtt message is not a Mesh network device, remove the second Mqtt message from the Map.
4. The flow control method based on BLE GATT as claimed in claim 3, characterized in that: After the step of determining whether the target distribution device corresponding to the second MQTT message is a Mesh network device, the method further includes: If the target distribution device corresponding to the second Mqtt message is a Mesh network device, determine whether the monitored GATT proxy device is online; If the GATT proxy device is not online, remove the second Mqtt message from the Map.
5. The flow control method based on BLE GATT as claimed in claim 4, characterized in that: After the step of determining whether the monitored GATT proxy device is online, the method further includes: If the monitored GATT proxy device is online, determining whether the number of the third Mqtt message in the GATT channel message pool is greater than a threshold of the GATT channel message pool; If the number of third Mqtt messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, then after the number of third Mqtt messages in the GATT channel message pool is less than the threshold of the GATT channel message pool, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is performed.
6. The flow control method based on BLE GATT as claimed in claim 5, characterized in that: After the step of determining whether the number of the third MQTT messages in the GATT channel message pool is greater than the threshold of the GATT channel message pool, the method further includes: If the number of the third Mqtt message in the GATT channel message pool is not greater than the threshold of the GATT channel message pool, determining whether the serial number keyword and the incremental entity class value of the third Mqtt message are equal to the serial number keyword and the incremental entity class value of the corresponding target Mesh network device; If they are not equal, executing the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device; If they are equal, the step of sending the third Mqtt message in the GATT channel message pool to the GATT proxy device is not performed, and the second Mqtt message is removed from the Map.
7. A flow control device based on BLE GATT, characterized in that: The BLE GATT-based flow control device comprises: a memory, a processor, and a BLE GATT-based flow control program stored in the memory and executable on the processor, wherein the BLE GATT-based flow control program is configured to implement the steps of the BLE GATT-based flow control method as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a BLE GATT-based flow control program, and when the BLE GATT-based flow control program is executed by a processor, the steps of the BLE GATT-based flow control method as claimed in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Message pushing user message state reporting processing method and device and storage medium
CN109873904A
Method for filtering redundant data packet at node in Bluetooth Mesh network
CN111669732A
Optimization method for Bluetooth Mesh remote control system
CN112017413A