WiFi configuration method, system and device, equipment and storage medium
By using asynchronous call functions on the WiFi configuration side, sending configuration requests to WiFi scripts, directly executing the wpa_cli command and generating configuration parameters, the problem of low WiFi configuration efficiency in the existing technology is solved, and a more efficient and flexible configuration process is achieved.
Patent Information
- Application Number
- CN202411801826.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-05-02
AI Technical Summary
The WiFi configuration method in the prior art is inefficient, and it is necessary to frequently adjust the C program process to deal with task changes in the wpa_cli command, resulting in cumbersome configuration process and reduced efficiency.
By setting up an asynchronous call function on the WiFi configuration side, the configuration request is sent to the WiFi script. The WiFi script directly executes the wpa_cli command and generates configuration parameters, and finally returns the parameters to the WiFi configuration side, simplifying the configuration process and eliminating the steps of encapsulating configuration requests.
It improves the efficiency of WiFi configuration, simplifies the operation process of C program processes using shell commands, and enhances flexibility and maintainability.
Smart Images

Figure CN119922573A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of WiFi technology, and in particular to a WiFi configuration method, system, device, equipment and storage medium. Background Art
[0002] The WiFi configuration end and the server end run on the Linux system. When it is necessary to perform configuration operations on the WiFi configuration end, the configuration operations include WiFi connection, obtaining WiFi status, WiFi list, and switching WiFi. The following steps are performed: the WiFi configuration sends a wpa_cli command to the server end. The C program process in the server end uses methods such as popen or fork to encapsulate the wpa_cli command. The wpa_supplicant (wpa_supplicant) is applied to the encapsulated wpa_cli command to obtain the configuration result corresponding to the wpa_cli command. The server end returns the configuration result to the WiFi configuration end to complete the WiFi configuration.
[0003] In the above method of configuring WiFi, the server needs to adjust the C program process used for encapsulation every time the wpa_cli command from the WiFi configuration end is changed. The adjustment of the C program process involves a lot of control, which reduces the efficiency of WiFi.
[0004] In summary, the WiFi configuration method in the prior art reduces the configuration efficiency.
[0005] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0006] In order to solve the above technical problems, the present invention provides a WiFi configuration method, system, device, equipment and storage medium, which solves the problem that the WiFi configuration method in the prior art reduces the configuration efficiency.
[0007] To achieve the above object, the present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a WiFi configuration method, which includes:
[0009] Obtain a configuration request sent by the WiFi configuration terminal, and send the configuration request to the WiFi script;
[0010] Receive configuration parameters fed back by the WiFi script;
[0011] The configuration parameters are sent to the WiFi configuration terminal, where the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
[0012] In one implementation, sending the configuration request to a WiFi script includes:
[0013] Determine wifi_start.sh in the WiFi script;
[0014] Sending the configuration request to the client via the TCP socket communication protocol;
[0015] The configuration request is sent to the wifi_start.sh through the client.
[0016] In one implementation, sending the configuration request to the wifi_start.sh through the client includes:
[0017] Converting the configuration request into a configuration standard request matching the WiFi script by the client;
[0018] The configuration standard request is sent to the wifi_start.sh through the client.
[0019] In one implementation, receiving the configuration parameters fed back by the WiFi script includes:
[0020] When the WiFi script completes executing the configuration request and generates configuration parameters, the configuration parameters fed back by the WiFi script are received through the client.
[0021] In one implementation, before the WiFi configuration end sends the configuration request, an asynchronous call function has been configured internally in the WiFi configuration end, and the asynchronous call function is used to take the configuration parameters as input and output a configuration result, and the configuration result is used to complete the configuration of the WiFi configuration end.
[0022] In a second aspect, the present invention further provides a WiFi configuration system for implementing the WiFi configuration method described above, comprising a server, a client, and a WiFi script, wherein the server and the client communicate bidirectionally, and the client and the WiFi script communicate bidirectionally;
[0023] The server is used to obtain the configuration request sent by the WiFi configuration end and send the configuration request to the WiFi script; and to receive the configuration parameters fed back by the WiFi script; and to send the configuration parameters to the WiFi configuration end, and the configuration parameters are used to complete the configuration of the WiFi configuration end.
[0024] In one implementation, the server is provided with a plurality of interfaces, the interfaces correspond to the configuration requests one by one, and each of the interfaces is used to receive the configuration request corresponding to the interface sent by the WiFi configuration end.
[0025] In a third aspect, an embodiment of the present invention further provides a WiFi configuration device, wherein the device includes the following components:
[0026] A first sending module, used to obtain a configuration request sent by a WiFi configuration terminal, and send the configuration request to a WiFi script;
[0027] A receiving module, used to receive the configuration parameters fed back by the WiFi script;
[0028] The second sending module is used to send the configuration parameters to the WiFi configuration terminal, and the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
[0029] In a fourth aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and a WiFi configuration program stored in the memory and executable on the processor, and when the processor executes the WiFi configuration program, the steps of the above-mentioned WiFi configuration method are implemented.
[0030] In a fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a WiFi configuration program is stored. When the WiFi configuration program is executed by a processor, the steps of the WiFi configuration method described above are implemented.
[0031] Beneficial effect: The server of the present invention receives a configuration request sent by a WiFi configuration end, and then sends the configuration request to a WiFi script. The WiFi script runs the configuration request to obtain configuration parameters, and then sends the configuration parameters to the WiFi configuration end. The WiFi configuration end completes the WiFi configuration based on the configuration parameters. The WiFi script can receive unencapsulated configuration requests, so the process of encapsulating configuration requests can be omitted. The configuration request runs directly on the WiFi script, which simplifies the operation process of the C program process using shell commands during WiFi configuration, thereby improving the WiFi configuration efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is the overall flow chart of the present invention;
[0033] Figure 2 This is a structural diagram of a WiFi configuration system in an embodiment of the present invention;
[0034] Figure 3This is a flowchart of WiFi configuration in an embodiment of the present invention;
[0035] Figure 4 A structural diagram of the WiFi configuration device provided by the present invention;
[0036] Figure 5 This is a block diagram of the internal structure principle of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following is a clear and complete description of the technical solution of the present invention in combination with the embodiments and the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Through research, it is found that the WiFi configuration end and the server end run on the Linux system. When it is necessary to perform configuration operations on the WiFi configuration end, the configuration operations include WiFi connection, obtaining WiFi status, WiFi list, and switching WiFi. The following steps are performed: the WiFi configuration sends a wpa_cli command to the server end, and the C program process in the server end uses methods such as popen or fork to encapsulate the wpa_cli command. The wpa_supplicant (wpa_supplicant) is applied to the encapsulated wpa_cli command to obtain the configuration result corresponding to the wpa_cli command. The server end returns the configuration result to the WiFi configuration end to complete the WiFi configuration.
[0039] In the above method of configuring WiFi, the server needs to adjust the C program process used for encapsulation every time the wpa_cli command from the WiFi configuration end is changed. The adjustment of the C program process involves a lot of control, which reduces the efficiency of WiFi.
[0040] The program code required for the above WiFi configuration method is as follows:
[0041]
[0042]
[0043] As can be seen from the above code, the WiFi configuration method in the prior art is cumbersome, difficult to debug, and lacks flexibility. Difficult debugging means that when calling through multiple levels of interfaces, debugging problems becomes more difficult. Error messages are not intuitive enough, and it is more difficult to locate specific problems. Lack of flexibility means that the encapsulated interface limits the customization and extension of the wpa_cli command, making it impossible to flexibly adjust when facing new requirements.
[0044] In order to solve the above technical problems, the present invention provides a WiFi configuration method, system, device, equipment and storage medium, which solves the problem that the WiFi configuration method in the prior art reduces the configuration efficiency.
[0045] Embodiment 1: This embodiment provides a WiFi configuration system, such as Figure 2 As shown, the system includes a server, a client and a WiFi script, which cooperate with each other to complete the configuration operation of the WiFi configuration terminal, that is, the WiFi configuration terminal is the configuration object of the WiFi configuration system. Figure 2 The server in the client is Figure 2 In the client, the WiFi script can be Figure 2 wifi_start.sh in the wifi_start.sh file. wifi_start.sh is a script used to start and configure WiFi connections. It can be used to create the folders required to connect to WiFi and load WiFi drivers.
[0046] The WiFi configuration end, server end, client end and WiFi script in this embodiment run in a Linux system.
[0047] The server is provided with multiple interfaces, and different configuration requests are transmitted to the server through different interfaces, so that the server can transmit different configuration requests to the WiFi script, so as to complete the WiFi configuration of the WiFi configuration terminal through the configuration parameters fed back by the WiFi script.
[0048] like Figure 2 As shown, the WiFi configuration end sends the configuration request to wifi_start.sh through the server, the client and the server in sequence. After wifi_start.sh runs the configuration request, wifi_start.sh outputs the configuration parameters and returns the configuration parameters to the WiFi configuration end through the client and the server in sequence.
[0049] The code required by wifi_start.sh to run the configuration request is as follows:
[0050] wpa_cli status
[0051] status_code=$?
[0052] echo "status_code$status_code".
[0053] Embodiment 2, based on embodiment 1, the WiFi configuration name method of this embodiment can be applied to a terminal device, and the terminal device can be a terminal product with data transceiver function, such as a server. Figure 1 As shown in , the WiFi configuration method specifically includes the following steps:
[0054] S100, obtaining a configuration request sent by a WiFi configuration terminal, and sending the configuration request to a WiFi script;
[0055] S200, receiving the configuration parameters fed back by the WiFi script;
[0056] S300, sending the configuration parameters to the WiFi configuration terminal, where the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
[0057] In this embodiment, an asynchronous call function is first set at the WiFi configuration end (the asynchronous call function is a prior art). After the setting of the asynchronous call function is completed, the server reads the configuration request from the queue package in the WiFi configuration end, and then the server sends the configuration request to the client through the TCP sockect communication protocol. The client converts the configuration request into a configuration standard request that matches the WiFi script, and the client sends the configuration standard request to the wifi_start.sh. That is, the client's output printf converts the configuration request into a standard configuration request and sends it to wifi_start.sh. Wifi_start.sh runs the configuration request to generate configuration parameters, and then feeds the configuration parameters back to the client. The client then feeds the configuration parameters back to the server through the TCP sockect communication protocol. The server feeds the configuration parameters back to the asynchronous call function of the WiFi configuration end. The asynchronous call function uses the configuration parameters as input and outputs the configuration result. After obtaining the configuration result, the WiFi configuration of the WiFi configuration end is completed. Among them, inputting the configuration parameters into the asynchronous call function and the asynchronous call function outputting the configuration result are prior art.
[0058] Before configuration, such as Figure 3As shown, you need to first open the TCP protocol of the server, start the client, and the TCP protocol of the client. The server sends the configuration request to the client, and the client sends the configuration request to wifi_start.sh. WiFi_start.sh feeds back the configuration parameters to the client. If the recv function of the client is blocked at this time, the configuration parameters will wait to be received by the client until the recv function is idle, and the client will receive the configuration parameters to prevent interruption of the task being executed by the client. The client feeds back the received configuration parameters to the server through the TCP protocol, and the server feeds back the configuration parameters to the WiFi configuration end. During the entire configuration process, the server is in the started state so as to receive the configuration request sent by the WiFi configuration end in time.
[0059] Using TCP (TCP stands for Transmission Control Protocol) as the communication protocol between the server and the client can ensure efficient and reliable communication between the client and the server.
[0060] In summary, the present invention can complete the WiFi configuration process and return the result by directly executing the wpa_cli command (the wpa_cli command is the configuration request command) on the shell script wifi_start.sh, which simplifies the operation process of the C program process using the shell command during WiFi configuration and improves flexibility, efficiency and maintainability.
[0061] This embodiment also provides a WiFi configuration device, such as Figure 4 As shown, the device comprises the following components:
[0062] The first sending module 01 is used to obtain a configuration request sent by a WiFi configuration terminal, and send the configuration request to a WiFi script;
[0063] Receiving module 02, used to receive the configuration parameters fed back by the WiFi script;
[0064] The second sending module 03 is used to send the configuration parameters to the WiFi configuration terminal, and the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
[0065] Based on the above embodiments, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 5As shown. The terminal device includes a processor, a memory, a network interface, and a display screen connected through a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a WiFi configuration method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen.
[0066] Those skilled in the art will understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0067] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a WiFi configuration method program stored in the memory and executable on the processor. When the processor executes the WiFi configuration method program, the following operation instructions are implemented:
[0068] Obtain a configuration request sent by the WiFi configuration terminal, and send the configuration request to the WiFi script;
[0069] Receive configuration parameters fed back by the WiFi script;
[0070] The configuration parameters are sent to the WiFi configuration terminal, where the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
[0071] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A WiFi configuration method, characterized in that: include: Obtain a configuration request sent by the WiFi configuration terminal, and send the configuration request to the WiFi script; Receive configuration parameters fed back by the WiFi script; The configuration parameters are sent to the WiFi configuration terminal, where the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
2. The WiFi configuration method according to claim 1, wherein: Send the configuration request to the WiFi script, including: Determine wifi_start.sh in the WiFi script; Sending the configuration request to the client via the TCP socket communication protocol; The configuration request is sent to the wifi_start.sh through the client.
3. The WiFi configuration method according to claim 2, characterized in that: Sending the configuration request to the wifi_start.sh through the client includes: Converting the configuration request into a configuration standard request matching the WiFi script by the client; The configuration standard request is sent to the wifi_start.sh through the client.
4. The WiFi configuration method according to claim 1, wherein: The configuration parameters fed back by the WiFi script are received, including: When the WiFi script completes executing the configuration request and generates configuration parameters, the configuration parameters fed back by the WiFi script are received through the client.
5. The WiFi configuration method according to claim 1, wherein: Before the WiFi configuration end sends the configuration request, an asynchronous call function has been configured inside the WiFi configuration end, and the asynchronous call function is used to take the configuration parameters as input and output a configuration result, and the configuration result is used to complete the configuration of the WiFi configuration end.
6. A WiFi configuration system, characterized in that: Used to implement the WiFi configuration method as claimed in claim 1, comprising a server, a client and a WiFi script, wherein the server and the client communicate bidirectionally, and the client and the WiFi script communicate bidirectionally; The server is used to obtain the configuration request sent by the WiFi configuration terminal, and send the configuration request to the WiFi script; and configuration parameters for receiving feedback from the WiFi script; And used to send the configuration parameters to the WiFi configuration end, where the configuration parameters are used to complete the configuration of the WiFi configuration end.
7. The WiFi configuration system according to claim 6, characterized in that: The server is provided with a plurality of interfaces, the interfaces correspond to the configuration requests one by one, and each of the interfaces is used to receive the configuration request corresponding to the interface sent by the WiFi configuration end.
8. A WiFi configuration device, characterized in that: The device comprises the following components: A first sending module, used to obtain a configuration request sent by a WiFi configuration terminal, and send the configuration request to a WiFi script; A receiving module, used to receive the configuration parameters fed back by the WiFi script; The second sending module is used to send the configuration parameters to the WiFi configuration terminal, and the configuration parameters are used to complete the configuration of the WiFi configuration terminal.
9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a WiFi configuration program stored in the memory and executable on the processor. When the processor executes the WiFi configuration program, the steps of the WiFi configuration method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a WiFi configuration program, and when the WiFi configuration program is executed by the processor, the steps of the WiFi configuration method according to any one of claims 1 to 5 are implemented.