Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a control method, an apparatus and a mobile terminal, so as to implement high robustness control on a behavior of controlling a connected wireless network by the mobile terminal.
In order to solve the above technical problem, an embodiment of the present invention provides the following solutions:
the embodiment of the invention provides a control method, which is used for a mobile terminal, wherein the mobile terminal carries out AT command interaction with a user terminal through an AT command transmission channel established between the mobile terminal and the user terminal, and the method comprises the following steps:
receiving a first AT command sent by a user terminal;
judging whether the first AT command indicates to connect a wireless network or not, and acquiring a first judgment result;
and when the first judgment result is yes, generating a first wireless network connection instruction.
Preferably, the wireless network is a WIFI network, and the generating the first wireless network connection instruction specifically includes:
analyzing a WIFI hotspot identification parameter from the first AT command;
generating the first wireless network connection instruction for indicating connection with a WIFI hotspot; wherein the WIFI hotspot corresponds to the WIFI hotspot identification parameter.
Preferably, before receiving the first AT command sent by the user terminal, the method further includes:
acquiring a scanning result of a current WIFI network;
and sending a second AT command carrying the scanning result to the user terminal, so that the user terminal can analyze the scanning result from the second AT command, and generate and send the first AT command to the mobile terminal according to the scanning result.
Preferably, the mobile terminal is provided with a first module for connecting to a wireless network having a first network type and a second module for connecting to a wireless network having a second network type, and the generating the first wireless network connection instruction specifically includes:
analyzing a network type parameter from the first AT command;
when the network type parameter is a first network type, generating a first wireless network connection instruction for controlling the first module to connect a wireless network with the first network type;
and when the network type parameter is a second network type, generating the first wireless network connection instruction for controlling the second module to connect the wireless network with the second network type.
Preferably, before receiving the first AT command sent by the user terminal, the method further includes:
under the control of a user terminal, controlling the first module to establish a first connection with a wireless network with a first network type;
when the first connection is established, a third AT command carrying the connected state of the wireless network is sent to the user terminal, so that the user terminal can generate and send a fourth AT command for indicating disconnection to the mobile terminal according to the third AT command;
receiving the fourth AT command;
controlling the first module to disconnect the first connection according to the fourth AT command;
and when the first connection is disconnected, sending a fifth AT command carrying a wireless network unconnected state to the user terminal, so that the user terminal can generate and send the first AT command to the mobile terminal according to the fifth AT command.
Preferably, the controlling, under the control of the user terminal, the first module to establish the first connection with the wireless network having the first network type specifically includes:
receiving a sixth AT command sent by the user terminal;
judging whether the sixth AT command indicates to connect a wireless network or not, and acquiring a second judgment result;
and when the second judgment result is yes, generating a second wireless network connection instruction.
Preferably, the first and second liquid crystal materials are,
the first network type is one of WIFI and cellular, and the second network type is one of WIFI and cellular except the first network type.
An embodiment of the present invention provides a control device, which is used for a mobile terminal, and the device includes:
a first receiving module, configured to receive a first AT command sent by a user terminal;
the judging module is used for judging whether the first AT command indicates to be connected with a wireless network or not and acquiring a first judging result;
and the generating module is used for generating a first wireless network connection instruction when the first judgment result is yes.
Preferably, the wireless network is a WIFI network, and the generating module specifically includes:
the first analysis unit is used for analyzing the WIFI hotspot identification parameters from the first AT command when the first judgment result is yes;
a first generating unit, configured to generate the first wireless network connection instruction for instructing to connect to a WIFI hotspot; wherein the WIFI hotspot corresponds to the WIFI hotspot identification parameter.
Preferably, the mobile terminal is provided with a first module for connecting to a wireless network having a first network type and a second module for connecting to a wireless network having a second network type, and the generating module specifically includes:
a second parsing unit, configured to parse the network type parameter from the first AT command if the first determination result is yes;
a second generating unit, configured to generate the first wireless network connection instruction for controlling the first module to connect to a wireless network with a first network type when the network type parameter is the first network type;
a third generating unit, configured to generate the first wireless network connection instruction for controlling the second module to connect to a wireless network with a second network type when the network type parameter is the second network type.
Preferably, the apparatus further comprises:
the first control module is used for controlling the first module to establish a first connection with a wireless network with a first network type under the control of the user terminal before the receiving module receives a first AT command sent by the user terminal;
a second sending module, configured to send, before the receiving module receives the first AT command sent by the user terminal, a third AT command carrying a connected state of the wireless network to the user terminal when the first connection is established, so that the user terminal can generate and send a fourth AT command indicating disconnection to the mobile terminal according to the third AT command;
a second receiving module, configured to receive the fourth AT command before the receiving module receives the first AT command sent by the user terminal;
a second control module, configured to control the first module to disconnect the first connection according to the fourth AT command before the receiving module receives the first AT command sent by the user terminal;
and the third sending module is used for sending a fifth AT command carrying a wireless network unconnected state to the user terminal before the receiving module receives the first AT command sent by the user terminal and when the first connection is disconnected, so that the user terminal can generate and send the first AT command to the mobile terminal according to the fifth AT command.
Preferably, the first control module specifically includes:
the control unit is used for receiving a sixth AT command sent by the user terminal before the receiving module receives the first AT command sent by the user terminal;
a determining unit, configured to determine, before the receiving module receives a first AT command sent by a user terminal, whether the sixth AT command indicates to connect to a wireless network, and obtain a second determination result;
a fourth generating unit, configured to generate a second wireless network connection instruction when the second determination result is yes before the receiving module receives the first AT command sent by the user terminal.
The embodiment of the invention provides a mobile terminal comprising the control device.
From the above, it can be seen that the embodiments of the present invention have at least the following beneficial effects:
the mobile terminal carries out AT command interaction with the user terminal through an AT command transmission channel established between the mobile terminal and the user terminal, and generates a first wireless network connection instruction when the first AT command indicates to connect a wireless network by receiving a first AT command sent by the user terminal, thereby realizing high robustness control on the behavior of controlling and connecting the wireless network by the mobile terminal.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a flowchart illustrating steps of a control method according to an embodiment of the present invention, and referring to fig. 1, the control method according to the embodiment of the present invention includes the following steps:
step 101, receiving a first AT command sent by a user terminal;
step 102, judging whether the first AT command indicates to connect a wireless network or not, and acquiring a first judgment result;
step 103, when the first judgment result is yes, generating a first wireless network connection instruction.
The method is used for a mobile terminal, and the mobile terminal carries out AT command interaction with the user terminal through an AT command transmission channel established between the mobile terminal and the user terminal.
Therefore, the mobile terminal carries out AT command interaction with the user terminal through an AT command transmission channel established between the mobile terminal and the user terminal, and generates a first wireless network connection instruction when the first AT command indicates to connect a wireless network by receiving the first AT command sent by the user terminal, so that high robustness control on the behavior of controlling and connecting the mobile terminal with the wireless network is realized.
In addition, the method can perform information interaction between the user terminal and the mobile terminal through the established AT command transmission channel without establishing a PPPOE transmission channel, thereby reducing the consumption of certain time resources caused by establishing the PPPOE transmission channel and the occupation of certain transmission resources and processing resources between the mobile terminal and the user terminal, and further realizing the efficient control of the behavior of controlling the connection of the mobile terminal with the wireless network to a certain extent.
Wherein the mobile terminal, for example: data card, cell-phone, panel computer etc..
The determining whether the first AT command indicates to connect to the wireless network, and obtaining a first determination result, for example:
resolving an indicator behind a character ' AT ' in the first AT command from the first AT command, wherein if the indicator is a plus ' representing a standard AT command, the first judgment result is no; if the character is a custom specific character (e.g., ""), the first judgment result is yes.
Another example is:
resolving an indicator behind a character 'AT' in the first AT command from the first AT command, resolving a command name behind a specific character from the first AT command if the indicator is a customized specific character, and if the indicator is a customized name (such as 'TCONN') representing wireless network connection, determining that the first judgment result is yes; otherwise, the first judgment result is negative.
Another example is:
resolving an indicator and a command name behind a character 'AT' in the first AT command from the first AT command, resolving a certain self-defined parameter from the first AT command if the indicator is a '+' representing a standard AT command and the command name is a preset certain standard AT command name, and if the parameter represents connection (for example, < mode >, 1 represents connection), the first judgment result is yes; otherwise, the first judgment result is negative.
The wireless network is for example: a WIFI network, a 2G/3G and other cellular networks, and the like.
A wireless chip, such as a WIFI chip or an EDGE/3G dual-mode chip, can be built in the mobile terminal; alternatively, an external wireless module, such as a WIFI module or an EDGE/3G dual-mode module, may be used. Accordingly, the first wireless network connection command should be a command that can be recognized by the wireless chip or the wireless module and the wireless chip or the wireless module can connect to the wireless network under the control of the first wireless network connection command.
Since those skilled in the art can design and generate the first wireless network connection command in various ways, it is not described herein again.
In step 102 and step 103 of the embodiment of the present invention, for the case that the wireless network is a WIFI network, if the first AT command indicates to connect to the wireless network, there may be various situations, for example:
in a first situation, the first AT command may not indicate which WIFI hotspot is connected, and accordingly, a first wireless network connection instruction generated by the mobile terminal may carry a preset WIFI hotspot connection condition, for example, the signal strength is greater than a certain threshold. Or,
in case two, the first AT command may carry a WIFI hotspot connection condition, for example, the signal strength is greater than a certain threshold, and accordingly, the first wireless network connection instruction generated by the mobile terminal may also carry the condition. Or,
in a third scenario, the first AT command may carry WIFI hotspot identification parameters (e.g., SSID and bsidd), so as to indicate which WIFI hotspot is connected, and accordingly, there may be:
the generating the first wireless network connection instruction specifically includes:
analyzing a WIFI hotspot identification parameter from the first AT command;
generating the first wireless network connection instruction for indicating connection with a WIFI hotspot; wherein the WIFI hotspot corresponds to the WIFI hotspot identification parameter.
Therefore, the control of the behavior of controlling and connecting the specific WIFI hotspot by the mobile terminal can be realized. Considering the situation that the mobile terminal controls the WIFI chip arranged on the mobile terminal to be connected with the WIFI network, the control capability of the user terminal on the behavior of connecting the mobile terminal with the WIFI network is enhanced.
Corresponding to the above situation, the first wireless network connection instruction should be an instruction that can be recognized by a wireless chip built in the mobile terminal or an external wireless module, and the wireless chip or the wireless module can perform a corresponding operation under the control of the first wireless network connection instruction (for example, connect to a WIFI hotspot meeting the condition information, and connect to a WIFI hotspot indicating connection). Since those skilled in the art can design and generate the first wireless network connection command in various ways, it is not described herein again.
Further, considering that the user terminal may need to know the scanning condition of the WIFI network before instructing to connect to the WIFI network, in view of this, before the receiving the first AT command sent by the user terminal, the method may further include:
acquiring a scanning result of a current WIFI network;
and sending a second AT command carrying the scanning result to the user terminal, so that the user terminal can analyze the scanning result from the second AT command, and generate and send the first AT command to the mobile terminal according to the scanning result.
The scanning result may be obtained by the mobile terminal actively, or obtained under the instruction of the user terminal. The scanning result may include a scanned WIFI hotspot identification list, and optionally, may also include information such as a signal strength of each WIFI hotspot in the list.
In addition, considering that the mobile terminal has the capability of being connected with two types of wireless networks, if one type is a cellular wireless network and the other type is a WIFI wireless network, a control mode of PPP dialing can be reserved for the cellular wireless network, and the control mode based on the AT command in the embodiment of the invention is adopted for the WIFI wireless network, however, from the perspective of user terminals such as a computer, the same thing is done by two different methods (namely, the mobile terminals such as a data card are used as wireless MODEMs to access the network), the complexity of the system is increased, certain transmission resources and processing resources are consumed, and the control efficiency is reduced to a certain extent. The AT command is simple in design and strong in expandability, so that the AT command can be further used for controlling the behavior of the mobile terminal for controlling the connection of different types of wireless networks. The control efficiency of the mode is higher, and the aim which cannot be realized only by using the PPP dialing mode is realized. In view of this, when a mobile terminal is capable of controlling connections to multiple types of wireless networks, it may still be controlled by means of AT commands, e.g., using different AT command names to represent indications of connections to different types of wireless networks; alternatively, different parameters are used to represent indications of connections to different types of wireless networks. Corresponding to the latter, specifically, there may be the following examples:
the mobile terminal is provided with a first module for connecting a wireless network with a first network type and a second module for connecting a wireless network with a second network type, and the generating of the first wireless network connection instruction specifically includes:
analyzing a network type parameter from the first AT command;
when the network type parameter is a first network type, generating a first wireless network connection instruction for controlling the first module to connect a wireless network with the first network type;
and when the network type parameter is a second network type, generating the first wireless network connection instruction for controlling the second module to connect the wireless network with the second network type.
In this example, the user terminal can simply and conveniently control the behavior of the mobile terminal controlling the connection with different types of wireless networks through an AT command.
Further, considering that the user terminal may not need the mobile terminal to connect to different types of wireless networks simultaneously, in view of this, there may be:
before the receiving the first AT command sent by the user terminal, the method further includes:
under the control of a user terminal, controlling the first module to establish a first connection with a wireless network with a first network type;
when the first connection is established, a third AT command carrying the connected state of the wireless network is sent to the user terminal, so that the user terminal can generate and send a fourth AT command for indicating disconnection to the mobile terminal according to the third AT command;
receiving the fourth AT command;
controlling the first module to disconnect the first connection according to the fourth AT command;
and when the first connection is disconnected, sending a fifth AT command carrying a wireless network unconnected state to the user terminal, so that the user terminal can generate and send the first AT command to the mobile terminal according to the fifth AT command.
Therefore, the user terminal can indicate to connect a specific type of wireless network when confirming that a certain connection is disconnected, so that simple control of the user terminal on the control behavior of the mobile terminal on connection and disconnection of the wireless network is realized, the control flow is simplified, and the method is convenient, reliable and efficient.
The controlling, under the control of the user terminal, the first module to establish the first connection with the wireless network having the first network type may specifically include:
receiving a sixth AT command sent by the user terminal;
judging whether the sixth AT command indicates to connect a wireless network or not, and acquiring a second judgment result;
and when the second judgment result is yes, generating a second wireless network connection instruction.
Therefore, the user terminal controls the behavior of the mobile terminal for controlling the connection with the specific type of wireless network through the second AT command, when the first connection is established, the fourth AT command indicates the mobile terminal to disconnect the first connection, and when the first connection is disconnected, the behavior of the mobile terminal for controlling the connection with the specific type of wireless network is controlled through the first AT command, so that the user terminal can conveniently control the behavior of the mobile terminal for controlling the connection with and disconnection of the specific type of wireless network under the condition that the two specific types are the same type; for the two specific types of the different types, the user terminal can conveniently control the mobile terminal, so that the mobile terminal can control the random switching between the wireless access corresponding to the first module and the wireless access corresponding to the second module at the gap.
In this embodiment of the present invention, the first network type may be one of WIFI and cellular, and the second network type may be one of WIFI and cellular except for the first network type.
In the embodiment of the present invention, particularly in the case where the mobile terminal is a data card and the wireless network is a WIFI network, there is another advantage, which is specifically described as follows:
with the development of the WIFI technology, the deployment of the AP hotspot gradually increases, and more terminal products start to support the WIFI function. Conventional data cards are also beginning to evolve toward class T + W data cards. T is TD-SCDMA, W is WLAN, means for traditional data card, through the operation of UI interface, not only can connect 2G/3G network, can also have WIFI environment place, switch to WIFI wantonly and carry out data service. Compared with a 2G/3G network, the WIFI network has the characteristics of high speed, no flow limitation and the like. The use scenes of the data card can be enriched.
However, the T + W type data card mentioned here still has a certain use limitation, and because the data card itself does not have a WIFI chip, a wireless network card on a connected user terminal (such as a computer), such as a built-in wireless network card of a notebook computer, needs to be borrowed when connecting a WIFI network, and if the user terminal does not have a wireless network card, the user terminal cannot be connected with the WIFI network, and can only be used as a traditional data card.
Aiming at the place inconvenient to use, a WIFI chip can be added on the data card, the WIFI chip arranged on the data card is controlled by the data card to be connected with the WIFI network, but at present, the user terminal cannot control the behavior of the data card in connection with the WIFI network.
Therefore, particularly in the case that the mobile terminal is a data card, another advantage of the embodiment of the present invention is to provide a control manner for controlling a behavior of the data card in connection with the WIFI network.
When the data card is inserted into the user terminal, an NDIS network card device may be enumerated, the device defaults to a non-connection state, and after the WIFI connection is successful, the device may be set to a connection state, so that the device becomes a channel for data transmission, and the data card allocates an IP to the user terminal through the DHCP server, so that the user terminal may perform a data service through the data card. Therefore, the problem that software on the user terminal side of the T + W type data card with the hardware WIFI chip is difficult to control is solved. Therefore, the user terminal can still access the WIFI network through the data card under the condition that the wireless network card is not available or the wireless network card is not enabled temporarily, and the application scene of the data card is expanded.
In order to further clarify the embodiments of the present invention, the following takes the case that the user terminal is a Personal Computer (PC), the mobile terminal is a data card, and the first module and the second module are embedded in the data card as an example, and provides a preferred implementation manner of the embodiments of the present invention.
The preferred embodiment provides a control method based on AT commands, which meets the operation requirements of connecting a data card with hardware WIFI.
In order to solve the above problem, the present invention provides a control method based on AT commands, the core of which includes a set of AT command sets. The PC side software can operate the data card through the related newly added AT command, the data card receives the AT command and then executes according to the parameters given by the command, the execution result is returned to the PC side software, meanwhile, if the data card has a state change after the AT command is executed, the corresponding AT command is actively reported to the PC side software, and the PC side software determines what AT command to send next step for control according to the reported result.
The newly added AT command comprises an AT command reported by the current connection state, an AT command scanned by the WIFI hotspot and an AT command connected with the network.
First, when a data card is inserted into a computer, three COM port devices and one NDIS network card device are enumerated. The COM port type device is a channel for AT command transmission. The NDIS network card equipment defaults to a non-connection state, and can be set to a connection state after wireless connection is successful, and the NDIS network card equipment is a channel for data transmission between the data card and the computer.
Reporting AT command for current connection status:
when the COM port equipment is available, the PC side software issues a state reporting enabling AT command to the data card, and the data card immediately starts to actively report the current state after receiving the command. The reported first bit indicates the network type, whether the network is a 2G/3G network or a WIFI network, and the second bit indicates the state of the current network type.
Firstly, if the data card is successfully initialized after being inserted into a computer, and a 2G/3G network or a WIFI network is prepared and has no abnormality, reporting that the initialization is successful. Otherwise, reporting initialization failure and being unable to connect network.
And secondly, the data card can automatically report the unconnected state of the network and indicate that the PC side software can start to connect the network.
That is, after receiving the state report enable AT command issued by the PC side software, the data card may report the initialization success and the network unconnected state for the 2G/3G network connection type in sequence under normal conditions, and may report the initialization success and the network unconnected state for the WIFI network connection type in sequence.
In addition, other state reporting functions of the data card include: when the connection is being carried out, the connection of the network is reported, after the connection is successful, the connection of the network is reported, when the connection is being broken, the disconnection is reported, when the connection is being carried out, the connection state is cancelled if the connection is cancelled again, when the connection is broken, the disconnection of the network is reported again, and at the moment, the connection can be started again.
When the data card enters the state of scanning the AP hotspot, the state of scanning the AP is reported, so as to inform the PC side software, and AT this time, the AT connection command or the AT disconnection command may not be responded, and the execution needs to be delayed. And after the scanning is finished, reporting the state before the scanning again.
AT command for WIFI hotspot scan:
and PC side software reports the successful initialization of the WIFI network on the data card and then performs the enabling setting through an AT command.
If the set AT command contains the time parameter and the parameter value is not zero, enabling a timer on the data card according to the parameter value, and automatically scanning the WIFI hotspot by the data card after the timer is overtime so as to actively report the AT command by TAINF.
And reporting the SSID and bSSID of the WIFI hotspot represented by the first two-bit parameter of the AT command, so as to distinguish the only WIFI hotspot, and reporting the current signal intensity of the WIFI hotspot represented by the third-bit parameter.
And if the time parameter contained in the AT command is zero during setting, immediately scanning the WIFI hotspot once, actively reporting the scanning result, and scanning and reporting the scanning result in the same reporting format AT the same time. The mode is used when PC side software needs to immediately acquire the current peripheral WIFI hotspot information.
And if the AT command further comprises SSID and bSSID parameters during setting, indicating the data card to immediately acquire the current signal strength of the appointed WIFI hotspot according to the values of the SSID and the bSSID and providing the current signal strength to the PC side software.
Regarding network connection class AT commands:
the network connection AT command comprises a network connection AT command, a network connection cancellation AT command and a network connection disconnection AT command.
And after the data card actively reports the network unconnected state, the PC side software can issue a network connection AT command.
The first bit parameter of the command is the connection network type, which indicates whether the current connection operation is to connect to a 2G/3G network or a WIFI network.
Because it is considered that there is a scenario of canceling the connection if the connection is in progress. The meaning of the second bit parameter indicates whether the current action is to connect or disconnect a network for distinction.
And when the connected network type is the WIFI network, the third and fourth parameters are valid and used for designating the only WIFI hotspot to be connected.
The network connection type AT command also comprises a parameter acquisition AT command and a parameter setting AT command during connection.
The parameter acquisition AT command is provided with SSID and bSSID parameters which mark unique WIFI hotspot key information, after the data card executes the command, the acquired hotspot information is returned to the PC side software, the information comprises an authentication mode, an encryption algorithm, a network type and signal strength, and the PC side software displays the information and can modify the information.
Before a WIFI hotspot AT connection command is issued, the AT command needs to be set through parameters, and an authentication mode, an encryption algorithm, an authentication mode and a secret key are set in a data card for use during connection.
The parameter setting AT command and the WIFI hotspot connection AT command correspond to each other through SSID and bSSID parameters carried by the two commands.
After the data card actively reports the connected state of the network, the PC side software can issue an AT disconnection command. The parameters of the command need only specify the type of network connection currently to be disconnected, or be set to any type.
Only one of the connections will be active at the same time, i.e. the connection state is maintained. After the 2G/3G network is successfully connected or the WIFI network is successfully connected, the NDIS network card is set to be in a connection state, and the IP is distributed through the DHCP server side, so that the computer can perform data service through the data card. When the data service is not performed any more, the disconnection operation can be performed, the NDIS network card is set to be in an unconnected state, the data card enters an idle state, and the use of other network connections on the computer is not influenced.
By adopting the better embodiment, the problem that the PC side software with the hardware WIFI chip T + W type data card is difficult to control is solved, a unified AT command set is used, the connection and the switching between the 2G/3G network and the WIFI network can be facilitated, and the method is simple and effective.
< preferred embodiment of the present preferred embodiment >
Fig. 2 is a block diagram of a hardware WIFI-based data card software structure according to a preferred embodiment of the present preferred embodiment, referring to fig. 2, wherein a WLAN protocol stack is used for controlling a WIFI chip to connect a WIFI hotspot under the coordination of an SDIO driver; the 2G/3G protocol stack supports a PDP activation function and is used for controlling the 2G/3G chip to be connected with a cellular network; the NDIS protocol stack can enumerate a network card device after the data card is inserted into the computer based on the USB drive, and is used as a bridge for data interaction between the computer and the data card. AT command set through carry out overall control to above three to reach the data card and both can use in 2G 3G network environment, can use under WIFI network environment again, and can be convenient switch the use, strengthened the suitability of the product of data card class.
Here, the module for connecting the wireless network having the cellular type includes a 2G/3G protocol stack and a 2G/3G chip, and the module for connecting the wireless network having the WIFI type includes a WLAN protocol stack, an SDIO driver, and a WIFI chip;
the wireless network connection instruction is generated by a data receiving and transmitting and control module under the control of an extended AT command module, the extended AT command module receives a new AT command from an AT engine and controls the data receiving and transmitting and control module based on an API (application programming interface), and the extended AT command module controls the data receiving and transmitting and control module to generate the wireless network connection instruction under the condition of receiving the new AT command indicating the connection of a wireless network.
The following describes in detail the application process of the newly added AT command in the preferred embodiment with reference to fig. 3 to 7:
fig. 3 is a flowchart of an AT initialization command, and referring to fig. 3, the power-on initialization process and the timed scan reporting process include the following steps:
after the boot AT port is available, the PC side software sends the following AT command to the data card:
AT^TMODE=<n>
value of < n >: 0 cancel ^ TMODE reporting 1 enable ^ TMODE reporting
In fig. 3, the value of < n > is 1, i.e. status reporting is enabled.
After the successful enabling (namely the data card sends the ^ TMODE: 1OK to the PC side software), the active reporting of the ^ TMODE state is started, and the significance is as follows:
^TMODE:<linkstatus>,<netstatus>
< linkstatus >: and (3) identifying the connection type: 1WIFI2
TD/EDGE
< netstatus >: network type identification:
0 initialization was successful
1 initialization failure, unable to connect
2 network unconnected
3 network is connecting
4 network connected
5 is canceling the connection
6 is being disconnected
11 is scanning for WIFI hotspots, when < linkstatus > =1
Effective
When the WIFI network is in the initialization success state ^ TMODE:1,0 and reports, the PC side software can send the following AT commands to the data card to control the reporting and the reporting frequency of ^ TAINF:
AT^TAINF=<n>,[<time>,<ssid>,<bssid>]
< n >: 0 cancel ^ TAINF reporting and 1 enable ^ TAINF reporting
< time >: the reporting time interval is 0-65535 in unit of second
If the value is 0, the report is immediately carried out once. Effective when < n > =1
< ssid >: WIFI network SSID
< bsid >: WIFI network bSSID
And after the command is successfully executed, reporting the WIFI hotspot information once immediately, and reporting the WIFI hotspot information as a response. And then actively reporting the WIFI hotspot information at regular time according to the set time interval.
The reporting format of the WIFI hotspot information is as follows:
^TAINF:<ssid>,<bssid>,<rssi>
< ssid >: WIFI network SSID
< bsid >: WIFI network bSSID
< rssi >: WIFI network Signal Strength, Unit dbm
When the timing time set by the data card is overtime, entering a WIFI hotspot scanning state, reporting ^ TMODE:1,11, referring to fig. 7, reporting currently available WIFI hotspot information according to the format after scanning is finished, reporting the state before entering the scanning state after scanning and reporting are finished, and reporting ^ TMODE:1,2 after finishing the state if the state before entering is a WIFI network unconnected state; if the WIFI network is in the connected state before entering, reporting the ^ TMODE:1,4 after the WIFI network is in the connected state.
The network connection process, the network connection canceling process and the network connection disconnecting process comprise the following steps:
fig. 4 is a flow chart of AT connection command, and referring to fig. 4, after the state report network is not connected, the two situations, i.e., 2G/3G network is not connected ^ TMODE:2,2 and WIFI network is not connected ^ TMODE:1,2, are included, the PC side software can send the following command to the data card to indicate the connection:
AT^TCONN=<type>,<mode>[,<ssid>,<bssid>]
< type >: type of network to be connected: 1WIFI2TD/EDGE
< mode >: whether to connect or disconnect a network:
1 connection 0 cancels network connection
< ssid >: WLAN network SSID when < type > =1 is in effect
< bsid >: WLAN network bSSID, when < type > =1 is in effect
No matter the 2G/3G network or the WIFI network is connected, the connection parameters need to be set before connection. When the 2G/3G network is connected, the APN needs to be set, and standard AT commands AT + CGDCONT to carry out setting. When a WIFI network is connected, an authentication mode, an encryption algorithm, an authentication mode and key information need to be set, and the following AT commands can be used for setting:
AT^TTAPCFGS=<ssid>,<bssid>,<auth>,<encr>,<autype>
[,<wepkey0>,<wepkey1>,<wepkey2>,<wepkey3>,<wepkeyindex>]
< ssid >: WLAN network SSID
< bsid >: WLAN network bSSID
< auth >: authentication mode
The method comprises the following steps: 0 NONE1 IEEE8021X 2WPA _ PSK3WPA _ EAP4WPA2_ PSK
5WPA2_EAP
< encr >: encryption algorithm
The method comprises the following steps: 0 NONE1 TKIP 2 CCMP 3 WEP _ OPEN4WEP _ SHARE
5WEP1046YES
< Autype > authentication method
The method comprises the following steps: 0 NONE1(U) SIM authentication 2WEB authentication
< webkey 0 >: WEP encryption Key1 or WPA/WPA2 authentication Key
Effective when < encr > = TKIP or < encr > = CCMP
< webkey 1 >: WEP encryption Key2
< webkey 2 >: WEP encryption Key3
< webkey 3 >: WEP encryption Key 4
< webkeyindex >: WEP encryption key indexing
Effective when < encr > = WEP _ OPEN or < encr > = WEP _ SHARE
Because the action execution time of the network connection is long, if synchronous AT commands are used, the PC side software will block, resulting in untimely processing of other AT commands. Therefore, the network connection AT command execution result is reported in an asynchronous mode, and a unique key value mark exists in a response returned immediately after the command issues the data card, as shown in the following:
<CR><LF>^TCONN:
<CR><LF>ACK:<id><CR><LF>
<CR><LF>OK<CR><LF>
wherein < id >: and the asynchronous AT command processing number is used for marking the response result to be actively reported, and the cycle is from 0 to 127.
And then the actual connection processing result can be reported to the PC side software actively through the ^ TACK, wherein the actual connection processing result also has a unique key value mark, so that the PC side software can judge the processing result of the request, and the result confusion is prevented. The report format of the TACK is as follows:
^TACK:<id>,<result>[,<err>]
< id >: the asynchronous AT command processing number is used for marking the response result of the active report: cycling from 0 to 127, -11 represents the result of the WIFI hotspot scanning
< result >: asynchronous command processing results: 0OK1ERROR
< err >: error code, reporting when result! =0
Fig. 5 is a flow chart of an AT cancel connection command, and referring to fig. 5, if the connection can be canceled during the connection process, the AT command is the same as the AT command used during the network connection, except that a parameter, a < mode > parameter, needs to be changed.
Fig. 6 is a flowchart of an AT disconnection command, and referring to fig. 6, after the state reporting network is connected, the PC side software may issue the following command to the data card to perform disconnection operation, where the two conditions include that the 2G/3G network is connected with the 2G/3G network and that the WIFI network is connected with the 1G/4G network:
AT^TDISCONN=<type>
< type >: type of network to be disconnected: 0ALL1WIFI2TD/EDGE
This command is also an asynchronous execution command. And reporting the state that the network is disconnected in the execution process. And if the TACK indicates that the disconnection command is successfully executed, reporting the unconnected state of the network. Otherwise, the disconnection fails and the network connected state is still maintained.
An embodiment of the present invention further provides a control device, which is used for a mobile terminal, and the device includes:
a first receiving module, configured to receive a first AT command sent by a user terminal;
the judging module is used for judging whether the first AT command indicates to be connected with a wireless network or not and acquiring a first judging result;
and the generating module is used for generating a first wireless network connection instruction when the first judgment result is yes.
The mobile terminal carries out interaction of the AT command with the user terminal through an AT command transmission channel established between the mobile terminal and the user terminal, and generates a first wireless network connection instruction when the first AT command indicates to connect a wireless network by receiving the first AT command sent by the user terminal, thereby realizing high robustness control on the behavior of controlling and connecting the wireless network by the mobile terminal;
in addition, the method can perform information interaction between the user terminal and the mobile terminal through the established AT command transmission channel without establishing a PPPOE transmission channel, thereby reducing the consumption of certain time resources caused by establishing the PPPOE transmission channel and the occupation of certain transmission resources and processing resources between the mobile terminal and the user terminal, and further realizing the efficient control of the behavior of controlling the connection of the mobile terminal with the wireless network to a certain extent.
The wireless network may be a WIFI network, and the generating module may specifically include:
the first analysis unit is used for analyzing the WIFI hotspot identification parameters from the first AT command when the first judgment result is yes;
a first generating unit, configured to generate the first wireless network connection instruction for instructing to connect to a WIFI hotspot; wherein the WIFI hotspot corresponds to the WIFI hotspot identification parameter.
In addition, the mobile terminal may be provided with a first module for connecting a wireless network having a first network type and a second module for connecting a wireless network having a second network type, and the generating module may specifically include:
a second parsing unit, configured to parse the network type parameter from the first AT command if the first determination result is yes;
a second generating unit, configured to generate the first wireless network connection instruction for controlling the first module to connect to a wireless network with a first network type when the network type parameter is the first network type;
a third generating unit, configured to generate the first wireless network connection instruction for controlling the second module to connect to a wireless network with a second network type when the network type parameter is the second network type.
Further, the apparatus may further include:
the first control module is used for controlling the first module to establish a first connection with a wireless network with a first network type under the control of the user terminal before the receiving module receives a first AT command sent by the user terminal;
a second sending module, configured to send, before the receiving module receives the first AT command sent by the user terminal, a third AT command carrying a connected state of the wireless network to the user terminal when the first connection is established, so that the user terminal can generate and send a fourth AT command indicating disconnection to the mobile terminal according to the third AT command;
a second receiving module, configured to receive the fourth AT command before the receiving module receives the first AT command sent by the user terminal;
a second control module, configured to control the first module to disconnect the first connection according to the fourth AT command before the receiving module receives the first AT command sent by the user terminal;
and the third sending module is used for sending a fifth AT command carrying a wireless network unconnected state to the user terminal before the receiving module receives the first AT command sent by the user terminal and when the first connection is disconnected, so that the user terminal can generate and send the first AT command to the mobile terminal according to the fifth AT command.
Further, the first control module may specifically include:
the control unit is used for receiving a sixth AT command sent by the user terminal before the receiving module receives the first AT command sent by the user terminal;
a determining unit, configured to determine, before the receiving module receives a first AT command sent by a user terminal, whether the sixth AT command indicates to connect to a wireless network, and obtain a second determination result;
a fourth generating unit, configured to generate a second wireless network connection instruction when the second determination result is yes before the receiving module receives the first AT command sent by the user terminal.
The embodiment of the invention also provides a mobile terminal which comprises the control device.
The foregoing is merely an example of the embodiments of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the embodiments of the present invention, and these modifications and decorations should also be regarded as the protection scope of the embodiments of the present invention.