A wireless network connection method, device, equipment and medium of an Internet of Things device
By using the USB interface to enumerate storage device categories and install drivers on IoT devices, and then enumerating them as communication device categories, network connection information can be obtained and utilized to achieve wireless network connection. This solves the problems of cumbersome network configuration operations and security risks for IoT devices, improves network configuration efficiency, and reduces the risk of data leakage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN LINGDECHUANG TECH CO LTD
- Filing Date
- 2026-06-22
- Publication Date
- 2026-07-21
AI Technical Summary
When IoT devices connect to wireless networks, the operation links are lengthy and require a lot of manual operation, resulting in low deployment efficiency. Furthermore, the transmission of network configuration information through hotspot channels poses security risks.
The preset driver is sent to the host device via USB interface, enumerated as a storage device category for installation, and then enumerated as a communication device category. The current network connection information is obtained and fed back. Based on this information, the physical address and channel number of the target access point are determined to realize the wireless network connection.
It simplifies the network distribution process for IoT devices, improves network distribution efficiency, and reduces the risk of data leakage during the network distribution process.
Smart Images

Figure CN122438142A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of electronic digital data processing technology, specifically relating to a wireless network connection method, apparatus, device, and medium for Internet of Things (IoT) devices. Background Technology
[0002] With the rapid development of IoT technology, various IoT devices have been widely used in daily life and industrial scenarios. IoT devices typically need to connect to wireless networks to achieve functions such as data uploading and remote control.
[0003] Currently, the common way for IoT devices to connect to wireless networks is as follows: users turn on their mobile hotspots, the IoT devices connect to these hotspots, and after successful connection, the user enters the network name and password on their mobile phone, which are then transmitted to the IoT devices via the hotspot. The IoT devices then scan for corresponding wireless access points in the surrounding wireless environment based on the network name and complete access authentication using the network password. However, this network configuration method involves a lengthy operation chain and requires a lot of manual intervention. Deployment efficiency is low when configuring a large number of IoT devices in a centralized manner, and the fact that configuration information is transmitted via hotspot channels poses a security risk of information leakage. Summary of the Invention
[0004] This application provides a wireless network connection method, apparatus, device, and medium for IoT devices, aiming to simplify the network configuration process of IoT devices, improve network configuration efficiency, and reduce the risk of data leakage during the network configuration process.
[0005] In a first aspect, embodiments of this application provide a wireless network connection method for an Internet of Things (IoT) device. The IoT device includes a USB interface and a main control module, wherein the USB interface is connected to a host device. The method is executed by the main control module and includes: The USB interface is enumerated as a storage device category, and a preset driver is sent to the host device through the USB interface to install the preset driver on the host device; Upon detecting that the preset driver has been installed, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address, and access point channel number; The system receives the current network connection information returned by the host device through the USB interface, and determines the physical address of the target access point and the channel number of the target access point based on the current network connection information. A network connection is established based on the network name, the network password, the target access point physical address, and the target access point channel number.
[0006] Furthermore, the current network connection information also includes signal strength and signal-to-noise ratio; Accordingly, determining the physical address of the target access point and the channel number of the target access point based on the current network connection information includes: If the signal strength exceeds a first threshold and the signal-to-noise ratio exceeds a second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point. If the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name, and the physical address and channel number of the target access point are determined based on the other access points.
[0007] Furthermore, determining the physical address and channel number of the target access point based on the other access points includes: Obtain the signal strength, signal-to-noise ratio, physical address, and channel number of the other access points; Based on the signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points; The channel difference coefficient of the other access points is determined based on the access point channel number of the other access points and the access point channel number in the current network connection information; The comprehensive index of the other access points is determined based on the link quality index and the channel difference coefficient, and the physical address and channel number of the other access point with the highest comprehensive index are determined as the physical address and channel number of the target access point.
[0008] Furthermore, determining the link quality indicators of the other access points based on their signal strength and signal-to-noise ratio includes: Calculate the difference between the signal strength of the other access points and the signal strength in the current network connection information; Based on the difference, attenuation compensation is performed on the signal strength of the other access points to obtain the compensated signal strength of the other access points; Based on the compensated signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points.
[0009] Furthermore, determining the channel difference coefficient of the other access points based on their access point channel numbers and the access point channel numbers in the current network connection information includes: Obtain the number of access points corresponding to the access point channel numbers of the other access points, and determine the channel congestion parameters of the other access points based on the number of access points; The channel offset parameter of the other access points is determined based on the difference between the access point channel number of the other access points and the access point channel number in the current network connection information. The channel difference coefficients of the other access points are determined based on the channel congestion parameter and the channel offset parameter.
[0010] Furthermore, after determining the physical address and channel number of the target access point based on the other access points, the method further includes: The target access point physical address and target access point channel number are sent to the host device via the USB interface, so that the network name, the network password, the target access point physical address and the target access point channel number are associated and stored on the host device through the preset driver. When the IoT device connects to the host device again, the preset driver program calls the corresponding target access point physical address and target access point channel number based on the obtained network name and network password.
[0011] Furthermore, the enumeration of the USB interface as a storage device category includes: The device class identifier in the device descriptor of the USB interface is configured as a first preset device identifier, so that the host device recognizes the USB interface as a storage device; wherein, the first preset device identifier includes an MSC identifier; Accordingly, enumerating the USB interface as a communication device category includes: Configure the device class identifier in the device descriptor of the USB interface as a second preset device identifier, so that the host device recognizes the USB interface as a communication device category; wherein, the second preset device identifier includes a CDC identifier or an RNDIS identifier.
[0012] Secondly, embodiments of this application provide a wireless network connection device for an Internet of Things (IoT) device. The IoT device includes a USB interface and a main control module, the USB interface being connected to a host device. The device is configured on the main control module and includes: A preset program installation unit is used to enumerate the USB interface as a storage device category and send a preset driver to the host device through the USB interface to install the preset driver on the host device; The network information acquisition unit is used to enumerate the USB interface as a communication device category when the preset driver is detected to be installed, so as to trigger the host device to execute the installed preset driver and feed back the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address and access point channel number; The target access determination unit is used to receive the current network connection information returned by the host device through the USB interface, and determine the physical address of the target access point and the channel number of the target access point based on the current network connection information. The network connection unit is used to establish a network connection based on the network name, the network password, the physical address of the target access point, and the channel number of the target access point.
[0013] Furthermore, the current network connection information also includes signal strength and signal-to-noise ratio; Accordingly, the target access determination unit is specifically used for: If the signal strength exceeds a first threshold and the signal-to-noise ratio exceeds a second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point. If the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name, and the physical address and channel number of the target access point are determined based on the other access points.
[0014] Furthermore, the target access determination unit is specifically used for: Obtain the signal strength, signal-to-noise ratio, physical address, and channel number of the other access points; Based on the signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points; The channel difference coefficient of the other access points is determined based on the access point channel number of the other access points and the access point channel number in the current network connection information; The comprehensive index of the other access points is determined based on the link quality index and the channel difference coefficient, and the physical address and channel number of the other access point with the highest comprehensive index are determined as the physical address and channel number of the target access point.
[0015] Furthermore, the target access determination unit is specifically used for: Calculate the difference between the signal strength of the other access points and the signal strength in the current network connection information; Based on the difference, attenuation compensation is performed on the signal strength of the other access points to obtain the compensated signal strength of the other access points; Based on the compensated signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points.
[0016] Furthermore, the target access determination unit is specifically used for: Obtain the number of access points corresponding to the access point channel numbers of the other access points, and determine the channel congestion parameters of the other access points based on the number of access points; The channel offset parameter of the other access points is determined based on the difference between the access point channel number of the other access points and the access point channel number in the current network connection information. The channel difference coefficients of the other access points are determined based on the channel congestion parameter and the channel offset parameter.
[0017] Furthermore, the device is also used for: The target access point physical address and target access point channel number are sent to the host device via the USB interface, so that the network name, the network password, the target access point physical address and the target access point channel number are associated and stored on the host device through the preset driver. When the IoT device connects to the host device again, the preset driver program calls the corresponding target access point physical address and target access point channel number based on the obtained network name and network password.
[0018] Furthermore, the preset program installation unit is specifically used for: The device class identifier in the device descriptor of the USB interface is configured as a first preset device identifier, so that the host device recognizes the USB interface as a storage device; wherein, the first preset device identifier includes an MSC identifier; Accordingly, the target access determination unit is specifically used for: Configure the device class identifier in the device descriptor of the USB interface as a second preset device identifier, so that the host device recognizes the USB interface as a communication device category; wherein, the second preset device identifier includes a CDC identifier or an RNDIS identifier.
[0019] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the method described in the first aspect.
[0020] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the method described in the first aspect.
[0021] In this embodiment, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device via the USB interface to install the preset driver on the host device. Upon detection that the preset driver installation is complete, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information. This current network connection information includes the network name, network password, access point physical address, and access point channel number. The current network connection information returned by the host device is received via the USB interface, and the target access point physical address and target access point channel number are determined based on this information. A network connection is established based on the network name, network password, target access point physical address, and target access point channel number. This wireless network connection method for IoT devices simplifies the network configuration process for IoT devices, improves configuration efficiency, and reduces the risk of data leakage during the configuration process. Attached Figure Description
[0022] Figure 1 This is a flowchart illustrating a wireless network connection method for an Internet of Things (IoT) device provided in an embodiment of this application. Figure 2 This is a flowchart illustrating another wireless network connection method for an IoT device provided in an embodiment of this application; Figure 3 This is a flowchart illustrating another wireless network connection method for an IoT device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a wireless network connection device for an Internet of Things (IoT) device provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0024] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0025] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0026] The wireless network connection method, apparatus, device, and medium for IoT devices provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0027] Among them, IoT devices can be smart terminal devices that support wireless network access.
[0028] Furthermore, in this solution, the IoT device may include a USB interface and a main control module. Specifically, the USB interface can be a universal serial bus physical interface that supports hot-swapping and plug-and-play, used in this solution for data transmission with the host device and receiving power from the host device; the main control module can be the core processing unit of the IoT device, possessing operation control capabilities and communication processing capabilities, such as the ESP32-S3 chip.
[0029] It is understood that this application is applicable to scenarios that require network configuration for IoT devices; correspondingly, the implementing entity of this application can be the main control module of the IoT device.
[0030] Figure 1 This is a flowchart illustrating a wireless network connection method for an IoT device provided in an embodiment of this application. Figure 1 As shown, the specific steps include the following: S101, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device through the USB interface to install the preset driver on the host device.
[0031] Among them, the storage device category can be a standard USB device category that can be natively recognized by mainstream operating systems such as Windows, Linux and macOS, without requiring the operating system to pre-install a dedicated driver.
[0032] In one embodiment, enumerating the USB interface as a storage device category includes: configuring the device class identifier in the device descriptor of the USB interface as a first preset device identifier, so that the host device recognizes the USB interface as a storage device category; wherein, the first preset device identifier includes an MSC identifier.
[0033] The device descriptor can be a data structure in a USB device used to describe the device's attributes to the host; the device class identifier can be the bDeviceClass field in the device descriptor, used to indicate the USB category to which the device belongs.
[0034] The first preset device identifier can be an identifier used to identify the USB interface as a storage device category, such as an MSC identifier.
[0035] The MSC identifier can be the device class code corresponding to the USB mass storage device category, i.e., 0x08.
[0036] In one embodiment, configuring the device class identifier in the device descriptor of the USB interface as the first preset device identifier can be achieved by setting the bDeviceClass field in the device descriptor array of the USB interface to 0x08 through the TinyUSB protocol stack, that is, enumerating the USB interface as an MSC category.
[0037] The advantage of this setup is that it allows the host device to be automatically recognized as a storage device without the need for pre-installed drivers, thus enabling the transfer and installation of the preset drivers to the host device via a simulated USB flash drive.
[0038] The default driver can be a dedicated driver used to enable bidirectional communication between the host device and IoT devices, capture network connection information, and transmit encrypted data.
[0039] In one embodiment, the method of sending a preset driver to the host device via a USB interface to install the preset driver on the host device can be achieved by the host device automatically mounting the virtual storage partition of the IoT device after successfully connecting to the USB interface of the IoT device, which is enumerated as a storage device, reading the preset driver installation package encapsulated in the virtual storage partition, copying the preset driver installation package to the local system directory, and calling the system installation service to complete the automatic installation of the preset driver.
[0040] S102, upon detecting that the preset driver has been installed, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address, and access point channel number.
[0041] In one embodiment, the method for detecting that the preset driver has been installed can be to periodically send a driver status query command to the host device via the USB interface to obtain the driver installation log and device adaptation status of the host device in real time. When three status signals are detected, namely, successful driver registration, complete device port adaptation, and normal service startup, it is determined that the preset driver has been installed.
[0042] Among them, the communication equipment category can be a peripheral category specifically used for data interaction, command transmission, and information exchange between devices.
[0043] In one embodiment, enumerating the USB interface as a communication device category includes: configuring the device class identifier in the device descriptor of the USB interface as a second preset device identifier, so that the host device recognizes the USB interface as a communication device category; wherein the second preset device identifier includes a CDC identifier or an RNDIS identifier.
[0044] The second preset device identifier can be an identifier value used to identify the USB interface as a communication device category, such as a CDC identifier or an RNDIS identifier.
[0045] The CDC identifier can be the device class code corresponding to the USB communication device class, i.e., 0x02; the RNDIS identifier can be the device class code corresponding to the remote network driver interface specification, which is also usually 0x02, but needs to be distinguished in conjunction with the subclass and protocol fields.
[0046] In one embodiment, configuring the device class identifier in the device descriptor of the USB interface to a second preset device identifier can be achieved by setting the bDeviceClass field in the device descriptor array of the USB interface to 0x02 via the TinyUSB protocol stack, thereby enumerating the USB interface as a CDC category; setting the bDeviceClass field in the device descriptor array of the USB interface to 0x02 via the TinyUSB protocol stack, and configuring the subclass and protocol fields to the values corresponding to the RNDIS specification, thereby enumerating the USB interface as an RNDIS category.
[0047] The advantage of this setup is that it enables the host device to recognize IoT devices as standard network adapters or modems, thereby automatically loading the devices using the operating system's built-in CDC or RNDIS drivers without requiring additional driver installation.
[0048] The current network connection information can be detailed configuration parameters of the wireless network that the host device is currently connected to, which is used to guide IoT devices to connect to the same wireless network. The current network connection information can include network name, network password, access point physical address and access point channel number.
[0049] Specifically, the network name can be an identifier for the wireless network, used by the device to identify the network to connect to; the network password can be a credential used to verify the device's access to the wireless network; the access point physical address can be the unique MAC address of the wireless access point; and the access point channel number can be the frequency channel number used for wireless communication.
[0050] In one embodiment, the method of triggering the host device to execute the installed preset driver and provide feedback on the current network connection information can be achieved by having the installed preset driver on the host device automatically run and call the corresponding operating system interface (such as the WlanGetProfile function or the WlanGetNetworkBssList function) to obtain the current network connection information after the host device successfully connects to the USB interface enumerated as a communication device category on the IoT device.
[0051] S103, receive the current network connection information returned by the host device through the USB interface, and determine the target access point physical address and target access point channel number based on the current network connection information.
[0052] In one embodiment, the method of receiving the current network connection information returned by the host device through the USB interface can be achieved by a preset driver that, after obtaining the current network connection information, packages the current network connection information into a JSON data packet and calls the WriteFile function to send the JSON data packet to the USB interface. The USB interface receives the JSON data packet and obtains the current network connection information from it.
[0053] The target access point physical address can be the physical address of the access point where the IoT device finally establishes a wireless network connection; the target access point channel number can be the access point channel number where the IoT device finally completes network access binding.
[0054] In one embodiment, the method of determining the physical address and channel number of the target access point based on the current network connection information can be to directly determine the physical address and channel number of the access point in the current network connection information as the physical address and channel number of the target access point.
[0055] S104, establish a network connection based on the network name, the network password, the target access point physical address, and the target access point channel number.
[0056] In one embodiment, the method of connecting to the network based on the network name, network password, target access point physical address, and target access point channel number can be achieved by configuring the network name, network password, target access point physical address, and target access point channel number into the Wi-Fi module of the IoT device, initiating an active connection request, and skipping the scanning phase if the target access point physical address and target access point channel number are valid, and directly connecting to the target access point.
[0057] In this embodiment, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device via the USB interface to install the preset driver on the host device. Upon detection that the preset driver installation is complete, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information. This current network connection information includes the network name, network password, access point physical address, and access point channel number. The current network connection information returned by the host device is received via the USB interface, and the target access point physical address and target access point channel number are determined based on this information. A network connection is established based on the network name, network password, target access point physical address, and target access point channel number. This wireless network connection for IoT devices simplifies the network configuration process, improves configuration efficiency, and reduces the risk of data leakage during the configuration process.
[0058] Figure 2 This is a flowchart illustrating another wireless network connection method for IoT devices provided in an embodiment of this application. Figure 2 As shown, the specific steps include the following: S201, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device through the USB interface to install the preset driver on the host device.
[0059] S202, upon detecting that the preset driver has been installed, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address, access point channel number, signal strength, and signal-to-noise ratio.
[0060] S203, receive the current network connection information returned by the host device through the USB interface.
[0061] S204, if the signal strength exceeds the first threshold and the signal-to-noise ratio exceeds the second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point.
[0062] Signal strength can be a physical quantity used to measure the power of a wireless signal received; signal-to-noise ratio can be the ratio of signal power to noise power.
[0063] The first threshold can be a lower limit for determining whether the signal strength meets the requirements for stable connection of IoT devices; the second threshold can be a lower limit for determining whether the signal-to-noise ratio meets the requirements for reliable data communication of IoT devices. Furthermore, the first and second thresholds can be adaptively adjusted or factory preset based on the sensitivity of the IoT device's Wi-Fi module, its operating frequency band, and the electromagnetic interference level of the deployment environment.
[0064] If the signal strength of the current network connection information exceeds the first threshold and the signal-to-noise ratio exceeds the second threshold, it indicates that the signal quality of the access point currently connected to the host device is reliable enough. Therefore, the physical address of the access point and the access point channel number in the current network connection information can be directly determined as the physical address of the target access point and the target access point channel number.
[0065] S205, if the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name, and the physical address and channel number of the target access point are determined based on the other access points.
[0066] Other access points can be wireless access points with the same network name as the host device, but with different physical addresses.
[0067] One method for obtaining other access points by scanning based on network names is to send a scan request through a Wi-Fi module, collect information on all access points, and then filter out a list of access points with the same network name.
[0068] In one embodiment, the method for determining the physical address and channel number of the target access point based on other access points can be as follows: obtain the signal strength and signal-to-noise ratio of other access points, normalize the signal strength and signal-to-noise ratio, and perform a weighted summation (the weighting coefficients can be 0.5 and 0.5, respectively). The physical address and channel number of the other access point with the highest weighted summation result are then determined as the physical address and channel number of the target access point.
[0069] In one embodiment, after determining the target access point physical address and target access point channel number based on the other access points, the method further includes: sending the target access point physical address and target access point channel number to the host device via the USB interface, so as to associate and store the network name, the network password, the target access point physical address, and the target access point channel number on the host device through the preset driver; when the IoT device connects to the host device next time, the preset driver calls the corresponding target access point physical address and target access point channel number according to the obtained network name and network password.
[0070] In one embodiment, the method of sending the target access point physical address and the target access point channel number to the host device via the USB interface can be achieved by sending a JSON data packet containing the target access point physical address and the target access point channel number to the host device through the TinyUSB protocol stack, and the preset driver on the host device receives the JSON data packet through the ReadFile function.
[0071] In one embodiment, by using a preset driver to associate and store the network name, network password, target access point physical address, and target access point channel number on the host device, the preset driver can save the network name, network password, target access point physical address, and target access point channel number in the form of an associated data table to the persistent storage of the host device.
[0072] In one embodiment, when the IoT device connects to the host device again, a preset driver, based on the obtained network name and password, calls the corresponding target access point physical address and target access point channel number. Alternatively, when the IoT device connects to the host device again, the preset driver only obtains the network name and password currently connected to the host device and queries a locally stored association data table for the target access point physical address and target access point channel number corresponding to the network name. Understandably, the preset driver returns the network name, network password, target access point physical address, and target access point channel number to the IoT device. The IoT device does not need to identify whether the wireless access point corresponding to the target access point physical address and target access point channel number is valid; it directly uses the received network name, network password, target access point physical address, and target access point channel number to initiate a network connection.
[0073] The advantage of this setup is that IoT devices do not need to re-evaluate the access point quality during subsequent network configuration; they can directly reuse historical best information to achieve rapid connection.
[0074] S206, establish a network connection based on the network name, the network password, the target access point physical address, and the target access point channel number.
[0075] The advantage of this configuration is that when the signal quality of the current access point of the host device is good, the connection can be quickly completed by directly using the current access point, skipping the scanning phase. When the signal quality of the current access point of the host device is poor, it will automatically switch to other access points with the best signal quality under the same network name, thereby ensuring the wireless connection stability and communication quality of IoT devices.
[0076] Figure 3 This is a flowchart illustrating another wireless network connection method for an IoT device provided in an embodiment of this application. Figure 3 As shown, the specific steps include the following: S301, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device through the USB interface to install the preset driver on the host device.
[0077] S302, upon detecting that the preset driver has been installed, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address, access point channel number, signal strength, and signal-to-noise ratio.
[0078] S303, receive the current network connection information returned by the host device through the USB interface.
[0079] S304, if the signal strength exceeds the first threshold and the signal-to-noise ratio exceeds the second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point.
[0080] S305, if the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name.
[0081] S306, obtain the signal strength, signal-to-noise ratio, physical address of the access point, and channel number of the other access points.
[0082] In one embodiment, the access point information collected by sending a scan request through the Wi-Fi module includes the signal strength, signal-to-noise ratio, physical address, and channel number of other access points, which can be read directly.
[0083] S307, Based on the signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points.
[0084] Among them, the link quality index can be a quantitative value that comprehensively reflects the reliability of wireless link communication.
[0085] In one embodiment, the link quality index of other access points can be determined based on their signal strength and signal-to-noise ratio. This can be achieved by linearly normalizing the signal strength and signal-to-noise ratio of other access points to the [0,1] interval, and then performing a weighted summation of the two normalization results (the weighting coefficients can be 0.5 and 0.5, respectively) to obtain the link quality index of the other access point.
[0086] In one embodiment, determining the link quality index of the other access point based on its signal strength and signal-to-noise ratio includes: calculating the difference between the signal strength of the other access point and the signal strength in the current network connection information; performing attenuation compensation on the signal strength of the other access point based on the difference to obtain the compensated signal strength of the other access point; and determining the link quality index of the other access point based on its compensated signal strength and signal-to-noise ratio.
[0087] The compensation signal strength can be the value after attenuating and correcting the signal strength of other access points based on the difference between the signal strength of the current access point of the host device and the signal strength of other access points, in order to eliminate the signal strength deviation caused by different measurement locations or times.
[0088] In one embodiment, the method of attenuating and compensating the signal strength of other access points based on the difference to obtain the compensated signal strength of other access points can be to add the signal strength of other access points to the difference between the corresponding signal strength and the signal strength in the current network connection information, and then obtain the compensated signal strength of the other access points.
[0089] In one embodiment, the link quality index of other access points can be determined based on the compensated signal strength and signal-to-noise ratio of other access points by linearly normalizing the compensated signal strength and signal-to-noise ratio of other access points to the [0,1] interval, and then performing a weighted summation of the two normalization results (the weighting coefficients can be 0.5 and 0.5 respectively) to obtain the link quality index of the other access point.
[0090] The advantage of this solution is that it eliminates the absolute numerical deviation of signal strength caused by differences in the location of IoT devices and host devices, differences in antenna gain, or differences in measurement time, making the signal strength of different wireless access points comparable under the same benchmark, thereby improving the accuracy of link quality assessment.
[0091] S308, determine the channel difference coefficient of the other access points based on the access point channel number of the other access points and the access point channel number in the current network connection information.
[0092] Among them, the channel difference coefficient can be a value that comprehensively measures the suitability of the working channels of other access points as the target working channel.
[0093] In one embodiment, the channel difference coefficient of other access points can be determined based on the access point channel number of other access points and the access point channel number in the current network connection information by calculating the difference between the access point channel number of other access points and the access point channel number in the current network connection information as the channel difference coefficient of the other access point.
[0094] In one embodiment, determining the channel difference coefficient of the other access points based on the access point channel number of the other access points and the access point channel number in the current network connection information includes: obtaining the number of access points corresponding to the access point channel number of the other access points, and determining the channel congestion parameter of the other access points based on the number of access points; determining the channel offset parameter of the other access points based on the difference between the access point channel number of the other access points and the access point channel number in the current network connection information; and determining the channel difference coefficient of the other access points based on the channel congestion parameter and the channel offset parameter.
[0095] The number of access points corresponding to the access point channel number can be the total number of all wireless access points scanned on the access point channel number.
[0096] In one embodiment, the method for obtaining the number of access points corresponding to the access point channel number of other access points can be to traverse the access point information after scanning, group and count them by channel number, and obtain the number of access points existing for each access point channel number.
[0097] The channel congestion parameter can be a numerical value used to quantify the level of interference on a single working channel.
[0098] In one embodiment, the channel congestion parameter of other access points can be determined based on the number of access points by dividing the number of access points corresponding to the channel number of each access point by the maximum value among the number of access points corresponding to the channel number of each access point, thereby obtaining the channel congestion parameter of other access points corresponding to the channel number of that access point.
[0099] The channel offset parameter can be a value used to quantify the degree of difference between the working channel of other access points and the working channel of the current access point of the host device.
[0100] In one embodiment, the channel offset parameter of another access point can be determined by the difference between the access point channel number of another access point and the access point channel number in the current network connection information. This can be achieved by summing 1 and the difference between the access point channel number of another access point and the access point channel number in the current network connection information, and then dividing 1 by the summation result to obtain the channel offset parameter of that other access point.
[0101] In one embodiment, the channel difference coefficient of other access points can be determined based on the channel congestion parameter and the channel offset parameter by subtracting the channel congestion parameter of the other access point from 1 and subtracting the channel offset parameter of the other access point from 1, and then performing a weighted summation of the two subtraction results (the weighting coefficients can be 0.4 and 0.6, respectively) to obtain the channel difference coefficient.
[0102] The advantage of this scheme is that it comprehensively considers the congestion level of the working channel and the working channel interval with the current access point, so that the channel difference coefficient can more comprehensively reflect the advantages and disadvantages of the channel in the current environment, avoiding the selection of a channel that is actually very congested even though it has a large channel interval with the current access point, thereby improving the anti-interference capability after network connection.
[0103] S309, determine the comprehensive index of the other access points based on the link quality index and the channel difference coefficient, and determine the physical address and channel number of the other access point with the highest comprehensive index as the physical address and channel number of the target access point.
[0104] Among them, the comprehensive index can be a quantitative value used to evaluate the overall performance of a wireless access point.
[0105] In one embodiment, the method for determining the comprehensive index of other access points based on link quality indicators and channel difference coefficients can be to calculate the comprehensive index of other access points by weighting and summing the link quality indicators and channel difference coefficients of other access points (the corresponding weighting coefficients can be 0.7 and 0.3, respectively).
[0106] Among them, the other access point has the highest comprehensive index, which means that the other access point has achieved the optimal balance between signal quality and channel interference avoidance. Therefore, the physical address and channel number of the other access point can be determined as the physical address and channel number of the target access point.
[0107] S310, establish a network connection based on the network name, the network password, the target access point physical address, and the target access point channel number.
[0108] The advantage of this approach is that it not only considers the signal strength and signal-to-noise ratio of the wireless access point, but also introduces channel differences to avoid co-channel interference caused by channel overlap. This allows for the selection of the target access point with the best overall performance, thereby improving the communication stability of IoT devices after connection.
[0109] Figure 4 This is a schematic diagram of the structure of a wireless network connection device for an Internet of Things (IoT) device provided in an embodiment of this application. Figure 4 As shown, the device includes: The preset program installation unit 410 is used to enumerate the USB interface as a storage device category and send the preset driver to the host device through the USB interface to install the preset driver on the host device; The network information acquisition unit 420 is used to enumerate the USB interface as a communication device category when the preset driver is detected to be installed, so as to trigger the host device to execute the installed preset driver and feed back the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address and access point channel number; The target access determination unit 430 is used to receive the current network connection information returned by the host device through the USB interface, and determine the physical address of the target access point and the channel number of the target access point based on the current network connection information. The network connection unit 440 is used to establish a network connection based on the network name, the network password, the target access point physical address, and the target access point channel number.
[0110] Furthermore, the current network connection information also includes signal strength and signal-to-noise ratio; Accordingly, the target access determination unit is specifically used for: If the signal strength exceeds a first threshold and the signal-to-noise ratio exceeds a second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point. If the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name, and the physical address and channel number of the target access point are determined based on the other access points.
[0111] Furthermore, the target access determination unit is specifically used for: Obtain the signal strength, signal-to-noise ratio, physical address, and channel number of the other access points; Based on the signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points; The channel difference coefficient of the other access points is determined based on the access point channel number of the other access points and the access point channel number in the current network connection information; The comprehensive index of the other access points is determined based on the link quality index and the channel difference coefficient, and the physical address and channel number of the other access point with the highest comprehensive index are determined as the physical address and channel number of the target access point.
[0112] Furthermore, the target access determination unit is specifically used for: Calculate the difference between the signal strength of the other access points and the signal strength in the current network connection information; Based on the difference, attenuation compensation is performed on the signal strength of the other access points to obtain the compensated signal strength of the other access points; Based on the compensated signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points.
[0113] Furthermore, the target access determination unit is specifically used for: Obtain the number of access points corresponding to the access point channel numbers of the other access points, and determine the channel congestion parameters of the other access points based on the number of access points; The channel offset parameter of the other access points is determined based on the difference between the access point channel number of the other access points and the access point channel number in the current network connection information. The channel difference coefficients of the other access points are determined based on the channel congestion parameter and the channel offset parameter.
[0114] Furthermore, the device is also used for: The target access point physical address and target access point channel number are sent to the host device via the USB interface, so that the network name, the network password, the target access point physical address and the target access point channel number are associated and stored on the host device through the preset driver. When the IoT device connects to the host device again, the preset driver program calls the corresponding target access point physical address and target access point channel number based on the obtained network name and network password.
[0115] Furthermore, the preset program installation unit is specifically used for: The device class identifier in the device descriptor of the USB interface is configured as a first preset device identifier, so that the host device recognizes the USB interface as a storage device; wherein, the first preset device identifier includes an MSC identifier; Accordingly, the target access determination unit is specifically used for: Configure the device class identifier in the device descriptor of the USB interface as a second preset device identifier, so that the host device recognizes the USB interface as a communication device category; wherein, the second preset device identifier includes a CDC identifier or an RNDIS identifier.
[0116] In this embodiment, the USB interface is enumerated as a storage device category, and a preset driver is sent to the host device via the USB interface to install the preset driver on the host device. Upon detection that the preset driver installation is complete, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information. This current network connection information includes the network name, network password, access point physical address, and access point channel number. The current network connection information returned by the host device is received via the USB interface, and the target access point physical address and target access point channel number are determined based on this information. A network connection is established based on the network name, network password, target access point physical address, and target access point channel number. This wireless network connection device for IoT devices simplifies the network configuration process for IoT devices, improves configuration efficiency, and reduces the risk of data leakage during the configuration process.
[0117] The wireless network connection device for IoT devices in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0118] The wireless network connection device for the IoT device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0119] The wireless network connection device for IoT devices provided in this application can realize the various processes implemented in the above embodiments. To avoid repetition, it will not be described again here.
[0120] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. For example... Figure 5 As shown, this application embodiment also provides an electronic device 500, including a processor 501, a memory 502, and a program or instructions stored in the memory 502 and executable on the processor 501. When the program or instructions are executed by the processor 501, they implement the various processes of the above-described wireless network connection embodiment of the Internet of Things device and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0121] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0122] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described wireless network connection embodiments of the Internet of Things device and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0123] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0124] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0125] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0126] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0127] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.
Claims
1. A wireless network connection method for an Internet of Things (IoT) device, characterized in that, The IoT device includes a USB interface and a main control module, and the USB interface is connected to the host device. The method is executed by the main control module, and the method includes: The USB interface is enumerated as a storage device category, and a preset driver is sent to the host device through the USB interface to install the preset driver on the host device; Upon detecting that the preset driver has been installed, the USB interface is enumerated as a communication device category to trigger the host device to execute the installed preset driver and provide feedback on the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address, and access point channel number; The system receives the current network connection information returned by the host device through the USB interface, and determines the physical address of the target access point and the channel number of the target access point based on the current network connection information. A network connection is established based on the network name, the network password, the target access point physical address, and the target access point channel number.
2. The wireless network connection method for IoT devices according to claim 1, characterized in that, The current network connection information also includes signal strength and signal-to-noise ratio; Accordingly, determining the physical address of the target access point and the channel number of the target access point based on the current network connection information includes: If the signal strength exceeds a first threshold and the signal-to-noise ratio exceeds a second threshold, the physical address of the access point and the channel number of the access point in the current network connection information are determined as the physical address of the target access point and the channel number of the target access point. If the signal strength does not exceed the first threshold or the signal-to-noise ratio does not exceed the second threshold, other access points are obtained by scanning according to the network name, and the physical address and channel number of the target access point are determined based on the other access points.
3. The wireless network connection method for IoT devices according to claim 2, characterized in that, The step of determining the physical address and channel number of the target access point based on the other access points includes: Obtain the signal strength, signal-to-noise ratio, physical address, and channel number of the other access points; Based on the signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points; The channel difference coefficient of the other access points is determined based on the access point channel number of the other access points and the access point channel number in the current network connection information; The comprehensive index of the other access points is determined based on the link quality index and the channel difference coefficient, and the physical address and channel number of the other access point with the highest comprehensive index are determined as the physical address and channel number of the target access point.
4. The wireless network connection method for IoT devices according to claim 3, characterized in that, The step of determining the link quality indicators of the other access points based on their signal strength and signal-to-noise ratio includes: Calculate the difference between the signal strength of the other access points and the signal strength in the current network connection information; Based on the difference, attenuation compensation is performed on the signal strength of the other access points to obtain the compensated signal strength of the other access points; Based on the compensated signal strength and signal-to-noise ratio of the other access points, determine the link quality indicators of the other access points.
5. The wireless network connection method for IoT devices according to claim 3, characterized in that, The step of determining the channel difference coefficient of the other access points based on the access point channel number of the other access points and the access point channel number in the current network connection information includes: Obtain the number of access points corresponding to the access point channel numbers of the other access points, and determine the channel congestion parameters of the other access points based on the number of access points; The channel offset parameter of the other access points is determined based on the difference between the access point channel number of the other access points and the access point channel number in the current network connection information. The channel difference coefficients of the other access points are determined based on the channel congestion parameter and the channel offset parameter.
6. The wireless network connection method for IoT devices according to claim 2, characterized in that, After determining the physical address and channel number of the target access point based on the other access points, the method further includes: The target access point physical address and target access point channel number are sent to the host device via the USB interface, so that the network name, the network password, the target access point physical address and the target access point channel number are associated and stored on the host device through the preset driver. When the IoT device connects to the host device again, the preset driver program calls the corresponding target access point physical address and target access point channel number based on the obtained network name and network password.
7. The wireless network connection method for IoT devices according to claim 1, characterized in that, The enumeration of the USB interface as a storage device category includes: The device class identifier in the device descriptor of the USB interface is configured as a first preset device identifier, so that the host device recognizes the USB interface as a storage device; wherein, the first preset device identifier includes an MSC identifier; Accordingly, enumerating the USB interface as a communication device category includes: Configure the device class identifier in the device descriptor of the USB interface as a second preset device identifier, so that the host device recognizes the USB interface as a communication device category; wherein, the second preset device identifier includes a CDC identifier or an RNDIS identifier.
8. A wireless network connection device for an Internet of Things (IoT) device, characterized in that, The IoT device includes a USB interface and a main control module, the USB interface being connected to a host device; the device is configured within the main control module, and the device includes: A preset program installation unit is used to enumerate the USB interface as a storage device category and send a preset driver to the host device through the USB interface to install the preset driver on the host device; The network information acquisition unit is used to enumerate the USB interface as a communication device category when the preset driver is detected to be installed, so as to trigger the host device to execute the installed preset driver and feed back the current network connection information; wherein, the current network connection information includes network name, network password, access point physical address and access point channel number; The target access determination unit is used to receive the current network connection information returned by the host device through the USB interface, and determine the physical address of the target access point and the channel number of the target access point based on the current network connection information. The network connection unit is used to establish a network connection based on the network name, the network password, the physical address of the target access point, and the channel number of the target access point.
9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the wireless network connection method of the Internet of Things device as described in any one of claims 1-7.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the wireless network connection method for an Internet of Things device as described in any one of claims 1-7.