Data communication method, system, controller and storage medium based on BLE4.0 channel
By introducing a data frame number mechanism in the BLE4.0 channel, the integrity problem caused by data packet subcontracting in the BLE4.0 channel is solved, and the sequential transmission of data frames is ensured, and the reliability and efficiency of data transmission are achieved.
Patent Information
- Application Number
- CN202211594999.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-12-13
AI Technical Summary
In the BLE4.0 channel, the maximum transmission unit MTU of the data link layer is 23, resulting in the underlying subcontracting of packets exceeding 23 bytes, resulting in the application layer data packet integrity that cannot be defined and the data packet cannot be parsed and communication failed.
By establishing a data frame number mechanism between the sender and the responder, we ensure the sequential transmission of data frames, and use data frame numbers (0xff, 0x00, 0x01-0xfe) to identify the data frame type and order, ensuring the integrity of the data frame and Sequential transmission to avoid packet distribution errors.
It effectively guarantees the integrity of the application layer data frames, ensures the order of sending and receiving data frames, avoids the problems of undefined packet integrity and unresolved packets, and improves the reliability of data transmission in BLE4.0 channels.
Smart Images

Figure CN116015544B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data communication technology, and in particular to a data communication method based on a BLE4.0 channel, a data communication system based on a BLE4.0 channel, a controller and a computer storage medium. Background Art
[0002] Among the existing technologies, BLE4.0 is used more and more frequently. BLE4.0 includes three technologies: traditional Bluetooth, high-speed Bluetooth and low-power Bluetooth. Low power consumption is its core. BLE4.0 has the characteristics of low cost, backward compatibility and cross-vendor.
[0003] However, when data is transmitted in the BLE4.0 channel, the maximum transmission unit (MTU) of the BLE data link layer is 23, which means that BLE will perform underlying packet processing on messages longer than 23 bytes. This will cause a series of problems at the application layer, such as the inability to define the integrity of data messages, resulting in the inability to parse data packets and resulting in communication failure. Summary of the invention
[0004] The embodiments of the present application provide a data communication method based on BLE4.0 channel, a data communication system based on BLE4.0 channel, a controller and a computer storage medium, which can at least ensure that the scheme of the present application sends one or more data frames to the responder according to the data frame number through the sender, and the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, and then the communication protocol design when communicating in the BLE4.0 channel can effectively ensure the integrity of the application layer data frame, distribute the data message to different communication objects for data processing, group the message at the bottom layer and then send it multiple times, ensure the order of sending and receiving the data frame, and avoid problems such as the inability to define the message integrity and the inability to parse the data packet.
[0005] In a first aspect, an embodiment of the present application provides a data communication method based on a BLE 4.0 channel, wherein the data communication method based on the BLE 4.0 channel is applied to a data communication system based on a BLE 4.0 channel, wherein the data communication system includes a sender and a responder, and the data communication method includes:
[0006] The sender performs data grouping processing on the transmission data to obtain one or more data frames, wherein the data frame includes a data frame number;
[0007] The sender determines the data frame number corresponding to each of the data frames according to the grouping order of one or more of the data frames;
[0008] The sender determines the data frame number of the tail data frame in one or more data frames as 0xff;
[0009] The sender sends one or more data frames to the responder according to the data frame number;
[0010] In the case where the data frame number corresponding to the data frame received by the responder is not 0xff, the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number;
[0011] Alternatively, when the data frame number corresponding to the data frame received by the responder is 0xff, the responder sends 0xFF to the sender to stop the data communication of the transmission data.
[0012] In some embodiments, when the number of the data frames is single, the data frame is the tail data frame, and when the number of the data frames is multiple, the data frames include a head data frame, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of one or more of the data frames, including:
[0013] The sender determines the data frame number of the head data frame among the multiple data frames as 0x00.
[0014] In some embodiments, when the number of the data frames is greater than two, the data frames further include one or more intermediate data frames, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of the one or more data frames, further comprising:
[0015] The sender determines the data frame number of the intermediate data frame according to the grouping order of one or more of the data frames, so that the data frame number of the intermediate data frame cycles from small to large between 0x01 and 0xfe.
[0016] In some embodiments, the data structure of the header data frame includes the data frame number, logical object, total digital length, data length of this frame, valid data and check data.
[0017] In some embodiments, the data structure of the intermediate data frame and the tail data frame includes the data frame number, the data length of the current frame, valid data and check data.
[0018] In some embodiments, the data size of the data frame is less than or equal to 20 bytes.
[0019] In some embodiments, the sender sends one or more data frames to the responder according to the data frame number, including:
[0020] Timing is performed during the process in which the sender sends one or more data frames to the responder according to the data frame number, and obtaining the time interval between the sender sending the data frame and receiving the responder information;
[0021] When the time interval is greater than or equal to 500 ms, the sender resends one or more data frames to the responder.
[0022] In a second aspect, an embodiment of the present application provides a data communication system based on a BLE 4.0 channel, wherein the data communication system includes a sender and a responder.
[0023] The sender is configured to perform data grouping processing on the transmission data to obtain one or more data frames, wherein the data frames include data frame numbers, determine the data frame numbers corresponding to the data frames according to the grouping order of the one or more data frames, determine the data frame number of the tail data frame in the one or more data frames to be 0xff, and send the one or more data frames to the responder according to the data frame numbers;
[0024] The responder is used to obtain the next frame number according to the data frame number corresponding to the data frame received by the responder when the data frame number corresponding to the data frame received by the responder is not 0xff, and send the next frame number to the sender so that the sender sends the corresponding data frame to the responder according to the next frame number; or, when the data frame number corresponding to the data frame received by the responder is 0xff, send 0xFF to the sender to stop the data communication of the transmitted data.
[0025] In a third aspect, an embodiment of the present application provides a controller comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the data communication method based on the BLE4.0 channel as described in any one of the embodiments in the first aspect is implemented.
[0026] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the data communication method based on the BLE4.0 channel as described in any one of the embodiments in the first aspect.
[0027] The present application has at least the following beneficial effects: the data communication method based on the BLE4.0 channel is applied to a data communication system based on the BLE4.0 channel, the data communication system includes a sender and a responder, the data communication method includes: the sender performs data grouping processing on the transmission data to obtain one or more data frames, the data frame includes a data frame number, the sender determines the data frame number corresponding to each data frame according to the grouping order of one or more data frames, the sender determines the data frame number of the tail data frame in one or more data frames as 0xff, the sender sends one or more data frames to the responder according to the data frame number, and when the data frame number corresponding to the data frame received by the responder is not 0xff, the The responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, or, when the data frame number corresponding to the data frame received by the responder is 0xff, the responder sends 0xFF to the sender to stop the data communication of the transmitted data, and then the communication protocol design when communicating in the BLE4.0 channel can effectively ensure the integrity of the application layer data frame, distribute the data message to different communication objects for data processing, group the message at the bottom layer and then send it multiple times, ensure the sending and receiving order of the data frame, and avoid problems such as the inability to define the message integrity and the inability to parse the data packet. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 This is a flow chart of a data communication method based on a BLE 4.0 channel proposed in one embodiment of the present application;
[0029] Figure 2 This is a flow chart of a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0030] Figure 3 This is a flow chart of a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0031] Figure 4 This is a flow chart of a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0032] Figure 5 A system communication model diagram of a data communication system based on a BLE 4.0 channel proposed in another embodiment of the present application;
[0033] Figure 6 A schematic diagram of a data frame in a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0034] Figure 7 This is a schematic diagram of a first data frame in a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0035] Figure 8 This is a schematic diagram of other frame data in a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application;
[0036] Fig. 9 A schematic diagram of data frame transmission and reception in data communication proposed in another embodiment of the present application;
[0037] Fig.10 This is a structural diagram of a controller proposed in another embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0039] In some embodiments, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms first, second, etc. in the specification, claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0040] At present, in the existing technology, BLE4.0 is used more and more frequently. BLE4.0 includes three technologies: traditional Bluetooth, high-speed Bluetooth and low-power Bluetooth. Among them, low power consumption is its core. BLE4.0 has the characteristics of low cost, backward compatibility and cross-vendor. However, when transmitting data in the BLE4.0 channel, the maximum transmission unit MTU of the BLE data link layer is 23, that is, BLE will perform bottom-level packet processing on messages with a length of more than 23 bytes, which will bring a series of problems to the application layer, such as the inability to define the integrity of the data message, resulting in the inability to parse the data packet and resulting in communication failure.
[0041] In order to at least solve the above-mentioned problems, the present application discloses a data communication method based on BLE4.0 channel, a data communication system based on BLE4.0 channel, a controller and a computer storage medium, wherein the data communication method based on BLE4.0 channel is applied to a data communication system based on BLE4.0 channel, the data communication system includes a sender and a responder, and the data communication method includes: the sender performs data grouping processing on the transmission data to obtain one or more data frames, the data frame includes a data frame number, the sender determines the data frame number corresponding to each data frame according to the grouping order of the one or more data frames, the sender determines the data frame number of the tail data frame in the one or more data frames as 0xff, the sender sends the one or more data frames to the responder according to the data frame number, and when the responder receives the data frame, the responder sends the one or more data frames to the responder. When the data frame number corresponding to the received data frame is not 0xff, the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number. Alternatively, when the data frame number corresponding to the data frame received by the responder is 0xff, the responder sends 0xFF to the sender to stop the data communication of the transmitted data. The communication protocol design when communicating in the BLE4.0 channel can effectively ensure the integrity of the application layer data frame, distribute the data message to different communication objects for data processing, group the message at the bottom layer and then send it multiple times to ensure the order of sending and receiving the data frame, and avoid problems such as the inability to define the message integrity and the inability to parse the data packet.
[0042] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0043] refer to Figure 1 , Figure 1 A flowchart of a data communication method based on a BLE 4.0 channel proposed in an embodiment of the first aspect of the present application. In some embodiments, an embodiment of the present application provides a data communication method based on a BLE 4.0 channel. The data communication method based on a BLE 4.0 channel is applied to a data communication system based on a BLE 4.0 channel. The data communication system includes a sender and a responder. The data communication method includes but is not limited to the following steps S110, S120, S130, S140 and S150;
[0044] Step S110, the sender performs data grouping processing on the transmission data to obtain one or more data frames, where the data frame includes a data frame number;
[0045] Step S120, the sender determines the data frame number corresponding to each data frame according to the grouping order of one or more data frames;
[0046] Step S130, the sender determines the data frame number of the tail data frame in the one or more data frames as 0xff;
[0047] Step S140, the sender sends one or more data frames to the responder according to the data frame number;
[0048] Step S150, when the data frame number corresponding to the data frame received by the responder is not 0xff, the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number;
[0049] Step S160, or, in the case that the data frame number corresponding to the data frame received by the responder is 0xff, the responder sends 0xFF to the sender to stop the data communication of the transmitted data.
[0050] In some embodiments, when data is transmitted in the BLE4.0 channel, the MTU of the BLE data link layer is 23, that is, BLE will perform bottom-level packet processing on messages longer than 23 bytes. This will cause a series of problems in the application layer, such as the inability to define the integrity of the data message, resulting in the inability to parse the data packet and thus communication failure. Therefore, this patent provides a communication protocol design method when communicating in the BLE4.0 channel. The protocol can ensure the integrity of the application layer data frame, distribute the data message to different communication objects for data processing, ensure the order of sending and receiving the data frame, and avoid problems such as the inability to define the integrity of the message and the inability to parse the data packet.
[0051] In some embodiments, the data volume of the data frame of the present application is less than or equal to 20 bytes. The sending party application layer groups the data to obtain one or more data frames. The data volume of each data frame shall not exceed 20 bytes (including frame header, communication logic object, check data and valid data). Then, when the data structure of the header data frame includes the data frame number, logical object, total digital length, data length of this frame, valid data and check data, it is ensured that the BLE does not exceed 23 bytes in length. Specifically, the header data frame is the first frame in multiple data frames. The sender first groups and packages the data to be sent, and then sends them from the first frame downwards in sequence until all data are sent. For multiple frames of data, only the last frame of the data frame has a data volume less than 20 bytes, and the data volume of other frames is equal to 20 bytes, so that data transmission is more efficient and the data transmission rate is improved.
[0052] refer to Figure 2 , Figure 2A flowchart of a data communication method based on a BLE 4.0 channel proposed in another embodiment of the present application. In some embodiments, when the number of data frames is single, the data frame is a tail data frame, and when the number of data frames is multiple, the data frame includes a head data frame. The sender determines the data frame number corresponding to each data frame according to the grouping order of one or more data frames, including but not limited to the following steps S210;
[0053] Step S210: The sender determines the data frame number of the head data frame among the multiple data frames as 0x00.
[0054] In some embodiments, the sender determines the data frame number of the head data frame among multiple data frames as 0x00, or the sender determines the data frame number of the tail data frame among one or more data frames as 0xff. Therefore, when it is 0x00, it means that the message transmitted this time is divided into multiple frames for transmission, and when it is 0xff, it means that the data amount transmitted this time can be fully transmitted in one frame.
[0055] refer to Figure 3 , Figure 2 A flowchart of a data communication method based on a BLE 4.0 channel proposed in another embodiment of the present application. In some embodiments, when the number of data frames is greater than two, the data frame further includes one or more intermediate data frames. The sender determines the data frame number corresponding to each data frame according to the grouping order of the one or more data frames, including but not limited to the following steps S310;
[0056] Step S310: The sender determines the data frame number of the intermediate data frame according to the grouping order of one or more data frames, so that the data frame number of the intermediate data frame cycles from small to large between 0x01 and 0xfe.
[0057] In some embodiments, the sender determines the data frame number of the intermediate data frame according to the grouping order of one or more data frames, so that the data frame number of the intermediate data frame cycles from small to large between 0x01 and 0xfe. Specifically, the frame number is 1 byte in length, and the frame numbers of other frames are 0x01 to 0xff, which gradually increase from small to large. When it is the last frame, the value is 0xff. When it is not the last frame, the value is 0x01 to 0xfe, which increases from small to large, and cycles in sequence, so that the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number. The sender and the receiver can send and receive in the order of data grouping, which can ensure the integrity of the application layer data frame and distribute the data messages to different communication objects for data processing.
[0058] refer to Figure 4 , Figure 4This is a flow chart of a data communication method based on a BLE 4.0 channel proposed in another embodiment of the present application. In some embodiments, the sender sends one or more data frames to the responder according to the data frame number, including but not limited to the following steps S410 and S420;
[0059] Step S410, timing the process in which the sender sends one or more data frames to the responder according to the data frame number, and obtaining the time interval from when the sender sends the data frame to when the responder information is received;
[0060] Step S420: When the time interval is greater than or equal to 500 ms, the sender resends one or more data frames to the responder.
[0061] In some embodiments, the data communication between the sender and the responder in the present application is carried out in a question-and-answer manner, with timeout retransmission, the timeout is 500ms, and the number of retransmissions is 3 times, further ensuring the integrity of the data frame transmission between the sender and the responder.
[0062] refer to Figure 5 , Figure 5 This is a system communication model diagram of a data communication system based on a BLE 4.0 channel proposed in another embodiment of the present application. In some embodiments, such as Figure 5 As shown in the communication model, the BLE host communicates with the slave, and the specific logical entity of the communication can be the communication object of the master and slave. When the communication message is larger than 23 bytes, the data link layer of BLE4.0 will group the message into bottom layers and then send it multiple times.
[0063] refer to Figure 6 , Figure 6 This is a schematic diagram of a data frame in a data communication method based on a BLE4.0 channel proposed in another embodiment of the present application. In some embodiments, when there are multiple data frames, refer to Figure 6 , multiple data frames include a first frame, an Nth frame and a last frame, the first frame is the head data frame in this application, the Nth frame is the middle data frame in this application, and the last frame is the tail data frame in this application.
[0064] refer to Figure 7 , Figure 7This is a schematic diagram of the first data frame in the data communication method based on the BLE4.0 channel proposed in another embodiment of the present application. In some embodiments, the data structure of the header data frame includes a data frame number, a logical object, a total digital length, a data length of this frame, valid data and check data, wherein the frame number is 1 byte long, and the frame number of the first frame is 0x00 or 0xff; when it is 0x00, it indicates that the message transmitted this time is divided into multiple frames for transmission; when it is 0xff, it indicates that the amount of data transmitted this time can be fully transmitted in one frame; the logical object is 1 byte long, indicating the specific occurrence object of this communication; the total data length is 2 bytes, and the big-endian mode is adopted, indicating the total length of valid data transmitted this time; the frame data length is 1 byte, indicating the length of valid data in this frame; the valid data is the actual data of the message group contained in this frame, and its length is represented by the data length of this frame; the check data is 1 byte, which is the LRC check of all data from the frame number to the valid data.
[0065] refer to Figure 8 , Figure 8 This is a schematic diagram of other frame data in the data communication method based on the BLE4.0 channel proposed in another embodiment of the present application. In some embodiments, the data structure of the intermediate data frame and the tail data frame includes a data frame number, a data length of this frame, valid data and check data, wherein the frame number is 1 byte long, and the frame number of other frames is 0x01 to 0xff. It gradually increases from small to large. When it is the last frame, the value is 0xff, and when it is not the last frame, the value is between 0x01 and 0xfe, arriving from small to large, and circulates in sequence; the data length of this frame is 1 byte, indicating the length of the valid data in this frame; the valid data is the actual data of the message group contained in this frame, and its length is represented by the data length of this frame; the check data is 1 byte, which is the LRC check of all data from the frame number to the valid data.
[0066] refer to Fig. 9 , Fig. 9 This is a schematic diagram of data frame reception and transmission in data communication proposed in another embodiment of the present application. In some embodiments, the data structure of the middle data frame and the tail data frame includes the data frame number, the data length of the current frame, the valid data and the check data. When the transmission data is multi-frame data, during the transmission process, the sender sends a small segment of the entire message, and the responder sends the expected next frame number. For example, the sender sends the first frame data as "0x00 0x00 0x000x20 0x0f..." The responder replies: "0x01", and after receiving it, the sender continues to send the second frame.
[0067] In some embodiments, when the sender sends the last frame, the responder returns 0xFF. When the responder has return data, the responder returns the response data in an active sending manner, and the corresponding logical object is consistent with the received data, specifically as follows: the responder performs data grouping processing on the transmission data to obtain one or more data frames, and the data frame includes a data frame number; the responder determines the data frame number corresponding to each data frame according to the grouping order of the one or more data frames; the responder determines the data frame number of the tail data frame in the one or more data frames as 0xff; the responder sends the one or more data frames to the sender according to the data frame number; when the data frame number corresponding to the data frame received by the sender is not 0xff, the sender obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the responder, so that the responder sends the corresponding data frame to the sender according to the next frame number; or, when the data frame number corresponding to the data frame received by the sender is 0xff, the sender sends 0xFF to the responder to stop the data communication of the transmission data.
[0068] In some embodiments, the present application proposes a data communication system based on a BLE4.0 channel, the data communication system including a sender and a responder, the sender is used to perform data grouping processing on the transmission data to obtain one or more data frames, the data frame including a data frame number, and determine the data frame number corresponding to each data frame according to the grouping order of the one or more data frames, and determine the data frame number of the tail data frame in the one or more data frames as 0xff, and send the one or more data frames to the responder according to the data frame number; the responder is used to obtain the next frame number according to the data frame number corresponding to the received data frame when the data frame number corresponding to the data frame received by the responder is not 0xff, and send the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, or, when the data frame number corresponding to the data frame received by the responder is 0xff, send 0xFF to the sender to stop data communication of the transmission data.
[0069] In some embodiments, the data communication system based on the BLE4.0 channel can effectively ensure the integrity of the application layer data frame, distribute the data message to different communication objects for data processing, group the message at the bottom layer and then send it multiple times, to ensure the order of sending and receiving data frames, and avoid problems such as the inability to define message integrity and the inability to parse data packets.
[0070] refer to Fig.10 , Fig.10 It is a schematic diagram of the structure of a controller provided by an embodiment of the present invention.
[0071] Some embodiments of the present invention provide a controller, the controller comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the data communication method based on the BLE4.0 channel of any one of the above embodiments when executing the computer program, for example, executing the above described Figure 1 Steps S110 to S160 of the method, Figure 2 In the method step S210, Figure 3 Step S310 of the method, Figure 4 The method comprises steps S410 to S420.
[0072] The controller 1000 of the embodiment of the present invention includes one or more processors 1010 and a memory 1020. Fig.10 In the figure, a processor 1010 and a memory 1020 are taken as an example.
[0073] The processor 1010 and the memory 1020 may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.
[0074] The memory 1020 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory 1020 may include a high-speed random access memory and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device.
[0075] In some embodiments, the memory 1020 may optionally include a memory 1020 remotely disposed relative to the processor 1010, and these remote memories may be connected to the controller 1000 via a network. Examples of the above-mentioned networks include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0076] In some embodiments, when the processor executes the computer program, the data communication method based on the BLE4.0 channel of any of the above embodiments is executed at a preset interval.
[0077] Those skilled in the art will understand that Fig.10 The device structure shown in the figure does not constitute a limitation on the controller 1000, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0078] exist Fig.10 In the controller 1000 shown, the processor 1010 can be used to call the data communication method based on the BLE4.0 channel stored in the memory 1020, so as to implement the data communication method based on the BLE4.0 channel.
[0079] Based on the hardware structure of the above-mentioned controller 1000, various embodiments of the data communication system based on the BLE4.0 channel of the present invention are proposed. At the same time, the non-transient software program and instructions required to implement the data communication method based on the BLE4.0 channel of the above-mentioned embodiment are stored in the memory. When executed by the processor, the data communication method based on the BLE4.0 channel of the above-mentioned embodiment is executed.
[0080] In addition, an embodiment of the present invention further provides a data communication system based on a BLE4.0 channel, and the data communication system based on a BLE4.0 channel includes the above-mentioned controller.
[0081] In some embodiments, since the data communication system based on the BLE4.0 channel of an embodiment of the present invention has the controller of the above-mentioned embodiment, and the controller of the above-mentioned embodiment can execute the data communication method based on the BLE4.0 channel of the above-mentioned embodiment, the specific implementation manner and technical effects of the data communication system based on the BLE4.0 channel of an embodiment of the present invention can refer to the specific implementation manner and technical effects of the data communication method based on the BLE4.0 channel of any of the above-mentioned embodiments.
[0082] The embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to execute the above-mentioned data communication method based on the BLE4.0 channel, for example, the one or more processors can execute the data communication method based on the BLE4.0 channel in the above-mentioned method embodiment, for example, execute the above-described Figure 1 Steps S110 to S160 of the method, Figure 2 In the method step S210, Figure 3 Step S310 of the method, Figure 4 The method comprises steps S410 to S420.
[0083] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network nodes. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0084] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer-readable storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer-readable storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer-readable storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically embodies computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0085] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Technical personnel familiar with the field can also make various equivalent modifications or substitutions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A data communication method based on BLE4.0 channel, It is characterized in that The data communication method based on the BLE4.0 channel is applied to a data communication system based on the BLE4.0 channel, the data communication system includes a sender and a responder, and the data communication method includes: The sender performs data grouping processing on the transmission data to obtain one or more data frames, wherein the data frame includes a data frame number; The sender determines the data frame number corresponding to each of the data frames according to the grouping order of one or more of the data frames; The sender determines the data frame number of the tail data frame in one or more data frames as 0xff; The sender sends one or more data frames to the responder according to the data frame number; In the case where the data frame number corresponding to the data frame received by the responder is not 0xff, the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number; Alternatively, when the data frame number corresponding to the data frame received by the responder is 0xff, the responder sends 0xFF to the sender to stop the data communication of the transmission data; Wherein, in the case where the number of the data frames is single, the data frame is the tail data frame, and in the case where the number of the data frames is multiple, the data frames include a head data frame, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of one or more of the data frames, including: The sender determines the data frame number of the head data frame among the multiple data frames as 0x00; Wherein, when the number of the data frames is greater than two, the data frames further include one or more intermediate data frames, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of the one or more data frames, further comprising: The sender determines the data frame number of the intermediate data frame according to the grouping order of one or more of the data frames, so that the data frame number of the intermediate data frame cycles from small to large between 0x01 and 0xfe, wherein the data frame number is 1 byte in length, and the frame numbers of other frames are 0x01 to 0xff, which gradually increase from small to large. When it is the last frame, the value is 0xff, and when it is not the last frame, the value is 0x01 to 0xfe from small to large, which cycles in sequence, so that the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, so that the sender and the receiver can send and receive in the order of data grouping.
2. The data communication method based on the BLE4.0 channel according to claim 1, It is characterized in that The data structure of the header data frame includes the data frame number, logical object, total digital length, data length of this frame, valid data and check data.
3. The data communication method based on the BLE4.0 channel according to claim 1, It is characterized in that The data structure of the intermediate data frame and the tail data frame includes the data frame number, the data length of the current frame, valid data and check data.
4. The data communication method based on the BLE4.0 channel according to claim 1, It is characterized in that The data size of the data frame is less than or equal to 20 bytes.
5. The data communication method based on BLE4.0 channel according to claim 1, It is characterized in that The sending party sends one or more data frames to the responding party according to the data frame number, including: Timing is performed during the process in which the sender sends one or more data frames to the responder according to the data frame number, and obtaining a time interval between the sender sending the data frame and receiving the responder information; When the time interval is greater than or equal to 500 ms, the sender resends one or more data frames to the responder.
6. A data communication system based on BLE4.0 channel, It is characterized in that The data communication system includes a sender and a responder. The sender is configured to perform data grouping processing on the transmission data to obtain one or more data frames, wherein the data frames include data frame numbers, determine the data frame numbers corresponding to the data frames according to the grouping order of the one or more data frames, determine the data frame number of the tail data frame in the one or more data frames to be 0xff, and send the one or more data frames to the responder according to the data frame numbers; The responder is used to obtain a next frame number according to the data frame number corresponding to the received data frame when the data frame number corresponding to the data frame received by the responder is not 0xff, and send the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, or, when the data frame number corresponding to the data frame received by the responder is 0xff, send 0xFF to the sender to stop the data communication of the transmission data; Wherein, in the case where the number of the data frames is single, the data frame is the tail data frame, and in the case where the number of the data frames is multiple, the data frames include a head data frame, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of one or more of the data frames, including: The sender determines the data frame number of the head data frame among the multiple data frames as 0x00; Wherein, when the number of the data frames is greater than two, the data frames further include one or more intermediate data frames, and the sender determines the data frame number corresponding to each of the data frames according to the grouping order of the one or more data frames, further comprising: The sender determines the data frame number of the intermediate data frame according to the grouping order of one or more of the data frames, so that the data frame number of the intermediate data frame cycles from small to large between 0x01 and 0xfe, wherein the data frame number is 1 byte in length, and the frame numbers of other frames are 0x01 to 0xff, which gradually increase from small to large. When it is the last frame, the value is 0xff, and when it is not the last frame, the value is 0x01 to 0xfe from small to large, which cycles in sequence, so that the responder obtains the next frame number according to the data frame number corresponding to the received data frame, and sends the next frame number to the sender, so that the sender sends the corresponding data frame to the responder according to the next frame number, so that the sender and the receiver can send and receive in the order of data grouping.
7. A controller, It is characterized in that It comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the data communication method based on the BLE4.0 channel as claimed in any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the data communication method based on the BLE4.0 channel as described in any one of claims 1 to 5.
