Disclosure of Invention
The invention aims to provide an infrared-based data transmission protocol, which is used for carrying out data transmission in an uplink and downlink transmission mode, realizing configuration and control, ensuring the configuration rate and being beneficial to reducing the load.
In order to achieve the purpose, the invention adopts the following technical scheme:
an infrared-based data transfer protocol comprising a configuration protocol and a control protocol;
the configuration protocol can transmit data in an uplink and downlink transmission mode;
the control protocol can control the sub-devices in a one-to-one or one-to-many manner;
the configuration protocol includes:
the method comprises the steps that a main device sends addressing broadcast to adjacent sub-devices, the sub-devices are multiple, data transmission is carried out among the sub-devices in an uplink and downlink transmission mode, and the addressing broadcast is transmitted from the uplink sub-devices to the downlink sub-devices among the sub-devices in sequence;
the slave device in an unconfigured state receives the addressing broadcast and writes the unique identification code of the slave device into an addressing return message, and the addressing return message is transmitted in an uplink transmission mode and finally transmitted back to the master device;
after receiving the addressing return message, the main device sends an address configuration message to the adjacent sub-devices, and the address configuration message is transmitted between the sub-devices in a downlink transmission mode until the address configuration message is transmitted to the sub-devices in the non-configuration state, wherein the address configuration message comprises an address and a unique identification code of the sub-devices in the non-configuration state;
the slave device in the unconfigured state stores the address and the unique identification code in the address configuration message, switches the address and the unique identification code into the configured state, and then transmits configuration completion information in an uplink transmission mode;
the main device receives the configuration completion information and completes one configuration;
the main device repeats the above operation, and sends the addressing broadcast for many times, and completes the configuration if the configuration completion information is not received.
Therefore, the main equipment sends the addressing broadcast once by once, the addressing broadcast is transmitted between the sub-equipment in a downlink mode, the unconfigured sub-equipment is searched and configured one by one, the configuration rate is guaranteed, and the main equipment sends the addressing broadcast one by one, so that the instant load is favorably reduced.
In some embodiments, after receiving the addressing broadcast, the child device checks whether it is in a configured state;
if yes, the addressing broadcast is sent to the adjacent downlink sub-equipment;
and if not, sending an addressing return message to the adjacent uplink sub-equipment.
In some embodiments, after receiving the addressing return message, the master device checks whether the child device in the non-configuration state is already in the device chain table;
if so, filling the address configuration message into the corresponding address in the equipment chain table and the unique identification code of the sub-equipment in the unconfigured state, and then sending the address configuration message to the adjacent sub-equipment, wherein the address configuration message is transmitted between the sub-equipment in a downlink transmission mode until the address configuration message is transmitted to the sub-equipment in the unconfigured state;
if not, a new address is allocated, the new address and the unique identification code of the sub-equipment in the unconfigured state are filled in an address configuration message, then the address configuration message is sent to the adjacent sub-equipment, and the address configuration message is transmitted between the sub-equipment in a downlink transmission mode until the address configuration message is transmitted to the sub-equipment in the unconfigured state.
In some embodiments, after receiving the address configuration message, the child device checks whether the child device is in a configured state;
if yes, sending the address configuration message to the adjacent downlink sub-equipment;
if not, comparing whether the unique identification code in the address configuration message is the same as the unique identification code of the address configuration message;
if so, extracting and storing the address from the address configuration message, switching to a configured state, sending configuration completion information to adjacent uplink sub-equipment, and transmitting the configuration completion information between the sub-equipment in an uplink transmission mode until the configuration completion information is transmitted to the main equipment;
and if not, sending the address configuration message to the adjacent downlink sub-equipment.
In some embodiments, the one-to-one control protocol comprises:
the method comprises the steps that a main device sends a control command to an adjacent sub device, wherein the control command comprises an address, a unique identification code and a control message of the sub device, and the control message comprises a control command type;
the sub-devices transmit the control command in a downlink transmission mode;
the sub-equipment receives the control command, analyzes the control message and executes response operation, sends a reply message to the adjacent uplink sub-equipment, and transmits the reply message between the sub-equipment in an uplink transmission mode until the reply message is transmitted to the main equipment;
the main device receives the reply message and completes one-time control.
In some embodiments, after receiving the control command, the child device checks whether the address of the control packet is the same as that of the child device itself;
if yes, analyzing the control message and executing response operation;
and if not, sending the control command to the adjacent downlink sub-equipment.
In some embodiments, the one-to-many control protocol comprises:
the method comprises the steps that a main device sends a control command to adjacent sub-devices, the control command comprises address fields and control messages of the sub-devices, and the control messages comprise control command types;
the sub-devices transmit the control command in a downlink transmission mode;
the sub-devices receive the control command in sequence, analyze the control message, execute response operation and mark corresponding positions of the address fields;
when all the positions of the address field are marked, the sub-equipment which receives the control command finally sends a reply message, and the reply message is transmitted between the sub-equipment in an uplink transmission mode until the reply message is transmitted to the main equipment;
the main device receives the reply message and completes one-time control.
In some embodiments, after receiving the control command, the child device checks whether the address in the address field of the control packet is the same as itself;
if not, sending the control command to the adjacent downlink sub-equipment;
if yes, analyzing the control message, executing response operation, marking the corresponding position of the address field, and then checking whether all the positions of the address field are marked;
if yes, sending a reply message;
and if not, sending the control command to the adjacent downlink sub-equipment.
The invention has the beneficial effects that: the main device and the sub-devices transmit data in an uplink and downlink transmission mode, configuration and control are achieved, configuration rate is guaranteed, and load reduction is facilitated.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
Referring to fig. 1-4, an infrared-based data transmission protocol includes a configuration protocol and a control protocol, both of which are data transmission via an infrared network;
the configuration protocol can transmit data in an uplink and downlink transmission mode;
the control protocol can control the sub-devices in a one-to-one or one-to-many manner;
the sub-equipment can be a miniature circuit breaker, the miniature circuit breaker is provided with a communication unit, the plurality of sub-equipment are sequentially connected one by one, and the data transmission mode among the plurality of sub-equipment is also sequentially transmitted one by one, so that an uplink and downlink transmission mode is formed for data transmission.
Wherein, the downlink transmission mode is as follows: after receiving the data, the uplink sub-device (e.g., the first row) transmits the data to the adjacent downlink sub-device (e.g., the second row), and then transmits the data to the adjacent downlink sub-device (e.g., the third row), so that the data are transmitted one by one in the downlink, that is, the first row is transmitted to the second row, the second row is transmitted to the third row, and the data are sequentially transmitted to the nth row.
An uplink transmission mode: a row of sub-devices transmits data to an adjacent uplink sub-device, and then transmits data to the adjacent uplink sub-device, for example, the third row transmits data to the second row, the second row transmits data to the first row, and the first row transmits data to the master device, so that the data are transmitted to the uplink one by one.
It should be understood that the uplink and downlink transmission modes herein are only illustrative of the connection relationship between the sub-devices and do not represent the location relationship between the sub-devices, and the uplink and downlink transmission modes also only represent the transmission directions of the data.
The configuration protocol includes:
the method comprises the steps that a main device sends addressing broadcast to adjacent sub-devices (such as a first row of sub-devices), and the addressing broadcast is transmitted from an uplink sub-device to a downlink sub-device in sequence among the plurality of sub-devices;
the slave device in an unconfigured state receives the addressing broadcast and writes the unique identification code of the slave device into an addressing return message, and the addressing return message is transmitted in an uplink transmission mode and finally transmitted back to the master device;
after receiving the addressing return message, the main device sends an address configuration message to the adjacent sub-devices, and the address configuration message is transmitted between the sub-devices in a downlink transmission mode until the address configuration message is transmitted to the sub-devices in the non-configuration state, wherein the address configuration message comprises an address and a unique identification code of the sub-devices in the non-configuration state;
the slave device in the unconfigured state stores the address and the unique identification code in the address configuration message, switches the address and the unique identification code into the configured state, and then transmits configuration completion information in an uplink transmission mode;
the main device receives the configuration completion information and completes one configuration;
the main device repeats the above operation, and sends the addressing broadcast for many times, and completes the configuration if the configuration completion information is not received.
The main device sends addressing broadcast once by once, the addressing broadcast is transmitted between the sub-devices in a downlink mode, the unconfigured sub-devices are searched and configured one by one, configuration rate is guaranteed, and the main device sends the addressing broadcast one by one, and instant load is reduced.
Further, after receiving the addressing broadcast, the child device checks whether the child device is in a configured state;
if yes, the addressing broadcast is sent to the adjacent downlink sub-equipment, and the sub-equipment in the unconfigured state is continuously searched;
if not, sending an addressing return message to the adjacent uplink sub-equipment, namely sending the addressing return message to the main equipment.
Further explaining, after the main device receives the addressing return message, the main device checks whether the sub-device in the unconfigured state is in the device chain table;
if so, filling the address configuration message into the corresponding address in the equipment chain table and the unique identification code of the sub-equipment in the unconfigured state, and then sending the address configuration message to the adjacent sub-equipment, wherein the address configuration message is transmitted between the sub-equipment in a downlink transmission mode until the address configuration message is transmitted to the sub-equipment in the unconfigured state;
if not, a new address is allocated, the new address and the unique identification code of the sub-equipment in the unconfigured state are filled in an address configuration message, then the address configuration message is sent to the adjacent sub-equipment, and the address configuration message is transmitted between the sub-equipment in a downlink transmission mode until the address configuration message is transmitted to the sub-equipment in the unconfigured state. And a new address is automatically allocated, and the intelligent and quick configuration of the sub-equipment is realized.
Further explaining, after receiving the address configuration message, the child device checks whether the child device is in a configured state;
if yes, sending the address configuration message to the adjacent downlink sub-equipment, and searching the sub-equipment in an unconfigured state;
if not, comparing whether the unique identification code in the address configuration message is the same as the unique identification code of the address configuration message;
if so, extracting and storing the address from the address configuration message, switching to a configured state, sending configuration completion information to adjacent uplink sub-equipment, and transmitting the configuration completion information between the sub-equipment in an uplink transmission mode until the configuration completion information is transmitted to the main equipment;
if not, the address configuration message is sent to the adjacent downlink sub-equipment, and the corresponding sub-equipment in the unconfigured state is searched.
The one-to-one control protocol includes:
the method comprises the steps that a main device sends a control command to an adjacent sub device, wherein the control command comprises an address, a unique identification code and a control message of the sub device, and the control message comprises a control command type, such as a corresponding control value;
the sub-devices transmit the control command in a downlink transmission mode;
the sub-equipment receives the control command, analyzes the control message and executes response operation (such as switching, inquiring, setting a threshold value and the like), sends a reply message to the adjacent uplink sub-equipment, and transmits the reply message between the sub-equipment in an uplink transmission mode until the reply message is transmitted to the main equipment;
the main device receives the reply message and completes one-time control.
Further, after receiving the control command, the child device checks whether the address of the control message is the same as the address of the child device itself;
if yes, analyzing the control message and executing response operation;
and if not, sending the control command to the adjacent downlink sub-equipment.
The one-to-many control protocol includes:
the method comprises the steps that a main device sends a control command to adjacent sub-devices, wherein the control command comprises address fields and control messages of the sub-devices, and the control messages comprise control command types, such as corresponding control values;
the sub-devices transmit the control command in a downlink transmission mode;
the sub-devices receive the control command in sequence, analyze the control message, execute response operations (such as switching, inquiring, setting threshold values and the like), and mark corresponding positions of the address fields;
when all the positions of the address field are marked, the sub-equipment which receives the control command finally sends a reply message, and the reply message is transmitted between the sub-equipment in an uplink transmission mode until the reply message is transmitted to the main equipment;
the main device receives the reply message and completes one-time control.
Further, after receiving the control command, the child device checks whether the address in the address field of the control message is the same as itself;
if not, sending the control command to the adjacent downlink sub-equipment;
if yes, analyzing the control message, executing response operation, marking the corresponding position of the address field, and then checking whether all the positions of the address field are marked;
if yes, sending a reply message;
and if not, sending the control command to the adjacent downlink sub-equipment.
The foregoing disclosure discloses only some embodiments of the invention. It will be apparent to those skilled in the art that various changes and modifications can be made without departing from the inventive concept herein, and it is intended to cover all such modifications and variations as fall within the scope of the invention.