Connection method and device of external device, electronic device and storage medium
By acquiring the charging current and adjusting the current parameters according to the cause when communication between the electronic device and the external device is abnormally disconnected, the problem of low communication efficiency is solved, and rapid communication recovery is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- VIVO MOBILE COMM CO LTD
- Filing Date
- 2023-06-27
- Publication Date
- 2026-06-23
AI Technical Summary
Communication between electronic devices and external devices is inefficient and often results in communication failures.
When the communication connection is abnormally disconnected, the charging current between the electronic device and the external device before the disconnection is obtained, the current adjustment parameter is determined according to the cause of the abnormal disconnection, and the charging current is adjusted to restore the communication connection.
It improves the communication efficiency between electronic devices and external devices, ensuring rapid restoration of communication connections.
Smart Images

Figure CN116737633B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communications, and specifically relates to a connection method, apparatus, electronic device, and storage medium for an external device. Background Technology
[0002] When an electronic device is connected to an external device that requires communication via USB, such as a standard downstream port (SDP) or a charging downstream port (CDP) with strong charging capabilities, like a drone controller or a car controller, the electronic device can remotely control the drone controller. However, due to the diversity and uncertainty of external devices, communication with the external device often breaks down abnormally, resulting in low communication efficiency between the electronic device and the external device. Summary of the Invention
[0003] The purpose of this application is to provide a method, apparatus, electronic device, and storage medium for connecting external devices, thereby improving the communication efficiency between electronic devices and external devices.
[0004] In a first aspect, embodiments of this application provide a method for connecting an external device, the method comprising:
[0005] In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the electronic device and the first external device before the disconnection is obtained; the electronic device and the first external device establish a communication connection based on a USB cable;
[0006] The first current adjustment parameter is determined based on the reason for the abnormal disconnection between the electronic device and the first external device;
[0007] The second charging current is determined based on the first current adjustment parameter and the first charging current.
[0008] The communication connection between the electronic device and the first external device is restored based on the second charging current.
[0009] Secondly, embodiments of this application provide a connection device for an external device, the device comprising:
[0010] The acquisition module is used to acquire the first charging current between the electronic device and the first external device before the communication connection between the electronic device and the first external device is abnormally disconnected; the electronic device and the first external device establish a communication connection based on a USB cable.
[0011] The determining module is used to determine the first current adjustment parameter based on the reason for the abnormal disconnection between the electronic device and the first external device;
[0012] The determining module is further configured to determine the second charging current based on the first current adjustment parameter and the first charging current;
[0013] A connection restoration module is used to restore the communication connection between the electronic device and the first external device based on the second charging current.
[0014] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0015] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0016] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.
[0017] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.
[0018] In this embodiment, the electronic device and the first external device establish a communication connection via a USB cable. If the communication connection between the electronic device and the first external device is abnormally disconnected, the first charging current between the two devices before the disconnection is obtained. Based on the reason for the abnormal disconnection, a first current adjustment parameter is determined. A second charging current is determined based on the first current adjustment parameter and the first charging current. The communication connection between the electronic device and the first external device is then restored based on the second charging current. Thus, when the communication connection between the first external device and the electronic device is abnormally disconnected, adjusting the first charging current between them promptly restores the communication connection, improving the communication efficiency between the two devices. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating a USB external device connection restoration method provided in some embodiments of this application;
[0020] Figure 2 This is a flowchart illustrating a USB external device connection restoration method provided in some embodiments of this application;
[0021] Figure 3 This is a schematic diagram of the structure of a USB external device connection recovery device shown in some embodiments of this application;
[0022] Figure 4 These are schematic diagrams illustrating the structure of an electronic device according to some embodiments of this application;
[0023] Figure 5 These are schematic diagrams illustrating the hardware structure of an electronic device according to some embodiments of this application. Detailed Implementation
[0024] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0025] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0026] As described in the background section, existing technologies suffer from low communication efficiency between electronic devices and external devices. To address this issue, this application provides a method, apparatus, electronic device, and storage medium for connecting external devices. The electronic device and a first external device establish a communication connection via a USB cable. In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, a first charging current between the first external device and the electronic device before the disconnection is obtained. Based on the cause of the abnormal disconnection, a first current adjustment parameter is determined. A second charging current is determined based on the first current adjustment parameter and the first charging current. The communication connection between the electronic device and the first external device is then restored based on the second charging current. Thus, when the communication connection between the first external device and the electronic device is abnormally disconnected, adjusting the first charging current between them promptly restores the communication connection, improving the communication efficiency between the electronic device and the first external device.
[0027] The connection method for external devices provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0028] The solution in this application is applicable to scenarios where, when an electronic device is connected to an external device with an SDP or CDP USB port via a USB cable, the priority of using other functions of the external device takes precedence over the function of charging the electronic device, resulting in an abnormal VBUS disconnection between the electronic device and the external device. For example, if an electronic device is connected to an external device such as a drone controller via a USB cable, the user primarily uses the drone controller's communication function—specifically, using the electronic device to control the drone controller via USB communication—rather than primarily using the drone controller to charge the electronic device. In this scenario, if the VBUS connection between the drone controller and the electronic device is abnormally disconnected, the solution in this application can be used to restore the VBUS connection between the drone controller and the electronic device, thereby achieving a normal USB connection between them.
[0029] Before introducing the embodiments of this application, let's first explain the relationship between USB and VBUS:
[0030] Two devices are connected via a USB cable, for example, device A and device B are connected via a USB cable. If you want to use device A to charge device B via the USB cable, then the USB port connected to device A is VBUS, that is, the power supply port is VBUS.
[0031] Figure 1This is a flowchart illustrating a method for connecting an external device according to an embodiment of this application. The subject executing this method can be an electronic device. It should be noted that the aforementioned subject does not constitute a limitation on the embodiments of this application.
[0032] In embodiments of this application, the electronic device may be, but is not limited to, a personal computer (PC), a smartphone, a tablet computer, or a personal digital assistant (PDA).
[0033] like Figure 1 As shown, the connection method for external devices provided in this application embodiment may include steps 110-140.
[0034] Step 110: In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, obtain the first charging current between the electronic device and the first external device before the disconnection; the electronic device and the first external device are connected via a USB cable.
[0035] The first external device can be an external device that requires USB communication with an electronic device. For example, it could be a car infotainment system or a drone controller.
[0036] An abnormal disconnection of the communication connection can be assumed to be not caused by manually plugging or unplugging the USB cable, thus preventing the VBUS connection from being lost.
[0037] The first charging current can be the current used by the first external device to charge the electronic device before the communication connection between the electronic device and the first external device is abnormally disconnected. Here, the first charging current can be the current used by the first external device to charge the electronic device at any time before the abnormal disconnection of the communication connection between the electronic device and the first external device. The specific time before the abnormal disconnection of the communication connection between the electronic device and the first external device is selected as the first charging current can be chosen according to user needs, and is not limited in this embodiment.
[0038] In some embodiments of this application, in order to determine that the disconnection of the communication connection between the electronic device and the first external device is an abnormal disconnection, the method described above may further include the following steps before step 110:
[0039] Obtain the USB cable connection status, connection type, and disconnection duration between the electronic device and the first external device;
[0040] If the USB cable connection status is "connected", the connection type is "communication connection type", and the disconnection time is less than the preset time, it is determined that the communication connection between the electronic device and the first external device has been abnormally disconnected.
[0041] The USB cable connection status can be whether the USB cable between the electronic device and the first external device is connected.
[0042] The connection type can be categorized as whether the connection between the electronic device and the first external device is a communication connection. This means that the electronic device prioritizes other functions of the first external device over charging the electronic device. Specifically, the first external device's USB port must be an SDP or CDP type port. This type of external device has the capability to communicate via USB. The purpose of connecting the electronic device to this type of external device is most likely for communication via USB. For example, if the first external device is a drone controller or a car infotainment system, the electronic device connecting to it is likely to control the drone controller or project the car infotainment system, not just charge it. In this case, when the electronic device connects to this type of external device, the normal use of the external device's functions takes precedence over charging alone.
[0043] The disconnection duration can be the duration during which the communication connection between the electronic device and the first external device is abnormally disconnected.
[0044] The preset duration is a pre-set duration that can be considered as an abnormal disconnection of the communication connection between the electronic device and the first external device as a VBUS abnormal disconnection. This duration is generally less than the duration for which the user plugs and unplugs the USB cable.
[0045] In some embodiments of this application, when determining whether the USB port type of the first external device is an SDP or CDP type port, the device details information of the first external device can be viewed, or other detection methods can be used. This application does not limit the methods, as long as the USB port type of the first external device can be detected.
[0046] In some embodiments of this application, it is first necessary to determine that the electronic device and the first external device are connected via a USB cable. That is, it must first be confirmed that a USB cable is connected to the electronic device, meaning that the USB cable is properly connected. Specifically, the presence of a USB cable on the electronic device can be directly detected using the GPIO port of the electronic device.
[0047] Assuming the USB cable on the electronic device is properly connected, the connection type of the USB cable between the electronic device and the first external device must be communication type. Then, determine that the duration of the abnormal disconnection of the communication connection between the electronic device and the first external device is less than the normal duration of the user plugging and unplugging the USB cable (e.g., 300ms). This excludes the possibility that the USB port connected to the first external device was manually unplugged. Therefore, it can be determined that the disconnection of the communication connection between the electronic device and the first external device is an abnormal disconnection.
[0048] In the embodiments of this application, by obtaining the USB cable connection status, connection type, and disconnection duration between the electronic device and the first external device, if the USB cable connection status is "connected," the connection type is "communication connection type," and the disconnection duration is less than a preset duration, it is determined that the communication connection between the electronic device and the first external device is abnormally disconnected. In this way, by judging the USB cable connection status, connection type, and disconnection duration between the electronic device and the first external device, it is possible to accurately determine whether the communication connection disconnection between the electronic device and the first external device is an abnormal disconnection. The operation is simple and improves the efficiency of judging whether the communication connection disconnection between the electronic device and the first external device is an abnormal disconnection.
[0049] Step 120: Determine the first current adjustment parameter based on the reason for the abnormal disconnection between the electronic device and the first external device.
[0050] The reason for the abnormal disconnection between the electronic device and the first external device can be any condition that triggers the abnormal disconnection of the communication connection between the electronic device and the first external device. For example, it could be that the load current of the first external device is too large, or that the load voltage of the first external device is too large, or it could be other factors. In this application embodiment, no limitation is made. Any condition that can cause the abnormal disconnection of the communication connection between the electronic device and the first external device is within the scope of protection of this application embodiment.
[0051] The first current adjustment parameter can be a parameter that adjusts the first charging current, specifically a parameter that reduces the first charging current, so that the communication connection between the first external device and the electronic device can be restored.
[0052] In this embodiment, the reasons for the abnormal disconnection between the electronic device and the first external device are different, and the determination of the corresponding first current adjustment parameter is also different. The first current adjustment parameter can be determined according to different reasons for abnormal disconnection. This will be described in more detail in later embodiments.
[0053] Step 130: Determine the second charging current based on the first current adjustment parameter and the first charging current.
[0054] The second charging current can be the current obtained by adjusting the first charging current using the first current adjustment parameter.
[0055] In some embodiments of this application, the first charging current can be adjusted according to the first current adjustment parameter to obtain the second charging current. For example, the product of the first current adjustment parameter and the first charging current can be used as the second charging current.
[0056] Step 140: Restore the communication connection between the electronic device and the first external device based on the second charging current.
[0057] In some embodiments of this application, the VBUS connection will be reconnected after being disconnected. At this time, the current for the first external device to charge the electronic device is set as the second charging current. The second charging current is generally smaller than the previous first charging current, so the current for the first external device to charge the electronic device can be reduced. The current load of the first external device will not be too large, and the VBUS will be reconnected.
[0058] In some embodiments of this application, the communication connection between the electronic device and the first external device is abnormally disconnected for at least two reasons; step 120 may specifically include:
[0059] For each cause of abnormal disconnection, determine the corresponding candidate current regulation parameters;
[0060] The first current regulation parameter is determined based on at least two candidate current regulation parameters.
[0061] Among them, the candidate current regulation parameters can be current regulation parameters determined according to different reasons for abnormal disconnection.
[0062] In some embodiments of this application, different abnormal disconnection causes correspond to different candidate current adjustment parameters, and the first current adjustment parameter can be determined based on the candidate current adjustment parameter corresponding to each abnormal disconnection cause.
[0063] In the embodiments of this application, for each abnormal disconnection cause, a candidate current adjustment parameter corresponding to the abnormal disconnection cause is determined, and then a first current adjustment parameter is determined based on at least two candidate current adjustment parameters. In this way, the first current adjustment parameter can be accurately determined based on the candidate current adjustment parameters corresponding to different abnormal disconnection causes, thereby accurately restoring the communication connection between the electronic device and the first external device.
[0064] In some embodiments of this application, the candidate current adjustment parameters calculated for different abnormal disconnection reasons are different. However, since the electronic device cannot obtain the specific reason for the first external device disconnecting the VBUS connection, the first current adjustment parameter can be determined in the following way to cover the abnormal VBUS disconnection caused by the above three triggering conditions:
[0065] Determining the first current regulation parameter based on at least two candidate current regulation parameters may specifically include:
[0066] The minimum value among at least two candidate current regulation parameters is determined as the first current regulation parameter.
[0067] In some embodiments of this application, since the adjustment of the first charging current is to restore the VBUS connection, and since the other functions of the first external device are greater than its charging function in this embodiment, regardless of the current supplied by the first external device to the electronic device, as long as the first external device can supply power to the electronic device and the VBUS connection is restored, the minimum value among the candidate current adjustment parameters under different abnormal disconnection reasons can be selected as the first current adjustment parameter to ensure the restoration of the VBUS connection.
[0068] In the embodiments of this application, the minimum value among the candidate current adjustment parameters corresponding to each abnormal disconnection cause is determined as the first current adjustment parameter. This eliminates the need to repeatedly determine the first adjustment parameter, ensuring that the communication connection between the electronic device and the first external device is quickly restored.
[0069] The following is a detailed description of how to determine candidate current adjustment parameters under different abnormal disconnection causes:
[0070] Scenario 1: If the cause of the abnormal disconnection is determined to be that the first charging voltage of the first external device charging the electronic device is greater than the first preset voltage protection threshold of the first external device, the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection may specifically include:
[0071] The second charging voltage at the moment before the electronic device disconnects from the first external device, and the second preset voltage protection threshold specified in the charging protocol are obtained.
[0072] Candidate current adjustment parameters are determined based on the second charging voltage and the second preset voltage protection threshold.
[0073] The first charging voltage can be the actual voltage at which the first external device supplies power to the electronic device.
[0074] The first preset voltage protection threshold can be a pre-set voltage protection value for the first external device. Specifically, it can be the undervoltage protection threshold for the first external device, that is, the minimum threshold voltage at which the first external device supplies power to the electronic device. Undervoltage protection (UVP) is a circuit protection mechanism used to prevent damage to devices in a circuit due to excessively low voltage.
[0075] The second charging voltage can be the charging voltage supplied by the first external device to the electronic device at the moment before the electronic device is disconnected from the first external device.
[0076] The second preset voltage threshold can be the charging voltage of the second external device specified in the charging protocol, specifically the safe voltage Vsafe under normal power supply conditions specified in the charging protocol. In one example, ideally, Vsafe = 5V.
[0077] Based on the second charging voltage and the second preset voltage protection threshold, the candidate current adjustment parameters for the case where the abnormal disconnection is caused by the first external device charging the electronic device at a voltage greater than the first preset voltage protection threshold of the first external device can be determined according to the following formula (1):
[0078]
[0079] In formula (1), V safe The second preset voltage protection threshold, V drop This is the second charging voltage.
[0080] It should be noted that since the second preset voltage protection threshold is an ideal value, in reality, due to current loss or other reasons, this second preset voltage protection threshold will usually be lower than 5V. Therefore, the target voltage V for the recovery scheme can be set. goal =(V safe +V drop ) / 2, and then according to Ohm's law, when the circuit resistance is constant, the circuit current and voltage are linearly related. Thus, the candidate current adjustment parameter can be set as shown in formula (1) when the reason for abnormal disconnection is that the first charging voltage of the first external device charging the electronic device is greater than the first preset voltage protection threshold of the first external device.
[0081] In the embodiments of this application, by obtaining the second charging voltage at the moment before the electronic device disconnects from the first external device, and the second preset voltage protection threshold specified in the charging protocol, the candidate current adjustment parameters can be accurately determined when the reason for the abnormal disconnection is that the first charging voltage of the first external device charging the electronic device is greater than the first preset voltage protection threshold of the first external device.
[0082] Scenario 2: If the cause of the abnormal disconnection is determined to be that the first charging current exceeds the first preset current protection threshold of the first external device, the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection may specifically include:
[0083] The third charging current and the second preset current protection threshold are obtained at the moment before the electronic device is disconnected from the first external device.
[0084] Candidate current adjustment parameters are determined based on the third charging current value and the second preset current protection threshold.
[0085] The first preset current protection threshold can be a pre-set current protection value of the first external device, specifically the circuit overcurrent protection threshold of the first external device, i.e., the maximum current that the first external device can provide.
[0086] Overcurrent protection (OCP) is a circuit protection mechanism used to prevent devices in a circuit from being damaged by excessive current.
[0087] The third charging current can be the current that the first external device charges the electronic device at the moment before the electronic device is disconnected from the first external device.
[0088] It should be noted that if the first charging current is the current that the first external device charges the electronic device at the moment before the electronic device is disconnected from the first external device, then the first charging current is the same as the third charging current. If the first charging current is not the current that the first external device charges the electronic device at the moment before the electronic device is disconnected from the first external device, then the first charging current is different from the third charging current.
[0089] The second preset current protection threshold can be the minimum threshold of the second charging current. If the second charging current is less than the second preset current protection threshold, the process of adjusting the first charging current will be exited, that is, the first charging current will not be adjusted. This is because if the second charging current is less than the second preset current protection threshold, normal communication between the electronic device and the first external device cannot be ensured, so the process of adjusting the first charging current can be exited.
[0090] The second preset current protection threshold can be set based on prior experience or according to the charging protocol of the first external device. For example, it can be 20% of the current value specified in the charging protocol of the first external device. That is, when the type of the first external device is SDP, the second preset current protection threshold is 100mA, and when the type of the first external device is CDP, the second preset current protection threshold is 300mA. This is not limited in the embodiments of this application.
[0091] In some embodiments of this application, since the OCP value of the first external device is unknown, but it is known that the third charging current of the first external device charging the electronic device at the moment before the electronic device disconnects from the first external device is definitely greater than the OCP value, combined with the preset second preset current protection threshold, the candidate current adjustment parameters when the abnormal disconnection is caused by the first charging current being greater than the first preset current protection threshold of the first external device can be obtained according to the following formula (2):
[0092] k = Idrop - Iq / Idrop (2)
[0093] In formula (2), Idrop is the third charging current and Iq is the second preset current protection threshold.
[0094] In the embodiments of this application, by using the third charging current at the moment before the electronic device disconnects from the first external device and the second preset current protection threshold, the candidate current adjustment parameters can be accurately determined when the abnormal disconnection is caused by the first charging current being greater than the first preset current protection threshold of the first external device.
[0095] Scenario 3: If the cause of the abnormal disconnection is determined to be that the ground loop voltage of the first external device is greater than the preset ground loop voltage threshold, the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection may specifically include:
[0096] Obtain the first voltage amplitude threshold of the differential signal of the USB line as specified in the USB eye diagram, and the second voltage amplitude threshold of the differential signal as specified in the charging protocol;
[0097] Candidate current adjustment parameters are determined based on the first voltage amplitude threshold and the second voltage amplitude threshold.
[0098] The preset voltage threshold can be the ground loop voltage value of the first external device. When the ground loop voltage value of the first external device is higher than the threshold, the first external device will actively disconnect the VBUS power supply.
[0099] The differential signal of a USB cable can be the DpDm signal of the USB cable.
[0100] The first voltage amplitude threshold can be the threshold value of the differential signal voltage of the USB line as specified in the USB eye diagram. For example, it could be 300mV. This USB eye diagram can be a diagram used to determine whether the USB signal is normal. Generally, the USB eye diagram specifies that the voltage value of the USB differential signal in actual applications should not be lower than the first voltage amplitude threshold. That is to say, when the voltage value of the USB differential signal is lower than the first voltage amplitude threshold, USB communication may be abnormal.
[0101] The method for obtaining the USB eye diagram is the same as existing technology, and will not be described in detail here.
[0102] The second voltage amplitude threshold can be the threshold value of the differential signal voltage specified in the charging protocol, such as 400mV.
[0103] In some embodiments of this application, after obtaining the first voltage amplitude threshold and the second voltage amplitude threshold, according to Ohm's law, when the loop impedance remains constant, the current and voltage are linearly related. Therefore, based on the first voltage amplitude threshold and the second voltage amplitude threshold, the candidate current adjustment parameter for the case where the ground loop voltage of the first external device is greater than the preset ground loop voltage threshold can be determined according to the following formula (3):
[0104] k = Vth / Vsafe (3)
[0105] In formula (3), Vth is the first voltage amplitude threshold and Vsafe is the second voltage amplitude threshold.
[0106] In the embodiments of this application, by using the first voltage amplitude threshold of the differential signal of the USB line specified by the obtained USB eye diagram and the second voltage amplitude threshold of the differential signal specified by the charging protocol, the candidate current adjustment parameters can be accurately determined when the ground loop voltage of the first external device is greater than the preset ground loop voltage threshold due to the abnormal disconnection.
[0107] It should be noted that the above three abnormal disconnection causes are all due to excessive current load of the first external device, that is, the charging current of the first external device supplying power to the electronic device is too large. Therefore, the VBUS power supply connection can be restored by adjusting the first charging current of the first external device supplying power to the electronic device.
[0108] In some embodiments of this application, step 110 may specifically include:
[0109] In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the electronic device and the first external device is obtained at the first moment before the disconnection.
[0110] In some embodiments of this application, when obtaining the first charging current between the electronic device and the first external device before disconnection, the first charging current between the electronic device and the first external device can be obtained at a first moment before disconnection. Here, the first moment can be any moment before disconnection.
[0111] If, after adjusting the first charging current obtained at the first moment using the first current adjustment parameter, the obtained second charging current is insufficient to restore the communication connection between the electronic device and the first external device, this can be resolved in the following way: after step 140, the method described above may further include:
[0112] If the communication connection between the electronic device and the first external device is not restored based on the second charging current, obtain the fourth charging current between the electronic device and the first external device at the second moment before the disconnection;
[0113] The second current adjustment parameter is determined based on the cause of the abnormal disconnection between the electronic device and the first external device;
[0114] The fifth charging current is determined based on the second current adjustment parameter and the fourth charging current.
[0115] The communication connection between the electronic device and the first external device is restored based on the fifth charging current.
[0116] The second moment can be a moment different from the first moment before the connection is broken.
[0117] The fourth charging current can be the charging current between the electronic device and the first external device at the second moment before the disconnection. Specifically, this fourth charging current can be less than the first charging current. Since the current adjustment parameter for adjusting the charging current between the electronic device and the first external device before the disconnection is less than 1, when adjusting the charging current between the electronic device and the first external device before the disconnection using this current adjustment parameter, the charging current between the electronic device and the first external device before the disconnection is reduced. Therefore, when the fourth charging current is less than the first charging current, and a second current adjustment parameter is subsequently obtained based on this fourth charging current, and the fourth charging current is adjusted based on this second current adjustment parameter to obtain the fifth charging current, the fifth charging current may be less than the second charging current. This ensures that the communication connection between the electronic device and the first external device can be restored.
[0118] The second current regulation parameter can be a current regulation parameter determined based on the reason for the abnormal disconnection between the electronic device and the first external device. In fact, this second current regulation parameter is equal to the first current regulation parameter.
[0119] The fifth charging current can be the charging current obtained by adjusting the fourth charging current using the second current adjustment parameter.
[0120] In some embodiments of this application, if the communication connection between the electronic device and the first external device is not restored based on the second charging current, the fourth charging current between the electronic device and the first external device at the second moment before the disconnection can be obtained again. Then, based on the reason for the abnormal disconnection between the electronic device and the first external device, the second current adjustment parameter is determined, and then the fifth charging current is determined based on the second current adjustment parameter and the fourth charging current. The communication connection between the electronic device and the first external device is restored based on the fifth charging current.
[0121] In the embodiments of this application, if the communication connection between the electronic device and the first external device is not restored based on the second charging current, the fourth charging current between the electronic device and the first external device at the second moment before the disconnection can be reacquired, and then the fourth charging current can be adjusted to obtain the fifth charging current. The communication connection between the electronic device and the first external device can be restored based on the fifth charging current. In this way, if the communication connection between the electronic device and the first external device cannot be restored based on the adjusted charging current, the charging current at different moments before the disconnection can be continuously reacquired, and the charging current can be continuously adjusted to ensure that the communication connection between the electronic device and the first external device can be restored.
[0122] In some embodiments of this application, the charging current between the electronic device and the first external device before disconnection cannot be adjusted indefinitely. Therefore, a stop condition for repeated adjustment can be set. Specifically, after the communication connection between the electronic device and the first external device is restored based on the fifth charging current, the method described above may further include:
[0123] If the number of attempts to restore the connection exceeds a preset number, an error message indicating that the communication connection between the electronic device and the first external device has been abnormally disconnected will be output.
[0124] Alternatively, if the fifth charging current is less than or equal to the second preset current protection threshold, an error message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected is output.
[0125] In some embodiments of this application, the preset number of times may be a pre-set number of cycles.
[0126] In some embodiments of this application, when it is determined that the number of attempts to restore the connection is greater than a preset number, or the fifth charging current is less than or equal to the second preset current protection threshold, it means that no matter how the charging current between the electronic device and the first external device before the disconnection is adjusted, the VBUS connection cannot be restored, that is, the first external device cannot be connected to the electronic device normally. At this time, the power supply of the first external device to the electronic device can be stopped directly.
[0127] In the embodiments of this application, when the fifth charging current is less than the second preset current protection threshold, or when the number of attempts to restore the connection is greater than the preset number, a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected can be output to prompt the user that the communication connection between the electronic device and the first external device is abnormally disconnected, so that the user can make other adjustments to the communication connection between the electronic device and the first external device in a timely manner.
[0128] In some embodiments of this application, to prevent the user from noticing the abnormal disconnection of the communication connection between the electronic device and the first external device, the above-mentioned method may further include:
[0129] When the communication connection between the electronic device and the first external device is restored based on the second charging current, no prompt message indicating that the communication connection between the electronic device and the first external device has been abnormally disconnected is output.
[0130] In some embodiments of this application, since the time interval between the abnormal disconnection and the restoration of the communication connection between the electronic device and the first external device is relatively small, in order to improve the user experience and prevent the user from being aware of the abnormal disconnection of the communication connection between the electronic device and the first external device, the underlying layer of the electronic device may not send a prompt message about the abnormal disconnection of the communication connection between the electronic device and the first external device to the application layer. In this way, the user will not be aware that the communication connection between the electronic device and the first external device was abnormally disconnected.
[0131] In the embodiments of this application, when the communication connection between the electronic device and the first external device is restored based on the second charging current, no prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected is output, so that the user will not perceive that the communication connection between the electronic device and the first external device is abnormally disconnected.
[0132] In some embodiments of this application, in order to improve the efficiency of restoring the communication connection between the electronic device and the first external device, after step 140, the method described above may further include:
[0133] If an abnormal disconnection of the communication connection between the electronic device and the second external device is detected, the charging current of the second external device charging the electronic device is adjusted to the second charging current.
[0134] The second external device can be of the same type as the first external device.
[0135] In some embodiments of this application, after restoring the communication connection between the electronic device and the first external device using the second charging current, if the communication connection between the electronic device and a second external device of the same type as the first external device is subsequently detected to be abnormally disconnected, since the charging current between the external device and the electronic device of the same type is generally not much different, the charging current of the second external device charging the electronic device can be directly adjusted to the second charging current, so as to directly and quickly restore the communication connection between the electronic device and the second external device.
[0136] In the embodiments of this application, when an abnormal disconnection of the communication connection between the electronic device and the second external device is detected, the charging current of the second external device charging the electronic device is adjusted to a second charging current. There is no need to calculate the adjustment parameters of the charging current for charging the electronic device, and thus obtain the adjusted charging current. In this way, the communication connection between the electronic device and the second external device can be directly and quickly restored, improving the restoration efficiency of the communication connection between the electronic device and the second external device.
[0137] In some embodiments of this application, in addition to the aforementioned electronic device potentially being connected to an external device of the same type as the first external device, the electronic device may also subsequently be reconnected to the first external device. Thus, the charging current of the first external device for charging the electronic device can be set in the following manner: that is, after step 140, the method described above may further include:
[0138] If the communication connection between the electronic device and the first external device is abnormally disconnected again, obtain the device information of the first external device;
[0139] If the device information is determined to be the same as the preset device information stored in advance, the charging current of the first external device charging the electronic device is set as the second charging current.
[0140] The device information of the first external device can be identification information used to characterize the first external device, such as the Bluetooth device name of the first external device or the device code of the first external device.
[0141] Preset device information can be information about previously connected external devices that has been stored in the electronic device beforehand.
[0142] In one example, taking the Bluetooth device name of the first external device as the device information of the first external device, after restoring the communication connection between the electronic device and the first external device using the second charging current, if the electronic device has Bluetooth function and the Bluetooth function is enabled, the Bluetooth device name of the first external device can be obtained through the Bluetooth function of the electronic device and stored. The stored Bluetooth device name is the preset device information.
[0143] In some embodiments of this application, when the communication connection between the electronic device and the first external device is detected to be abnormally disconnected again, and when it is determined that the device information of the first external device is the same as the preset device information stored in advance, the charging current of the first external device to charge the electronic device can be set as the second charging current.
[0144] In one example, taking the Bluetooth device name as the device information of the first external device, after restoring the communication connection between the electronic device and the first external device using the second charging current, if the electronic device has Bluetooth and Bluetooth is enabled, the Bluetooth device name of the first external device can be obtained through the Bluetooth function of the electronic device. If the electronic device and the first external device are subsequently reconnected via USB cable, and the communication connection between the electronic device and the first external device is abnormally disconnected, if the Bluetooth of the electronic device recognizes that the Bluetooth of the connected first external device is the previously connected first external device, the charging current of the first external device charging the electronic device can be directly set to the second charging current, thus avoiding abnormal disconnection of the communication connection between the electronic device and the first external device.
[0145] In the embodiments of this application, when it is detected that the communication connection between the electronic device and the first external device is abnormally disconnected again, and when it is determined that the device information of the first external device is the same as the preset device information stored in advance, the charging current of the first external device charging the electronic device can be set as the second charging current. This can prevent the communication connection between the electronic device and the first external device from being abnormally disconnected again when the electronic device and the first external device are reconnected.
[0146] In some embodiments of this application, to more clearly understand the technical solutions of this application, the embodiments of this application also provide another possible implementation of the connection method for external devices, see reference. Figure 2 , Figure 2 This is a flowchart illustrating a method for connecting an external device, which includes steps 201-209:
[0147] Step 201: The electronic device and the first external device are connected via a USB cable.
[0148] Step 202: Obtain the connection type of the USB cable between the electronic device and the first external device.
[0149] Step 203: Obtain the connection status of the USB cable between the electronic device and the first external device.
[0150] In this step, the connection type of the USB cable between the electronic device and the first external device, as well as the method for determining the connection status of the USB cable between the electronic device and the first external device, are the same as in the previous embodiment, and will not be repeated here.
[0151] Step 204: Determine whether the disconnection of the communication connection between the electronic device and the first external device is an abnormal disconnection. If yes, proceed to step 205; otherwise, end the entire process.
[0152] Step 205: Obtain the first charging current between the electronic device and the first external device if the communication connection between the electronic device and the first external device is abnormally disconnected. Adjust the first charging current to obtain the second charging current.
[0153] Step 205 is implemented in the same way as steps 110-130 in the above embodiments.
[0154] Step 206: Determine whether the communication connection between the electronic device and the first external device has been restored. If yes, proceed to step 207; otherwise, proceed to step 208.
[0155] Step 207: Read the device information of the first external device. When the same device is connected again, set the charging current to the second charging current. Alternatively, if the communication connection between the second external device of the same type as the first external device and the electronic device is abnormally disconnected, adjust the charging current of the second external device to charge the electronic device to the second charging current.
[0156] Step 208: Is the loop stopping condition met? If yes, proceed to step 209; otherwise, return to step 205.
[0157] The loop stop condition in step 208 can be that the number of attempts to restore the connection is greater than a preset number, or that the fifth charging current is less than or equal to the second preset current protection threshold.
[0158] Step 209: Stop the first external device from supplying power to the electronic device and send a message indicating that the communication connection between the electronic device and the first external device has been abnormally disconnected.
[0159] The solution proposed in this application addresses the problem of abnormal Vbus drop when an electronic device is connected to an external device, and effectively solves the USB connection stability problem caused by design flaws in the external device itself.
[0160] The external device connection method provided in this application can be executed by an external device connection device. This application uses an example of an external device connection device executing the external device connection method to illustrate the external device connection device provided in this application.
[0161] Figure 3 This is a schematic diagram illustrating the structure of a connection device for an external device according to an exemplary embodiment.
[0162] like Figure 3 As shown, the connection device 300 of the external device may include:
[0163] The acquisition module 310 is used to acquire the first charging current between the electronic device and the first external device before the communication connection between the electronic device and the first external device is abnormally disconnected; the electronic device and the first external device establish a communication connection based on a USB cable.
[0164] The determining module 320 is used to determine the first current adjustment parameter based on the reason for the abnormal disconnection between the electronic device and the first external device;
[0165] The determining module 320 is further configured to determine the second charging current based on the first current adjustment parameter and the first charging current;
[0166] The connection restoration module 330 is used to restore the communication connection between the electronic device and the first external device based on the second charging current.
[0167] In the embodiments of this application, the electronic device and the first external device establish a communication connection based on a USB cable. In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the first external device and the electronic device before the disconnection is obtained. Based on the reason for the abnormal disconnection, a first current adjustment parameter is determined. A second charging current is determined based on the first current adjustment parameter and the first charging current. The communication connection between the electronic device and the first external device is restored based on the second charging current. In this way, when the communication connection between the first external device and the electronic device is abnormally disconnected, the communication connection between the electronic device and the first external device is restored in a timely manner by adjusting the first charging current between the first external device and the electronic device, thereby improving the communication efficiency between the electronic device and the first external device.
[0168] In some embodiments of this application, the communication connection between the electronic device and the first external device is abnormally disconnected for at least two reasons; the determining module 320 may include:
[0169] The first determining unit is used to determine the candidate current adjustment parameter corresponding to each abnormal disconnection cause;
[0170] The second determining unit is configured to determine the first current adjustment parameter based on at least two candidate current adjustment parameters.
[0171] In some embodiments of this application, the first determining unit is specifically used for:
[0172] When the abnormal disconnection is caused by the first charging voltage of the first external device charging the electronic device being greater than the first preset voltage protection threshold of the first external device, the second charging voltage of the electronic device at the moment before the disconnection from the first external device is obtained, as well as the second preset voltage protection threshold specified in the charging protocol.
[0173] The candidate current adjustment parameters are determined based on the second charging voltage and the second preset voltage protection threshold.
[0174] In some embodiments of this application, the first determining unit is specifically used for:
[0175] If the reason for the abnormal disconnection is that the first charging current is greater than the first preset current protection threshold of the first external device, the third charging current and the second preset current protection threshold are obtained at the moment before the electronic device disconnects from the first external device.
[0176] The candidate current adjustment parameters are determined based on the third charging current and the second preset current protection threshold.
[0177] In some embodiments of this application, the first determining unit is specifically used for:
[0178] When the abnormal disconnection is caused by the ground loop voltage of the first external device being greater than a preset ground loop voltage threshold, the first voltage amplitude threshold of the differential signal of the USB line as specified in the USB eye diagram and the second voltage amplitude threshold of the differential signal as specified in the charging protocol are obtained.
[0179] The candidate current adjustment parameters are determined based on the first voltage amplitude threshold and the second voltage amplitude threshold.
[0180] In some embodiments of this application, the acquisition module 310 may specifically be used for:
[0181] In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the electronic device and the first external device is obtained at the first moment before the disconnection.
[0182] The acquisition module 310 can also be used for:
[0183] If the communication connection between the electronic device and the first external device is not restored based on the second charging current, obtain the fourth charging current between the electronic device and the first external device at the second moment before the disconnection;
[0184] The determining module 320 can also be used to determine a second current adjustment parameter based on the reason for the abnormal disconnection between the electronic device and the first external device; and to determine a fifth charging current based on the second current adjustment parameter and the fourth charging current.
[0185] The connection restoration module 330 can also be used to restore the communication connection between the electronic device and the first external device based on the fifth charging current.
[0186] In some embodiments of this application, the apparatus described above may further include:
[0187] The output module is used to output a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected when the number of attempts to restore the connection exceeds a preset number; or, when the fifth charging current is less than or equal to the second preset current protection threshold, to output a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected.
[0188] In some embodiments of this application, the apparatus described above may further include:
[0189] The processing module is configured to not output a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected when the communication connection between the electronic device and the first external device is restored based on the second charging current.
[0190] The connection device for the external device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or any other device besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not impose specific limitations.
[0191] The connection device for the external device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system.
[0192] The external device connection device provided in this application embodiment can achieve... Figures 1-2 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0193] Optionally, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401 and a memory 402. The memory 402 stores a program or instructions that can run on the processor 401. When the program or instructions are executed by the processor 401, they implement the various steps of the above-described external device connection method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0194] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0195] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.
[0196] The electronic device 500 includes, but is not limited to, components such as: radio frequency unit 501, network module 502, audio output unit 503, input unit 504, sensor 505, display unit 506, user input unit 507, interface unit 508, memory 509, and processor 510.
[0197] Those skilled in the art will understand that the electronic device 500 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 510 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0198] The radio frequency unit 501 is used to acquire the first charging current between the electronic device and the first external device before the communication connection between the electronic device and the first external device is abnormally disconnected; the electronic device and the first external device establish a communication connection based on a USB cable.
[0199] The processor 510 is configured to determine a first current adjustment parameter based on the cause of the abnormal disconnection between the electronic device and the first external device; determine a second charging current based on the first current adjustment parameter and the first charging current; and restore the communication connection between the electronic device and the first external device based on the second charging current.
[0200] In this way, the electronic device and the first external device establish a communication connection based on a USB cable. In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the first external device and the electronic device before the disconnection is obtained. Based on the reason for the abnormal disconnection, a first current adjustment parameter is determined. Based on the first current adjustment parameter and the first charging current, a second charging current is determined. Based on the second charging current, the communication connection between the electronic device and the first external device is restored. Thus, when the communication connection between the first external device and the electronic device is abnormally disconnected, the communication connection between the electronic device and the first external device is restored in a timely manner by adjusting the first charging current between the two devices, thereby improving the communication efficiency between the electronic device and the first external device.
[0201] Optionally, the communication connection between the electronic device and the first external device may be abnormally disconnected for at least two reasons; the processor 510 is further configured to determine, for each abnormal disconnection reason, a candidate current adjustment parameter corresponding to the abnormal disconnection reason; and to determine the first current adjustment parameter based on the at least two candidate current adjustment parameters.
[0202] Thus, by determining the candidate current adjustment parameters corresponding to each abnormal disconnection cause, and then determining the first current adjustment parameter based on at least two candidate current adjustment parameters, the first current adjustment parameter can be accurately determined based on the candidate current adjustment parameters corresponding to different abnormal disconnection causes, thereby accurately restoring the communication connection between the electronic device and the first external device.
[0203] Optionally, the processor 510 is further configured to, when the abnormal disconnection is caused by the first charging voltage of the first external device charging the electronic device being greater than the first preset voltage protection threshold of the first external device, obtain the second charging voltage at the moment before the electronic device disconnects from the first external device, and the second preset voltage protection threshold specified in the charging protocol; and determine the candidate current adjustment parameter based on the second charging voltage and the second preset voltage protection threshold.
[0204] Thus, by obtaining the second charging voltage at the moment before the electronic device disconnects from the first external device, and the second preset voltage protection threshold specified in the charging protocol, the candidate current adjustment parameters can be accurately determined when the cause of the abnormal disconnection is that the first charging voltage of the first external device charging the electronic device is greater than the first preset voltage protection threshold of the first external device.
[0205] Optionally, the processor 510 is further configured to, when the cause of the abnormal disconnection is that the first charging current is greater than the first preset current protection threshold of the first external device, acquire the third charging current and the second preset current protection threshold at the moment before the electronic device disconnects from the first external device; and determine the candidate current adjustment parameter based on the third charging current and the second preset current protection threshold.
[0206] Thus, by using the third charging current at the moment before the electronic device disconnects from the first external device, and the second preset current protection threshold, the candidate current adjustment parameters can be accurately determined when the cause of the abnormal disconnection is that the first charging current is greater than the first preset current protection threshold of the first external device.
[0207] Optionally, the processor 510 is further configured to, when the abnormal disconnection is caused by the ground loop voltage of the first external device being greater than a preset ground loop voltage threshold, acquire a first voltage amplitude threshold of the differential signal of the USB line as specified in the USB eye diagram, and a second voltage amplitude threshold of the differential signal as specified in the charging protocol; and determine the candidate current adjustment parameter based on the first voltage amplitude threshold and the second voltage amplitude threshold.
[0208] Thus, by using the first voltage amplitude threshold of the differential signal of the USB line specified in the obtained USB eye diagram and the second voltage amplitude threshold of the differential signal specified in the charging protocol, the candidate current adjustment parameters can be accurately determined when the ground loop voltage of the first external device is greater than the preset ground loop voltage threshold due to the abnormal disconnection.
[0209] Optionally, the radio frequency unit 501 is further configured to, in the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, obtain a first charging current between the electronic device and the first external device at a first moment before the disconnection; and if the communication connection between the electronic device and the first external device is not restored based on the second charging current, obtain a fourth charging current between the electronic device and the first external device at a second moment before the disconnection.
[0210] The processor 510 is further configured to determine a second current adjustment parameter based on the cause of the abnormal disconnection between the electronic device and the first external device; determine a fifth charging current based on the second current adjustment parameter and the fourth charging current; and restore the communication connection between the electronic device and the first external device based on the fifth charging current.
[0211] Thus, if the communication connection between the electronic device and the first external device is not restored based on the second charging current, the fourth charging current between the electronic device and the first external device at the second moment before the disconnection can be obtained again. Then, the fourth charging current is adjusted to obtain the fifth charging current. The communication connection between the electronic device and the first external device is restored based on the fifth charging current. In this way, if the communication connection between the electronic device and the first external device cannot be restored based on the adjusted charging current, the charging current at different moments before the disconnection can be continuously obtained again, and the charging current can be continuously adjusted to ensure that the communication connection between the electronic device and the first external device can be restored.
[0212] Optionally, the processor 510 is further configured to output a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected when the number of attempts to restore the connection exceeds a preset number; or, when the fifth charging current is less than or equal to a second preset current protection threshold, output a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected.
[0213] Thus, when the fifth charging current is less than the second preset current protection threshold, or when the number of attempts to restore the connection is greater than the preset number, a prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected can be output. This prompts the user that the communication connection between the electronic device and the first external device is abnormally disconnected, so that the user can make other adjustments to the communication connection between the electronic device and the first external device in a timely manner.
[0214] Optionally, the processor 510 is further configured to not output a prompt message indicating that the communication connection between the electronic device and the first external device was abnormally disconnected when the communication connection between the electronic device and the first external device is restored based on the second charging current.
[0215] Thus, when the communication connection between the electronic device and the first external device is restored based on the second charging current, no prompt message indicating that the communication connection between the electronic device and the first external device is abnormally disconnected is output, so that the user will not perceive that the communication connection between the electronic device and the first external device is abnormally disconnected.
[0216] It should be understood that, in this embodiment, the input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The GPU 5041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 507 includes at least one of a touch panel 5071 and other input devices 5072. The touch panel 5071 is also called a touch screen. The touch panel 5071 may include a touch detection device and a touch controller. Other input devices 5072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
[0217] The memory 509 can be used to store software programs and various data. The memory 509 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 509 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 509 in this embodiment includes, but is not limited to, these and any other suitable types of memory.
[0218] Processor 510 may include one or more processing units; optionally, processor 510 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 510.
[0219] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described USB external device connection recovery method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0220] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0221] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled. The processor is used to run programs or instructions to implement the various processes of the above-described USB external device connection recovery method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0222] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0223] This application provides a computer program product stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the USB external device connection recovery method embodiment described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0224] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0225] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0226] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for connecting an external device, characterized in that, The method includes: In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the electronic device and the first external device before the disconnection is obtained; the electronic device and the first external device establish a communication connection based on a USB cable; The first current adjustment parameter is determined based on the reason for the abnormal disconnection between the electronic device and the first external device; The second charging current is determined based on the first current adjustment parameter and the first charging current. The communication connection between the electronic device and the first external device is restored based on the second charging current.
2. The method according to claim 1, characterized in that, The communication connection between the electronic device and the first external device is abnormally disconnected for at least two reasons; The step of determining the first current adjustment parameter based on the cause of the abnormal disconnection between the electronic device and the first external device includes: For each abnormal disconnection cause, determine the corresponding candidate current regulation parameter; The first current regulation parameter is determined based on at least two of the candidate current regulation parameters.
3. The method according to claim 2, characterized in that, The process of determining the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection includes: When the abnormal disconnection is caused by the first charging voltage of the first external device charging the electronic device being greater than the first preset voltage protection threshold of the first external device, the second charging voltage of the electronic device at the moment before the disconnection from the first external device is obtained, as well as the second preset voltage protection threshold specified in the charging protocol. The candidate current adjustment parameters are determined based on the second charging voltage and the second preset voltage protection threshold.
4. The method according to claim 2, characterized in that, The process of determining the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection includes: If the reason for the abnormal disconnection is that the first charging current is greater than the first preset current protection threshold of the first external device, the third charging current and the second preset current protection threshold are obtained at the moment before the electronic device disconnects from the first external device. The candidate current adjustment parameters are determined based on the third charging current and the second preset current protection threshold.
5. The method according to claim 2, characterized in that, The process of determining the candidate current adjustment parameters corresponding to the cause of the abnormal disconnection includes: When the abnormal disconnection is caused by the ground loop voltage of the first external device being greater than a preset ground loop voltage threshold, the first voltage amplitude threshold of the differential signal of the USB line as specified in the USB eye diagram and the second voltage amplitude threshold of the differential signal as specified in the charging protocol are obtained. The candidate current adjustment parameters are determined based on the first voltage amplitude threshold and the second voltage amplitude threshold.
6. The method according to claim 2, characterized in that, In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, obtaining the first charging current between the electronic device and the first external device before the disconnection includes: In the event of an abnormal disconnection of the communication connection between the electronic device and the first external device, the first charging current between the electronic device and the first external device is obtained at the first moment before the disconnection. The method further includes: If the communication connection between the electronic device and the first external device is not restored based on the second charging current, obtain the fourth charging current between the electronic device and the first external device at the second moment before the disconnection; The second current adjustment parameter is determined based on the reason for the abnormal disconnection between the electronic device and the first external device; The fifth charging current is determined based on the second current adjustment parameter and the fourth charging current; The communication connection between the electronic device and the first external device is restored based on the fifth charging current.
7. The method according to claim 6, characterized in that, The method further includes: If the number of attempts to restore the connection exceeds a preset number, an error message indicating that the communication connection between the electronic device and the first external device has been abnormally disconnected will be output. Alternatively, if the fifth charging current is less than or equal to the second preset current protection threshold, a prompt message indicating that the communication connection between the electronic device and the first external device has been abnormally disconnected is output.
8. A connection device for an external device, characterized in that, The device includes: The acquisition module is used to acquire the first charging current between the electronic device and the first external device before the communication connection between the electronic device and the first external device is abnormally disconnected; the electronic device and the first external device establish a communication connection based on a USB cable. The determining module is used to determine the first current adjustment parameter based on the reason for the abnormal disconnection between the electronic device and the first external device; The determining module is further configured to determine the second charging current based on the first current adjustment parameter and the first charging current; A connection restoration module is used to restore the communication connection between the electronic device and the first external device based on the second charging current.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the connection method for an external device as described in any one of claims 1-7.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the connection method for an external device as described in any one of claims 1-7.