A simple link message transmission method and system

Through the simple link message transmission method, link status judgment and message correctness check are used to solve the problem of complexity and low efficiency of existing protocols in embedded systems, and efficient communication in resource-constrained environments is achieved , suitable for embedded and low-power Bluetooth applications.

CN115955729BActive Publication Date: 2024-11-08CHANGSHA JOYMED MEDICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211604006.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-13
Publication Date
2024-11-08
Estimated Expiration
2042-12-13

AI Technical Summary

Technical Problem

The existing communication protocols are complex and inefficient in embedded resource-constrained systems, lack stability and comprehensiveness, resulting in the waste of manpower and material resources of repeated development and testing, and cannot provide a highly versatile simple link message transmission method.

Method used

A simple link message transmission method is proposed, which sends connection messages every time period through the sender and the receiver, judges the link status, and sends data messages in the link connection state, and the receiver checks the correctness of the message And respond, use ACK or NAK messages for confirmation and error processing, supports heartbeat mechanism and optional encryption, and is suitable for embedded systems.

Benefits of technology

Reduces the complexity of protocol implementation, simplifies communication processes, reduces system resource requirements, improves communication efficiency, can run on small embedded MCUs, and has stronger versatility, suitable for product information exchange and low-power Bluetooth applications system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115955729B_ABST
    Figure CN115955729B_ABST
Patent Text Reader

Abstract

The present invention provides a simple link message transmission method and system, which relates to the field of communication technology, and includes the following steps: determining the link status of the communication link; the sender sends a data message and waits for the receiver to respond, and the waiting time is T. ack ; The data message is at least one of a connection message, a normal data message and an encrypted data message; the receiver checks the correctness of the data message and responds to the received data message; the receiver replies with a response message, and the sender processes the response message. The present invention provides a simple link message transmission method and system, which can carry different applications on the upper layer by providing a simple transmission control mechanism. Based on the link message transmission method, some commonly used applications can be defined, and users can also customize new applications, which is more versatile.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a simple link message transmission method and system. Background Art

[0002] The communication protocol is called the software of the communication system. It completes the transmission of communication information together with the hardware (various communication devices). It is an indispensable and very important component in the modern communication system. There are many communication protocols now, but they are basically aimed at high-end and complex scenarios. There is no ready-made simple and practical underlying communication protocol available.

[0003] The Chinese patent application number CN201710656499.5 discloses a data transmission method and system of a communication protocol, the data transmission method comprising: forwarding node data stream, classifying the data stream, and obtaining multiple data stream fragments; configuring a unique identity tag for each data stream fragment, calling a preset data stream protocol for preprocessing, and sending the identity tag information to a central processor; the central processor allocates a storage area and sends feedback information to the forwarding node; the forwarding node calls a preset transfer channel to send the data stream fragment to the corresponding storage area. It also relates to a system, which includes: a server, a forwarding node, and a central processor. The invention can avoid data stream loss during transmission. When data stream loss occurs, it can be quickly searched through identity tags and the storage area is partitioned, which is conducive to orderly receiving data stream fragments, greatly reducing the phenomenon of chaotic sending of data stream fragments and improving the transmission rate of data streams.

[0004] The Chinese patent application number CN201610413632.X discloses a relay communication protocol method with a variable header, which includes: encapsulating the transmission data according to a certain data format, dividing it into request messages and response messages according to the message type, dividing it into switch messages and digital messages according to the message mode, completing different types of encapsulation according to different message requests or response methods, each field represents a different meaning, and can effectively reduce the transmission of invalid data. The data message is attached with a check code to check the message data transmission to ensure the correctness of the data transmission process. The invention is simple and easy to implement, can work on a variety of communication protocols, is not restricted by the platform, can reduce communication traffic, save power, and can effectively integrate data interaction between heterogeneous wireless sensor network systems.

[0005] The above protocols are all mature, too complex, occupy more resources, and have slightly low execution efficiency, especially in embedded resource-constrained systems. However, writing a dedicated protocol for each project is not stable and comprehensive enough, and repeated development and testing wastes manpower and material resources. Therefore, it is necessary to provide a communication protocol and data transmission method with strong versatility, using a simple transmission control mechanism and carrying different applications on its basis. Summary of the invention

