CN111865790B - Method and device for collecting router information, internet of things equipment and Internet of things system - Google Patents
Method and device for collecting router information, internet of things equipment and Internet of things system Download PDFInfo
- Publication number
- CN111865790B CN111865790B CN202010664577.8A CN202010664577A CN111865790B CN 111865790 B CN111865790 B CN 111865790B CN 202010664577 A CN202010664577 A CN 202010664577A CN 111865790 B CN111865790 B CN 111865790B
- Authority
- CN
- China
- Prior art keywords
- router
- internet
- router information
- information
- request message
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/26—Route discovery packet
-
- G—PHYSICS
- G16—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
- G16Y—INFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
- G16Y30/00—IoT infrastructure
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The application relates to the technical field of Internet of things and discloses a method for collecting router information. The method for collecting the router information is applied to the Internet of things equipment, and comprises the following steps: after WiFi connection with a router is established, a request message with a set format is sent to the router, a response message which is sent by the router and corresponds to the request message is received, the response message is analyzed, and router information is obtained, wherein the request message with the set format corresponds to the router information. The method for acquiring the router information can automatically acquire the router information, and improves the convenience of acquiring the router information. The application also discloses a device for acquiring the router information, an internet of things device and an internet of things system.
Description
Technical Field
The application relates to the technical field of internet of things, for example, to a method and device for collecting router information, an internet of things device and an internet of things system.
Background
At present, with the development of the internet of things and intelligent hardware technology, a large number of internet of things devices enter the lives of people. The usage scenario of the internet of things equipment is that the equipment is accessed to a wireless router network in a user home through a self-contained WiFi module, and a network terminal (a mobile phone and the like) is controlled by means of wireless communication. The aspects of the scene system mainly comprise a WiFi module, a router, a cloud end and a user terminal (such as a mobile phone).
The WiFi module is divided into an embedded WiFi module and a standard WiFi module, wherein the embedded WiFi module realizes the drive control of WiFi radio frequency by a single chip microcomputer, and is characterized in that the software and hardware integration level is high, the whole embedded WiFi module integrates a radio frequency transceiver, a Media Access control address (MAC address), a WiFi drive and a WiFi protocol (different applications and different integrated WiFi protocols), a wireless security protocol, a one-key connection and the like, and is suitable for intelligent hardware singles and used for low-cost Internet of things connection; the standard WiFi module is a WiFi module used for a notebook computer and a tablet computer.
In the use scene of thing allies oneself with equipment, router and thing allies oneself with equipment often all are provided with the wiFi module, and both communicate through the wiFi module. The WiFi module of the router and the WiFi module of the internet of things device both belong to the embedded WiFi module, but there is a difference in implementation manners of partial details of WiFi protocol stacks of the router and the WiFi module of the internet of things device, which causes unstable connection between the internet of things device and the router, for example, the internet of things device is disconnected, and control fails. And the implementation manners of parts of details of the WiFi protocol stacks of the routers of different manufacturers are different, so that the WiFi protocol stacks of the routers are obtained and analyzed in the process of connecting the Internet of things equipment and the routers, and the WiFi protocol stacks of the Internet of things equipment are adjusted according to the WiFi protocol stacks of the routers, so that the connection stability of the Internet of things equipment and the routers can be improved. In practical applications, it is often necessary for relevant personnel (users or technicians) to read router information (for example, a specific model of a router) on the router and query a WiFi protocol stack of the router according to the router information.
In the process of implementing the embodiments of the present disclosure, it is found that at least the following problems exist in the related art:
the way of manually obtaining the router information is not convenient enough.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview nor is intended to identify key/critical elements or to delineate the scope of such embodiments but rather as a prelude to the more detailed description that is presented later.
The embodiment of the disclosure provides a method and a device for acquiring router information, an internet of things device and an internet of things system, so as to solve the technical problem that the router information is not convenient and fast to obtain.
In some embodiments, the method for collecting router information is applied to an internet of things device, and the method for collecting router information comprises the following steps:
after WiFi connection is established with a router, a request message with a set format is sent to the router;
receiving a response message which is sent by the router and corresponds to the request message;
analyzing the response message to obtain router information;
and the request message with the set format corresponds to the router information.
Optionally, sending a request packet with a set format to the router includes:
and sending the browser type, the recognizable content type, the host name and the preset request character string which are adjusted according to the set format to the router.
Optionally, sending a request packet with a set format to the router includes:
in the process of sending the request message with the set format to a router, obtaining a return value of a sending interface, and under the condition that the return value of the sending interface indicates that the sending is failed, sending the request message with the set format to the router again;
and after the request message with the set format is sent to the router, obtaining a return value of a receiving interface, and under the condition that the return value of the receiving interface indicates that the receiving fails, sending the request message with the specific format to the router again.
Optionally, analyzing the response packet to obtain the router information includes:
inquiring a first character string and a second character string in the response message;
and reading a character string between the first character string and the second character string to obtain the router information.
Optionally, before sending the request packet with the set format to the router, the method for acquiring the router information further includes:
judging whether the router information is collected or not;
and under the condition that the router information is not collected, establishing socket connection with the router.
Optionally, the determining whether the router information has been collected includes:
obtaining an IP address of the router through a Transmission Control Protocol/Internet Protocol (TCP/IP);
resolving the IP Address according to an Address Resolution Protocol (ARP) to obtain a Basic Service Set Identity (BSSID) of the router;
searching the BSSID of the router in a stored BSSID list;
determining that the router information is not collected in a case that the BSSID of the router is not found.
Optionally, after analyzing the response packet to obtain the router information, the method for acquiring the router information further includes:
and sending the router information to a server.
In some embodiments, the apparatus for collecting router is applied to an internet of things device, and the apparatus for collecting router information includes:
the first sending module is configured to send a request message with a set format to a router after WiFi connection is established with the router;
a receiving module configured to receive a response message corresponding to the request message sent by the router;
the analysis module is configured to analyze the response message to obtain router information;
and the request message with the set format corresponds to the router information.
In some embodiments, the internet of things device includes a processor and a memory storing program instructions, the processor being configured to execute the method for collecting router information provided by the foregoing embodiments when executing the program instructions.
In some embodiments, the internet of things system includes the internet of things device provided in the foregoing embodiments.
The method, the device, the Internet of things equipment and the Internet of things system for acquiring the router information provided by the embodiment of the disclosure can realize the following technical effects:
the Internet of things equipment sends a request message with a set format to the router, the request message corresponds to the router information, the router returns a response message including the router information after receiving the request message, the Internet of things equipment can analyze the request message according to the response message to obtain the router information, the whole process of obtaining the router information is automatically completed, related personnel (users or technical personnel) are not needed to participate, and the convenience of obtaining the router information is improved.
The foregoing general description and the following description are exemplary and explanatory only and are not restrictive of the application.
Drawings
One or more embodiments are illustrated in drawings corresponding to, and not limiting to, embodiments in which elements having the same reference number designation are illustrated as similar elements and in which:
fig. 1 is an environment schematic diagram of an implementation environment of a method for collecting router information according to an embodiment of the present disclosure;
fig. 2 is a schematic diagram of a method for collecting router information according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram for parsing a response packet according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram of a method for collecting router information according to an embodiment of the present disclosure;
fig. 5 is a schematic diagram for determining whether router information has been collected according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram of a method for collecting router information according to an embodiment of the present disclosure;
fig. 7 is a schematic diagram of a method for collecting router information according to an embodiment of the present disclosure;
fig. 8 is a schematic diagram of communication in an internet of things system according to an embodiment of the present disclosure;
fig. 9 is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 9a is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 9b is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 9c is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 9d is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 9e is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure;
fig. 10 is a schematic diagram of an apparatus for collecting router information according to an embodiment of the present disclosure.
Detailed Description
So that the manner in which the features and elements of the disclosed embodiments can be understood in detail, a more particular description of the disclosed embodiments, briefly summarized above, may be had by reference to the embodiments, some of which are illustrated in the appended drawings. In the following description of the technology, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the disclosed embodiments. However, one or more embodiments may be practiced without these details. In other instances, well-known structures and devices may be shown in simplified form in order to simplify the drawing.
The terms "first," "second," and the like in the description and in the claims, and the above-described drawings of embodiments of the present disclosure, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the present disclosure described herein may be made. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion.
The term "plurality" means two or more unless otherwise specified.
In the embodiment of the present disclosure, the character "/" indicates that the preceding and following objects are in an or relationship. For example, A/B represents: a or B.
Referring to fig. 1, an environment diagram of an implementation environment of a method for collecting router information is provided in an embodiment of the present disclosure. The implementation environment schematic diagram includes an internet of things device 110, a router 120, and a server 130.
The internet of things device 110 is an electronic device with WiFi communication functionality. The internet of things device 110 includes household appliances with WiFi communication function, such as an intelligent audio device, an intelligent air conditioner, an intelligent security system, and the like.
The router 120 is an electronic device providing a wireless Access Point (AP), and includes a device having only a wireless AP function and a device integrating a wireless AP function, such as a television having a WiFi function. A TCP/IP based communication connection may be established between router 120 and internet of things device 110.
The server 130 may be a machine, a server cluster composed of several servers, or a cloud computing service center.
The internet of things device 110, the router 120 and the server 130 establish communication connection, the internet of things device 110 reads router information from the router 120 and then sends the router information to the server 130, the server 130 queries a specific WiFi protocol stack of the router 120 according to the router information, and then adjusts the internet of things device 110 according to the WiFi protocol stack, so that the connection between the internet of things device 110 and the router 120 is more stable.
Referring to fig. 2, an embodiment of the present disclosure provides a method for collecting router information. In this embodiment, the method for acquiring router information is applied to the internet of things device shown in fig. 1 for example. The method for collecting the router information comprises the following steps:
s201, after WiFi connection is established with the router, a request message with a set format is sent to the router.
The request message with the set format corresponds to the router information. The request message is used for requesting a response message containing router information from the router.
And after receiving the request message with the set format, the router sends a response message to the Internet of things equipment. The response message corresponds to the request message, and the response message comprises router information.
The router broadcasts a Service Set Identifier (SSID) of WiFi, the Internet of things equipment receives the SSID and initiates a connection request to the router based on the SSID, the router responds to the connection request, the Internet of things equipment sends identity authentication information to the router, the router authenticates the identity authentication information, and after the authentication is passed, the Internet of things equipment and the router establish WiFi connection.
Optionally, sending a request packet with a set format to the router includes: in the process of sending the request message with the set format to the router, obtaining a return value of a sending interface, and under the condition that the return value of the sending interface indicates that the sending is failed, sending the request message with the set format to the router again; after sending the request message with the set format to the router, obtaining the return value of the receiving interface, and under the condition that the return value of the receiving interface indicates that the receiving fails, sending the request message with the specific format to the router again.
The transmission failure is indicated when the return value of the transmission interface satisfies a specific condition, and the transmission success is indicated when the return value of the transmission interface satisfies another specific condition. For example, when the return value of the transmission interface is less than zero, it indicates that the transmission has failed, and when the return value of the transmission interface is greater than or equal to zero, it indicates that the transmission has succeeded.
The transmission failure is indicated in the case where the return value of the reception interface satisfies a specific condition, and the transmission success is indicated in the case where the return value of the reception interface satisfies another specific condition. For example, in the case where the return value of the receiving interface is less than zero, it indicates that the reception has failed, and in the case where the return value of the receiving interface is greater than or equal to zero, it indicates that the reception has succeeded.
The method for sending the request message with the set format to the router again by the internet of things device comprises the following steps: and after the time is set, sending a request message to the router. Alternatively, the set time is 0.5min to 3min, for example, the set time is 0.5min, 1min, 1.5min, 2min or 3min.
The internet of things equipment continuously sends the request message to the router until after the request message is sent for a certain time, the return value received by the sending interface indicates that the sending is successful, the return value received by the receiving interface indicates that the receiving is successful, and the internet of things equipment prepares to receive the response message returned by the router.
By the mode, the router can be ensured to successfully receive the request message with the set format sent by the Internet of things equipment.
Optionally, after establishing a WiFi connection with the router, before sending the request packet with the set format to the router, the method for acquiring router information further includes: a socket connection is established with the router. In this case, the internet of things device serves as a socket client, the router serves as a socket server, the sending interface is a socket send interface, and the receiving interface is a socket recv interface. Correspondingly, a request message with a set format is sent to the router through the socket send interface.
In the process of sending the request message with the set format to the router through the socket send interface, monitoring the return value of the socket send interface in real time, and sending the request message with the set format to the router through the socket send interface again under the condition that the return value of the socket send interface is less than zero; monitoring the return value of the socket recv interface under the condition that the return value of the socket send interface is greater than or equal to zero, and sending a request message with a set format to the router again through the socket send interface under the condition that the return value of the socket recv interface is less than zero; and under the condition that the return value of the socket recv interface is greater than or equal to zero, preparing to receive response information returned by the router through the socket recv interface.
S202, receiving a response message which is sent by the router and corresponds to the request message.
And under the condition that the gateway equipment establishes socket connection with the router, sending a response message through a socket recv port interface router.
S203, analyzing the response message to obtain the router information.
The router information includes one or more of a specific model of the router, a factory serial number of the router, a current software version, and a current hardware version.
The internet of things equipment sends a request message with a set format to the router, the request message corresponds to the router information, the router returns a response message containing the router information after receiving the request message, the internet of things equipment can analyze and obtain the router information according to the response message, the whole process of obtaining the router information is automatically completed, related personnel (users or technical personnel) are not required to participate, and the convenience of obtaining the router information is improved.
Optionally, sending a request packet with a set format to the router includes: and sending the browser type, the recognizable content type, the host name and the preset request character string which are arranged according to the set format to the router.
The set format conforms to the application layer protocol of the network communication model between the internet of things equipment and the router. For example, application layer protocols include: hypertext Transfer Protocol over secure Layer (https) or hypertext Transfer Protocol (http). Similarly, the preset request character string also conforms to the application layer protocol of the network communication model between the internet of things device and the router.
Therefore, after the TCP connection is established between the Internet of things equipment and the router, data can be transmitted between the Internet of things equipment and the router according to the set format.
In some specific applications, the application layer protocol is http, and the request message with the set format sent to the router by the internet of things device is an http request message.
The browser type refers to a browser type generating a request, namely, a browser type built in the internet of things device.
The identifiable content type refers to a content type identifiable by the internet of things device.
The hostname refers to a hostname and port number, a virtual hostname and port number, a domain name and port number, or an IP address and port number of the router.
In some specific applications, the request message is: GET/HTTP/1.1\ r \ nUser-Agent, browser type \ r \ nACCept, recognizable content type \ r \ nHost, host name \ r \ nConnection, close \ r \ n \ r \ n. Wherein, GET/HTTP/1.1, and \ r \ nConnection, close \ r \ n \ r \ n are preset request character strings. For example, the specific content of the request message is "GET/HTTP/1.1\ r \ nUser-Agent: HAIER \ r \ nACCept:/r \ nHost: none \ r \ nConnection: close \ r \ n'.
Optionally, before the router sends the request packet with the set format, the method for acquiring router information further includes: and generating a request message with a set format. For example, the browser type, the identifiable content type, the host name and the preset request character string are obtained, and the browser type, the identifiable content type, the host name and the preset request character string are arranged according to the set format to obtain the request message conforming to the set format.
Referring to fig. 3, analyzing the response packet to obtain the router information includes:
s301, inquiring the first character string and the second character string in the response message.
The first character string and the second character string are two corresponding character strings, and the second character string usually appear in pairs. One of the first character string and the second character string is a start identifier, and the other is an end identifier.
The first character string and the second character string are used for marking the character string between the first character string and the second character string, and generally have the function of explanation.
In some practical applications, the first string is < title >, and the second string is </title >, and the first string is a start identifier and the second string is an end identifier. The first character string and the second character string explain the role of the character strings between the two: titles that can be displayed.
After receiving the response message sent by the router, the internet of things device stores the response message, for example, stores the response message in a Random Access Memory (RAM), and marks the storage content as buf _ http.
S302, reading a character string between the first character string and the second character string to obtain the router information.
And searching the whole response message by the Internet of things equipment, and reading other character strings behind the first character string after the first character string (the starting identifier) is found until the second character string (the ending identifier) is read. And other character strings after the first character string read by the Internet of things equipment are the router information.
Or under the condition that the first character string is < title >, the second character string is </title >, and the response message is stored and marked as buff _ http by the internet-of-things device, the first character string < title > is searched in the buff _ http, after the first character string < title > is searched, the position of the first character string < title > in the buff _ http is recorded and marked as title _ start, the second character string </title > is searched in the buff _ http, after the second character string </title > is searched, the position of the second character string </title > in the buff _ http is recorded and marked as title _ end, the character string between the position title _ start and the position title _ end is read in the buff _ http, and the character string is router information.
Through the steps, the Internet of things equipment can obtain the router information.
As shown in fig. 4, before sending the request message with the set format to the router, the method for acquiring the router information further includes:
s401, judging whether the router information is collected.
And the Internet of things equipment directly inquires whether the router information of the currently connected router is collected. For example, a collection status bit is set, and after the router information of the currently connected router is collected, the collection status bit is set to be "1", which indicates that the router information of the currently connected router has been read. After the communication connection based on TCP/IP is established between the Internet of things equipment and the router, reading the acquisition state bit, and acquiring the router information if the acquisition state bit is '1'; if the collection status bit is "0", no router information is collected.
Or reading the identifier of the currently connected router, and inquiring the identifier in the identifier list to obtain an inquiry result. If the identifier is found in the identifier list, the router information is collected; if the identifier is not found in the identifier list, no router information is collected. The identifier list stores identifiers of routers which have collected router information, and the identifiers of the routers comprise BSSIDs or MAC addresses.
S402, under the condition that the router information is not collected, socket connection is established with the router.
And the Internet of things equipment establishes socket connection with the router according to the IP address of the router. After the connection between the internet of things equipment and the router is established, the internet of things equipment is a client side, and the router is a server side.
Under the condition that the router information is collected, the internet of things equipment does not establish socket connection with the router any more, and continues to communicate with the router based on the established communication connection.
Through the steps, repeated collection of the router information can be avoided.
Referring to fig. 5, determining whether router information has been collected includes:
s501, the IP address of the router is obtained through TCP/IP.
After the Internet of things equipment and the router establish communication connection based on TCP/IP, the Internet of things equipment and the router communicate through messages conforming to TCP/IP formats. The IP datagram is directly read to obtain the IP address of the router.
S502, resolving the IP address according to the ARP to obtain the BSSID of the router.
The internet of things equipment establishes an ARP list in an APR buffer area, and the APR list stores the corresponding relation between the IP address and the BSSID of the router. And inquiring the IP address of the router in the ARP list to obtain the BSSID of the router.
Under the condition that the BSSID of the router is not stored in the APR list of the Internet of things device, the Internet of things device broadcasts a request to request the BSSID corresponding to the IP address of the router, and after receiving the request, the router sends the local IP address and the BSSID to the Internet of things device. And the Internet of things equipment receives the router IP address and the BSSID of the router sent by the router, and stores the IP address and the BSSID of the router in an APR list in a one-to-one correspondence mode. Through the mode, the internet of things equipment can analyze the BSSID of the router according to the IP address of the router.
S503, find the BSSID of the router in the stored BSSID list.
S504, under the condition that the BSSID of the router is not found, the router information which is not collected is determined;
and determining the collected router information under the condition that the BSSID of the router is found successfully.
Through the steps, whether the router information is acquired by the router connection equipment can be judged.
Under the condition that the router information is collected, the internet of things equipment does not establish socket connection with the router any more, does not repeatedly read the router information any more, and continues to communicate with the router based on the established communication connection.
And under the condition that the router information is not acquired, the Internet of things equipment and the router establish socket connection to acquire the router information.
Optionally, after analyzing the response packet to obtain the router information, the method for acquiring the router information further includes: and sending the router information to the server. The server can be used for searching the router information, then the server finds the WiFi protocol stack and the implementation mode of the router according to the router information, and configures the Internet of things equipment, so that the Internet of things equipment and the router can establish more stable communication connection.
It can be seen that after judging whether the router information is acquired and obtaining the judgment result, under the condition that the judgment result is the acquired router information, it indicates that the equipment of the internet of things has established connection with the router, the server has obtained the WiFi protocol stack of the router and the implementation manner thereof, and the server has configured the WiFi module of the equipment of the internet of things, and at this time, the equipment of the internet of things and the router can establish more stable communication connection; and under the condition that the judgment result is that the router information is not acquired, the connection between the equipment of the internet of things and the router is established for the first time, the server does not acquire a WiFi protocol stack of the router and an implementation mode thereof, and the server does not configure the equipment of the internet of things, so that whether the communication connection established between the equipment of the internet of things and the router is stable or not cannot be determined.
Optionally, the sending, by the internet of things device, the router information to the server includes: in the process of sending the router information to the server, obtaining a return value of a sending interface, and under the condition that the return value of the sending interface indicates that the sending is failed, sending the router information to the server again; after the router information is sent to the server, the return value of the receiving interface is obtained, and when the return value of the receiving interface is a reception failure, the router information is sent to the server again.
The transmission failure is indicated when the return value of the transmission interface satisfies a specific condition, the transmission success is indicated when the return value of the transmission interface satisfies another specific condition, for example, the transmission failure is indicated when the return value of the transmission interface is less than zero, and the transmission success is indicated when the return value of the transmission interface is greater than or equal to zero.
The reception failure is indicated in the case where the return value of the reception interface satisfies a specific condition, and the reception success is indicated in the case where the return value of the reception interface satisfies another specific condition. For example, in the case where the return value of the receiving interface is less than zero, it indicates that the reception has failed; in case the return value of the receiving interface is greater than or equal to zero, a successful reception is indicated.
The method for retransmitting the router information to the server by the internet of things device comprises the following steps: and after the time is set, the Internet of things equipment sends router information to the server. Alternatively, the set time is 0.5min to 3min, for example, the set time is 0.5min, 1min, 1.5min, 2min or 3min.
The internet of things equipment continuously sends the router information to the server until the return value of the sending interface is larger than or equal to zero after the router information is sent for a certain time, and the return value of the receiving interface is larger than or equal to zero to indicate that the server successfully receives the router information, and the internet of things equipment stops sending the router information to the server.
Optionally, after the internet of things device obtains the router information, before the internet of things device sends the router information to the server, the internet of things device establishes socket connection with the server. The internet of things equipment is a client, the server is a server, the socket send interface is the sending interface, and the socket recv interface is the receiving interface.
In the process of sending router information to a server through a socket send interface, monitoring a return value of the socket send interface in real time, and sending the router information to the server through the socket send interface by the Internet of things equipment under the condition that the return value of the socket send interface is less than zero; monitoring the return value of the socket recv interface under the condition that the return value of the socket send interface is greater than or equal to zero, and sending router information to the server through the socket send interface again under the condition that the return value of the socket recv interface is less than zero; and under the condition that the return value of the socket recv interface is greater than or equal to zero, stopping sending the router information to the server through the socket send interface.
As shown in fig. 6, an embodiment of the present disclosure provides a method for collecting router information. This embodiment exemplifies that the method for acquiring router information is applied to the internet of things device shown in fig. 1. The method for collecting the router information comprises the following steps:
s601, after socket connection with the router is established, the IP address and BSSID of the router are obtained;
s602, determining whether the stored BSSID list includes the BSSID of the router: if yes, successfully acquiring the router information is confirmed, and the process is ended; otherwise, executing S603;
searching the BSSID of the router in the stored BSSID list, and if the BSSID of the router is successfully searched, successfully acquiring router information; otherwise, the router information is not collected.
S603, establishing socket connection with the router;
s604, sending a request message with a set format to the router;
s605, judging whether the request message is successfully sent to the router and the router successfully receives the request message with the set format: if yes, go to S606; otherwise, executing S604;
for example, a return value of the sending interface is obtained, and the sending fails when the return value of the sending interface is less than zero; and under the condition that the return value of the sending interface is greater than or equal to zero, the Internet of things equipment successfully sends a request message with a set format to the router. Obtaining a return value of a receiving interface, and when the return value of the receiving interface is less than zero, the router fails to receive; and when the return value of the receiving interface is greater than or equal to zero, the router successfully receives the request message with the set format.
S606, receiving a response message corresponding to the request message sent by the router;
s607, analyzing the response message to obtain the router information;
s608, establishing socket connection with a server;
s609, sending router information to a server;
s610, judging whether the router information is successfully sent to the server and successfully received by the server: if yes, go to S611; otherwise, executing S609;
for example, a return value of the sending interface is obtained, and the sending fails when the return value of the sending interface is less than zero; and when the return value of the sending interface is greater than or equal to zero, the Internet of things equipment successfully sends the router information to the server. Obtaining a return value of a receiving interface, and failing to receive by the server under the condition that the return value of the receiving interface is less than zero; and under the condition that the return value of the receiving interface is greater than or equal to zero, the server successfully receives the router information sent by the Internet of things equipment.
And S611, storing the BSSID of the router.
And S612, confirming that the router information is successfully acquired.
As shown in fig. 7, an embodiment of the present disclosure provides a method for collecting router information. In this embodiment, the method for acquiring router information is described in terms of data interaction between the internet of things device and the router. The method for collecting the router information comprises the following steps:
s701, after WiFi connection is established between the Internet of things equipment and a router, the Internet of things equipment sends a request message with a set format to the router;
the request message with the set format corresponds to the router information.
S702, the router sends a response message to the Internet of things equipment;
the response message corresponds to the request message, and the response message comprises router information;
and S703, the Internet of things equipment analyzes the response message to obtain the router information.
As shown in fig. 8, an embodiment of the present disclosure provides an internet of things system. The Internet of things system comprises a server, a router and the Internet of things equipment provided in other embodiments, wherein the server is in communication connection with the Internet of things equipment through the router. In this thing networking system:
s801, after WiFi connection is established between the Internet of things equipment and the router, the Internet of things equipment sends a request message with a set format to the router;
the request message with the set format corresponds to the router information.
S802, the router sends a response message to the Internet of things equipment;
the response message corresponds to the request message, and the response message comprises router information;
s803, the Internet of things equipment analyzes the response message to obtain router information;
s804, the Internet of things equipment sends the router information to a server;
in the step, the server collects router information through the Internet of things equipment;
and S805, the server inquires a WiFi protocol stack of the router and an implementation mode thereof according to the router information.
In some embodiments, the internet of things system further comprises a control terminal, and the control terminal is in communication connection with the router or the server. The control terminal receives the state information of the Internet of things equipment through the router or the server, and the Internet of things equipment receives the control instruction sent by the control terminal.
As shown in fig. 9, an embodiment of the present disclosure provides an apparatus for collecting router information. The apparatus for collecting router information may be implemented as an internet of things device in fig. 1 by software, hardware or a combination of both. The apparatus for collecting router information includes a first sending module 910, a receiving module 920, and a parsing module 930. The first sending module 910 is configured to send a request message with a set format to the router after establishing a communication connection with the router; the receiving module 920 is configured to receive a response message corresponding to the request message sent by the router; the parsing module 930 is configured to parse the reply message to obtain router information; the request message with the set format corresponds to the router information.
Optionally, the first sending module 910 is specifically configured to send the browser type, the identifiable content type, the host name and the preset request string, which are adjusted according to the set format, to the router.
As shown in fig. 9a, the first sending module 910 includes a first determining unit 911 and a second determining unit 912. The first determining unit 911 is configured to obtain a return value of the sending interface in the process of sending the request message with the set format to the router, and resend the request message with the set format to the router if the return value of the sending interface indicates that the sending fails; the second determining unit 912 is configured to obtain a return value of the receiving interface after sending the request message with the set format to the router, and resend the request message with the specific format to the router if the return value of the receiving interface indicates that the receiving fails.
As shown in fig. 9b, the parsing module 930 includes a first lookup unit 931 and a reading unit 932, where the first lookup unit 931 is configured to query the response message for the first character string and the second character string; the reading unit 932 is configured to read a character string between the first character string and the second character string, and obtain the router information.
As shown in fig. 9c, the apparatus for collecting router information further includes: a judging module 940 and a connecting module 950, wherein the judging module 940 is configured to judge whether the router information is collected before sending the request message with the set format to the router; the connection module 950 is configured to establish a socket connection with a router without collecting router information.
As shown in fig. 9d, the determining module 940 includes an obtaining unit 941, a parsing unit 942, a second lookup unit 943, and a third determining unit 944, where the obtaining unit 941 is configured to obtain an IP address of a router through TCP/IP; the parsing unit 942 is configured to parse the IP address according to the ARP, obtaining the BSSID of the router; a second lookup unit 943 is configured to lookup BSSID of the router in the stored BSSID list; the third determining unit 944 is configured to determine that no router information is collected in the case where the BSSID of the router is not found.
As shown in fig. 9e, the apparatus for acquiring router information further includes a second sending module 950, where the second sending module 950 is configured to send the router information to the server after analyzing the response message to obtain the router information.
As shown in fig. 10, an embodiment of the present disclosure provides an internet of things device. This thing allies oneself with equipment includes:
a processor (processor) 101 and a memory (memory) 102, and may also include a Communication Interface 103 and a bus 104. The processor 101, the communication interface 103, and the memory 102 may communicate with each other via the bus 104. The communication interface 103 may be used for information transfer. The processor 101 may invoke logic instructions in the memory 102 to perform the methods for collecting router information provided by the foregoing embodiments.
Furthermore, the logic instructions in the memory 102 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products.
The memory 102 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, such as program instructions/modules corresponding to the methods in the embodiments of the present disclosure. The processor 101 executes the functional application and data processing by executing the software program, instructions and modules stored in the memory 102, that is, implements the method in the above-described method embodiments.
The memory 102 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 102 may include high speed random access memory and may also include non-volatile memory.
The embodiment of the present disclosure provides a computer-readable storage medium, which stores computer-executable instructions configured to execute the method for acquiring router information provided in the foregoing embodiment.
The disclosed embodiments provide a computer program product comprising a computer program stored on a computer-readable storage medium, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the method for collecting router information provided by the foregoing embodiments.
The computer readable storage medium described above may be a transitory computer readable storage medium or a non-transitory computer readable storage medium.
The technical solution of the embodiments of the present disclosure may be embodied in the form of a software product, where the computer software product is stored in a storage medium and includes one or more instructions to enable a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method in the embodiments of the present disclosure. And the aforementioned storage medium may be a non-transitory storage medium comprising: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a RAM, a magnetic disk, or an optical disk, may also be transient storage media.
The above description and drawings sufficiently illustrate embodiments of the disclosure to enable those skilled in the art to practice them. Other embodiments may incorporate structural, logical, electrical, process, and other changes. The examples merely typify possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in or substituted for those of others. Furthermore, the words used in the specification are words of description only and are not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this application is meant to encompass any and all possible combinations of one or more of the associated listed. Furthermore, the terms "comprises" and/or "comprising," when used in this application, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of additional like elements in a process, method, or apparatus that comprises the element. In this document, each embodiment may be described with emphasis on differences from other embodiments, and the same and similar parts between the respective embodiments may be referred to each other. For methods, products, etc. of the embodiment disclosure, reference may be made to the description of the method section for relevance if it corresponds to the method section of the embodiment disclosure.
Those of skill in the art would appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software may depend upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments. It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the apparatus and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, apparatuses, etc.) may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit may be merely a division of a logical function, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form. Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to implement the present embodiment. In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. Each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Claims (10)
1. A method for collecting router information is applied to an Internet of things device, and is characterized in that the Internet of things device is provided with an embedded WiFi module, and the method comprises the following steps:
after WiFi connection is established with a router, a request message with a set format is sent to the router;
receiving a response message which is sent by the router and corresponds to the request message;
analyzing the response message to obtain router information;
the request message with the set format corresponds to the router information and is used for requesting a response message containing the router information from the router; the router information is used for querying a WiFi protocol stack of the router.
2. The method of claim 1, wherein sending the formatted request message to the router comprises:
sending the browser type, the identifiable content type, the host name and the preset request character string which are adjusted according to the set format to the router;
the browser type refers to a browser type built in the internet of things device; the identifiable content type refers to an identifiable content type of the internet of things device; the host name refers to a host name and a port number of the router, a virtual host name and a port number, a domain name and a port number, or an IP address and a port number; the preset request character string conforms to an application layer protocol of a network communication model between the internet of things equipment and the router.
3. The method of claim 1, wherein sending the request message in a set format to the router comprises
In the process of sending the request message with the set format to a router, obtaining a return value of a sending interface, and under the condition that the return value of the sending interface indicates that the sending is failed, sending the request message with the set format to the router again;
and after the request message with the set format is sent to the router, obtaining a return value of a receiving interface, and under the condition that the return value of the receiving interface indicates that the receiving fails, sending the request message with the set format to the router again.
4. The method of claim 1, wherein parsing the reply packet to obtain the router information comprises:
inquiring a first character string and a second character string in the response message;
and reading a character string between the first character string and the second character string to obtain the router information.
5. The method according to any one of claims 1 to 4, further comprising, before sending the request message of the set format to the router:
judging whether the router information is acquired or not;
and under the condition that the router information is not collected, establishing socket connection with the router.
6. The method of claim 5, wherein determining whether the router information has been collected comprises:
obtaining an IP address of the router through TCP/IP;
analyzing the IP address according to the ARP to obtain BSSID of the router;
searching BSSID of the router in a stored BSSID list;
determining that the router information is not collected in a case that the BSSID of the router is not found.
7. The method according to any one of claims 1 to 4, further comprising, after parsing the reply packet to obtain router information:
and sending the router information to a server.
8. The utility model provides a device for gathering router, is applied to thing allies oneself with equipment, a serial communication port, thing allies oneself with equipment and is provided with embedded wiFi module, the device includes:
the first sending module is configured to send a request message with a set format to a router after WiFi connection with the router is established;
a receiving module configured to receive a response message corresponding to the request message sent by the router;
the analysis module is configured to analyze the response message to obtain router information;
the request message with the set format corresponds to the router information and is used for requesting a response message containing the router information from the router; the router information is used for querying a WiFi protocol stack of the router.
9. An internet of things device comprising a processor and a memory storing program instructions, wherein the internet of things device is provided with an embedded WiFi module, and wherein the processor is configured to execute the method for collecting router information according to any one of claims 1 to 7 when executing the program instructions.
10. An internet of things system, characterized by comprising the internet of things device of claim 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010664577.8A CN111865790B (en) | 2020-07-10 | 2020-07-10 | Method and device for collecting router information, internet of things equipment and Internet of things system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010664577.8A CN111865790B (en) | 2020-07-10 | 2020-07-10 | Method and device for collecting router information, internet of things equipment and Internet of things system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111865790A CN111865790A (en) | 2020-10-30 |
CN111865790B true CN111865790B (en) | 2022-10-14 |
Family
ID=72984079
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010664577.8A Active CN111865790B (en) | 2020-07-10 | 2020-07-10 | Method and device for collecting router information, internet of things equipment and Internet of things system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111865790B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114024823A (en) * | 2022-01-05 | 2022-02-08 | 广州朗国电子科技股份有限公司 | Method and system for realizing convenient management of router |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7590144B1 (en) * | 2003-05-13 | 2009-09-15 | Advanced Digital Broadcast Holdings S.A. | Network router apparatus and method |
CN101984706A (en) * | 2010-11-04 | 2011-03-09 | 中国电信股份有限公司 | Gateway of Internet of things and automatic adaptation method of communication protocol |
CN104660498A (en) * | 2015-03-17 | 2015-05-27 | 联想(北京)有限公司 | Gateway equipment and information processing method |
CN109068346A (en) * | 2018-08-27 | 2018-12-21 | 出门问问信息科技有限公司 | A kind of method and device configuring WiFi parameter |
CN109818983A (en) * | 2019-03-29 | 2019-05-28 | 重庆邮电大学 | A kind of ZigBee and WiFi group-net communication recognize anti-interference method |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
IL131831A (en) * | 1997-03-12 | 2002-12-01 | Nomadix Inc | Nomadic translator or router |
CN105991380A (en) * | 2015-03-05 | 2016-10-05 | 美的集团股份有限公司 | Household appliance network access method, router, and household appliance |
CN106603508A (en) * | 2016-11-30 | 2017-04-26 | 青岛海尔科技有限公司 | Wireless encryption communication method, intelligent household electrical appliance, server, and terminal |
CN110798493B (en) * | 2018-08-02 | 2022-12-13 | 青岛经济技术开发区海尔热水器有限公司 | Network configuration method, device, terminal equipment and storage medium |
CN111225429B (en) * | 2018-11-26 | 2022-05-27 | 阿里巴巴集团控股有限公司 | SSID (service set identifier) acquisition method, device, equipment and system of router |
CN110392445B (en) * | 2019-07-17 | 2022-10-28 | 青岛海尔科技有限公司 | Method, device and system for equipment distribution network |
CN110809308A (en) * | 2019-09-29 | 2020-02-18 | 上海商米科技集团股份有限公司 | Method and device for automatically connecting IOT device and WIFI router |
CN110635957B (en) * | 2019-10-28 | 2022-10-25 | 青岛海尔科技有限公司 | Method and device for network distribution of Internet of things equipment and mobile terminal |
-
2020
- 2020-07-10 CN CN202010664577.8A patent/CN111865790B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7590144B1 (en) * | 2003-05-13 | 2009-09-15 | Advanced Digital Broadcast Holdings S.A. | Network router apparatus and method |
CN101984706A (en) * | 2010-11-04 | 2011-03-09 | 中国电信股份有限公司 | Gateway of Internet of things and automatic adaptation method of communication protocol |
CN104660498A (en) * | 2015-03-17 | 2015-05-27 | 联想(北京)有限公司 | Gateway equipment and information processing method |
CN109068346A (en) * | 2018-08-27 | 2018-12-21 | 出门问问信息科技有限公司 | A kind of method and device configuring WiFi parameter |
CN109818983A (en) * | 2019-03-29 | 2019-05-28 | 重庆邮电大学 | A kind of ZigBee and WiFi group-net communication recognize anti-interference method |
Also Published As
Publication number | Publication date |
---|---|
CN111865790A (en) | 2020-10-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20130268632A1 (en) | Server assisted authenticated device | |
CN103647869B (en) | A kind of matching method of terminal, terminal and system | |
CN110839046B (en) | Multi-protocol intercommunication method and system | |
CN108200567B (en) | Device discovery method and device | |
CN113518407A (en) | WiFi network distribution method and system for intelligent equipment, electronic equipment and medium | |
CN103179184A (en) | Communication system, network storage, server device and communication method | |
CN107623752B (en) | Network management method and device based on link layer | |
US8369245B2 (en) | Communication apparatus having network interfaces and responding to device search, communication method, and storage medium | |
JP2000101640A (en) | Client/server system | |
CN111865790B (en) | Method and device for collecting router information, internet of things equipment and Internet of things system | |
CN106304277A (en) | A kind of method realizing network insertion and terminal | |
CN111884938B (en) | Router information acquisition method and device | |
CN112616171B (en) | Communication method and device based on wireless local area network and computer readable storage medium | |
WO2012041029A1 (en) | Method and device for server processing service | |
CN102111289A (en) | Method and device for deploying authentication | |
CN113992508A (en) | Local area network automatic networking method of intelligent equipment and intelligent equipment | |
CN111064729B (en) | Message processing method and device, storage medium and electronic device | |
CN113067710A (en) | Online user query method and device, computer equipment and storage medium | |
CN115086276B (en) | Address management method, device, equipment and system | |
CN114650197B (en) | Communication method, device, user plane network element and storage medium | |
CN115190042B (en) | Network target range target access state detection system and method | |
CN114629725B (en) | User domain dumb terminal management method, device, system and storage medium | |
CN109151086B (en) | Message forwarding method and network equipment | |
CN116719868A (en) | Network asset identification method, device and equipment | |
US20040230830A1 (en) | Receiver, connection controller, transmitter, method, and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |