A method for transmitting a data packet based on a Wi-Fi switch circuit
By introducing a pre-amplifier, current limiting unit, and boost module into the Wi-Fi switch circuit, the software packet sending process is optimized, solving the battery life and reliability issues of button battery-powered Wi-Fi switches under high current scenarios, and achieving highly applicable and long-lasting point-to-point communication.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ESPRESSIF SYST SHANGHAI
- Filing Date
- 2022-12-30
- Publication Date
- 2026-06-02
AI Technical Summary
Existing wireless switch solutions suffer from high cost, low communication reliability, high latency, high power consumption, and short battery life. In particular, Wi-Fi switches powered by button batteries cannot be effectively applied in high-current scenarios.
The Wi-Fi switch circuit, powered by a button cell battery, combines a pre-amplifier, a current limiting unit, and a boost module to optimize the software packet sending process. It enables point-to-point communication through the Wi-Fi data link layer, reducing the average current and power consumption during packet sending and increasing battery life.
It achieves a highly applicable, long-lasting, and highly reliable Wi-Fi wireless switch, reducing power consumption, extending battery life, and improving communication distance and real-time performance.
Smart Images

Figure CN116017337B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Wi-Fi switches, and more particularly to a method for transmitting data packets based on a Wi-Fi switch circuit, a device based on a Wi-Fi switch circuit, and a computer-readable storage medium. Background Technology
[0002] Wireless switches are used to remotely control household lights or electrical appliances. The mainstream types include Bluetooth, Zigbee, and 433MHz band wireless switches. Wireless switches typically use the following power supply methods: lithium batteries, alkaline batteries, self-generating batteries, and button batteries. Lithium batteries have advantages such as large capacity, rechargeability, high discharge current, and flexible size; however, they suffer from overcharging and over-discharging issues requiring external maintenance circuitry, and have a relatively high self-discharge rate and short lifespan. Alkaline batteries have large capacity and stable discharge voltage, but their larger size makes it difficult to miniaturize devices. Self-generating batteries use the energy from finger pressure to power the switch, but the energy output is relatively low, resulting in short transmission distances and higher mechanical load costs. Button batteries are small, have high energy density, and low self-discharge rate, making them an ideal power supply for wireless switches. Their disadvantage is their low discharge current, making them unsuitable for high-current applications.
[0003] A common communication method in existing wireless switch solutions is via Bluetooth and ZigBee protocols. However, Bluetooth and ZigBee-based wireless switches require a corresponding gateway or receiver to acquire signals and relay them to the controlled terminal device, such as a speaker, light, or smart curtain, to achieve on / off control. This is costly and involves latency. Specifically, for example... Figure 1 The diagram illustrates the working principle of a prior art wireless switch, including a wireless switch, a smart controller, a terminal, and a gateway. Both the wireless switch and the smart controller need to join the gateway's network to communicate with it. The wireless switch sends control information to the gateway, which then forwards this control information to the smart controller to execute the corresponding operation. This method suffers from high costs, and because it requires relaying through a gateway, communication quality is difficult to guarantee, and delays are likely to occur.
[0004] Another common approach in existing wireless switch solutions is to communicate using 433MHz wireless technology. However, such 433MHz-based wireless switches typically fail to receive responses from the controlled terminal devices, resulting in low communication reliability. Furthermore, these wireless switches cannot connect to a network without additional chips, and their control logic is relatively simple; however, adding additional chips significantly increases the device cost.
[0005] Therefore, there is an urgent need for a wireless switch solution that does not rely on a specific gateway, has high versatility, low power consumption, and long battery life. Summary of the Invention
[0006] This application provides a method for transmitting data packets based on a Wi-Fi switching circuit, a device based on a Wi-Fi switching circuit, and a computer-readable storage medium.
[0007] According to a first aspect of the present invention, a method for transmitting data packets based on a Wi-Fi switching circuit is provided. The Wi-Fi switching circuit includes a power module, a switch module, and an output module. The power module includes a button battery and a pre-amplifier capacitor. The switch module includes a push-button switch. The output module includes a Wi-Fi chip. The method for transmitting data packets includes: in response to pressing the push-button switch, the Wi-Fi switching circuit momentarily turns on and triggers the Wi-Fi chip to enter an initialization state; determining whether the Wi-Fi chip is bound to a receiving device; and the Wi-Fi chip transmitting data packets. The pre-amplifier capacitor supplies power to the Wi-Fi chip while it transmits data packets. After each data packet transmission, the Wi-Fi chip enters a sleep state. During the sleep state, the button battery charges the pre-amplifier capacitor to store electrical energy. The Wi-Fi chip re-enters the operating state after a predetermined time has elapsed.
[0008] As one example, the predetermined duration includes the duration for the front-stage capacitor to store all electrical energy or the duration for the front-stage capacitor to store a predetermined amount of electrical energy.
[0009] As one embodiment, the method further includes: in response to determining that the Wi-Fi chip has been bound to a receiving device, the Wi-Fi chip reads the MAC address and channel information of the receiving device, and sends a data packet to the receiving device according to the MAC address and channel information, wherein the data packet is a control packet.
[0010] Further, as an embodiment, the method includes, wherein the Wi-Fi chip re-enters the working state after a predetermined period of time, comprising: receiving a control response packet; in response to the Wi-Fi chip receiving the control response packet, indicating that the data packet sent by the Wi-Fi chip was successfully received by the receiving device; and in response to the Wi-Fi chip not receiving the control response packet, the Wi-Fi chip continuously sends control packets to the receiving device according to the MAC address and channel information.
[0011] Further, as an embodiment, the method includes, wherein when the number of times the Wi-Fi chip continuously sends control packets reaches a first predetermined threshold, switching to the next channel as the current channel, and performing the following steps: (a) the Wi-Fi chip sends a control packet to the receiving device according to the MAC address and the information of the current channel; (b) determining whether the Wi-Fi chip has received a control response packet; wherein, in response to the Wi-Fi chip receiving a control response packet, indicating that the control packet sent by the Wi-Fi chip has been successfully received by the receiving device, and the Wi-Fi chip stores the current channel information; in response to the Wi-Fi chip not receiving a control response packet, continuing to switch to the next channel as the current channel, and repeating steps (a) and (b) until all channels are traversed, wherein the number of channels is greater than three.
[0012] Furthermore, as an embodiment, the method includes, wherein, in response to the Wi-Fi chip still not receiving a control response packet after switching all channels in turn, the Wi-Fi chip terminates communication with the receiving device.
[0013] As one embodiment, the method further includes: in response to determining that the Wi-Fi chip is not bound to a receiving device, the Wi-Fi chip reads the current channel information and sends a data packet to the current channel according to the current channel information, wherein the data packet is a binding packet.
[0014] Further, as an embodiment, the method includes, wherein the Wi-Fi chip re-enters the working state after a predetermined time period, comprising: receiving a binding response packet; in response to the Wi-Fi chip receiving the binding response packet, the Wi-Fi chip stores the MAC address of the receiving device and the current channel information, and indicates that the Wi-Fi chip has successfully bound to the receiving device; in response to the Wi-Fi chip not receiving the binding response packet, the Wi-Fi chip continuously sends binding packets to the current channel.
[0015] Further, as an embodiment, the method includes, wherein when the number of times the Wi-Fi chip continuously sends a binding packet reaches a second predetermined threshold, switching to the next channel as the current channel, and performing the following steps: (a) the Wi-Fi chip sends a binding packet to the current channel according to the information of the current channel; (b) determining whether the Wi-Fi chip receives a binding response packet, wherein, in response to the Wi-Fi chip receiving a binding response packet, the Wi-Fi chip stores the MAC address of the receiving device and the current channel information, and indicates that the Wi-Fi chip has successfully bound to the receiving device; in response to the Wi-Fi chip not receiving a binding response packet, continuing to switch to the next channel as the current channel, and repeating steps (a) and (b) until all channels are traversed, wherein the number of all channels is greater than three.
[0016] Furthermore, as an embodiment, the method includes, in response to the Wi-Fi chip still not receiving a binding response packet after switching all channels in turn, indicating that the binding between the Wi-Fi chip and the receiving device has failed.
[0017] As one embodiment, the method includes waking up the Wi-Fi chip and triggering a long press operation in response to a button switch being continuously pressed.
[0018] According to a second aspect of the present invention, a method for receiving data packets from a Wi-Fi switching circuit is also provided, comprising: registering a MAC event callback on a receiving device; receiving data packets from a Wi-Fi chip in the Wi-Fi switching circuit, wherein the receiving device determines the type of the received data packets and performs corresponding operations according to the data packet type, wherein the data packet type includes control packets and binding packets; in response to the receiving device completing the corresponding operations, the receiving device enters a sleep state; and in response to the sleep state duration of the receiving device reaching its expiration, the receiving device continuously sends response packets to the Wi-Fi chip; wherein in response to the received data packet type being a control packet, the response packet is a control response packet, and in response to the received data packet type being a binding packet, the response packet is a binding response packet; wherein the sleep state duration of the receiving device is less than a predetermined duration, wherein the predetermined duration is the time interval from when the Wi-Fi chip enters a sleep state after sending data packets to when it re-enters a working state.
[0019] As one embodiment, the receiving device determines the type of the received data packet, and further includes: in response to determining that the data packet is a control packet, the receiving device executes a corresponding control event; in response to determining that the data packet is a binding packet, the receiving device stores the MAC address of the Wi-Fi chip.
[0020] As an example, the number of times the receiving device continuously sends response packets does not exceed a second predetermined threshold or the duration of continuously sending response packets does not exceed a second predetermined duration.
[0021] As one embodiment, after the receiving device continuously sends response packets to the Wi-Fi chip, it also includes: clearing the received data packets.
[0022] According to a third aspect of the present invention, a device based on a Wi-Fi switching circuit is also provided, comprising: a memory; a processor; and a computer program stored in the memory and executable by the processor; wherein, when the processor executes the computer program, it implements the above-described method for transmitting data packets based on the Wi-Fi switching circuit.
[0023] According to a fourth aspect of the present invention, a computer-readable storage medium is also provided, on which computer instructions are stored, which, when executed by a processor, implement the above-described method for transmitting data packets based on a Wi-Fi switching circuit.
[0024] This invention, through reasonable hardware circuitry and optimized software packet transmission processes, realizes a highly applicable, long-lasting, and highly reliable Wi-Fi wireless switch powered by a coin cell battery. According to the technical solution of this invention, point-to-point communication without a router connection can be achieved. Addressing the issue that the Wi-Fi wireless switch generates a large short-term packet transmission current while the actual packet transmission time is very short, this invention breaks down a packet transmission process into multiple sub-transmission processes. By adding intermittent sleep time during the packet transmission process, the average current of the entire packet transmission process is reduced. Regarding the issue that coin cell batteries cannot support the current of short-term packet transmission, this invention proposes to design a front-end capacitor for energy storage, improving the instantaneous load-carrying capacity. To address the issue of actual capacity decay caused by the high current of the coin cell battery, this invention proposes to add a current limiting unit, achieving the following beneficial effects: When the Wi-Fi chip operates in low-power mode, the coin cell battery is directly powered by a boost circuit, and the current limiting unit consumes almost no power. When the Wi-Fi chip performs high-current operations such as sending data packets, the current limiting unit limits the maximum output current of the coin cell battery, ensuring the battery's lifespan. Furthermore, this invention proposes a method for sending data packets for a Wi-Fi switching circuit via the Wi-Fi data link layer, based on a memory-based packet sending mechanism. Addressing the Wi-Fi standby power consumption issue, this invention enables connectionless point-to-point packet sending between the Wi-Fi wireless switch and the receiving device at the data link layer. This eliminates the power consumption associated with connecting to a router and maintaining the connection, resulting in zero power consumption when the switching circuit is not in operation. When sending messages at the Wi-Fi data link layer, all devices within the signal coverage area of the current channel can receive and send the message. Moreover, since the receiving device's channel changes depending on the router it is connected to, this invention effectively reduces the need to scan all channels and minimizes the number of packet transmissions by memorizing the receiving device's channel. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This diagram illustrates the working principle of a wireless switch in the prior art.
[0027] Figure 2(a) shows a schematic diagram of a button battery-powered Wi-Fi switch circuit according to an embodiment of the present invention;
[0028] Figure 2(b) shows a schematic diagram of a button battery-powered Wi-Fi switch circuit according to another embodiment of the present invention;
[0029] Figure 3 A table showing the battery characteristics of CR series button batteries in different sizes is provided.
[0030] Figure 4 The diagram shows a discharge curve of a Panasonic CR2032 battery as an example.
[0031] Figure 5 An exemplary circuit diagram of the current limiting unit according to the present invention is shown;
[0032] Figure 6 Another exemplary circuit diagram of the current limiting unit according to the present invention is shown;
[0033] Figure 7 An exemplary circuit diagram of a boost module according to the present invention is shown;
[0034] Figure 8 A schematic diagram of a system using a Wi-Fi switch according to the present invention is shown;
[0035] Figure 9 An exemplary flowchart of a method for transmitting data packets based on a Wi-Fi switching circuit according to the present invention is shown;
[0036] Figure 10 Another exemplary flowchart of the method for transmitting data packets based on a Wi-Fi switching circuit according to the present invention is shown;
[0037] Figure 11 An exemplary flowchart is shown below, illustrating how a Wi-Fi chip according to the present invention sends a binding packet to a receiving device.
[0038] Figure 12 An exemplary flowchart is shown, illustrating how a Wi-Fi chip according to the present invention sends a control packet to a bound receiving device;
[0039] Figure 13 Another exemplary flowchart is shown, illustrating how a Wi-Fi chip according to the present invention sends a control packet to a bound receiving device;
[0040] Figure 14 This illustrates an exemplary process for a receiving device according to the present invention to send a binding response packet and a control response packet;
[0041] Figure 15This illustrates another exemplary process for the receiving device to send a response packet according to the present invention;
[0042] Figure 16 An exemplary current-voltage waveform diagram of a Wi-Fi switching circuit according to the present invention is shown;
[0043] Figure 17 An exemplary circuit diagram of a controlled switch according to the present invention is shown;
[0044] Figure 18 Showing according to Figure 5 The equivalent circuit diagram of the current limiting unit. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0047] Wi-Fi, as a universal protocol, is widely used in various smart lights, curtains, speakers, and other devices. Devices based on the Wi-Fi protocol have advantages such as long communication distance, high real-time transmission, and good compatibility. Therefore, if Wi-Fi is used as the communication protocol for wireless switches, no gateway is needed; it can directly communicate with Wi-Fi-enabled receivers, resulting in lower costs, longer communication distances, and higher real-time reliability. However, due to size limitations, wireless switches typically use button batteries as their power source. Since Wi-Fi communication usually requires a relatively large current, it is not suitable for wireless switches powered by button batteries. Specifically, button batteries are small, have high energy density, and low self-discharge rate, making them an ideal power supply for wireless switches. However, their disadvantage is their low discharge current, making them unsuitable for high-current applications. Currently, Wi-Fi protocol chips are generally not applicable to wireless switch solutions powered by coin cell batteries. The main technical obstacles include: First, compared to other wireless communication solutions, Wi-Fi chips have a large short-term transmission current, which coin cell batteries cannot support; second, coin cell batteries typically have a nominal current of about 0.1mA, and excessive operating current will cause their actual usable capacity to decay rapidly, resulting in extremely poor battery life; third, the communication mechanism of the Wi-Fi protocol is complex and consumes a lot of energy, and the coin cell battery itself has a limited capacity and cannot provide sufficient battery life.
[0048] To address the aforementioned issues, this invention, through reasonable hardware circuitry and optimized software packet sending process, realizes a highly applicable, long-lasting, and highly reliable Wi-Fi wireless switch powered by a button battery. According to the technical solution of this invention, point-to-point communication without connecting to a router can be achieved.
[0049] Hardware circuit design
[0050] The hardware circuit design of the Wi-Fi switch circuit according to the present invention is described below with reference to Figures 2(a) and 2(b). As shown in Figure 2(a), the present invention provides a button battery-powered Wi-Fi switch circuit, which may include a power module 10, a switch module 20, and an output module 30. The switch module 20 and the output module 30 are connected in series. The Wi-Fi switch circuit provided by the present invention can communicate with a receiving device, thereby controlling the switching of the receiving device.
[0051] The power module 10 includes: a button cell battery 101 for providing electrical energy; and a pre-capacitor 103 connected in parallel with the button cell battery 101 for storing the electrical energy of the button cell battery 101.
[0052] The switch module 20 includes a push-button switch 202. As an example, the push-button switch 202 is used to receive user operation commands.
[0053] The output module 30 includes a Wi-Fi chip 302 for communicating with the receiving device.
[0054] In response to pressing the button switch 202, the Wi-Fi switch circuit is momentarily turned on, and the Wi-Fi chip 302 is triggered to enter the initialization state;
[0055] After initialization, the Wi-Fi chip 302 enters the working state and begins sending data packets to the receiving device. Furthermore, the pre-amplifier provides power to the Wi-Fi chip 302 when it enters the working state.
[0056] When the Wi-Fi chip 302 enters a sleep state after sending a data packet, the button battery 101 charges the front-end capacitor 103, allowing the front-end capacitor 103 to store electrical energy. The Wi-Fi chip 302 then re-enters the working state after a predetermined period of time. For example, the predetermined period may include the time it takes for the front-end capacitor 103 to store all its electrical energy or the time it takes for the front-end capacitor 103 to store a predetermined amount of electrical energy.
[0057] Preferably, as shown in Figure 2(b), the Wi-Fi switch circuit further includes a boost module 40. The input terminal of the boost module 40 is connected in series with the switch module 20, and the output terminal of the boost module 40 is connected in series with the output module 30. In response to pressing the button switch 202, the boost module 40 pumps the voltage of the button battery 101 to the operating voltage of the Wi-Fi chip 302.
[0058] Specifically, as an example, the boost module 40 uses a Boost circuit.
[0059] Preferably, as shown in Figure 2(b), the power module 10 further includes a current limiting unit 102, which is connected in series with the button battery 101 and then connected in parallel with the pre-stage capacitor 103. The function of the current limiting unit 102 is to limit the short-term release current of the button battery 101 to increase battery life. Specifically, the current limiting unit 102 is configured as follows: in response to pressing the button switch 202, the Wi-Fi chip 302 enters an initialization state, where the current required by the Wi-Fi chip 302 is less than a first threshold current, and the current limiting unit 102 does not operate, with the button battery 101 supplying power to the Wi-Fi chip 302; and in response to the Wi-Fi chip 302 entering an operating state, where the current required by the Wi-Fi chip 302 is greater than the first threshold current, the current limiting unit 102 limits the output current of the button battery 101 to the first threshold current, and the pre-stage capacitor 103 and the button battery 101 work together to supply power to the Wi-Fi chip 302.
[0060] According to one embodiment, the current limiting unit 102 includes a first MOSFET, a first resistor, and a second resistor; wherein, the coin cell 101 is connected in series with the first and second resistors, the output terminal of the coin cell 101 after voltage division through the first resistor is connected to the gate of the first MOSFET, the source of the first MOSFET is connected to the negative terminal of the coin cell 101, and the drain of the first MOSFET is grounded; and, in response to the Wi-Fi chip 302 entering the initialization state, the gate-source voltage of the first MOSFET is greater than the first threshold voltage, causing the first MOSFET to conduct, at which time the voltage of the front capacitor 103 is equal to the voltage of the coin cell 101; in response to the Wi-Fi chip 302 entering the working state, the gate-source voltage of the first MOSFET is less than the second threshold voltage, causing the first MOSFET to be turned off, at which time the output current of the coin cell 101 is limited to the first threshold current.
[0061] According to another embodiment, the current limiting unit 102 includes a second MOSFET, a first inductor, and a first diode; the first inductor is used to smooth the current waveform; wherein, the button cell 101 is connected in series with the second MOSFET and the first diode, the positive terminal of the button cell 101 is connected to the source of the second MOSFET, the cathode of the first diode is connected to the drain of the second MOSFET, the PWM control circuit is connected to the gate of the second MOSFET, the anode of the first diode is connected to the negative terminal of the button cell and grounded, the input terminal of the first inductor is connected to the cathode of the first diode, and a voltage is provided from the output terminal of the first inductor; and the Wi-Fi chip 102 generates a PWM pulse wave to control the second MOSFET to conduct periodically, and adjusts the magnitude of the output current of the button cell 101 by adjusting the duty cycle, and in response to the second MOSFET being turned off, the first diode provides a freewheeling circuit to the first inductor; wherein, the duty cycle of the PWM pulse wave corresponds to the magnitude of the preset output current.
[0062] Preferably, as shown in Figure 2(b), the output module 30 further includes a post-stage capacitor 301, which is connected in parallel with the Wi-Fi chip 302. After being connected in parallel with the Wi-Fi chip 302, the post-stage capacitor 301 is connected in series with the output terminal of the boost module 40. The post-stage capacitor 301 is used to maintain a stable voltage at the output terminal of the boost module 40 when the boost module 40 pumps the voltage of the button battery 101. Specifically, in response to pressing the button switch 202, the post-stage capacitor 301 charges to the operating voltage of the Wi-Fi chip 302.
[0063] Preferably, as shown in FIG2(b), the switch module 20 further includes a controlled switch 201, and a push-button switch 202 is connected in parallel with the controlled switch 201. In response to pressing the push-button switch 202, the Wi-Fi chip 302 sends a control signal to the controlled switch 201 to lock the controlled switch 201 in a connected state, thereby activating the power supply circuit of the Wi-Fi switch circuit; or, in response to pressing the push-button switch 202, the push-button switch 202 controls the controlled switch 201 to lock in a connected state, thereby activating the power supply circuit of the Wi-Fi switch circuit.
[0064] Preferably, in response to the Wi-Fi chip 302 ending communication with the receiving device, the Wi-Fi chip sends a control signal to the controlled switch 201 to control the controlled switch 201 to switch to the off state, thereby disconnecting the power supply circuit of the Wi-Fi switch circuit. At the same time, the boost module 40 stops working, the downstream capacitor 301 discharges to 0V, and the Wi-Fi chip 302 stops working.
[0065] As an example and not a limitation, the controlled switch is made of MOSFETs and is controlled by the Wi-Fi chip to turn the power supply loop of the Wi-Fi switching circuit on or off.
[0066] Preferably, in response to the Wi-Fi chip 302 being in a sleep state, the Wi-Fi chip 302 requires 0 current, and the button battery 101 charges the front capacitor 103 so that the front capacitor 103 stores electrical energy.
[0067] Preferably, the Wi-Fi chip 302 includes one or more sleep states. Specific Implementation Example 1
[0069] The main parts of the hardware design will be further explained below with reference to the accompanying drawings.
[0070] (1) Button battery
[0071] According to one embodiment of the present invention, a button cell battery is used to provide the energy required for the entire Wi-Fi switching circuit. As a specific example of the present invention, the button cell battery 101 can be a CR series button cell battery, typically designated as CRXXYY, where XX represents the diameter (in millimeters) and YY represents the thickness (in 0.1 millimeters). The most commonly used button cell battery designation is CR2032, which has a diameter of 20 millimeters and a thickness of 3.2 millimeters. Additionally, some high-power devices may use batteries designated as CRR2450 or CR3022. (See reference...) Figure 3 As shown, taking Panasonic's CR series batteries as an example, a battery characteristic table for different sizes of CR series button batteries is presented. According to... Figure 3 It can be seen that the main difference in the electrical characteristics of batteries of different sizes lies in capacity, with little difference in voltage and output current capabilities. However, when the load current of a coin cell (e.g., a Wi-Fi chip) increases, its discharge capacity decreases exponentially. See details... Figure 4 The diagram illustrates a discharge curve using a Panasonic CR2032 coin cell as an example. The CR2032 coin cell has a nominal voltage of 3.0V, a discharge cutoff voltage of 2.0V, and a standard continuous load discharge current of approximately 0.2mA. Under the standard continuous load current, the internal resistance and voltage drop are not significant within the first 80% of the capacity, but the voltage drop is more significant towards the end of the discharge. Furthermore, the CR2032 coin cell has a nominal maximum pulse current of 20mA, where the nominal maximum pulse current refers to the current required to maintain a minimum voltage of 2V. The pulse discharge lasts 3 seconds, discharging 50% of the nominal capacity at an ambient temperature of 23°C. Therefore, as an example, the technical solution of this invention can be used to design a constant current circuit based on the nominal maximum pulse current. It should be noted that the embodiments of this invention do not limit the type and size of the coin cell; CR2032 or any other coin cell suitable for the circuit design can be used.
[0072] Since the discharge capacity of the aforementioned button battery decreases exponentially with increasing load current, it is necessary to consider how to protect the button battery's charge when designing a Wi-Fi switch circuit powered by a button battery, in order to avoid excessive discharge and depletion of energy.
[0073] (2) Preamplifier
[0074] According to one embodiment of the present invention, the power module 10 further includes a pre-stage capacitor 103, which is connected in parallel with the coin cell battery 101 to store the electrical energy of the coin cell battery 101, providing energy when the current increases due to transient load. Since the pre-stage capacitor 103 is normally connected to the coin cell battery 101, the leakage current of the pre-stage capacitor 103 is a key factor affecting the storage capacity. Low-leakage-current electrolytic capacitors or sheet capacitors are preferred. Tantalum capacitors are generally not recommended because they typically have a large leakage current. As an example of the present invention, the pre-stage capacitor can be a low-leakage-current (e.g., leakage current less than 1uA) electrolytic capacitor or a sheet / solid-state capacitor, etc.
[0075] Furthermore, the size of the pre-amplifier capacitor needs to be selected based on the current drawn by the Wi-Fi chip 302 when transmitting data packets. Specifically, as an example, let the size of the pre-amplifier capacitor be denoted as C. Assume that the pre-amplifier capacitor is fully charged and has a voltage of U before the Wi-Fi chip 302 transmits a data packet. ct1 After the Wi-Fi chip 302 finishes transmitting packets, the voltage is U. ct2 When the Wi-Fi chip 302 sends a packet, the average voltage output by the button battery 101 is U. ba The average current is I ba The packet transmission duration of Wi-Fi chip 302 is t, and the energy consumed by Wi-Fi chip 302 in transmitting packets is W. L If the voltage converter efficiency is η, then the required capacitance of the preceding stage capacitor can be calculated using the following formula:
[0076]
[0077] In practical applications, during the final stage of the operation of the button cell 101, the discharge capacity of the button cell 101 decreases, and the pre-stage capacitor 103 cannot guarantee the initial voltage. Therefore, when determining the capacitance of the pre-stage capacitor, it is usually necessary to increase the value of C obtained from the above calculation.
[0078] As an example of the present invention, a pre-amplifier 103 with a capacitance of 1000uF can be selected. It should be noted that the size of the pre-amplifier is not limited in the embodiments of the present invention, and any other pre-amplifier suitable for the circuit design can be used.
[0079] According to an embodiment of the present invention, the design of the pre-amplifier can greatly improve the utilization rate of its stored energy, so as to serve as the main energy provider when the Wi-Fi chip sends packets, and there is no need to worry about the capacity reduction of the coin cell battery. The beneficial effects include a significant increase in the instantaneous load capacity of the switching circuit, thereby protecting the coin cell battery and increasing the battery life.
[0080] (3) Current limiting unit
[0081] According to one embodiment of the present invention, the power module 10 further includes a current limiting unit 102, which is connected in series with the button battery 101 and then connected in parallel with the pre-stage capacitor 103. The addition of the current limiting unit 102 provides the following advantages: First, it disconnects the direct connection between the button battery 101 and the input terminal of the boost module 40, allowing the boost module 40 to draw more energy from the pre-stage capacitor 103; second, it limits the maximum output current of the button battery 101, increasing the actual usable capacity of the button battery 101.
[0082] According to one embodiment of the present invention, the current limiting unit 102 includes a first MOSFET, a first resistor, and a second resistor. For example... Figure 5 The diagram illustrates an exemplary circuit diagram of the current limiting unit according to the present invention. The first MOSFET can be a depletion-type N-channel MOSFET Q4, the first resistor can be resistor R1, and the second resistor can be resistor R2. A coin cell battery BT1 is connected in series with resistors R1 and R2. The positive terminal of the coin cell battery BT1, after voltage division through resistor R1, is connected to the gate of the MOSFET Q4. The negative terminal of the coin cell battery BT1, after voltage division through resistor R2, is connected to the gate of the MOSFET Q4 to control the turn-on degree of the MOSFET. The source of the MOSFET Q4 is connected to the negative terminal of the coin cell battery BT1, and the drain of the MOSFET Q4 is grounded.
[0083] According to another embodiment of the present invention, the current limiting unit includes a second MOSFET, a first inductor, and a first diode. Figure 6The diagram shows another exemplary circuit diagram of the current limiting unit according to the present invention. The second MOSFET can be a P-channel MOSFET Q1, the first inductor can be an inductor L1, and the first diode can be a diode D2. A coin cell battery BT1 is connected in series with the MOSFET Q1 and the diode D2. The positive terminal of the coin cell battery BT1 is connected to the source of the MOSFET Q1, the cathode of the diode D2 is connected to the drain of the MOSFET Q1, the PWM control circuit is connected to the gate of the MOSFET Q1, the anode of the diode D2 is connected to the negative terminal of the coin cell battery BT1 and grounded, and the input terminal of the inductor L1 is connected to the cathode of the diode D2, providing voltage from the output terminal of the first inductor. Here, the MOSFET Q1 acts as a switch to control the on / off state, the inductor L1 smooths the current waveform, and the diode D2 provides a freewheeling path to the inductor L1 when the MOSFET Q1 is turned off.
[0084] When the current limiting unit 102 circuit is working, the Wi-Fi chip 302 generates a PWM pulse wave to control the MOSFET Q1 to conduct periodically, and adjusts the output current of the coin cell 101 by adjusting the duty cycle. When the MOSFET Q1 is turned off, diode D2 provides a freewheeling path to inductor L1; the duty cycle of the PWM pulse wave corresponds to the preset output current. It should be noted that PWM pulse waves can also be generated by chips other than the Wi-Fi chip 302, and this invention does not impose specific limitations on this. The preset output current value corresponds to the first threshold current, that is, the maximum supply current set by the current limiting unit 102.
[0085] According to an embodiment of the present invention, by adding a current limiting unit to limit the short-term release current of the battery, the battery life is increased. The beneficial effects include: on the one hand, the direct connection between the button battery and the input side of the boost circuit is disconnected, so that the boost circuit can draw more energy stored in the pre-stage capacitor; on the other hand, the maximum output current of the button battery is limited, thereby increasing the actual usable capacity of the battery.
[0086] (4) Boost module
[0087] As an example of the present invention, the Wi-Fi switching circuit further includes a boost module 40, the input terminal of which is connected in series with the switching module 20, and the output terminal of which is connected in series with the output module 30.
[0088] Specifically, as an example, boost module 40 can raise the voltage using a boost circuit, requiring the input voltage to be as low as possible, efficiency to be as high as possible, and a current requirement of over 500mA. To prevent voltage drop, the output voltage can typically be set slightly higher than the operating voltage, such as 3.4V to 3.5V. Figure 7The diagram illustrates an example boost module of the present invention, using the SGM6603 from Sanbang Microelectronics as the boost chip. It is important to understand that the input voltage of the Boost circuit is an inherent parameter of the Boost circuit, which can be understood as the minimum allowable input voltage for the Boost circuit; below this voltage, the chip will not operate. The output voltage of the Boost circuit refers to the voltage passing through the Boost circuit.
[0089] It should be noted that, according to embodiments of the present invention, the boost module is a preferred but not necessary technical solution.
[0090] (5) Post-stage capacitor
[0091] According to one embodiment of the present invention, the output module 30 further includes a post-stage capacitor 301, which is connected in parallel with the Wi-Fi chip 302. After being connected in parallel with the Wi-Fi chip 302, the post-stage capacitor 301 is connected in series with the output terminal of the boost module 40. The post-stage capacitor 301 is used to maintain the voltage of the output terminal of the boost module 40 stable when the boost module 40 pumps the voltage of the button battery 101.
[0092] The selection of the post-stage capacitor 301 needs to be based on a comprehensive consideration of the power supply's load adjustment capability and the packet transmission current. Each time the button switch is pressed, the post-stage capacitor 301 needs to charge from zero to the operating voltage of the Wi-Fi chip 302. After the Wi-Fi chip 302 finishes transmitting data packets, the post-stage capacitor 301 self-discharges to 0V. The post-stage capacitor 301 is directly connected in parallel across the Wi-Fi chip 301, and its voltage value is equal to that of the Wi-Fi chip 301, with the same trend of change. Once the circuit is stable, the post-stage capacitor 301 only discharges and charges slightly during sudden load changes. An excessively large post-stage capacitor can lead to unnecessary energy loss and affect the normal operation of the circuit during continuous pressing. As an example, assuming the peak current of the Wi-Fi chip 301 when transmitting data packets is approximately 270mA, an excessively small post-stage capacitor will not effectively suppress voltage changes and may cause the chip to reset. As an example, to best suit most Boost converter modules, it is appropriate to use a 47uF and a 0.1uF multilayer ceramic chip (MLCC) capacitor as the downstream capacitor.
[0093] According to embodiments of the present invention, the post-stage capacitor can make the output voltage more stable. When the equivalent resistance of the load changes, the boost module often cannot respond in time. The design using a post-stage capacitor can reduce the voltage drop on the output side during sudden load changes. After the equivalent resistance of the load stabilizes, it will only perform small-scale discharge and charging again when a sudden load change occurs. According to embodiments of the present invention, the post-stage capacitor is directly connected in parallel across the two ends of the Wi-Fi chip, and its voltage value is equal to the chip's voltage, and its change trend is exactly the same as the voltage of the chip segment. It should be noted that the embodiments of the present invention do not limit the type and size of the post-stage capacitor; any other post-stage capacitor suitable for the circuit design can be used.
[0094] According to an embodiment of the present invention, the downstream capacitor is used to boost the voltage, which has the beneficial effect of preventing voltage track collapse at the chip terminals.
[0095] It should be noted that, according to embodiments of the present invention, the boost module is a preferred but not necessary technical solution.
[0096] (6) Wi-Fi chip
[0097] As an example of the present invention, the output module 30 may include a Wi-Fi chip 302, which is used for circuit logic control and sending data packets to the receiving device. The Wi-Fi chip 302 may be a small-size, low-cost, low-power IoT chip. As an example, the Wi-Fi chip 302 may be an ESP32-C2, etc. As an example, the parameters of the Wi-Fi chip 302 may include an operating voltage of 3.3V, a CPU operating current of 15.01mA, a Wi-Fi pulse transmission current of 300mA, and a receiving current of 65mA. It should be noted that the embodiments of the present invention do not specifically limit the model and parameters of the Wi-Fi chip; any model and parameters of a Wi-Fi chip suitable for the circuit design can be selected.
[0098] In summary, existing technologies typically use a pre-amplifier capacitor directly connected to a button cell battery. The voltage of the button cell battery is always equal to the voltage of the pre-amplifier capacitor, and the energy that the pre-amplifier capacitor can release is... Where U1 is the initial voltage of the button cell battery when it is unloaded, and U2 is the battery voltage of the button cell battery when it is loaded. Usually, the allowable voltage difference between U1 and U2 is very low, otherwise it will cause the battery capacity to decay sharply. Therefore, the energy that the front-end capacitor can actually provide is also very small, so its energy is mainly provided by the battery.
[0099] According to an embodiment of the present invention, the energy that the front-end capacitor can release is In this circuit, U1 represents the initial voltage of the coin cell battery, while U3 can be as low as the minimum operating voltage of the boost module, thus significantly improving the utilization rate of the energy stored in the pre-amplifier capacitor. Therefore, the pre-amplifier capacitor can serve as the primary energy provider when the Wi-Fi chip transmits data packets, without concern about a rapid decrease in the coin cell battery's capacity. Consequently, the circuit's instantaneous load capacity is greatly increased.
[0100] As an example of the present invention, assuming the initial voltage U1 of the button battery is 2.9V, and the voltage drops to U2 of 2.6V under load, and the size of the pre-amplifier capacitor is 1000uF, then the energy that the pre-amplifier capacitor in the prior art can provide is...
[0101] However, according to an embodiment of the present invention, assuming the minimum operating voltage U3 of the boost module of the present invention is 0.9V, the energy that the front-stage capacitor of the present invention can provide is... With the same preamplifier capacitor size, the instantaneous energy provided is 4.6 times that of the former.
[0102] Therefore, according to the embodiments of the present invention, the utilization rate of the pre-stage capacitor can be greatly improved, and it can be used as the main energy output device for instantaneous load, thereby overcoming the problem of excessive power consumption that easily occurs when button batteries are used in wireless switching circuits.
[0103] Software control design
[0104] Wi-Fi devices are divided into access points (APs) and standby devices (STAs). APs are the network creators, typically routers; standby devices are network-connected devices such as laptops, mobile phones, and smart home products. To fully utilize frequency band resources, Wi-Fi operates in the 2.4GHz band, ranging from 2.4GHz to 2.4835GHz. This 83.5MHz band is divided into 13 channels, each with a center frequency difference of 5MHz, extended upwards and downwards by 11MHz, resulting in a channel bandwidth of 22MHz.
[0105] Typically, access points (APs) autonomously select available channels based on their environment. However, in smart home applications, controlled devices connect to the AP, and their channels change according to the AP's channel. Since Wi-Fi devices only allow data transmission with devices on the same channel, third-party devices (such as Wi-Fi switches) need to know the channel the controlled device is on before communicating with it. However, scanning 13 channels consumes a significant amount of unnecessary energy. To address this issue, this invention proposes a method for sending data packets to a Wi-Fi switch circuit using a memory-based packet sending mechanism at the Wi-Fi data link layer. When sending messages at the Wi-Fi data link layer, all devices within the signal coverage area of the current channel can receive or send messages.
[0106] The following is combined with Figure 8 and Figure 9 The software control design of the Wi-Fi switching circuit according to the present invention is introduced.
[0107] like Figure 8 The diagram illustrates a system utilizing a Wi-Fi switch, including a Wi-Fi switch, a smart device, and a router. The Wi-Fi switch and the smart device (i.e., the receiving device) communicate by sending data packets through the Wi-Fi data link layer. The smart device is connected to the router, and the channel on which the smart device operates switches as the router switches channels.
[0108] like Figure 9 The diagram illustrates a flowchart of sending data packets according to an embodiment of the present invention. According to this embodiment, a method for sending data packets based on a Wi-Fi switch circuit is disclosed. The Wi-Fi switch circuit includes a power module, a switch module, and an output module. The power module includes a button battery and a pre-amplifier capacitor. The switch module includes a push-button switch. The output module includes a Wi-Fi chip. The method for sending data packets includes: in response to pressing the push-button switch, the Wi-Fi switch circuit is momentarily turned on, triggering the Wi-Fi chip to enter an initialization state; determining whether the Wi-Fi chip is bound to a receiving device; and the Wi-Fi chip sending data packets. The pre-amplifier capacitor supplies power to the Wi-Fi chip while it is sending data packets. After each data packet transmission, the Wi-Fi chip enters a sleep state. During the sleep state, the button battery charges the pre-amplifier capacitor to store electrical energy. The Wi-Fi chip re-enters the working state after a predetermined time has elapsed.
[0109] Preferably, the predetermined duration includes the duration for the preceding capacitor to store all electrical energy or the duration for the preceding capacitor to store a predetermined amount of electrical energy.
[0110] Preferably, the method further includes: in response to determining that the Wi-Fi chip has been bound to the receiving device, the Wi-Fi chip reads the MAC address and channel information of the receiving device, and sends a data packet to the receiving device according to the MAC address and channel information, wherein the data packet is a control packet.
[0111] More preferably, the Wi-Fi chip re-entering the working state after a predetermined period of time includes: receiving a control response packet, and in response to the Wi-Fi chip receiving the control response packet, indicating that the data packet sent by the Wi-Fi chip was successfully received by the receiving device; in response to the Wi-Fi chip not receiving the control response packet, the Wi-Fi chip continuously sends control packets to the receiving device according to the MAC address and channel information.
[0112] More preferably, when the number of times the Wi-Fi chip continuously sends control packets reaches a first predetermined threshold, it switches to the next channel as the current channel and performs the following steps: (a) the Wi-Fi chip sends a control packet to the receiving device based on the MAC address and the current channel information; (b) it determines whether the Wi-Fi chip has received a control response packet; wherein, in response to the Wi-Fi chip receiving a control response packet, it indicates that the control packet sent by the Wi-Fi chip has been successfully received by the receiving device, and the Wi-Fi chip stores the current channel information; in response to the Wi-Fi chip not receiving a control response packet, it continues to switch to the next channel as the current channel, and repeats steps (a) and (b) until all channels are traversed, wherein the number of channels is greater than three.
[0113] Preferably, the method further includes: in response to determining that the Wi-Fi chip is not bound to a receiving device, the Wi-Fi chip reads the current channel information and sends a data packet to the current channel according to the current channel information, wherein the data packet is a binding packet.
[0114] More preferably, the Wi-Fi chip re-entering the working state after a predetermined time period includes: receiving a binding response packet; and, in response to the Wi-Fi chip receiving the binding response packet, the Wi-Fi chip stores the MAC address of the receiving device and the current channel information, and indicates that the Wi-Fi chip has successfully bound to the receiving device; in response to the Wi-Fi chip not receiving a binding response packet, the Wi-Fi chip continuously sends binding packets to the current channel.
[0115] More preferably, when the number of times the Wi-Fi chip continuously sends the binding packet reaches a second predetermined threshold, it switches to the next channel as the current channel and performs the following steps: (a) the Wi-Fi chip sends the binding packet to the current channel according to the information of the current channel; (b) it determines whether the Wi-Fi chip has received the binding response packet, wherein, in response to the Wi-Fi chip receiving the binding response packet, the Wi-Fi chip stores the MAC address of the receiving device and the current channel information, and indicates that the Wi-Fi chip has successfully bound to the receiving device; in response to the Wi-Fi chip not receiving the binding response packet, it continues to switch to the next channel as the current channel, and repeats steps (a) and (b) until all channels are traversed, wherein the number of all channels is greater than three.
[0116] More preferably, if the Wi-Fi chip still does not receive a binding response packet after switching all channels in turn, it indicates that the binding between the Wi-Fi chip and the receiving device has failed.
[0117] Preferably, in response to the button switch being pressed continuously, the Wi-Fi chip is woken up and a long press operation is triggered. Specific Implementation Example 2
[0119] The following combination Figure 10 This invention introduces the software packet sending process design of the Wi-Fi switching circuit. Figure 10 Another exemplary flowchart of the data packet transmission method based on a Wi-Fi switch circuit according to the present invention is shown. The packet transmission method provided by the present invention constructs and transmits data packets at the data link layer. The receiving device is typically a Wi-Fi connected wireless device, such as a light or wall switch, whose MAC address is unique and fixed, but whose channel changes according to the access point (AP) requirements. In order to successfully communicate with the receiving device, the Wi-Fi chip needs to know the MAC address and channel of the receiving device in advance. To achieve the above requirements, the Wi-Fi chip 302's data packet transmission process includes the following steps S10 to S100.
[0120] In step S10, the operator presses button switch 202.
[0121] In step S20, in response to the button switch 202 being pressed, the Wi-Fi switch circuit is momentarily turned on, and the Wi-Fi chip 302 is triggered to enter the initialization state.
[0122] Preferably, in step S30, the Wi-Fi chip 302 sends a control signal to the controlled switch 201 to lock the controlled switch 201 in a connected state, so as to keep the power supply circuit of the Wi-Fi switch circuit in a conducting state; or in response to the button switch 202 being pressed, the button switch 202 controls the controlled switch 201 to lock in a connected state, so as to conduct the power supply circuit of the Wi-Fi switch circuit.
[0123] In step S40, the Wi-Fi chip 302 determines whether it has been bound to a receiving device. A management device table can be stored in the memory to store binding information between the Wi-Fi chip 302 and the receiving device. This table may also store the receiving device's MAC address, channel information, etc. If the Wi-Fi chip 302 cannot find the binding information for the receiving device in the management device table, it means the Wi-Fi switch is not bound to the receiving device, and step S50 is executed to perform the binding operation. If the Wi-Fi chip 302 can find the binding information for the receiving device in the management device table, it means the Wi-Fi switch is bound to the receiving device, and step S60 is executed to perform the control operation.
[0124] Specifically, in step S50, performing the binding operation includes: the Wi-Fi chip 302 broadcasting a binding packet. As an example of the present invention, the Wi-Fi chip 302 reads the current channel information and sends a binding packet to the current channel according to the current channel information. The binding packet may include a binding command.
[0125] Specifically, in step S60, performing the control operation includes: the Wi-Fi chip 302 sending a control packet to the bound receiving device. As an example of the present invention, the Wi-Fi chip 302 reads the MAC address and channel information of the bound receiving device, and sends a control packet to the receiving device based on the MAC address and channel information. The Wi-Fi chip 302 can look up the MAC address and channel information of the bound receiving device in a device management table. The control packet may include control commands.
[0126] In step S70, after the Wi-Fi chip 302 completes the binding operation or after the Wi-Fi chip 302 completes the control operation on the bound receiving device, the Wi-Fi chip 302 ends the communication and sends a control signal to the controlled switch 201 to control the controlled switch 201 to switch to the off state, thereby disconnecting the power supply circuit of the Wi-Fi switch circuit.
[0127] In step S80, the Wi-Fi chip stops working and enters sleep mode.
[0128] In step S90, in response to the long press button switch 202, the Wi-Fi chip can be woken up from the sleep state and a long press operation can be performed. The long press operation includes executing a custom event. As an example of the present invention, if the receiving device is a lamp, the long press operation can be to make the lamp brighter / dimer, adjust the color of the lamp, etc.
[0129] In step S100, the entire data packet sending process ends.
[0130] Binding operation
[0131] The following combination Figure 11 This invention describes an exemplary process for the Wi-Fi chip of the present invention to send a binding packet to a receiving device. When it is determined that the Wi-Fi chip is not bound to the receiving device, the Wi-Fi chip performs a binding operation.
[0132] In step S1101, the Wi-Fi chip 302 reads the current channel information and sends a binding packet to the current channel according to the current channel information. The binding packet may include a binding command. After sending a binding packet, the Wi-Fi chip 302 enters a sleep state. The sleep state duration corresponds to the predetermined duration for the coin cell battery to charge the front-end capacitor. When the Wi-Fi chip 302 is in a sleep state, the coin cell battery 101 charges the front-end capacitor 103. The Wi-Fi chip 302 re-enters the working state after the sleep state duration (i.e., the predetermined duration) has elapsed. As an example of the present invention, the sleep state duration / predetermined duration includes the duration for the front-end capacitor to store all its electrical energy or the duration for the front-end capacitor to store a predetermined amount of electrical energy. As an example of the present invention, the sleep state duration can be 30ms, 35ms, or 40ms.
[0133] In step S1102, the Wi-Fi chip 302 re-enters the working state after a predetermined time has elapsed to receive the binding response packet. If the Wi-Fi chip 302 fails to receive the binding response packet, step S1103 is executed; if the Wi-Fi chip 302 receives the binding response packet, step S1104 is executed.
[0134] Specifically, in step S1103, the Wi-Fi chip continuously sends binding packets to the current channel. Furthermore, if the Wi-Fi chip fails to receive a binding response packet after sending the maximum number of binding packets, step S1104 is executed, switching to the next channel as the current channel and continuing to send binding packets.
[0135] Repeat steps S1102 to S1104 until the Wi-Fi chip receives a binding response packet. Then, execute step S1106, where the Wi-Fi chip stores the MAC address and current channel information of the receiving device and indicates that the Wi-Fi chip has successfully bound to the receiving device. Specifically, the Wi-Fi chip 302 stores the binding information, MAC address, and channel information of the receiving device in the management device table. If no binding response packet is received after traversing all channels, step S1107 indicates that the binding between the Wi-Fi chip and the receiving device has failed. The total number of channels is greater than three.
[0136] Control process
[0137] The following combination Figure 12 This invention describes an exemplary process for the Wi-Fi chip of the present invention to send control packets to a paired receiving device. When it is determined that the Wi-Fi chip is paired with a receiving device, the Wi-Fi chip performs control operations.
[0138] In step S1201, the Wi-Fi chip 302 reads the MAC address and channel information of the bound receiving device from the management device table.
[0139] In step S1202, the Wi-Fi chip 302 sends a data packet to the receiving device based on the MAC address and channel information, wherein the data packet is a control packet. The control packet may include control commands. After sending a control packet, the Wi-Fi chip 302 enters a sleep state. The sleep state duration corresponds to the predetermined duration for the coin cell battery to charge the pre-stage capacitor. When the Wi-Fi chip 302 is in a sleep state, the coin cell battery 101 charges the pre-stage capacitor 103, and the Wi-Fi chip 302 re-enters the working state after the sleep state duration (i.e., the predetermined duration) has elapsed. As an example of the present invention, the sleep state duration / predetermined duration includes the duration for the pre-stage capacitor to store all electrical energy or the duration for the pre-stage capacitor to store a predetermined amount of electrical energy. As an example of the present invention, the sleep state duration can be 30ms, 35ms, or 40ms.
[0140] In step S1203, the Wi-Fi chip 302 re-enters the working state after a predetermined time has elapsed to receive a control response packet. If the Wi-Fi chip 302 fails to receive the control response packet, step S1104 is executed to determine whether the number of times the Wi-Fi chip 302 has sent control packets exceeds a predetermined threshold. For example, this predetermined threshold could be the maximum number of retransmissions for a stored channel. If the number of retransmissions does not exceed the predetermined threshold, steps S1202 to S1204 are repeated so that the chip continuously sends control packets to the receiving device based on the MAC address and channel information until the Wi-Fi chip receives the control response packet. Then, step S1210 is executed to indicate that the control packet sent by the Wi-Fi chip has been successfully received by the receiving device. If the number of retransmissions exceeds the predetermined threshold and no control response is received, step S1205 is executed to switch to the next channel as the current channel, and step S1206 is executed. The Wi-Fi chip sends control packets to the receiving device based on the MAC address and the current channel information and determines whether the control response packet has been successfully received. In step S1207, it is determined whether the number of times the Wi-Fi chip 302 sends control packets exceeds a predetermined threshold. For example, this predetermined threshold could be the maximum number of channel retransmissions. If the Wi-Fi chip continuously sends control packets on the current channel more than the predetermined threshold and still does not receive a control response packet, it continues to switch to the next channel as the current channel until all channels have been traversed. If a control response packet is successfully received, the process proceeds to step S1209, where the Wi-Fi chip 302 stores the current channel information in the management device table, and in step S1210, it indicates that the control packet sent by the Wi-Fi chip has been successfully received by the receiving device. If the Wi-Fi chip still does not receive a control response packet after switching all channels in turn, the process proceeds to step S1208, instructing the Wi-Fi chip to terminate communication with the receiving device.
[0141] As an example, not a limitation, Figure 13 Another exemplary flowchart is shown, illustrating how a Wi-Fi chip according to the present invention sends a control packet to a bound receiving device to perform a control operation.
[0142] In step S1301, the Wi-Fi chip 302 sends a data packet to the receiving device based on the MAC address and channel information, wherein the data packet is a control packet. The control packet may include control commands. After sending a control packet, the Wi-Fi chip 302 enters a sleep state. The sleep state duration corresponds to the predetermined duration for the coin cell battery to charge the pre-stage capacitor. When the Wi-Fi chip 302 is in a sleep state, the coin cell battery 101 charges the pre-stage capacitor 103, and the Wi-Fi chip 302 re-enters the working state after the sleep state duration (i.e., the predetermined duration) has elapsed. As an example of the present invention, the sleep state duration / predetermined duration includes the duration for the pre-stage capacitor to store all electrical energy or the duration for the pre-stage capacitor to store a predetermined amount of electrical energy. As an example of the present invention, the sleep state duration can be 30ms, 35ms, or 40ms.
[0143] In step S1302, the Wi-Fi chip 302 re-enters the working state after a predetermined time has elapsed to receive a control response packet. If the Wi-Fi chip 302 fails to receive the control response packet, step S1303 is executed; if the Wi-Fi chip 302 receives the control response packet, step S1104 is executed.
[0144] Specifically, in step S1303, the Wi-Fi chip continuously sends control packets to the current channel. If the Wi-Fi chip fails to receive a control response packet after sending control packets a predetermined threshold number of times, step S1304 is executed, switching to the next channel as the current channel and continuing to send control packets. When sending control packets on a stored channel, the predetermined threshold can be the maximum number of retransmissions on the stored channel; when sending control packets on other scanning channels, the predetermined threshold can be the maximum number of retransmissions on the scanning channel. The maximum number of retransmissions on the stored channel and the maximum number of retransmissions on the scanning channel can be the same value or different values. Preferably, the predetermined threshold is set to an integer greater than or equal to 5.
[0145] Repeat steps S1302 to S1304 until the Wi-Fi chip receives a control response packet. Then, execute step S1306, where the Wi-Fi chip stores the current channel information and indicates to the receiving device that it successfully received the control packet. If no control response packet is received after traversing all channels, then in step S1307, instruct the Wi-Fi chip to terminate communication with the receiving device. Note that the number of channels must be greater than three.
[0146] Receiving device response process
[0147] The following combination Figure 14This invention describes an exemplary process for a receiving device to send a response packet, wherein the response packet includes a binding response packet and a control response packet. The receiving device sends the binding response packet and the control response packet, specifically including the following steps:
[0148] (1) Register MAC event callbacks on the receiving device;
[0149] (2) Receive data packets from the Wi-Fi chip in the Wi-Fi switch circuit;
[0150] (3) The receiving device determines the type of the received data packet and performs corresponding operations according to the data packet type, wherein the data packet type includes control packets and binding packets;
[0151] (4) After the receiving device completes the corresponding operation, the receiving device enters a sleep state;
[0152] (5) When the sleep state duration of the receiving device is reached, the receiving device continuously sends response packets to the Wi-Fi chip; wherein the response packet is a control response packet when the received data packet type is a control response packet, and the response packet is a binding response packet when the received data packet type is a binding response packet.
[0153] The sleep state duration of the receiving device is less than the predetermined duration, where the predetermined duration is the time interval between when the Wi-Fi chip enters sleep state after sending data packets and when it re-enters working state.
[0154] Preferably, in response to determining that the data packet is a control packet, the receiving device executes a corresponding control event; in response to determining that the data packet is a binding packet, the receiving device stores the MAC address of the Wi-Fi chip.
[0155] Preferably, the number of times the receiving device continuously sends response packets does not exceed a second predetermined threshold or the duration of continuously sending response packets does not exceed a second predetermined duration.
[0156] Preferably, after the receiving device continuously sends response packets to the Wi-Fi chip, it further includes: clearing the received data packets.
[0157] Furthermore, combined Figure 15 This illustrates another exemplary process for a receiving device to send a response packet according to the present invention.
[0158] In step S1501, a MAC event callback is registered on the receiving device. As an example and not a limitation, the callback process includes receiving information, parsing message frames, determining whether the data comes from a bound device, determining the validity of the data, executing the message content, and returning a response.
[0159] In step S1502, the receiving device waits to receive a message. As an example of the present invention, the receiving device receives data packets from the Wi-Fi chip 302.
[0160] In step S1503, the receiving device determines the type of the received data packet and performs the corresponding operation. If the data packet is determined to be a control packet, which includes control commands, steps S1504 to S1506 are further executed. If the data packet is determined to be a binding packet, which includes binding commands, steps S1508 to S1510 are further executed.
[0161] In step S1504, the receiving device executes a corresponding control event. As an example of the present invention, assuming the receiving device is a smart light, the control event may include controlling the light to turn on, off, dim, brighten, or change color, etc.
[0162] In step S1505, after the receiving device executes the corresponding control event, it enters a receiving sleep state. As an example of the present invention, the duration of the receiving sleep state is shorter than the duration of the Wi-Fi chip 302 sleep state, so that the receiving device is woken up before the duration of the Wi-Fi chip 302 sleep state is reached (for example, 5ms before the duration of the sleep state is reached), thereby ensuring that the Wi-Fi chip 302 receives the acknowledgment information (ACK) in the response packet in the fastest possible time.
[0163] In step S1506, when the receiver's sleep state duration expires, the receiver continuously sends control response packets to the Wi-Fi chip 302. The control response packets include the receiver's MAC address. As an example of the present invention, the number of times the receiver continuously sends control response packets does not exceed a predetermined threshold or a predetermined duration. The predetermined threshold can be 5 times, or any predetermined number, which is not specifically limited here. The predetermined duration can be 10ms, or any predetermined response duration, which is not specifically limited here. After step S1506, step S1511 is executed.
[0164] In step S1507, it is further determined whether the data packet is a binding packet, which includes a binding command. If it is, steps S1508 to S1510 are executed; otherwise, the process proceeds to step S1511.
[0165] Specifically, in step S1508, the receiving device stores the MAC address of the Wi-Fi chip.
[0166] In step S1509, after storing the MAC address of the Wi-Fi chip, the receiving device enters a sleep state. As an example of the present invention, to ensure that the Wi-Fi chip 302 receives the acknowledgment (ACK) information as quickly as possible, the receiving device is woken up before the sleep state duration expires (e.g., 5ms before the sleep state duration expires). Therefore, the sleep state duration of the receiving device is shorter than the sleep state duration of the Wi-Fi chip 302.
[0167] In step S1510, when the sleep state duration of the receiving end expires, the receiving device continuously sends binding response packets to the Wi-Fi chip 302, and then executes step S1511. The binding response packets include the MAC address of the receiving device.
[0168] As an example of the present invention, the number of times the receiving device continuously sends the binding response packet does not exceed a predetermined threshold or does not exceed a predetermined duration. The predetermined threshold can be 5 times, or any predetermined number, which is not specifically limited here. The predetermined duration can be 10ms, or any predetermined response duration, which is not specifically limited here.
[0169] In step S1511, the received control packet is cleared, and the process returns to step S1502. Specific Implementation Example 3
[0171] The following is combined with Figure 16 The software workflow of the Wi-Fi switch circuit of this invention is described in conjunction with the hardware design. Figure 16 An exemplary current-voltage waveform diagram of the Wi-Fi switching circuit of the present invention is shown. Wherein, Io is the current required by the Wi-Fi chip, Ib is the output current of the coin cell battery, Ic is the current of the front-stage capacitor, Uo is the voltage on the capacitor side of the rear stage, Uc is the voltage on the capacitor side of the front stage, and Ub is the voltage on the coin cell battery side.
[0172] From the initial time to time t0
[0173] Initially, the voltage of the coin cell battery 101 is equal to the voltage of the pre-stage capacitor 103, while the voltages of the post-stage capacitor 301 and the Wi-Fi chip are zero. At this time, the current of the coin cell battery 101 is only the leakage current of the pre-stage capacitor 103. From the initial moment to time t0, due to the voltage division caused by the internal resistance of the coin cell battery, the voltage Ub on the coin cell battery side decreases slightly.
[0174] At time t0, the button switch 202 is pressed, the Wi-Fi switch circuit is turned on instantaneously, and the Wi-Fi chip 302 is triggered to enter the initialization state; the boost module 40 pumps the voltage of the button battery 101 to the operating voltage of the Wi-Fi chip 302, and at the same time the downstream capacitor 301 is charged to the operating voltage of the Wi-Fi chip 302, locking the controlled switch.
[0175] The locking of the controlled switch 201 may include: the Wi-Fi chip 302 sending a control signal to the controlled switch 201 to lock it in a connected state, thereby activating the power supply circuit of the Wi-Fi switch circuit; or, in response to pressing the button switch 202, the button switch 202 controls the controlled switch 201 to lock in a connected state, thereby activating the power supply circuit of the Wi-Fi switch circuit. A specific example of the Wi-Fi chip 302 sending a control signal to the controlled switch 201 is provided below. Figure 17 An exemplary circuit diagram of a controlled switch is shown. Specifically, when the push-button switch SW1 is pressed, the Wi-Fi chip initializes and pulls GPIO0 high in the software. At this time, MOSFET Q5 turns on, which in turn controls MOSFET Q2 to turn on. Regardless of whether the push-button switch SW1 is released, the BOOST circuit is in working state until the software pulls GPIO0 low, thereby turning off the power.
[0176] From time t0 to t1
[0177] At times t0 to t1, in response to pressing the button switch 202, the Wi-Fi chip 302 enters the initialization state. The current required for the initialization of the Wi-Fi chip 302 is less than the first threshold current, where the first threshold current is the maximum power supply current set by the current limiting unit 102. Therefore, the current limiting unit 102 does not work, and the current for the initialization of the Wi-Fi chip 302 is directly provided by the button battery 101.
[0178] Between times t0 and t1, there is a momentary increase in the front-end capacitor current Ic, which can be understood as a response to the instantaneous current provided when the load (e.g., Wi-Fi chip 302) is connected to the circuit. As the coin cell battery 101 continuously provides the output current Ib, the front-end capacitor current Ic drops to 0.
[0179] From time t1 to t2
[0180] Between times t1 and t2, the Wi-Fi chip 302 enters its working state and begins sending its first data packet. The operating current of the Wi-Fi chip 302 suddenly increases, exceeding the first threshold current (Io). Due to energy conservation, the current flowing into the input terminal of the boost module 40 also increases, exceeding the first threshold current (i.e., the maximum supply current set by the current limiting unit 102). At this time, the current limiting unit 102 starts working, limiting the output current Ib of the coin cell battery to the first threshold current. The coin cell battery 101 provides a constant first threshold current. To ensure a constant voltage at the output terminal of the boost module 40, the boost module 40 draws energy from the pre-stage capacitor 103, causing the voltage Uc on the pre-stage capacitor side to decrease. Because the power at the input terminal of the boost module 40 needs to be constant, the pre-stage capacitor current Ic continuously increases. It can be seen that at this time, the pre-stage capacitor 103 and the coin cell battery 101 work together to power the Wi-Fi chip 302.
[0181] At times t1 to t2, at the instant when the Wi-Fi chip 302 sends data packets, the boost module 40 circuit cannot respond to load changes in time (for example, the equivalent load resistance of the Wi-Fi chip decreases at the instant of packet transmission), which leads to a decrease in the output voltage of the boost module 40 (for example, the trend of Uo changing at times t1 and t3 in the current-voltage waveform). The subsequent capacitor 301 is used to provide buffer at the instant when the Wi-Fi chip 302 sends data packets to reduce the change in the output voltage of the boost module 40.
[0182] From time t2 to t3
[0183] Between times t2 and t3, when the Wi-Fi chip 302 finishes sending its first data packet and enters sleep mode, since the voltage Uc on the front-end capacitor side is lower than the voltage Ub on the coin cell side, the coin cell 101 charges the front-end capacitor 103 with a constant first threshold current through the current limiting unit 102, allowing the front-end capacitor to store electrical energy. The Wi-Fi chip 302 re-enters the operating state after a predetermined time has elapsed. It should be noted that when the Wi-Fi chip 302 enters sleep mode, its required current is approximately 1% of that in normal operation; therefore, it can be approximated that the required current of the Wi-Fi chip 302 at this time is 0.
[0184] The predetermined duration includes the duration for the pre-amplifier 103 to store all electrical energy, for example, the duration for which the pre-amplifier 103 is charged to a voltage equal to that of the coin cell 101; or the predetermined duration includes the duration for the pre-amplifier 103 to store a predetermined amount of electrical energy, for example, the duration for which the voltage of the pre-amplifier 103 is charged to a voltage equal to 80% to 90% of that of the coin cell 101.
[0185] Between times t2 and t3, the coin cell 101 is charging the pre-amplifier 103, with current flowing into it. Generally, the current is defined as positive when the pre-amplifier 103 is discharging and negative when it is charging. Therefore, the pre-amplifier current Ic is negative at this time. In the first half, due to the low voltage Uc on the pre-amplifier side after discharge, the charging process of the coin cell 101 to the pre-amplifier 103 is limited by the current limiting unit 102, causing the coin cell 101 to charge the pre-amplifier 103 with a constant current Ib. Therefore, the waveform in the first half is flat. In the second half, as the voltage Uc on the pre-amplifier side rises, the coin cell output current Ib gradually decreases. Therefore, the overall waveform of the coin cell output current Ib is that it initially maintains a high current value, then slowly decreases to near zero.
[0186] Time intervals from t3 to t5
[0187] Starting from time t3, the operations from times t1 to t2 and from t2 to t3 are repeated, with Wi-Fi chip 302 sending the remaining data packets to the receiving device. Since sending one data packet corresponds to Wi-Fi chip 302 entering a sleep state, Wi-Fi chip 302 can send one or more data packets to the receiving device. As an example of the present invention, the Wi-Fi chip includes one or more sleep states.
[0188] t6 time
[0189] At time t6, the Wi-Fi chip finishes sending all data packets. In response to the end of communication between the Wi-Fi chip and the receiving device, the Wi-Fi chip sends a control signal to the controlled switch to switch to the off state, thereby disconnecting the power supply circuit of the Wi-Fi switch circuit. At the same time, the boost module stops working, the voltage Uo on the side of the downstream capacitor discharges to 0V, and the Wi-Fi chip stops working.
[0190] As a specific example of the present invention, further explanation is provided regarding times t0 to t2. The following is in conjunction with... Figure 5 Current limiting unit and Figure 18 The diagram illustrates the operation of a current limiting unit of the present invention during times t0 to t2. Figure 18 Is it like this? Figure 5 The circuit diagram shown is an equivalent circuit diagram. In it, Vb is the equivalent power supply of button cell 101, Rb is the equivalent internal resistance of button cell 101, R1 and R2 are the voltage divider resistors of button cell voltage, and VCCS and Rds are the equivalent voltage-controlled current source and equivalent drain-source resistance of MOSFET Q4, respectively.
[0191] On the one hand, refer to Figure 5Between times t0 and t1, the Wi-Fi chip 302 enters the initialization state. The gate-source voltage of MOSFET Q4 is greater than the first threshold voltage, causing MOSFET Q4 to conduct. At this time, the voltage of the front-end capacitor 103 is equal to the voltage of the coin cell battery BT1. The first threshold voltage is the turn-on voltage. As an example of the present invention, the gate-source voltage of MOSFET Q4 is configured to be approximately 1V greater than the turn-on voltage, causing MOSFET Q4 to conduct.
[0192] Between times t1 and t2, in response to the Wi-Fi chip 302 entering the working state, the gate-source voltage of MOSFET Q4 is less than the second threshold voltage, causing MOSFET Q4 to be turned off. At this time, the output current of the coin cell BT1 is limited to the first threshold current. The second threshold voltage is the cutoff voltage.
[0193] On the other hand, reference Figure 18 At times t0 to t1, the button switch 202 is pressed, and the Wi-Fi chip 302 enters the initialization process. At this time, the current of the Wi-Fi chip 302 is low, the voltage division of the button battery Rb is low, the output voltage of the button battery does not decrease significantly, and the on-resistance of the MOSFET Q4 is almost zero. At this time, the energy required by the Wi-Fi chip 302 is directly provided by the button battery 101.
[0194] Between times t1 and t2, the Wi-Fi chip 302 begins sending data packets, increasing its operating current. This increases the current flowing into the input of the boost module 40, leading to an increase in the output current of the coin cell battery 101. Consequently, the voltage drop across the coin cell battery 101 due to its internal resistance Rb increases, causing its output voltage to decrease. This, in turn, lowers the gate-source voltage Vgs, increasing the on-resistance of the MOSFET Q5. This, in turn, reduces the current flowing through the coin cell battery, creating negative feedback and clamping the current to a preset value. Meanwhile, the remaining energy is supplied by the front-stage capacitor 103, causing its voltage to decrease slowly. Since the boost module 40 ensures consistent power across the boost side, the current in the front-stage capacitor 103 continuously increases as its voltage decreases. Specific Implementation Example 4
[0196] The following illustrates the power consumption analysis and testing of the Wi-Fi switching circuit according to an embodiment of the present invention. Referring to the current statistics during the packet transmission process provided in Table 1, the energy required for one packet transmission process is calculated as follows:
[0197] event Time (ms) Average current (mA) boot 30.9 14.8 nvs_init 8.84 21.4 Wi-Fi_init 7.18 21.65 Wi-Fi_start 17.77 47.1 send 2.87 96.3 wait ack 4.2 56.18
[0198] Table 1
[0199] Assuming an average of two data packets are sent before a response packet is received, the total energy of packet transmission is 8.790 mJ; the subsequent capacitor is 47 uF, and the energy required to fully charge it is 0.256 mJ.
[0200] As an example of the present invention, in an experimental environment of normal room temperature and office setting, using ordinary CR2032 batteries, the nominal voltage of the button battery is 3V, the nominal capacity of the button battery is 200mAh, the maximum output current is limited to the maximum pulse current, that is, the output current with half of the nominal capacity, the average discharge voltage is 2.7V, the actual energy that the button battery can release is 972J, the overall efficiency of the switching converter is 70%, and theoretically it can send about 94010 data packets.
[0201] As an example of this invention, the receiving device uses an ESP32C2 chip. A button switch is pressed every two seconds to send packets and the number of packets sent is counted; the actual number of packets sent is 36,254. Based on 20 presses per day, it can be used for approximately 5 years.
[0202] On the other hand, the present invention also protects a Wi-Fi switching device, which includes: a memory; a processor; and a computer program stored in the memory and executable by the processor; the processor executes the computer program to implement the button battery power supply method disclosed in the present invention.
[0203] Furthermore, the present invention also protects a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the button battery power supply method disclosed in the present invention.
[0204] On the other hand, the present invention also protects a device based on a Wi-Fi switching circuit, the Wi-Fi switching device comprising: a memory; a processor; and a computer program stored in the memory and executable by the processor; the processor executing the computer program implements the method for transmitting data packets based on the Wi-Fi switching circuit disclosed in the present invention.
[0205] Furthermore, the present invention also protects a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the method for transmitting data packets based on a Wi-Fi switching circuit disclosed in the present invention.
[0206] The methods, circuits, devices, and / or computer program products described in this invention can be used in scenarios such as remote controls for home appliances and smart doorbells.
[0207] Various aspects of a button cell battery powered method may take the form of a computer program product embodied in a computer-readable medium (or media), the computer-readable medium having computer-readable program code / instructions embodied thereon.
[0208] The method for sending data packets based on Wi-Fi switching circuits can take the form of a computer program product embodied in a computer-readable medium (or multiple media), which has computer-readable program code / instructions embodied thereon.
[0209] Any combination of computer-readable media may be used. Computer-readable media can be computer-readable signal media and / or computer-readable storage media. Computer-readable storage media can include electronic, magnetic, optical, electromagnetic, infrared, and / or semiconductor systems, devices, or apparatuses, or any suitable combination thereof. More specific examples of computer-readable storage media may include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable optical disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, any suitable combination thereof, etc. In the context of this disclosure, computer-readable storage media may include any suitable non-transitory tangible medium that may contain or store programs used by or in conjunction with an instruction execution system, device, or apparatus.
[0210] Computer-readable signal media may include, for example, data signals propagated in baseband or as part of a carrier wave, wherein the propagated data signals have computer-readable program code embodied therein. Such propagated signals may take any of a variety of forms, including, but not limited to, electromagnetic, optical, and / or any suitable combination thereof. Computer-readable signal media may include any computer-readable medium that is not a computer-readable storage medium and is capable of transmitting, propagating, or transferring programs for use by or in connection with an instruction execution system, device, or apparatus.
[0211] The program code embodied on the computer-readable medium can be transmitted using any suitable medium. The computer program code for performing the operations of various aspects of the methods disclosed herein can be written in one or any combination of programming languages, including object-oriented programming languages such as Java, Smalltalk, C++, etc., and conventional procedural programming languages (such as C). Mobile applications can be developed using any suitable language, including those previously mentioned, as well as Objective-C, Swift, C#, HTML5, etc. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN) and / or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0212] This invention describes aspects of methods with reference to flowchart illustrations and / or block diagrams of methods, circuits, apparatus, and / or computer program products. Each block and / or combination of blocks in the flowchart illustrations and / or block diagrams can be implemented by computer program instructions. The computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, implement the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. In some examples, machine-readable instructions can be programmed onto a programmable logic device, such as a field-programmable gate array (FPGA).
[0213] Computer program instructions may also be stored in a computer-readable medium that can direct a computer to operate in a particular manner, such that the instructions stored in the computer-readable medium produce an article of art including instructions that implement the functions / actions specified in the flowcharts and / or block diagrams.
[0214] Computer program instructions can also be loaded onto a computer to cause a series of operational steps to be performed on a device to produce a computer-implemented process, such that the instructions executed on the computer provide a process for implementing the functions / actions specified in the flowcharts and / or block diagrams.
[0215] Any flowcharts and / or block diagrams in the accompanying drawings are intended to illustrate the architecture, functionality, and / or operation of possible implementations of systems, methods, and computer program products according to aspects of the methods disclosed herein. In this regard, each block may represent a module, segment, or portion of code comprising one or more executable instructions for implementing a specified logical function. In some embodiments, the functions marked in a block may occur in a non-linear order as indicated in the drawings. For example, two blocks shown consecutively may actually execute substantially simultaneously, or these blocks may sometimes execute in reverse order, depending on the functions involved. Each block and / or combination of blocks may be implemented by a dedicated hardware-based system (or a combination of dedicated hardware and computer instructions) performing the specified function or action.
Claims
1. A method for transmitting data packets based on a Wi-Fi switching circuit, characterized in that, The Wi-Fi switching circuit includes: The system includes a power module, a switch module, and an output module. The power module includes a button battery and a pre-amplifier. The switch module includes a push-button switch. The output module includes a Wi-Fi chip. The method for sending data packets includes: In response to pressing the button switch, the Wi-Fi switch circuit is momentarily turned on and triggers the Wi-Fi chip to enter the initialization state, determines whether the Wi-Fi chip has been bound to the receiving device, and the Wi-Fi chip sends data packets. The front-end capacitor supplies power to the Wi-Fi chip when the Wi-Fi chip sends data packets. The Wi-Fi chip enters a sleep state after sending a data packet. During the sleep state, the button battery charges the front-end capacitor so that the front-end capacitor stores electrical energy. The Wi-Fi chip enters the working state again after a predetermined time. Specifically, in response to the Wi-Fi chip being bound to the receiving device, the data packet sent by the Wi-Fi chip is a control packet; in response to the Wi-Fi chip not being bound to the receiving device, the data packet sent by the Wi-Fi chip is a binding packet.
2. The method for sending data packets according to claim 1, characterized in that, in, The predetermined duration includes the duration for which the preceding capacitor stores all electrical energy or the duration for which the preceding capacitor stores a predetermined amount of electrical energy.
3. The method for sending data packets according to claim 1, characterized in that, Further includes: In response to determining that the Wi-Fi chip has been bound to a receiving device, the Wi-Fi chip reads the MAC address and channel information of the receiving device, and sends the data packet to the receiving device according to the MAC address and the channel information, wherein the data packet is a control packet.
4. The method for sending data packets according to claim 1, characterized in that, Further includes: In response to determining that the Wi-Fi chip is not bound to a receiving device, the Wi-Fi chip reads the current channel information and sends the data packet to the current channel according to the current channel information, wherein the data packet is a binding packet.
5. The method for sending data packets according to claim 3, characterized in that, in, The Wi-Fi chip re-enters the working state after a predetermined period of time, including receiving control response packets. In response to the Wi-Fi chip receiving a control response packet, the data packet sent by the Wi-Fi chip is successfully received by the receiving device; In response to the Wi-Fi chip not receiving a control response packet, the Wi-Fi chip continuously sends control packets to the receiving device based on the MAC address and the channel information.
6. The method for sending data packets according to claim 5, characterized in that, in, When the number of times the Wi-Fi chip continuously sends control packets reaches a first predetermined threshold, it switches to the next channel as the current channel and performs the following steps: (6a) The Wi-Fi chip sends a control packet to the receiving device based on the MAC address and the current channel information; (6b) Determine whether the Wi-Fi chip has received the control response packet; wherein, in response to the Wi-Fi chip receiving the control response packet, it indicates that the control packet sent by the Wi-Fi chip has been successfully received by the receiving device, and the Wi-Fi chip stores the current channel information; in response to the Wi-Fi chip not receiving the control response packet, it continues to switch to the next channel as the current channel, and repeats steps (6a) and (6b) until all channels are traversed, wherein the number of channels is greater than three.
7. The method for sending data packets according to claim 6, characterized in that, in, If the Wi-Fi chip still does not receive the control response packet after switching all channels in turn, the Wi-Fi chip terminates communication with the receiving device.
8. The method for sending data packets according to claim 4, characterized in that, in, The Wi-Fi chip re-enters the working state after a predetermined time period, including receiving a binding response packet. In response to the Wi-Fi chip receiving a binding response packet, the Wi-Fi chip stores the MAC address and current channel information of the receiving device, and indicates that the Wi-Fi chip has successfully bound to the receiving device; In response to the Wi-Fi chip not receiving a binding response packet, the Wi-Fi chip continuously sends the binding packet to the current channel.
9. The method for sending data packets according to claim 8, characterized in that, in, When the number of times the Wi-Fi chip continuously sends binding packets reaches a second predetermined threshold, it switches to the next channel as the current channel and performs the following steps: (9a) The Wi-Fi chip sends a binding packet to the current channel based on the information of the current channel; (9b) Determine whether the Wi-Fi chip has received the binding response packet, wherein, in response to the Wi-Fi chip receiving the binding response packet, the Wi-Fi chip stores the MAC address of the receiving device and the current channel information, and indicates that the Wi-Fi chip has successfully bound to the receiving device; in response to the Wi-Fi chip not receiving the binding response packet, continue to switch to the next channel as the current channel, and repeat steps (9a) and (9b) until all channels are traversed, wherein the number of all channels is greater than three.
10. The method for sending data packets according to claim 9, characterized in that, in, If the Wi-Fi chip still does not receive the binding response packet after switching all channels in turn, it indicates that the binding between the Wi-Fi chip and the receiving device has failed.
11. The method for sending data packets according to claim 1, characterized in that, In response to the button switch being pressed continuously, the Wi-Fi chip is woken up and triggers a long press operation.
12. A method for receiving data packets from a Wi-Fi switching circuit, characterized in that, include: Register a MAC event callback on the receiving device; The receiving device receives data packets from the Wi-Fi chip in the Wi-Fi switch circuit, determines the type of the received data packets, and performs corresponding operations based on the data packet type. The data packet type includes control packets and binding packets. In response to the receiving device completing the corresponding operation, the receiving device enters a sleep state; and When the sleep state duration of the receiving device is reached, the receiving device continuously sends response packets to the Wi-Fi chip; wherein, in response to the received data packet type being a control packet, the response packet is a control response packet, and in response to the received data packet type being a binding packet, the response packet is a binding response packet; The sleep state duration of the receiving device is less than a predetermined duration, wherein the predetermined duration is the time interval between when the Wi-Fi chip enters sleep state after sending a data packet and when it re-enters working state.
13. The method according to claim 12, characterized in that, The receiving device determines the type of the received data packet, including: In response to determining that the data packet is a control packet, the receiving device executes a corresponding control event; In response to determining that the data packet is a binding packet, the receiving device stores the MAC address of the Wi-Fi chip.
14. The method according to claim 12, characterized in that, The number of times the receiving device continuously sends the response packet does not exceed a second predetermined threshold or the duration of continuously sending the response packet does not exceed a second predetermined duration.
15. The method according to claim 13, characterized in that, After the receiving device continuously sends the response packets to the Wi-Fi chip, it further includes: clearing the received data packets.
16. A device based on a Wi-Fi switching circuit, characterized in that, include: Memory; processor; And computer programs stored in memory and executable by a processor; The processor executes the computer program to implement the method as described in any one of claims 1 to 11.
17. A computer-readable storage medium storing computer instructions thereon, characterized in that, When the computer instructions are executed by the processor, they implement the method as described in any one of claims 1 to 11.