Network management method for embedded device
By setting physical buttons and thread mechanisms on embedded devices, the network management problem of devices without touch screen displays is solved, automatic network switching and fault handling are achieved, and a unified network management interface is provided to support user and APP operations.
Patent Information
- Application Number
- CN202311078307.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-08-25
AI Technical Summary
Embedded Linux devices cannot effectively perform network management without a touch screen display, especially when problems occur during the network connection process, they cannot provide feedback to users, and lack an effective network management response mechanism, which affects the normal use of network functions.
By setting a physical button on the embedded device as the client, combining the first and second threads, callback functions and global variables, automatic switching of network modes and fault handling are achieved, providing a unified network management interface, and supporting network operations for users and built-in APPs.
It realizes automatic network switching and troubleshooting on devices without touch screen displays, provides an automated network management mechanism for different network environments, avoids network unavailability caused by arbitrary switching of illegal processes, and supports network management of users and apps.
Abstract
Description
Technical Field
[0001] The present invention relates to a network management method, in particular to a network management method for embedded devices. Background Art
[0002] Embedded Linux devices often use Wi-Fi and Ethernet modules. Wi-Fi allows for efficient device connectivity, effectively avoiding Ethernet cabling issues. Ethernet ensures stable data transmission, addressing Wi-Fi's susceptibility to interference. Using both together enables efficient interoperability between devices, making them more intelligent.
[0003] Because embedded devices integrate multiple network communication methods, network management and configuration are required on the device. Existing embedded Linux devices primarily interact with the device through a touchscreen display to manage and operate Wi-Fi and Ethernet networks. This approach offers the advantages of intuitiveness and simple implementation of underlying interactive applications, allowing users to directly enable and disable services based on touch selections.
[0004] However, many embedded devices lack touchscreen functionality due to cost and other constraints. In these cases, network configuration and management cannot be accomplished through touchscreen interaction. In particular, when network connection issues arise, these devices are unable to provide user feedback via the display, and users are unable to take appropriate actions based on this information, hindering effective network management.
[0005] On the other hand, dedicated devices such as campus radio speakers also integrate apps such as music playback and online radio. These apps also need to actively initiate specific network connections based on actual usage. However, existing embedded devices lack effective network management response mechanisms and are unable to assist such apps in completing network connections and intermediate state control processing. Summary of the Invention
[0006] The present invention proposes a network management method for embedded devices, the purpose of which is to solve the problem that in existing devices without a touch screen display, users and built-in APPs cannot perform effective network management, which hinders the normal use of network functions.
[0007] The technical solutions of the present invention are as follows:
[0008] A network management method for an embedded device, wherein the embedded device is provided with a physical button for initiating a network switching instruction;
[0009] A first thread is provided, and the first thread is used to process the registration and management of the client; the client includes the physical button and the APP installed in the device;
[0010] A second thread is provided, and the second thread is used to respond to the network management request sent by the client;
[0011] A global variable is provided, and the global variable is used to record the current target network mode and the current network status;
[0012] A network processing loop is started in the main program of the device to handle faults in the network management process based on global variables.
[0013] As a further improvement of the network management method of the embedded device: multiple first callback functions corresponding to different network modes are registered, and the first callback function is used to process the status information generated when the device switches to the network mode corresponding to the first callback function.
[0014] As a further improvement of the network management method of the embedded device: the second thread calls the first callback function in response to the network management request sent by the client, and the first callback function sends the formatted status information obtained by processing to the client that initiates the network management request.
[0015] As a further improvement of the network management method for embedded devices: a second callback function is registered for parsing the network management request sent by the client to obtain the target network mode in the network management request.
[0016] As a further improvement of the network management method for the embedded device: the second thread calls the second callback function when responding to the network management request sent by the client, and saves the target network mode obtained by parsing into a global variable.
[0017] As a further improvement of the network management method for the embedded device: when responding to the network management request sent by the client, the second thread determines the current network status according to the generated status information and saves the current network status to a global variable.
[0018] As a further improvement of the network management method of the embedded device: in the network processing loop, the current network status recorded by the global variable is first read. If the current network status is "connection failed", the network mode is switched according to the current target network mode recorded by the global variable.
[0019] As a further improvement of the network management method of the embedded device: when the network processing loop switches the network mode, the current network status is determined based on the generated status information, and the current network status is saved in a global variable until the network status is "connection successful".
[0020] As a further improvement of the network management method of the embedded device: when the device is turned on, the main program first switches the device to a preset network mode, then starts the first thread and the second thread, and then starts the network processing loop.
[0021] As a further improvement of the network management method of the embedded device: the network mode includes Wi-Fi STA mode, Wi-Fi SoftAP mode and Ethernet mode.
[0022] Compared with the prior art, the present invention has the following positive effects: (1) The present invention processes the network management request and the status information generated during the network mode switching process by creating a second thread and a corresponding callback function for processing client requests, and uses global variables as a bridge to further utilize the network processing loop to automatically identify the switching failure and re-switch, thereby providing an automated network management mechanism for different network usage environments, so that the device can assist users and built-in APPs to complete network management without a touch screen; (2) The present invention introduces a client mechanism, and regards the physical buttons operated by the user and the built-in APP as clients, and completes the relevant processing of network management operations by responding to client requests, providing users and built-in APPs with a unified network management interface, while also avoiding the problem of network unavailability caused by illegal processes switching networks at will. DETAILED DESCRIPTION
[0023] The technical solution of the present invention is described in detail below:
[0024] The present invention discloses a network management method for an embedded device. The embedded device does not have a touchscreen display, but is provided with a physical button for initiating a network switching command. Typically, the network modes include Wi-Fi STA mode, Wi-Fi SoftAP mode, and Ethernet mode. Accordingly, the device can be provided with three groups of buttons corresponding to the three network modes to issue network mode switching commands. Alternatively, another number of buttons can be provided to distinguish different target network modes through short presses, long presses, double presses, and other methods.
[0025] The device program includes a first thread for handling client registration and management. In this disclosure, the term "client" is an abstract concept encompassing both the physical button and apps installed on the device (e.g., music player software). Before the device leaves the factory, the physical button is registered as the default client. Other apps are then registered during installation or through other configurations to complete client registration. Within the device, clients are managed through a database.
[0026] A second thread is provided in the device program, and the second thread is used to respond to the network management request sent by the client.
[0027] At the same time, the program registers three first callback functions corresponding to the three network modes, and also registers a second callback function. Among them, network_ap_status_handler is a callback function corresponding to softap mode. When Wi-Fi is in softap mode, i.e., routing mode, this callback function is responsible for processing the relevant status information of disconnection and connection operations; network_sta_status_handler is a callback function corresponding to sta mode. When Wi-Fi is in sta mode, it processes the status information such as scanning, connecting, connection success, connection failure, disconnection, and authentication generated by the device during the process of connecting to the designated router; network_ether_line_status_handler is a callback function corresponding to Ethernet mode, which is used to process the status information when the Ethernet cable is inserted / disconnected. The first callback function can also send the processed status information to the client. The second callback function is used to parse the network management request sent by the client and obtain the target network mode in the network management request.
[0028] The program also includes global variables for recording the current target network mode and the current network status.
[0029] The working process of the equipment is as follows:
[0030] 1. When the device is turned on, the main program Manager is started. The main program is the core daemon process of the network management mechanism.
[0031] 2. The main program first switches the device to the preset network mode.
[0032] 3. The main thread registers the three groups of first callback functions mentioned above: network_ap_status_handler, network_sta_status_handler and network_ether_line_status_handler.
[0033] 4. The main thread starts the first thread and the second thread, and registers the second callback function.
[0034] 5. The first thread registers clients for physical buttons and other apps, and manages the clients through the database.
[0035] 6. The second thread starts to listen to the client's network management request. When the second thread receives the network management request sent by the client, it first determines whether the client has been registered. If not, it will not respond. When responding to the request, the second thread first calls the second callback function, parses the network management request sent by the client, obtains the target network mode in the network management request, and saves the target network mode to a global variable. At the same time, the second thread starts a new thread, and starts switching to the target network mode in the new thread. When switching the network mode, the status information generated during the switching process is processed by calling the corresponding first callback function, and the formatted status information obtained by the processing is sent to the client that initiated the network management request. The status information is specific status text information, such as "network cable inserted", "network cable unplugged" in Ethernet mode, and "connected to router" in STA mode. The status information is different in different network modes, and the information format required by the client is also different.
[0036] When switching network modes, the current network status is determined based on the generated status information and saved in a global variable. The "network status" here is not the same as the "status information" mentioned above. The network status only has a few fixed values, such as "Connecting," "Connection Successful," and "Connection Failed." It is a status flag derived from detailed status information, which is determined and classified.
[0037] 7. After completing step 4, the main program begins the network processing loop (mainloop). This loop provides a fault-tolerant mechanism, handling network management failures based on global variables. The loop is divided into three main sections: AP, STA, and Ethernet, corresponding to the three network modes. Conditional jumps are performed based on the target network mode, enabling targeted processing.
[0038] In the network processing loop, for each target network mode, the current network status recorded in the global variable is first read. If the current network status is "connection failed", indicating that the second thread has failed to complete the network mode switch, the network mode is switched again according to the target network mode.
[0039] When the network processing loop switches the network mode again, the current network status is determined based on the generated status information and saved in the global variable until the network status is "connected successfully".
[0040] In the network processing loop, the client that initiated the request can also be found by querying the request record, and the status information generated during the re-switching process can be returned to the client through the first callback function.
[0041] The above callback functions and two threads work closely with the mainloop and complement each other to help users and apps implement network management functions. This allows devices without touch screens to automatically complete network switching through user key operations or app requests, and automatically handle faults and errors during the switching process.
Claims
1. A network management method for an embedded device, characterized by: The embedded device is provided with a physical button for initiating a network switching instruction; A first thread is provided, and the first thread is used to process the registration and management of the client; the client includes the physical button and the APP installed in the device; A second thread is provided, and the second thread is used to respond to the network management request sent by the client; A global variable is provided, and the global variable is used to record the current target network mode and the current network status; Start a network processing loop in the device's main program to handle network management failures based on global variables. A plurality of first callback functions corresponding to different network modes are registered, wherein the first callback function is used to process status information generated when the device switches to the network mode corresponding to the first callback function; The status information in Ethernet mode includes: "Network cable plugged in", "Network cable unplugged", and the status information in STA mode includes: "Scanning", "Connecting", "Connection successful", "Connection failed", "Disconnected", and "Authentication"; The second thread calls the first callback function in response to the network management request sent by the client, and the first callback function sends the formatted status information obtained by processing to the client that initiates the network management request; A second callback function is registered for parsing the network management request sent by the client and obtaining the target network mode in the network management request; The second thread calls the second callback function in response to the network management request sent by the client, and saves the target network mode obtained by parsing into a global variable; When responding to the network management request sent by the client, the second thread determines the current network status according to the generated status information and saves the current network status into a global variable.
2. The network management method for an embedded device according to claim 1, wherein: In the network processing loop, the current network status recorded in the global variable is first read. If the current network status is "connection failed", the network mode is switched according to the current target network mode recorded in the global variable.
3. The network management method for an embedded device according to claim 2, wherein: When the network processing loop switches the network mode, the current network status is determined based on the generated status information and saved to the global variable until the network status is "connected successfully".
4. The network management method for an embedded device according to claim 1, wherein: When the device is turned on, the main program first switches the device to a preset network mode, then starts the first thread and the second thread, and then starts the network processing loop.
5. The network management method for an embedded device according to any one of claims 1 to 4, characterized in that: The network modes include Wi-Fi STA mode, Wi-Fi SoftAP mode and Ethernet mode.
Citation Information
Patent Citations
Embedded type data communication terminal and method
CN101646264A
Back splint type private network mobile device
CN111294452A
Network type switching method and device, terminal equipment and computer readable medium
CN114585037A