A reverse charging method, a first electronic device and related media

By periodically updating and saving the power information of the charging port in the first electronic device, the problem that the laptop cannot respond to the phone charging parameter query in a timely manner is solved, and the stability of reverse charging and user experience is improved.

CN118748457BActive Publication Date: 2025-04-11HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411076625.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2025-04-11
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

During the reverse charging of the laptop for the mobile phone, the laptop may not respond to the mobile phone's inquiry request for charging parameters in a timely manner, resulting in the interruption of charging of the mobile phone.

Method used

By obtaining the power information of the charging port in the first electronic device (such as a laptop), and saving it in memory, updating the power information in a preset period, receiving query instructions sent by the second electronic device (such as a mobile phone), reading the power information from the memory and sending it to the second electronic device.

Benefits of technology

Ensure that the second electronic device can quickly obtain the latest power information, avoid charging interruptions, and improve the stability and user experience of reverse charging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118748457B_ABST
    Figure CN118748457B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a reverse charging method, a first electronic device and related media, the method is applied to the first electronic device, the first electronic device includes a charging port and a memory, the method includes: in response to the second electronic device being connected to the first electronic device through the charging port, charging the second electronic device through the charging port; obtaining the power information of the charging port, and saving the power information in the memory; updating the power information according to a preset period; receiving a query instruction sent by the second electronic device, reading the power information from the memory based on the query instruction, and sending the power information to the second electronic device. By implementing the method of the present application, the first electronic device can improve the efficiency of reading the power information and timely feed back the power information to the second electronic device, which helps to prevent the situation of disconnection in the process of the first electronic device charging the second electronic device, and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a reverse charging method, a first electronic device and related media. Background Art

[0002] With the development of Internet technology, electronic devices can provide users with a variety of functions, such as entertainment, office, communication and life functions, which makes users use electronic devices more frequently. Therefore, electronic devices need stronger battery life, more efficient charging technology or more diverse charging methods to meet users' needs. At present, the existing technology can use laptops to reverse charge mobile phones, providing users with a new way to charge mobile phones, helping to avoid the situation where the mobile phone is shut down due to low power, and ensuring the user experience. The disadvantage is that in the process of reverse charging the mobile phone by the laptop, the laptop may not be able to respond to the mobile phone's query request for charging parameters in time, resulting in the interruption of mobile phone charging.

[0003] Therefore, how to improve the stability of reverse charging is a problem that technical personnel in this field need to solve urgently. Summary of the invention

[0004] In a first aspect, the present application provides a reverse charging method, a first electronic device, and related media. The method is applied to an electronic device, and the electronic device may include a charging port and a memory. The method may include:

[0005] In response to the second electronic device being connected to the first electronic device through the charging port, charging the second electronic device through the charging port;

[0006] Acquire power information of the charging port and save the power information in the memory, where the power information may include the current current value and voltage value of the charging port;

[0007] Update power information according to preset cycles;

[0008] A query instruction sent by the second electronic device is received, power information is read from the memory based on the query instruction, and the power information is sent to the second electronic device.

[0009] By implementing the method provided in the first aspect, a second electronic device (such as a mobile phone) can establish a connection with a first electronic device (such as a laptop) through a charging port, and the first electronic device can charge the second electronic device through the charging port. Optionally, the first electronic device also obtains the power information of the charging port and updates the power information according to a preset period. The power information is stored in the memory of the first electronic device. After the first electronic device receives the query instruction sent by the second electronic device, the first electronic device can read the power information from the memory based on the query instruction and send it to the second electronic device, which helps to shorten the time of feeding back the power information to the second electronic device and prevent the occurrence of charging interruption caused by the second electronic device not receiving the power information of the first electronic device within the preset time, thereby avoiding a bad charging experience for the user. In the prior art, the power information of the charging port is obtained through the analog-to-digital converter each time after receiving the query instruction sent by the second electronic device, and the speed of reading the power information cannot be guaranteed, which may cause the second electronic device to fail to receive the power information of the first electronic device within the preset time. At this time, in order to ensure the charging safety of the device, the second electronic device will choose to interrupt the charging, and the user needs to reconnect the second electronic device to the first electronic device through the charging port to continue charging the second electronic device, which greatly reduces the user's experience. The difference is that after the second electronic device in the embodiment of the present application is connected to the first electronic device through the charging port, the first electronic device will periodically update the power information stored in the memory, so that no matter when the second electronic device sends a query request, the first electronic device can quickly feedback the latest power information to the second electronic device, thereby effectively avoiding the occurrence of charging failure of the second electronic device.

[0010] In some embodiments of the method provided in the first aspect, if the first electronic device does not send the power information to the second electronic device within a preset time period after receiving the query instruction, charging is interrupted.

[0011] In some embodiments of the method provided in the first aspect, before charging the second electronic device, the method may further include:

[0012] receiving a charging request sent by a second electronic device, where the charging request may include power receiving parameters required for charging the second electronic device, where the power receiving parameters may include a power receiving voltage value and a power receiving current value;

[0013] When the charging parameters of the first electronic device match the power receiving parameters, the second electronic device is charged. The charging parameters may include a charging voltage range and a charging current value of the first electronic device.

[0014] By implementing the method provided in the above embodiment, the first electronic device charges the second electronic device only when its own charging parameters match the power receiving parameters of the second electronic device, which helps to prevent the second electronic device from experiencing faults such as battery burnout or battery bulging, thereby ensuring the charging safety of the second electronic device and the user experience. Among them, the charging parameters of the first electronic device may include the charging voltage range and charging current value of the first electronic device. Specifically, after the second electronic device is connected to the first electronic device through the charging port, the first electronic device will receive a charging request sent by the second electronic device, wherein the charging request may include the power receiving parameters required for charging the second electronic device, and the power receiving parameters may include the power receiving voltage value and the power receiving current value.

[0015] In some embodiments, the method provided in the first aspect may include:

[0016] If the power receiving voltage value in the power receiving parameters is within the charging voltage range, and the power receiving current value is the same as the charging current value, it is considered that the charging parameters match the power receiving parameters.

[0017] Implementing the method provided in the first aspect, in some embodiments, the method may further include:

[0018] In response to the first electronic device being powered on, a charging thread is initialized and running resources are allocated, and the charging thread can be used to obtain and / or update power information according to a preset period;

[0019] In response to the second electronic device being connected to the first electronic device through the charging port, a charging thread is executed.

[0020] By implementing the method provided in the above embodiment, the first electronic device can realize the periodic collection of the above-mentioned power information based on the charging thread. Specifically, in response to the first electronic device being powered on, the first electronic device can initialize the charging thread and allocate operating resources to the charging thread, wherein the charging thread can be used to obtain and / or update the power information according to a preset period. Optionally, in response to the second electronic device being connected to the first electronic device through the charging port, the first electronic device can start running the charging thread, thereby achieving the purpose of collecting and / or updating the power information according to a preset period, which helps to ensure that the first electronic device can subsequently feedback the power information to the second electronic device in a timely manner, avoid the occurrence of the second electronic device being disconnected from charging, and thus ensure the user's experience.

[0021] In some embodiments of the method provided in the first aspect, in response to the second electronic device being connected to the first electronic device through the charging port, running a charging thread may include:

[0022] In response to the second electronic device being connected to the first electronic device through the charging port, establishing a first event;

[0023] In response to a loop function in the first electronic device detecting a first event, setting a charging flag bit to true, setting and starting a first timer, and acquiring power information of a charging port based on an analog-to-digital converter;

[0024] Store power information in memory;

[0025] Delete the first event.

[0026] By implementing the method provided in the above embodiment, after the second electronic device is connected to the first electronic device through the charging port, the power information of the charging port in this charging event is collected for the first time, and the charging flag and the first timer are set, which is helpful for the subsequent periodic update of the power information of the charging port. Specifically, in response to the second electronic device being connected to the first electronic device through the charging port, the charging thread in the first electronic device establishes a first event. Optionally, in response to the loop function in the first electronic device detecting the first event, the charging flag can be set to true, the first timer can be set and started, and the power information of the charging port can be obtained based on the analog-to-digital converter, wherein the power information obtained this time can be understood as the first time the power information of the charging port is obtained during this charging process. Further, the charging thread can delete the first event, which helps to prevent the subsequent thread from running in confusion. Among them, by setting and running the first timer, the first electronic device can be realized to periodically update the power information, which helps to ensure that the first electronic device can promptly feedback the power information to the second electronic device in the future, avoid the occurrence of the second electronic device being disconnected from charging, and thus ensure the user's experience.

[0027] Implementing the method provided in the first aspect, in some embodiments, the method may further include:

[0028] In response to the first timer counting down to an end, establishing a second event;

[0029] In response to the loop function detecting the second event, determining whether the charging flag is true;

[0030] When the charging flag is true, the latest power information is obtained through the analog-to-digital converter, the power information in the memory is changed to the latest power information, and the first timer is set and started;

[0031] Delete the second event.

[0032] By implementing the method provided in the above embodiment, based on the working state of the first timer, the first electronic device can achieve the effect of periodically updating the power information. Specifically, in response to the end of the countdown of the first timer, the charging thread in the first electronic device can establish a second event. Further, in response to the loop function detecting the second event, it is determined whether the charging flag is true; when the charging flag is true, the latest power information is obtained through the analog-to-digital converter, and the power information in the memory is changed to the latest power information, and the first timer is set and started, thereby achieving the effect of periodically updating the power information. Furthermore, the charging thread can delete the second event, which helps prevent confusion in the operation of subsequent threads.

[0033] Implementing the method provided in the first aspect, in some embodiments, the method may further include:

[0034] In response to the second electronic device being disconnected from the first electronic device, establishing a third event;

[0035] In response to the loop function detecting the third event, setting the charging flag bit to false and turning off the first timer;

[0036] Clear the third event.

[0037] By implementing the method provided in the above embodiment, after the second electronic device is disconnected from the first electronic device, the charging thread in the first electronic device can set the charging flag to false, thereby avoiding the situation where the first electronic device periodically updates the power information after being disconnected from the second electronic device, and preventing the first electronic device from wasting operating resources. Specifically, in response to the second electronic device being disconnected from the first electronic device, the charging thread in the first electronic device can establish a third event. Further, in response to the loop function detecting the third event, the charging thread can set the charging flag to false and turn off the first timer. Further, the charging thread can delete the third event, which helps to avoid the first electronic device from wasting operating resources due to repeated processing of the third event.

[0038] In a second aspect, an embodiment of the present application provides a first electronic device, which can be used to charge a second electronic device, and the first electronic device includes: a charging module and a processing module;

[0039] a charging module, which can be used to charge the second electronic device in response to the second electronic device being connected to the first electronic device through the charging port;

[0040] The processing module can be used to obtain power information of the charging port, where the power information includes a current value and a voltage value of the charging port of the first electronic device;

[0041] The processing module can also be used to store the power information in the memory and update the power information according to a preset period;

[0042] The processing module may also be used to read the power information from the memory in response to a query instruction sent by the second electronic device;

[0043] The processing module can also be used to send the power information to the second electronic device.

[0044] In some embodiments of the method provided in the second aspect, if the first electronic device does not send the power information to the second electronic device within a preset time period after receiving the query instruction, charging is interrupted.

[0045] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include:

[0046] The processing module may also be used to receive a charging request from a second electronic device, where the charging request may include power receiving parameters required for charging the second electronic device, where the power receiving parameters may include a power receiving voltage value and a power receiving current value;

[0047] The charging module can also be used to charge the second electronic device when the charging parameters of the first electronic device match the power receiving parameters. The charging parameters can include the charging voltage range and charging current value of the first electronic device.

[0048] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include:

[0049] If the power receiving voltage value in the power receiving parameters is within the charging voltage range, and the power receiving current value is the same as the charging current value, it is considered that the charging parameters match the power receiving parameters.

[0050] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include:

[0051] The processing module may also be used to initialize a charging thread and allocate running resources in response to the first electronic device being powered on, and the charging thread may be used to obtain and / or update the power information according to a preset period;

[0052] The processing module may also be configured to execute a charging thread in response to the second electronic device being connected to the first electronic device via the charging port.

[0053] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include:

[0054] The processing module may also be used to establish a first event in response to the second electronic device being connected to the first electronic device via the charging port;

[0055] The processing module may also be used to, in response to the cyclic function in the first electronic device detecting the first event, set the charging flag to true, set and start the first timer, and obtain the power information of the first electronic device based on the analog-to-digital converter;

[0056] The processing module can also be used to store the power information in the memory;

[0057] The processing module can also be used to delete the first event.

[0058] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include: a judgment module;

[0059] The processing module may also be used to establish a second event in response to the first timer counting down ending;

[0060] A judging module, which can be used to judge whether the charging flag is true in response to the loop function detecting the second event;

[0061] The processing module may also be used to obtain the latest power information through the analog-to-digital converter when the charging flag is true, change the power information in the memory to the latest power information, and set and start the first timer;

[0062] The processing module can also be used to delete the second event.

[0063] To implement the method provided in the second aspect, in some embodiments, the first electronic device may further include:

[0064] The processing module may also be used to establish a third event in response to the second electronic device being disconnected from the first electronic device;

[0065] The processing module may also be configured to, in response to the loop function detecting a third event, set a charging flag bit to false and turn off the first timer;

[0066] The processing module can also be used to clear the third event.

[0067] In a third aspect, an embodiment of the present application provides a first electronic device, which includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the method described in the first aspect and any possible implementation method of the first aspect is executed.

[0068] In a fourth aspect, an embodiment of the present application provides a chip, comprising a logic circuit and an interface, wherein the logic circuit and the interface are coupled; the interface is used to input and / or output code instructions, and the logic circuit is used to execute the code instructions so that the method in the first aspect or any possible implementation of the first aspect is executed.

[0069] In a fifth aspect, the present application provides a computer-readable storage medium comprising instructions, which, when executed on a target terminal, execute the method described in the first aspect and any possible implementation of the first aspect.

[0070] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect.

[0071] It can be understood that the first electronic device provided in the second and third aspects, the chip provided in the fourth aspect, the computer-readable storage medium provided in the fifth aspect, and the computer program product provided in the sixth aspect are all related to the interface display method based on operation gestures provided in the first aspect, and can be used to execute the method provided in the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of the interface display method based on operation gestures in the corresponding first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0073] Figure 1 This is a schematic diagram of a mobile phone charging scenario provided in an embodiment of the present application;

[0074] Figure 2 It is a flowchart of a reverse charging method provided in an embodiment of the present application;

[0075] Figure 3a is a schematic diagram of the composition of a first electronic device provided in an embodiment of the present application;

[0076] Figure 3b is a schematic diagram of the composition of a second electronic device provided in an embodiment of the present application;

[0077] Figure 4a It is a charging interaction flow chart provided in an embodiment of the present application;

[0078] Figure 4b is another charging interaction flow chart provided in an embodiment of the present application;

[0079] Figure 4c This is another charging interaction flow chart provided in an embodiment of the present application;

[0080] Figure 5 This is a workflow diagram of a charging thread provided in an embodiment of the present application;

[0081] Figure 6a It is a schematic diagram of a flow chart of electric energy information interaction provided by an embodiment of the present application;

[0082] Figure 6b is a schematic diagram of another flow chart of electric energy information interaction provided by an embodiment of the present application;

[0083] Figure 7 is a schematic diagram of the composition of a first electronic device provided in an embodiment of the present application;

[0084] Figure 8 is a schematic diagram of the hardware structure of a first electronic device provided in an embodiment of the present application;

[0085] Fig. 9 It is a software structure block diagram of a first electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0086] The technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the accompanying drawings. The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in the context. It should also be understood that in the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a kind of association relationship describing the associated objects, indicating that there can be three relationships, for example, A and / or B, can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" refers to two or more than two.

[0087] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0088] The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device and finally presented as content that the user can recognize. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operations that is displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.

[0089] In order to make the description of the following embodiments clear and concise, a brief introduction to the related technology is first given:

[0090] (1) Fast charging protocol

[0091] The fast charge protocol is a battery charging technology that shortens the charging time of a device by improving charging efficiency. It does this by establishing a communication mechanism between the charger and the device, so that the charger can adjust the output voltage and current according to the needs and status of the device. This communication mechanism is defined by the fast charge protocol, which determines how the device and charger identify and communicate with each other, and how to adjust the power output. By using the fast charge protocol, the device can charge as fast as possible while being safe, rather than simply charging with the maximum current, which can cause the battery to overheat or damage.

[0092] Fast charging protocols usually include a handshake mechanism, which is an electronic dialogue process that allows devices (such as mobile phones) and chargers to recognize each other and charge at the correct voltage and current. The handshake phase occurs after the device is plugged into the charger, and the device and charger exchange information, including the fast charging protocol version supported by the device, the maximum accepted current, etc.

[0093] After a successful handshake, the charger will adjust the output voltage and current according to the needs of the device. For example, some devices can accept higher voltage and current when the battery is low for fast charging, but when the battery is close to full, the charger will reduce the voltage and current to protect the battery and extend its life.

[0094] It should be noted that different fast charging protocols have different working principles. For example, some fast charging protocols may use more complex communication mechanisms, such as modulation / demodulation technology, to support more complex charging modes, such as constant current / constant voltage charging. Other fast charging protocols may adjust voltage and current based on the device's temperature, battery chemistry, or other factors.

[0095] (2) Power transmission protocol

[0096] The USB Power Delivery (USB PD) protocol is a charging protocol developed by the USB Standardization Organization (USB Implementers Forum, USB-IF). It not only supports charging small devices such as mobile phones and tablets, but also high-power devices such as laptops. This is because the maximum output power supported by the USB PD protocol can reach 240W (in the PD3.1 version), which is much higher than other common fast charging protocols.

