Data transmission method, system and device based on BLE and readable storage medium
By monitoring the data transmission requirements in the main device and entering the sleep state, the problem of high power consumption and poor battery life of the main device in BLE data transmission is solved, data transmission with lower power consumption and higher battery life is achieved, and at the same time, the slave device is improved. The data transmission capabilities of the device.
Patent Information
- Application Number
- CN202411170238.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-21
AI Technical Summary
In data transmission based on BLE protocol, the master device needs to keep the master MCU in an active state, resulting in high power consumption and poor battery life.
By monitoring whether there is data transmission within the preset time period, if there is no data transmission, it will enter the sleep state; in the sleep state, if it is detected that the master device or the slave device has a data transmission requirement, it will enter the activation state for data transmission.
It reduces the power consumption of the main device, improves the battery life of the main device, and allows the slave device to initiate data transmission, improving the universality of the data transmission method.
Smart Images

Figure CN119342560A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and in particular to a BLE-based data transmission method, system, device and readable storage medium. Background Art
[0002] Bluetooth is a wireless technology standard that enables short-distance data exchange between fixed devices, mobile devices, and building personal mobile devices and building personal area networks. With the development of Bluetooth wireless communication technology, Bluetooth 4.0 has achieved low power consumption based on traditional Bluetooth technology, allowing Bluetooth devices to work with extremely low power consumption. Bluetooth Low Energy (BLE) technology is a data transmission technology designed for terminal devices using batteries.
[0003] After the master device and the slave device establish a Bluetooth connection, data can be transmitted based on the BLE protocol. However, when data is transmitted based on the BLE protocol, the master device is required to keep its main control MCU in an activated state during the connection with the slave device to ensure that when the master device initiates a data transmission request, the master device and the slave device can transmit data normally. However, in this data transmission method, the master device needs to remain activated all the time, resulting in high power consumption and poor battery life of the master device.
[0004] Therefore, how to reduce the power consumption of the main device and improve the endurance of the main device is a technical problem that needs to be solved urgently in this technical field. Summary of the invention
[0005] The main purpose of this application is to provide a BLE-based data transmission method, system, device and readable storage medium, aiming to solve the technical problem of how to reduce the power consumption of the main device and improve the endurance of the main device.
[0006] To achieve the above object, the present application provides a BLE-based data transmission method, which is applied to a master device, the master device is connected to a slave device, and the BLE-based data transmission method includes the following steps:
[0007] If it is detected that there is no data transmission within the preset time, it will enter the sleep state;
[0008] After entering the dormant state, if it is detected that the master device has a data transmission requirement, it enters the activated state to start data transmission;
[0009] After entering the dormant state, if it is detected that the slave device has a data transmission requirement, the active state is entered to start data transmission.
[0010] In one embodiment, the step of entering an activation state if it is detected that the slave device has a data transmission requirement comprises:
[0011] If a directional broadcast message sent by the slave device is received, determining a data transmission demand state of the slave device based on the directional broadcast message;
[0012] If the data transmission demand state is that there is a data transmission demand, the activation state is entered.
[0013] In one embodiment, the step of determining the data transmission requirement state of the slave device based on the directed broadcast message includes:
[0014] Reading a field value from a reserved field in the directed broadcast message;
[0015] If the field value is a first preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0016] If the field value is a second preset threshold, it is determined that the data transmission demand state of the slave device is no data transmission demand, wherein the first preset threshold is different from the second preset threshold.
[0017] In addition, to achieve the above purpose, the present application also provides a BLE-based data transmission method, which is applied to a slave device, wherein the slave device is connected to a master device, and the BLE-based data transmission method comprises the following steps:
[0018] Periodically sending a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement;
[0019] If the data transmission requirement state is that there is a data transmission requirement, the original data to be sent is transmitted to the master device.
[0020] In one embodiment, the step of periodically sending the data transmission requirement status to the master device includes:
[0021] Periodically sending a directed broadcast message to the master device, wherein the directed broadcast message is used to carry the data transmission requirement status of the slave device.
[0022] In one embodiment, before the step of periodically sending a directed broadcast message to the master device, the method further includes:
[0023] receiving a broadcast parameter configuration command, and acquiring a data transmission requirement state of the slave device based on the broadcast parameter configuration command;
[0024] Generate a directed broadcast message based on the data transmission demand state, and execute the step of periodically sending the directed broadcast message to the master device;
[0025] Among them, when the data transmission demand state is that there is data transmission demand, the field value of the reserved field in the directed broadcast message is a first preset threshold value, and when the data transmission demand state is that there is no data transmission demand, the field value of the reserved field in the directed broadcast message is a second preset threshold value, and the first preset threshold value is different from the second preset threshold value.
[0026] In one embodiment, the step of acquiring the data transmission requirement state of the slave device based on the broadcast parameter configuration command includes:
[0027] Read a type value from the broadcast type field in the broadcast parameter configuration command;
[0028] If the type value is consistent with the third preset threshold or the fourth preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0029] If the type value is inconsistent with both the third preset threshold and the fourth preset threshold, determining that the data transmission demand state of the slave device is no data transmission demand;
[0030] The third preset threshold is different from the fourth preset threshold.
[0031] In one embodiment, before the step of receiving the broadcast parameter configuration command, the method further includes:
[0032] Setting a valid value space of a broadcast type field in a broadcast parameter configuration command, wherein the valid value space includes a third preset threshold and a fourth preset threshold;
[0033] The third preset threshold is used to indicate a directional connectable broadcast in a high duty cycle mode and the slave device has a data transmission requirement, and the fourth preset threshold is used to indicate a directional connectable broadcast in a low duty cycle mode and the slave device has a data transmission requirement.
[0034] In addition, to achieve the above purpose, the present application also provides a BLE-based data transmission system, the BLE-based data transmission system includes a master device and a slave device, the master device is connected to the slave device,
[0035] If the master device detects that there is no data transmission within a preset time period, it enters a dormant state. After entering the dormant state, if it detects that the master device has a data transmission requirement, it enters an activated state;
[0036] The slave device periodically sends a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement;
[0037] After the master device enters the dormant state, if it detects that the slave device has a data transmission requirement, it enters the activated state;
[0038] When the data transmission requirement state is that there is a data transmission requirement, the slave device transmits the original data to be sent to the master device.
[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a main device, which includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the BLE Bluetooth module is used to execute the steps of the BLE-based data transmission method as described above.
[0040] In addition, to achieve the above-mentioned purpose, the present application also provides a slave device, which includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the controller is used to execute the steps of the BLE-based data transmission method as described above.
[0041] In addition, to achieve the above-mentioned purpose, the present application also provides a readable storage medium, which is a computer-readable storage medium, and a program for implementing a BLE-based data transmission method is stored on the computer-readable storage medium. The program for implementing a BLE-based data transmission method is executed by a processor to implement the steps of the BLE-based data transmission method as described above.
[0042] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned BLE-based data transmission method when executed by a processor.
[0043] One or more technical solutions proposed in this application have at least the following technical effects:
[0044] If the master device detects that there is no data transmission within the preset time, it enters a dormant state; after entering the dormant state, if it detects that the master device has a data transmission demand, it enters an activated state to start data transmission; after entering the dormant state, if it detects that the slave device has a data transmission demand, it enters an activated state to start data transmission. In this way, compared with the data transmission method in which the master device always remains in an activated state, the embodiment of the present application enters a dormant state when it detects that there is no data transmission within the preset time, so as to sleep the master device until it detects that the master device or the slave device has a data transmission demand, and then wakes up the master device to enter an activated state to ensure normal data transmission. In this way, when there is no data transmission for a long time, the master device enters a dormant state without having to remain in an activated state, thereby reducing the power consumption of the master device and improving the endurance of the master device. And when there is a data transmission demand from the slave device, the master device will also be awakened to enter an activated state, so that data transmission can proceed normally, so that not only the master device can initiate data transmission, but also the slave device can initiate data transmission, which improves the universality of the data transmission method. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0047] Figure 1 This is a flow chart of the first embodiment of the BLE-based data transmission method of the present application;
[0048] Figure 2 This is a schematic diagram of the composition of a directional broadcast message involved in an embodiment of a BLE-based data transmission method of the present application;
[0049] Figure 3 This is a flow chart of a third embodiment of a BLE-based data transmission method of the present application;
[0050] Figure 4 This is a brief flowchart of the BLE-based data transmission method of this application;
[0051] Figure 5 This is a schematic diagram of the main device structure of the hardware operating environment involved in the BLE-based data transmission device in the embodiment of the present application;
[0052] Figure 6This is a schematic diagram of the slave device structure of the hardware operating environment involved in the BLE-based data transmission device in the embodiment of the present application.
[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0055] Bluetooth communication is a commonly used near-end communication technology. For business scenarios with near-field wireless communication requirements and a small amount of transmitted data, Bluetooth communication is usually preferred.
[0056] Taking into account the requirements of miniaturization, aesthetics, and long continuous use time for some Bluetooth devices, the Bluetooth 4.0 protocol supports "Bluetooth Low Energy" technology, namely BLE, which can be used in Bluetooth transmission scenarios other than audio transmission. Compared with classic Bluetooth technology, it greatly reduces the power consumption of Bluetooth devices.
[0057] However, the power consumption reduction strategy of the BLE protocol only considers reducing the power consumption of the master and slave devices during BLE data transmission through configurable parameters such as connection interval (data transmission time interval) and connection transmit window (data transmission time window duration). However, for the case of small data transmission volume and low density, power consumption cannot be significantly improved, because in this scenario, there is a long period of time without actual data transmission. During this period, in order to maintain the BLE connection, the master device (also called the master device) and the slave device (also called the slave device) must keep their main control MCU in an activated state to ensure that when the master device initiates a data transmission request, both ends can transmit data normally.
[0058] As the protocol stipulates, BLE can only be sent by the master device to send a connection indication (Connect_IND). Therefore, for scenarios where data transmission is initiated only from the master device, the master device can be considered to wake up the MCU internally. However, if the slave device has a need to initiate data transmission, the master cannot be aware of the need. After receiving the ADV_DIRECT_IND from the slave device, it will reply with Connect_IND. Then the slave may start to transmit data. If the master device MCU is in sleep state, the master cannot process the data transmission normally, which will cause data transmission abnormality.
[0059] Based on this, the main solution of this application is: if it is detected that there is no data transmission within the preset time, it enters the sleep state; after entering the sleep state, if it is detected that the master device has a data transmission demand, it enters the activation state to start data transmission; after entering the sleep state, if it is detected that the slave device has a data transmission demand, it enters the activation state to start data transmission.
[0060] This application ensures normal data transmission by causing the master device to enter a dormant state when it detects that there is no data transmission within a preset time period, and then waking up the master device to enter an activated state when it detects that the master device or the slave device has a data transmission demand, so that the master device enters a dormant state when there is no data transmission for a long time, and does not need to remain in an activated state, thereby reducing the power consumption of the master device and improving the endurance of the master device. And when there is a data transmission demand from the slave device, the master device will also be awakened to enter an activated state, so that data transmission can proceed normally, so that not only the master device can initiate data transmission, but also the slave device can initiate data transmission, thereby improving the universality of the data transmission method.
[0061] The following is a first embodiment of the data transmission method based on BLE of the present application. Figure 1 , Figure 1 The flowchart of the first embodiment of the data transmission method based on BLE of the present application is shown in FIG. The data transmission method based on BLE described in this embodiment is applied to a master device, and the master device is connected to a slave device. Both the master device and the slave device can be a computing service device with data processing, network communication and program running functions, such as a server, a tablet computer, a personal computer, a mobile phone, etc.
[0062] In a specific application scenario, IOT (Internet of Things) devices and peer devices (such as car computers, personal computers) generally only have some interactive messages for control or reading information to transmit, with little data and low density. IOT devices usually act as masters, which may be in mobile use for a long time, inconvenient to charge, and have requirements for battery life; the peers act as slaves, which are generally fixed and have fixed power supply or charging conditions. Based on this, exemplarily, the master device is used as an IOT device to illustrate and describe the various embodiments of the data transmission method based on BLE in this application.
[0063] In this embodiment, the steps of the BLE-based data transmission method include:
[0064] Step S10, if it is detected that there is no data transmission within a preset time, then enter a dormant state;
[0065] It should be noted that after the IOT device establishes a connection with the slave device, the data transmission status between the IOT device and the slave device can be monitored. If it is detected that there is no data transmission within a preset time, the device enters a sleep state. Specifically, the IOT device enters a sleep state when the MCU (Microcontroller Unit) controlling the IOT device enters a sleep state.
[0066] The preset duration may be any duration set in advance, such as 5 seconds, 10 seconds, 20 seconds, etc., and this embodiment does not impose any specific limitation on this.
[0067] The sleep state refers to a low power consumption state. Specifically, in the sleep state, the power consumption can be reduced by reducing or stopping the clock frequency of the MCU and changing the operating state of the CPU to an inactive or shutdown state. This embodiment does not impose any specific restrictions on this.
[0068] It should be noted that if the IOT device is receiving data and / or sending data, it can be determined that there is data transmission. Conversely, if the IOT device neither receives data nor sends data, it can be determined that there is no data transmission.
[0069] Step S20, after entering the dormant state, if it is detected that the master device has a data transmission requirement, then entering the activated state to start data transmission;
[0070] After the IOT device enters the dormant state, if the IOT device itself has data transmission requirements, such as the IOT device has data to send to the slave device, the IOT device can wake up and enter the active state by itself. Specifically, the MCU controlling the IOT device can enter the active state.
[0071] The active state is the opposite of the sleep state. In the active state, the MCU can respond to external events, execute scheduled tasks, and process data from sensors and other devices.
[0072] After the IOT device enters the activated state, data can be sent to the slave device, thereby starting data transmission. Further, after the IOT device enters the activated state, it can return to execute step S10 to put the IOT device to sleep in time when there is no data transmission within a preset time.
[0073] It should be noted that after the IOT device establishes a connection with the slave device, the slave device remains activated.
[0074] Step S30, after entering the dormant state, if it is detected that the slave device has a data transmission requirement, then entering the activated state to start data transmission.
[0075] After the IOT device enters the dormant state, if it is detected that the slave device has a data transmission demand, such as data that needs to be sent from the slave device to the IOT device, the IOT device is also awakened to enter the activated state. Further, after the IOT device enters the activated state, it can return to execute step S10 to hibernate the IOT device in time when there is no data transmission within the preset time.
[0076] After the IOT device enters the activated state, it can send data to the slave device, thereby starting data transmission. It should be noted that if the IOT device enters the activated state because the slave device has a data transmission demand, after the IOT device enters the dormant state, the IOT device can also send a connection indication back to the slave device, and the connection indication can be specifically Connect_IND, so that after the slave device receives the connection indication, the slave device starts sending data for data transmission.
[0077] Furthermore, it should be noted that, for the switching of the state of the IOT device, the BLE Bluetooth module in the IOT device can specifically wake up or put the MCU of the IOT device to sleep, thereby making the IOT device enter the active state or the sleep state accordingly. It can be understood that when the BLE Bluetooth module wakes up the MCU, the IOT device enters the active state, and when the BLE Bluetooth module puts the MCU to sleep, the IOT device enters the sleep state.
[0078] The BLE module can wake up the MCU directly through a hardware signal, or send an interrupt signal to the MCU through an interrupt pin. When the MCU detects these interrupt signals, the MCU wakes up from the sleep state. This embodiment does not specifically limit the specific implementation method of waking up the MCU.
[0079] The BLE module can put the MCU to sleep by reducing the CPU clock speed, shutting down unnecessary hardware components, etc. This embodiment does not specifically limit the specific implementation method of putting the MCU to sleep.
[0080] In this embodiment, if the IOT device detects that there is no data transmission within the preset time, it enters a dormant state; after entering the dormant state, if it detects that the IOT device has a data transmission demand, it enters an activated state to start data transmission; after entering the dormant state, if it detects that the slave device has a data transmission demand, it enters an activated state to start data transmission. In this way, compared with the data transmission method in which the IOT device always remains in an activated state, in this embodiment, when it detects that there is no data transmission within the preset time, the IOT device enters a dormant state to sleep the IOT device until it detects that the IOT device or the slave device has a data transmission demand, and then wakes up the IOT device to enter an activated state to ensure normal data transmission. In this way, when there is no data transmission for a long time, the IOT device enters a dormant state without having to remain in an activated state, thereby reducing the power consumption of the IOT device and improving the endurance of the IOT device. And when there is a data transmission demand from the slave device, the IOT device will also be awakened to enter an activated state, so that data transmission can proceed normally, so that not only the IOT device can initiate data transmission, but also the slave device can initiate data transmission, which improves the universality of the data transmission method.
[0081] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above description, and will not be described in detail later. In this embodiment, if it is detected that the slave device has a data transmission requirement, the step of entering the activation state includes:
[0082] Step A10, if a directional broadcast message sent by the slave device is received, determining the data transmission demand state of the slave device based on the directional broadcast message;
[0083] The directional broadcast message may specifically be an ADV_DIRECT_IND message. The slave device may encapsulate the data transmission requirement status in the directional broadcast message and send it to the IOT device, so that the IOT device determines the data transmission requirement status of the slave device based on the information carried in the directional broadcast message.
[0084] It should be noted that the directional broadcast message is specifically a message of the LL layer (Link Layer) in the BLE protocol.
[0085] Step A20: If the data transmission demand state is that there is a data transmission demand, enter the activation state.
[0086] If the data transmission demand state of the slave device is that there is a data transmission demand, the IOT device enters an activation state.
[0087] In addition, if the data transmission demand state of the slave device is no data transmission demand, the IOT device remains in a dormant state. Further, a connection indication Connect_IND may be sent back to the slave device. By sending back the connection indication, the connection can be confirmed, information can be exchanged, communication can be started, service discovery can be performed, security checks can be performed, other protocol operations can be performed, and the like. Among them, confirming the connection means that when the slave device sends a connection request, the IOT device sends back Connect_IND as a confirmation, indicating that the connection has been established. Exchanging information means that after the connection is established, the IOT device and the slave device can exchange connection information, such as device name, address, device type, etc. Starting communication means that once the connection is established, the IOT device and the slave device can start communicating, including sending and receiving data. Service discovery means that after the connection is established, the IOT device can find the services and features provided by the slave device through the service discovery process. Performing a security check means that after the connection is established, the IOT device may request the slave device to perform a security check to ensure the security of the communication. Performing other protocol operations means that after the connection is established, the IOT device can perform other BLE protocol operations, such as reading or writing the characteristic values of the slave device.
[0088] It can be understood that after the IOT device establishes a connection with the slave device in the BLE protocol, the slave device will periodically send a directional broadcast message ADV_DIRECT_IND to the IOT device. Based on this, this embodiment carries the data transmission requirement status of the slave device through a directional broadcast message, so that the IOT device can monitor whether the slave device has a data transmission requirement. Moreover, based on the existing directional broadcast message of the BLE protocol that carries the data transmission requirement status of the slave device, there is no need to define additional messages, thereby reducing the implementation cost.
[0089] In a possible implementation manner, the step of determining the data transmission requirement state of the slave device based on the directed broadcast message includes:
[0090] Step B10, reading a field value from a reserved field in the directional broadcast message;
[0091] It is understandable that a directional broadcast message includes one or more fields, and a reserved field refers to a reserved field that has no specific use in the directional broadcast message defined in the current BLE protocol. Figure 2As shown, the directional broadcast message includes an 8-bit leading field, a 32-bit access address field, a protocol data unit (PDU) field, and a 24-bit check field, wherein the PDU field specifically includes an 8-bit header field, an 8-bit length field, and a 0-296-bit data field, and the 8-bit header field specifically includes a 4-bit broadcast message type field, a 2-bit reserved field, a 1-bit sending address type field, and a 1-bit receiving address type field, that is, Figure 2 The directed broadcast message shown in includes a 2-bit reserved field.
[0092] The field value is specifically the data filled in the reserved field. Furthermore, considering that the data transmission demand state of the slave device includes two states: data transmission demand and no data transmission demand, at least 1 bit of space can represent the two states of data transmission demand and no data transmission demand. Therefore, at least one bit can be selected from the reserved field to represent the data transmission demand state of the slave device, and the remaining bits are still reserved as reserved space. The bit in the reserved field used to represent the data transmission demand state of the slave device is referred to as the target bit, and the field value is specifically the data filled in the target bit of the reserved field. Exemplarily, with Figure 2 Taking the directed broadcast message shown as an example, the reserved field includes 2 bits, which are recorded as bit2 and bit3 respectively. If bit2 is selected as the target bit from bit2 and bit3, the field value is the data filled in bit2.
[0093] Step B20, if the field value is a first preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0094] Step B30: If the field value is a second preset threshold, determining that the data transmission demand state of the slave device is no data transmission demand, wherein the first preset threshold is different from the second preset threshold.
[0095] The first preset threshold and the second preset threshold are two different thresholds to represent two different data transmission demand states of the slave device. This embodiment does not impose any specific restrictions on the specific values of the first preset threshold and the second preset threshold.
[0096] In order to reduce the space occupied by representing the data transmission demand status of the slave device, in a preferred embodiment, the first preset threshold is 1, the second preset threshold is 0, or the first preset threshold is 0 and the second preset threshold is 1. In this way, 1 bit of space can be used to represent both the data transmission demand and the no data transmission demand states, thereby reducing the space occupied in the reserved field.
[0097] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those of the above-mentioned first and second embodiments can be referred to the above introduction, and will not be described in detail later. Figure 3 As shown, in this embodiment, the BLE-based data transmission method is applied to a slave device, that is, the execution subject is the slave device, the slave device is connected to the master device, and the BLE-based data transmission method includes the following steps:
[0098] Step S100, periodically sending a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement;
[0099] The slave device periodically sends its own data transmission demand status to the IOT device, so that the IOT device can monitor the data transmission demand status of the slave device, that is, the IOT device can monitor whether the slave device has a data transmission demand.
[0100] It should be noted that the data transmission demand state of the slave device includes two states: having data transmission demand and having no data transmission demand.
[0101] Step S200: If the data transmission requirement state is that there is a data transmission requirement, the original data to be sent is transmitted to the master device.
[0102] If the data transmission requirement state is that there is a data transmission requirement, the original data to be sent is transmitted to the IOT device. Further, if the IOT device sends back a connection indication each time after receiving the data transmission requirement state sent by the slave device, the data transmission requirement state of the slave device is that there is a data transmission requirement, and after receiving the connection indication sent by the IOT device, the original data to be sent is transmitted to the IOT device.
[0103] In this embodiment, the slave device periodically sends its own data transmission demand status to the IOT device, so that the IOT device can monitor whether the slave device has data transmission demand, and then the IOT device enters the activation state when the slave device has data transmission demand. The IOT device does not need to remain in the activation state all the time, thereby reducing the power consumption of the IOT device and improving the battery life of the IOT device. And when the slave device has data transmission demand, it will also wake up the IOT device and enter the activation state, so that data transmission can proceed normally, so that not only the IOT device can initiate data transmission, but the slave device can also initiate data transmission, which improves the universality of the data transmission method.
[0104] Based on the first embodiment, the second embodiment and / or the third embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the first embodiment, the second embodiment and the third embodiment can be referred to the above description, and will not be described in detail later. In this embodiment, the step of periodically sending the data transmission requirement status to the master device includes:
[0105] Step A100: periodically sending a directed broadcast message to the master device, wherein the directed broadcast message is used to carry the data transmission requirement status of the slave device.
[0106] The directed broadcast message may specifically be an ADV_DIRECT_IND message.
[0107] After the IOT device establishes a connection with the slave device in the BLE protocol, the slave device will periodically send a directional broadcast message ADV_DIRECT_IND to the IOT device. Based on this, this embodiment carries the data transmission requirement status of the slave device based on the existing directional broadcast message of the BLE protocol, and there is no need to define additional messages, thereby reducing the implementation cost.
[0108] Furthermore, the directional broadcast message includes a reserved field, and the data transmission demand status of the slave device can be carried through the reserved field in the directional broadcast message. Specifically, when the data transmission demand status of the slave device is that there is a data transmission demand, the first preset threshold can be filled into the reserved field, that is, the reserved field is the first preset threshold, and when the data transmission demand status of the slave device is that there is no data transmission demand, the second preset threshold can be filled into the reserved field, that is, the reserved field is the second preset threshold. The first preset threshold and the second preset threshold are two different thresholds to represent two different data transmission demand states of the slave device. This embodiment does not impose specific restrictions on the specific values of the first preset threshold and the second preset threshold.
[0109] Further, the first preset threshold or the second preset threshold may be filled into the target bit position in the reserved field.
[0110] In a possible implementation manner, before the step of periodically sending a directed broadcast message to the master device, the method further includes:
[0111] Step B100, receiving a broadcast parameter configuration command, and acquiring a data transmission requirement state of the slave device based on the broadcast parameter configuration command;
[0112] The broadcast parameter configuration command may specifically be LE Set Advertising Parameters Command in the BLE protocol.
[0113] Furthermore, the broadcast parameter configuration command is a command sent by the Host layer to the LL layer in the BLE protocol. The data transmission requirement status of the slave device is notified from the Host layer to the LL layer through the broadcast parameter configuration command, and the slave device is then transmitted to the LL layer of the IOT device through the directional broadcast message of the LL layer, and then the data transmission requirement status of the slave device is notified to the IOT device.
[0114] The advertising parameter configuration command is sent by the Host layer to the LL layer to configure the advertising parameters of the slave device. These parameters determine how the slave device broadcasts its presence and characteristics in the BLE network, such as the advertising interval, advertising type, advertising channel, etc. By sending this command, the Host layer can tell the LL layer how to set and adjust the advertising parameters so that the slave device can effectively broadcast its services and characteristics in the BLE network and allow other devices to discover and establish connections with it.
[0115] Based on the existing broadcast parameter configuration commands of the BLE protocol, the data transmission requirement status of the device will be notified from the Host layer to the LL layer, without defining additional commands, thereby reducing the implementation cost.
[0116] Step B200, generating a directed broadcast message based on the data transmission demand state, and executing the step of periodically sending the directed broadcast message to the master device;
[0117] Among them, when the data transmission demand state is that there is data transmission demand, the field value of the reserved field in the directed broadcast message is a first preset threshold value, and when the data transmission demand state is that there is no data transmission demand, the field value of the reserved field in the directed broadcast message is a second preset threshold value, and the first preset threshold value is different from the second preset threshold value.
[0118] When the LL layer receives the broadcast parameter configuration command, it will configure and generate a directional broadcast message according to the parameters in the broadcast parameter configuration command. Based on this, in this embodiment, the directional broadcast message is configured based on the data transmission demand state carried in the broadcast parameter configuration, and the reserved field of the directional broadcast message is specifically configured. When the data transmission demand state is that there is a data transmission demand, the field value of the reserved field is filled with the first preset threshold value. When the data transmission demand state is that there is no data transmission demand, the field value of the reserved field is filled with the second preset threshold value. For the configuration of other fields, the existing BLE protocol configuration method can be adopted, which will not be described in detail in this embodiment.
[0119] It can be understood that the BLE protocol sends broadcast parameter configuration commands when the device is initialized, parameters are changed, the device is reset, and responds to external events. Therefore, each time a broadcast parameter configuration command sent by the Host layer is received, a directed broadcast message can be regenerated, and the latest directed broadcast message can be sent periodically to promptly notify the IOT device of the latest data transmission demand status from the device.
[0120] Device initialization means that the device starts and is ready to start broadcasting. Parameter change means that the broadcast parameters need to be changed (for example, adjusting the broadcast interval, type, or data). Device reset means that the broadcast parameters need to be reconfigured after the device is reset or restarted. Responding to external events means that in some cases, the broadcast behavior of the device needs to be changed based on external events (such as user input or sensor data).
[0121] In a possible implementation manner, the step of acquiring the data transmission requirement state of the slave device based on the broadcast parameter configuration command includes:
[0122] Step C100, reading a type value from the broadcast type field in the broadcast parameter configuration command;
[0123] It can be understood that the broadcast parameter configuration command includes fields such as the broadcast interval (Advertising Interval), the broadcast type (Advertising Type), the master device address type (Own Address Type), the peer address type (PeerAddress Type), the channel mapping (Channel Map), and the advertising filtering policy (Advertising Filter Policy). Among them, the values 0x00~0x04 in the broadcast type field have been defined, and other values are reserved values. Based on this, in this embodiment, the broadcast type field is selected to carry the data transmission requirement status of the slave device.
[0124] The type value is specifically the data filled in the broadcast type field.
[0125] Step C200, if the type value is consistent with the third preset threshold or the fourth preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0126] Step C300: if the type value is inconsistent with both the third preset threshold and the fourth preset threshold, determining that the data transmission demand state of the slave device is no data transmission demand;
[0127] The third preset threshold is different from the fourth preset threshold.
[0128] Considering that when there is no data transmission demand from the device, the type value of 0x01 or 0x04 is set in the broadcast type field, where 0x01 means: ADV_DIRECT_IND, high duty cycle (directional connectable broadcast, high duty cycle mode), and 0x04 means: ADV_DIRECT_IND, low duty cycle (directional connectable broadcast, low duty cycle mode). Based on this, two new type values corresponding to these two type values (i.e., the third preset threshold and the fourth preset threshold) are added to indicate that there is a data transmission demand.
[0129] The type value is consistent with the third preset threshold or the fourth preset threshold, that is, when the type value is the third preset threshold or the fourth preset threshold, it is determined that there is a data transmission demand from the device; otherwise, when the type value is inconsistent with both the third preset threshold and the fourth preset threshold, it is determined that there is no data transmission demand from the device.
[0130] It should be noted that the third preset threshold is different from the fourth preset threshold and is not a type value defined by the BLE protocol. For example, when the type value defined by the BLE protocol is 0x00 to 0x04, the third preset threshold is different from the fourth preset threshold and is not any value from 0x00 to 0x04. In a specific implementation, the third preset threshold is 0x05 and the fourth preset threshold is 0x06.
[0131] In a possible implementation manner, before the step of receiving the broadcast parameter configuration command, the method further includes:
[0132] Step D100, setting a valid value space of the broadcast type field in the broadcast parameter configuration command, wherein the valid value space includes a third preset threshold and a fourth preset threshold;
[0133] The third preset threshold is used to indicate a directional connectable broadcast in a high duty cycle mode and the slave device has a data transmission requirement, and the fourth preset threshold is used to indicate a directional connectable broadcast in a low duty cycle mode and the slave device has a data transmission requirement.
[0134] The valid value space indicates a value space with a specific meaning, that is, the valid value space includes other values except reserved values. It can be understood that the BLE protocol has defined the valid value space of the broadcast type field. In order to avoid the third preset threshold and the fourth preset threshold being considered as reserved values, the valid value space of the broadcast type field can be reset at the initialization. Specifically, the third preset threshold and the fourth preset threshold are added as the valid value space of the broadcast type field. Exemplarily, assuming that the valid value space of the broadcast type field currently defined by the BLE protocol is 0x00~0x04, the third preset threshold is 0x05, and the fourth preset threshold is 0x06, then the valid value space of the broadcast type field is set to 0x00~0x06.
[0135] Specifically, the third preset threshold indicates a directional connectable broadcast in a high duty cycle mode and the slave device has a data transmission requirement (ADV_DIRECT_IND, high duty cycle, data transmit), and the fourth preset threshold indicates a directional connectable broadcast in a low duty cycle mode and the slave device has a data transmission requirement (ADV_DIRECT_IND, low duty cycle, data transmit).
[0136] In this embodiment, when sending a broadcast parameter configuration command, a third preset threshold and a fourth preset threshold are first added to the valid value space of the broadcast type field in the broadcast parameter configuration command, so that after the subsequent LL layer receives the broadcast parameter configuration command, it can effectively parse the information carried by the third preset threshold and the fourth preset threshold, and then effectively identify the data transmission demand status of the slave device, avoiding the phenomenon of parsing the third preset threshold and the fourth preset threshold as reserved values.
[0137] For example, in order to help understand the technical concept or technical principle of the BLE-based data transmission method after combining this embodiment with the first embodiment, the second embodiment and the third embodiment, please refer to Figure 4 Based on the connectable state processing mechanism in the BLE protocol, a new identification field is added to the slave device Host layer->LL layer parameter configuration instructions and the slave LL->master LL broadcast message to convey whether the slave device has data to transmit. Figure 4 In the example, LL A represents the LL layer of the master device, LL B represents the LL layer of the slave device, Host A represents the Host layer of the master device, and Host B represents the Host layer of the slave device. First, set the slave device to broadcast ( Figure 4Step 1: Setup Device B to Advertise) shown in Figure 1, based on this, the specific processing mechanism is as follows:
[0138] 1. After the master and slave establish a connection, if the master determines that no data transmission occurs for a certain period of time (for example, 5 seconds), the MCU will sleep automatically.
[0139] 2. When the slave device has data to transmit, two new characteristic values are added to the 1-byte Advertising_Type parameter in the LE Set AdvertisingParameters Command sent by the Host layer to the LL layer:
[0140] 0x05: ADV_DIRECT_IND, high duty cycle, data transmit, indicating that the broadcast type is directional connectable broadcast, high duty cycle mode;
[0141] 0x06: ADV_DIRECT_IND, low duty cycle, data transmit, indicating that the broadcast type is directional connectable broadcast, low duty cycle mode.
[0142] 3. The slave device sends the LE Set Advertising Enable command to the LL layer at the Host layer to inform the LL layer whether to enable the advertising function. If the advertising function is enabled (Enable), after the LE Set Advertising Enable command is sent (Command Cmoplete), the slave LL periodically sends ADV_DIRECT_IND to the master LL within the advertising interval (broadcast interval). Figure 4 The Advert message shown in the figure is used to inquire whether the peer master device is still there, and the Advertising timeout parameter is used to control the time when the slave device stops broadcasting in broadcast mode, and define the maximum time the slave device remains active in broadcast mode. At the same time, if the slave device has data transmission requirements, in the ADV_DIRECT_IND message, a 1-bit position is used to indicate that the slave device has data to transmit, as follows:
[0143] There is a 1-byte message header in ADV_DIRECT_IND, of which bit3 and bit2 are currently reserved;
[0144] Use bit3 or bit2 to indicate whether there is a data transmission requirement:
[0145] When this bit = 0, there is no data transmission requirement;
[0146] When this bit = 1, there is a data transmission requirement.
[0147] 4. The master device receives ADV_DIRECT_IND and parses the value of the data transmission requirement flag. When it is 1, it wakes up the MCU, replies Connect_IND, and starts data transmission. When it is 0, it only replies Connect_IND without waking up the MCU. Further, in the slave device, the LL layer receives Connect_IND and sends LE Connection Complete to the Host layer, notifying the Host layer that the slave device has completed the connection process with the peer device.
[0148] It should be noted that the above examples are only used to assist in understanding the present application and do not constitute a limitation on the BLE-based data transmission method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0149] In addition, the embodiment of the present application further proposes a BLE-based data transmission system, wherein the BLE-based data transmission system includes a master device and a slave device, wherein the master device is connected to the slave device.
[0150] If the master device detects that there is no data transmission within a preset time period, it enters a dormant state. After entering the dormant state, if it detects that the master device has a data transmission requirement, it enters an activated state;
[0151] The slave device periodically sends a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement;
[0152] After the master device enters the dormant state, if it detects that the slave device has a data transmission requirement, it enters the activated state;
[0153] When the data transmission requirement state is that there is a data transmission requirement, the slave device transmits the original data to be sent to the master device.
[0154] In one embodiment, the master device is further configured to:
[0155] If a directional broadcast message sent by the slave device is received, determining a data transmission demand state of the slave device based on the directional broadcast message;
[0156] If the data transmission demand state is that there is a data transmission demand, the activation state is entered.
[0157] In one embodiment, the master device is further configured to:
[0158] Reading a field value from a reserved field in the directed broadcast message;
[0159] If the field value is a first preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0160] If the field value is a second preset threshold, it is determined that the data transmission demand state of the slave device is no data transmission demand, wherein the first preset threshold is different from the second preset threshold.
[0161] In one embodiment, the slave device is further used for:
[0162] Periodically sending a directed broadcast message to the master device, wherein the directed broadcast message is used to carry the data transmission requirement status of the slave device.
[0163] In one embodiment, the slave device is further used for:
[0164] receiving a broadcast parameter configuration command, and acquiring a data transmission requirement state of the slave device based on the broadcast parameter configuration command;
[0165] The step of generating a directed broadcast message based on the data transmission demand state, and periodically sending the directed broadcast message to the master device;
[0166] Among them, when the data transmission demand state is that there is data transmission demand, the field value of the reserved field in the directed broadcast message is a first preset threshold value, and when the data transmission demand state is that there is no data transmission demand, the field value of the reserved field in the directed broadcast message is a second preset threshold value, and the first preset threshold value is different from the second preset threshold value.
[0167] In one embodiment, the slave device is further used for:
[0168] Read a type value from the broadcast type field in the broadcast parameter configuration command;
[0169] If the type value is consistent with the third preset threshold or the fourth preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand;
[0170] If the type value is inconsistent with both the third preset threshold and the fourth preset threshold, determining that the data transmission demand state of the slave device is no data transmission demand;
[0171] The third preset threshold is different from the fourth preset threshold.
[0172] In one embodiment, the slave device is further used for:
[0173] Setting a valid value space of a broadcast type field in a broadcast parameter configuration command, wherein the valid value space includes a third preset threshold and a fourth preset threshold;
[0174] The third preset threshold is used to indicate a directional connectable broadcast in a high duty cycle mode and the slave device has a data transmission requirement, and the fourth preset threshold is used to indicate a directional connectable broadcast in a low duty cycle mode and the slave device has a data transmission requirement.
[0175] In addition, an embodiment of the present application further proposes a master device, which includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the BLE Bluetooth module is used to execute the steps of the BLE-based data transmission method as described above.
[0176] In addition, an embodiment of the present application further proposes a slave device, which includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the controller is used to execute the steps of the BLE-based data transmission method as described above.
[0177] The controller in the master device and the slave device may specifically be an MCU (Microcontroller Unit).
[0178] The BLE Bluetooth module is an integrated circuit that implements Bluetooth Low Energy (BLE) technology, allowing devices to communicate wirelessly. It may specifically include a radio frequency front end, a baseband processor, a memory, an interface, and a power management unit, among which the radio frequency front end is responsible for sending and receiving wireless signals. The baseband processor is used to process the Bluetooth protocol stack, including data encapsulation, decapsulation, encryption, decryption, etc. The memory is used to store firmware and temporary data. The interface is used to provide a connection interface with external devices (such as MCU, sensors, etc.). The power management unit is used to manage the power supply of the module to ensure low power operation.
[0179] It should be noted that the structure of the BLE Bluetooth module shown above is only an example, and the embodiment of the present application does not specifically show the specific structure of the BLE Bluetooth module.
[0180] In addition, reference Figures 5 and 6, which shows a schematic diagram of the structure of a master device (slave device) suitable for implementing the embodiment of the present application. The master device (slave device) in the embodiment of the present application may also include but is not limited to mobile terminals such as headphones, mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figures 5 and 6 The master device (slave device) shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0181] like Figures 5 and 6 As shown, the master device (slave device) may also include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the master device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the master device (slave device) to communicate wirelessly or wired with other devices to exchange data. Although the master device (slave device) with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.
[0182] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0183] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0184] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0185] In addition, to achieve the above-mentioned purpose, an embodiment of the present application also provides a readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the BLE-based data transmission method in the above-mentioned embodiment.
[0186] The computer-readable storage medium provided in the embodiment of the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0187] The computer-readable storage medium may be included in the master device (slave device); or may exist independently without being assembled into the master device (slave device).
[0188] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the main device, the main device: if it is detected that there is no data transmission within a preset time period, it will enter a sleep state; after entering the sleep state, if it is detected that the master device has a data transmission demand, it will enter an activation state to start data transmission; after entering the sleep state, if it is detected that the slave device has a data transmission demand, it will enter an activation state to start data transmission.
[0189] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the master device, the slave device: periodically sends a data transmission requirement status to the master device, wherein the data transmission requirement status is used to characterize whether the slave device has a data transmission requirement; if the data transmission requirement status indicates that there is a data transmission requirement, the original data to be sent is transmitted to the master device.
[0190] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0191] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0192] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0193] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned BLE-based data transmission method, and can solve the technical problem of how to reduce the power consumption of the main device and improve the endurance of the main device. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the BLE-based data transmission method provided by the above-mentioned embodiment, and will not be repeated here.
[0194] In addition, an embodiment of the present application further proposes a computer program product, including a BLE-based data transmission program, which, when executed by a processor, implements the steps of the BLE-based data transmission method described above.
[0195] The specific implementation methods of the computer program product of the present application are basically the same as the above-mentioned embodiments of the BLE-based data transmission method, and will not be repeated here.
[0196] 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.
[0197] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0198] 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 this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software sensor, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, including a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0199] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data transmission method based on BLE, characterized in that: Applied to a master device, the master device is connected to a slave device, and the BLE-based data transmission method comprises the following steps: If it is detected that there is no data transmission within the preset time, it will enter the sleep state; After entering the dormant state, if it is detected that the master device has a data transmission requirement, it enters the activated state to start data transmission; After entering the dormant state, if it is detected that the slave device has a data transmission requirement, the active state is entered to start data transmission.
2. The method according to claim 1, characterized in that The step of entering the activation state if it is detected that the slave device has a data transmission requirement comprises: If a directional broadcast message sent by the slave device is received, determining a data transmission demand state of the slave device based on the directional broadcast message; If the data transmission demand state is that there is a data transmission demand, the activation state is entered.
3. The method according to claim 2, characterized in that The step of determining the data transmission requirement state of the slave device based on the directional broadcast message comprises: Reading a field value from a reserved field in the directed broadcast message; If the field value is a first preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand; If the field value is a second preset threshold, it is determined that the data transmission demand state of the slave device is no data transmission demand, wherein the first preset threshold is different from the second preset threshold.
4. A data transmission method based on BLE, characterized in that: Applied to a slave device, the slave device is connected to a master device, and the BLE-based data transmission method comprises the following steps: Periodically sending a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement; If the data transmission requirement state is that there is a data transmission requirement, the original data to be sent is transmitted to the master device.
5. The method according to claim 4, characterized in that The step of periodically sending the data transmission requirement status to the master device comprises: Periodically sending a directed broadcast message to the master device, wherein the directed broadcast message is used to carry the data transmission requirement status of the slave device.
6. The method according to claim 4, characterized in that Before the step of periodically sending a directed broadcast message to the master device, the method further includes: receiving a broadcast parameter configuration command, and acquiring a data transmission requirement state of the slave device based on the broadcast parameter configuration command; Generate a directed broadcast message based on the data transmission demand state, and execute the step of periodically sending the directed broadcast message to the master device; Among them, when the data transmission demand state is that there is data transmission demand, the field value of the reserved field in the directed broadcast message is a first preset threshold value, and when the data transmission demand state is that there is no data transmission demand, the field value of the reserved field in the directed broadcast message is a second preset threshold value, and the first preset threshold value is different from the second preset threshold value.
7. The method according to claim 6, characterized in that The step of acquiring the data transmission requirement state of the slave device based on the broadcast parameter configuration command comprises: Read a type value from the broadcast type field in the broadcast parameter configuration command; If the type value is consistent with the third preset threshold or the fourth preset threshold, determining that the data transmission demand state of the slave device is that there is a data transmission demand; If the type value is inconsistent with both the third preset threshold and the fourth preset threshold, determining that the data transmission demand state of the slave device is no data transmission demand; The third preset threshold is different from the fourth preset threshold.
8. The method according to claim 6, characterized in that Before the step of receiving the broadcast parameter configuration command, the method further includes: Setting a valid value space of a broadcast type field in a broadcast parameter configuration command, wherein the valid value space includes a third preset threshold and a fourth preset threshold; The third preset threshold is used to indicate a directional connectable broadcast in a high duty cycle mode and the slave device has a data transmission requirement, and the fourth preset threshold is used to indicate a directional connectable broadcast in a low duty cycle mode and the slave device has a data transmission requirement.
9. A data transmission system based on BLE, characterized in that: The BLE-based data transmission system includes a master device and a slave device, wherein the master device is connected to the slave device. If the master device detects that there is no data transmission within a preset time period, it enters a dormant state. After entering the dormant state, if it detects that the master device has a data transmission requirement, it enters an activated state; The slave device periodically sends a data transmission requirement status to the master device, wherein the data transmission requirement status is used to indicate whether the slave device has a data transmission requirement; After the master device enters the dormant state, if it detects that the slave device has a data transmission requirement, it enters the activated state; When the data transmission requirement state is that there is a data transmission requirement, the slave device transmits the original data to be sent to the master device.
10. A master device, characterized in that: The master device includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the BLE Bluetooth module is used to execute the steps of the BLE-based data transmission method as described in any one of claims 1 to 3.
11. A slave device, characterized in that: The slave device includes a controller and a BLE Bluetooth module, the controller is connected to the BLE Bluetooth module, and the controller is used to execute the steps of the BLE-based data transmission method as described in any one of claims 4 to 8.
12. A readable storage medium, characterized in that: The readable storage medium is a computer-readable storage medium, and a computer program is stored on the readable storage medium. When the computer program is executed by a processor, the steps of the BLE-based data transmission method according to any one of claims 1 to 8 are implemented.