WO2023151553A1 - 一种数据交互方法及系统 - Google Patents

一种数据交互方法及系统 Download PDF

Info

Publication number
WO2023151553A1
WO2023151553A1 PCT/CN2023/074757 CN2023074757W WO2023151553A1 WO 2023151553 A1 WO2023151553 A1 WO 2023151553A1 CN 2023074757 W CN2023074757 W CN 2023074757W WO 2023151553 A1 WO2023151553 A1 WO 2023151553A1
Authority
WO
WIPO (PCT)
Prior art keywords
battery pack
electric tool
communication
data
handshake
Prior art date
Application number
PCT/CN2023/074757
Other languages
English (en)
French (fr)
Inventor
崔阳
朱彦亮
庄宪
Original Assignee
格力博(江苏)股份有限公司
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
Priority claimed from CN202210123150.6A external-priority patent/CN116611079A/zh
Priority claimed from CN202210214304.2A external-priority patent/CN116743356A/zh
Priority claimed from CN202210695560.8A external-priority patent/CN117294547A/zh
Application filed by 格力博(江苏)股份有限公司 filed Critical 格力博(江苏)股份有限公司
Publication of WO2023151553A1 publication Critical patent/WO2023151553A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data

Definitions

  • the present application relates to the field of communication technologies, and in particular to a data interaction method and system.
  • the original battery pack and electric tools use a single-bus high-low level communication method, and there is still a problem that it is easy for people to intercept the communication content and perform brute force cracking, so as to easily imitate the company's battery pack products.
  • the purpose of this application is to provide a data interaction method and system for solving the problem of multiple different communication methods coexisting between existing battery packs or/and electric tools, and the battery
  • the battery pack and the electric tool share the same physical communication channel, because the battery pack and the electric tool use different communication methods when communicating and connecting, technical problems such as communication failure and tool shutdown occur.
  • the present application provides a data interaction method and system, which is applied to the data interaction between the battery pack and the electric tool, and the battery pack and the electric tool share the same physical communication channel for communication.
  • One of the battery pack and the electric tool has at least one communication method, and the other has at least two communication methods;
  • the data interaction method includes:
  • the battery pack performs handshake communication with the electric tool
  • the battery pack performs data transmission with the electric tool.
  • the battery pack includes one communication method, and the electric tool includes two communication methods;
  • the handshake communication between the battery pack and the electric tool includes:
  • the battery pack sends a handshake message to the electric tool
  • the electric tool When the electric tool receives the handshake message within the first preset time, it will reply an appointment message to the battery pack; when the battery pack receives the appointment message returned by the battery tool , it means that the handshake communication between the battery pack and the electric tool is successful;
  • the electric tool When the electric tool does not receive the handshake message within the first preset time, it means that the handshake communication between the battery pack and the electric tool fails; when the battery pack and the electric tool handshake communication When it fails, the electric tool switches its current communication mode to another communication mode; re-execute the handshake communication between the battery pack and the electric tool until the handshake communication between the battery pack and the electric tool succeeds.
  • the battery pack includes at least two communication methods, and the electric tool includes at least one communication method;
  • the handshake communication between the battery pack and the electric tool includes:
  • the battery pack sends a handshake message to the electric tool and records the number of times the handshake message is sent;
  • the battery pack When the battery pack receives the agreed message replied by the electric tool within the preset number of times that the handshake message is sent, it means that the battery pack and the electric tool handshake communication successfully;
  • the battery pack switches its current communication mode to another communication mode; re-execute the handshake communication between the battery pack and the electric tool until the battery The packet communicates successfully with the power tool handshake.
  • the battery pack and the electric tool respectively have at least two communication modes
  • the handshake communication between the battery pack and the electric tool includes:
  • the battery pack sends a handshake message to the electric tool, and the electric tool returns an agreement message to the battery pack after receiving the handshake message;
  • the battery pack When the battery pack receives the agreed message within the second preset time, it means that the battery pack and the electric tool have successfully handshake communication; If the handshake message is received, it means that the handshake communication between the battery pack and the electric tool fails;
  • the battery pack or the battery tool When the handshake communication between the battery pack and the electric tool fails, the battery pack or the battery tool will switch its current communication mode to another communication mode; re-execute the communication between the battery pack and the electric tool Carry out handshake communication until the battery pack and the electric tool handshake communication is successful.
  • the battery pack and the electric tool respectively have at least two communication modes
  • the handshake communication between the battery pack and the electric tool includes:
  • the battery pack sends a handshake message to the electric tool, and the electric tool returns an agreement message to the battery pack after receiving the handshake message;
  • the battery pack When the battery pack receives the appointment message replied by the electric tool twice in a row, and the time between receiving the appointment message twice is less than the preset interval, it means that the battery pack and the electric tool handshake communication If successful, otherwise, it means that the handshake communication between the battery pack and the electric tool has failed;
  • the battery pack or the battery tool When the handshake communication between the battery pack and the electric tool fails, the battery pack or the battery tool will switch its current communication mode to another communication mode; re-execute the communication between the battery pack and the electric tool Carry out handshake communication until the battery pack and the electric tool handshake communication is successful.
  • the data transmission between the battery pack and the electric tool includes:
  • the battery pack and the electric tool perform data transmission in the communication mode when the handshake communication is successful;
  • the battery pack and the electric tool switch the communication mode when the handshake communication is successful to another communication mode for data transmission.
  • the battery pack and the electric tool have at least a single bus communication mode and a serial bus communication mode;
  • the data transmission between the battery pack and the electric tool includes:
  • the battery pack and the electric tool When the battery pack and the electric tool successfully handshake and communicate through the serial bus communication mode, the battery pack and the electric tool perform data transmission through the serial bus communication mode;
  • the battery pack and the electric tool When the handshake communication between the battery pack and the electric tool is successful through the single bus communication mode, the battery pack and the electric tool first switch the communication mode from the single bus communication mode to the serial bus communication mode, Then data transfer is performed.
  • the data interaction method further includes: after the data transmission between the battery pack and the electric tool is completed, setting the communication mode of the battery pack and the electric tool to their respective default way of communication.
  • the battery pack detects the connected electric tool, generates a first random number, encrypts the battery pack data and the first random number into first handshake information according to a preset key, and outputs the first handshake information to the electric tools;
  • the battery pack receives the second handshake information fed back by the electric tool, decrypts the second handshake information according to the preset key, and obtains the electric tool data and the second random number;
  • the data transmission between the battery pack and the electric tool includes:
  • the battery pack encrypts the first raw data and the first random number into first data according to a preset first rule, and outputs the first data to the electric tool;
  • the battery pack receives the second data fed back by the electric tool, parses the second data into second original data according to a preset second rule, and performs discharge according to the second original data and the electric tool data .
  • the battery pack encrypts first data after combining the first original data and the first random number according to a preset first rule, including:
  • the battery pack adds the first random number to the first raw data according to a preset order
  • the battery pack encrypts the first original data added with the first random number through a preset encryption algorithm to obtain the first data.
  • the step of adding the first random number to the first raw data according to a preset order of the battery pack includes:
  • the battery pack divides the first random number into individual bytes, and inserts each byte into the first original data in a preset order.
  • the battery pack receives the second data fed back by the electric tool, and parses the second data into second raw data according to a preset second rule, including:
  • the battery pack receives the second data fed back by the electric tool, and decrypts the second data into the second original data added with the second random number through a preset decryption algorithm;
  • the battery pack separates the second random number from the second original data according to a preset sequence to obtain the second original data.
  • the data interaction method further includes:
  • the battery pack saves the second random number in a preset first verification table in chronological order
  • the second random number received this time is used to replace the earliest second random number in the first verification form.
  • the data interaction method further includes:
  • the battery pack compares the second random number with the data in the first verification table, and if there is the same data, it is considered that the connected electric tool is illegally connected, and the battery pack disconnection and The communication link of the power tool.
  • the data interaction method further includes:
  • the battery pack compares the generated first random number with the data in the preset second verification form, and if the same data exists, regenerates the first random number
  • the first random number generated this time in the second verification table in chronological order, and when the number of data in the second verification table is greater than the preset second number, use the random number generated this time
  • the first random number replaces the earliest first random number in the second verification table.
  • the step before the step of data transmission between the battery pack and the electric tool, the step further includes:
  • the electric tool reads the first array in the memory of the battery pack
  • the electric tool verifies the first array, and if the verification is successful, it performs data transmission with the battery pack, otherwise, stops the communication connection with the battery pack;
  • the step of verifying the first array by the electric tool includes:
  • the electric tool judges whether there is a preset check character in the first array
  • the electric tool intercepts the first key and the first ciphertext in the first array, and according to the first ciphertext The key generates the second ciphertext, matches the second ciphertext and the first ciphertext, and if the matching is successful, it is considered that the verification is successful.
  • before the data transmission between the battery pack and the electric tool further includes:
  • the battery pack pre-stores a first array for verification
  • the battery pack receives the verification request sent by the electric tool, and sends the first array to the electric tool, and the verification request is sent when the battery pack detects that the electric tool is connected. triggered to send;
  • the battery pack receives indication information from the electric tool, wherein the indication information is used to indicate to the battery pack whether the verification is successful, and if successful, perform data interaction with the electric tool.
  • this application provides another data interaction method, which is applied to the data interaction between the battery pack and the electric tool.
  • the battery pack and the electric tool share the same physical communication channel for communication, so The battery pack and the electric tool have at least two communication methods;
  • the data interaction method includes:
  • the battery pack and the electric tool perform handshake communication through a communication method
  • the battery pack and the electric tool respectively switch the communication mode from the communication mode when the handshake communication is successful to another communication mode.
  • the other communication mode has a large data transmission capability and a high transmission rate.
  • this application provides a data interaction system, including:
  • the battery pack shares the same physical communication channel with the electric tool for communication;
  • One of the battery pack and the electric tool has at least one communication mode, and the other has at least two communication modes, and the communication units corresponding to the communication modes in the battery pack and the electric tool are connected to the respective micro control unit connection;
  • the electric tool and the battery pack are configured to perform data interaction in the following manner:
  • the battery pack performs handshake communication with the electric tool
  • the battery pack performs data transmission with the electric tool.
  • a data interaction method and system of the present application is applied to data interaction between a battery pack and an electric tool.
  • the battery pack and the electric tool share the same physical communication channel for communication, and one of the battery pack and the electric tool has at least one communication
  • the other has at least two communication methods; when performing data interaction, the battery pack and the electric tool perform the initial handshake communication; when the initial handshake communication between the battery pack and the electric tool fails, the battery pack and the electric tool have two communication methods One switches the current communication method to another communication method; the battery pack and the electric tool perform a second handshake communication; when the battery pack and the electric tool complete the second handshake communication, the battery pack and the electric tool perform data transmission.
  • the application can realize the smooth switching between the battery pack and the electric tool in a variety of different communication modes under the same physical communication channel, so as to be compatible with the iteration between new and old products, and ensure the normal communication between the battery pack and the electric tool; at the same time
  • the anti-counterfeiting operation in the handshake stage between the battery pack and the electric tool increases the difficulty of imitation and improves product competitiveness.
  • the data interaction method of this application performs two-layer encryption on the data in the handshake phase and the communication phase respectively, which ensures the security of the interactive data. Even if the interactive data is captured by a third party, the real and valid data cannot be obtained, avoiding imitation possibility, which greatly guarantees the safety of users.
  • the data interaction method of this application generates verification information and stores it in the memory of the battery pack. Before the electric tool communicates with the battery pack, it first reads the verification information from the memory to verify it. The battery pack performs data interaction, otherwise the communication with the battery pack is stopped, which reduces the analysis of the intercepted communication content and prevents the battery pack product from being easily imitated.
  • the present application realizes the anti-counterfeiting function by means of the memory, without changing the existing circuit structure, and reduces the cost.
  • FIG. 1 shows a schematic flowchart of the data interaction method of the present application.
  • Fig. 2 shows a conceptual diagram of a data interaction system according to an embodiment of the present application.
  • Fig. 3 shows a flow chart of battery pack processing in a data interaction method according to an embodiment of the present application.
  • Fig. 4 shows a flow chart of electric tool processing in a data interaction method according to an embodiment of the present application.
  • Fig. 5 shows a conceptual diagram of a data interaction system according to another embodiment of the present application.
  • FIG. 6 shows a flow chart of battery pack processing in a data interaction method according to another embodiment of the present application.
  • Fig. 7 shows a flow chart of electric tool processing in a data interaction method according to another embodiment of the present application.
  • Fig. 8 shows a conceptual diagram of a data interaction system according to another embodiment of the present application.
  • FIG. 9 shows a flow chart of battery pack processing in a data interaction method according to another embodiment of the present application.
  • Fig. 10 shows a flow chart of electric tool processing in a data interaction method according to another embodiment of the present application.
  • Fig. 11 shows a flow chart of battery pack processing in the data interaction method of the fourth embodiment of the present application.
  • Fig. 12 shows a flow chart of electric tool processing in the data interaction method of the fourth embodiment of the present application.
  • FIG. 13 is a schematic flowchart of a data interaction method in a fifth embodiment of the present application.
  • FIG. 14 is a schematic flowchart of generating first data in the fifth embodiment of the present application.
  • FIG. 15 is a schematic flowchart of parsing the second data in the fifth embodiment of the present application.
  • FIG. 16 is a schematic flowchart of another data interaction method in the fifth embodiment of the present application.
  • FIG. 17 is a schematic flowchart of a data interaction method in the sixth embodiment of the present application.
  • Fig. 18 is a schematic flowchart of generating second data in the sixth embodiment of the present application.
  • FIG. 19 is a schematic flowchart of parsing the first data in the sixth embodiment of the present application.
  • FIG. 20 is a schematic flowchart of another data interaction method in the sixth embodiment of the present application.
  • Fig. 21 is a structural block diagram of the data interaction system in the seventh embodiment of the present application.
  • Fig. 22 is a structural block diagram of the communication anti-counterfeiting system in the eighth embodiment of the present application.
  • FIG. 23 is a schematic flowchart of a communication anti-counterfeiting method in the ninth embodiment of the present application.
  • FIG. 24 is a schematic flowchart of verifying the first array in the ninth embodiment of the present application.
  • FIG. 25 is another schematic flowchart of the communication anti-counterfeiting method in the ninth embodiment of the present application.
  • FIG. 26 is a schematic flowchart of a communication anti-counterfeiting method in the tenth embodiment of the present application.
  • FIG. 27 is a schematic flowchart of generating the first array in the tenth embodiment of the present application.
  • FIG. 28 is another schematic flowchart of generating the first array in the tenth embodiment of the present application.
  • the existing SmartG battery pack 200 or power tool uses the serial port communication method.
  • the battery pack 200 or power tool used the custom COM communication method.
  • the old power tool can use the SmartG battery pack 200 or the old battery pack 200 can To adapt to the tool using SmartG, it is necessary to customize the way of smooth switching between COM communication and serial port communication.
  • the present application introduces a data interaction method between the battery pack 200 and the electric tool 100 .
  • the battery pack 200 is composed of a communication unit for realizing a specific communication mode, a battery pack micro-control unit (that is, a battery pack MCU) and peripheral circuits
  • the electric tool 100 is composed of a specific communication
  • the battery pack 200 and the electric tool 100 are connected to each other through the positive pole of the power supply, the negative pole of the power supply, and the communication line.
  • the battery pack 200 of the electric tool 100 and the electric tool 100 share the same physical communication channel for communication, one of the battery pack 200 and the electric tool 100 has at least one communication mode, and the other has at least two communication modes.
  • One communication mode, the communication mode in the battery pack 200 and the electric tool 100 is connected with their respective micro control units.
  • FIG. 1 is a schematic flowchart of a data interaction method according to an embodiment of the present application.
  • the data interaction method of the embodiment of the present application is applied to the data interaction between the battery pack 200 and the electric tool 100, and includes the following steps:
  • S10 power-on initialization, including power-on initialization of the battery pack 200 and power-on initialization of the electric tool 100 .
  • the battery pack 200 is powered on and initialized: after the battery pack 200 is powered on and the electric tool 100 is detected, the communication mode of the battery pack 200 is initialized, and the communication mode of the battery pack 200 is initialized to default communication Way.
  • the communication mode of the battery pack 200 is initialized to this communication mode.
  • the communication mode of the battery pack 200 can be initialized to one of them (configurable), for example, when the battery pack 200 has a single In case of bus communication mode and serial bus communication mode, the communication mode of the battery pack 200 can be initialized to single bus communication mode or serial bus communication mode, such as single bus communication mode.
  • Power-on initialization of the electric tool 100 power on the electric tool 100, and perform the power-on initialization of the electric tool 100
  • the communication mode of the electric tool 100 is initialized, and the communication mode of the electric tool 100 is initialized as the default communication mode.
  • the communication mode of the electric tool 100 is initialized to this communication mode.
  • the communication method of the electric tool 100 can be initialized to one of them (configurable), for example, when the electric tool 100 has a single
  • the communication mode of the electric tool 100 can be initialized to single bus communication mode or serial bus communication mode, such as single bus communication mode.
  • the battery pack 200 performs handshake communication with the electric tool 100, and determines whether the handshake communication between the battery pack 200 and the electric tool 100 is successful.
  • step S50 Before the normal data transmission between the battery pack 200 and the electric tool 100, the battery pack 200 and the electric tool 100 perform handshake communication, only when the battery pack 200 and the electric tool 100 handshake communication succeed Only then can jump to step S50 to execute the data transmission between the battery pack 200 and the electric tool 100, otherwise, execute step S40.
  • the handshake communication process between the battery pack 200 and the electric tool 100 is different according to the number of communication modes between the battery pack 200 and the electric tool 100 , please refer to the description of the relevant part below for details. .
  • One of the two communication modes between the battery pack 200 and the electric tool 100 switches its current communication mode to another communication mode, and returns to step S20 to re-execute the communication between the battery pack 200 and the electric tool 100.
  • the tool 100 performs handshake communication until the battery pack 200 and the electric tool 100 succeed in handshake communication.
  • S50 The battery pack 200 and the electric tool 100 perform data transmission, that is, perform normal communication message transmission and interaction.
  • the data interaction method further includes, when the battery pack 200 and the electric tool 100 After the data transmission is completed, the communication mode between the battery pack 200 and the electric tool 100 is set as the default communication mode between the battery pack 200 and the electric tool 100 .
  • the battery pack 200 and the electric tool 100 do not switch the default communication mode during the data interaction process (including the handshake communication and data transmission phase), then it is sufficient to keep the current communication mode in this step.
  • the default communication mode is changed between the battery pack 200 and the electric tool 100 during the data interaction process (including the handshake communication and data transmission phase), it is necessary to switch the communication mode to connect the battery pack 200 with the electric tool 100
  • the current communication mode is switched to the default of the battery pack 200 and the electric tool 100 way of communication.
  • the default communication mode is a communication mode that is considered to be initialized after the battery pack 200 or the electric tool 100 is powered on.
  • Using the data interaction method of the embodiment can realize the smooth switching between the battery pack and the electric tool in a variety of different communication modes under the same physical communication channel, so as to be compatible with the iteration between new and old products, and ensure the communication between the battery pack and the electric tool Normal communication.
  • the handshake phase of the battery pack and the electric tool is also used as an anti-counterfeiting operation, which increases the difficulty of imitation and improves product competitiveness.
  • FIGS. 2-4 respectively show the conceptual diagram of the data interaction system of the first embodiment, the flow chart of the battery pack 200 in the data interaction method, and the flow chart of the electric tool 100 in the data interaction method.
  • Figures 2-4 show the communication methods in the process of data interaction between the battery pack 200 and the electric tool 100 including at least one communication method including two communication methods (of course also applicable to three or more situations). Smooth switching.
  • the handshake communication between the battery pack 200 and the electric tool 100 includes: the battery pack 200 sends a handshake message to the electric tool 100 and records the number of times the handshake message is sent; After the handshake message, if the agreed message replied by the electric tool 100 is still not received, it means that the handshake communication between the battery pack 200 and the electric tool 100 has failed; If within the time period of the set number of handshake messages, when the agreed message replied by the electric tool 100 is received, it means that the handshake communication between the battery pack 200 and the electric tool 100 is successful.
  • the battery pack 200 is composed of a communication unit A (serial bus communication unit) that implements communication mode A (serial bus communication unit), and a communication unit B that implements communication mode B (single bus communication unit). unit), a battery pack micro-control unit (battery pack MCU) and peripheral circuits, and the electric tool 100 is also composed of a communication unit A (such as a serial bus communication unit) that realizes communication mode A, a tool micro-control unit (tool MCU) and peripheral circuits, the battery pack 200 and the electric tool 100 are connected to each other through the positive pole of the power supply, the negative pole of the power supply, and the communication line.
  • the battery pack 200 of the electric tool 100 and the electric tool 100 share the same physical communication channel for communication, the battery pack 200 has two communication modes of communication mode A and communication mode B, and the electric tool 100 has a communication mode of A means of communication.
  • the working process of the battery pack 200 includes the following steps:
  • the battery pack 200 is powered on and initialized, the electric tool is detected, and the communication mode is initialized to the first communication mode, such as communication mode A;
  • step S113 If the battery pack 200 receives an agreed message, such as 0x56, 0x78, from the electric tool 100 within the period of sending N times (preset times) of handshake message information, stop the first duration timer, Set the second duration timer to send a normal communication message in a cycle of the second duration; enter step S114; if the battery pack 200 sends N times (preset number of times) handshake message information, it has not received all If the agreed message replied by the above electric tool 100, switch the communication mode to the second communication mode, such as communication mode B, and return to step S112;
  • an agreed message such as 0x56, 0x78
  • the battery pack 200 judges whether the second duration timer overflows, and if it overflows, switches to the first communication mode, such as communication mode A, and ends this data interaction process.
  • the workflow of the electric tool 100 includes the following steps:
  • the tool is powered on and initialized, and the communication mode is initialized to a third communication mode, such as communication mode A.
  • the third communication mode of the electric tool 100 and the first communication mode of the battery pack 200 may be the same or different communications Way;
  • S122 Set a third duration timer, and determine whether the electric tool 100 receives a handshake message within the third duration, such as 0x12, 0x34; when the electric tool 100 receives the handshake packet within the third duration , stop the third duration timer, set the fourth duration timer, and reply the battery pack 200 with an agreed message, such as 0x56, 0x78; when the electric tool 100 does not receive the handshake message within the third duration , then reset the third duration timer, and continue to execute the step of judging whether the electric tool 100 receives a handshake message within the third duration;
  • the data interaction method can realize smooth switching between the electric tool 100 with one communication method and the battery pack 200 with multiple different communication methods under the same physical communication channel.
  • the normal communication between the battery pack and the electric tool is guaranteed.
  • the data message interaction mode and the switching mode of the communication mode in the handshake phase of the battery pack and the electric tool are also used as anti-counterfeiting operations, increasing the It is difficult to imitate and improve product competitiveness.
  • FIG. 5-7 respectively show the conceptual diagram of the data interaction system of the second embodiment, the flow chart of the battery pack 200 in the data interaction method, and the flow chart of the electric tool 100 in the data interaction method.
  • Figures 5-7 show the smoothness of the communication modes between the battery pack 200 including at least one communication mode and the electric tool 100 including two communication modes (of course, it is also applicable to three or more situations). switch.
  • the handshake communication between the battery pack 200 and the electric tool 100 includes: the battery pack 200 sends a handshake message to the electric tool 100; when the electric tool 100 receives the handshake message within a first preset time, message, then reply the agreed message to the battery pack 200; when the electric tool 100 does not receive the handshake message within the first preset time, it means that the battery pack 200 and the electric tool 100
  • the handshake communication of the tool 100 fails; when the battery pack 200 receives the appointment message replied by the battery electric tool 100, it means that the handshake communication between the battery pack 200 and the electric tool 100 succeeds.
  • the battery pack 200 is composed of a communication unit A (serial bus communication unit) that implements communication mode A, a battery pack micro control unit (battery pack MCU) and peripheral
  • the electric tool 100 is also composed of a communication unit A (such as a serial bus communication unit) that realizes communication mode A, a communication unit B (single bus communication unit) that realizes communication mode B, and a tool micro-control unit (tool MCU). and peripheral circuits, the battery pack 200 and the electric tool 100 are connected to each other through the positive pole of the power supply, the negative pole of the power supply, and the communication line.
  • the battery pack 200 and the electric tool 100 share the same physical communication channel for communication, the battery pack 200 has a communication mode of communication A, and the electric tool 100 has two communication modes of communication mode A and communication mode B Mode.
  • the working process of the battery pack 200 includes the following steps:
  • the battery pack 200 is powered on and initialized, the electric tool is detected, and the communication mode is initialized to the first communication mode, such as communication mode A;
  • the battery pack 200 receives the agreed message replied by the electric tool 100 within the first duration, such as 0x56, 0x78, stop the first duration timer, set the second duration timer, and use the second Send a normal communication message in a period of time; enter step S214; when the battery pack 200 does not receive the agreed message replied by the electric tool 100 within the first time period, return to step S212 to continue running;
  • the battery pack 200 judges whether the second duration timer overflows, and if it overflows, ends the current data interaction process, and if not, continues to send normal communication messages at the second duration timer.
  • the workflow of the electric tool 100 includes the following steps:
  • the tool is powered on and initialized, and the communication mode is initialized to a third communication mode, such as communication mode A.
  • a third communication mode such as communication mode A.
  • the third communication mode of the electric tool 100 and the first communication mode of the battery pack 200 may be the same or different way of communication
  • step S222 Set a third duration timer, and judge whether the electric tool 100 receives a handshake message, such as 0x12, 0x34, within the third duration (that is, the first preset time); when the electric tool 100 When the handshake message is received within three hours and the verification is successful, the third duration timer is stopped, the fourth duration timer is set, and an agreed message is returned to the battery pack 200, such as 0x56, 0x78, and step S224 is entered; When the above-mentioned electric tool 100 does not receive the handshake message within the third period of time, then enter step 3);
  • the electric tool 100 switches the third communication method to the fourth communication method.
  • the current communication method is A
  • the communication method B resets the third duration timer, and enters step S221;
  • the data interaction method can realize a The communication mode of the battery pack 200 and the communication mode of the electric tool 100 with different communication modes can be switched smoothly, so as to be compatible with the iteration between new and old products, and ensure the normal communication between the battery pack and the electric tool.
  • the data message interaction mode and the switching mode of the communication mode are also used as anti-counterfeiting operations, which increases the difficulty of imitation and improves product competitiveness.
  • FIGS 8-10 respectively show the conceptual diagram of the data interaction system of the third embodiment, the flow chart of the battery pack 200 in the data interaction method, and the flow chart of the electric tool 100 in the data interaction method.
  • Figures 8-10 show the battery pack 200 including at least two communication methods (of course also applicable to three or more situations) and the battery pack 200 including two communication methods (of course also applicable to three or more than three situations) The communication mode between the electric tools 100 is switched smoothly.
  • the handshake communication between the battery pack 200 and the electric tool 100 includes: the battery pack 200 sends a handshake message to the electric tool 100, and the electric tool 100 sends a handshake message to the battery
  • the battery pack 200 replies the appointment message; when the battery pack 200 receives the appointment message within the second preset time, it means that the battery pack 200 and the electric tool 100 have successfully handshake communication, and when the electric tool 100 If the tool 100 does not receive the handshake message within the first preset time, it means that the handshake communication between the battery pack 200 and the electric tool 100 fails.
  • the above-mentioned first implementation mode can be used to switch the current communication mode in the battery pack 200 to another communication mode, or the second implementation mode way to switch the current communication mode of the electric tool 100 to another communication mode, and re-execute the handshake communication between the battery pack 200 and the electric tool 100 until the battery pack 200 and the electric power tool
  • the tool 100 handshake communication is successful.
  • data transmission is performed in the communication mode when the handshake communication between the battery pack 200 and the electric tool 100 is successful.
  • the data transmission between the battery pack 200 and the electric tool 100 includes: the data transmission between the battery pack 200 and the electric tool 100 in the communication mode when the handshake communication is successful; or the data transmission between the battery pack 200 and the electric tool 100 switches the communication mode when the handshake communication is successful to another communication mode for data transmission.
  • the battery pack 200 is composed of a communication unit A (serial bus communication unit) implementing communication mode A (serial bus communication unit), and a communication unit B (single bus communication unit) implementing communication mode B (single bus communication unit). unit), a battery pack micro-control unit (battery pack MCU) and peripheral circuits. (single-bus communication unit), tool micro-control unit (tool MCU) and peripheral circuits, the battery pack 200 communicates with the electric tool 100 The positive pole of the power supply, the negative pole of the power supply, and the communication line are connected to each other.
  • the battery pack 200 of the electric tool 100 and the electric tool 100 share the same physical communication channel for communication, the battery pack 200 has two communication modes of communication mode A and communication mode B, and the electric tool 100 has a communication mode of A and communication B two communication methods.
  • the working process of the battery pack 200 includes the following steps:
  • the battery pack 200 is powered on and initialized, the electric tool is detected, and the communication mode is initialized to the first communication mode, such as communication mode B (of course, it can also be communication mode A);
  • the battery pack 200 When the battery pack 200 receives the agreed message, such as 0x56 and 0x78, from the electric tool 100 within the first duration (that is, the second preset time), switch to the second communication method, such as the communication method A, stop the first duration timer, set the second duration timer, and send the normal communication message with the cycle of the second duration;
  • the agreed message such as 0x56 and 0x78
  • the workflow of the electric tool 100 includes the following steps:
  • the tool is powered on and initialized, and the communication mode is initialized to a third communication mode, such as communication mode B (of course, it can also be communication mode A).
  • the third communication mode of the electric tool 100 is the same as the first
  • the communication methods can be the same or different communication methods;
  • the serial bus communication method is used to carry out large data volume interactive communication and improve data transmission efficiency.
  • the serial bus communication method can be compatible with iterations between new and old products, and realize the smooth switching function of battery pack 200 and electric tool 100 between various communication modes under the same physical communication channel, so as to be compatible with new and old products.
  • the iteration between products ensures the normal communication between the battery pack and the electric tool.
  • the data message interaction mode and the switching mode of the communication mode in the handshake phase of the battery pack and the electric tool are also used as anti-counterfeiting operations, which increases the difficulty of imitation and improves Product competitiveness.
  • the data interaction scheme of the above-mentioned third embodiment is susceptible to communication interference, and data transmission errors may occur (for example, after the electronic tool receives the handshake messages of 0x12 and 0x34, it replies to the battery pack 200 with the agreed messages of 0x56 and 0x78 , and then the electronic tool switches the communication method A to the communication method B, but at this time the electric tool replies to the battery pack 200 with the agreed message of 0x56 and 0x78.
  • the communication mode A) cannot guarantee 100% successful communication switching, and the battery pack 200 is in the communication mode of A, while the electric tool is in the communication mode of B, and the two parties are not in the same communication mode. Due to the communication failure, the device It will stop running and affect the user experience.
  • this embodiment also proposes a data interaction method in which multiple communication modes coexist in the same channel without communication interference, as a fourth implementation mode of the data interaction mode.
  • FIG 11 and Figure 12 respectively show the battery pack 200 processing flow chart in the data interaction method of the fourth embodiment and the electric tool 100 processing flow chart in the data interaction method, wherein, the conceptual diagram of the data interaction system of the fourth embodiment As shown in Figure 8.
  • Figure 8 Figure 11 and Figure 12 show the battery pack 200 including at least two communication modes (of course also applicable to three or more situations) and the battery pack 200 including two communication modes (of course also applicable to three or three or more situations), the communication mode between the electric tools 100 is switched smoothly.
  • the handshake communication between the battery pack 200 and the electric tool 100 includes: the battery pack 200 sends a handshake message to the electric tool 100, and the electric tool 100 sends a handshake message to the battery
  • the battery pack 200 replies the appointment message; when the battery pack 200 receives the appointment message replied by the electric tool 100 twice consecutively, and the time between receiving the appointment message twice is less than the preset interval, it means that the The handshake communication between the battery pack 200 and the electric tool 100 succeeds, otherwise, it means that the handshake communication between the battery pack 200 and the electric tool 100 fails.
  • the above-mentioned first implementation mode can be used to switch the current communication mode in the battery pack 200 to another communication mode, or the second implementation mode can be used to switch Switch the current communication mode of the electric tool 100 to another communication mode, and re-execute the handshake communication between the battery pack 200 and the electric tool 100 until the battery pack 200 shakes hands with the electric tool 100 The communication was successful.
  • the handshake communication between the battery pack 200 and the electric tool 100 is successful, data transmission is performed in the communication mode when the handshake communication between the battery pack 200 and the electric tool 100 is successful.
  • adding the determination that the battery pack receives the agreed message replied by the electric tool twice in a row, and the time for receiving the agreed message twice is less than the preset interval can increase the anti-interference ability between the battery pack and the electric tool, Reduce data transmission errors and improve user experience.
  • the data transmission between the battery pack 200 and the electric tool 100 includes: the data transmission between the battery pack 200 and the electric tool 100 in the communication mode when the handshake communication is successful; or the data transmission between the battery pack 200 and the electric tool 100 switches the communication mode when the handshake communication is successful to another communication mode for data transmission.
  • the battery pack 200 and the electric tool 100 respectively have at least a single bus communication mode and a serial bus communication mode; If successful, the battery pack 200 and the electric tool 100 perform data transmission in the serial bus communication mode; The battery pack 200 and the electric tool 100 first switch the communication mode from the single bus communication mode to the serial bus communication mode, and then perform data transmission.
  • the battery pack 200 is composed of a communication unit A (serial bus communication unit) implementing communication mode A (serial bus communication unit), and a communication unit B (single bus communication unit) implementing communication mode B (single bus communication unit). unit), a battery pack micro-control unit (battery pack MCU) and peripheral circuits. (single-bus communication unit), tool micro-control unit (tool MCU) and peripheral circuits, the battery pack 200 and the electric tool 100 are connected to each other through the positive pole of the power supply, the negative pole of the power supply, and the communication line.
  • the battery pack 200 of the electric tool 100 and the electric tool 100 share the same physical communication channel for communication, the battery pack 200 has two communication modes of communication mode A and communication mode B, and the electric tool 100 has a communication mode of A and communication B two communication methods.
  • the working process of the battery pack 200 includes the following steps:
  • the battery pack 200 is powered on and initialized, the electric tool is detected, and the communication mode is initialized to the first communication mode,
  • communication method B (of course, it can also be communication method A);
  • the battery pack 200 judges whether to receive the agreed message replied by the electric tool within the first time period, such as 0x56, 0x78. If the battery pack 200 receives the agreed message replied by the electric tool 100, then judge whether it is the second The agreed message that the power tool 100 replies is received for the first time, and the time interval between this time and the last received agreed message is less than T milliseconds (preset interval), if the above conditions are met this time, the battery pack 200 will change the communication method from Communication mode B is switched to communication party A, and the first duration timer is stopped at the same time, and the second duration timer is set; if the above conditions are not met, return to step 2) to continue running;
  • the battery pack 200 If the battery pack 200 receives and successfully verifies the normal communication reply message replied by the electric tool 100 within the second period of time, it will reload or reset the second duration timer; if it does not receive it within the second period of time If there is any message, the battery pack 200 switches the communication mode from communication mode A to communication party B.
  • the workflow of the electric tool 100 includes the following steps:
  • the tool is powered on and initialized, and the communication method is initialized to a third communication method, such as communication method B (of course, it can also be communication method A).
  • the third communication method of the electric tool 100 is the same as the first
  • the communication methods can be the same or different communication methods;
  • the electric tool 100 judges whether the fifth duration timer overflows, and if it overflows, the electric tool 100 switches the communication mode from the third communication mode to the fourth communication mode, for example, the communication mode B is switched to the communication mode A, and stop the fifth duration timer, set the fourth duration timer;
  • the electric tool 100 judges whether the fourth duration timer overflows. If it overflows, the electric tool 100 switches the communication mode from the fourth communication mode to the third communication mode, and stops the fourth duration timer at the same time. device.
  • the serial bus communication method is used to carry out large data volume interactive communication and improve data transmission efficiency.
  • the serial bus communication method can be compatible with iterations between new and old products, and realize the smooth switching function of battery pack 200 and electric tool 100 between various communication modes under the same physical communication channel, so as to be compatible with new and old products.
  • the iteration between products ensures the normal communication between the battery pack and the electric tool.
  • the data message interaction mode and the switching mode of the communication mode in the handshake phase of the battery pack and the electric tool are also used as anti-counterfeiting operations, which increases the difficulty of imitation and improves Product competitiveness.
  • serial bus communication mode and the single bus communication mode are listed, it can be understood that the data interaction mode of this embodiment can also be extended to other buses.
  • CAN bus For example CAN bus. Aiming at the current communication method between the battery pack and the electric tool, the single-bus high-low level communication method is generally adopted. This method is easy to be intercepted by people for brute force cracking, so as to easily imitate the company’s battery pack products. The quality of the imitation products is not good enough and the technical ability is limited. , has brought great danger to the user.
  • This application discloses an encryption method in the data interaction process.
  • the fifth embodiment of the present application relates to a data interaction method.
  • the data interaction is applied to a battery pack.
  • the battery pack has a communication function.
  • When the battery pack is connected to an electric tool, it can communicate with the electric tool
  • the matching communication interface is used for communication connection. After the communication connection is successful, the battery pack can exchange data with the electric tool and charge the electric tool.
  • the interaction data in this embodiment is encrypted, so that even if it is captured by a third party, real and valid data cannot be obtained to avoid imitation.
  • the battery pack In the handshake phase, after the battery pack is powered on, the connected electric tool is detected, the first random number is generated, and the first random number is encrypted. Number and battery pack data, obtain the first handshake information and send it to the electric tool; receive the second handshake information fed back by the electric tool, decrypt the second handshake information, and obtain the electric tool data and the second random number.
  • the battery pack also saves the first random number in the second verification table, and saves the second random number in the first verification table.
  • the battery pack encrypts the first random number and the first original data, obtains the first data and sends it to the electric tool; receives the second data fed back by the electric tool, decrypts the second data, and obtains the second original data, The battery pack is discharged according to the second raw data and the electric tool data.
  • the battery pack After the battery pack is powered on, it detects the connected electric tool, and communicates with the electric tool to shake hands. After the handshake is successful, a first random number is generated.
  • the preset key the battery pack data and the first random number are encrypted into the first A handshake message.
  • the preset key is agreed in advance, for example, set to "abcdef", and the preset key is used to encrypt and decrypt the communication data during the handshake phase.
  • the battery pack data includes fixed information such as battery pack voltage and current, and the battery pack packs and encrypts the battery pack data and the first random number generated this time before sending it to the electric tool.
  • the handshake data and the first random number can be obtained.
  • the first random number is a natural number greater than 1.
  • the value of the first random number can be appropriately increased.
  • the generation range of the first random number is set to 10000-99999.
  • a first random number will be generated.
  • the battery pack will save the generated first random number to the preset second verification table , and before storing the first random number each time, the first random number generated this time will be compared with the data in the second verification table, if there is the same data, the first random number will be discarded, and a second A random number until the first generated random number is a new value.
  • the amount of data in the second verification form can be limited if the requirements are met.
  • the number of data set in this embodiment is 1000, that is, 1000 first random numbers can be stored in the second verification form. And the first random numbers are arranged in chronological order.
  • the first random number generated this time is used to replace the first random number with the earliest time in the second verification form, thereby ensuring that the data stored in the second verification form All data is up to date.
  • the battery pack and the electric tool communicate normally and perform data transmission.
  • the battery pack outputs the first data and the first handshake information, and receives the input second data, and then discharges according to the second data.
  • the battery pack encrypts the first data after combining the first original data and the first random number according to a preset first rule.
  • the first raw data is the real-time discharge parameters of the battery pack, including discharge voltage, discharge current, single cell voltage, temperature, and the like.
  • the step of combining the first original data and the first random number and then encrypting the first data includes:
  • the data D1 0x01, 0x04, 0x02, 0x03, 0x03, 0x07, 0x04, 0x08, 0x05, 0x09, 0x06 are obtained; it should be understood that the preset order can be set according to the needs, except for the above interval numbers,
  • the first random number may also be combined according to a certain rule before being inserted into the first original data.
  • the data D1 obtained above is encrypted by a preset encryption algorithm to obtain the first data; wherein, the preset encryption algorithm in this embodiment can be selected from DES encryption algorithm (Data Encryption Standard, DES), DES encryption algorithm As one of the symmetric encryption algorithms, the same key is used for encryption and decryption.
  • the key length used by DES is 64 bits.
  • the basic structure of DES is designed by Horst Feistel of IBM, so it is called Feistel network. In the Feistel network, each step of encryption is called a round.
  • the 64-bit plaintext after initial permutation undergoes 16 rounds of Feistel round encryption, and finally the final 64-bit ciphertext is formed after final permutation.
  • the electric tool receives the first data, and extracts the first random number according to the preset sequence through the DES decryption algorithm, so as to obtain the first original data.
  • the battery pack receives the second data, parses the second data into second original data according to a preset second rule, and performs discharge according to the second original data.
  • the step of parsing the second data into the second original data includes:
  • the second data is the charging parameter transmitted by the electric tool, and the charging parameter is transmitted to the battery pack after being encrypted in a manner similar to the discharge parameter in the above-mentioned battery pack.
  • the preset sequence and preset encryption algorithm adopted by the battery pack and the electric tool for encryption in this embodiment are the same. In actual use, different sequences and encryption algorithms can be adopted under the implementation agreement.
  • the battery pack also receives the second handshake information transmitted by the electric tool, the battery pack decrypts the second handshake information according to the preset key, obtains the second random number, and saves the second random number to the preset In the pre-set first verification form; when the amount of data in the first verification form is greater than the preset first amount, the second random number received this time is used to replace the earliest second random number in the first verification form.
  • the amount of data in the first verification form can be limited if the requirements are met.
  • the number of data set in this embodiment is 1000, that is, 1000 second random numbers can be stored in the first verification form.
  • the second random numbers are arranged in chronological order. When the number of data is greater than 1000, the second random number generated this time is used to replace the earliest second random number in the first verification form, thereby ensuring that the first verification form is saved. All data is up to date.
  • each battery pack and electric tool carries a unique identification code when it leaves the factory, and the battery pack and electric tool can exchange their own identification codes during the handshake information interaction after the connection and handshake is successful.
  • the battery pack and electric tool can exchange their own identification codes during the handshake information interaction after the connection and handshake is successful.
  • the identification codes of these 100 electric tools and 1000 second random numbers corresponding to each electric tool will be stored.
  • the battery pack will use the 101st
  • the information of the first electric tool can be replaced by the information of the first electric tool, so as to ensure that the saved electric tool is the latest tool.
  • this embodiment also provides a failure judgment mechanism, including:
  • the battery pack After receiving the second handshake information of a certain electric tool, the battery pack compares the parsed second random number with the data in the first verification form. If the same data exists, the second random number is considered If the random number does not comply with the failure mechanism, the connected electric tool is illegally connected, the battery pack disconnects the communication connection with the electric tool, and stops outputting the first data and receiving the second data. If the same data does not exist, it is considered that the second random number conforms to the failure mechanism, and the second random number is saved in the first verification form, and the battery pack and the electric tool perform normal data interaction, output the first data, and receive the second data , and then discharge the electric tool according to the received second data.
  • the battery pack and the electric tool perform data interaction, it is updated in real time based on the data fed back by the other party, that is, the first data output by the battery pack is generated based on the second handshake information and the second data fed back by the electric tool; Correspondingly, the second data output by the electric tool is generated based on the first handshake information and the first data fed back by the battery pack.
  • this embodiment implements two layers of encryption on the data in the handshake phase and the communication phase respectively to ensure the security of the interactive data. Even if the interactive data is captured by a third party, the real and valid data cannot be obtained; in addition, the received The random number is used for verification. If it does not meet the failure mechanism, the connected electric tool is considered to be illegally connected, and the communication connection is disconnected, which avoids the possibility of being imitated and greatly guarantees the safety of users.
  • the sixth embodiment of the present application relates to a data interaction method
  • the data interaction method is applied to an electric tool
  • the electric tool has a communication function
  • the electric tool when the electric tool is connected with a battery pack, it can communicate with the battery pack
  • the communication connection is carried out through the matching communication interface.
  • the electric tool can exchange data with the battery pack and charge through the battery pack.
  • the interaction data in this embodiment is encrypted, so that even if it is captured by a third party, real and valid data cannot be obtained to avoid imitation.
  • the encryption in this embodiment is realized by two layers of encryption in the handshake stage and the normal communication stage,
  • the electric tool In the handshake phase, after the electric tool is powered on, it detects the connected battery pack, generates a second random number, encrypts the second random number and the data of the electric tool, obtains the second handshake information and sends it to the battery pack; The first handshake information is decrypted to obtain the battery pack data and the first random number.
  • the electric tool also saves the first random number in the third verification table, and saves the second random number in the fourth verification table.
  • the electric tool encrypts the second random number and the second original data, obtains the second data and sends it to the battery pack; receives the first data fed back by the battery pack, decrypts the first data, and obtains the first original data, The electric tool is charged according to the first raw data and the battery pack data.
  • the electric tool After the electric tool is powered on, it detects that there is a battery pack connected, and performs a communication handshake with the battery pack. After the handshake is successful, a second random number is generated, and according to the preset key, the data of the electric tool and the second random number are encrypted as Second handshake information.
  • the preset key is agreed in advance, for example, set to "abcdef", and the preset key is used to encrypt and decrypt the communication data during the handshake phase.
  • the power tool data includes fixed information such as the voltage and current of the power tool.
  • the handshake data and the second random number can be obtained.
  • the second random number is a natural number greater than 1.
  • the value of the second random number can be appropriately increased.
  • the generation range of the second random number is set to 10000-99999.
  • a second random number will be generated, in order to ensure that the second The uniqueness of the random number, the electric tool will save the generated second random number to the preset fourth verification table, and before storing the second random number each time, it will compare the second random number generated this time with the fourth The data in the verification form is compared, and if the same data exists, the second random number is discarded and a second random number is regenerated until the generated second random number is a new value.
  • the amount of data in the fourth verification form can be limited if the requirements are met.
  • the number of data set in this embodiment is 1000, that is, 1000 second random numbers can be stored in the fourth verification form. And the second random numbers are arranged in chronological order.
  • the second random number generated this time is used to replace the second random number with the earliest time in the fourth verification form, so as to ensure that the data stored in the fourth verification form All data is up to date.
  • the electric tool and the battery pack communicate normally and perform data transmission.
  • the electric tool outputs the second data and the second handshake information, and receives the input first data, and then charges according to the first data.
  • the electric tool combines the second original data and the second random number according to a preset first rule and then encrypts it into the second data.
  • the second raw data is real-time charging parameters of the electric tool, including charging voltage, charging current, temperature and so on.
  • the step of combining the second original data and the second random number and then encrypting the second data includes:
  • the generated first random number is 98734, and the corresponding 5 bytes are: 0x09, 0x08, 0x07, 0x03, 0x04;
  • the obtained data D1' 0x06, 0x09, 0x05, 0x08, 0x04, 0x07, 0x03, 0x03, 0x02, 0x04, 0x01;
  • the second random number can also be combined according to a certain rule first, and then inserted into the second original data.
  • the data D1' obtained above is encrypted by a preset encryption algorithm to obtain the second data; wherein, the preset encryption algorithm in this embodiment can select the DES encryption algorithm, and the battery pack receives the second data, pass DES decrypts the algorithm, and extracts the second random number according to the preset order to obtain the second original data.
  • the electric tool receives the first data, parses the first data into first original data according to the preset second rule, and performs charging according to the first original data.
  • the step of parsing the first data into the first original data includes:
  • the first data is the discharge parameter transmitted by the battery pack, and the discharge parameter is transmitted to the electric tool after being encrypted in a manner similar to the charging parameter in the above-mentioned electric tool.
  • the preset sequence and preset encryption algorithm adopted by the electric tool and the battery pack for encryption in this embodiment are the same. In actual use, different sequences and encryption algorithms can be adopted under the implementation agreement.
  • the electric tool also receives the first handshake information transmitted by the battery pack.
  • the electric tool decrypts the first handshake information according to the preset key, obtains the first random number, and saves the first random number to the preset In the provided third verification table; when the amount of data in the third verification table is greater than the preset third number, the first random number received this time is used to replace the earliest first random number in the third verification table.
  • the amount of data in the third verification form can be limited if the requirements are met.
  • the number of data set in this embodiment is 1000, that is, 1000 first random numbers can be stored in the third verification form. And the first random numbers are arranged in chronological order. When the number of data is greater than 1000, the first random number generated this time is used to replace the first random number with the earliest time in the third verification form, thereby ensuring that the data saved in the third verification form All data is up to date.
  • each battery pack and electric tool carries a unique identification code when it leaves the factory, and the electric tool and battery pack can exchange their respective identification codes in the handshake information interaction after the connection and the handshake is successful.
  • the identification codes of these 100 battery packs and the 1000 first random numbers corresponding to each battery pack will be stored.
  • the power tool will use the 101st random number. Replace the information of the first battery pack with the information of the first battery pack, so as to ensure that the saved battery pack is up to date.
  • this embodiment also provides a failure judgment mechanism, including:
  • the electric tool After receiving the first handshake information of a certain battery pack, the electric tool compares the analyzed first random number with the data in the third verification form. If there is the same data, the first random number is considered to be The random number does not meet the invalidation mechanism, the battery pack is accessed illegally, the electric tool disconnects the communication connection with the battery pack, and stops outputting the second data and receiving the first data. If the same data does not exist, it is considered that the first random number conforms to the failure mechanism, and the first random number is saved in the third verification form. At the same time, the electric tool and the battery pack perform normal data interaction, output the second data, and receive the first data. , and then charge the battery pack according to the received first data.
  • this embodiment implements two layers of encryption on the data in the handshake phase and the communication phase respectively to ensure the security of the interactive data. Even if the interactive data is captured by a third party, the real and valid data cannot be obtained; in addition, the received The random number is verified, and if it does not meet the failure mechanism, the connected battery pack is considered to be illegally connected, and the communication connection is disconnected, avoiding the possibility of being copied, which greatly guarantees the safety of users.
  • the seventh embodiment of the present application relates to a data interaction system, including a detachably connected battery pack and an electric tool. Both the battery pack and the electric tool have a communication function. When the two are connected, they can communicate through a matching communication interface. After the communication is successful, data interaction is performed, and charging and discharging are performed based on the interactive data.
  • the battery pack After the battery pack is powered on, it detects that there is an electric tool connected, and communicates with the electric tool to shake hands. After the handshake is successful, a first random number is generated. According to the preset key, the battery pack data and the first random number The number is encrypted as the first handshake information and output to the electric tool. Correspondingly, after the electric tool is powered on, it detects that there is an connected battery pack, and communicates with the battery pack to shake hands. After the handshake is successful, a second random number is generated, and according to the preset key, the electric tool data and the second random number The data is encrypted into the second handshake information and output to the battery pack.
  • the battery pack decrypts the second handshake information to obtain the second random number, and saves the second random number in the preset first verification form in chronological order.
  • the second random number received this time is used to replace the earliest second random number in the first verification table.
  • the electric tool decrypts the first handshake information to obtain the first random number, and saves the first random number in the preset third verification form in chronological order, when the data amount in the third verification form When it is greater than the preset third number, replace the earliest first random number in the third verification table with the first random number received this time.
  • the battery pack before the battery pack saves the second random number, it also compares the second random number with the first verification table. If there is the same data, it is considered that the connected electric tool is illegally connected. communication connection. Correspondingly, before the electric tool saves the first random number, it also compares the first random number with the third verification form. Package communication connection.
  • the battery pack also compares the generated first random number with the data in the preset second verification table, If there is the same data, regenerate a first random number; otherwise, save the first random number generated this time in the second verification table in time order, when the amount of data in the second verification table is greater than the preset second When the quantity is used, the first random number generated this time is used to replace the earliest first random number in the second verification form.
  • the electric tool also compares the generated second random number with the data in the preset fourth verification form, and if there is the same data, regenerates a second random number;
  • the second random number is stored in the fourth verification form.
  • the second random number generated this time is used to replace the earliest second random number in the fourth verification form. random number.
  • the battery pack judges that the connected electric tool is legal according to the received second random number, it will perform normal data interaction with the electric tool, output the first data, receive the second data, and perform data processing on the electric tool according to the second data.
  • Discharge specifically:
  • the battery pack combines the first original data and the first random number and then encrypts the first data, wherein the specific steps of generating the first data include: dividing the first random number into individual byte, each byte is inserted into the first original data according to the preset order, thereby adding the first random number to the first original data; and then through the preset encryption algorithm, the first random number added The original data is encrypted to obtain the first data.
  • the battery pack receives the second data, and parses the second data into the second original data according to the preset second rule, wherein the specific step of obtaining the second original data includes: using the preset decryption algorithm to convert the second data to decrypting to the second original data with the second random number added; separating the second random number and the second original data according to a preset order to obtain the second original data; Each byte of the second random number is extracted from the second original data to obtain the second original data.
  • the battery pack discharges the electric tool according to the second raw data.
  • the electric tool judges that the battery pack connected is legal according to the received first random number, it will perform normal data interaction with the battery pack, output the second data, receive the first data, and perform Charging, specifically:
  • the electric tool combines the second original data and the second random number into the second data according to the preset first rule, wherein the specific step of generating the second data includes: dividing the second random number into individual Byte, each byte is inserted into the second original data according to the preset order, thereby adding the second random number to the second original data; and then through the preset encryption algorithm, the second random number added
  • the original data is encrypted to obtain the second data.
  • the electric tool receives the first data, and parses the first data into the first original data according to the preset second rule, wherein the specific steps of obtaining the first original data include: using the preset decryption algorithm to convert the first data to Deciphering the first original data with the first random number added; separating the first random number from the first original data according to a preset order to obtain the first original data; Each byte of the first random number is extracted from the first original data to obtain the first original data.
  • the electric tool is charged through the battery pack according to the first raw data.
  • this embodiment implements two layers of encryption on the data in the handshake phase and the communication phase respectively to ensure the security of the interactive data. Even if the interactive data is captured by a third party, the real and valid data cannot be obtained; in addition, the received The random number is verified. If it does not meet the failure mechanism, the connected battery pack or electric tool is considered to be illegally connected, and the communication connection is disconnected, avoiding the possibility of being copied, which greatly protects the safety of users.
  • the data interaction method and system of this application perform two-layer encryption on the data in the handshake phase and the communication phase respectively, which ensures the security of the interactive data, even if the interactive data is captured by a third party, it cannot be obtained Real and valid data; in addition, the random number received is also verified. If it does not meet the failure mechanism, the battery pack or electric tool connected is considered to be illegally connected, and the communication connection is disconnected to avoid the possibility of being copied. Greatly protect the safety of users. Therefore, the present application effectively overcomes various shortcomings in the prior art and has high industrial application value.
  • the eighth embodiment of the present application relates to a communication anti-counterfeiting system for data interaction, which includes a detachably connected electric tool 100 and a battery pack 200. It should be understood that the electric tool 100 and the battery pack 200 in this embodiment Both have a communication function, and the two can realize communication connection through a matching communication interface.
  • the electric tool 100 includes a first processor 101 (also referred to as a tool micro-control unit).
  • the first processor 101 communicates with the battery pack 200, obtains verification information from the battery pack 200, and performs verification. If the verification is successful, it performs normal data interaction with the battery pack 200; otherwise, it considers If it is abnormal access, disconnect the communication connection with the battery pack 200 .
  • the battery pack 200 includes a memory 201 for storing verification information. It should be understood that the memory 201 is a memory chip with a communication function, such as an eID chip.
  • the verification information is randomly generated according to the system time.
  • a verification information is randomly generated according to the system time in advance and stored in the memory 201 of the battery pack 200.
  • the verification information is read from the memory 201 and analyzed according to agreed rules.
  • a verification information can be generated in real time according to the system time, and after the electric tool 100 obtains the verification information generated in real time, it can perform parse.
  • the verification information may be generated by an external device and stored in the memory 201 of the battery pack 200, or may be generated by the battery pack 200 itself.
  • the battery pack 200 also includes a second processor 202 (battery pack microcontroller unit), and the second processor 202 is connected to the memory 201 for generating verification information and storing it in in memory 201.
  • the first processor 101 of the electric tool communicates with the second processor 202 and reads the verification information from the memory 201 .
  • the first processor 101 When the electric tool 100 is inserted into the battery pack 200, the battery pack 200 is awakened, the first processor 101 establishes a communication connection with the battery pack 200, accesses the memory 201, reads the first array from the specific address of the memory 201, and performs calibration If the verification is successful, normal data interaction with the battery pack 200 is performed, otherwise, the communication connection with the battery pack 200 is stopped, wherein the step of the first processor 101 verifying the first array includes:
  • the first array is randomly generated and stored in the memory 201 of the battery pack 200.
  • the first array is generated by the second processor 202 of the battery pack 200 for illustration.
  • the generating steps include:
  • the second processor 202 randomly generates the first key based on the system time, according to the preset rules, according to the first key generation
  • the system time can be the current time, or a specific time selected by the user.
  • the second processor 202 converts the system time into a time stamp to generate a corresponding first key, wherein the key is generated according to the time.
  • the key is a conventional means in the prior art, and there are mature implementations.
  • a hash encryption algorithm may be used to generate a corresponding first key based on the system time.
  • the second processor 202 maps the first key to the first ciphertext according to a preset rule, wherein the preset rule is a mapping relationship between the first key and the first ciphertext, which can be set as required, For example, the first key is multiplied by a specific coefficient to obtain the first ciphertext.
  • the preset rule is a mapping relationship between the first key and the first ciphertext, which can be set as required, For example, the first key is multiplied by a specific coefficient to obtain the first ciphertext.
  • the second processor 202 combines the first key, the first ciphertext and the preset check characters into a first array according to a preset sequence, and writes the first array into the memory 201 .
  • the number of digits of the first key, the first ciphertext, and the preset check character may be the same or different, and may be set according to needs during actual use.
  • the second processor 202 generates an N-bit first key according to the time stamp converted from the current time, and records the first key as N 0 and the second key as N 1 , ... the last digit of the key is N n .
  • the first key, the first ciphertext, and the preset check character in the preset order for example, in the order of N-bit first key + M-bit first ciphertext + Y-bit check character , and the Y-bit check character in this embodiment can be set as "ABC", finally forming a first array of N+M+Y bits.
  • the first processor 101 checks the first array, according to the preset order, the check character can be extracted for comparison, and the first key and the first ciphertext in the first array can be intercepted .
  • the second processor 202 stores this first array of N+M+Y bits into the memory 201 at a specific address.
  • the second processor 202 after storing the first array, the second processor 202 also re-reads the stored first array from the memory 201, and combines the re-read first array with the stored If the matching is successful, it is considered that the first array stored in the memory is correct and can be used; otherwise, rewrite the first array to the memory 201 to replace the wrong data.
  • the first array is an array of N+M+Y bits
  • the preset check character is "ABC”. Whether "ABC" exists in the first array, and if it exists, further intercept the N-bit first key and M-bit first ciphertext in the first array, and generate the second ciphertext according to the first key according to the preset rules , it should be understood that the preset rule here should be the same as the preset rule used by the above-mentioned second processor 202 .
  • the match is successful, it is considered that the data read by the first processor 101 from the memory 201 is the first processor 102 stored data.
  • One array that is, the verification is successful, can work normally, and perform data interaction; otherwise, the connection between the battery pack 200 and the electric tool 100 is considered to be abnormal access, and the communication between the two should be disconnected immediately in order to prevent being cracked by violence connect.
  • connection between the first processor 101 and the second processor 202 and the memory 201, and between the second processor 202 and the memory 201 in the above embodiment is connected by a bus, and the bus may include any number of interconnected
  • the bus and the bridge the bus connects various circuits of the first processor 101 , the second processor 202 and the memory 201 together.
  • the bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein.
  • the bus interface provides an interface between the bus and the transceivers.
  • a transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium.
  • the data processed by the first processor 101 is transmitted on the wireless medium through the antenna, and further, the antenna also receives the data and transmits the data to the first processor 101 and the second processor 202 .
  • the first processor 101 and the second processor 202 are responsible for bus management and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, charge and discharge management, and other control functions.
  • the memory 201 can also be used to store data used by the second processor 202 when performing operations.
  • this embodiment generates verification information and stores it in the memory 201 of the battery pack 200.
  • the electric tool 100 communicates with the battery pack 200, it reads the verification information from the memory 201 to verify it, and the verification is successful. Data interaction with the battery pack 200 is performed, otherwise the communication with the battery pack 200 is stopped, which reduces the analysis of the communication content being intercepted and prevents the battery pack product from being easily imitated.
  • the present application implements the anti-counterfeiting function by means of the memory 201, without changing the existing circuit structure and reducing the cost.
  • the ninth embodiment of the present application relates to a communication anti-counterfeiting method, which is applied to The electric tool 100, and the electric tool 100 is detachably connected to the battery pack 200, including:
  • Step S201 read the first array in the memory of the battery pack 200 .
  • Step S202 verifying the first array.
  • Step S203 judging whether the verification is successful, if the verification is successful, then work normally and perform data interaction with the battery pack 200 ; otherwise, stop the communication connection with the battery pack 200 .
  • step S201 when the electric tool 100 is inserted into the battery pack 200 , the battery pack 200 wakes up, establishes a communication connection with the electric tool 100 , accesses the memory 201 , and reads the first array from a specific address of the memory 201 .
  • the first array is the verification information of the electric tool 100 and the battery pack 200. If the verification is successful, it is considered that the electric tool 100 and the battery pack 200 are normally connected and can work normally; otherwise, it is considered to be abnormal connection , should stop working immediately to avoid being brute force cracked.
  • the steps of verifying the first array include:
  • Step S301 judging whether there is a preset check character in the first array.
  • check character "ABC" set in the first embodiment exists in the first array. It should be understood that in actual use, different check characters may be set as required.
  • Step S302 if it exists, intercept the first key and the first ciphertext in the first array.
  • the first key, the first ciphertext, and the check character in the first array are arranged in a preset order.
  • the first ciphertext in the first array can be intercepted according to the preset order.
  • Step S303 generating a second ciphertext according to the first key.
  • the second ciphertext is generated according to the first key.
  • the preset rules here should be the same as the preset rules used by the second processor 202 in the first embodiment, for example
  • the intercepted first key is multiplied by a specific coefficient to obtain the second ciphertext.
  • Step S304 matching the second ciphertext and the first ciphertext, that is, judging whether the first ciphertext and the second ciphertext are the same, if they are the same, the matching is successful, that is, the verification is successful, and normal communication can be performed.
  • the first ciphertext and the second ciphertext are compared step by step, and if each character is the same, it is considered that the two match successfully.
  • the communication anti-counterfeiting method for data interaction in the ninth embodiment of the present application is improved on the basis of Fig. 23, including:
  • Step S401 read the first array in the memory of the battery pack 200 .
  • Step S402 verifying the first array.
  • Step S403 judging whether the verification is successful, and if the verification is successful, it works normally and exchanges data with the battery pack 200 . Otherwise, the communication connection with the battery pack 200 is stopped.
  • Step S404 after the verification fails, read the first array in the memory again, and verify it, if the verification is successful, then work normally, and perform data interaction with the battery pack 200; otherwise, stop communicating with the battery pack 200 communication connection.
  • the first array in the memory can also be read multiple times, and the number of reads to the memory can be recorded, and the first array read can be verified at the same time, if the verification is successful within the preset number of times , it works normally and performs data interaction with the battery pack 200 , and if the check fails within the preset number of times, the communication connection with the battery pack 200 is stopped.
  • this embodiment generates verification information and stores it in the memory 201 of the battery pack 200.
  • the electric tool 100 communicates with the battery pack 200, it reads the verification information from the memory 201 to verify it, and the verification is successful. Data interaction with the battery pack 200 is performed, otherwise the communication with the battery pack 200 is stopped, which reduces the analysis of the communication content being intercepted and prevents the battery pack product from being easily imitated.
  • the present application implements the anti-counterfeiting function by means of the memory 201, without changing the existing circuit structure and reducing the cost.
  • the tenth embodiment of the present application relates to a communication anti-counterfeiting method for data interaction.
  • the communication anti-counterfeiting method is applied to the battery pack 200, and the battery pack 200 is detachably connected to the electric tool 100, including:
  • Step S501 pre-store a first array, and the first array is used for verification between the battery pack 200 and the electric tool 100 .
  • step S502 it is judged whether the verification request sent by the electric tool 100 is received, and if so, step S503 is executed.
  • Step S503 sending the first array to the electric tool 100 for verification by the electric tool 100 .
  • Step S504 judging whether the indication information sent by the electric tool 100 is received, the indication information is used to indicate to the battery pack whether the verification is successful, if successful, execute step S505.
  • Step S505 data interaction with the electric tool 100 .
  • the first array is randomly generated and stored in the memory 201 of the battery pack 200 , it can be generated by an external device and stored in the memory 201 of the battery pack 200 , or it can be generated by the battery pack 200 itself.
  • the generation step of the first array includes:
  • Step S601 randomly generating a first key based on system time.
  • the system time can be the current time, or a specific time selected by the user. Time is converted into a time stamp, and the corresponding first key is generated, wherein generating a key according to time is a conventional means in the prior art, and there are mature implementations, for example, in this embodiment, a hash encryption algorithm can be used , generating a corresponding first key based on the system time.
  • Step S602 generating a first ciphertext according to the first key.
  • the first key can be mapped to the first ciphertext according to preset rules, wherein the preset rule is the mapping relationship between the first key and the first ciphertext, which can be set as needed, For example, the first key is multiplied by a specific coefficient to obtain the first ciphertext.
  • the preset rule is the mapping relationship between the first key and the first ciphertext, which can be set as needed, For example, the first key is multiplied by a specific coefficient to obtain the first ciphertext.
  • Step S603 combining the first key, the first ciphertext, and the preset check character in a preset order to obtain a first array.
  • the first key, the first ciphertext, and the preset check character are multi-digit character strings, and the number of digits can be the same or different, and can be set according to actual needs.
  • N-digit first keys For example, generate N-digit first keys according to the system time, and record the first-digit key as N 0 , the second-digit key as N 1 , ... and the last-digit key as N n .
  • the first key, the first ciphertext, and the preset check character in the preset order for example, in the order of N-bit first key + M-bit first ciphertext + Y-bit check character , and the Y-bit check character in this embodiment can be set as "ABC", finally forming a first array of N+M+Y bits.
  • Step S604 writing the first array into the memory of the battery pack 200 .
  • the above-mentioned first array of N+M+Y bits is stored in a specific address of the memory 201 .
  • the step of generating the first array in the present application is improved on the basis shown in FIG. 27, including:
  • Step S701 randomly generating a first key based on system time.
  • Step S702 generating a first ciphertext according to the first key.
  • Step S703 combining the first key, the first ciphertext, and the preset check character in a preset order to obtain a first array.
  • Step S704 writing the first array into the memory of the battery pack 200 .
  • Step S705 after writing the first array to the memory of the battery pack 200, re-read the stored first array, match the re-read first array with the stored first array, if the matching is successful, then holds the first stored in memory The array is correct and can be used; otherwise, rewrite the first array to the memory to replace the wrong data.
  • this embodiment generates verification information and stores it in the memory 201 of the battery pack 200.
  • the electric tool 100 communicates with the battery pack 200, it reads the verification information from the memory 201 to verify it, and the verification is successful. Data interaction with the battery pack 200 is performed, otherwise the communication with the battery pack 200 is stopped, which reduces the analysis of the communication content being intercepted and prevents the battery pack product from being easily imitated.
  • the present application implements the anti-counterfeiting function by means of the memory 201, without changing the existing circuit structure and reducing the cost.
  • the communication anti-counterfeiting method and system for data interaction of the present application generates verification information and stores it in the memory 201 of the battery pack 200. Before the electric tool 100 communicates with the battery pack 200, it first reads Take the verification information and verify it. Only when the verification is successful can the data exchange with the battery pack 200 be performed. Otherwise, the communication with the battery pack 200 will be stopped, which reduces the analysis of the communication content being intercepted and prevents the battery pack product from being easily imitated. In addition, the present application implements the anti-counterfeiting function by means of the memory 201, without changing the existing circuit structure and reducing the cost.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Charge And Discharge Circuits For Batteries Or The Like (AREA)
  • Battery Mounting, Suspending (AREA)

Abstract

本申请提供一种数据交互方法及系统,应用于电池包与电动工具之间的数据交互,电池包与电动工具共用同一物理通信通道进行通信,电池包和电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式;进行数据交互时,电池包与电动工具进行初次握手通信;当电池包与电动工具初次握手通信失败时,电池包和电动工具中具有两种通信方式的一个将当前的通信方式切换为另一种通信方式;电池包与电动工具进行二次握手通信;当电池包与电动工具二次握手通信成功后,电池包与电动工具进行数据传输。利用本申请能够实现电池包和电动工具中具有至少两种通信方式的一个的通信方式的平滑切换,从而实现电池包与电动工具的正常通信。

Description

一种数据交互方法及系统 技术领域
本申请涉及通信技术领域,特别涉及一种数据交互方法及系统。
背景技术
随着技术不断发展,产品线的不断丰富,以及网联化智能化的不断演进,电池包与电动工具之间通信的数据量也在急速增长,原有的单总线通信协议不能满足目前电池包与电动工具之间的通信需求,极大的限制了产品功能及体验的提高。
采用新的通信方式虽然能满足大数据量的传输要求,但是为了兼容新老产品之间的迭代,电池包或/和电动工具之间会并存多种不同的通信方式,且受制于物理通信通道的限制,多种通信方式共用同一物理通信通道,这会因电池包与电动工具在通信连接时采用不同的通信方式,而出现通信失败以及工具停机等问题。
另外,原有电池包与电动工具采用单总线高低电平的通信方式,还存在容易被人截取通信内容,进行暴力破解,从而轻松仿制公司电池包产品的问题。
发明内容
鉴于以上所述现有技术的缺点,本申请的目的在于提供一种数据交互方法及系统,用于解决现有的电池包或/和电动工具之间会并存多种不同的通信方式,且电池包与电动工具之间共用同一物理通信通道场景下因电池包与电动工具在通信连接时采用不同的通信方式,而出现通信失败以及工具停机等的技术问题。
为实现上述目的及其他相关目的,本申请提供一种数据交互方法及系统,应用于电池包与电动工具之间的数据交互,所述电池包与所述电动工具共用同一物理通信通道进行通信,所述电池包和所述电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式;
所述数据交互方法包括:
所述电池包与所述电动工具进行握手通信;
当所述电池包与所述电动工具握手通信失败时,所述电池包和所述电动工具中具有两种通信方式的一个将自身当前的通信方式切换为另一种通信方式;
重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功;
所述电池包与所述电动工具进行数据传输。
在本申请的一可选实施例中,所述电池包包括一种通信方式,所述电动工具包括两种通信方式;
所述电池包与所述电动工具进行握手通信包括:
所述电池包向所述电动工具发送握手报文;
当所述电动工具在第一预设时间内收到所述握手报文,则向所述电池包回复约定报文,当所述电池包收到所述电池工具回复的所述约定报文时,则表示所述电池包与所述电动工具握手通信成功;
当所述电动工具在所述第一预设时间未内收到所述握手报文,则表示所述电池包与所述电动工具握手通信失败;当所述电池包与所述电动工具握手通信失败时,所述电动工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
在本申请的一可选实施例中,所述电池包包括至少两种通信方式,所述电动工具包括至少一种通信方式;
所述电池包与所述电动工具进行握手通信包括:
所述电池包向所述电动工具发送握手报文并记录握手报文发送次数;
当所述电池包在所述握手报文发送的预设次数内收到所述电动工具回复的约定报文时,则表示所述电池包与所述电动工具握手通信成功;
当所述电池包在所述握手报文发送的预设次数内未收到所述电动工具回复的约定报文时,则表示所述电池包与所述电动工具握手通信失败;
当所述电池包与所述电动工具握手通信失败时,所述电池包将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池 包与所述电动工具握手通信成功。
在本申请的一可选实施例中,所述电池包和所述电动工具分别具有至少两种通信方式;
所述电池包与所述电动工具进行握手通信包括:
所述电池包向所述电动工具发送握手报文,所述电动工具收到所述握手报文,则向所述电池包回复约定报文;
当所述电池包在第二预设时间内收到所述约定报文,则表示所述电池包与所述电动工具握手通信成功,而当所述电动工具未在所述第一预设时间内收到所述握手报文,则表示所述电池包与所述电动工具握手通信失败;
当所述电池包与所述电动工具握手通信失败时,则所述电池包或所述电池工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
在本申请的一可选实施例中,所述电池包和所述电动工具分别具有至少两种通信方式;
所述电池包与所述电动工具进行握手通信包括:
所述电池包向所述电动工具发送握手报文,所述电动工具收到所述握手报文,则向所述电池包回复约定报文;
当所述电池包连续两次接收所述电动工具回复的所述约定报文,并且两次接收所述约定报文的时间小于预设间隔,则表示所述电池包与所述电动工具握手通信成功,否则,则表示所述电池包与所述电动工具握手通信失败;
当所述电池包与所述电动工具握手通信失败时,则所述电池包或所述电池工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
在本申请的一可选实施例中,所述电池包与所述电动工具进行数据传输包括:
所述电池包与所述电动工具以握手通信成功时的通信方式进行数据传输;或
所述电池包与所述电动工具将握手通信成功时的通信方式切换为另一种通信方式进行数据传输。
在本申请的一可选实施例中,所述电池包和所述电动工具分别至少具有单总线通信方式和串行总线通信方式;
所述电池包与所述电动工具进行数据传输包括:
当所述电池包与所述电动工具通过所述串行总线通信方式握手通信成功,所述电池包与所述电动工具以所述串行总线通信方式进行数据传输;
当所述电池包与所述电动工具通过所述单总线通信方式握手通信成功时,所述电池包与所述电动工具先将通信方式由所述单总线通信方式切换为串行总线通信方式,然后在进行数据传输。
在本申请的一可选实施例中,所述数据交互方法还包括,当所述电池包与所述电动工具数据传输完毕后,所述电池包与所述电动工具将通信方式设置为各自默认的通信方式。
在本申请的一可选实施例中,在所述电池包与所述电动工具进行握手通信时:
所述电池包检测到接入的所述电动工具,产生一个第一随机数,根据预设密钥,将电池包数据和第一随机数加密为第一握手信息,输出第一握手信息到所述电动工具;
所述电池包接收所述电动工具反馈的第二握手信息,根据预设密钥,解密第二握手信息,得到电动工具数据和第二随机数;
所述电池包与所述电动工具进行数据传输,包括:
所述电池包根据预设第一规则,将第一原始数据和所述第一随机数组合后加密成第一数据,输出第一数据到所述电动工具;
所述电池包接收所述电动工具反馈的第二数据,根据预设第二规则,将所述第二数据解析成第二原始数据,根据所述第二原始数据和所述电动工具数据进行放电。
所述电池包根据预设第一规则,将所述第一原始数据和所述第一随机数组合后加密成第一数据,包括:
所述电池包按照预设顺序,在所述第一原始数据中加入所述第一随机数;
所述电池包通过预设加密算法,对加入所述第一随机数的所述第一原始数据进行加密,得到所述第一数据。
在本申请的一可选实施例中,所述电池包按照预设顺序,在所述第一原始数据中加入所述第一随机数的步骤包括:
所述电池包将所述第一随机数分成单个字节,将每个字节按照预设顺序,分别插入所述第一原始数据中。
在本申请的一可选实施例中,所述电池包接收所述电动工具反馈的第二数据,根据预设第二规则,将所述第二数据解析成第二原始数据,包括:
所述电池包接收所述电动工具反馈的第二数据,通过预设解密算法,将所述第二数据解密为加入了所述第二随机数的所述第二原始数据;
所述电池包按照预设顺序,将所述第二随机数和所述第二原始数据分离,得到所述第二原始数据。
在本申请的一可选实施例中,所述数据交互方法还包括:
所述电池包按照时间顺序将所述第二随机数保存到预设的第一验证表格中;
当所述第一验证表格中的数据数量大于预设第一数量时,采用此次接收的所述第二随机数替换所述第一验证表格中时间最早的所述第二随机数。
在本申请的一可选实施例中,所述数据交互方法还包括:
所述电池包将所述第二随机数与所述第一验证表格中的数据相比较,若存在相同数据,则认为接入的所述电动工具为非法接入,所述电池包断开与所述电动工具的通信连接。
在本申请的一可选实施例中,所述数据交互方法还包括:
所述电池包将产生的所述第一随机数与预设的第二验证表格中的数据相比较,若存在相同数据,则重新生成一个所述第一随机数;
否则,按照时间顺序将此次产生的所述第一随机数保存到所述第二验证表格中,当所述第二验证表格中的数据数量大于预设第二数量时,采用此次产生的所述第一随机数替换所述第二验证表格中时间最早的所述第一随机数。
在本申请的一可选实施例中,所述电池包与所述电动工具进行数据传输的步骤之前还包括:
所述电动工具读取所述电池包的存储器内的第一数组;
所述电动工具校验所述第一数组,校验成功,则与所述电池包进行数据传输,否则,停止与所述电池包的通信连接;
其中,所述电动工具校验所述第一数组的步骤包括:
所述电动工具判断所述第一数组是否存在预设的校验字符,
若存在,所述电动工具截取所述第一数组中的第一密钥和第一密文,根据所述第一密 钥生成第二密文,匹配所述第二密文和所述第一密文,匹配成功,则认为校验成功。
在本申请的一可选实施例中,所述电池包与所述电动工具进行数据传输之前还包括:
所述电池包预存用于校验的第一数组;
所述电池包接收到所述电动工具发送的校验请求,发送所述第一数组到所述电动工具,所述校验请求是在所述电池包检测到有所述电动工具接入时所触发发送的;
所述电池包接收来自所述电动工具的指示信息,其中,所述指示信息用于向所述电池包指示校验是否成功,若成功,则与所述电动工具进行数据交互。
为实现上述目的及其他相关目的,本申请提供另一种数据交互方法,应用于电池包与电动工具之间的数据交互,所述电池包与所述电动工具共用同一物理通信通道进行通信,所述电池包和所述电动工具至少具有两种通信方法;
所述数据交互方法包括:
所述电池包与所述电动工具通过一种通信方式进行握手通信;
当所述电池包与所述电动工具握手通信成功时,所述电池包和所述电动工具分别将通信方式由握手通信成功时的通信方式切换为另一种通信方式。
在本申请的一可选实施例中,所述另一种通信方式具备大数据传输能力和高传输速率。
为实现上述目的及其他相关目的,本申请提供一种数据交互系统,包括:
电动工具;
电池包,所述电池包与所述电动工具共用同一物理通信通道进行通信;
所述电池包和所述电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式,所述电池包和所述电动工具中的通信方式所对应的通信单元与各自的微控单元连接;
所述电动工具与所述电池包被配置通过以下方式进行数据交互:
所述电池包与所述电动工具进行握手通信;
当所述电池包与所述电动工具握手通信失败时,所述电池包和所述电动工具中具有两种通信方式的一个将自身当前的通信方式切换为另一种通信方式;
重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功;
所述电池包与所述电动工具进行数据传输。
本申请的一种数据交互方法及系统,应用于电池包与电动工具之间的数据交互,电池包与电动工具共用同一物理通信通道进行通信,电池包和电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式;进行数据交互时,电池包与电动工具进行初次握手通信;当电池包与电动工具初次握手通信失败时,电池包和电动工具中具有两种通信方式的一个将当前的通信方式切换为另一种通信方式;电池包与电动工具进行二次握手通信;当电池包与电动工具二次握手通信成功后,电池包与电动工具进行数据传输。
利用本申请能够实现同一物理通信通道下,电池包和电动工具在多种不同的通信方式之间的平滑切换,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信;同时电池包与电动工具握手阶段的防伪操作,增大了仿制难度,提高产品竞争力。
本申请的数据交互方法,分别在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据,避免了被仿制的可能性,极大地保障了用户的安全。
本申请的数据交互方法,通过生成校验信息,并存储在电池包的存储器中,电动工具与电池包通信前,先从存储器中读取校验信息对其进行校验,校验成功才与电池包进行数据交互,否则停止与电池包的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制。此外,本申请借助存储器实现防伪功能,无需改变现有的电路结构,降低了成本。
附图说明
图1示出了本申请的数据交互方法的流程示意图。
图2示出了本申请的一种实施方式的数据交互系统概念图。
图3示出了本申请的一种实施方式的数据交互方法中电池包处理流程图。
图4示出了本申请的一种实施方式的数据交互方法中电动工具处理流程图。
图5示出了本申请的另一种实施方式的数据交互系统概念图。
图6示出了本申请的另一种实施方式的数据交互方法中电池包处理流程图。
图7示出了本申请的另一种实施方式的数据交互方法中电动工具处理流程图。
图8示出了本申请的又一种实施方式的数据交互系统概念图。
图9示出了本申请的又一种实施方式的数据交互方法中电池包处理流程图。
图10示出了本申请的又一种实施方式的数据交互方法中电动工具处理流程图。
图11示出了本申请的第四种实施方式的数据交互方法中电池包处理流程图。
图12示出了本申请的第四种实施方式的数据交互方法中电动工具处理流程图。
图13显示为本申请第五实施方式中的数据交互方法的流程示意图。
图14显示为本申请第五实施方式中的生成第一数据的流程示意图。
图15显示为本申请第五实施方式中的解析第二数据的流程示意图。
图16显示为本申请第五实施方式中的另一种数据交互方法的流程示意图。
图17显示为本申请第六实施方式中的数据交互方法的流程示意图。
图18显示为本申请六实施方式中的生成第二数据的流程示意图。
图19显示为本申请第六实施方式中的解析第一数据的流程示意图。
图20显示为本申请第六实施方式中的另一种数据交互方法的流程示意图。
图21显示为本申请第七实施方式中的数据交互系统的结构框图。
图22显示为本申请第八实施方式中的通信防伪系统的结构框图。
图23显示为本申请第九实施方式中的通信防伪方法的流程示意图。
图24显示为本申请第九实施方式中的校验第一数组的流程示意图。
图25显示为本申请第九实施方式中的通信防伪方法的另一种流程示意图。
图26显示为本申请第十实施方式中的通信防伪方法的流程示意图。
图27显示为本申请第十实施方式中的生成第一数组的流程示意图。
图28显示为本申请第十实施方式中的生成第一数组的另一种流程示意图。
具体实施方式
以下通过特定的具体实例说明本申请的实施方式,本领域技术人员可由本说明书所揭露的内容轻易地了解本申请的其他优点与功效。本申请还可以通过另外不同的具体实施方式加以实施或应用,本说明书中的各项细节也可以基于不同观点与应用,在没有背离本申请的精神下进行各种修饰或改变。
请参阅图1-12。需要说明的是,本实施例中所提供的图示仅以示意方式说明本申请的 基本构想,遂图式中仅显示与本申请中有关的组件而非按照实际实施时的组件数目、形状及尺寸绘制,其实际实施时各组件的型态、数量及比例可为一种随意的改变,且其组件布局型态也可能更为复杂。
现有的SmartG电池包200或电动工具采用串口通信方式,之前电池包200或电动工具采用的还是自定义的COM通信方式,为了保证老电动工具能使用SmartG的电池包200或老电池包200能适配采用SmartG的工具,因此需要自定义COM通信与串口通信之间能平滑切换的方式。
基于此,本申请介绍一种电池包200与电动工具100之间的数据交互方法。请参阅图2、5及8所示,所述电池包200由实现特定通信方式的通信单元、电池包微控单元(也即电池包MCU)及外围电路,所述电动工具100由实现特定通信方式的通信单元、工具微控单元(工具MCU)及外围电路组成,所述电池包200与所述电动工具100之间通过电源正极、电源负极、以及通信线相互连接。所述电动工具100所述电池包200与所述电动工具100共用同一物理通信通道进行通信,所述电池包200和所述电动工具100中的一个至少具有一种通信方式,另一个至少具有两种通信方式,所述电池包200和所述电动工具100中的通信方式与各自的微控单元连接。
请参阅图1所示,图1为本申请实施例的数据交互方法流程示意图。本申请实施例的数据交互方法,应用于电池包200与电动工具100之间的数据交互,包括如下步骤:
S10:上电初始化,包括所述电池包200的上电初始化和所述电动工具100的上电初始化。
所述电池包200上电初始化:所述电池包200上电,检测到所述电动工具100后,进行所述电池包200的通信方式初始化,将所述电池包200的通信方式初始化为默认通信方式。当所述电池包200只存在一种通信方式时,则将所述电池包200的通信方式初始化为该通信方式。当所述电池包200存在两种或者两种以上的通信方式时,则可将所述电池包200的通信方式初始化为其中的一个(可进行配置),例如,当所述电池包200存在单总线通信方式和串行总线通信方式时,则可将所述电池包200的通信方式初始化为单总线通信方式或串行总线通信方式,例如单总线通信方式。
所述电动工具100的上电初始化:所述电动工具100上电,并进行所述电动工具100 的通信方式初始化,将所述电动工具100通信方式初始化为默认通信方式。当所述电动工具100只存在一种通信方式时,则将所述电动工具100的通信方式初始化为该通信方式。当所述电动工具100存在两种或者两种以上的通信方式时,则可将所述电动工具100的通信方式初始化为其中的一个(可进行配置),例如,当所述电动工具100存在单总线通信方式和串行总线通信方式时,则可将所述电动工具100的通信方式初始化为单总线通信方式或串行总线通信方式,例如单总线通信方式。
S20及S30:所述电池包200与所述电动工具100进行握手通信,并判断所述电池包200与所述电动工具100握手通信是否成功。
所述电池包200与所述电动工具100要进行正常的数据传输之前,所述电池包200与所述电动工具100进行握手通信,只有当所述电池包200与所述电动工具100握手通信成功后,才能跳转到步骤S50来执行所述电池包200与所述电动工具100进行数据传输,否则,执行步骤S40。
需要说明的是,所述电池包200与所述电动工具100进行握手通信流程根据所述电池包200与所述电动工具100中通信方式的个数不同而不同,详见后文相关部分的描述。
S40:所述电池包200和所述电动工具100中具有两种通信方式的一个将自身当前的通信方式切换为另一种通信方式,并返回步骤S20重新执行所述电池包200与所述电动工具100进行握手通信,直至所述电池包200与所述电动工具100握手通信成功。
S50:所述电池包200与所述电动工具100进行数据传输,也即进行正常通信报文的传输交互。
需要说明的是,为了保证所述电池包200和/或所述电动工具100每次上电后的通信逻辑一致,所述数据交互方法还包括,当所述电池包200与所述电动工具100数据传输完毕后,所述电池包200与所述电动工具100的将通信方式设置为所述电池包200与所述电动工具100的各自默认的通信方式。当所述电池包200与所述电动工具100在数据交互过程中(包括握手通信和数据传输阶段)没有切换默认通信方式时,则在该步骤中保持当前的通信方式即可,当所述电池包200与所述电动工具100在数据交互过程中(包括握手通信和数据传输阶段)改变了默认通信方式,则需要进行通信方式的切换,以将所述电池包200与所述电动工具100的当前通信方式切换为所述电池包200与所述电动工具100的默认 通信方式。默认通信方式是认为规定的所述电池包200或所述电动工具100上电后,执行初始化后的通信方式。
利用实施例的数据交互方式能够实现同一物理通信通道下,电池包和电动工具在多种不同的通信方式之间的平滑切换,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信。同时电池包与电动工具握手阶段的握手阶段数据报文交互方式及通信方式的切换方式也作为防伪操作,增大了仿制难度,提高产品竞争力。
下面将结合四个不同的实施方式来说明本实施例的数据交互方法。
图2-4分别示出了第一种实施方式的数据交互系统概念图、数据交互方法中电池包200处理流程图及数据交互方法中电动工具100处理流程图。图2-4给出了包括两种通信方式(当然也适用于三种或三种以上的情形)电池包200与包括至少一种通信方式的所述电动工具100之间数据交互过程中通信方式平滑切换。
所述电池包200与所述电动工具100进行握手通信包括:所述电池包200向所述电动工具100发送握手报文并记录握手报文发送次数;当所述电池包200在发送预设次数的所述握手报文后,仍未收到所述电动工具100回复的约定报文时,则表示所述电池包200与所述电动工具100握手通信失败;当所述电池包200在发送预设次数的所述握手报文的时间内,收到所述电动工具100回复的约定报文时,则表示所述电池包200与所述电动工具100握手通信成功。
当所述电池包200与所述电动工具100握手通信失败时,将所述电池包200中自身当前的通信方式切换为另一种通信方式,并重新执行所述电池包200与所述电动工具100进行握手通信的步骤,直至所述电池包200与所述电动工具100握手通信成功。
当所述电池包200与所述电动工具100握手通信成功时,则以所述电池包200与所述电动工具100握手通信成功时的通信方式来进行数据传输。
如图2所示,在该实施方式的一具体示例中,所述电池包200由实现通信方式A的通信单元A(串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、电池包微控单元(电池包MCU)及外围电路组成,所述电动工具100也是由实现通信方式A的通信单元A(比如串行总线通信单元)、工具微控单元(工具MCU)及外围电路组成,所述电池包200与所述电动工具100之间通过电源正极、电源负极、以及通信线相互连接。 所述电动工具100所述电池包200与所述电动工具100共用同一物理通信通道进行通信,所述电池包200具有通信方式A和通信方式B两种通信方式,所述电动工具100具有通信方式A一种通信方式。
如图3所示,在数据交互过程中,所述电池包200的工作流程包括如下步骤:
S111、电池包200上电初始化,检测到电动工具,将通信方式初始化为第一通信方式,譬如通信方式A;
S112、设置第一时长定时器,所述电池包200以第一时长的周期发送握手报文,譬如0x12,0x34;
S113、所述电池包200若发送N次(预设次数)握手报文信息的时间内收到所述电动工具100回复的约定报文,譬如0x56,0x78,停止所述第一时长定时器,设置第二时长定时器,以第二时长的周期发送正常通信报文;进入步骤S114;若所述电池包200发送N次(预设次数)握手报文信息的时间内,仍未收到所述电动工具100回复的约定报文,则将通信方式切换为第二通信方式,譬如通信方式B,返回步骤S112;
S114、电池包200判断第二时长定时器是否溢出,若溢出,则切换为第一通信方式,譬如通信方式A,则结束本次数据交互流程。
如图4所示,在数据交互过程中,所述电动工具100的工作流程包括如下步骤:
S121、工具上电初始化,将通信方式初始化为第三通信方式,譬如通信方式A,所述电动工具100的第三通信方式与所述电池包200的第一通信方式可为相同或者不同的通信方式;
S122、设置第三时长定时器,并判断所述电动工具100在第三时长内是否收到握手报文,譬如0x12,0x34;当所述电动工具100在第三时长内收到握手报文时,停止第三时长定时器,设置第四时长定时器,并给所述电池包200回复约定报文,譬如0x56,0x78;当所述电动工具100在第三时长内未收到握手报文时,则重置第三时长定时器,并继续执行判断所述电动工具100在第三时长内是否收到握手报文步骤;
S123、判断所述电动工具100在第四时长内是否收到正常通信报文;当所述电动工具100在第四时长内收到正常通信报文,则回复正常通信回复报文;当所述电动工具100在第四时长内未收到正常通信报文,则结束本次数据交互流程。
由上可知,在该实施方式中,所述数据交互方式能够实现同一物理通信通道下,一种通信方式的电动工具100和存在多种不同通信方式的电池包200的通信方式之间平滑切换,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信,同时电池包与电动工具握手阶段的握手阶段数据报文交互方式及通信方式的切换方式也作为防伪操作,增大了仿制难度,提高产品竞争力。
图5-7分别示出了第二种实施方式的数据交互系统概念图、数据交互方法中电池包200处理流程图及数据交互方法中电动工具100处理流程图。图5-7给出了包括至少一种通信方式的所述电池包200与包括两种通信方式的所述电动工具100(当然也适用于三种或三种以上的情形)之间通信方式平滑切换。
所述电池包200与所述电动工具100进行握手通信包括:所述电池包200向所述电动工具100发送握手报文;当所述电动工具100在第一预设时间内收到所述握手报文,则向所述电池包200回复约定报文;当所述电动工具100在所述第一预设时间未内收到所述握手报文,则表示所述电池包200与所述电动工具100握手通信失败;当所述电池包200收到所述电池电动工具100回复的所述约定报文时,则表示所述电池包200与所述电动工具100握手通信成功。
当所述电池包200与所述电动工具100握手通信失败时,将所述电动工具100当前的通信方式切换为另一种通信方式,并重新执行所述电池包200与所述电动工具100进行握手通信,直至所述电池包200与所述电动工具100握手通信成功。
当所述电池包200与所述电动工具100握手通信成功时,则以所述电池包200与所述电动工具100握手通信成功时的通信方式来进行数据传输。
如图5所示,在该实施方式的一具体示例中,所述电池包200由实现通信方式A的通信单元A(串行总线通信单元)、电池包微控单元(电池包MCU)及外围电路组成,所述电动工具100也是由实现通信方式A的通信单元A(比如串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、工具微控单元(工具MCU)及外围电路组成,所述电池包200与所述电动工具100之间通过电源正极、电源负极、以及通信线相互连接。所述电池包200与所述电动工具100共用同一物理通信通道进行通信,所述电池包200具有通信方式A一种通信方式,所述电动工具100具有通信方式A和通信方式B两种通信方 式。
如图6所示,在数据交互过程中,所述电池包200的工作流程包括如下步骤:
S211、电池包200上电初始化,检测到电动工具,将通信方式初始化为第一通信方式,譬如通信方式A;
S212、设置第一时长定时器,所述电池包200以第一时长的周期发送握手报文,譬如0x12,0x34;
S213、当所述电池包200在第一时长内收到所述电动工具100回复的约定报文,譬如0x56,0x78,停止所述第一时长定时器,设置第二时长定时器,以第二时长的周期发送正常通信报文;进入步骤S214;当所述电池包200在第一时长内未收到所述电动工具100回复的约定报文,则返回步骤S212继续运行;
S214、电池包200判断第二时长定时器是否溢出,若溢出,则结束本次数据交互流程,若未溢出则继续以第二时长的周期发送正常通信报文。
如图7所示,在数据交互过程中,所述电动工具100的工作流程包括如下步骤:
S221、工具上电初始化,将通信方式初始化为第三通信方式,譬如通信方式A,当然,所述电动工具100的第三通信方式与所述电池包200的第一通信方式可为相同或者不同的通信方式
S222、设置第三时长定时器,并判断所述电动工具100在第三时长(也即第一预设时间)内是否收到握手报文,譬如0x12,0x34;当所述电动工具100在第三时长内收到握手报文并验证成功时,停止第三时长定时器,设置第四时长定时器,并给所述电池包200回复约定报文,譬如0x56,0x78,进入步骤S224;当所述电动工具100在第三时长内未收到握手报文时,则进入步骤3);
S223、所述电动工具100将第三通信方式切换为第四通信方式,譬如当前是通信方式A,则切换为通信方式B,重置第三时长定时器,进入步骤S221;
S224、当所述电动工具100在第三时长内收到握手报文并验证成功,则回复电池包200所述正常通信回复报文并重装在第四时长定时器;若第三时长内未收到任何消息,则从步骤S221开始运行。
由上可知,在该实施方式中,所述数据交互方式能够实现同一物理通信通道下,一种 通信方式的电池包200和存在多种不同通信方式的电动工具100的通信方式之间平滑切换,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信,同时电池包与电动工具握手阶段的握手阶段数据报文交互方式及通信方式的切换方式也作为防伪操作,增大了仿制难度,提高产品竞争力。
图8-10分别示出了第三种实施方式的数据交互系统概念图、数据交互方法中电池包200处理流程图及数据交互方法中电动工具100处理流程图。图8-10给出了包括至少两种通信方式(当然也适用于三种或三种以上的情形)的所述电池包200与包括两种通信方式(当然也适用于三种或三种以上的情形)的所述电动工具100之间的通信方式平滑切换。
所述电池包200与所述电动工具100进行握手通信包括:所述电池包200向所述电动工具100发送握手报文,所述电动工具100收到所述握手报文,则向所述电池包200回复约定报文;当所述电池包200在第二预设时间内收到所述约定报文,则表示所述电池包200与所述电动工具100握手通信成功,而当所述电动工具100未在所述第一预设时间内收到所述握手报文,则表示所述电池包200与所述电动工具100握手通信失败。当所述电池包200与所述电动工具100握手通信失败时,可采用上述第一种实施方式将所述电池包200中自身当前的通信方式切换为另一种通信方式,或第二种实施方式来将所述电动工具100中自身当前的通信方式切换为另一种通信方式,并重新执行所述电池包200与所述电动工具100进行握手通信,直至所述电池包200与所述电动工具100握手通信成功。当所述电池包200与所述电动工具100握手通信成功时,则以所述电池包200与所述电动工具100握手通信成功时的通信方式来进行数据传输。
所述电池包200与所述电动工具100进行数据传输包括:所述电池包200与所述电动工具100以握手通信成功时的通信方式进行数据传输;或所述电池包200与所述电动工具100将握手通信成功时的通信方式切换为另一种通信方式进行数据传输。
如图8所示,在该实施方式的一具体示例中,所述电池包200由实现通信方式A的通信单元A(串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、电池包微控单元(电池包MCU)及外围电路组成,所述电动工具100也是由实现通信方式A的通信单元A(比如串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、工具微控单元(工具MCU)及外围电路组成,所述电池包200与所述电动工具100之间通 过电源正极、电源负极、以及通信线相互连接。所述电动工具100所述电池包200与所述电动工具100共用同一物理通信通道进行通信,所述电池包200具有通信方式A和通信方式B两种通信方式,所述电动工具100具有通信方式A和通信方式B两种通信方式。
如图9所示,在数据交互过程中,所述电池包200的工作流程包括如下步骤:
S311、电池包200上电初始化,检测到电动工具,将通信方式初始化为第一通信方式,譬如通信方式B(当然也可以是通信方式A);
S312、设置第一时长定时器,所述电池包200以第一时长的周期发送握手报文,譬如0x12,0x34;
S313、当所述电池包200在第一时长(也即第二预设时间)内收到所述电动工具100回复的约定报文,譬如0x56,0x78,切换到第二通信方式,譬如通信方式A,停止所述第一时长定时器,设置第二时长定时器,以第二时长的周期发送正常通信报文;
S314、电池包200若在第二时长内收到且校验成功所述电动工具100回复的正常通信回复报文,则重置第二时长定时器;若第二时长内未收到任何消息,则将通信方式切换为第一通信方式,譬如通信方式B,从步骤S312开始运行。
如图10所示,在数据交互过程中,所述电动工具100的工作流程包括如下步骤:
S321、工具上电初始化,将通信方式初始化为第三通信方式,譬如通信方式B(当然也可以是通信方式A),所述电动工具100的第三通信方式与所述电池包200的第一通信方式可为相同或者不同的通信方式;
S322、设置第三时长定时器,并判断所述电动工具100在第三时长(第一预设时间)内是否收到握手报文,譬如0x12,0x34,且校验成功;当所述电动工具100在第三时长内收到握手报文并验证成功时,停止第三时长定时器,并给所述电池包200回复约定报文,譬如0x56,0x7,同时进行通信方式的替换,将第三通信方式替换为第四通信方式,譬如当前是通信方式B,则切换为通信方式A;
S323、设置第四时长定时器;
S324、所述电动工具100若在第四时长内收到且校验成功电池包200发的正常通信报文,则重装载四时长定时器;若所述电动工具100若在第四时长内未收到任何消息,则从步骤1)开始运行。
由上可知,在该实施方式中,由于单总线通信方式不能满足大数据量的传输要求,故当所述电池包200与所述电动工具100之间通过单总线通信方式握手成功后,需要切换为能够满足大数据量传输需求的串行总线通信方式来进行大数据量的交互通信,提升数据传输效率。通过这种通信方式的切换,能够兼容新老产品之间的迭代,实现同一物理通信通道下,电池包200和电动工具100在多种不同的通信方式之间平滑切换的功能,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信,同时电池包与电动工具握手阶段的握手阶段数据报文交互方式及通信方式的切换方式也作为防伪操作,增大了仿制难度,提高产品竞争力。
上述第三种实施方式的数据交互方案,容易受到通信干扰,会出现数据传输出错的情况(比如电子工具收到0x12,0x34的握手报文后,给电池包200回复0x56,0x78的约定报文,然后电子工具将通信方式A切换成通信方式B,但是此时电动工具给电池包200回复0x56,0x78的约定报文由于某种原因并没有被电池包200成功识别,因此电池包200仍处于通信方式A),无法保证百分百的通信切换成功,出现电池包200处于A种通信方式,而电动工具处于B种通信方式,双方不处于同一种通信方式的场景,由于通信的失败,设备会停止运行,影响用户体验。
为此,本实施例还提出一不受通信干扰的同一通道下多种通信方式并存的数据交互方法,作为数据交互方式的第四种实施方式。
如图11与图12分别示出了第四种实施方式数据交互方法中电池包200处理流程图及数据交互方法中电动工具100处理流程图,其中,第四种实施方式的数据交互系统概念图如图8所示。图8、图11与图12给出了包括至少两种通信方式(当然也适用于三种或三种以上的情形)的所述电池包200与包括两种通信方式(当然也适用于三种或三种以上的情形)的所述电动工具100之间的通信方式平滑切换。
所述电池包200与所述电动工具100进行握手通信包括:所述电池包200向所述电动工具100发送握手报文,所述电动工具100收到所述握手报文,则向所述电池包200回复约定报文;当所述电池包200连续两次接收所述电动工具100回复的所述约定报文,并且两次接收所述约定报文的时间小于预设间隔,则表示所述电池包200与所述电动工具100握手通信成功,否则,则表示所述电池包200与所述电动工具100握手通信失败。当所述 电池包200与所述电动工具100握手通信失败时,可采用上述第一种实施方式将所述电池包200中自身当前的通信方式切换为另一种通信方式,或第二种实施方式来将所述电动工具100中自身当前的通信方式切换为另一种通信方式,并重新执行所述电池包200与所述电动工具100进行握手通信,直至所述电池包200与所述电动工具100握手通信成功。当所述电池包200与所述电动工具100握手通信成功时,则以所述电池包200与所述电动工具100握手通信成功时的通信方式来进行数据传输。在握手阶段,增加电池包连续两次接收电动工具回复的所述约定报文,并且两次接收约定报文的时间小于预设间隔的判定,可以增加电池包与电动工具间的抗干扰能力,减少数据传输出错的情况,提升用户体验。
所述电池包200与所述电动工具100进行数据传输包括:所述电池包200与所述电动工具100以握手通信成功时的通信方式进行数据传输;或所述电池包200与所述电动工具100将握手通信成功时的通信方式切换为另一种通信方式进行数据传输。
作为示例,所述电池包200和所述电动工具100分别至少具有单总线通信方式和串行总线通信方式;当所述电池包200与所述电动工具100通过所述串行总线通信方式握手通信成功,所述电池包200与所述电动工具100以所述串行总线通信方式进行数据传输;当所述电池包200与所述电动工具100通过所述单总线通信方式握手通信成功时,所述电池包200与所述电动工具100先将通信方式由所述单总线通信方式切换为串行总线通信方式,然后在进行数据传输。
如图8所示,在该实施方式的一具体示例中,所述电池包200由实现通信方式A的通信单元A(串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、电池包微控单元(电池包MCU)及外围电路组成,所述电动工具100也是由实现通信方式A的通信单元A(比如串行总线通信单元)、实现通信方式B的通信单元B(单总线通信单元)、工具微控单元(工具MCU)及外围电路组成,所述电池包200与所述电动工具100之间通过电源正极、电源负极、以及通信线相互连接。所述电动工具100所述电池包200与所述电动工具100共用同一物理通信通道进行通信,所述电池包200具有通信方式A和通信方式B两种通信方式,所述电动工具100具有通信方式A和通信方式B两种通信方式。
如图10示,在数据交互过程中,所述电池包200的工作流程包括如下步骤:
S411、电池包200上电初始化,检测到电动工具,将通信方式初始化为第一通信方式, 譬如通信方式B(当然也可以是通信方式A);
S412、设置第一时长定时器,所述电池包200以第一时长的周期发送握手报文,譬如0x12,0x34;
S413、电池包200判断是否在第一时长内收到电动工具回复的约定报文,譬如0x56,0x78,如果电池包200接收到所述电动工具100回复的约定报文,则判断是否是第二次收到电动工具100回复的约定报文,且本次与上次收到约定报文的时间间隔小于T毫秒(预设间隔),若本次满足上述条件,则电池包200将通信方式从通信方式B切换成通信方A,同时停止第一时长定时器,设置第二时长定时器;若不满足上述条件返回步骤2)继续运行;
S414、电池包200切换通信方式A后,以第四时长的周期发送正常通信报文SSS;
S415、电池包200若在第二时长内收到且校验成功所述电动工具100回复的正常通信回复报文,则重装载或重置第二时长定时器;若第二时长内未收到任何消息,则电池包200将通信方式从通信方式A切换成通信方B。
如图12所示,在数据交互过程中,所述电动工具100的工作流程包括如下步骤:
S421、工具上电初始化,将通信方式初始化为第三通信方式,譬如通信方式B(当然也可以是通信方式A),所述电动工具100的第三通信方式与所述电池包200的第一通信方式可为相同或者不同的通信方式;
S422、设置第三时长定时器,并判断所述电动工具100在第三时长内是否收到握手报文(譬如0x12,0x34)且校验成功,当所述电动工具100在第三时长内收到握手报文并验证成功时,给电池包200回复约定报文,譬如0x34,0x45;
S423、当所述电动工具100在第三时长内收到握手报文并验证成功时,则所述电动工具100判断是不是第一次收到所述电池包200发送的握手报文,若是,则停止第三时长定时器,设置第五时长定时器;若非则重新复位所述第五时长定时器;
S424、所述电动工具100判断所述第五时长定时器是否溢出,若溢出则所述电动工具100将通信方式有第三通信方式切换为第四通信方式,譬如有通信方式B切换为通信方式A,并停止第五时长定时器,设置第四时长定时器;
S425、所述电动工具100处于通信方式A的场景下,接收到所述电池包200发送的正常通信报文,则回复正常通信回复报文,并重置第四时长定时器;
S426、所述电动工具100判断所述第四时长定时器是否溢出,若溢出,则所述电动工具100将通信方式有第四通信方式切换为第三通信方式,同时停止所述第四时长定时器。
由上可知,在该实施方式中,由于单总线通信方式不能满足大数据量的传输要求,故当所述电池包200与所述电动工具100之间通过单总线通信方式握手成功后,需要切换为能够满足大数据量传输需求的串行总线通信方式来进行大数据量的交互通信,提升数据传输效率。通过这种通信方式的切换,能够兼容新老产品之间的迭代,实现同一物理通信通道下,电池包200和电动工具100在多种不同的通信方式之间平滑切换的功能,以兼容新老产品之间的迭代,保证电池包与电动工具的正常通信,同时电池包与电动工具握手阶段的握手阶段数据报文交互方式及通信方式的切换方式也作为防伪操作,增大了仿制难度,提高产品竞争力。
需要说明的是,虽然本实施例中,只列举出了串行总线通信方式、单总线通信方式两种通信方式,但可以理解的是,本实施例的数据交互方式也可以扩展到其他总线,例如CAN总线。针对目前电池包与电动工具之间一般采用单总线高低电平的通信方式,这个方式容易被人截取通信内容,进行暴力破解,从而轻松仿制公司电池包产品,仿制产品质量不过关、技术能力有限,给用户带来了极大的危险的问题,本申请公开了一种在数据交互过程的加密方式,通过在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据,避免了被仿制的可能性,极大地保障了用户的安全,详见下文中第五-第七实施方式中描述的技术方案,第五-第七实施方式中各实施方式的技术方案也可应用于上述第一-第四实施方式及后续第八-第十实施方式中各实施方式的技术方案中。
请参阅图13,本申请的第五实施方式涉及一种数据交互方法,该数据交互应用于电池包,该电池包具有通信功能,当该电池包上连接有电动工具时,可与电动工具通过相匹配的通信接口进行通信连接,通信连接成功后电池包可与电动工具进行数据交互,以及对电动工具充电。为了保证数据交互的安全,本实施例中的交互数据是经过加密的,这样即使被第三方抓取,也无法获得真实的有效数据,避免被仿制。
本实施方式的加密通过握手阶段和正常通信阶段的两层加密来实现:
在握手阶段,电池包上电后检测到接入的电动工具,产生第一随机数,加密第一随机 数和电池包数据,得到第一握手信息并发送至电动工具;接收到电动工具反馈的第二握手信息,解密该第二握手信息,得到电动工具数据和第二随机数。同时,电池包还保存第一随机数至第二验证表格中,保存第二随机数至第一验证表格中。
在正常通信阶段,电池包加密第一随机数和第一原始数据,得到第一数据并发送至电动工具;接收到电动工具反馈的第二数据,解密该第二数据,得到第二原始数据,电池包根据该第二原始数据和电动工具数据进行放电。
具体的说:
电池包上电后,检测到有接入的电动工具,与电动工具进行通信握手,握手成功后产生一个第一随机数,根据预设密钥,将电池包数据和第一随机数加密为第一握手信息。其中,预设密钥为事先约定的,例如设定为“abcdef”,该预设密钥用于在握手阶段对通信数据进行加密和解密。在握手阶段,电池包数据包括电池包电压、电流等固定信息,电池包将电池包数据和此次产生的第一随机数打包加密后发送至电动工具,电动工具根据约定的预设密钥即可获取握手数据及第一随机数。
需要说明的是,该第一随机数为一个大于1的自然数,为了提高加密的复杂度,可适当加大第一随机数的数值,例如本实施例中,将第一随机数的产生范围设置为10000-99999。
此外,电池包与电动工具每次握手成功后,都会产生一个第一随机数,为了确保第一随机数的唯一性,电池包将产生的第一随机数保存至预设的第二验证表格中,并且在每次存储第一随机数前,会将本次产生的第一随机数与第二验证表格中的数据相比较,若存在相同数据,则舍弃该第一随机数,重新生成一个第一随机数,直至生成的第一随机数为一个新的数值。
为了降低内存,可在满足需要的情况下限定第二验证表格中的数据数量,例如本实施例中设定的数据数量为1000个,即第二验证表格中可保存1000个第一随机数,并且各第一随机数按照时间顺序排列,当数据数量大于1000时,采用此次产生的第一随机数替换第二验证表格中时间最早的第一随机数,从而保证第二验证表格中保存的所有数据都是最新的。
继续说明,握手完成后,电池包和电动工具正常通信,进行数据传输,电池包输出第一数据和第一握手信息,并接收输入的第二数据,再根据第二数据进行放电。
具体的说,电池包根据预设第一规则,将第一原始数据和第一随机数组合后加密成第一数据。应理解,第一原始数据为电池包实时的放电参数,包括放电电压、放电电流、单个电芯电压、温度等。其中,根据预设第一规则,将第一原始数据和第一随机数组合后加密成第一数据的步骤包括:
请参阅图14,按照预设顺序,将第一随机数分成单个字节,将每个字节按照预设顺序,分别插入第一原始数据中,从而在第一原始数据中加入第一随机数;再通过预设加密算法,对加入第一随机数的第一原始数据进行加密,得到第一数据。
例如,电池包的第一原始数据为D0=0x01,0x02,0x03,0x04,0x05,0x06;生成的第一随机数为43789,对应的5个字节为:0x04,0x03,0x07,0x08,0x09;按照预设顺序,将第一随机数的每个字节插入第一原始数据中,其中,预设顺序可以为将第一随机数的每个字节从前到后的顺序,间隔插入第一原始数据中,得到数据D1=0x01,0x04,0x02,0x03,0x03,0x07,0x04,0x08,0x05,0x09,0x06;应理解,预设顺序可根据需要进行设置,除了上述隔数放入外,还可将第一随机数先按照一定规律组合后,再插入第一原始数据中。
继续说明,通过预设加密算法,对上述得到的数据D1进行加密,得到第一数据;其中,本实施例中的预设加密算法可以选择DES加密算法(Data Encryption Standard,DES),DES加密算法为对称加密算法中的一种,在加密和解密时使用同一密钥,DES使用的密钥长度为64比特,DES的基本结构由IBM公司的Horst Feistel设计,因此称Feistel网络。在Feistel网络中,加密的每个步骤称为轮,经过初始置换后的64位明文,进行了16轮Feistel轮的加密过程,最后经过终结置换后形成最终的64位密文。电动工具接收到该第一数据,通过DES解密算法,并按照预设顺序提取出第一随机数,即可获取第一原始数据。
继续说明,电池包接收到第二数据,根据预设第二规则,将第二数据解析成第二原始数据,根据第二原始数据进行放电。
请参阅图15,根据预设第二规则,将第二数据解析成第二原始数据的步骤包括:
通过预设解密算法,将第二数据解密为加入了第二随机数的第二原始数据;按照预设顺序,将第二随机数和第二原始数据分离,得到第二原始数据;按照预设顺序,从加入了第二随机数的第二原始数据中将第二随机数的每个字节提取出来,得到第二原始数据。应 理解,此处的第二数据为电动工具传输的充电参数,该充电参数经过上述电池包中的放电参数类似的加密方式,再传输至电池包。为方便操作,本实施例中电池包和电动工具进行加密时所采用的预设顺序和预设加密算法均相同,实际使用时,可在实现约定下,采用不同的顺序和加密算法。
电池包在通信过程中,还接收到电动工具传输的第二握手信息,电池包根据预设密钥解密第二握手信息,得到第二随机数,并按照时间顺序将第二随机数保存到预设的第一验证表格中;当第一验证表格中的数据数量大于预设第一数量时,采用此次接收的第二随机数替换第一验证表格中时间最早的第二随机数。为了降低内存,可在满足需要的情况下限定第一验证表格中的数据数量,例如本实施例中设定的数据数量为1000个,即第一验证表格中可保存1000个第二随机数,并且各第二随机数按照时间顺序排列,当数据数量大于1000时,采用此次产生的第二随机数替换第一验证表格中时间最早的第二随机数,从而保证第一验证表格中保存的所有数据都是最新的。
应理解,每个电池包和电动工具在出厂时均携带有唯一的识别码,电池包和电动工具在连接且握手成功后的握手信息交互中,可以交互各自的识别码,例如一个电池包与100个电动工具连接后,会存储这100个电动工具的识别码,以及每个电动工具对应的1000个第二随机数,当第101个电动工具与电池包连接时,电池包会采用第101个电动工具的信息替换第一个电动工具的信息,从而保证保存的电动工具为最新的工具。
进一步说明,本实施方式还提供一种失效判断机制,包括:
请参阅图16,在接收到某一个电动工具的第二握手信息后,电池包将解析出的第二随机数与第一验证表格中的数据相比较,若存在相同数据,则认为该第二随机数不符合失效机制,接入的该电动工具为非法接入,电池包断开与该电动工具的通信连接,停止输出第一数据和接收第二数据。若不存在相同数据,则认为该第二随机数符合失效机制,保存第二随机数到第一验证表格中,同时电池包与电动工具进行正常的数据交互,输出第一数据、接收第二数据,再根据接收的第二数据对电动工具进行放电。
应理解,电池包和电动工具进行数据交互时,是基于对方反馈的数据而实时更新的,即电池包输出的第一数据是基于电动工具反馈的第二握手信息及第二数据而生成的;相应的,电动工具输出的第二数据是基于电池包反馈的第一握手信息及第一数据而生成的。
可见,本实施方式分别在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据;此外,还对接收的随机数进行验证,若不符合失效机制,则认为接入的电动工具为非法接入,断开通信连接,避免了被仿制的可能性,极大地保障了用户的安全。
请参阅图17,本申请的第六实施方式涉及一种数据交互方法,该数据交互方法应用于电动工具,该电动工具具有通信功能,当该电动工具上连接有电池包时,可与电池包通过相匹配的通信接口进行通信连接,通信连接成功后电动工具可与电池包进行数据交互,以及通过电池包进行充电。为了保证数据交互的安全,本实施例中的交互数据是经过加密的,这样即使被第三方抓取,也无法获得真实的有效数据,避免被仿制。
本实施方式的加密通过握手阶段和正常通信阶段的两层加密来实现,
在握手阶段,电动工具上电后检测到接入的电池包,产生第二随机数,加密第二随机数和电动工具数据,得到第二握手信息并发送至电池包;接收到电池包反馈的第一握手信息,解密该第一握手信息,得到电池包数据和第一随机数。同时,电动工具还保存第一随机数至第三验证表格中,保存第二随机数至第四验证表格中。
在正常通信阶段,电动工具加密第二随机数和第二原始数据,得到第二数据并发送至电池包;接收到电池包反馈的第一数据,解密该第一数据,得到第一原始数据,电动工具根据该第一原始数据和电池包数据进行充电。
具体的说:
电动工具上电后,检测到有接入的电池包,与电池包进行通信握手,握手成功后产生一个第二随机数,并根据预设密钥,将电动工具数据和第二随机数加密为第二握手信息。其中,预设密钥为事先约定的,例如设定为“abcdef”,该预设密钥用于在握手阶段对通信数据进行加密和解密。在握手阶段,电动工具数据包括电动工具电压、电流等固定信息,电动工具将电动工具数据和此次产生的第二随机数打包加密后发送至电池包,电池包根据约定的预设密钥即可获取握手数据及第二随机数。
需要说明的是,该第二随机数为一个大于1的自然数,为了提高加密的复杂度,可适当加大第二随机数的数值,例如本实施例中,将第二随机数的产生范围设置为10000-99999。
此外,电动工具与电池包每次握手成功后,都会产生一个第二随机数,为了确保第二 随机数的唯一性,电动工具将产生的第二随机数保存至预设的第四验证表格中,并且在每次存储第二随机数前,会将本次产生的第二随机数与第四验证表格中的数据相比较,若存在相同数据,则舍弃该第二随机数,重新生成一个第二随机数,直至生成的第二随机数为一个新的数值。
为了降低内存,可在满足需要的情况下限定第四验证表格中的数据数量,例如本实施例中设定的数据数量为1000个,即第四验证表格中可保存1000个第二随机数,并且各第二随机数按照时间顺序排列,当数据数量大于1000时,采用此次产生的第二随机数替换第四验证表格中时间最早的第二随机数,从而保证第四验证表格中保存的所有数据都是最新的。
继续说明,握手完成后,电动工具和电池包正常通信,进行数据传输,电动工具输出第二数据和第二握手信息,并接收输入的第一数据,再根据第一数据进行充电。
具体的说,电动工具根据预设第一规则,将第二原始数据和第二随机数组合后加密成第二数据。应理解,第二原始数据为电动工具实时的充电参数,包括充电电压、充电电流、温度等。其中,根据预设第一规则,将第二原始数据和第二随机数组合后加密成第二数据的步骤包括:
请参阅图18,按照预设顺序,将第二随机数分成单个字节,将每个字节按照预设顺序,分别插入第二原始数据中,从而在第二原始数据中加入第二随机数;再通过预设加密算法,对加入第二随机数的第二原始数据进行加密,得到第二数据。
例如,电动工具的第二原始数据为D0’=0x06,0x05,0x04,0x03,0x02,0x01;生成的第一随机数为98734,对应的5个字节为:0x09,0x08,0x07,0x03,0x04;按照预设顺序,将第二随机数的每个字节插入第二原始数据中,其中,预设顺序可以为将第二随机数的每个字节从前到后的顺序,间隔插入第二原始数据中,得到数据D1’=0x06,0x09,0x05,0x08,0x04,0x07,0x03,0x03,0x02,0x04,0x01;应理解,预设顺序可根据需要进行设置,除了上述隔数放入外,还可将第二随机数先按照一定规律组合后,再插入第二原始数据中。
继续说明,通过预设加密算法,对上述得到的数据D1’进行加密,得到第二数据;其中,本实施例中的预设加密算法可以选择DES加密算法,电池包接收到该第二数据,通过 DES解密算法,并按照预设顺序提取出第二随机数,即可获取第二原始数据。
继续说明,电动工具接收到第一数据,根据预设第二规则,将第一数据解析成第一原始数据,根据第一原始数据进行充电。
请参阅图19,根据预设第二规则,将第一数据解析成第一原始数据的步骤包括:
通过预设解密算法,将第一数据解密为加入了第一随机数的第一原始数据;按照预设顺序,将第一随机数和第一原始数据分离,得到第一原始数据;按照预设顺序,从加入了第一随机数的第一原始数据中将第一随机数的每个字节提取出来,得到第一原始数据。应理解,此处的第一数据为电池包传输的放电参数,该放电参数经过上述电动工具中的充电参数类似的加密方式,再传输至电动工具。为方便操作,本实施例中电动工具和电池包进行加密时所采用的预设顺序和预设加密算法均相同,实际使用时,可在实现约定下,采用不同的顺序和加密算法。
电动工具在通信过程中,还接收到电池包传输的第一握手信息,电动工具根据预设密钥解密第一握手信息,得到第一随机数,并按照时间顺序将第一随机数保存到预设的第三验证表格中;当第三验证表格中的数据数量大于预设第三数量时,采用此次接收的第一随机数替换第三验证表格中时间最早的第一随机数。为了降低内存,可在满足需要的情况下限定第三验证表格中的数据数量,例如本实施例中设定的数据数量为1000个,即第三验证表格中可保存1000个第一随机数,并且各第一随机数按照时间顺序排列,当数据数量大于1000时,采用此次产生的第一随机数替换第三验证表格中时间最早的第一随机数,从而保证第三验证表格中保存的所有数据都是最新的。
应理解,每个电池包和电动工具在出厂时均携带有唯一的识别码,电动工具和电池包在连接且握手成功后的握手信息交互中,可以交互各自的识别码,例如一个电动工具与100个电池包连接后,会存储这100个电池包的识别码,以及每个电池包对应的1000个第一随机数,当第101个电池包与电动工具连接时,电动工具会采用第101个电池包的信息替换第一个电池包的信息,从而保证保存的电池包为最新。
进一步说明,本实施方式还提供一种失效判断机制,包括:
请参阅图20,在接收到某一个电池包的第一握手信息后,电动工具将解析出的第一随机数与第三验证表格中的数据相比较,若存在相同数据,则认为该第一随机数不符合失效 机制,接入的该电池包为非法接入,电动工具断开与该电池包的通信连接,停止输出第二数据和接收第一数据。若不存在相同数据,则认为该第一随机数符合失效机制,保存第一随机数到第三验证表格中,同时电动工具与电池包进行正常的数据交互,输出第二数据、接收第一数据,再根据接收的第一数据通过电池包进行充电。
可见,本实施方式分别在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据;此外,还对接收的随机数进行验证,若不符合失效机制,则认为接入的电池包为非法接入,断开通信连接,避免了被仿制的可能性,极大地保障了用户的安全。
请请参阅图21,本申请的第七实施方式涉及一种数据交互系统,包括可拆卸连接的电池包和电动工具。该电池包和电动工具均具有通信功能,当两者相连接时,可通过相匹配的通信接口进行通信连接,通信成功后进行数据交互,并基于交互的数据进行充放电。
具体的说,电池包上电后,检测到有接入的电动工具,与电动工具进行通信握手,握手成功后产生一个第一随机数,根据预设密钥,将电池包数据和第一随机数加密为第一握手信息,并输出至电动工具。相应的,电动工具上电后,检测到有接入的电池包,与电池包进行通信握手,握手成功后产生一个第二随机数,并根据预设密钥,将电动工具数据和第二随机数加密为第二握手信息,并输出至电池包。
电池包根据预设密钥,将第二握手信息解密后得到第二随机数,并按照时间顺序将第二随机数保存至预设的第一验证表格中,当第一验证表格中的数据数量大于预设第一数量时,采用此次接收的第二随机数替换所述第一验证表格中时间最早的第二随机数。
电动工具根据预设密钥,将第一握手信息解密后得到第一随机数,并按照时间顺序将第一随机数保存至预设的第三验证表格中,当第三验证表格中的数据数量大于预设第三数量时,采用此次接收的第一随机数替换所述第三验证表格中时间最早的第一随机数。
此外,电池包在保存第二随机数前,还将第二随机数与第一验证表格相比较,若存在相同数据,则认为接入的电动工具为非法接入,电池包断开与电动工具的通信连接。相应的,电动工具在保存第一随机数前,还将第一随机数与第三验证表格相比较,若存在相同数据,则认为接入的电池包为非法接入,电动工具断开与电池包的通信连接。
进一步说明,电池包还将产生的第一随机数与预设的第二验证表格中的数据相比较, 若存在相同数据,则重新生成一个第一随机数;否则,按照时间顺序将此次产生的第一随机数保存到第二验证表格中,当第二验证表格中的数据数量大于预设第二数量时,采用此次产生的第一随机数替换第二验证表格中时间最早的第一随机数。
相应的,电动工具还将产生的第二随机数与预设的第四验证表格中的数据相比较,若存在相同数据,则重新生成一个第二随机数;否则,按照时间顺序将此次产生的第二随机数保存到第四验证表格中,当第四验证表格中的数据数量大于预设第四数量时,采用此次产生的第二随机数替换第四验证表格中时间最早的第二随机数。
继续说明,若电池包根据接收的第二随机数判断接入的电动工具合法,则与电动工具进行正常的数据交互,输出第一数据、接收第二数据,并根据第二数据对电动工具进行放电,具体的说:
电池包根据预设第一规则,将第一原始数据和第一随机数组合后加密成第一数据,其中,生成第一数据具体的步骤包括:按照预设顺序,将第一随机数分成单个字节,将每个字节按照预设顺序,分别插入第一原始数据中,从而在第一原始数据中加入第一随机数;再通过预设加密算法,对加入第一随机数的第一原始数据进行加密,得到第一数据。
同时,电池包接收到第二数据,根据预设第二规则,将第二数据解析成第二原始数据,其中,获取第二原始数据具体的步骤包括:通过预设解密算法,将第二数据解密为加入了第二随机数的第二原始数据;按照预设顺序,将第二随机数和第二原始数据分离,得到第二原始数据;按照预设顺序,从加入了第二随机数的第二原始数据中将第二随机数的每个字节提取出来,得到第二原始数据。
电池包根据第二原始数据,对电动工具进行放电。
相应的,若电动工具根据接收的第一随机数判断接入的电池包合法,则与电池包进行正常的数据交互,输出第二数据、接收第一数据,并根据第一数据通过电池包进行充电,具体的说:
电动工具根据预设第一规则,将第二原始数据和第二随机数组合后加密成第二数据,其中,生成第二数据具体的步骤包括:按照预设顺序,将第二随机数分成单个字节,将每个字节按照预设顺序,分别插入第二原始数据中,从而在第二原始数据中加入第二随机数;再通过预设加密算法,对加入第二随机数的第二原始数据进行加密,得到第二数据。
同时,电动工具接收到第一数据,根据预设第二规则,将第一数据解析成第一原始数据,其中,获取第一原始数据具体的步骤包括:通过预设解密算法,将第一数据解密为加入了第一随机数的第一原始数据;按照预设顺序,将第一随机数和第一原始数据分离,得到第一原始数据;按照预设顺序,从加入了第一随机数的第一原始数据中将第一随机数的每个字节提取出来,得到第一原始数据。
电动工具根据第一原始数据,通过电池包进行充电。
可见,本实施方式分别在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据;此外,还对接收的随机数进行验证,若不符合失效机制,则认为接入的电池包或电动工具为非法接入,断开通信连接,避免了被仿制的可能性,极大地保障了用户的安全。
综上所述,本申请的一种数据交互方法及系统,分别在握手阶段和通信阶段对数据进行两层加密,保证了交互数据的安全性,即使交互数据被第三方抓取,也无法获得真实的有效数据;此外,还对接收的随机数进行验证,若不符合失效机制,则认为接入的电池包或电动工具为非法接入,断开通信连接,避免了被仿制的可能性,极大地保障了用户的安全。所以,本申请有效克服了现有技术中的种种缺点而具高度产业利用价值。
针对目前电池包与电动工具之间一般采用单总线高低电平的通信方式,这个方式容易被人截取通信内容,进行暴力破解,从而轻松仿制公司电池包产品,的问题,本申请公开了一种在数据交互过程的通信防伪方式及系统,通过生成校验信息,并存储在电池包的存储器中,电动工具与电池包在进行通信(正常数据交互)前,先从存储器中读取校验信息对其进行校验,校验成功才与电池包进行数据交互,否则停止与电池包的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制,详见下文中第八-第十实施方式中描述的技术方案,第八-第十实施方式中各实施方式的技术方案也可应用于上述第一-第七实施方式中各实施方式的技术方案中。
请参阅图22,本申请的第八实施方式涉及一种数据交互的通信防伪系统,包括可拆卸连接的电动工具100和电池包200,应理解,本实施例中的电动工具100和电池包200均具有通信功能,且两者可通过相匹配的通信接口实现通信连接。
电动工具100包括第一处理器101(也称为工具微控单元),当电动工具100与电池包 200相连接时,第一处理器101与电池包200通信连接,从电池包200获取校验信息,并进行校验,若校验成功,则与电池包200进行正常的数据交互,否则,认为是非正常接入,断开与电池包200的通信连接。
电池包200包括存储器201,用于存储校验信息,应理解,存储器201为具有通信功能的存储芯片,例如eID芯片。
需要说明的是,校验信息是根据系统时间随机生成的,在一个可行的实施例中,预先根据系统时间随机生成一个校验信息,并存储在电池包200的存储器201中,当电动工具100插入电池包200时,从存储器201中读取该校验信息,并根据约定规则对其进行解析。在另一个可行的实施例中,还可以在电动工具100插入电池包200时,根据系统时间实时生成一个校验信息,电动工具100获取该实时生成的校验信息后,根据约定规则对其进行解析。
应理解,校验信息可以由外部设备生成后存储在电池包200的存储器201中,也可以是电池包200自身生成的。当校验信息由电池包200自身生成时,电池包200还包括第二处理器202(电池包微控单元),第二处理器202与存储器201通信连接,用于生成校验信息并存储在存储器201中。当电池包200上插入电动工具100并被激活后,电动工具的第一处理器101与第二处理器202通信连接,并从存储器201中读取该校验信息。
以下详细说明:
当电动工具100插入电池包200时,电池包200被唤醒,第一处理器101与电池包200建立通信连接,访问存储器201,从存储器201的特定地址中读取第一数组,对其进行校验,若校验成功,则与电池包200进行正常的数据交互,否则,停止与电池包200的通信连接,其中,第一处理器101校验第一数组的步骤包括:
判断第一数组是否存在预设的校验字符,若存在,截取第一数组中的第一密钥和第一密文,按照预设规则,根据第一密钥生成第二密文,匹配第二密文和第一密文,匹配成功,则认为校验成功。
进一步说明,第一数组是随机生成并存储于电池包200的存储器201中,本实施例中,以电池包200的第二处理器202生成第一数组来进行说明,生成步骤包括:
第二处理器202基于系统时间随机生成第一密钥,按照预设规则,根据第一密钥生成 第一密文,按照预设顺序组合所述第一密钥、所述第一密文和预设的校验字符,得到第一数组。
具体的说,系统时间可以为当前时间,也可以是用户选定的某一特定时间,第二处理器202将该系统时间换算成时间戳,生成对应的第一密钥,其中,根据时间生成密钥为现有技术中的常规手段,有成熟的实施方式,例如,本实施例中,可采用哈希加密算法,基于系统时间生成对应的第一密钥。
第二处理器202按照预设规则,将第一密钥映射为第一密文,其中,预设规则为第一密钥与第一密文之间的映射关系,可根据需要进行设定,例如将第一密钥乘以一个特定系数,得到第一密文。
第二处理器202按照预设顺序,将第一密钥、第一密文和预设的校验字符组合成第一数组,并将第一数组写入存储器201中。
应理解,第一密钥、第一密文和预设的校验字符的位数可以相同,也可以不同,实际使用时可根据需要进行设定。
在一个可行的实施例中,第二处理器202根据当前时间换算的时间戳,进而生成N位的第一密钥,并记第一位密钥为N0,第二位密钥为N1,…最后一位密钥为Nn
再将生成的N位第一密钥通过预设规则计算得到M位第一密文,例如第一位密文M0=N0+N1+…+Nn,第二位密文M1=N0+N1+…+Nn-1,…最后一位密文Mm=N0
再按照预设顺序,将第一密钥、第一密文和预设的校验字符相组合,例如,按照N位第一密钥+M位第一密文+Y位校验字符的顺序,且本实施例中的Y位校验字符可设定为“ABC”,最终组成一个N+M+Y位的第一数组。相应的,当第一处理器101校验第一数组时,根据预设顺序,即可提取出校验字符来进行比对,并可截取第一数组中的第一密钥和第一密文。
第二处理器202将这个N+M+Y位的第一数组存入存储器201的特定地址中。
进一步说明,为了确保存入数据的正确性,在存入第一数组后,第二处理器202还从存储器201中重新读取存入的第一数组,将重新读取的第一数组与存入的第一数组相匹配,若匹配成功,则认为存储器中保存的第一数组无误,可以使用;否则,重新写入第一数组到存储器201中,将错误的数据替换掉。
继续说明,在第一处理器101读取第一数组后,本实施例中,第一数组为一个N+M+Y位的数组,且预设的校验字符为“ABC”,先判断第一数组中是否存在“ABC”,若存在,则进一步截取第一数组中的N位第一密钥和M位第一密文,并按照预设规则,根据第一密钥生成第二密文,应理解,此处的预设规则应与上述第二处理器202所使用的预设规则相同。
将第二密文与第一数组中的M位第一密文相匹配,若匹配成功,则认为第一处理器101从存储器201中读取的数据即为第一处理器102存入的第一数组,即校验成功,可以正常工作,并进行数据交互;否则,认为电池包200和电动工具100的连接为非正常接入,为防止被暴力破解,应立即断开两者间的通信连接。
应理解,上述实施例中的第一处理器101与第二处理器202、存储器201之间,以及第二处理器202和存储器201之间,采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将第一处理器101、第二处理器202和存储器201的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经第一处理器101处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给第一处理器101、第二处理器202。
第一处理器101、第二处理器202负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理、充放电管理以及其他控制功能。而存储器201还可以被用于存储第二处理器202在执行操作时所使用的数据。
可见,本实施方式生成校验信息,并存储在电池包200的存储器201中,电动工具100与电池包200通信前,先从存储器201中读取校验信息对其进行校验,校验成功才与电池包200进行数据交互,否则停止与电池包200的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制。此外,本申请借助存储器201实现防伪功能,无需改变现有的电路结构,降低了成本。
请参阅图23,本申请的第九实施方式涉及一种通信防伪方法,该通信防伪方法应用于 电动工具100,且电动工具100与电池包200可拆卸连接,包括:
步骤S201,读取电池包200的存储器内的第一数组。
步骤S202,校验第一数组。
步骤S203,判断校验是否成功,若校验成功,则正常工作,与电池包200进行数据交互;否则,停止与电池包200的通信连接。
具体的说,步骤S201中,当电动工具100插入电池包200时,电池包200被唤醒,与电动工具100建立通信连接,访问存储器201,从存储器201的特定地址中读取第一数组。
步骤S202中,该第一数组即为电动工具100与电池包200的校验信息,若校验成功,则认为电动工具100与电池包200正常连接,可以正常工作;否则,认为是非正常接入,应立即停止工作,避免被暴力破解。
请参阅图24,校验第一数组的步骤包括:
步骤S301,判断第一数组是否存在预设的校验字符。
具体的说,判断第一数组是否存在第一实施方式中设定的校验字符“ABC”。应理解,实际使用时可根据需要设置不同的校验字符。
步骤S302,若存在,截取第一数组中的第一密钥和第一密文。
具体的说,第一数组中的第一密钥、第一密文及校验字符是按照预设顺序进行排列,相应的,截取时,按照预设顺序,即可截取第一数组中的第一密钥和第一密文。
步骤S303,根据第一密钥生成第二密文。
具体的说,按照预设规则,根据第一密钥生成第二密文,应理解,此处的预设规则应与第一实施方式中第二处理器202所使用的预设规则相同,例如将截取的第一密钥乘以一个特定系数,得到第二密文。
步骤S304,匹配第二密文和第一密文,即判断第一密文和第二密文是否相同,若相同,则匹配成功,即校验成功,可以正常通信。
具体的说,逐步比较第一密文和第二密文,若每个字符均相同,则认为两者匹配成功。
请参阅图25,在另一实施例中,本申请第九实施方式的数据交互的通信防伪方法在图23所示的基础上进行了改进,包括:
步骤S401,读取电池包200的存储器内的第一数组。
步骤S402,校验第一数组。
步骤S403,判断校验是否成功,若校验成功,则正常工作,与电池包200进行数据交互。否则,停止与电池包200的通信连接。
步骤S404,在校验失败后,再次读取存储器内的第一数组,并对其进行校验,若校验成功,则正常工作,与电池包200进行数据交互;否则,停止与电池包200的通信连接。在另一实施例中,还可以多次读取存储器内的第一数组,并记录对存储器的读取次数,同时对读取的第一数组进行校验,若在预设次数内校验成功,则正常工作,与电池包200进行数据交互,若在预设次数内均检验失败,则停止与电池包200的通信连接。
可见,本实施方式生成校验信息,并存储在电池包200的存储器201中,电动工具100与电池包200通信前,先从存储器201中读取校验信息对其进行校验,校验成功才与电池包200进行数据交互,否则停止与电池包200的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制。此外,本申请借助存储器201实现防伪功能,无需改变现有的电路结构,降低了成本。
请参阅图26,本申请的第十实施方式涉及一种数据交互的通信防伪方法,该通信防伪方法应用于电池包200,且电池包200与电动工具100可拆卸连接,包括:
步骤S501,预存第一数组,该第一数组用于电池包200与电动工具100之间的校验。
步骤S502,判断是否接收到电动工具100发送的校验请求,若接收到,则执行步骤S503。
步骤S503,发送第一数组到电动工具100,供电动工具100校验。
步骤S504,判断是否接收到电动工具100发送的指示信息,该指示信息用于向所述电池包指示校验是否成功,若成功,则执行步骤S505。
步骤S505,与电动工具100进行数据交互。
请参阅图27,第一数组是随机生成并存储于电池包200的存储器201中,可以由外部设备生成后存储在电池包200的存储器201中,也可以是电池包200自身生成。其中,第一数组的生成步骤包括:
步骤S601,基于系统时间随机生成第一密钥。
具体的说,系统时间可以为当前时间,也可以是用户选定的某一特定时间,将该系统 时间换算成时间戳,并生成对应的第一密钥,其中,根据时间生成密钥为现有技术中的常规手段,有成熟的实施方式,例如,本实施例中,可采用哈希加密算法,基于系统时间生成对应的第一密钥。
步骤S602,根据第一密钥生成第一密文。
具体的说,可按照预设规则,将第一密钥映射为第一密文,其中,预设规则为第一密钥与第一密文之间的映射关系,可根据需要进行设定,例如将第一密钥乘以一个特定系数,得到第一密文。
步骤S603,按照预设顺序组合第一密钥、第一密文和预设的校验字符,得到第一数组。
具体的说,第一密钥、第一密文和预设的校验字符均为多位的字符串,其位数可以相同,也可以不同,实际使用时可根据需要进行设定。
例如,根据系统时间生成N位第一密钥,并记第一位密钥为N0,第二位密钥为N1,…最后一位密钥为Nn
再将生成的N位第一密钥通过预设规则计算得到M位第一密文,例如第一位密文M0=N0+N1+…+Nn,第二位密文M1=N0+N1+…+Nn-1,…最后一位密文Mm=N0
再按照预设顺序,将第一密钥、第一密文和预设的校验字符相组合,例如,按照N位第一密钥+M位第一密文+Y位校验字符的顺序,且本实施例中的Y位校验字符可设定为“ABC”,最终组成一个N+M+Y位的第一数组。
步骤S604,写入第一数组到电池包200的存储器中。
具体的说,将上述N+M+Y位的第一数组存入存储器201的特定地址中。
请参阅图28,在另一实施例中,本申请中第一数组的生成步骤在图27所示的基础上进行了改进,包括:
步骤S701,基于系统时间随机生成第一密钥。
步骤S702,根据第一密钥生成第一密文。
步骤S703,按照预设顺序组合第一密钥、第一密文和预设的校验字符,得到第一数组。
步骤S704,写入第一数组到电池包200的存储器中。
步骤S705,在写入第一数组到电池包200的存储器后,重新读取存入的第一数组,将重新读取的第一数组与存入的第一数组相匹配,若匹配成功,则认为存储器中保存的第一 数组无误,可以使用;否则,重新写入第一数组到存储器中,将错误的数据替换掉。
可见,本实施方式生成校验信息,并存储在电池包200的存储器201中,电动工具100与电池包200通信前,先从存储器201中读取校验信息对其进行校验,校验成功才与电池包200进行数据交互,否则停止与电池包200的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制。此外,本申请借助存储器201实现防伪功能,无需改变现有的电路结构,降低了成本。
综上所述,本申请的数据交互的通信防伪方法及系统,通过生成校验信息,并存储在电池包200的存储器201中,电动工具100与电池包200通信前,先从存储器201中读取校验信息对其进行校验,校验成功才与电池包200进行数据交互,否则停止与电池包200的通信,降低了通信内容被截取的分析,防止电池包产品被轻松仿制。此外,本申请借助存储器201实现防伪功能,无需改变现有的电路结构,降低了成本。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。
以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。

Claims (20)

  1. 一种数据交互方法,其特征在于,应用于电池包与电动工具之间的数据交互,所述电池包与所述电动工具共用同一物理通信通道进行通信,所述电池包和所述电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式;
    所述数据交互方法包括:
    所述电池包与所述电动工具进行握手通信;
    当所述电池包与所述电动工具握手通信失败时,所述电池包和所述电动工具中具有两种通信方式的一个将自身当前的通信方式切换为另一种通信方式;
    重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功;
    所述电池包与所述电动工具进行数据传输。
  2. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包包括一种通信方式,所述电动工具包括两种通信方式;
    所述电池包与所述电动工具进行握手通信包括:
    所述电池包向所述电动工具发送握手报文;
    当所述电动工具在第一预设时间内收到所述握手报文,则向所述电池包回复约定报文,当所述电池包收到所述电池工具回复的所述约定报文时,则表示所述电池包与所述电动工具握手通信成功;
    当所述电动工具在所述第一预设时间未内收到所述握手报文,则表示所述电池包与所述电动工具握手通信失败;当所述电池包与所述电动工具握手通信失败时,所述电动工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
  3. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包包括两种通信方式,所述电动工具包括一种通信方式;
    所述电池包与所述电动工具进行握手通信包括:
    所述电池包向所述电动工具发送握手报文并记录握手报文发送次数;
    当所述电池包在所述握手报文发送的预设次数内收到所述电动工具回复的约定报文时,则表示所述电池包与所述电动工具握手通信成功;
    当所述电池包在所述握手报文发送的预设次数内未收到所述电动工具回复的约定报文时,则表示所述电池包与所述电动工具握手通信失败;
    当所述电池包与所述电动工具握手通信失败时,所述电池包将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
  4. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包和所述电动工具分别具有至少两种通信方式;
    所述电池包与所述电动工具进行握手通信包括:
    所述电池包向所述电动工具发送握手报文,所述电动工具收到所述握手报文,则向所述电池包回复约定报文;
    当所述电池包在第二预设时间内收到所述约定报文,则表示所述电池包与所述电动工具握手通信成功,而当所述电动工具未在所述第二预设时间内收到所述握手报文,则表示所述电池包与所述电动工具握手通信失败;
    当所述电池包与所述电动工具握手通信失败时,则所述电池包或所述电池工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
  5. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包和所述电动工具分别具有至少两种通信方式;
    所述电池包与所述电动工具进行握手通信包括:
    所述电池包向所述电动工具发送握手报文,所述电动工具收到所述握手报文,则向所述电池包回复约定报文;
    当所述电池包连续两次接收所述电动工具回复的所述约定报文,并且两次接收所述约 定报文的时间小于预设间隔,则表示所述电池包与所述电动工具握手通信成功,否则,则表示所述电池包与所述电动工具握手通信失败;
    当所述电池包与所述电动工具握手通信失败时,则所述电池包或所述电池工具将自身当前的通信方式切换为另一种通信方式;重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功。
  6. 根据权利要求4或5所述的数据交互方法,其特征在于,所述电池包与所述电动工具进行数据传输包括:
    所述电池包与所述电动工具以握手通信成功时的通信方式进行数据传输;或
    所述电池包与所述电动工具将握手通信成功时的通信方式切换为另一种通信方式进行数据传输。
  7. 根据权利要求6所述的数据交互方法,其特征在于,所述电池包和所述电动工具分别至少具有单总线通信方式和串行总线通信方式;
    所述电池包与所述电动工具进行数据传输包括:
    当所述电池包与所述电动工具通过所述串行总线通信方式握手通信成功,所述电池包与所述电动工具以所述串行总线通信方式进行数据传输;
    当所述电池包与所述电动工具通过所述单总线通信方式握手通信成功时,所述电池包与所述电动工具先将通信方式由所述单总线通信方式切换为所述串行总线通信方式,然后在进行数据传输。
  8. 根据权利要求1所述的数据交互方法,其特征在于,所述数据交互方法还包括,当所述电池包与所述电动工具数据传输完毕后,所述电池包与所述电动工具将通信方式设置为各自默认的通信方式。
  9. 根据权利要求1所述的数据交互方法,其特征在于,在所述电池包与所述电动工具进 行握手通信时:
    所述电池包检测到接入的所述电动工具,产生一个第一随机数,根据预设密钥,将电池包数据和第一随机数加密为第一握手信息,输出第一握手信息到所述电动工具;
    所述电池包接收所述电动工具反馈的第二握手信息,根据预设密钥,解密第二握手信息,得到电动工具数据和第二随机数;
    所述电池包与所述电动工具进行数据传输,包括:
    所述电池包根据预设第一规则,将第一原始数据和所述第一随机数组合后加密成第一数据,输出第一数据到所述电动工具;
    所述电池包接收所述电动工具反馈的第二数据,根据预设第二规则,将所述第二数据解析成第二原始数据,根据所述第二原始数据和所述电动工具数据进行放电。
  10. 根据权利要求9所述的数据交互方法,其特征在于,所述电池包根据预设第一规则,将所述第一原始数据和所述第一随机数组合后加密成第一数据,包括:
    所述电池包按照预设顺序,在所述第一原始数据中加入所述第一随机数;
    所述电池包通过预设加密算法,对加入所述第一随机数的所述第一原始数据进行加密,得到所述第一数据。
  11. 根据权利要求10所述的数据交互方法,其特征在于,所述电池包按照预设顺序,在所述第一原始数据中加入所述第一随机数的步骤包括:
    所述电池包将所述第一随机数分成单个字节,将每个字节按照预设顺序,分别插入所述第一原始数据中。
  12. 根据权利要求10所述的数据交互方法,其特征在于,所述电池包接收所述电动工具反馈的第二数据,根据预设第二规则,将所述第二数据解析成第二原始数据,包括:
    所述电池包接收所述电动工具反馈的第二数据,通过预设解密算法,将所述第二数据解密为加入了所述第二随机数的所述第二原始数据;
    所述电池包按照预设顺序,将所述第二随机数和所述第二原始数据分离,得到所述第 二原始数据。
  13. 根据权利要求9所述的数据交互方法,其特征在于,所述数据交互方法还包括:
    所述电池包按照时间顺序将所述第二随机数保存到预设的第一验证表格中;
    当所述第一验证表格中的数据数量大于预设第一数量时,采用此次接收的所述第二随机数替换所述第一验证表格中时间最早的所述第二随机数。
  14. 根据权利要求13所述的数据交互方法,其特征在于,所述数据交互方法还包括:
    所述电池包将所述第二随机数与所述第一验证表格中的数据相比较,若存在相同数据,则认为接入的所述电动工具为非法接入,所述电池包断开与所述电动工具的通信连接。
  15. 根据权利要求9所述的数据交互方法,其特征在于,所述数据交互方法还包括:
    所述电池包将产生的所述第一随机数与预设的第二验证表格中的数据相比较,若存在相同数据,则重新生成一个所述第一随机数;
    否则,按照时间顺序将此次产生的所述第一随机数保存到所述第二验证表格中,当所述第二验证表格中的数据数量大于预设第二数量时,采用此次产生的所述第一随机数替换所述第二验证表格中时间最早的所述第一随机数。
  16. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包与所述电动工具进行数据传输的步骤之前还包括:
    所述电动工具读取所述电池包的存储器内的第一数组;
    所述电动工具校验所述第一数组,校验成功,则与所述电池包进行数据传输,否则,停止与所述电池包的通信连接;
    其中,所述电动工具校验所述第一数组的步骤包括:
    所述电动工具判断所述第一数组是否存在预设的校验字符,
    若存在,所述电动工具截取所述第一数组中的第一密钥和第一密文,根据所述第一密钥生成第二密文,匹配所述第二密文和所述第一密文,匹配成功,则认为校验成功。
  17. 根据权利要求1所述的数据交互方法,其特征在于,所述电池包与所述电动工具进行数据传输之前还包括:
    所述电池包预存用于校验的第一数组;
    所述电池包接收到所述电动工具发送的校验请求,发送所述第一数组到所述电动工具,所述校验请求是在所述电池包检测到有所述电动工具接入时所触发发送的;
    所述电池包接收来自所述电动工具的指示信息,其中,所述指示信息用于向所述电池包指示校验是否成功,若成功,则与所述电动工具进行数据交互。
  18. 一种数据交互方法,其特征在于,应用于电池包与电动工具之间的数据交互,所述电池包与所述电动工具共用同一物理通信通道进行通信,所述电池包和所述电动工具分别至少具有两种通信方法;
    所述数据交互方法包括:
    所述电池包与所述电动工具通过一种通信方式进行握手通信;
    当所述电池包与所述电动工具握手通信成功时,所述电池包和所述电动工具分别将通信方式由握手通信成功时的通信方式切换为另一种通信方式。
  19. 根据权利要求18所述的数据交互方法,其特征在于,所述另一种通信方式具备大数据传输能力和高传输速率。
  20. 一种数据交互系统,其特征在于,所述数据交互系统包括:
    电动工具;
    电池包,所述电池包与所述电动工具共用同一物理通信通道进行通信;
    所述电池包和所述电动工具中的一个至少具有一种通信方式,另一个至少具有两种通信方式,所述电池包和所述电动工具中的通信方式所对应的通信单元与各自的微控单元连接;
    所述电动工具与所述电池包被配置通过以下方式进行数据交互:
    所述电池包与所述电动工具进行握手通信;
    当所述电池包与所述电动工具握手通信失败时,所述电池包和所述电动工具中具有两种通信方式的一个将自身当前的通信方式切换为另一种通信方式;
    重新执行所述电池包与所述电动工具进行握手通信,直至所述电池包与所述电动工具握手通信成功;
    所述电池包与所述电动工具进行数据传输。
PCT/CN2023/074757 2022-02-08 2023-02-07 一种数据交互方法及系统 WO2023151553A1 (zh)

Applications Claiming Priority (6)

Application Number Priority Date Filing Date Title
CN202210123150.6 2022-02-08
CN202210123150.6A CN116611079A (zh) 2022-02-08 2022-02-08 一种通信防伪方法及系统
CN202210214304.2A CN116743356A (zh) 2022-03-04 2022-03-04 一种通信方法及系统
CN202210214304.2 2022-03-04
CN202210695560.8 2022-06-16
CN202210695560.8A CN117294547A (zh) 2022-06-16 2022-06-16 一种数据交互方法及系统

Publications (1)

Publication Number Publication Date
WO2023151553A1 true WO2023151553A1 (zh) 2023-08-17

Family

ID=87563608

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/074757 WO2023151553A1 (zh) 2022-02-08 2023-02-07 一种数据交互方法及系统

Country Status (1)

Country Link
WO (1) WO2023151553A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104155971A (zh) * 2014-08-07 2014-11-19 北京九五智驾信息技术股份有限公司 一种车辆诊断仪对车辆诊断仪协议的自诊断方法
JP2017140686A (ja) * 2016-02-12 2017-08-17 日立工機株式会社 電動工具、電池パック及び電動工具システム
CN111130750A (zh) * 2018-10-30 2020-05-08 长城汽车股份有限公司 车辆can安全通信方法及系统
CN112510793A (zh) * 2020-12-16 2021-03-16 沈阳顺义科技有限公司 一种蓄电池智能充电装置
CN213186158U (zh) * 2020-09-01 2021-05-11 重庆雅讯科技有限公司 通用电池协议接口电路及电池管理装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104155971A (zh) * 2014-08-07 2014-11-19 北京九五智驾信息技术股份有限公司 一种车辆诊断仪对车辆诊断仪协议的自诊断方法
JP2017140686A (ja) * 2016-02-12 2017-08-17 日立工機株式会社 電動工具、電池パック及び電動工具システム
CN111130750A (zh) * 2018-10-30 2020-05-08 长城汽车股份有限公司 车辆can安全通信方法及系统
CN213186158U (zh) * 2020-09-01 2021-05-11 重庆雅讯科技有限公司 通用电池协议接口电路及电池管理装置
CN112510793A (zh) * 2020-12-16 2021-03-16 沈阳顺义科技有限公司 一种蓄电池智能充电装置

Similar Documents

Publication Publication Date Title
US9596075B2 (en) Transparent serial encryption
CN101317166B (zh) 统一dma
CN111131278B (zh) 数据处理方法及装置、计算机存储介质、电子设备
CN101588236B (zh) 内容安全传输保护设备、系统以及内容安全传输方法
CN108809646A (zh) 安全共享密钥共享系统及方法
JPS6127751B2 (zh)
CN102081713B (zh) 一种用于防止数据泄密的办公系统
US7864954B2 (en) Method and system for encryption and authentication
CN108141364A (zh) 消息认证
CN112235107A (zh) 一种数据传输方法、装置、设备和存储介质
CN101931623B (zh) 一种适用于受控制端能力有限的远程控制的安全通信方法
WO2023151553A1 (zh) 一种数据交互方法及系统
CN107733936B (zh) 一种移动数据的加密方法
CN109960943A (zh) 一种密码设备
KR20050057400A (ko) 멀티플 매칭 제어 방법
CN111092860A (zh) 一种医疗数据安全交互传输模块
CN110213292A (zh) 数据发送方法及装置、数据接收方法及装置
CN112713992B (zh) 一种基于无证书的抗泄露认证与密钥协商方法及系统
CN102930229B (zh) 用于提高数据安全性的办公系统
CN114448607A (zh) 一种基于puf技术的离线设备安全认证系统及实现方法
CN112583580B (zh) 一种量子密钥的处理方法及相关设备
CN105024800A (zh) 随机安全通讯方法及蓝牙装置
Chen et al. Research and Application of Communication Security in Security and Stability Control System of Power Grid
CN107437638A (zh) 基于可变明文、可变密匙aes加密的电池保护系统
CN110636040B (zh) 一种基于区块链通信的信息流认证系统及方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23752333

Country of ref document: EP

Kind code of ref document: A1