[0097] The core advantage of the USB PD protocol is its intelligent power management. The protocol allows devices and chargers to conduct fine power negotiation in order to provide the charging voltage and current that best suits the device. The USB PD protocol supports a variety of different voltage levels, including 5V, 9V, 12V, 15V, and 20V, as well as the extended power capability introduced in the PD3.1 version, which can provide up to 48V.

[0098] It is worth noting that the USB PD protocol can not only charge devices, but also provide bidirectional power supply, which means that if a laptop supports the USB PD protocol, users can use the laptop to charge mobile phones or other devices.

[0099] (3) Programmable power supply protocol

[0100] The Programmable Power Supply (PPS) protocol is a fast charging technology specification launched by the USB-IF organization during the 2017 Spring Festival. The protocol aims to provide users with a more convenient and efficient charging experience. Among them, the PPS protocol is part of the USB PD 3.0 protocol, which is essentially a PD protocol. It supports a variety of voltage and current combinations, allowing the charger to be intelligently adjusted according to the needs of the device. Moreover, compared with other versions of the PD protocol, the PPS protocol can make the voltage regulation more accurate, thereby achieving better fast charging effects.

[0101] See also Figure 1 , Figure 1 A schematic diagram of a mobile phone charging scenario provided in an embodiment of the present application.

[0102] like Figure 1 As shown, users can use laptops to charge their mobile phones. Specifically, during the charging process of the mobile phone, the mobile phone can periodically obtain power information from the laptop charging port to determine whether the power provided by the laptop to the mobile phone meets the needs of the mobile phone. If not, the mobile phone can disconnect from the laptop in time to avoid overheating or damage to the mobile phone battery. The power information may include the current voltage and current values ​​of the laptop charging port.

[0103] Furthermore, after the mobile phone sends a query command to the laptop, it sets and starts a timer. If the mobile phone does not receive the power information fed back by the laptop before the countdown of the timer ends, the mobile phone will disconnect from the laptop. The query command can be used to query the power information of the charging port.

[0104] Among them, after receiving the query command sent by the mobile phone, the laptop can use the analog to digital converter (ADC) to obtain the corresponding power information. Specifically, the ADC can convert the electrical signals of each port of the laptop into digital signals and store them in the register, but the storage location of the corresponding digital signals of each port is not fixed. Therefore, the time it takes for the laptop to feed back the power information to the mobile phone is also not fixed, which is proportional to the time it takes for the laptop to read the corresponding digital signal from the register. It can be seen that since the laptop cannot guarantee the time to feed back the power information to the mobile phone, it may happen that "the mobile phone does not receive the power information fed back by the laptop before the countdown of the timer ends", resulting in the interruption of mobile phone charging, which greatly reduces the user experience.

[0105] To solve the above problems, the method of the embodiment of the present application allows the laptop computer to periodically obtain power information and save the power information in the memory of the first electronic device. Optionally, after receiving the query instruction sent by the mobile phone, the laptop computer can directly read the latest power information from the memory in response to the query instruction and feed it back to the mobile phone, which helps to shorten the time for the laptop computer to feed back power information to the mobile phone, prevent the situation of charging interruption when the first electronic device is charging the second electronic device, and improve the user experience.

[0106] See also Figure 2 , Figure 2 A flowchart of a reverse charging method provided in an embodiment of the present application.

[0107] like Figure 2As shown, the method is applied to a first electronic device 100, and the first electronic device 100 may include a charging port and a memory; the method may include the following steps:

[0108] S201: In response to a second electronic device being connected to a first electronic device via a charging port, charging the second electronic device via the charging port.

[0109] It should be noted that the method of the embodiment of the present application can be applied to the first electronic device 100, see Figure 3a , Figure 3a The following is a schematic diagram of the composition of a first electronic device provided in an embodiment of the present application. Figure 3a As shown, the first electronic device 100 may include a first screen 310, a keyboard 320, and a charging port 330. The first electronic device 100 may also be referred to as a user equipment (UE), which may be a notebook computer or other device that supports the PPS charging protocol and has the ability to charge other devices. The specific structure of the first electronic device 100 may refer to Figure 8 and Fig. 9 The relevant content will not be elaborated here.

[0110] Optionally, the first electronic device 100 can be used to charge the second electronic device 200 (it can be understood that the first electronic device 100 can charge the second electronic device 200), see Figure 3b , Figure 3b The following is a schematic diagram of the composition of a second electronic device provided in an embodiment of the present application. Figure 3b As shown, the second electronic device 200 includes a second screen 340 and a power receiving port 350. The second electronic device 200 may be a mobile phone, a tablet, a smart watch or other mobile electronic devices supporting the PPS charging protocol.

[0111] In some possible implementations, before charging the second electronic device 200, the method may further include:

[0112] receiving a charging request from the second electronic device 200, where the charging request may include power receiving parameters required for charging the second electronic device 200, where the power receiving parameters may include a power receiving voltage value and a power receiving current value;

[0113] When the charging parameters of the first electronic device 100 match the power receiving parameters, the second electronic device 200 is charged. The charging parameters may include a charging voltage range and a charging current value of the first electronic device 100 .

[0114] Optionally, before receiving the charging request from the second electronic device 200, the first electronic device 100 may broadcast its charging capability to the second electronic device 200. For example, if the first electronic device 100 can provide a voltage of 3.3V to 11V and a current of 2A to other electronic devices, the charging capability of the first electronic device 100 may be considered to be "providing a voltage of 3.3V to 11V and a current of 2A".

[0115] Optionally, the second electronic device 200 may generate a charging request based on the power receiving parameters required for its own charging. For example, if the power receiving parameters corresponding to the second electronic device 200 are "5V, 2A", the second electronic device 200 may write the power receiving parameters into the charging request and send it to the first electronic device 100.

[0116] Optionally, if the power receiving voltage value in the power receiving parameter is within the charging voltage range, and the power receiving current value is the same as the charging current value, then the charging parameter is considered to match the power receiving parameter. Exemplarily, in combination with the above example of the charging capability of the first electronic device 100, it can be considered that the charging parameter of the first electronic device 100 is "3.3V~11V, 2A", wherein the charging voltage range is 3.3V to 11V, and the charging current is 2A. Among them, for the case where the charging parameter of the first electronic device 100 does not match the power receiving parameter of the second electronic device 200, if the first electronic device 100 forcibly transmits power to the second electronic device 200, it may cause the battery of the second electronic device 200 to overheat or be damaged. Therefore, in order to ensure the safety of the components of the second electronic device, when the charging parameter of the first electronic device 100 does not match the power receiving parameter of the second electronic device 200, the first electronic device 100 will not respond to the charging request of the second electronic device 200, that is, it will not charge the second electronic device 200.

[0117] Exemplarily, assuming that the charging parameters of the first electronic device 100 are "3.3V~11V, 2A", if the corresponding power receiving parameters of the second electronic device 200 are "5V, 2A", it can be considered that the charging parameters match the power receiving parameters, so the first electronic device 100 can start to power / charge the second electronic device 200; if the corresponding power receiving parameters of the second electronic device 200 are "3V, 2A", it can be considered that the charging parameters and the power receiving parameters do not match, so the first electronic device 100 cannot respond to the charging request of the second electronic device 200, that is, it cannot charge the second electronic device 200; if the corresponding power receiving parameters of the second electronic device 200 are "5V, 2.5A", it can be considered that the charging parameters and the power receiving parameters do not match, so the first electronic device 100 cannot respond to the charging request of the second electronic device 200, that is, it cannot charge the second electronic device 200.

[0118] See also Figure 4a-4c , Figure 4a-4c A charging interaction flow chart provided for an embodiment of the present application.

[0119] Optionally, Figure 4a-4c The interactive flow chart shown is used to present the interactive process after the first electronic device 100 has broadcast its own charging capability to the second electronic device 200. The step of the first electronic device 100 broadcasting its own charging capability can refer to the following description:

