Search

CN-119011648-B - Data transmission method, device, equipment and storage medium

CN119011648BCN 119011648 BCN119011648 BCN 119011648BCN-119011648-B

Abstract

The disclosure relates to a data transmission method, a device, equipment and a storage medium, wherein the method is applied to first electronic equipment and comprises the steps of responding to establishment of first connection with second electronic equipment based on initial connection parameters, determining whether the first connection meets data transmission conditions, responding to failure of the first connection to meet the data transmission conditions, determining target connection parameters, establishing second connection with the second electronic equipment based on the target connection parameters, and carrying out data transmission based on the second connection. The method and the device can realize automatic adaptation of the connection parameters, and further ensure smooth proceeding of data transmission and improve fluency of the data transmission process.

Inventors

  • LI MANMAN
  • KOU HAOTIAN
  • QIAN PING

Assignees

  • 北京小米移动软件有限公司

Dates

Publication Date
20260508
Application Date
20230522

Claims (14)

  1. 1. A data transmission method, applied to a first electronic device, the method comprising: Responsive to establishing a first connection with a second electronic device based on an initial connection parameter, determining whether the first connection satisfies a data transmission condition; determining a target connection parameter in response to the first connection not meeting the data transmission condition; Establishing a second connection with the second electronic equipment based on the target connection parameter, and transmitting data based on the second connection; wherein the determining the target connection parameter includes: selecting each set of alternative connection parameters from the plurality of sets of alternative connection parameters of the first set in turn, wherein the alternative connection parameters comprise connection parameters corresponding to a plurality of types of data lines; Establishing a third connection with the second electronic device based on each set of alternative connection parameters; performing a transmission test based on the third connection to obtain a transmission test result corresponding to each set of alternative connection parameters; and determining the target connection parameters from the plurality of sets of alternative connection parameters based on the transmission test results.
  2. 2. The method of claim 1, wherein the determining whether the first connection satisfies a data transmission condition comprises: And responding to receiving a first preset message, and determining that the first connection meets the data transmission condition, wherein the first preset message is used for indicating that the connection with the second electronic equipment is successful.
  3. 3. The method according to claim 1, wherein the performing a transmission test based on the third connection, to obtain a transmission test result corresponding to each set of alternative connection parameters, includes: transmitting a preset number of test messages to the second electronic equipment based on the third connection; receiving a reply message returned by the second electronic equipment based on the received test message; And determining a packet loss rate based on the preset number and a first number carried in the reply message, and taking the first number as a transmission test result corresponding to each set of alternative connection parameters, wherein the first number is used for representing the number of test messages received by the second electronic equipment.
  4. 4. The method according to claim 1, wherein the method further comprises: Generating prompt information for prompting to execute a connection parameter adaptation operation in response to the target connection parameter not being present in the multiple sets of alternative connection parameters of the first set, wherein the connection parameter adaptation operation is used for determining the target connection parameter from the multiple sets of alternative connection parameters of the second set based on a parameter traversal mode; And responding to the received operation execution instruction triggered based on the prompt information, and executing the connection parameter adaptation operation.
  5. 5. The method of claim 1, wherein the determining the target connection parameter comprises: generating prompt information for prompting to execute a connection parameter adaptation operation, wherein the connection parameter adaptation operation is used for determining the target connection parameter from a plurality of sets of alternative connection parameters of a second set based on a parameter traversing mode; And responding to the received operation execution instruction triggered based on the prompt information, and executing the connection parameter adaptation operation.
  6. 6. The method according to claim 4 or 5, characterized in that the method further comprises: Responding to a storage instruction of the target connection parameter, and creating a corresponding relation between the target connection parameter and equipment information of the second electronic equipment; And storing the target connection parameters in at least one of the first electronic equipment, the second electronic equipment and a server based on the corresponding relation.
  7. 7. A data transmission apparatus for use with a first electronic device, the apparatus comprising: A connection determining module for determining whether the first connection satisfies a data transmission condition in response to establishing a first connection with a second electronic device based on an initial connection parameter; A parameter determining module, configured to determine a target connection parameter in response to the first connection not meeting the data transmission condition; the data transmission module is used for establishing a second connection with the second electronic equipment based on the target connection parameter and transmitting data based on the second connection; wherein the parameter determination module comprises a first determination unit; The first determining unit is configured to: selecting each set of alternative connection parameters from the plurality of sets of alternative connection parameters of the first set in turn, wherein the alternative connection parameters comprise connection parameters corresponding to a plurality of types of data lines; Establishing a third connection with the second electronic device based on each set of alternative connection parameters; performing a transmission test based on the third connection to obtain a transmission test result corresponding to each set of alternative connection parameters; and determining the target connection parameters from the plurality of sets of alternative connection parameters based on the transmission test results.
  8. 8. The apparatus of claim 7, wherein the connection determination module is further configured to determine that the first connection satisfies the data transmission condition in response to receiving a first preset message, the first preset message indicating that the connection with the second electronic device is successful.
  9. 9. The apparatus of claim 7, wherein the first determining unit is further configured to: transmitting a preset number of test messages to the second electronic equipment based on the third connection; receiving a reply message returned by the second electronic equipment based on the received test message; And determining a packet loss rate based on the preset number and a first number carried in the reply message, and taking the first number as a transmission test result corresponding to each set of alternative connection parameters, wherein the first number is used for representing the number of test messages received by the second electronic equipment.
  10. 10. The apparatus of claim 7, wherein the first determining unit is configured to: generating prompt information for prompting to execute a connection parameter adaptation operation in response to the target connection parameter not being present in the multiple sets of alternative connection parameters, wherein the connection parameter adaptation operation is used for determining the target connection parameter from the multiple sets of alternative connection parameters in a second set based on a parameter traversal mode; And responding to the received operation execution instruction triggered based on the prompt information, and executing the connection parameter adaptation operation.
  11. 11. The apparatus of claim 7, wherein the parameter determination module comprises a second determination unit; The second determining unit is configured to: generating prompt information for prompting to execute a connection parameter adaptation operation, wherein the connection parameter adaptation operation is used for determining the target connection parameter from a plurality of sets of alternative connection parameters of a second set based on a parameter traversing mode; And responding to the received operation execution instruction triggered based on the prompt information, and executing the connection parameter adaptation operation.
  12. 12. The apparatus according to claim 10 or 11, further comprising a parameter preservation module; The parameter storage module comprises: A relationship creation unit, configured to create a correspondence between the target connection parameter and device information of the second electronic device in response to a save instruction of the target connection parameter; and the parameter storage unit is used for storing the target connection parameters in at least one of the first electronic equipment, the second electronic equipment and the server based on the corresponding relation.
  13. 13. An electronic device, the device comprising: A processor and a memory for storing a computer program; wherein the processor is configured to implement, when executing the computer program: Responsive to establishing a first connection with a second electronic device based on an initial connection parameter, determining whether the first connection satisfies a data transmission condition; determining a target connection parameter in response to the first connection not meeting the data transmission condition; Establishing a second connection with the second electronic equipment based on the target connection parameter, and transmitting data based on the second connection; wherein the determining the target connection parameter includes: selecting each set of alternative connection parameters from the plurality of sets of alternative connection parameters of the first set in turn, wherein the alternative connection parameters comprise connection parameters corresponding to a plurality of types of data lines; Establishing a third connection with the second electronic device based on each set of alternative connection parameters; performing a transmission test based on the third connection to obtain a transmission test result corresponding to each set of alternative connection parameters; and determining the target connection parameters from the plurality of sets of alternative connection parameters based on the transmission test results.
  14. 14. A computer readable storage medium having stored thereon a computer program, the program being embodied when executed by a processor: Responsive to establishing a first connection with a second electronic device based on an initial connection parameter, determining whether the first connection satisfies a data transmission condition; determining a target connection parameter in response to the first connection not meeting the data transmission condition; Establishing a second connection with the second electronic equipment based on the target connection parameter, and transmitting data based on the second connection; wherein the determining the target connection parameter includes: selecting each set of alternative connection parameters from the plurality of sets of alternative connection parameters of the first set in turn, wherein the alternative connection parameters comprise connection parameters corresponding to a plurality of types of data lines; Establishing a third connection with the second electronic device based on each set of alternative connection parameters; performing a transmission test based on the third connection to obtain a transmission test result corresponding to each set of alternative connection parameters; and determining the target connection parameters from the plurality of sets of alternative connection parameters based on the transmission test results.