[0006] Based on the above problems, the present invention discloses a simple link message transmission method and system.

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] A simple link message transmission method, the steps comprising:

[0009] S1, establish link connection;

[0010] The sender and the receiver each time period T connect Send a connection message to the other party to determine whether a response is received. If both parties receive a correct response message, the communication link is determined to be in a link connection state;

[0011] S2. Based on the link connection state, enter at least one of a working state and a standby state;

[0012] The standby state is: every T hello Time, the sender sends a connection message to the receiver. If the receiver feeds back a correct response message, the link remains normal; if there is T disconnect If no response message is received within the time, the communication link is determined to be in a link-disconnected state;

[0013] S3: If the working state is entered, the sender sends a data message and waits for the receiver to respond. The waiting time is T ack ; The data message is at least one of a connection message, a normal data message and an encrypted data message; the receiver checks the correctness of the data message and responds to the received data message; the receiver checks the correctness of the data message including checking the message checksum, checking the message type and checking the message ID;

[0014] S4. The receiver replies with a response message, and the sender processes the response message.

[0015] Preferably, the method by which the receiving party responds to the received data message is:

[0016] If a connection message is received, respond with an ACK message, wherein the ID of the ACK message matches the ID of the connection message;

[0017] If a normal data message is received, respond with an ACK message, wherein the ID of the ACK message matches the ID of the normal data message, and processes the App message payload function according to the application protocol;

[0018] If there is an error in the correctness of the data message, a NAK message with error information is responded.

[0019] Preferably, the method for the receiver to check the correctness of the data message is performed according to the following message correctness checking steps:

[0020] Check the message checksum: Verify that the checksum calculated by the message length must be the same as the checksum field inside the message. If they are different, respond with a NAK message and specify the error cause as a checksum error. If they are the same, record the message ID and continue to check the message type.

[0021] Check the message type: verify whether the message type is supported. If it is an unsupported type, respond with a NAK message and specify the error cause as: unknown type error; otherwise, continue to check the message ID;

[0022] Check the message ID: T repeat Whether the IDs of two adjacent messages received within the time are the same, if they are the same, it is determined that the message is sent repeatedly, responds with a NAK message, and specifies the error cause as a duplicate ID error.

[0023] Preferably, if the sender receives a NAK message and the error cause is a checksum error, the sender attempts to resend the same data message;

[0024] If the sender receives a NAK message and the error cause is an unknown type error or a duplicate ID error, the sender stops sending the data message and enters the next data message sending process.

[0025] Preferably, the method for the sender to process the response message is:

[0026] If an ACK message is received, determine whether the ID of the ACK message matches the ID field of the sent data message. If not, ignore the ACK message and continue to wait for the response message. If they match, stop waiting.

[0027] If a NAK message is received, determine whether the ID of the NAK message matches the ID field of the sent data message. If not, ignore the NAK message and continue to wait for the response message. If they match, obtain the error information in the NAK message and take corresponding measures.

[0028] Preferably, if T ack If no response message with matching ID is received within the time period, the sender determines that the link of the receiver is faulty and stops waiting to resend the same data message;

[0029] If the number of times the data packet is sent has reached or exceeded C retry , the sender determines that the communication link is in a link-disconnected state and stops sending data messages.

[0030] The present invention also provides a simple link message transmission system, comprising a first processing system and a second processing system;

[0031] The first processing system includes a main processor and a first application processor, and the second processing system includes a second application processor;

[0032] Serial port communication is performed between the main processor and the first application processor, and between the main processor and the second application processor, using a simple link message transmission method as described in any one of the above.

[0033] Preferably, the first application processor is a first low-power Bluetooth processor; the second application processor is a second low-power Bluetooth processor; the first low-power Bluetooth processor and the second low-power Bluetooth processor are connected via Bluetooth wireless communication.

[0034] Preferably, the main processor uses a simple link message transmission method as described in any one of the above

[0035] The Bluetooth application function of the first low-power Bluetooth processor / the second low-power Bluetooth processor is called; at this time, the main processor is defined as the Bluetooth user, and the first low-power Bluetooth processor / the second low-power Bluetooth processor is the Bluetooth provider.

[0036] Preferably, the Bluetooth function at least includes: turning on the low-power Bluetooth function, turning off the low-power Bluetooth function, reading the low-power Bluetooth status, scanning devices, stopping scanning, connecting to a specified device, disconnecting, and using customized services.

[0037] Compared with the prior art, the present invention has the following advantages:

[0038] The present invention proposes a simple link message transmission method and system, which provides a simple transmission control mechanism, and its upper layer can carry different applications. The message transmission method disclosed in the present invention first performs the link state of the communication link, and the sender and the receiver send messages at intervals. Tconnect Send a connection message to the other party to determine whether a response is received. If both parties receive the correct response message, the communication link is determined to be in a link connection state. The verification method is simpler, reducing the complexity of protocol implementation. The communication process is simple, concise and compact, with low requirements on system resources. It can run on a small embedded MCU (microcontroller) and has stronger versatility.

[0039] Based on the data transmission method of this application, some commonly used applications can be defined, and users can also customize new applications, which is more versatile. At present, it has been successfully applied to product information exchange systems and low-power Bluetooth application systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a flow chart of a simple link message transmission method of the present invention;

[0041] Figure 2 It is a schematic diagram of a simple link message transmission system of the present invention;

[0042] Figure 3 It is a schematic diagram of a BLE application in a simple link message transmission system of the present invention. DETAILED DESCRIPTION

[0043] In order to make the purpose and technical solution of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention.

[0044] Embodiment 1

[0045] The present invention provides a simple link message transmission method suitable for communication with embedded products, wherein the common binary protocol (hereinafter referred to as JCBP protocol) is a common point-to-point binary protocol. The two communicating parties are called nodes, and the communication between nodes is full-duplex. Communication requires a response to ensure reliability, and supports retransmission and timeout mechanisms. The protocol supports a heartbeat mechanism to maintain the virtual connection between the two communicating parties. The protocol supports an optional encryption scheme to ensure the security of data transmission.

[0046] The JCBP protocol is designed to provide a simple transmission control mechanism, and its upper layer can carry different applications. This protocol also defines some commonly used applications, and users can also customize new applications. The main application scenario of the JCBP protocol is embedded resource-constrained systems, so its message size and complexity are subject to certain restrictions, which is convenient for implementation in resource-constrained systems. The JCBP protocol can run on different link layers. Such as serial ports, BLE wireless, etc. It can be used between two systems, or it can run between two CPUs in a system.

[0047] The JCBP protocol uses binary messages, and its message format is shown in Table 1:

[0048] Table 1 JCBP protocol binary message format

[0049]

[0050] The definitions of the terms are as follows:

[0051] Message length (Length): indicates the overall length of the message, in bytes. One byte can be expressed as 1 byte. The maximum length of the overall message is 256 bytes.

[0052] Type: The type field is 1 byte long. This field defines the type of message. The JCBP protocol has two major message categories, one is control message and the other is data message.

[0053] Control messages include ACK messages (acknowledgement data messages) and NAK messages (error feedback messages).

[0054] The ACK message is a confirmation data message, which is used to confirm the correctness of the received data message; when the message length, type, ID, message payload, checksum and other formats of the received data message pass the check, the receiver should send an ACK message; the ID field of the ACK message should be the ID of the data message to which it responds; the ACK message has no message payload. The NAK message is used to feedback message errors to the sender. When the message length, type, ID, message payload, checksum check of the received message fails, the receiver should send a NAK message. The ID field of the NAK message is the ID of the data message to which it responds. The message payload field of the NAK message contains one byte, which is the error field, used to describe the type of error. Its error types can be summarized as described in Table 2:

[0055] Table 2 Types of NAK message description errors

[0056]