[0120] In the second electronic device 200 (which can be understood as Figure 4a The Sink in the charging port is connected to the first electronic device 100 (which can be understood as Figure 4a After the connection is made to the Source on the Source side, the policy engine Source Policy Engine on the Source side can generate a broadcast data packet, wherein the broadcast data packet can contain information related to the charging capability of the first electronic device 100. Further, the protocol layer Protocol and the physical layer PHY on the Source side can transmit the broadcast data packet to the physical layer on the Sink side, and the broadcast data packet of the first electronic device 100 can eventually be transmitted to the policy engine on the Sink side through the forwarding of the physical layer and the protocol layer on the Sink side. Among them, the physical layer of the first electronic device 100 will not only send the broadcast data packet to the physical layer of the second electronic device 200, but also send the first verification code to the second electronic device 200 at the same time, which helps to help the second electronic device 200 verify whether the broadcast data packet is correctly and completely transmitted. Among them, after the protocol layer on the Sink side receives the broadcast data packet sent by the first electronic device 100, it can check whether the broadcast data packet complies with the preset transmission rules. Optionally, the preset transmission rules can be verification rules set in the PPS charging protocol. Wherein, when the first check code complies with the preset transmission rule, the protocol layer of the second electronic device 200 can generate a first check correct message (such as Good CRC), and send the first check correct message to the first electronic device 100 through the hardware layer of the second electronic device 200, which is used to indicate that the broadcast data packet of the first electronic device 100 complies with the preset communication rule, or the broadcast data packet of the first electronic device 100 is correctly and completely received by the second electronic device 200. Wherein, when the hardware layer of the second electronic device 200 sends the first check correct message to the first electronic device 100, it also sends the second check code corresponding to the first check correct message to the first electronic device 100, which helps the first electronic device 100 to verify whether the first check correct message is correctly and completely transmitted.

[0121] Among them, see Figure 4a , Figure 4a A charging interaction flow chart provided in an embodiment of the present application, such as Figure 4aAs shown, after the second electronic device 200 receives the broadcast data packet of the first electronic device 100, the first policy engine (which can be understood as Figure 4a The Source Policy Engine on the Sink side shown in the figure can generate and send to the first protocol layer (which can be understood as Figure 4a The Sink side Protocol shown in the figure) sends a "send charging request" instruction (such as Figure 4a ), and sets and starts a PPS response timer (optionally, the step of "setting and starting a PPS response timer" can be expressed as a PPSResponseTimer Timeout step), wherein, if the second electronic device 200 does not receive a response message from the first electronic device 100 before the countdown of the response timer ends, it is deemed that the first electronic device 100 does not respond to the charging request of the second electronic device 200, and therefore the second electronic device 200 cannot obtain power from the first electronic device 100.

[0122] Optionally, the charging request generated by the first protocol layer of the second electronic device 200 may be received via the first physical layer (which may be understood as Figure 4aThe first physical layer of the second electronic device 200 transmits the charging request to the first electronic device 100, and also transmits the third check code corresponding to the charging request to the first electronic device 100. Optionally, the check code can also be understood as a cyclic redundancy check code (CRC), which helps the first electronic device 100 to verify whether the charging request is completely and correctly transmitted. Further, the first protocol layer of the second electronic device 200 can set and start the first check code receiving timer (optionally, the step of "setting and starting the first check code receiving timer" can be expressed as the Start CRCReceive Timer step) while transmitting the charging request to the first physical layer. If the second electronic device 200 receives the second check correct message sent by the first electronic device 100 before the countdown of the first check code receiving timer ends (optionally, the second check correct message can be understood as the GoodCRC message in the USB PD protocol), it can be considered that the charging request of the second electronic device 200 is completely and correctly transmitted to the first electronic device 100, and it can also indicate that the first electronic device 100 has received the charging request of the second electronic device 200. Further, the first protocol layer checks whether the second check-correct message complies with the preset transmission rules (optionally, the step of "checking whether the second check-correct message complies with the preset transmission rules" can be expressed by the step of Check and increment MessageIDCounter). Wherein, if the second check-correct message complies with the preset transmission rules, the first protocol layer can stop the first check code receiving timer (optionally, the step of "stopping the first check code receiving timer" can be expressed by the step of Stop CRCReceive Timer).

[0123] Further, when the second verification correct message complies with the preset transmission rule, the first protocol layer may send a message to the first policy engine that "the charging request has been completely and correctly sent to the first electronic device 100" (optionally, the message "the charging request has been completely and correctly sent to the first electronic device 100" may be expressed as a Request sent message). Further, in response to the Request sent message, the first policy engine may set and start a first response timer (optionally, the step of "setting and starting a first response timer" may be expressed as a Start SenderResponse Timer step), and turn off the PPS response timer (optionally, the step of "turning off the PPS response timer" may be expressed as a Stop PPSRequestTimer step), wherein, if the second electronic device 200 does not receive an acceptance message (which may be understood as an Accept message) from the first electronic device 100 before the countdown of the first response timer ends, it may choose to re-initiate the charging request, or choose to disconnect from the first electronic device 100.

[0124] Furthermore, the first electronic device 100 can pass through the second physical layer (which can be understood as Figure 4a The PHY on the Source side in the example receives the charging request sent by the second electronic device 200, and forwards the charging request to the second protocol layer (which can be understood as Figure 4aThe second protocol layer may verify the charging request (optionally, the step of "verifying the charging request" may be expressed as the step of Check MessageID against local copy). Wherein, when the charging request complies with the preset transmission rule, the second protocol layer may save the MessageID corresponding to the charging request (optionally, the step of "saving the MessageID corresponding to the charging request" may be expressed as the step of Store copy of MessageID), and generate a second verification correct message. Furthermore, the second hardware layer may send the second verification correct message to the second electronic device 200, and at the same time, may also send the fourth verification code corresponding to the second verification correct message to the second electronic device 200, which may help the second electronic device 200 to subsequently verify whether the second verification correct message is transmitted completely and correctly. Optionally, the second protocol layer may send a request receiving instruction to the second policy engine (optionally, the "request receiving" instruction may be expressed as the Request received instruction). In response to the request receiving instruction, the second policy engine may close the second response timer (optionally, the "close the second response timer" step may be expressed as the Stop SenderResponseTimer step), and close the PPS communication timer (optionally, the "close the PPS communication timer" step may be expressed as the StopPPSComm Timer step), indicating that the first electronic device 100 has received the charging request of the second electronic device 200 and is ready to start processing the charging request. Further, the second policy engine may evaluate whether the power receiving parameters in the charging request of the second electronic device 200 match the charging parameters of the first electronic device 100 (optionally, the "evaluate whether the power receiving parameters in the charging request of the second electronic device 200 match the charging parameters of the first electronic device 100" step may be expressed as the Evaluate Request step on the Source side).

[0125] Optionally, see Figure 4b , Figure 4b Another charging interaction flow chart provided in the embodiment of the present application is as follows: Figure 4bAs shown, when the power receiving parameters of the second electronic device 200 match the charging parameters of the first electronic device 100, the first electronic device 100 can send an acceptance instruction to the second electronic device 200 (optionally, the "receive instruction" can be expressed as an Accept instruction). Specifically, the second policy engine of the first electronic device 100 can send a "send accept instruction" instruction to the second protocol layer (optionally, the "send receive instruction" instruction can be expressed as a Send Accept instruction) to instruct the second protocol layer to generate an acceptance instruction. Furthermore, after sending the acceptance instruction to the second hardware layer, the second protocol layer can also set and start the second verification code receiving timer (optionally, the "set and start the second verification code receiving timer" step can be expressed as a Start CRCReceive Timer step). Among them, the acceptance instruction is sent to the second electronic device 200 via the second physical layer. It should be noted that when the second physical layer sends the acceptance instruction to the second electronic device 200, it will send the fifth verification code corresponding to the acceptance instruction to the second electronic device 200.

[0126] Further, the second electronic device 200 can receive the acceptance instruction and the fifth check code sent by the second physical layer through the first physical layer, and forward the acceptance instruction to the first protocol layer. The first protocol layer will check the acceptance instruction (optionally, the step of "checking the acceptance instruction" can be represented by the step of Check MessageID against local copy). If the reception instruction meets the preset transmission rule, the first protocol layer can save the MessageID corresponding to the acceptance instruction (optionally, the step of "saving the MessageID corresponding to the acceptance instruction" can be represented by the step of Store copy of MessageID), and generate a third verification correct message, which can be sent by the first physical layer to the first electronic device 100 to indicate that the second electronic device 200 has correctly and completely received the acceptance instruction sent by the first electronic device 100. While sending the third verification correct message to the first electronic device 100, the first physical layer can also send the sixth check code to the first electronic device 100, which helps the first electronic device 100 to subsequently check whether the third verification correct information is correctly and completely transmitted.

[0127] Furthermore, the first protocol layer may also transmit the information of "receiving the accept instruction" to the first policy engine (optionally, the information of "receiving the accept instruction" may be expressed as the Accept Received information). In response to the Accept Received information, the first policy engine may stop the first response timer (optionally, the step of "stopping the first response timer" may be expressed as the Stop Sender Response Timer step), set and start the charging response timer (optionally, the step of "setting and starting the charging response timer" may be expressed as the Start PS Transition Timer step). If the second electronic device 200 does not receive the charging preparation completion message (which may be understood as the PS_RDY message) sent by the first electronic device 100 before the countdown of the charging response timer ends, it is deemed that the charging response has failed, and the second electronic device 200 may disconnect the connection with the first electronic device 100, or convert the connection into a normal USB connection (such as a communication connection for transmitting file data, etc.). Optionally, the second electronic device 200 may also reduce the current of the device operation (optionally, the step of "reducing the current of the device operation" may be expressed as the Reduce Current step).

[0128] Furthermore, the second physical layer may forward the third check correct message to the second protocol layer, and the second protocol layer may verify whether the third check correct information is correctly and completely transmitted (optionally, the step of "verifying whether the third check correct information is correctly and completely transmitted" may be expressed by the step of Check and increment MessageIDCounter). Wherein, if the third check correct information complies with the preset transmission rule, the second protocol layer may stop the second check code receiving timer (optionally, the step of "stopping the second check code receiving timer" may be expressed by the step of Stop CRCReceiveTimer).

[0129] Furthermore, the second protocol layer may send a message "the acceptance instruction has been correctly sent to the second electronic device 200" to the second policy engine (optionally, the "acceptance instruction has been correctly sent to the second electronic device 200" message may be expressed by an Accept sent message). In response to the Accept sent message, the second policy engine may adjust the voltage and current output of the charging port based on the power receiving parameters of the second electronic device 200 (optionally, the "adjusting the voltage and current output of the charging port based on the power receiving parameters of the second electronic device 200" step may be expressed by a Power supply adjusted to negotiated output step), and may also send a Ping packet to ensure the activity of the connection between the first electronic device 100 and the second electronic device 200 (optionally, the "sending a Ping packet to ensure the activity of the connection between the first electronic device 100 and the second electronic device 200" step may be expressed by a Send ping if required to maintain activity step).

[0130] Optionally, see Figure 4c , Figure 4c Another charging interaction flow chart provided in the embodiment of the present application is as follows: Figure 4c As shown, after executing Figure 4b After the steps shown, the first electronic device 100 can start charging the second electronic device 200. Specifically, the second policy engine of the first electronic device 100 can send a "send charging preparation completed" message to the second protocol layer (optionally, the "send charging preparation completed" message can be expressed as a Send PS_RDY message), and the second protocol layer can generate a charging preparation completed message in response to the Send PS_RDY message (optionally, the "charging preparation completed" message can be expressed as a PS_RDY message). Further, the second protocol layer can pass the PS_RDY message to the second hardware layer, and set and start the third verification code receiving timer (optionally, the "set and start the third verification code receiving timer" step can be expressed as a StartCRCReceive Timer step). Further, when the second hardware layer sends the PS_RDY message to the first hardware layer, it will also generate and send the seventh verification code corresponding to the PS_RDY message to the first hardware layer. The seventh verification code helps the first protocol layer in the second electronic device 200 to subsequently check whether the PS_RDY message is transmitted completely and correctly.

[0131] Further, the second electronic device 200 can receive the PS_RDY message and the seventh check code sent by the second physical layer through the first physical layer, and forward the PS_RDY message to the first protocol layer. The first protocol layer will check the charging preparation completion message (optionally, the "checking the charging preparation completion message" step can be expressed as the Check MessageIDagainst local copy step). Wherein, if the PS_RDY message complies with the preset transmission rule, the first protocol layer can save the MessageID corresponding to the charging preparation completion message (optionally, the "saving the MessageID corresponding to the charging preparation completion message" step can be expressed as the Store copy of MessageID step), and generate a fourth check correct message, which can be sent by the first physical layer to the first electronic device 100 to indicate that the second electronic device 200 has correctly and completely received the PS_RDY message sent by the first electronic device 100. Wherein, while sending the fourth check correct message to the first electronic device 100, the first physical layer can also send the eighth check code to the first electronic device 100, which helps the first electronic device 100 to subsequently check whether the fourth check correct information is correctly and completely transmitted.

[0132] Before the second electronic device 200 receives the PS_RDY message sent by the first electronic device 100, the first policy engine of the second electronic device 200 can control the second electronic device 200 to prepare for charging (optionally, the "prepare for charging" step can be expressed as the Prepare for new power step).

[0133] Further, when the PS_RDY message complies with the preset transmission rules, the first protocol layer of the second electronic device 200 may send a message to the first policy engine stating that "a message indicating that charging is ready has been received from the first electronic device 100" (optionally, "a message indicating that charging is ready has been received from the first electronic device 100" may be expressed as a PS_RDYReceived message). Further, in response to the PS_RDY Received message, the first policy engine may stop the charging response timer (optionally, the step of "stopping the charging response timer" may be expressed as a Stop PSTransition Timer step), and may also set and start a PPS response timer (optionally, the step of "setting and starting a PPS response timer" may be expressed as a Start PPSRequest Timer step).

[0134] Furthermore, the second physical layer may forward the fourth check correct message to the second protocol layer, and the second protocol layer may check whether the fourth check correct information complies with the preset transmission rules (optionally, the step of "checking whether the fourth check correct information complies with the preset transmission rules" may be expressed by the Check and increment MessageIDCounter step). Wherein, when the fourth check correct information complies with the preset transmission rules, the second protocol layer may stop the third check code receiving timer (optionally, the step of "stopping the third check code receiving timer" may be expressed by the Stop CRCReceive Timer step).

[0135] Furthermore, the second protocol layer may send a message to the second policy engine stating that "the message indicating that charging is ready has been correctly sent to the second electronic device 200" (optionally, the message indicating that "the message indicating that charging is ready has been correctly sent to the second electronic device 200" may be expressed by a PS_RDY sent message), and the second policy engine may continue to start the PPS communication timer in response to the PS_RDY sent message (optionally, the step of "starting the PPS communication timer" may be expressed by a StartPPSComm Timer step).

[0136] It should be noted that Figure 4a-4c There is a sequence of execution timing. Specifically, the execution sequence can be: Figure 4a The corresponding process steps are then executed Figure 4b The corresponding process steps are finally executed Figure 4c The corresponding process steps.

[0137] S202: Acquire power information of the charging port and save the power information in a memory.

[0138] The power information may include a current value and a voltage value of a charging port through which the first electronic device 100 charges the second electronic device 200 .

[0139] Optionally, since digital signals corresponding to multiple ports are stored in the register corresponding to the analog-to-digital converter, the time taken by the first electronic device to obtain the power information corresponding to the charging port is not fixed. Therefore, after the first electronic device 100 in the embodiment of the present application reads the power information of the charging port through the analog-to-digital converter, the power information is not saved in the register corresponding to the analog-to-digital converter, but is saved in other data forms such as global variables in other memory spaces of the first electronic device 100 (which can be understood as a memory space different from the register), which helps the first electronic device 100 to quickly obtain the power information of the charging port from the memory and promptly feed it back to the second electronic device 200.

[0140] S203: Update the power information according to a preset period.

[0141] Exemplarily, assuming that the preset period is 200 milliseconds, in response to the second electronic device 200 being connected to the first electronic device 100 through the charging port, the first electronic device 100 may begin to obtain the power information of the charging port for the first time, and save it in the memory in the form of a global variable. Further, after obtaining the power information for the first time, the first electronic device 100 may re-acquire new power information every 200 milliseconds, and replace the power information in the memory with the new power information. It should be noted that the preset period for the first electronic device 100 to update the power information is shorter than the period for the second electronic device 200 to send a query request to the first electronic device 100. Exemplarily, the period for the second electronic device 200 to send a query request to the first electronic device 100 may be 600 milliseconds, and the preset period for the first electronic device 100 to update the power information may be set to 200 milliseconds.

[0142] It should be noted that the above examples of the preset period and the period for the second electronic device 200 to send query requests are only for detailed explanation of the method of the embodiment of the present application and should not constitute a limitation on the present application. The specific value corresponding to the preset period is set by the technician according to the actual situation.

[0143] In some possible implementations, the method of the embodiment of the present application may also include:

[0144] In response to the first electronic device 100 being powered on, a charging thread is initialized and running resources are allocated, and the charging thread can be used to obtain and / or update power information according to a preset period;

[0145] In response to the second electronic device 200 being connected to the first electronic device 100 through the charging port, a charging thread is executed.

[0146] For example, see Figure 5 , Figure 5 A workflow diagram of a charging thread provided in an embodiment of the present application.

[0147] like Figure 5As shown, in response to the first electronic device 100 being turned on, the main function initialization function pps_status_mainthread_init function can be executed, and the battery management thread BattMngr_Thread_Create function can be created. Further, the first electronic device 100 can create a PPS main function pps_status_mainthread function related to directional charging. Further, the first electronic device 100 can create a parameter initialization function pps_status_context_init function. Further, the first electronic device 100 can also create a loop function pps_status_mianloop function, which helps the charging thread identify key events corresponding to the need to periodically collect power information, and ensure that the first electronic device 100 can update the power information in the memory in a timely manner. Further, the charging thread can include a waiting event function BattMngr_WaitForMultipleEvents function, and whenever the pps_status_mianloop function detects a corresponding event, the first electronic device 100 can perform operations corresponding to various events. Among them, the loop function pps_status_mianloop function can be a while loop function. It should be noted that the BattMngr_WaitForMultipleEvents function is always in an active state (Activity state) after the first electronic device 100 is turned on, but before the BattMngr_WaitForMultipleEvents function detects the corresponding waiting event, the BattMngr_WaitForMultipleEvents function will not consume the operating resources of the first electronic device 100. Among them, the waiting event may include a Start event (corresponding to the first event described below), a Restart event (corresponding to the second event described below), and a Stop event (corresponding to the third event described below).

[0148] In some other possible implementations, in response to the second electronic device 200 being connected to the first electronic device 100 through the charging port, running the charging thread may include:

[0149] In response to the second electronic device 200 being connected to the first electronic device 100 via the charging port, establishing a first event;

[0150] In response to the loop function in the first electronic device 100 detecting a first event, setting a charging flag bit to true, setting and starting a first timer, and acquiring power information of the charging port based on an analog-to-digital converter;

[0151] Store power information in memory;

[0152] Delete the first event.

[0153] For example, in combination Figure 5 , after the second electronic device 200 is electrically connected to the first electronic device 100, the first electronic device 100 may start the first timer and set the charging flag to true. Specifically, in response to the second electronic device 200 being connected to the first electronic device 100 through the charging port, the charging thread may create a first event (such as a Start event). Further, after the loop function detects the Start event, the charging thread may delete the Start event and control the ADC to read the power information of the charging port, such as the current voltage value and current value of the charging port of the first electronic device 100. Among them, the first electronic device 100 may save the power information in the form of a global variable in the memory. Optionally, the first electronic device 100 sets and starts the first timer, and the first timer may be used to subsequently trigger the first electronic device 100 to periodically collect power information. Exemplarily, the countdown time of the first timer may be 200 milliseconds. Further, in response to the loop function detecting the Start function, the first electronic device 100 may set the charging flag gPpsStatusGetValueFlag corresponding to "obtaining power information" to true, which is helpful to subsequently trigger the first electronic device 100 to periodically collect power information.

[0154] In some other possible implementations, the method of the embodiment of the present application may also include:

[0155] In response to the first timer counting down to an end, establishing a second event;

[0156] In response to the loop function detecting the second event, determining whether the charging flag is true;

[0157] When the charging flag is true, the latest power information is obtained through the analog-to-digital converter, the power information in the memory is changed to the latest power information, and the first timer is set and started;

[0158] Delete the second event.

[0159] For example, in combination Figure 5, when the charging flag is set to true, the first electronic device 100 can start the first timer according to a preset cycle. Specifically, in response to the end of the countdown of the first timer, the charging thread can create a second event (such as a Restart event). After the loop function detects the ReStart event, the charging thread can delete the Restart event and determine whether to continue to collect the power information of the charging port based on the value of the charging flag gPpsStatusGetValueFlag. Possibly, if the value of the charging flag gPpsStatusGetValueFlag is true, the power information of the charging port continues to be collected through the ADC, and the power information in the memory is replaced with the latest collected power information. Further, after collecting or updating the power information, the first timer is restarted. Possibly, if the value of the charging flag gPpsStatusGetValueFlag is false, the power information of the charging port is no longer collected.

[0160] In some other possible implementations, the method of the embodiment of the present application may also include:

[0161] In response to the second electronic device 200 being disconnected from the first electronic device 100, establishing a third event;

[0162] In response to the loop function detecting the third event, setting the charging flag bit to false and turning off the first timer;

[0163] Clear the third event.

[0164] For example, in combination Figure 5 , after the second electronic device 200 is electrically disconnected from the first electronic device 100, the first electronic device 100 may turn off the first timer and set the charging flag to false. Specifically, in response to the second electronic device 200 being disconnected from the first electronic device 100, the charging thread may establish a third event (such as a Stop event). After the loop function detects the Stop event, the charging thread may delete the Stop event and set the value of the charging flag gPpsStatusGetValueFlag to false, to instruct the first electronic device 100 to stop collecting the power information of the charging port. Optionally, in response to the loop function detecting the Stop event, the charging thread may control the first electronic device 100 to turn off the first timer.

[0165] S204: receiving a query instruction sent by the second electronic device, reading power information from the memory based on the query instruction, and sending the power information to the second electronic device.

[0166] If the first electronic device 100 does not send the power information to the second electronic device 200 within a preset time, the second electronic device 200 disconnects from the first electronic device 100 .

[0167] For example, see Figure 6a-Figure 6b , Figure 6a-Figure 6b A schematic diagram of the flow of electric energy information interaction provided in an embodiment of the present application.

[0168] Optionally, the second electronic device 200 may send a query command to the first electronic device 100 to obtain the power information of the charging port, so as to determine whether the power currently provided by the first electronic device 100 will damage the battery of the second electronic device 200 (for example, if the voltage value provided by the first electronic device 100 exceeds the maximum voltage value that the second electronic device 200 can receive, the battery of the second electronic device 200 will be damaged). For example, see Figure 6a , Figure 6a A schematic diagram of a flow chart of electric energy information interaction provided in an embodiment of the present application, such as Figure 6a As shown, the second electronic device 200 (which can be understood as Figure 6a The first policy engine of the Sink shown in the figure can send a "send query instruction" message to the first protocol layer (optionally, the "send query instruction" message can be expressed as a Send Get_PPS_Status message). In response to the Send Get_PPS_Status message, the first protocol layer can generate a query instruction (optionally, the "query instruction" can be expressed as a Get_PPS_Status instruction) and send the query instruction to the first physical layer. Furthermore, the first protocol layer can also set and start the fourth verification code receiving timer (optionally, the "setting and starting the fourth verification code receiving timer" step can be expressed as the StartCRCReceive Timer step), wherein, if the second electronic device 200 receives the fifth verification correct message Good CRC sent by the first electronic device 100 before the countdown of the fourth verification code receiving timer ends, it can be considered that the query instruction of the second electronic device 200 is completely and correctly transmitted to the first electronic device 100, and it can also indicate that the first electronic device 100 has received the query instruction of the second electronic device 200.

[0169] Optionally, when sending the query instruction to the first electronic device 100, the first physical layer may also send a verification code CRC corresponding to the query instruction to the first electronic device 100, which helps the first electronic device 100 to subsequently verify whether the query instruction is transmitted completely and correctly.

[0170] Furthermore, the first electronic device 100 can use the second physical layer (which can be understood as Figure 6aThe PHY on the Source side in the second protocol layer receives the query instruction sent by the second electronic device 200, and forwards the query instruction to the second protocol layer, and the second protocol layer can verify the query instruction (optionally, the "verify the query instruction" step can be expressed by the CheckMessageID against local copy step). Wherein, if the query instruction complies with the preset transmission rule, the second protocol layer can save the MessageID corresponding to the query instruction (optionally, the "save the MessageID corresponding to the query instruction" step can be expressed by the Store copy of MessageID step), and generate a fifth verification correct message (which can be understood as Good CRC). Further, the second hardware layer can send the fifth verification correct message to the second electronic device 200, and at the same time, it can also send the verification code CRC corresponding to the fifth verification correct message to the second electronic device 200, which helps the second electronic device 200 to subsequently verify whether the fifth verification correct message is completely and correctly transmitted. Optionally, the second protocol layer can send a message "the query instruction has been received" to the second policy engine (optionally, the "query instruction has been received" message can be expressed by the Get_PPS_Status Received message).

[0171] Furthermore, the second electronic device 200 can receive the fifth correct verification message and its corresponding verification code CRC sent by the first electronic device 100 through the first physical layer, and forward the fifth correct verification message to the first protocol layer. Among them, the first protocol layer can detect whether the fifth correct verification message complies with the preset transmission rules (optionally, the step of "detecting whether the fifth correct verification message complies with the preset transmission rules" can be expressed by the Check and incrementMessageIDCounter step). Further, when the fifth correct verification message complies with the preset transmission rules, the first protocol layer can stop the fourth verification code receiving timer (optionally, the step of "stopping the fourth verification code receiving timer" can be expressed by the Stop CRCReceive Timer step).

[0172] Furthermore, the first protocol layer may send a message to the first policy engine stating that "the query instruction has been correctly sent to the first electronic device 100" (optionally, the message "the query instruction has been correctly sent to the first electronic device 100" may be expressed as a Get_PPS_Status sent message). In response to the Get_PPS_Status sent message, the first policy engine may set and start a third response timer (optionally, the step of "setting and starting a third response timer" may be expressed as a Start SenderResponse Timer step).

[0173] Optionally, see Figure 6b , Figure 6b A schematic diagram of another flow chart of electric energy information interaction provided in an embodiment of the present application, such as Figure 6b As shown, the second policy engine in the first electronic device 100 can obtain the power information of the charging port from the storage pool (Data Protection Manager, DPM) in response to the Get_PPS_Status Received message (optionally, the "get the power information of the charging port from the storage pool" step can be expressed by the Get Source PPS Statusinformation from DPM step), and send a "send power information" instruction to the second protocol layer (optionally, the "send power information" instruction can be expressed by the Send PPS_Status instruction). Among them, the second protocol layer can generate a data packet containing power information (which can be understood as a data packet corresponding to the power information PPS_Status) in response to the Send PPS_Status instruction, and send the data packet containing the power information to the second physical layer. Furthermore, the second protocol layer can set and start the fifth check code receiving timer (optionally, the "set and start the fifth check code receiving timer" step can be expressed by the Start CRCReceive Timer step).

[0174] Further, the second physical layer can send the data packet containing the electric energy information and its corresponding check code CRC to the second electronic device 200. After the second electronic device 200 receives the data packet containing the electric energy information (or, PPS_Status) and its corresponding check code CRC through the first hardware layer, it can forward the data packet containing the electric energy information (or, PPS_Status) to the first protocol layer, and the first protocol layer checks whether the data packet containing the electric energy information (or, PPS_Status) complies with the preset transmission rules (optionally, the step of "checking whether the data packet containing the electric energy information complies with the preset transmission rules" can be expressed as the Check MessageID against local copy step). Wherein, in the case where the data packet corresponding to the PPS_Status complies with the preset transmission rules, the first protocol layer can save the MessageID corresponding to the data packet containing the electric energy information (or, the MessageID corresponding to the PPS_Status) (optionally, the step of "the MessageID corresponding to the data packet containing the electric energy information" can be expressed as the Store copy of MessageID step), and generate the sixth check correct message Good CRC. Further, the first hardware layer can send the sixth verification correct message to the first electronic device 100, and at the same time, can also send the verification code CRC corresponding to the sixth verification correct message to the first electronic device 100, which helps the first electronic device 100 to subsequently verify whether the sixth verification correct message is completely and correctly transmitted. Optionally, the first protocol layer can send a message "power information has been received" to the first policy engine (optionally, the "power information has been received" message can be expressed as a PPS_Status Received message). Further, in response to the PPS_Status Received message, the first policy engine can turn off the third response timer (optionally, the "turn off the third response timer" step can be expressed as a StopSenderResponse Timer step).

[0175] Furthermore, the first electronic device 100 can receive the sixth verification correct message and its corresponding verification code CRC sent by the second electronic device 200 through the second physical layer, and forward the sixth verification correct message to the second protocol layer. Among them, the second protocol layer can detect whether the sixth verification correct message complies with the preset transmission rules (optionally, the step of "detecting whether the sixth verification correct message complies with the preset transmission rules" can be expressed by the Check and incrementMessageIDCounter step). Further, when the sixth verification correct information complies with the preset transmission rules, the first protocol layer can stop the fifth verification code receiving timer (optionally, the step of "stopping the fifth verification code receiving timer" can be expressed by the Stop CRCReceive Timer step).

[0176] Furthermore, the second protocol layer may send a message to the second policy engine that "the power information has been correctly sent to the second electronic device 200" (optionally, the message that "the power information has been correctly sent to the second electronic device 200" may be expressed as a PPS_Status sent message).

[0177] It should be noted that Figure 6a-Figure 6b There is a sequence of execution timing. Specifically, the execution sequence can be: Figure 6a The corresponding process steps are then executed Figure 6b The corresponding process steps.

[0178] It can be seen that by implementing the method of the embodiment of the present application, after the second electronic device is connected to the first electronic device through the charging port, the power information stored in the memory will be periodically updated, so that no matter when the second electronic device sends a query request, the latest power information can be quickly fed back to the second electronic device, thereby effectively avoiding the occurrence of charging failure of the second electronic device.

[0179] See also Figure 7 , Figure 7 A schematic diagram of the composition of a first electronic device provided in an embodiment of the present application.

[0180] like Figure 7 As shown, the first electronic device 100 may include: a charging module 710 and a processing module 720;

[0181] The charging module 710 may be used to charge the second electronic device in response to the first electronic device and the second electronic device being connected to the first electronic device through the charging port;

[0182] The processing module 720 may be used to obtain power information of the charging port, where the power information includes a current value and a voltage value of the charging port of the first electronic device;

[0183] The processing module 720 may also be used to store the power information in the memory and update the power information according to a preset period;

[0184] The processing module 720 may also be used to read the power information from the memory in response to the query instruction sent by the second electronic device;

[0185] The processing module 720 may also be used to send the power information to a second electronic device.

[0186] In some possible embodiments, if the first electronic device does not send the power information to the second electronic device within a preset time period after receiving the query instruction, charging is interrupted.

[0187] In some other possible embodiments, the first electronic device may further include:

[0188] The processing module 720 may also be used to receive a charging request from a second electronic device, where the charging request may include power receiving parameters required for charging the second electronic device, where the power receiving parameters may include a power receiving voltage value and a power receiving current value;

[0189] The charging module 710 may also be used to charge the second electronic device when the charging parameters of the first electronic device match the power receiving parameters. The charging parameters may include the charging voltage range and charging current value of the first electronic device.

[0190] In some other possible embodiments, the first electronic device may further include:

[0191] If the power receiving voltage value in the power receiving parameters is within the charging voltage range, and the power receiving current value is the same as the charging current value, it is considered that the charging parameters match the power receiving parameters.

[0192] In some other possible embodiments, the first electronic device may further include:

[0193] The processing module 720 may also be used to initialize a charging thread and allocate running resources in response to the first electronic device being powered on, and the charging thread may be used to obtain and / or update power information according to a preset period;

[0194] The processing module 720 may also be configured to execute a charging thread in response to the second electronic device being connected to the first electronic device via the charging port.

[0195] In some other possible embodiments, the first electronic device may further include:

[0196] The processing module 720 may also be used to establish a first event in response to the second electronic device being connected to the first electronic device through the charging port;

[0197] The processing module 720 may also be configured to, in response to the loop function in the first electronic device detecting the first event, set the charging flag to true, set and start the first timer, and obtain the power information of the charging port based on the analog-to-digital converter;

[0198] The processing module 720 may also be used to store the power information in the memory;

[0199] The processing module 720 may also be used to delete the first event.

[0200] In some other possible embodiments, the first electronic device may further include: a determination module 730;

[0201] The processing module 720 may also be used to establish a second event in response to the first timer counting down being completed;

[0202] The determination module 730 may be configured to determine whether the charging flag is true in response to the loop function detecting the second event;

[0203] The processing module 720 may also be used to obtain the latest power information through the analog-to-digital converter when the charging flag is true, change the power information in the memory to the latest power information, and set and start the first timer;

[0204] The processing module 720 may also be used to delete the second event.

[0205] In some other possible embodiments, the first electronic device may further include:

[0206] The processing module 720 may also be used to establish a third event in response to the second electronic device being disconnected from the first electronic device;

[0207] The processing module 720 may also be configured to, in response to the loop function detecting a third event, set a charging flag bit to false and turn off the first timer;

[0208] The processing module 720 may also be used to clear the third event.

[0209] For further information, see Figure 8 , Figure 8 A schematic diagram of the hardware structure of a first electronic device provided in an embodiment of the present application.

[0210] The first electronic device 100 may include a processor 101, a memory 102, a wireless communication module 103, a mobile communication module 104, an antenna 103A, an antenna 104A, a power switch 105, a sensor module 106, a camera 107, a display screen 108, etc. Among them, the sensor module 106 may include an ambient light sensor 106A and an image sensor 106B, etc. Among them, the wireless communication module 103 may include a WLAN communication module, a Bluetooth communication module, etc. The above multiple parts can transmit data through a bus.

[0211] The processor 101 may include one or more processing units, for example, the processor 101 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0212] The memory 102 may be used to store computer executable program codes, and the executable program codes may include instructions. The processor 101 executes various functional applications and data processing of the first electronic device 100 by running the instructions stored in the memory 102. The memory 102 may include a program storage area and a data storage area. In a specific implementation, the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices.

[0213] The wireless communication function of the first electronic device 100 can be implemented through the antenna 103A, the antenna 104A, the mobile communication module 104, the wireless communication module 103, the modem processor and the baseband processor.

[0214] Antenna 103A and antenna 104A can be used to transmit and receive electromagnetic wave signals. Each antenna in the first electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization rate of the antennas.

[0215] The mobile communication module 104 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the first electronic device 100 .

[0216] The wireless communication module 103 can provide wireless communication solutions for application on the first electronic device 100, including wireless local area networks (WLAN), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc.

[0217] The first electronic device 100 can realize the shooting function through the ISP, the camera 107, the video codec, the GPU, the display screen 108 and the application processor.

[0218] The first electronic device 100 can realize the display function through a GPU, a display screen 108, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 108 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 101 may include one or more GPUs, which execute program instructions to generate or change display information.

[0219] The display screen 108 is used to display images, videos, etc. The display screen 108 includes a display panel. In some embodiments, the first electronic device 100 may include 1 or N display screens 108, where N is a positive integer greater than 1.

[0220] The structure illustrated in the embodiment of the present application does not constitute a specific limitation on the first electronic device 100. In other embodiments of the present application, the first electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0221] In the embodiments of the present application:

[0222] Any one or more of the wireless communication module 103 , the mobile communication module 104 , the sensor module 106 , the camera 107 , etc. may be used to detect current environmental characteristics of the first electronic device 100 .

[0223] The display screen 108 is used to display the user interface provided by the first electronic device 100, such as a shooting interface or an album interface. The user interface displayed by the display screen 108 can refer to the UI embodiment described above.

[0224] For details of the operations performed by the components in the first electronic device 100, please refer to the relevant description of the above method embodiments.

[0225] The software system of the first electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The present application embodiment takes a mobile operating system with a layered architecture as an example to exemplify the software structure of the first electronic device 100.

[0226] For further information, see Fig. 9 , Fig. 9 is a software structure block diagram of a first electronic device provided in an embodiment of the present application. Fig. 9 The layered architecture shown divides the software into several layers. Each layer has a clear role and division of labor, and the layers can communicate through software interfaces.

[0227] In some embodiments, the system of the first electronic device 100 can be divided into five layers, from top to bottom, namely, application layer, application framework layer, system runtime layer, hardware abstraction layer (HAL) and kernel layer. The description of each of the above layers is as follows:

[0228] The application layer may include a series of application packages. For example, the application packages of the application layer may include applications such as camera, gallery, calendar, call, map, navigation, browser, video, and music.

[0229] The application framework layer can provide an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer can include some predefined functions.

[0230] Exemplarily, the application framework layer may include an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, and an accelerated graphics port (AGP), etc. Among them:

[0231] The activity manager can be used to manage the individual application lifecycles as well as general navigation back functionality.

[0232] The window manager can be used to manage window programs. For example, the window manager can obtain the display screen size of the first electronic device 100, lock the screen, capture the screen, and determine whether there is a status bar.

[0233] Content providers can be used to store and retrieve data and make the data accessible to applications so that different applications can access or share data. For example, the data may include videos, images, audio, calls made and received, browsing history and bookmarks, and phone books.

[0234] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0235] The phone manager is used to provide communication functions of the first electronic device 100, such as management of call status (including answering a call, hanging up a call, etc.).

[0236] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, etc.

[0237] The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can automatically disappear after a short stay without user interaction. Exemplarily, the notification manager can be used to notify the completion of downloads, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the display screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt sound is emitted, the first electronic device vibrates, an indicator light flashes, etc.

[0238] AGP in the application framework layer can be used to improve the rendering performance of the graphics card, such as providing the graphics card with more cache capacity to achieve faster image processing speed.

[0239] The system runtime layer may include system libraries, including:

[0240] The system library can be understood as the support of the application framework, and is an important link between the application framework layer and the kernel layer. The system layer can include multiple functional modules, such as surface managers, media libraries, 3D graphics processing libraries (such as OpenGL ES), 2D graphics engines (such as SGL), etc. Among them:

[0241] The surface manager can be used to manage the display subsystem, for example, when the first electronic device 100 executes multiple applications, it is responsible for managing the interaction between display and access operations. The surface manager can also be used to provide fusion of two-dimensional and three-dimensional layers for multiple applications.

[0242] The media library can support playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0243] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.

[0244] A two-dimensional graphics engine can be understood as a drawing engine for two-dimensional drawing.

[0245] The hardware abstraction layer provides standard interfaces, such as the HAL interface definition language (HIDL) interface or the Android interface definition language (AIDL) interface.

[0246] The kernel layer can be understood as an abstract layer between hardware and software. The kernel layer may include system services such as security, memory management, process management, power management, network protocol management, and driver management. Exemplarily, the kernel layer may include drivers, such as display drivers, camera drivers, audio drivers, and sensor drivers. Optionally, the kernel layer may also be referred to as an Android kernel or kernel program. Exemplarily, the hardware layer of the first electronic device 100 may include a touch panel (TP), a liquid crystal display (LCD), and the like.

[0247] In some embodiments, the kernel layer can be understood as kernel state, and the other four layers (ie, application layer, application framework layer, system runtime layer, and HAL) can be understood as user state.

[0248] It is understandable that multiple applications that may exist in the application layer have video recording and / or playback functions. For example, if a camera has a video recording function, applications such as gallery, navigation, and browser may have a video playback function. Furthermore, based on the length, resolution, and shooting parameters of the video, the recording and / or playback of the video may be affected. The shooting parameters may include aperture value, shutter speed, sensitivity, exposure, focal length, depth of field, and the like.

[0249] For example, the video recording and / or playback related parameters supported by various applications can be stored in a sensor binary file (sensor bin), and the sensor bin file can be stored in an external memory, such as a disk or a hard disk. When a user uses a specific application to record and / or play a video, the application can read the video recording and / or playback related parameters into the memory so that the user can use the application normally and ensure the user experience.

[0250] It should be understood that each step in the above method embodiment can be completed by an integrated logic circuit of hardware in a processor or by instructions in the form of software. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.

[0251] The present application also provides a first electronic device, which may include: a memory and a processor. The memory may be used to store a computer program; the processor may be used to call the computer program in the memory, so that the first electronic device executes the method executed by the first electronic device side in any of the above embodiments.

[0252] The present application also provides a chip system, which includes at least one processor for implementing the functions involved in the first electronic device side in any of the above embodiments.

[0253] In some possible designs, the chip system also includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.

[0254] The chip system may be composed of the chip, or may include the chip and other discrete devices.

[0255] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.

[0256] Optionally, the memory in the chip system may also be one or more. The memory may be integrated with the processor or may be separately arranged with the processor, which is not limited in the embodiments of the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be arranged on different chips respectively. The embodiments of the present application do not specifically limit the type of memory and the arrangement of the memory and the processor.

[0257] Exemplarily, the chip system may be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD), or other integrated chips.

[0258] The present application also provides a computer program product, which includes: a computer program (also referred to as code, or instruction), which, when executed, enables a computer to execute the method executed by the first electronic device side in any of the above embodiments.

[0259] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the method executed by the first electronic device side in any of the above embodiments.

[0260] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0261] The various implementation modes of the present application can be combined arbitrarily to achieve different technical effects.

[0262] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0263] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0264] In short, the above is only an embodiment of the technical solution of this application, and is not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of this application shall be included in the protection scope of this application.

Claims

1. A reverse charging method, characterized in that: Applied to a first electronic device, the first electronic device includes a charging port and a memory, the method includes: In response to a second electronic device being connected to the first electronic device via the charging port, charging the second electronic device via the charging port; Acquire power information of the charging port, and save the power information in the memory, wherein the power information includes a current current value and a voltage value of the charging port; Updating the electric energy information according to a preset period; receiving a query instruction sent by the second electronic device, reading the power information from the memory based on the query instruction, and sending the power information to the second electronic device; The method further comprises: In response to the second electronic device being connected to the first electronic device through the charging port, running a charging thread; The method further comprises: In response to the first timer counting down to an end, establishing a second event; In response to the loop function detecting the second event, determining whether the charging flag is true; When the charging flag is true, the latest electric energy information is obtained through an analog-to-digital converter, the electric energy information in the memory is changed to the latest electric energy information, and the first timer is set and started; Delete the second event.

2. The method according to claim 1, characterized in that If the first electronic device does not send the power information to the second electronic device within a preset time period after receiving the query instruction, the charging is interrupted.

3. The method according to claim 2, characterized in that Before charging the second electronic device through the charging port, the method further includes: receiving a charging request sent by the second electronic device, wherein the charging request includes power receiving parameters required for charging the second electronic device, wherein the power receiving parameters include a power receiving voltage value and a power receiving current value; When the charging parameters of the first electronic device match the power receiving parameters, the second electronic device is charged, wherein the charging parameters include a charging voltage range and a charging current value of the first electronic device.

4. The method according to claim 3, characterized in that The method further comprises: If the power receiving voltage value in the power receiving parameter is within the charging voltage range, and the power receiving current value is the same as the charging current value, it is considered that the charging parameter matches the power receiving parameter.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: In response to the first electronic device being powered on, a charging thread is initialized and running resources are allocated to the charging thread, wherein the charging thread is used to obtain and / or update the power information of the charging port according to the preset period.

6. The method according to claim 5, characterized in that In response to the second electronic device being connected to the first electronic device through the charging port, running the charging thread includes: In response to the second electronic device being connected to the first electronic device through the charging port, establishing a first event; In response to the loop function in the first electronic device detecting the first event, setting a charging flag bit to true, setting and starting a first timer, and acquiring power information of the charging port based on an analog-to-digital converter; storing the electric energy information in the memory; Delete the first event.

7. The method according to claim 6, characterized in that The method further comprises: In response to the second electronic device being disconnected from the first electronic device, establishing a third event; In response to the loop function detecting the third event, setting the charging flag bit to false and turning off the first timer; The third event is cleared.

8. A first electronic device, characterized in that: The first electronic device comprises: a charging module and a processing module; The charging module is used to charge the second electronic device through the charging port in response to the second electronic device being connected to the first electronic device through the charging port of the first electronic device; The processing module is used to obtain the power information of the charging port, wherein the power information includes the current current value and voltage value of the charging port; The processing module is further used to store the power information in the memory of the first electronic device and update the power information according to a preset period; The processing module is further used to read the electric energy information from the memory in response to a query instruction sent by the second electronic device; The processing module is further used to send the electric energy information to the second electronic device; The processing module is further configured to execute a charging thread in response to the second electronic device being connected to the first electronic device via the charging port; The processing module is further configured to establish a second event in response to the countdown of the first timer ending; The processing module is further configured to determine whether the charging flag is true in response to the loop function detecting the second event; The processing module is further configured to, when the charging flag is true, obtain the latest power information through an analog-to-digital converter, change the power information in the memory to the latest power information, and set and start the first timer; The processing module is further used to delete the second event.

9. A first electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions so that the method according to any one of claims 1 to 7 is executed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the method according to any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • Charging control method, electronic equipment and charging control system

    CN115882535A

  • Charging control method and terminal equipment

    CN116031964A