CN110493775B - Communication method and system adapted by ATT and exception handling - Google Patents

Communication method and system adapted by ATT and exception handling Download PDF

Info

Publication number
CN110493775B
CN110493775B CN201910783902.XA CN201910783902A CN110493775B CN 110493775 B CN110493775 B CN 110493775B CN 201910783902 A CN201910783902 A CN 201910783902A CN 110493775 B CN110493775 B CN 110493775B
Authority
CN
China
Prior art keywords
cpa
layer
att
error
pdu
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910783902.XA
Other languages
Chinese (zh)
Other versions
CN110493775A (en
Inventor
钟代笛
冯海玲
曹小英
段小炼
高雪梅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing University
Original Assignee
Chongqing University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing University filed Critical Chongqing University
Priority to CN201910783902.XA priority Critical patent/CN110493775B/en
Publication of CN110493775A publication Critical patent/CN110493775A/en
Application granted granted Critical
Publication of CN110493775B publication Critical patent/CN110493775B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/02Protecting privacy or anonymity, e.g. protecting personally identifiable information [PII]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/04Key management, e.g. using generic bootstrapping architecture [GBA]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/06Authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/04Arrangements for maintaining operational condition
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W80/00Wireless network protocols or protocol adaptations to wireless operation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Telephonic Communication Services (AREA)
  • Communication Control (AREA)

Abstract

The invention belongs to the technical field of data communication, and particularly relates to a communication method and a system which are adaptive through ATT and exception handling, wherein the communication method comprises a CPA layer with an exception handling method, and the exception handling method comprises the following steps: the invention solves the problem that communication between two communication parties fails due to errors or abnormalities such as time interval overtime, execution errors of an ATT attribute operation method, ATT protocol errors and the like or link loss and the like which often occur in the data exchange process or CPA data exchange process of the two communication parties, and has the beneficial technical effects of identifying the types of errors generated in the data exchange process and carrying out active or automatic fault-tolerant processing, thereby ensuring the effectiveness of the data communication process.

Description

Communication method and system adapted by ATT and exception handling
Technical Field
The invention belongs to the technical field of data communication, and particularly relates to a communication method and a communication system which are adaptive through ATT and exception handling.
Background
Att (attribute protocol) is a data transmission protocol proposed by the bluetooth alliance, which is suitable for sensor network applications. The protocol models data exposed to the outside of the sensor equipment into a plurality of attributes (attributes) with handles (handles), and the master equipment completes the operation on the attributes through protocol instructions with various different functions, so that the aim of realizing data exchange with the slave equipment is fulfilled;
due to a plurality of factors such as signal interference, too long distance, protocol content errors and the like, errors or abnormal conditions often occur in the communication process, in order to enhance the robustness and environmental adaptability of communication, two parties participating in data communication should monitor and analyze various abnormal error conditions which may occur, and effective measures are taken to recover the normal state of communication, or a user is informed of the abnormal conditions and corresponding error details are provided. The handling mechanism for abnormal error conditions is one of the effective tools to help the communication device manage the communication state;
the invention is based on the application number: 201910765383.4, filing date: in 2019, 08 and 19 months, the invention name is as follows: a data communication system and method relying on ATT and indication for adaptation;
the existing communication mode has the problem that communication failure of two communication parties is caused by errors or abnormity such as time interval overtime, execution errors of an ATT attribute operation method, errors of an ATT protocol and the like or link loss and the like in the data exchange process or CPA data exchange process of the two communication parties.
Disclosure of Invention
The invention provides a communication method and a system which are adaptive through ATT and exception handling, and aims to solve the problem that communication failure of two communication parties is caused by errors or exceptions such as time interval overtime, execution errors of an ATT attribute operation method, ATT protocol errors and the like or link loss and the like which often occur in the data exchange process or CPA data exchange process of the two communication parties in the background technology.
The technical problem solved by the invention is realized by adopting the following technical scheme: before data exchange is carried out between master and slave devices, both communication sides respectively establish a data communication protocol stack level structure which sequentially comprises a bottom layer transmission layer, an attribute protocol ATT layer, a universal attribute specification protocol adaptation CPA layer, a data exchange protocol PHD layer and an application layer from bottom to top;
the CPA layer includes an exception handling method, the exception handling method including:
if the two communication parties generate time interval overtime or CC attribute abnormity or ASN field value abnormity in the data exchange process, executing corresponding active abnormal event intervention;
if the two communication parties generate an ATT attribute operation method to execute an error in the CPA data exchange process, executing corresponding active ATT error intervention;
if the two communication parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error which is thrown on an ATT layer and is defined in the error code range of an application layer reserved by the ATT, and then corresponding active CPA PDU error intervention is executed;
and if the link loss is detected, executing corresponding non-active event exception handling.
Further, if the two communication parties generate time interval timeout or CC attribute exception or ASN field value exception during the data exchange process, executing corresponding active exception event intervention includes:
if any one of four time intervals included in the CPA layer for assisting the CPA layer in managing the connection state thereof is expired, or:
if the CPA connection sub-process is not successful, either party of the two communication parties receives the message related to the CC attribute, or;
if the CPA runs in the sub-process, the value of the ASN field in the CPA PDU received by either one of the two communication parties is not the ASN value added with 1 in the CPA PDU which is successfully transmitted or received last time;
the master device then:
the indication function of the CC attribute of the default slave equipment is closed, the working state data is cleared, a notice that the connection of the bottom layer is disconnected is sent to the PHD layer, and other data sent by the slave equipment is not processed before the next connection;
the slave device then:
and closing the indication function of the CC attribute, clearing the working state data, sending an event notice with the semantic of disconnecting the bottom layer connection to the PHD layer, and not processing other data sent by the main equipment except the connection request.
Further, the CPA layer comprises four time intervals for assisting the CPA layer in managing the connection state thereof;
a first time interval: the longest waiting time for the master device to receive the corresponding ATT write response after sending the ATT write request or the longest waiting time for the slave device to receive the corresponding ATT confirmation after sending the ATT indication;
the second time interval is: the CPA layer receives the longest waiting time from the time-out error of the link connection sent by the ATT layer to the successful link reconnection;
the third time interval: after the ATT layer is planned to be disconnected, when the CPA layer receives APDU from the PHD layer, the CPA layer sends semantics to the ATT layer, wherein the semantics is the longest waiting time from the start of establishing a bottom layer connection internal instruction to the completion of reconnection of the ATT;
fourth time interval: and after receiving the semantic that the internal instruction of the bottom layer connection is disconnected, the CPA layer of the master equipment writes a second preset value into the IE attribute of the slave equipment to close the longest waiting time of the corresponding write response when the CC attribute indication function is closed.
Further, if the waiting time of any one of the four time intervals exceeds the maximum waiting time, the operating state of the CPA layer automatically changes.
Further, if the two communicating parties generate an ATT attribute in the CPA data exchange process and the operation method executes an error, executing corresponding active ATT error intervention includes:
the ATT protocol errors include authentication insufficiency, encryption insufficiency, key length insufficiency, unexpected errors, and invalid written values or other related errors;
if the authentication of the two communication parties is insufficient, the main equipment can carry out authentication operation and resend the ATT write request;
if the encryption of both communication parties is insufficient, the main equipment can carry out encryption operation and resend the ATT write request;
if the key lengths of the two communication parties are not enough, the main equipment can change the key and re-execute the encryption operation;
if both communication parties are in unexpected error, the main equipment can try to resend the ATT write request with the original write value;
if the written values of the two communication parties are invalid, the master device can try to write other preset values;
further, if one of the error types in the ATT protocol error repeatedly occurs, the subsequent error handling operation is decided by the application layer.
Further, if the two communicating parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error which is thrown on the ATT layer and is defined in the application layer error code range reserved by the ATT, and then the corresponding active CPA PDU error intervention is executed, including:
if the semantic meaning is error of receiving CPA PDU, the original sender can try to resend the current CPA PDU after receiving the error, meanwhile, the original receiver discards the received current CPA PDU segment when the error occurs and prepares to receive the resent CPA PDU, if the error is received after resending, the application layer determines the subsequent error processing operation;
if the semantics is an error that the CPA PDU information part is too long, the device where the receiving party is located cannot receive the too long APDU, the error is sent to the original sending party, the original sending party can try to resend a new CPA PDU after receiving the error, meanwhile, the original receiving party discards the current CPA PDU segment received when the error occurs and prepares to receive the resent CPA PDU, and if the error is still received after resending, the application layer determines the subsequent error processing operation.
Further, if the link loss is detected, the performing corresponding non-proactive event exception handling includes:
if the link loss is detected, the ATT layer sends a link connection timeout error to the CPA layer, when both communication sides receive the link connection timeout error at any time after the last CPA PDU transmission is completed, the working state data is saved, and after the ATT layer link reconnection is waited to be successful, both communication sides immediately enter a CPA operation sub-process and continue to execute the communication before the link disconnection from the current CPA PDU.
Further, if the link loss is detected, the executing the corresponding inactive exception handling further includes:
the working state data includes the ASN value in the last CPA PDU, and when the bottom layer link is disconnected:
if the sender encapsulates the APDU, the working state data also comprises the APDU sent by the PHD layer of the sender, and the APDU which is being encapsulated before the bottom-layer link is reconnected is encapsulated as the CPA PDU again after the bottom-layer link is reconnected;
if the sender is sending CPA PDU through ATT layer, the working state data also includes current CPA PDU, and resends CPA PDU after bottom link is reconnected;
if the receiving party is receiving the current CPA PDU, all the segments which are received and belong to the current CPA PDU are discarded.
The invention also provides a communication system adapted through ATT and exception handling, wherein before the communication system exchanges data based on the master and slave devices, the two communication sides respectively establish a data communication protocol stack level structure which sequentially comprises a bottom layer transmission layer, an attribute protocol ATT layer, a universal attribute specification protocol adaptation CPA layer, a data exchange protocol PHD layer and an application layer from bottom to top;
the CPA layer includes an exception handling module to:
a communication method adapted by ATT and exception handling implementing any of the above.
The beneficial technical effects are as follows:
if the two communication parties generate time interval overtime or CC attribute abnormity or ASN field value abnormity in the data exchange process, executing corresponding active abnormal event intervention; if the two communication parties generate an ATT attribute operation method to execute an error in the CPA data exchange process, executing corresponding active ATT error intervention; if the two communication parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error which is thrown on an ATT layer and is defined in the error code range of an application layer reserved by the ATT, and then corresponding active CPA PDU error intervention is executed; if detecting that the link is lost, executing corresponding non-active event exception handling;
the method has the advantages that errors in the processing process and errors which are automatically processed and do not need to be interfered are defined, the errors in the processing process are actively repaired through an error correction mechanism, and the errors which do not need to be interfered are automatically repaired, so that the problem that communication between two communication parties fails due to errors or abnormity such as time interval overtime, execution errors of an ATT attribute operation method, errors of an ATT protocol and the like or link loss and the like which often occur in the data exchange process or the CPA data exchange process of the two communication parties is solved, the types of the errors generated in the data exchange process are identified, and active or automatic fault-tolerant processing is carried out, so that the effectiveness of the data communication process is ensured;
the invention defines the error of the processing process and the error which is automatically processed and does not need to be intervened, actively repairs the error of the processing process through an error correction mechanism, and automatically repairs the error which does not need to be intervened.
Drawings
FIG. 1 is a flow chart of a communication method of the present invention adapted by ATT and exception handling;
fig. 2 is a timing chart of the master device of the communication method adapted by ATT and exception handling according to the present invention, which executes step a2, and receives a "CPA PDU reception error" handling method when transmitting a CPA PDU through a write request;
fig. 3 is a timing diagram of the master device of the communication method adapted by ATT and exception handling according to the present invention receiving the "CPA PDU reception error" handling method when transmitting CPA PDUs by a plurality of write requests, performing step a 2;
fig. 4 is a timing diagram of the slave device of the communication method adapted by ATT and exception handling according to the present invention receiving the CPA PDU reception error handling method when step B2 indicates transmission of CPA PDUs by an attribute;
fig. 5 is a timing diagram of the reception of the "CPA PDU reception error" handling method when the slave device of the communication method adapted by ATT and exception handling of the present invention performs step B2 to indicate the transmission of CPA PDUs by a plurality of attributes;
fig. 6 is a timing chart of the success of the underlying reconnection when the primary device of the communication method adapted by ATT and exception handling processes the underlying link timeout error when step a1 is executed;
fig. 7 is a timing chart of the failure of the underlying reconnection when the underlying link timeout error is handled when the master device of the communication method adapted by ATT and exception handling of the present invention performs step a 1;
fig. 8 is a timing chart of the success of the underlying reconnection when the primary device of the communication method adapted by ATT and exception handling processes the underlying link timeout error when step a2 is executed;
fig. 9 is a timing chart of the failure of the underlying reconnection when the underlying link timeout error is handled when the master device of the communication method adapted by ATT and exception handling of the present invention performs step a 2;
fig. 10 is a timing diagram of the success of the underlying reconnection when the underlying link timeout error is handled when the slave device of the communication method adapted by ATT and exception handling of the present invention performs step B1;
fig. 11 is a timing diagram of unsuccessful underlying reconnection when processing a link connection timeout error when the slave device of the communication method adapted by ATT and exception handling of the present invention performs step B1;
fig. 12 is a timing diagram of the success of the underlying reconnection when the underlying link timeout error is handled when the slave device of the communication method adapted by ATT and exception handling of the present invention performs step B2;
fig. 13 is a timing diagram of unsuccessful underlying reconnection when processing a link connection timeout error when the slave device of the communication method adapted by ATT and exception handling of the present invention performs step B2;
FIG. 14 is a timing diagram of an active exception intervention procedure performed when an error occurs in the CPA data exchange procedure of the communication method adapted by ATT and exception handling or when an unexpected ATT layer error occurs in the CPA data exchange procedure of the present invention;
the technical scheme provided by the invention has flexibility in implementation, and a preferable scheme can be provided for the technical effect to be achieved by the invention by setting part of parameters in the technical scheme and setting up a better application design related to the parameters, and the invention is further described by combining the accompanying drawings as follows:
the numbers in the figures represent the following:
1-a bottom layer transmission layer, 2-an ATT layer, 3-a CPA layer, 4-a PHD layer and 5-an application layer;
ST 401: if the two communication parties are in the data exchange process, time interval overtime or CC attribute abnormity or ASN field value abnormity is generated;
ST 402: executing corresponding active abnormal event intervention;
ST 403: if both communication parties generate an ATT attribute operation method to execute errors in the CPA data exchange process;
ST 404: executing corresponding active ATT error intervention;
ST 405: if two communication parties send a CPA PDU to a receiving party in the CPA data exchange process, an original sending party may receive an ATT protocol error which is thrown on an ATT layer and is defined in an application layer error code range reserved by the ATT;
ST 406: performing a corresponding active CPA PDU error intervention;
ST 407: if detecting the loss of the link;
ST 408: executing corresponding inactive event exception handling;
the specific implementation mode is as follows:
example (b):
in the CPA connection sub-process, the possible errors of the CPA connection sub-process and the corresponding error handling include:
1. when CPA connection starts but before CPA connection is unsuccessful, the master device or the slave device receives data related to CC attributes, for example, after the master device sends a "write request" with a predetermined value one to the slave device through ATT (both sides of the operation identifier are ready to use CPA for data communication), the master device receives an error condition of indication of CC attributes sent by the slave device before receiving a corresponding "write response", and after the error condition occurs, a proactive abnormal event intervention process is executed;
2. when the master device does not receive the 'write response' or the error response sent by the slave device through the ATT after waiting for the first time interval, executing an active abnormal event intervention process;
3. when a master device sends a "write request" for an IE attribute to a slave device via an ATT, it may receive an error response sent by the slave device regarding the throwing on the ATT layer, and the contents of these protocol errors are usually encoded or preset character strings, which represent specific semantics. The error response includes
a) The authentication is insufficient. At this point, the master device may perform an authentication operation and resend the "write request";
b) the encryption is insufficient. At this point, the master device may perform the encryption operation and resend the "write request";
c) the key length is not sufficient. At this time, the main device can change the key and execute the encryption operation again;
d) unexpected mistakes. At this point the master may attempt to resend a "write request" in which the value is unchanged.
e) The written value is invalid. This error code is defined to be within the reserved "application error" code of the ATT, at which time the master may attempt to write other predetermined values.
f) The remaining errors other than the above;
if any error in a) to f) repeatedly occurs, the application layer determines the subsequent error processing operation, for example, the application layer can disconnect the ATT layer connection;
errors that may occur in the CPA run sub-process and corresponding error handling include:
1. when the value of the ASN field in the CPA PDU received by the master device or the slave device is not the ASN value plus 1 in the CPA PDU which is successfully interacted (transmitted or received) last time, executing the active abnormal event intervention process.
2. Fig. 2 and 3 show that when the master device receives a response with an error code with the semantic "CPA PDU reception error" after sending a "write request" via ATT in step a2, then:
when the master performs step a2, i.e., sends a "write request" to the CC attribute of the slave through the ATT to send a CPA PDU, the master may receive an error response from the upper throw of the ATT layer and an error reason for indicating that a specified request cannot be completed in the ATT layer. The error thrown up may be a "CPA PDU reception error" defined within the "application error" code range reserved by the ATT to indicate that an error occurred at the CPA layer at the time of receiving the CPA PDU. At this time, the master device may try to perform step a2 again, in which the retransmitted write request contains CPA PDUs which remain unchanged, and the slave device discards the CPA PDUs received in error and prepares to re-receive the CPA PDUs, wherein, in connection with the implementation method shown in fig. 2, if the transmitted mth CPA PDU can be completely placed in an ATT PDU for transmission, the master device retransmits the mth CPA PDU after receiving the error response, the slave device only needs to discard the mth CPA PDU received in error and prepare to re-receive the mth CPA PDU, in connection with another implementation method shown in fig. 3, if the transmitted mth CPA PDU is divided into multiple sequential segments for transmission in sequence, and when the nth segment transmitting the mth CPA PDU has an error, the slave device discards all segments of the CPA PDU received before, and waits for re-reception of the start fragment of the mth CPA PDU. If the host device receives the ATT layer error after resending the write request, the application layer determines the subsequent error handling operation, for example, the application layer may notify the user to check whether the bluetooth connection is disconnected.
Fig. 4 and 5 are timing diagrams of the error handling method when the slave device receives a response with an error code with the semantic "CPA PDU reception error" after performing step B2, i.e. sending an "indication" of the CC property to the master device. The error handling is essentially the same as the error handling described in fig. 2 and fig. 3 in this embodiment, and the specific error handling process can be compared with the implementation method described with reference to fig. 2 and fig. 3.
3. When the master device does not receive the write response within a first time interval (the first time interval is far less than the timeout period specified by the ATT) after sending the write request; or after the slave equipment sends the indication and does not receive the confirmation within the first time interval, and the master equipment or the slave equipment determines that the connection of the ATT layer is abnormally disconnected, executing an active abnormal event intervention process.
4. In the operation process of the CPA, if the CPA layer does not receive the APDU sent by the self-PHD layer, the ATT layer may actively disconnect in view of saving power consumption, and if any one of the CPA layers receives the APDU sent by the self-PHD layer, after sending an internal command of "establishing ATT layer connection" to the disconnected ATT layer, when waiting for the third time interval and still not receiving an event notification of "established ATT layer connection" sent by the ATT layer, the ATT layer executes an active abnormal event intervention process.
5) Link connection timeout error. FIG. 6 is a timing diagram illustrating the bottom link timeout error handling performed by the master device in step A1. FIG. 8 is a timing diagram illustrating the bottom link timeout error handling performed by the master device in step A2. FIG. 10 is a timing diagram of the underlying link timeout error handling when the slave device performs step B1. FIG. 12 is a timing diagram of the underlying link timeout error handling when the slave device performs step B2. When the connected link is lost due to factors such as too long distance between the devices, severe interference or power failure, the ATT layer notifies the master device and the slave device of a link connection timeout error. When the master device and the slave device receive the error at any time after the m-1 CPA PDU transmission is completed, the working state data is saved, and the bottom layer link reconnection operation is executed in a second time interval. And when the ATT layer is reconnected successfully, entering a CPA operation sub-process immediately and recovering the communication state before the loss of the bottom layer link, namely, starting from the mth CPA PDU to continue executing the transmission process of the CPA PDU.
Fig. 7 is a timing diagram illustrating the ATT layer reconnection error when the master device performs step a1 and processes the underlying link timeout error. Fig. 9 is a timing diagram of the ATT layer reconnection error when the master device performs step a2 and processes the underlying link timeout error. Fig. 11 is a timing diagram of the ATT layer reconnection error when the slave device executes step B1 and processes the underlying link connection timeout error. Fig. 13 is a timing diagram of the ATT layer reconnection error when the slave device executes step B2 and processes the underlying link connection timeout error. If the underlying link reconnection is overtime, the master device and the slave device stop reconnection, the slave device closes the indication function of the CC attribute, and the indication function of the default CC attribute of the master device is closed, meanwhile, the master device and the slave device clear the data of the respective working states and send an event notice that the underlying connection is disconnected to the respective PHD layer, and if the master device is executing the step A1 or the step A2 when the link is lost, or the slave device is executing the step B1 or the step B2 when the link is lost, the master device or the slave device notifies the own PHD layer that the current APDU transmission fails.
When the PHD layer has no data to transmit and is in a certain sub-state of the connected state, the CPA layer sends an internal instruction with the semantic of disconnecting ATT layer connection to the ATT layer at any direction of the CPA layer, and the working state data is stored. And after the ATT layer is disconnected, sending an event notice that the ATT layer is connected with the disconnected event to the CPA layer. When any party (assumed as an original receiver) of the CPA layer receives an APDU (assumed as an mth APDU) sent by the PHD layer, if the ATT layer connection is disconnected, the CPA layer immediately sends an internal command of 'ATT layer connection establishment' to the ATT layer and waits for receiving an event notification of 'ATT layer connection establishment' sent by the ATT layer, and then the CPA layer sends the CPA PDU (m) to the original sender through a 'write request' defined by the ATT.
The errors and error handling that may occur in this embodiment are: and when the CPA layer waits for the third time interval after sending the internal command of 'establishing ATT layer connection' and does not receive the 'ATT layer connection established' event notification sent by the ATT layer, executing the active abnormal event intervention process.
In this embodiment, generally, in order to save power consumption, the ATT layer may control the ATT layer to actively disconnect when there is no data transmission, but the ATT layer may also remain in a connected state because the device reconnects and consumes a certain amount of energy, and if the device reconnects and consumes more energy than the device maintains the connection, the connection is maintained better, which mainly depends on the usage method of the device.
In this embodiment, the triggering condition of the CPA disconnection sub-process is that when the two communication parties end the interaction of the PHD layers or the PHD layers are abnormally disconnected, the PHD layers of the two communication parties are switched from the current state to the "unconnected" state, and send an internal instruction with a semantic of "disconnecting the bottom layer connection" to the respective CPA layers without waiting for the feedback of the respective CPA layers.
In this embodiment, the possible errors of the CPA disconnection sub-process include:
1. when the written value in the write request sent by the master device to the IE attribute is inconsistent with the preset closing value defined by the protocol, the slave device replies an error response with an error code with the semantic of 'written value invalid'.
2. After the slave device receives the event notification of ' bottom layer connection disconnection ' sent by the own PHD layer, if a ' write request with a predetermined value two for the IE attribute sent by the master device is not received within a fourth time interval, the slave device closes the indication function of the CC attribute, clears the working state data, and sends the event notification of ' bottom layer connection disconnection ' to the own PHD layer, and the master device defaults that the indication function of the CC attribute is closed after the fourth time interval, clears the working state data, and sends the event notification of ' bottom layer connection disconnection ' to the own PHD layer.
3. After the master device sends a write request with a preset value of two to the slave device, if the write response or the error response of the slave device is not received within the first time interval, the master device closes the indication function of the default CC attribute, clears the working state data, and sends an event notice that the bottom layer connection is disconnected to the PHD layer of the own party. For the slave equipment, after receiving a 'write request' with a preset value of two, the indication function of the CC attribute is closed, if the 'write response' is failed to be sent in a first time interval, the working state data is cleared, and an 'underlying connection disconnected' event notice is sent to the PHD layer of the own party.
Through the exception processing, errors in the processing process and errors which are processed automatically and do not need to be interfered are defined, the errors in the processing process are actively repaired through an error correction mechanism, and the errors which do not need to be interfered are automatically repaired.
As shown in fig. 1, the CPA layer includes an exception handling method including:
if both communication parties generate time interval overtime or CC attribute abnormity or ASN field value abnormity ST401 in the data exchange process, executing corresponding active abnormal event intervention ST 402;
if both communication parties generate an ATT attribute operation method to execute an error ST403 in the CPA data exchange process, executing corresponding active ATT error intervention ST 404;
if the two communication parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error ST405 which is thrown on an ATT layer and is defined in the error code range of an application layer reserved by the ATT, and then corresponding active CPA PDU error intervention ST406 is executed;
if a link loss is detected ST407, then a corresponding inactive event exception handling is performed ST408
Due to the Communication Protocol Adaptation (CPA) layer, the slave device (personal health device) is used for data Communication between the master device and the slave device (personal health device) with low power consumption and low computing resources. The Protocol stack level structure of the data communication is respectively a bottom layer transmission layer, an Attribute Protocol (ATT) layer, a CPA layer, a personal health device application layer data exchange Protocol (PHD) layer and an application layer from bottom to top. The CPA layer manages the operation of the ATT, so that the PHD depending on reliable connection-oriented (reliable-oriented) can normally operate on the ATT characterized by stateless communication, is not influenced by frequent disconnection and reconnection of the ATT and the bottom layer transmission, is not limited by the protocol message length of the ATT, not only fully utilizes the low power consumption characteristic of the ATT, but also can realize the synchronous interaction of two communication parties on an application layer; the attribute protocol (ATT) is a standard in the Bluetooth Low Energy (BLE) technology standard system, characterized in that: the slave devices compliant with the standard provide the exchanged data in the format of an Attribute (Attribute) defined in the BLE standard when exchanging data with the master device. The master device following the standard can operate on the attribute provided by the slave device by the "write request", "write response", "indication", "confirmation", and "information search request" methods among the attribute operation methods defined in the ATT. The ATT is composed of an ATT data unit (ATT PDU) and an ATT data exchange procedure. The ATT PDU is a data message which is exchanged at an ATT layer and conforms to the message format defined by ATT, and the byte length of a Payload (Payload) part of the ATT PDU does not exceed the maximum Payload length of the ATT PDU. The transmission of the ATT PDUs is done by the underlying transport layer. The ATT data exchange process comprises an ATT connection establishment process, an ATT operation process and an ATT planned disconnection process. The ATT connection establishment process is a process that two communication parties establish communication connection between the two parties at a bottom layer transmission layer by using a broadcast event and a scanning event defined in BLE; the ATT planned disconnection process is a process in which communication connection between two communication parties is disconnected at a bottom layer transmission layer by using a termination connection event defined in BLE, and the CPA layer is characterized by being composed of a CPA data exchange unit (CPA PDU) and a CPA data exchange process. The CPA PDUs are data messages of a specific format exchanged at the CPA layer, the CPA PDUs are transmitted via ATT as payload in ATT PDUs. The two communication parties can only operate the CPA data exchange process when the two communication parties are in the ATT operation process, and the process comprises a CPA connection sub-process, a CPA operation sub-process and a CPA disconnection sub-process.
The two device roles of the slave device and the master device respectively obtain APDUs from the PHD layer of the device where the slave device and the master device are located, and then the APDUs are packaged into a CPA PDU format and transmitted to the opposite side through ATT; the two device roles also receive CPAP PDU from the opposite side respectively, and extract APDU contained in the CPAP PDU and send the APDU to respective PHD layer, and the two communication sides can operate the PHD layer data exchange process only when the two communication sides are in the CPA operation sub-process and the PHD layer enters the connected state. When the PHD layers of both communication parties transmit APDUs, the PHD layer of the sender sends the APDUs to the CPA layer of the other party, and data transmission is carried out through the CPA layer. When the PHD layers of the two communication parties finish interaction or are abnormally disconnected, the PHD layers of the two communication parties are switched to an unconnected state from a current state, and send an internal instruction with a semantic of disconnecting the bottom layer connection to the CPA layers of the two communication parties without waiting for the feedback of the CPA layers of the two communication parties. The application layer may set Connection parameters related to power consumption, such as a Connection interval (Connection interval) defined in BLE and Slave device latency (Slave latency), according to a data transmission requirement based on a low power consumption characteristic of a bottom layer transmission technology, and further control a timing sequence of reconnection of a bottom layer link between devices, where the CPA layer is characterized in that both communication parties may complete use and management of ATT through CPA. When the two communication parties are in a connected state in the PHD layer, the two communication parties can disconnect the ATT layer through the CPA layer so as to reduce power consumption. If the application layer does not intend to disconnect the PHD layer, before disconnecting the ATT layer, both communication parties save the working state data of the CPA layer and the PHD layer; when reconnection is needed, the two communication parties reestablish the connection of the ATT layer through the CPA layer, and continue to execute the PHD layer data exchange process based on the previously stored working state data.
As shown in fig. 1, if the two communicating parties generate time interval timeout or CC attribute abnormality or value abnormality of ASN field ST401 during data exchange, executing corresponding proactive abnormal event intervention ST402 includes:
if any one of four time intervals included in the CPA layer for assisting the CPA layer in managing the connection state thereof is expired, or:
if the CPA connection sub-process is not successful, either party of the two communication parties receives the message related to the CC attribute, or;
if the CPA runs in the sub-process, the value of the ASN field in the CPA PDU received by either one of the two communication parties is not the ASN value added with 1 in the CPA PDU which is successfully transmitted or received last time;
the master device then:
the indication function of the CC attribute of the default slave equipment is closed, the working state data is cleared, a notice that the connection of the bottom layer is disconnected is sent to the PHD layer, and other data sent by the slave equipment is not processed before the next connection;
the slave device then:
and closing the indication function of the CC attribute, clearing the working state data, sending an event notice with the semantic of disconnecting the bottom layer connection to the PHD layer, and not processing other data sent by the main equipment except the connection request.
Due to the CPA layer data exchange process, the generated errors and the fault tolerance processing include:
in the CPA connection subprocess, before the CPA connection is unsuccessful, after the master device or the slave device receives the message related to the CC attribute, a proactive abnormal event intervention process is executed.
In the CPA operation sub-process, if the value of the ASN field in the CPA PDU received by the master device or the slave device is not the ASN value plus 1 in the CPA PDU successfully interacted (transmitted or received) last time, the active abnormal event intervention process is executed.
In the CPA data exchange process, after the slave equipment sends an indication through the ATT, the slave equipment determines that the connection of the ATT layer is abnormally disconnected when waiting for a first time interval and does not receive corresponding confirmation, and executes an active abnormal event intervention process; or after the main equipment sends the 'write request' through the ATT, when the main equipment waits for the first time interval and does not receive the corresponding 'write response', the main equipment determines that the connection of the ATT layer is abnormally disconnected, and executes an active abnormal event intervention process.
In the CPA operation sub-process, if the CPA layer receives the APDU from the PHD layer, after sending the internal instruction with the semantic of "establishing the ATT layer connection" to the disconnected ATT layer, and after waiting for the third time interval and not receiving the "established ATT layer connection" event notification sent by the ATT layer, the active abnormal event intervention process is executed.
In the CPA disconnection subprocess, if the slave device has waited for the fourth time interval and has not received the "write request" with the second predetermined value sent by the master device through the ATT, or the master device fails to send the "write request" with the second predetermined value through the ATT in the fourth time interval, the active abnormal event intervention process is executed.
The CPA data exchange process also includes four time intervals for assisting the CPA layer in managing its connection status:
the first time interval is the longest waiting time for the master device to receive a corresponding "write response" after sending a "write request"; or the maximum waiting time for the slave device to receive a corresponding "acknowledgement" after sending the "indication";
the second time interval is the longest waiting time for executing link reconnection after the CPA layer receives the link connection timeout error sent by the ATT layer;
the third time interval is the longest waiting time for the CPA layer to send an internal command of 'establishing bottom layer connection' to the ATT layer to start and wait for the self to complete reconnection when the CPA layer receives the APDU from the PHD layer after the ATT layer actively disconnects (generally, to reduce power consumption);
the fourth time interval is the longest waiting time of the indication function of closing the CC attribute by writing a second preset value into the IE attribute of the slave equipment by the master equipment after the CPA layer receives the internal instruction of 'disconnecting the bottom layer connection' sent by the PHD layer; or after the CPA layer receives the internal command of 'disconnecting the bottom layer connection' sent by the PHD layer, the slave device waits for the longest waiting time of receiving the 'write request' with the preset value two from the master device.
When the waiting time in one link exceeds the time interval, the working state of the CPA layer automatically changes.
The error generated due to the ATT layer is an ATT error. In the CPA connection sub-flow, when the master device sends a "write request" for the IE attribute to the slave device through the ATT, a protocol error thrown on the ATT layer sent by the slave device through the ATT may be received, and the semantics thereof include but are not limited to the following situations:
one is insufficient authentication. At this point, the master device may perform an authentication operation and resend the "write request";
second, insufficient encryption. At this point, the master device may perform the encryption operation and resend the "write request";
thirdly, the key length is not sufficient. At this time, the main device can change the key and execute the encryption operation again;
and fourthly, unexpected errors. At this time, the master device can try to resend the write request, wherein the write value in the write request is not changed;
and fifthly, the written value is invalid. The master may then attempt to write other predetermined values;
six are other errors in addition to the above. If six errors occur or one to five errors occur repeatedly, the subsequent error processing operation is determined by the application layer.
If the two communication parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error ST405 which is thrown on the ATT layer and is defined in the application layer error code range reserved by the ATT, and then the corresponding active CPA PDU error intervention ST406 includes:
if the semantic meaning is error of receiving CPA PDU, the original sender can try to resend the current CPA PDU after receiving the error, meanwhile, the original receiver discards the received current CPA PDU segment when the error occurs and prepares to receive the resent CPA PDU, if the error is received after resending, the application layer determines the subsequent error processing operation;
if the semantics is an error that the CPA PDU information part is too long, the device where the receiving party is located cannot receive the too long APDU, the error is sent to the original sending party, the original sending party can try to resend a new CPA PDU after receiving the error, meanwhile, the original receiving party discards the current CPA PDU segment received when the error occurs and prepares to receive the resent CPA PDU, and if the error is still received after resending, the application layer determines the subsequent error processing operation.
If a link loss is detected ST407, the performing corresponding inactive event exception handling ST408 includes:
if ST407 when detecting the link loss, the ATT layer will send the link connection timeout error to the CPA layer, when both communication parties receive the link connection timeout error at any time after finishing the transmission of the last CPA PDU, the working state data is saved, after waiting for the successful reconnection of the ATT layer link, both communication parties immediately enter the CPA operation sub-process and continue to execute the communication before the link disconnection from the current CPA PDU, which includes:
the working state data includes the ASN value in the last CPA PDU, and when the bottom layer link is disconnected:
if the sender encapsulates the APDU, the working state data also comprises the APDU sent by the PHD layer of the sender, and the APDU which is being encapsulated before the bottom-layer link is reconnected is encapsulated as the CPA PDU again after the bottom-layer link is reconnected;
if the sender is sending CPA PDU through ATT layer, the working state data also includes current CPA PDU, and resends CPA PDU after bottom link is reconnected;
if the receiving party is receiving the current CPA PDU, all the segments which are received and belong to the current CPA PDU are discarded.
The technical solutions of the present invention or similar technical solutions designed by those skilled in the art based on the teachings of the technical solutions of the present invention are all within the scope of the present invention to achieve the above technical effects.

Claims (10)

1. Before data exchange is carried out between master equipment and slave equipment, the two sides of the communication respectively establish a data communication protocol stack level structure which sequentially comprises a bottom layer transmission layer, an attribute protocol ATT layer, a universal attribute specification protocol adaptation CPA layer, a data exchange protocol PHD layer and an application layer from bottom to top;
the CPA layer includes an exception handling method, the exception handling method including:
if the two communication parties generate time interval overtime or CC attribute abnormity or ASN field value abnormity in the data exchange process, executing corresponding active abnormal event intervention;
if the two communication parties generate an ATT attribute operation method to execute an error in the CPA data exchange process, executing corresponding active ATT error intervention;
if the two communication parties send a CPA PDU to the receiving party in the CPA data exchange process, the original sending party may receive an ATT protocol error which is thrown on an ATT layer and is defined in the error code range of an application layer reserved by the ATT, and then corresponding active CPA PDU error intervention is executed;
and if the link loss is detected, executing corresponding non-active event exception handling.
2. The communication method according to claim 1, wherein if the two communicating parties generate time interval timeout or CC attribute exception or value exception of ASN field during data exchange, performing corresponding proactive exception event intervention comprises:
if any one of four time intervals included in the CPA layer for assisting the CPA layer in managing the connection state thereof is expired, or:
if the CPA connection sub-process is not successful, either party of the two communication parties receives the message related to the CC attribute, or;
if the CPA runs in the sub-process, the value of the ASN field in the CPA PDU received by either one of the two communication parties is not the value of the ASN in the CPA PDU successfully transmitted or received last time plus 1;
the master device then:
the indication function of the CC attribute of the default slave equipment is closed, the working state data is cleared, a notice that the connection of the bottom layer is disconnected is sent to the PHD layer, and other data sent by the slave equipment is not processed before the next connection;
the slave device then:
and closing the indication function of the CC attribute, clearing the working state data, sending an event notice with the semantic of disconnecting the bottom layer connection to the PHD layer, and not processing other data sent by the main equipment except the connection request.
3. The communication method according to claim 2, wherein the CPA layer comprises four time intervals for assisting the CPA layer in managing its connection status;
a first time interval: the longest waiting time for the master device to receive the corresponding ATT write response after sending the ATT write request or the longest waiting time for the slave device to receive the corresponding ATT confirmation after sending the ATT indication;
the second time interval is: the CPA layer receives the longest waiting time from the time-out error of the link connection sent by the ATT layer to the successful link reconnection;
the third time interval: after the ATT layer is planned to be disconnected, when the CPA layer receives APDU from the PHD layer, the CPA layer sends semantics to the ATT layer, wherein the semantics is the longest waiting time from the start of establishing a bottom layer connection internal instruction to the completion of reconnection of the ATT;
fourth time interval: and after receiving the semantic that the internal instruction of the bottom layer connection is disconnected, the CPA layer of the master equipment writes a second preset value into the IE attribute of the slave equipment to close the longest waiting time of the corresponding write response when the CC attribute indication function is closed.
4. The communication method according to claim 3, wherein if the waiting time of any one of the four time intervals exceeds the maximum waiting time, the operating state of the CPA layer is automatically changed.
5. The communication method according to claim 1, wherein if the both parties of communication generate ATT attribute operation method execution error during CPA data exchange, then executing corresponding active ATT error intervention comprises:
the ATT protocol errors include authentication insufficiency, encryption insufficiency, key length insufficiency, unexpected errors, and invalid written values or other related errors;
if the authentication of the two communication parties is insufficient, the main equipment can carry out authentication operation and resend the ATT write request;
if the encryption of both communication parties is insufficient, the main equipment can carry out encryption operation and resend the ATT write request;
if the key lengths of the two communication parties are not enough, the main equipment can change the key and re-execute the encryption operation;
if both communication parties are in unexpected error, the main equipment can try to resend the ATT write request with the original write value;
if the written values are invalid, the master device may attempt to write another predetermined value.
6. The communication method according to claim 5, wherein if one of the ATT protocol errors is repeated, the subsequent error handling operation is determined by the application layer.
7. The communication method according to claim 1, wherein if the sender sends a CPA PDU to the receiver during CPA data exchange, and the original sender may receive an ATT protocol error that is thrown on the ATT layer and is defined within an application layer error code range reserved in ATT, then performing corresponding proactive CPA PDU error intervention comprises:
if the semantic is error of receiving CPAP PDU, the original sender can try to resend the current CPAP PDU after receiving the error, meanwhile, the original receiver discards the received current CPA PDU segment when the error occurs and prepares to receive the resent CPA PDU, if the error is still received after resending, the application layer determines the subsequent error processing operation;
if the semantics is an error that the CPA PDU information part is too long, the device where the receiving party is located cannot receive the too long APDU, the error is sent to the original sending party, the original sending party can try to resend a new CPA PDU after receiving the error, meanwhile, the original receiving party discards the current CPA PDU segment which is received when the error occurs and prepares to receive the resent CPA PDU, and if the error is still received after resending, the application layer determines the subsequent error processing operation.
8. The communication method according to claim 1, wherein the performing of the corresponding non-proactive event exception handling if the link loss is detected comprises:
if the link loss is detected, the ATT layer sends a link connection timeout error to the CPA layer, when both communication sides receive the link connection timeout error at any time after the last CPA PDU transmission is completed, the working state data is saved, and after the ATT layer link reconnection is waited to be successful, both communication sides immediately enter a CPA operation sub-process and continue to execute the communication before the link disconnection from the current CPA PDU.
9. The communication method according to claim 8, wherein the performing the corresponding non-proactive exception handling if the link loss is detected further comprises:
the operating state data includes the ASN value in the last CPAP PDU, and when the underlying link is disconnected:
if the sender encapsulates the APDU, the working state data also comprises the APDU sent by the PHD layer of the sender, and the APDU which is being encapsulated before the bottom-layer link is reconnected is encapsulated as CPAP PDU again after the bottom-layer link is reconnected;
if the sender is sending CPA PDU through ATT layer, the working state data also includes current CPA PDU, and resends CPA PDU after bottom link is reconnected;
if the receiving party is receiving the current CPA PDU, all the segments which are received and belong to the current CPA PDU are discarded.
10. The communication system is characterized in that before the communication system exchanges data based on the master device and the slave device, two communication parties respectively establish a data communication protocol stack level structure which sequentially comprises a bottom layer transmission layer, an attribute protocol ATT layer, a universal attribute specification protocol adaptation CPA layer, a data exchange protocol PHD layer and an application layer from bottom to top;
the CPA layer includes an exception handling module to:
a communication method adapted by ATT and exception handling according to any of claims 1 to 9 is implemented.
CN201910783902.XA 2019-08-23 2019-08-23 Communication method and system adapted by ATT and exception handling Active CN110493775B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910783902.XA CN110493775B (en) 2019-08-23 2019-08-23 Communication method and system adapted by ATT and exception handling

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910783902.XA CN110493775B (en) 2019-08-23 2019-08-23 Communication method and system adapted by ATT and exception handling