[0057] Data messages include ordinary data messages, and other types of messages will be expanded to support, such as encrypted data messages. Commonly used data messages can be of the following three types:

[0058] The connection message is used for the heartbeat mechanism and does not carry any other data. The message payload field is empty. The connection message requires confirmation from the receiver.

[0059] Ordinary data messages are used to transmit unencrypted data. The transmitted data content is in the message payload field. Ordinary data messages require confirmation from the receiver.

[0060] Encrypted data messages are used to transmit encrypted data. The transmitted data content is in the message payload field. Encrypted data messages require confirmation by the receiver.

[0061] ID: All data messages contain an ID field, which is used as a serial number of the sender to identify the uniqueness of the data message sent within a certain period of time. The ID field is 1 byte and its value ranges from 1 to 255. The sender starts at 1 and increases by 1 each time it tries to send a new message. After reaching 255, it restarts from 1 and ends; the ID field in the control message is the ID value of the data message it responds to.

[0062] Message Payload: The message payload field is the payload of the message, with a length of 0 to 250 bytes. The message payload field is used to carry application data, and its content may be encrypted. For encrypted data, it needs to be decrypted first. The format of the decrypted message payload field is shown in Table 3 below:

[0063] Table 3 Message payload field format

[0064]

[0065] AppID is the application ID, which is used to identify the data usage of the App message payload. The field is 1 byte, and the value is 1 to 255. 1 to 127 represent system applications, which are specified by this protocol. Users can use 128 to 255 to define their own applications as long as the communicating parties can reach an agreement. The App message payload represents application data, and the length is usually 0 to 249 bytes.

[0066] Checksum (CRC) is a channel coding technology that generates a short fixed-bit check code based on data such as network data packets or computer files. It is mainly used to detect or verify errors that may occur after data transmission or storage. Checksum can correct errors in the information transmission process at a high rate, complete the calculation of data check codes in a very short time, and quickly complete the error correction process. By automatically retransmitting data packets, the computer's communication speed is greatly improved, providing guarantees for communication efficiency and security. Since the checksum algorithm has a strong error detection capability and a low detection cost, it is widely used in the detection of encoders and circuits.

[0067] The specific steps of the data transmission method based on the communication binary protocol include:

[0068] Step 1: Determine the link status of the communication link. Both parties need to determine the status of the communication link. At the beginning of the protocol, both parties determine that the link is disconnected. T connect The link is connected when it receives any correct message from the other party.

[0069] Only when the link is connected can data packets other than connection packets be sent to the other party. T hello If there is no need for other message interaction within this period, one party should try to send a connection message or any other normal message to the other party to keep the link normal.

[0070] in T connect The time interval for trying to establish a connection is preferably 1-120 seconds; Thello is the heartbeat time interval, preferably 1-120 seconds, T disconnect To determine the time of disconnection, generally 3-360 seconds, usually T hello Three times.

[0071] Step 2: The sender sends a data message and waits for the receiver to respond. The waiting time is T ack ;in T ack The value of is 100-5000 milliseconds; the data message is at least one of a connection message, a common data message and an encrypted data message;

[0072] Step 3: The receiver checks the correctness of the data message and responds to the received data message; if a connection message is received, it responds with an ACK message, wherein the ID of the ACK message matches the ID of the connection message; if a normal data message is received, it responds with an ACK message, wherein the ID of the ACK message matches the ID of the normal data message, and processes the App message payload function according to the application protocol; if there is an error in the correctness of the data message, it responds with a NAK message with error information.

[0073] Step 4: The receiver replies with a response message, and the sender checks the correctness of the response message and processes it.

[0074] If the sender receives an ACK message, it determines whether the ID of the ACK message matches the ID field of the sent data message. If not, the ACK message is ignored and the sender continues to wait for the response message. If they match, the sender stops waiting and can continue to send the next message.

[0075] If a NAK message is received, determine whether the ID of the NAK message matches the ID field of the sent data message. If not, ignore the NAK message and continue to wait for the response message. If they match, obtain the error information in the NAK message and take corresponding measures. Depending on the error reason returned by the other party, the receiver should take different measures:

[0076] If the sender receives a NAK message and the error is caused by a checksum error, the sender attempts to resend the same data message. If the number of times the message has been sent has reached or exceeded C retry (The maximum number of retransmissions is preferably 3-10 times), the sender should consider that the message cannot be successfully delivered, should discard the message, and can continue to send the next message; if the sender receives a NAK message and the error cause is an unknown type error or a duplicate ID error, the sender stops sending the data message and enters the next data message sending process.

[0077] Waiting time for response T ack If the sender does not receive an ACK or NAK with a matching ID within 10 seconds, the sender will assume that the other party or the link is faulty. The sender should stop waiting and try to resend the message. If the message has been sent for a certain number of times or more, C retry (The maximum number of retransmissions is preferably 3-10 times), the sender should consider the link disconnected and stop sending data messages.

[0078] The method for the receiver to check the correctness of the data message and the sender to check the correctness of the response message are both performed according to the following message correctness checking steps:

[0079] S1. Check the message checksum: The checksum calculation includes multiple calculations of the message length, type, ID, and message payload. Verify that the checksum calculated by the message length must be the same as the checksum field inside the message. If different, respond with a NAK message and specify the error cause as a checksum error; if the same, record the ID of the message and continue with S2 check.

[0080] S2. Check the message type: verify whether the message type is supported. If it is an unsupported type, respond with a NAK message and specify the error cause as: unknown type error; otherwise, continue with S3.

[0081] S3, check the message ID: determine T repeat Within the time (ID duplication time, generally 100-5000 milliseconds), the IDs of two adjacent messages received are the same. If they are the same, it is determined that the message is sent repeatedly, responds with a NAK message, and specifies the error cause as a duplicate ID error. T repeat satisfy: T repeat =2* T ack .

[0082] When the JCBP protocol is used for communication between two processors, in low-power applications, the processor of the receiving party may be in a low-power sleep state, and its response to the sender's data may not be timely enough. This usually causes data loss, and thus data cannot be received normally. The usual solution is to select the appropriate T ack and C retry , in conjunction with the time when the processor exits the low-power sleep mode. When the processor exits the low-power mode, it maintains the running mode for a certain period of time (at least enough to receive the other party's data), so that the sender's resent data can be completely received.

[0083] Embodiment 2

[0084] This embodiment is based on the specific application of the simplified link message transmission method (hereinafter referred to as JCBP protocol) provided in the first embodiment. JCBP application generally refers to an application that transmits another layer of JCBP protocol data in the App message payload of the JCBP protocol. Figure 2 and Figure 3As shown, the JCBP protocol innovatively defines an application mode. In this application mode, a first processing system and a second processing system are included; the first processing system includes a main processor and a first application processor, and the second processing system includes a second application processor;

[0085] The main processor and the first application processor, as well as the main processor and the second application processor, communicate via serial ports through the simple link message transmission method shown in the JCBP protocol. In this mode, extended application modes such as product information exchange, JCBP application (transmitting another layer of JCBP protocol through JCBP), and BLE application (using the BLE function provided by one party through JCBP control) can be completed. In particular, JCBP application and BLE application can achieve penetrating communication and penetrating control due to the simplicity of the JCBP protocol. The application mode can also be extended to other methods, such as WIFI control.

[0086] Here is an example of an application scenario: a dual-processor system A, including a main processor and a BLE (Bluetooth Low Energy) processor. The main processor and the BLE processor communicate through the serial port using the JCBP protocol. System A communicates with another system B using a BLE processor through BLE. The communication endpoints between system A and system B are the main processor of system A and the BLE processor of system B, but they must pass through the BLE processor of system A in order to communicate wirelessly through BLE.

[0087] At this time, the main processor of system A and the BLE of system B can also communicate using JCBP, and their communication messages are implemented between the main processor of system A and the BLE processor through the JCBP application.

[0088] The JCBP application is transmitted as the App message payload of the underlying JCBP, so its overall size is limited by the size of the underlying App message payload. Its message format is the JCBP format.

[0089] BLE applications are used by one party to control and use the Bluetooth Low Energy (BLE) function of another party through JCBP. Usually, the two communicating parties are two processors in the same system, and the two communicating parties can be connected through serial ports and other means. In such applications, the party that provides the BLE function is called the BLE provider, and the other party is called the BLE user.

[0090] BLE applications are designed mainly for BLE devices. In order to simplify the work of users, BLE providers hide some BLE functions and only provide some functions to BLE users, some of which use special services of BLE devices. All BLE devices should be identified by product model and serial number. In BLE applications, this is used to identify BLE devices instead of traditional MAC addresses. BLE providers usually only support one BLE role, central device (Central) or peripheral device (Peripheral), and only support one BLE connection.

[0091] The functions of BLE applications mainly include: BLE users request BLE providers to turn on BLE functions, turn off BLE functions, read BLE status, scan devices, stop scanning, connect to specified devices, disconnect, and use TX service (a BLE service) to send data.

[0092] The BLE provider actively reports BLE status changes, scan results, and data received by the RX service (a BLE service) to the BLE user.

[0093] The message types of BLE applications are shown in the following table:

[0094] Table 4 BLE application message types

[0095]

[0096] Several important message types are defined as follows:

[0097] BLE status message: BLE status message is used by BLE provider to report BLE status changes to user. When the user reads the BLE status, the BLE provider also uses this message to respond to the other party. It contains several status types, as shown in Table 5:

[0098] Table 5 BLE status message status

[0099]

[0100] Scan Start Message: Scan Start Message is used to start scanning. The BLE consumer uses this message to request the BLE provider to start scanning for devices. The request can contain the product model to be scanned, and even the product serial number. If the product model is not provided, it is considered to search for any product model. If the product serial number is not provided, it is considered to search for any product serial number.

[0101] After receiving the Scan Start message, if the BLE provider can support scanning, it should start scanning immediately and report the Scan Start message with the status of Scanning. If the BLE provider cannot support scanning, it should immediately return the Scan Stop message.

[0102] During the scanning process, the BLE provider is responsible for comparing the scanned devices to see if they meet the product model and serial number required by the user, and should only return the scan results that meet the conditions. When the scan is completed, the BLE provider reports the scan termination. If the BLE user actively requests to stop scanning during the scanning process, the BLE status message is reported, and the status is connection preparation status.

[0103] The message format of the scan start message is shown in Table 6:

[0104] Table 6 StartScan message format

[0105]

[0106] The parameters are defined as:

[0107] Scan duration (Time): 1 byte, unsigned integer. From 0 to 255 seconds. When the value is 0, it means that the scan will continue until the BLE user explicitly requests to stop scanning.

[0108] Product model (Model): 7 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 7 bytes.

[0109] Product serial number (Serial): 10 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 10 bytes.

[0110] Scan result message: The scan result message is used by the BLE provider to report the scanned BLE devices that meet the requirements to the BLE user. The message format is shown in Table 7:

[0111] Table 7 Scan result message format

[0112]

[0113] The parameters are defined as:

[0114] Product model (Model): 7 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 7 bytes.

[0115] Product serial number (Serial): 10 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 10 bytes.

[0116] Signal strength (RSSI): 1 byte. Signed integer, -127 to 127.

[0117] Designated device connection message: The BLE user requests the BLE provider to connect to the designated device. After receiving this message, the BLE provider should start trying to connect to the designated device and return a BLE status message with the status being connected. If the device is already connected at that time, it should disconnect the device and connect the new device. When the connection succeeds or fails, a BLE status message should be sent with the status being connected or ready to connect. The message format is as follows:

[0118] Table 8 specifies the message format of the device connection message

[0119]

[0120] The parameters are defined as:

[0121] Product model: Product model, 7 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 7 bytes.

[0122] Product serial number: Product serial number, 10 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 10 bytes.

[0123] TX send message: TX send message is a means for BLE users to send data to other Bluetooth devices through the TX service of the BLE provider. The TX service provides an unreliable data transmission service, and the data sent is not confirmed at the Bluetooth level. Therefore, the user needs to use the upper-layer application to ensure the confirmation and retransmission of data transmission. If the data size sent by the TX send message exceeds the maximum transmission unit (MTU) size of the BLE provider, the BLE provider should have the function of automatic packetization, or be able to adjust the size of the maximum transmission unit to adapt to the data size of the TTX send message.

[0124] Table 9 TX message format for sending messages

[0125]

[0126] The parameters are defined as:

[0127] Message length: data length, 1 byte, unsigned integer. The value range is 1 to 247 bytes.

[0128] Data: The data to be sent.

[0129] RX receive message: RX receive message is the message sent to BLE user when BLE provider receives data from other Bluetooth devices through RX service. RX service also provides unreliable data transmission service, and the data sent is not confirmed in Bluetooth. Therefore, the user needs to ensure the confirmation and retransmission of data transmission through upper layer application.

[0130] Table 10 Message format of RX received message

[0131]

[0132] The parameters are defined as:

[0133] Message length: data length, 1 byte, unsigned integer. The value range is 1 to 247 bytes.

[0134] Data: The data to be sent.

[0135] Embodiment 3

[0136] This embodiment provides a product information exchange system based on the specific application of the JCBP protocol-based data transmission method provided in the first embodiment.

[0137] The two communicating parties often need to know each other's product information, such as product model, serial number, hardware version, software version, etc. Sometimes this need is two-way, sometimes it is one-way, and the information to be exchanged may not be exactly the same. The purpose of this product information exchange system is to exchange this product information between the two communicating parties.

[0138] It is generally believed that product information will not change much during the software operation, so it only needs to be performed once when the connection is established. Since the communication parties may not have completely consistent judgments on the connection status, in certain special time periods, one party may think that the connection is disconnected while the other party thinks that the connection is successful.

[0139] The following describes the rules for exchanging product information: When the connection state of one party changes from the disconnected state to the connected state, it actively sends its own product information to the other party through a product information message. When one party needs to know the other party's product information, it can actively send a product information response message to the other party. After receiving the product information response message, the recipient should send a product information message to the other party.

[0140] Specific messages include product information messages and product information response messages.

[0141] The product information message is used to report its own product information to the other party. The App message payload format is shown in the following table:

[0142] Table 11 App message payload format of product information message

[0143]

[0144] The definition of each parameter is:

[0145] Product information: indicates that this message is a product information message, 1 byte, fixed to 0x01.

[0146] Product model (Model): 7 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 7 bytes.

[0147] Product serial number (Serial): 10 bytes. The content is a string ending with '\0'. Including '\0', it cannot exceed 10 bytes.

[0148] Hardware version (HWVer): one byte, ranging from 1 to 255.

[0149] Software version (SWVer): 3 bytes. The first byte is the major version, the second byte is the minor version, and the third byte is the revision version.

[0150] The App message payload format of the product information response message is shown in the following table:

[0151] Table 12 App message payload format of product information response message

[0152]

[0153] The definition of each parameter is:

[0154] Product information response: Indicates that this message is a product information response message, 1 byte. Fixed to 0x02. The following product model, product serial number, hardware version, and software version indicate the sender's own product information, and the meaning and format are the same as the product information message.