Description

Data transmission method, device, equipment and storage medium Technical Field The disclosure relates to the technical field of electronic devices, and in particular relates to a data transmission method, a data transmission device and a storage medium. Background With the popularization of electronic devices such as tablet computers, smart phones, vehicle-mounted terminals, digital cameras, printers, etc., data transmission between these devices and computers, or between devices, is receiving more and more attention. In the related art, when the electronic device leaves the factory, a set of USB (Universal Serial Bus ) parameters is usually adapted to the standard data line and the test device, and the parameters are only suitable for the electronic device to be connected with the charger for charging through the standard data line, or for data transmission through interconnection of the standard data line and other devices. However, with increasing number of data lines and devices in the market, when electronic devices are interconnected with other devices through standard or non-standard data lines for data transmission, the electronic devices are prone to problems such as failure of interconnection of the sending devices (i.e., failure of the devices to identify), or interruption of data transmission after interconnection. Disclosure of Invention To overcome the problems in the related art, embodiments of the present disclosure provide a data transmission method, apparatus, device, and storage medium, which are used to solve the drawbacks in the related art. According to a first aspect of embodiments of the present disclosure, there is provided a data transmission method, applied to a first electronic device, the method including: Responsive to establishing a first connection with a second electronic device based on an initial connection parameter, determining whether the first connection satisfies a data transmission condition; determining a target connection parameter in response to the first connection not meeting the data transmission condition; And establishing a second connection with the second electronic equipment based on the target connection parameter, and carrying out data transmission based on the second connection. In some embodiments, the determining whether the first connection satisfies a data transmission condition includes: And responding to receiving a first preset message, and determining that the first connection meets the data transmission condition, wherein the first preset message is used for indicating that the connection with the second electronic equipment is successful. In some embodiments, the determining the target connection parameter includes: Selecting each set of alternative connection parameters in turn from the plurality of sets of alternative connection parameters of the first set; Establishing a third connection with the second electronic device based on each set of alternative connection parameters; performing a transmission test based on the third connection to obtain a transmission test result corresponding to each set of alternative connection parameters; and determining the target connection parameters from the plurality of sets of alternative connection parameters based on the transmission test results. In some embodiments, the performing a transmission test based on the third connection, to obtain a transmission test result corresponding to each set of alternative connection parameters, includes: transmitting a preset number of test messages to the second electronic equipment based on the third connection; receiving a reply message returned by the second electronic equipment based on the received test message; and determining a packet loss rate based on the preset number and a first number carried in the reply message, and taking the first number as a transmission test result corresponding to each set of alternative connection parameters, wherein the first number is used for representing the number of the test messages received by the second electronic equipment. In some embodiments, the method further comprises: Generating prompt information for prompting to execute a connection parameter adaptation operation in response to the target connection parameter not being present in the multiple sets of alternative connection parameters of the first set, wherein the connection parameter adaptation operation is used for determining the target connection parameter from the multiple sets of alternative connection parameters of the second set based on a parameter traversal mode; And responding to the received operation execution instruction triggered based on the prompt information, and executing the connection parameter adaptation operation. In some embodiments, the determining the target connection parameter includes: generating prompt information for prompting to execute a connection parameter adaptation operation, wherein the connection parameter adaptation operat