Publications (2)

Publication Number Publication Date
CN110493775A CN110493775A (en) 2019-11-22
CN110493775B true CN110493775B (en) 2021-10-12

Family

ID=68553226

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910783902.XA Active CN110493775B (en) 2019-08-23 2019-08-23 Communication method and system adapted by ATT and exception handling

Country Status (1)

Country Link
CN (1) CN110493775B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111416889B (en) * 2020-01-16 2022-03-04 重庆大学 Communication method and system adapted through GATT and exception handling
CN111328056B (en) * 2020-01-20 2023-03-24 钟代笛 Communication method and system for carrying out protocol adaptation based on ATT (advanced technology transfer) and read-write command
CN111314448B (en) * 2020-02-05 2022-02-08 重庆大学 Data communication system and method adapted based on CPA field protection
CN111417116B (en) * 2020-03-10 2023-09-19 国家体育总局体育科学研究所 Communication method and system adapted through ATT, read-write and exception handling

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102739788A (en) * 2012-06-25 2012-10-17 广州复旦奥特科技股份有限公司 Field equipment communication method based on European installation bus (EIB) protocol
CN109474969A (en) * 2018-12-19 2019-03-15 苏芯物联技术(南京)有限公司 Mixed communication method and system based on IEEE 802.15.4 and low-power consumption bluetooth dual stack

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6523104B2 (en) * 2001-07-13 2003-02-18 Mips Technologies, Inc. Mechanism for programmable modification of memory mapping granularity

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102739788A (en) * 2012-06-25 2012-10-17 广州复旦奥特科技股份有限公司 Field equipment communication method based on European installation bus (EIB) protocol
CN109474969A (en) * 2018-12-19 2019-03-15 苏芯物联技术(南京)有限公司 Mixed communication method and system based on IEEE 802.15.4 and low-power consumption bluetooth dual stack