[0155] The above is only an embodiment of the present invention, and its description is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A simple link message transmission method, characterized in that: A binary protocol is used for message transmission. The binary protocol is a point-to-point binary protocol. The two communicating parties are called nodes. The nodes communicate in full-duplex mode. The application scenario of the binary protocol is an embedded resource-constrained system. The message of the binary protocol has five fields, which are 1 byte message length, 1 byte type, 1 byte ID, 0-250 bytes message payload and 2 bytes checksum. The steps include: S1, establish link connection; The sender and receiver communicate every time period T connect Send a connection message to the other party to determine whether a response is received. If both parties receive a correct response message, the communication link is determined to be in a link connection state; S2. Based on the link connection state, enter at least one of a working state and a standby state; The standby state is: every T hello Time, the sender sends a connection message to the receiver. If the receiver feeds back a correct response message, the link remains normal. If there is T disconnect If no response message is received within the time, the communication link is determined to be in a link-disconnected state; S3: If the working state is entered, the sender sends a data message and waits for the receiver to respond. The waiting time is T ack ; The data message is at least one of a connection message, a normal data message and an encrypted data message; the receiver checks the correctness of the data message and responds to the received data message; the receiver checks the correctness of the data message including checking the message checksum, checking the message type and checking the message ID; S4, the receiving party replies with a response message, and the sending party processes the response message; The receiving party responds to the received data message including: When the message length, type, ID, message payload, checksum and format of the received data message pass the check, the receiver sends an ACK message, the ID field of the ACK message is the ID of the data message it responds to; the message payload has two subfields, namely AppID and App message payload; if the data message responded by the ACK message is a common data message, the receiver processes the App message payload function according to the application protocol; if there is an error in the correctness of the data message, a NAK message with error information is responded; The receiver checks the correctness of the data message according to the following message correctness check steps: Check the message checksum: Verify whether the checksum calculated by the message length is the same as the checksum field inside the message. If they are different, respond with a NAK message and specify the error cause as a checksum error. If they are the same, record the message ID and continue to check the message type. Check the message type: verify whether the message type is supported. If it is an unsupported type, respond with a NAK message and specify the error cause as: unknown type error; otherwise, continue to check the message ID; Check the message ID: determine the repeat Whether the IDs of two adjacent messages received within the time are the same, if they are the same, it is determined that the message is sent repeatedly, responds with a NAK message, and specifies the error cause as a duplicate ID error.

2. A simple link message transmission method as claimed in claim 1, characterized in that: If the sender receives a NAK message and the error cause is a checksum error, the sender attempts to resend the same data message; If the sender receives a NAK message and the error cause is an unknown type error or a duplicate ID error, the sender stops sending the data message and enters the next data message sending process.

3. A simple link message transmission method as claimed in claim 1, characterized in that: The method for the sender to process the response message is: If an ACK message is received, determine whether the ID of the ACK message matches the ID field of the sent data message. If not, ignore the ACK message and continue to wait for the response message. If they match, stop waiting. If a NAK message is received, determine whether the ID of the NAK message matches the ID field of the sent data message. If not, ignore the NAK message and continue to wait for the response message. If they match, obtain the error information in the NAK message and take corresponding measures.

4. A simple link message transmission method as claimed in claim 3, characterized in that: If in T ack If no response message with matching ID is received within the time period, the sender determines that the link of the receiver is faulty, stops waiting and resends the same data message; If the number of times the data message is sent reaches or exceeds C retry , the sender determines that the communication link is in a link-disconnected state and stops sending data messages.

5. A simple link message transmission system, characterized in that: including a first processing system and a second processing system; The first processing system includes a main processor and a first application processor, and the second processing system includes a second application processor; Serial communication is performed between the main processor and the first application processor, and between the main processor and the second application processor, through a simple link message transmission method as described in any one of claims 1 to 4.

6. A simple link message transmission system as claimed in claim 5, characterized in that: The first application processor is a first low-power Bluetooth processor; the second application processor is a second low-power Bluetooth processor; the first low-power Bluetooth processor and the second low-power Bluetooth processor are connected via Bluetooth wireless communication.

7. A simple link message transmission system as claimed in claim 6, characterized in that: The main processor calls the Bluetooth application function of the first low-power Bluetooth processor / the second low-power Bluetooth processor through a simple link message transmission method as described in any one of claims 1-4; at this time, the main processor is defined as a Bluetooth user, and the first low-power Bluetooth processor / the second low-power Bluetooth processor is a Bluetooth provider.

8. A simple link message transmission system as claimed in claim 7, characterized in that: The Bluetooth application functions at least include: turning on the low-power Bluetooth function, turning off the low-power Bluetooth function, reading the low-power Bluetooth status, scanning devices, stopping scanning, connecting to a specified device, disconnecting, and using customized services.