Also Published As

Publication number Publication date
CN110493775A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
CN110493775B (en) Communication method and system adapted by ATT and exception handling
CN103036904B (en) A kind of udp protocol that uses in a communication network carries out the method for reliable data transmission
US7693952B2 (en) Availability and scalability in a messaging system in a manner transparent to the application
KR100692354B1 (en) Method and apparatus for discarding packets in a data network having automatic repeat request
US20040205781A1 (en) Message delivery with configurable assurances and features between two endpoints
US9055099B2 (en) Method of preventing TCP-based denial-of-service attacks on mobile devices
CN102025474A (en) Network data transmission method
US20110038369A1 (en) Communication method and apparatus based on user datagram protocol
JP3001435B2 (en) Data retransmission method in confirmation type information transfer
US7178051B2 (en) Method for synchronous support of fault-tolerant and adaptive communication
CN101605128A (en) The method that the LINUX master-slave equipment communicates by Ethernet interface
US20040193941A1 (en) Method for asynchronous support of fault-tolerant and adaptive communication
CN112395237A (en) Method and system for communication between at least two controllers
JPH10308791A (en) Method and equipment for data communication and data communication program recording medium
JP3608905B2 (en) Data communication system and data communication method
CN111416889B (en) Communication method and system adapted through GATT and exception handling
CN111417116B (en) Communication method and system adapted through ATT, read-write and exception handling
US8549345B1 (en) Methods and apparatus for recovering from a failed network interface card
CN102045883B (en) Method for poll processing after radio link control reconfiguration in radio communication system
CN113259404A (en) Industrial communication middleware based on TCP/IP protocol and use method thereof
JPH10336242A (en) Data communication system
EP2405627B1 (en) Method for operating a remote procedure call handler in a client and a server and computer system comprising the same
JP2576076B2 (en) Message rescue method for data communication system
CN117082125A (en) Data exchange method based on TCP/IP protocol and peer communication program
JPH10336274A (en) Data communication system and data communication method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant