CN117177386A - Network connection method, electronic device, and computer-readable storage medium - Google Patents

Network connection method, electronic device, and computer-readable storage medium Download PDF

Info

Publication number
CN117177386A
CN117177386A CN202311400131.4A CN202311400131A CN117177386A CN 117177386 A CN117177386 A CN 117177386A CN 202311400131 A CN202311400131 A CN 202311400131A CN 117177386 A CN117177386 A CN 117177386A
Authority
CN
China
Prior art keywords
network
server
electronic device
reconnection
electronic equipment
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.)
Granted
Application number
CN202311400131.4A
Other languages
Chinese (zh)
Other versions
CN117177386B (en
Inventor
刘亚静
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202311400131.4A priority Critical patent/CN117177386B/en
Publication of CN117177386A publication Critical patent/CN117177386A/en
Application granted granted Critical
Publication of CN117177386B publication Critical patent/CN117177386B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Mobile Radio Communication Systems (AREA)

Abstract

The application provides a network connection method, an electronic device and a computer readable storage medium. The network connection method comprises the following steps: the electronic equipment determines the network connection state of the electronic equipment through the network quality parameters monitored locally, and the network connection state of the electronic equipment can be determined without sending data to a server as the network quality parameters can reflect the real-time communication capability of the electronic equipment and are acquired locally. Therefore, the network connection state of the electronic device can be determined more quickly according to the network quality parameter relative to the TCP protocol, and the electronic device initiates a reconnection request to the server when the network connection state is a connected network and the network is unavailable. Because the network connection state can be quickly determined, the electronic equipment can also quickly reestablish connection with the server, and the instantaneity of sending the notification message by the electronic equipment is improved.

Description

Network connection method, electronic device, and computer-readable storage medium
Technical Field
The present application relates to the field of communications, and in particular, to a network connection method, an electronic device, and a computer readable storage medium.
Background
After the electronic equipment and the other terminal which are logged in the same account are paired, far-field communication can be carried out through the server, so that notification information on the electronic equipment is synchronized to the other terminal. For example, when the mobile phone is far away from the watch, the mobile phone is disconnected from the watch by bluetooth, far-field communication can still be performed, and the mobile phone can synchronize the notification message to the watch in real time through the far-field communication, so that a user can view the notification message in real time and reply quickly. In the prior art, in the context of far-field communications, communications between an electronic device and a server are implemented based on the transmission control protocol (TCP, transmission Control Protocol). TCP has a weak capability of reflecting link abnormality, and whether link abnormality occurs needs to be determined according to data transmission conditions between the electronic device and the server, so that network change of an application layer cannot be perceived rapidly based on TCP. When the network is in a connected state but the network is not available (such as abnormal router, width arrears, hot spot closing, etc.), the electronic device still sends a notification message to the server, so that the notification message cannot be sent to another terminal through the server, and thus the instantaneity of communication cannot be guaranteed.
Disclosure of Invention
The application provides a network connection method, electronic equipment and a computer readable storage medium, which can quickly sense the network change of the electronic equipment so as to improve the instantaneity of the communication between the electronic equipment and a server.
In order to achieve the above purpose, the application adopts the following technical scheme:
in a first aspect, a network connection method is provided, where an electronic device determines a network connection state of the electronic device through a network quality parameter monitored locally, and the network connection state of the electronic device can be determined without sending data to a server, because the network quality parameter can reflect real-time communication capability of the electronic device, and the network quality parameter is acquired locally. Therefore, compared with the TCP protocol, the network connection state of the electronic equipment can be determined more quickly according to the network quality parameters, when the network connection state is a connected network and the network is unavailable, the electronic equipment sends a reconnection request to the server, and in the reconnection process, the electronic equipment does not send a notification message to the server. Because the network connection state can be quickly determined, the electronic equipment can also quickly reestablish connection with the server, and the instantaneity of sending the notification message by the electronic equipment is improved.
In one embodiment, the network quality parameter characterizes the WIFI connection status. And when the electronic equipment is connected with the WIFI, the WIFI connection state represents the current communication capability of the electronic equipment.
In an embodiment, the electronic device determines the network connection state by monitoring the network quality parameter detected by the WIFI tracker, where the WIFI tracker is located in the application framework layer and is configured to receive broadcast information of a WIFI module of the electronic device, where the broadcast information carries the network quality parameter. By monitoring the WIFI tracker, the network quality parameters of the electronic equipment can be determined without waiting for the response of the server, so that the network abnormal condition can be rapidly determined.
In an embodiment, the electronic device determines a network connection state of the electronic device by monitoring a network speed of the electronic device detected by a system user interface, where the system user interface is configured to update the network speed of the electronic device according to a set time interval. The system user interface is a system application, the network speed can reflect the communication condition of the electronic equipment, and the network quality parameters of the electronic equipment can be determined without waiting for the response of the server by monitoring the network speed of the electronic equipment, so that the network abnormal condition can be rapidly determined.
In an embodiment, when the network quality parameter is a network speed of the electronic device, the network speed is less than a preset rate (for example, 1 k/s), which indicates that the network speed is not available, and further determines that the network connection state is the first state.
In an embodiment, after the electronic device initiates the reconnection request to the server, the method further comprises: and setting a reconnection state bit of the electronic equipment to a preset value, wherein the preset value represents that the electronic equipment is in a state of initiating a reconnection request to a server. Therefore, reconnection can be performed under the condition that the electronic equipment is not reconnected, and the connection efficiency of the electronic equipment and the server is improved.
In an embodiment, after the electronic device initiates the reconnection request to the server, the method further comprises: if the network connection state is a second state, the electronic device and the server establish a new connection channel, the second state represents a network connected and available state, and the new connection channel is used for sending a notification message cached in the electronic device to the server. Whether the network is restored or not can be quickly determined through the network quality parameters monitored locally, so that a new connection channel can be quickly established with the server under the condition of network restoration, and the instantaneity of message synchronization is improved.
In an embodiment, under the condition that a first transmission module of the electronic device performs far-field communication with the server through the first communication module, the electronic device calls the first transmission module to monitor the local network quality parameter; the electronic device instructs the first communication module to initiate a reconnection request to the server through the first transmission module. The first transmission module monitors network quality parameters and indicates reconnection, so that decision efficiency of the electronic equipment can be improved, and a connection channel can be quickly established by reconnecting with the server.
In a second aspect, there is provided a network connection device comprising:
the monitoring module is used for determining the network connection state of the electronic equipment through the network quality parameters monitored locally by the electronic equipment;
and the reconnection module is used for sending a reconnection request to the server by the electronic equipment if the network connection state is a first state, wherein the first state represents a connected network and network unavailable state.
In an embodiment, the network quality parameter characterizes a WIFI connection status.
In an embodiment, the monitoring module is specifically configured to:
the electronic equipment determines the network connection state by monitoring network quality parameters detected by a WIFI tracker, wherein the WIFI tracker is used for receiving broadcast information of a WIFI module of the electronic equipment, and the broadcast information carries the network quality parameters.
In an embodiment, the monitoring module is specifically configured to:
the network connection state of the electronic equipment is determined by the electronic equipment through monitoring the network speed of the electronic equipment detected by a system user interface, and the system user interface is used for updating the network speed of the electronic equipment according to a set time interval.
In an embodiment, the listening module is further configured to:
and when the network quality parameter is the network speed of the electronic equipment, and the network speed is smaller than a preset speed, the network connection state is the first state.
In an embodiment, the reconnection module is further for:
and setting the reconnection status bit of the electronic equipment to a preset value, wherein the preset value indicates that the electronic equipment is in a state of initiating a reconnection request to the server.
In an embodiment, the reconnection module is further for:
if the network connection state is a second state, the electronic device and the server establish a new connection channel, wherein the second state represents a connected network and a network available state, and the new connection channel is used for sending a notification message cached in the electronic device to the server.
In an embodiment, the monitoring module is specifically configured to:
Under the condition that a first transmission module of the electronic equipment performs far-field communication with the server through a first communication module, the electronic equipment calls the first transmission module to monitor the local network quality parameter;
correspondingly, the reconnection module is specifically configured to:
and the electronic equipment instructs the first communication module to initiate a reconnection request to the server through the first transmission module.
In a third aspect, an electronic device is provided, comprising a processor for executing a computer program stored in a memory for implementing the network connection method as described in the first aspect above.
In a fourth aspect, there is provided a computer readable storage medium storing a computer program which, when executed by a processor, implements the network connection method according to the first aspect described above.
In a fifth aspect, a chip is provided, the chip comprising a processor, the processor being coupled to a memory, the processor executing a computer program or instructions stored in the memory to implement the network connection method as described in the first aspect above.
In a sixth aspect, there is provided a computer program product for, when run on a terminal device, causing the terminal device to perform the network connection method of the first aspect described above.
It will be appreciated that the advantages of the second to sixth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
Fig. 1 is a software architecture diagram of an electronic device according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a network connection system according to an embodiment of the present application;
FIG. 3 is a flowchart of a network connection method based on TCP according to an embodiment of the present application;
FIG. 4 is a timing diagram of a network connection method based on TCP according to an embodiment of the present application;
fig. 5 is a schematic diagram of a network setup page according to an embodiment of the present application;
fig. 6 is a flowchart of a network connection method according to an embodiment of the present application;
fig. 7 is a timing chart of a network connection method according to an embodiment of the present application;
fig. 8 is a flowchart of a network connection method according to another embodiment of the present application;
fig. 9 is a timing chart of a network connection method according to another embodiment of the present application;
fig. 10 is a flowchart of a network connection method according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, 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.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The network connection method provided by the embodiment of the application is applied to a network connection system. The network connection system includes two electronic devices and a server. The two electronic devices are devices which establish trust relationship, and can perform far-field communication through the server so as to synchronize notification messages.
The electronic device in the embodiments of the present application may be a mobile phone, a tablet computer, a handheld computer, a personal digital assistant (personal digital assistant, PDA), an augmented reality (augmented reality, AR) \virtual reality (VR) device, a media player, a wearable device, or the like, which may be held/operated by one hand, and the specific form/type of the electronic device is not particularly limited in the embodiments of the present application. The electronic device includes, but is not limited to, a device on which iOS, android, microsoft, hong and mony systems (Harmony OS) or other operating systems are mounted.
For example, the two electronic devices may be a mobile phone and a wristwatch, a mobile phone and a printer, a computer and a computer, respectively.
The software system of the electronic device may employ a layered architecture, an event driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the application, an Android system with a layered architecture is taken as an example, and the software structure of the electronic equipment is illustrated.
Fig. 1 is a software configuration block diagram of an electronic device according to an embodiment of the present invention.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into five layers, from top to bottom, an application layer, an application framework layer, an Zhuoyun row (Android run) and system library, a hardware abstraction layer (Hardware Abstraction Layer, HAL), and a kernel layer, respectively.
The application layer may include a series of application packages.
As shown in fig. 1, the application package may include applications for cameras, gallery, calendar, phone calls, maps, navigation, WLAN, bluetooth, music, video, short messages, etc.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions.
As shown in FIG. 1, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc.
The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text message notification icon may include a view displaying text and a view displaying a picture.
The telephony manager is for providing communication functions of the electronic device. Such as the management of call status (including on, hung-up, etc.).
The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like.
The notification manager allows the application to display notification information in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. Such as notification manager is used to inform that the download is complete, message alerts, etc. The notification manager may also be a notification in the form of a chart or scroll bar text that appears on the system top status bar, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in a status bar, a prompt tone is emitted, the electronic device vibrates, and an indicator light blinks, etc.
Android run time includes a core library and virtual machines. Android run time is responsible for scheduling and management of the Android system.
The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The system library may include a plurality of functional modules. For example: surface manager (surface manager), media Libraries (Media Libraries), three-dimensional graphics processing Libraries (e.g., openGL ES), 2D graphics engines (e.g., SGL), etc.
The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio and video encoding formats, such as MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc.
The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
The 2D graphics engine is a drawing engine for 2D drawing.
HAL is used to provide a unified hardware access interface and resource management so that upper layer applications can be developed and run independent of the specific hardware platform. HAL includes WIFI interface, bluetooth interface, audio interface, etc.
The kernel layer is a layer between hardware and software. The kernel layer contains wireless fidelity (WIreless Fidelity, WIFI) drivers, display drivers, audio drivers, sensor drivers, etc.
The network connection system provided by the embodiment of the application is described below by taking an example that one of the electronic devices is a mobile phone and the other electronic device is a watch.
As shown in fig. 2, the mobile phone and the watch are devices for establishing trust relationship. The mobile phone and the watch log in the same user account to perform trusted authentication, so that a trust relationship is established, and a trust ring is formed. Under the condition that the mobile phone and the watch are connected with each other, when the mobile phone receives the notification message, the mobile phone sends the notification message to the watch through the server, so that the synchronization of the notification message is realized. The watch can realize communication connection with the server by opening the eSIM.
Specifically, the server is a cluster server, and the server is divided into an account cloud, a trust ring cloud, a device cloud and a far-field cloud according to the function of the server. The mobile phone and the watch log in the account cloud through the user account respectively, when authentication is needed, a first account authentication module of the mobile phone sends the user account of the mobile phone to the trust ring cloud, a second account authentication module of the watch sends the user account of the watch to the trust ring cloud, the trust ring cloud obtains account information of the mobile phone and the watch from the account cloud, the same account authentication is carried out, and authentication results are sent to the first account authentication module and the second account authentication module respectively. And under the condition that the authentication result is that the authentication is passed, the mobile phone and the watch establish a trust relationship through the trust ring cloud to form a trust ring.
The mobile phone and the watch can also carry out double-end authentication through the device cloud when in first communication. For example, the mobile phone sends the authentication information to the equipment cloud through the first connection module, the watch sends the authentication information to the equipment cloud through the second connection module, the equipment cloud verifies the received authentication information, the authentication results are respectively sent to the first connection module and the second connection module, the first connection module sends the authentication information to the first account authentication module, the second connection module sends the authentication information to the second account authentication module, and the account authentication module can display the authentication results on a display interface of the mobile phone/the watch. The first connection module and the second connection module are modules for realizing information sharing among devices, and include a module located in an application framework layer and a module located in a HAL, for example, a logic link may be used.
The first transmission module on the mobile phone and the second transmission module on the watch can also perform double-end authentication through far-field cloud before sending the notification message. For example, the first transmission module and the second transmission module respectively send authentication information of the mobile phone and the watch to a far-field cloud, the far-field cloud authenticates the authentication information, authentication results are respectively sent to the first transmission module and the second transmission module, the first transmission module sends the authentication results to the first account authentication module, and the second transmission module sends the authentication results to the second account authentication module. The first transmission module and the second transmission module are used for realizing data transmission between the mobile phone and the watch, and include a module located in an application framework layer and a module located in a HAL, for example, a magic ring.
After authentication is completed, the mobile phone can synchronize the notification message to the watch through the server.
Specifically, the notification message is a notification message of an application program, for example, may be a short message of a short message application program, weather reminding information of a weather application program, schedule reminding information of a schedule application program, time information of an alarm clock application program, motion information of a motion health application program, or the like, or may be a notification message sent to a preset functional module on the electronic device by a third party server. The notification message can be displayed on the mobile phone display interface in the form of a card according to the setting information of the user, and can also be displayed on a notification bar.
A message notification module (which can be a system application) on the mobile phone monitors notification messages of the application program, and when the application program is determined to generate new notification messages, the notification messages are transmitted to a first transmission module through a first connection module. Meanwhile, the first connection module pulls up the first transmission module, the first transmission module sends the notification message to the far-field cloud through the first communication module (such as libwebsocket), the far-field cloud determines the identification of the watch establishing trust relationship with the mobile phone according to the identification (such as comID) of the mobile phone, and the notification message is sent to the second transmission module on the watch through the second communication module on the watch according to the identification of the watch. The second transmission module sends the notification message to the message receiving module through the second connection module on the watch. The message receiving module may include one or more applications on the watch, such as sports health, weather, etc., or other functional modules on the watch for receiving messages. The second connection module may send the notification message to the corresponding application according to the identifier corresponding to the notification message. A message display module (such as a system UI) on the watch displays the notification message received by the message receiving module on a display interface of the watch, so that synchronization of the notification message is realized.
The control channel between the first transmission module and the second transmission module comprises an end cloud control channel between the first transmission module and the far-field cloud and an end cloud control channel between the second transmission module and the far-field cloud. The end cloud control channel is a long connection established through websocket. The websocket long connection adopts an open-source websocket library, and the websocket bottom layer is based on TCP. The communication mode based on TCP is that one of the two ends of communication sends detection information to the opposite end according to a set interval, and whether the two ends normally communicate is determined according to whether the opposite end replies a confirmation character (Acknowledge character, ACK), and further whether the network connection is abnormal is determined. Therefore, the communication mode based on TCP cannot quickly sense network abnormality, has weak capability of reflecting link abnormality, and cannot provide excessive abnormality processing details for the upper application program. For example, when a mobile phone is in a network connection state and a network becomes unavailable from available, information determined based on TCP cannot quickly perceive a network change. When the network is not available, the mobile phone side can still generate notification messages according to the condition that the network is available. Because the network is not available, the notification message cannot be sent to the watch through the server, and in the case that the network is not available and becomes available, the mobile phone cannot quickly sense the network change information, and still cannot disconnect the old connection from the server and establish a new connection, so that the notification message cannot be sent to the watch. Thus, determining network information based on TCP cannot guarantee immediate synchronization of notification messages.
Fig. 3 is a flowchart of a method for TCP-based network connection according to an embodiment of the application.
As shown in fig. 3, the mobile phone and the watch establish an end-to-end control channel through the server, and the mobile phone and the server communicate through the end-to-cloud control channel. Under the conditions of network disconnection and network switching, the mobile phone can receive LWS_CALLBACK_CLIENT_CLOSED information called back by the first communication module. And then, marking reconnection flag bits by the mobile phone, wherein the numerical value of the reconnection flag bits represents reconnection times. The mobile phone determines whether the current reconnection times reach the set reconnection times (for example, 2 times) according to the value of the reconnection flag bit. And if the set reconnection times are reached, releasing the cloud control channel by the mobile phone. If the set reconnection times are not reached, further determining whether the reconnection condition is satisfied, wherein whether the reconnection condition is satisfied can be determined according to whether the reconnection time interval is reached and whether the total reconnection duration is reached. And if the reconnection condition is met, reconnecting again, and if the reconnection condition is not met, releasing the control connection channel by the mobile phone. Under the condition that the network resumes the mobile phone networking, the mobile phone receives client_APPEND_ HANDSHAKE _HEADER information called back by the first communication module, and then the mobile phone is reconnected with the server to establish an end cloud control channel, so that the mobile phone and the watch establish the end cloud control channel through the server.
Under the condition that the network connection of the mobile phone is unavailable, the mobile phone cannot sense in time, the server side does not sense either, and the mobile phone can only determine that the network is abnormal when the server or the mobile phone fails to send detection information or heartbeat keep-alive packets to the opposite terminal or when the server or the mobile phone fails to send notification messages to the opposite terminal, so that the mobile phone can release the cloud control channel of the end.
Fig. 4 is a timing diagram of a method for TCP-based network connection according to an embodiment of the present application.
As shown in fig. 4, the mobile phone includes a first connection module, a first transmission module and a first communication module, the server includes a far-field cloud, and the watch includes a second transmission module and a second connection module. The first connection module is used for receiving the notification message of the mobile phone and sending the notification message to the first transmission module. The first transmission module is configured to establish a communication connection with the server through the first communication module and send a notification message to the server, and the first communication module may be a libwebsocket. The second transmission module establishes a control channel with the first transmission module through the server, and is used for receiving the notification message sent by the first transmission module through the server. The second connection module is used for sending the notification message received by the second transmission module to the message display module on the watch, so that the notification message is displayed on the watch.
The first transmission module monitors the network thread of the first communication module, determines whether the mobile phone is connected with a network, and establishes a control channel through the server to perform data transmission under the condition that the mobile phone is connected with the network. In the case of a network outage, the first transmission module receives lws_call_client_closed information called back by the first communication module, determines that the network is disconnected according to the received information, sends an outage instruction (for example, may be an sm_event_device_group_release instruction) to the first communication module, and disconnects the connection with the server according to the outage reconnection instruction.
After the first transmission module sends the network disconnection instruction to the first communication module, if the notification message sent by the first connection module is received, the first transmission module caches the notification message. And after the first transmission module sends the disconnected reconnection instruction to the first communication module, marking reconnection flag bits, wherein the initial value of the reconnection flag bits is the set reconnection times. If the current reconnection times are not up to the set reconnection times according to the value of the reconnection flag bit, the first transmission module subtracts 1 from the value of the reconnection flag bit to update the value of the reconnection flag bit. And then, the first transmission module determines whether the reconnection condition is met, and if the reconnection condition is met, the first transmission module instructs the first communication module to execute reconnection action. The first communication module enters a connect state machine according to the indication information of the first transmission module, reestablishes websocket connection, and starts a timer, wherein the duration of the timer is retransmission interval. And when the duration of the timer is up, the first communication module sends a reconnection request to the server. If reconnection fails, the first communication module sends CALLBACK information of LWS_CALLBACK_CLIENT_CONNECTION_ERROR to the first transmission module, and the first transmission module disconnects websocket according to the CALLBACK information. Under the condition that the current reconnection times are not up to the set reconnection times according to the value of the reconnection flag bit, subtracting 1 from the value of the reconnection flag bit, and then determining whether the reconnection condition is met. If the reconnection condition is met, the first communication module enters a connect state machine again according to the indication of the first transmission module, reestablishes websocket connection, starts a timer, and sends a reconnection request to the server when the duration of the timer is reached.
And the first transmission module determines that the set reconnection times are reached according to the value of the reconnection flag bit, and indicates the first communication module to disconnect the cloud connection channel under the condition that reconnection failure information returned by the first communication module is received. The first communication module returns information of the release channel, for example, onCtrlChannelStatusUpdated (status= -202), after disconnecting the end cloud connection channel. If there is a cache message, the first communication module returns a message of failed transmission, for example, onCtrlMsgSendUpdated (status= -1000). The first transmission module transmits the information of the release channel returned by the first communication module and the information of the transmission failure to the first connection module.
In the reconnection process, if the network is restored, the mobile phone is connected, the first transmission module receives LWS_CALLBACK_CLIENT_APPEND_ HANDSHAKE _HEADER information called back by the first communication module, the first transmission module updates the value of the reconnection flag bit, and under the condition that the reconnection condition is confirmed to be met, the first transmission module enters a connect state machine, the websocket connection is rebuilt, and the duration of a timer is reached, the first communication module sends a reconnection request to the server. The server returns configuration information such as heartbeat time and the like to the first communication module according to the reconnection request, and the first communication module sends the configuration information to the first transmission module, so that the first transmission module and the server establish heartbeat connection, and further an end cloud control channel is established. And then, the first transmission module and the second transmission module establish an end-to-end control channel through the server. The first transmission module sends the identification of the mobile phone and the notification message to the server under the condition that the cached notification message exists, the server sends the notification message to the second transmission module at the watch side according to the identification of the mobile phone, the second transmission module sends the notification message to the second connection module, and the second connection module sends the notification message to the display module on the watch, so that the notification message is displayed on the display interface of the watch. And under the condition that the message is successfully sent, the first transmission module receives the message returned by the server and the message is successfully sent. The first transmission module returns the message which is successfully sent to the first connection module.
The first communication module may initiate a reconnection request to the server in case of a network disconnection based on the TCP protocol. However, in the case that the network is connected and the network is unavailable, the first communication module cannot sense in time, and when the first transmission module receives the notification message, the notification message is still sent to the server, so that the notification message cannot be sent to the watch, and the instantaneity of the notification message received by the watch is affected.
In order to solve the above-mentioned problems, an embodiment of the present application provides a network connection method, in which a mobile phone determines a network connection state of the mobile phone through a network quality parameter monitored locally, and if the network connection state is a connected network and a network is unavailable state, the mobile phone sends a reconnection request to a server through a first communication module. The network quality parameter is used for representing the WIFI connection state, or the network quality parameter is the network speed of a network connected with the mobile phone, and can reflect the communication capability of the mobile phone. Compared with the method for determining the network connection state through the data transmission condition between the two terminals based on the TCP protocol, the method for determining the network connection state can determine the network connection state more quickly by locally monitoring the network quality parameters without waiting for the response information of the server, so that a reconnection request can be sent to the server quickly when the network is unavailable, communication connection can be established with the server again, and the instantaneity of sending the notification message to the server is improved.
In an embodiment, the network quality parameter is used for characterizing a WIFI connection state, and the mobile phone determines the network connection state by monitoring the WIFI connection state detected by the WIFI tracker. The WIFI connection state comprises a WIFI disconnection state, a WIFI connection and availability state and a WIFI connection and unavailable state. The WIFI tracker is located application program framework layer and is used for receiving the WIFI connection state broadcasted by the WIFI module.
Specifically, the WIFI module of the mobile phone determines a network quality parameter for characterizing a WIFI connection state according to a WIFI quality (e.g., a WIFI signal strength). The WifiManager_STATE_CHANGED_ACTION in the WIFI module broadcasts network info information, wherein the network info information carries network quality parameters for representing the WIFI connection STATE. The WIFI tracker receives network info information broadcast by the WifiManager, NETWORK_STATE_CHANGED_ACTION, obtains network quality parameters according to the broadcast information, and further determines the WIFI connection STATE.
In an embodiment, after determining the WIFI connection state, the WIFI tracker sends the WIFI connection state to the first transmission module, and the first transmission module determines a network connection state according to the WIFI connection state, where the network connection state is consistent with the WIFI connection state. When the network connection state is a connected network and the network is unavailable, the first transmission module indicates the first communication module to send a reconnection request to the server, so that the network connection state can be determined without waiting for a response of the server, and the connection can be quickly reestablished with the server under the condition that the network is unavailable, thereby improving the instantaneity of message synchronization of the mobile phone and the watch.
The WIFI tracker can also display the current WIFI connection state on the display interface according to user operation. Illustratively, in the case where the mobile phone detects that the user opens the network setting information, a network setting page as shown in fig. 5 is displayed on the display interface. The network equipment page displays the opening option of the WLAN, the setting option of the WLAN, the name of the WLAN to which the mobile phone is currently connected and the connection state of the WLAN. For example, the name of the WIFI network currently connected to the mobile phone is ABC, and if the WIFI connection state obtained by the WIFI tracker is a connected network and the network is unavailable, information that the WIFI is connected (can not be connected to the internet) is displayed on the display interface.
In the case that the mobile phone determines the network connection state by monitoring the WIFI tracker, a specific flow of the network connection method is shown in fig. 6.
The mobile phone and the watch establish an end-to-end control channel through the server (S61), and the mobile phone and the server communicate through an end-to-cloud connection channel. The mobile phone monitors the WIFI connection state detected by the WIFI tracker (S62). In the case of network disconnection and network switching (S63), the mobile phone receives lws_call_client_closed information called back by the first communication module (S64), and determines to perform network disconnection reconnection. Meanwhile, the mobile phone can determine the conditions of network disconnection and network switching according to the WIFI connection state detected by the WIFI tracker, and can also determine the conditions that the connected network is unavailable. In case of network disconnection, network handover, connected network and network unavailability (S65), the handset determines to perform a network disconnection reconnection.
After determining that the network is disconnected and reconnected, the mobile phone marks a reconnection flag bit (S66), and the value of the reconnection flag bit represents the reconnection times. The mobile phone determines whether the set reconnection times are reached according to the value of the reconnection flag bit (S67). If the set reconnection times are reached, the mobile phone releases the end cloud control channel (S68). If the set number of reconnections is not reached, the mobile phone further determines whether the reconnection condition is satisfied (S69), where whether the reconnection condition is satisfied may be determined according to whether a reconnection time interval (for example, may be 3S) is reached, and whether the total reconnection duration is reached. If the reconnection condition is satisfied, reconnection is performed (S610), and if the reconnection condition is not satisfied, the handset releases the end cloud control channel (S68).
If the network is disconnected, if the network is restored, the mobile phone is networked (S611), the mobile phone receives client_application_ HANDSHAKE _header information called back by the first communication module (S612), and then the mobile phone is reconnected with the server to establish an end cloud control channel (S613). If the mobile phone determines that the network connection state is the connected network and the network is available according to the WIFI connection state detected by the WIFI tracker (S614), the mobile phone and the server are reconnected to establish the end cloud control channel (S613). Under the condition that the mobile phone and the server establish an end cloud control channel, the mobile phone and the watch establish the end cloud control channel through the server.
As shown in fig. 7, the timing diagram of the above network connection method is different from the TCP-based network connection method in that the first transmission module further obtains a WIFI connection state from the WIFI tracker, and initiates a reconnection request to the server according to the WIFI connection state.
Specifically, the mobile phone comprises a first connection module, a WIFI tracker, a first transmission module and a first communication module, and the watch comprises a second transmission module and a second connection module.
The first connection module instructs the first transmission module to initiate far-field communication according to an instruction to establish communication connection with the wristwatch. In the far-field communication process, the first transmission module monitors the WIFI tracker from an upper layer, and when the network connection state is determined to be the connected network and the network is available according to the WIFI connection state detected by the WIFI tracker, the first transmission module calls the first communication module to establish an end cloud connection channel with the server, so that the first transmission module and the second transmission module establish an end control channel through the server.
When the source of the WIFI network connected to the mobile phone is disconnected, a WIFI STATE machine (WIFI STATE machine) of the WIFI module indicates that the WIFI manager. And the WIFI tracker receives the broadcast information and determines the WIFI connection state according to the broadcast information.
The first transmission module monitors the WIFI tracker to obtain a WIFI connection state. For example, if the network quality parameter for characterizing the WIFI connection status includes network info. GetDetailedState () =DetailedState. CONNECTED, wificonTignomonworutil. AP_NO_INTERNET_ACCESS, wificonTignomonwortil. PORTAL_AP_UNAUTHORIZED, the first transmission module determines that the network connection status is connected to the network and the network is unavailable, inserts a high priority processing task (for example, ctrlChannelProcWsReconnect) from CtrCreateUsers task of an upper layer (frame layer), the high priority task is used to instruct the first communication module to disconnect the network. The first communication module disconnects the connection with the server according to the network disconnection indication.
After the first transmission module sends the network disconnection instruction to the first communication module, if the notification message sent by the first connection module is received, the first transmission module caches the notification message. The first connection module may send the notification message to the first transmission module by calling SendCtrlMsg. The first transmission module marks the reconnection flag bit after sending a disconnection instruction to the first communication module. If the current reconnection times are not up to the set reconnection times according to the value of the reconnection flag bit, the first transmission module subtracts 1 from the value of the reconnection flag bit to update the value of the reconnection flag bit. And then, the first transmission module determines whether the reconnection condition is met, and if the reconnection condition is met, the first transmission module instructs the first communication module to execute reconnection action. The first communication module enters a connect state machine according to the indication information of the first transmission module, reestablishes websocket connection, and starts a timer, wherein the duration of the timer is retransmission interval. And when the duration of the timer is up, the first communication module sends a reconnection request to the server. If reconnection fails, the first communication module sends CALLBACK information of LWS_CALLBACK_CLIENT_CONNECTION_ERROR to the first transmission module, and the first transmission module disconnects websocket CONNECTION according to the CALLBACK information. Under the condition that the current reconnection times are not up to the set reconnection times according to the value of the reconnection flag bit, subtracting 1 from the value of the reconnection flag bit, and then determining whether the reconnection condition is met. If the reconnection condition is met, the first communication module enters a connect state machine again according to the indication of the first transmission module, reestablishes websocket connection, starts a timer, and sends a reconnection request to the server when the duration of the timer is reached.
The first transmission module indicates the first communication module to break the cloud control channel under the condition that the first transmission module determines that the set reconnection times are reached according to the value of the reconnection flag bit and receives reconnection failure information returned by the first communication module. And the first communication module returns information of the release channel after disconnecting the end cloud connection channel. If the information cached in the first transmission module is not sent successfully, the first communication module returns information of failed sending to the first transmission module.
In the reconnection process, if the WIFI connection state in the broadcast information received by the WIFI tracker is networkinfo. If the reconnection condition is satisfied, the first transmission module instructs the first communication module to execute the reconnection operation. The first communication module enters a connect state machine according to the indication information of the first transmission module, reestablishes websocket connection, and starts a timer, wherein the duration of the timer is retransmission interval. When the duration of the timer is reached, the first communication module sends a reconnection request to the server, wherein the reconnection request comprises authentication information of the mobile phone side. The server returns configuration information such as authentication information and heartbeat time of the server side to the first communication module according to the reconnection request, and the first communication module sends the configuration information to the first transmission module, so that the first transmission module and the server establish heartbeat connection, and the end cloud connection channel is successfully established. And then, the mobile phone sends a handshake message to the watch through the server, and establishes an end control channel with the watch after receiving the watch handshake ACK. The first transmission module sends the cached notification message to the second transmission module through the end control channel, and the second transmission module returns the successful notification message receiving information to the first connection module after receiving the notification message, wherein the successful notification message receiving information can be OnReceiveCtrlMsg (status=0).
It can be understood that, according to the WIFI connection status obtained from the WIFI tracker, the first transmission module may determine whether the network connection status of the mobile phone is a disconnected network status, in addition to determining that the network connection status is a connected network and the network is unavailable and determining that the network is restored. For example, when the WIFI connection state is the WIFI disconnection state, and when the mobile phone determines that the network connection state is the disconnection state, the mobile phone also initiates a reconnection request to the server.
The first transmission module monitors the WIFI connection state of the WIFI tracker and monitors the network thread of the first communication module. And the first transmission module is used for reconnecting with the server through the first communication module under the condition of determining that the network is disconnected according to the monitoring result of the network thread, and establishing an end cloud control channel with the server through the first communication module under the condition of recovering the network. The process that the first transmission module is reconnected with the server through the first communication module, and the process that the end cloud control channel is established with the server through the first communication module is consistent with the process of the network connection method based on TCP, and is not repeated here.
The WIFI tracker can directly reflect the real-time WIFI connection condition of the mobile phone according to the WIFI connection state determined by the broadcast information of the WIFI module, further can reflect the communication capability of the mobile phone, and indicates that the network of the mobile phone is abnormal when the WIFI connection state is the connected WIFI and the WIFI is unavailable, notification information of the mobile phone cannot be sent to the opposite-end watch through the server, so that message synchronization is realized, the mobile phone sends a reconnection request to the server, new connection can be quickly established between the mobile phone and the server, and the instantaneity of the message synchronization is improved.
In another embodiment, the network quality parameter is a network speed of a network connected to the mobile phone, and the mobile phone determines the network connection state through monitoring the network speed detected by a system user interface (SystemUI, for system application). If the network speed is smaller than a preset speed (for example, 1 k/s), determining that the network connection state of the mobile phone is a connected network and network unavailable state, and if the network speed is larger than or equal to the preset speed, determining that the network connection state of the mobile phone is a connected network and network available state.
The mobile phone can also display the network speed detected by the system user interface on the display interface according to the user setting information, for example, the network speed can be displayed in a status bar of the display interface.
In an embodiment, the first transmission module obtains the network speed through the monitoring system user interface, and when the network connection state of the mobile phone is determined to be the connected network and the network is unavailable according to the network speed, instructs the first communication module to send a reconnection request to the server, so that connection can be quickly reestablished with the server under the condition that the network is unavailable, and the instantaneity of message synchronization of the mobile phone and the watch is improved.
Specifically, as shown in fig. 8, the mobile phone and the watch establish an end-to-end control channel through the server (S81), and the mobile phone communicates with the server through an end-to-cloud connection channel. The system user interface calls a refresh Speed module (a module for monitoring the Network Speed) according to a set interval to acquire the Network Speed, the Network Speed is updated in the Network Speed manager Ex.java, the mobile phone monitors the textValue in the Network Speed manager Ex.java to acquire the Network Speed (S82), and the textValue is used for storing the value of the Network Speed monitored by the system user interface. After obtaining the network speed, the mobile phone judges whether the network speed is smaller than a preset speed (S83). If the network speed is greater than or equal to the preset speed, the mobile phone determines that the network connection state is the connected network and the network is available, and continues to monitor the network speed obtained by the system user interface. If the network speed is smaller than the preset speed, the mobile phone determines that the network connection state is the connected network and the network is unavailable, and further determines to disconnect and reconnect the network. Meanwhile, the mobile phone receives LWS_CALLBACK_CLIENT_CLOSED information called back by the first communication module (S85) under the conditions of network disconnection and network switching based on the bottom TCP protocol (S84), and determines to disconnect and reconnect.
After determining that the network is disconnected and reconnected, the mobile phone marks a reconnection flag bit and a reconnection status bit (S86), wherein the value of the reconnection flag bit indicates the reconnection times, and the value of the reconnection status bit indicates whether reconnection is in progress or not. If the handset is reconnecting, the handset sets the value of the reconnection status bit to a preset value (e.g., 1 or Y, etc.). When the mobile phone is reconnected next time, whether the mobile phone is in a state of initiating a reconnection request to the server or not can be determined according to the reconnection status bit. The network speed information received by the system user interface can be information of any network connected with the mobile phone, for example, the system user interface monitors the network speed information of a module such as TelephonyIntents, connectivityManager, wifiManager of the mobile phone, and can obtain the network speed information of other networks such as 4G, 5G and the like besides the network speed of the WIFI network. When the network speed of any network is smaller than the preset speed, the first transmission module indicates the first transmission module to reconnect the server. When the first communication module determines that the network is abnormal based on the TCP protocol, the first transmission module also indicates the first transmission module to reconnect the server, so that repeated reconnection can exist. By setting the reconnection status bit, the reconnection status bit is set to a preset value when the mobile phone is reconnecting, and the mobile phone can reconnect under the condition that the first communication module is not reconnecting, thereby improving the connection efficiency with the server.
The handset determines whether reconnection is in progress based on the reconnection status bit (S87). If the mobile phone is reconnecting, the mobile phone continues to monitor the user interface of the system to obtain the network speed. If the mobile phone does not perform reconnection, the mobile phone determines whether the current reconnection times reach the set reconnection times according to the value of the reconnection flag bit (S88). If the reconnection times are reached, the mobile phone releases the end cloud control channel (S89). If the number of reconnections is not reached, it is further determined whether a reconnection condition is satisfied (S810). If the reconnection condition is satisfied, reconnection is performed (S811), and if the reconnection condition is not satisfied, the mobile phone releases the end cloud control channel (S89).
If the network is disconnected, if the network is restored, the mobile phone is networked (S812), the mobile phone receives client_application_ HANDSHAKE _header information called back by the first communication module (S813), and the mobile phone is reconnected with the server to establish an end cloud control channel (S814). On the other hand, if the mobile phone is through the monitoring system user interface, the obtained network speed is greater than or equal to the preset speed (S815), it is determined that the network connection state is the connected network and the network is available, and the mobile phone and the server are reconnected to establish the end cloud control channel (S814). Under the condition that the mobile phone and the server establish an end cloud control channel, the mobile phone and the watch establish the end cloud control channel through the server.
As shown in fig. 9, the timing diagram of the above network connection method is different from the TCP-based network connection method in that the first transmission module further obtains the network speed of the network connected to the mobile phone from the system user interface, and sends a reconnection request to the server according to the network speed.
The mobile phone comprises a first connection module, a system user interface, a first transmission module and a first communication module, and the watch comprises a second transmission module and a second connection module.
The first connection module instructs the first transmission module to initiate far-field communication according to an instruction to establish communication connection with the wristwatch. During far-field communication, the first transmission module monitors the network speed of the system user interface from an upper layer. Under the condition that the network connection state is determined to be network connection and the network is available according to the network speed, the first transmission module calls the first communication module to establish an end cloud connection channel with the server, and then the first transmission module and the second transmission module establish an end control channel through the server.
And if the first transmission module determines that the network connection state is network connection according to the network speed and the network is unavailable, inserting a high-priority processing task (for example, ctrlChannelProcWsReconnect) from a CtrlCreateUser task of an upper layer (frame layer), wherein the high-priority task is used for indicating the first communication module to disconnect the network. The first communication module disconnects the connection with the server according to the network disconnection indication.
After the first transmission module sends the network disconnection instruction to the first communication module, if the notification message sent by the first connection module is received, the first transmission module caches the notification message. And after the first transmission module sends the network disconnection instruction to the first communication module, if the first communication module is determined not to be reconnected, marking a reconnection flag bit, wherein the initial value of the reconnection flag bit is the set reconnection times. The first transmission module subtracts 1 from the value of the reconnection flag bit to update the value of the reconnection flag bit in the case where it is determined that the set number of reconnection times is not reached based on the value of the reconnection flag bit. And then, the first transmission module determines whether the reconnection condition is met, and if the reconnection condition is met, the first transmission module instructs the first communication module to execute reconnection action. The first communication module enters a connect state machine according to the indication information of the first transmission module, reestablishes websocket connection, and starts a timer, wherein the duration of the timer is retransmission interval. And when the duration of the timer is up, the first communication module sends a reconnection request to the server. If reconnection fails, the first communication module sends CALLBACK information of LWS_CALLBACK_CLIENT_CONNECTION_ERROR to the first transmission module, and the first transmission module disconnects websocket CONNECTION according to the CALLBACK information. And then, when the first transmission module determines that the set reconnection times are not reached according to the numerical value of the reconnection flag bit, subtracting 1 from the value of the reconnection flag bit to update the value of the reconnection flag bit, and when the reconnection condition is determined to be met, indicating the first communication module to execute reconnection operation again.
And the first transmission module determines that the set reconnection times are reached according to the value of the reconnection flag bit, and indicates the first communication module to disconnect the cloud connection channel under the condition that reconnection failure information returned by the first communication module is received. And the first communication module returns information of the release channel after disconnecting the end cloud connection channel. If the information cached in the first transmission module is not sent successfully, the first communication module returns information of failed sending to the first transmission module.
In the reconnection process, the first transmission module subtracts 1 from the value of the reconnection flag bit to update the value of the reconnection flag bit under the condition that the network connection state is determined to be network connection and the network is available according to the network speed. And then, the first transmission module determines whether the reconnection condition is met, and if the reconnection condition is met, the first transmission module instructs the first communication module to execute reconnection action. The first communication module enters a connect state machine according to the indication information of the first transmission module, reestablishes websocket connection, and starts a timer, wherein the duration of the timer is retransmission interval. When the duration of the timer is reached, the first communication module sends a reconnection request to the server, wherein the reconnection request comprises authentication information of the mobile phone side. The server returns configuration information such as authentication information and heartbeat time of the server side to the first communication module according to the reconnection request, and the first communication module sends the configuration information to the first transmission module, so that the first transmission module and the server establish heartbeat connection, the end cloud connection channel is successfully established, and the mobile phone and the watch establish an end control channel through the server. The first transmission module sends the cached notification message to the second transmission module through the terminal control channel, and the second transmission module returns the information of successful notification message reception to the first connection module after receiving the notification message.
The first transmission module monitors network threads of the first communication module in addition to monitoring the network speed of the system user interface. And the first transmission module is used for reconnecting with the server through the first communication module under the condition of determining that the network is disconnected according to the monitoring result of the network thread, and establishing an end cloud control channel with the server through the first communication module under the condition of recovering the network. The process that the first transmission module is reconnected with the server through the first communication module, and the process that the end cloud control channel is established with the server through the first communication module is consistent with the process of the network connection method based on TCP, and is not repeated here.
The system user interface acquires the network speed, namely the flow change, from the kernel layer according to the set interval, the network speed can reflect the communication capacity of the mobile phone and is used for determining the network connection state of the mobile phone, and when the network speed is smaller than a preset value, namely the communication capacity is poor, the notification information of the mobile phone cannot be sent to the opposite-end watch through the server, so that the message synchronization is realized, the mobile phone sends a reconnection request to the server, the mobile phone can quickly establish new connection with the server, and the instantaneity of the message synchronization is improved.
As shown in fig. 10, a network connection method provided in an embodiment of the present application includes:
S101: and the electronic equipment determines the network connection state of the electronic equipment through the network quality parameters monitored locally.
The network quality parameter is used for representing the WIFI connection state, or the network quality parameter is the network speed of a network connected with the electronic equipment.
The WIFI tracker is used for receiving broadcast information of a WIFI module of the electronic equipment, and the broadcast information carries network quality parameters. The WIFI tracker can determine the WIFI connection state according to the network quality parameters in the broadcast information, and the electronic equipment determines the network connection state of the electronic equipment by monitoring the WIFI connection state detected by the WIFI tracker. When the electronic equipment is connected with the WIFI, the network connection state of the electronic equipment is the WIFI connection state.
In other embodiments, the first transmission module may also determine the network connection state of the electronic device by installing an application program for detecting the WIFI connection state in the electronic device, and monitoring the WIFI connection state of the application program.
The system user interface updates the network speed of the electronic equipment according to the set time interval, and the electronic equipment determines the network connection state of the electronic equipment by monitoring the network speed detected by the system user interface.
The network connection state comprises a connected network and network unavailable state, a connected network and network available state and a disconnected network state, and the network connection state is consistent with the WIFI connection state. If the network speed is smaller than the preset speed, determining that the network connection state of the electronic equipment is a connected network and network unavailable state, and if the network speed is larger than or equal to the preset speed, determining that the network connection state of the electronic equipment is a connected network and network available state.
The electronic device can call the first transmission module to monitor the WIFI connection state detected by the WIFI tracker or monitor the network speed detected by the system user interface when the first transmission module performs far-field communication with the server through the first communication module.
S102: if the network connection state is a first state, the electronic device initiates a reconnection request to the server, wherein the first state represents a connected network and network unavailable state.
Specifically, as shown in fig. 7 or fig. 9, when it is determined that the network connection state of the electronic device is a connected network and the network is unavailable according to the WIFI connection state or the network speed of the network to which the electronic device is connected, the electronic device sends a reconnection request to the server through the first communication module to reestablish connection with the server. The electronic device may instruct the first communication module to initiate a reconnection request to the server through the first transmission module.
When the network connection state is the connected network and the network is unavailable, the electronic equipment receives the notification message to be sent to the server through the first transmission module, and caches the notification message.
In an embodiment, if the electronic device determines that the network connection state is a second state according to the network quality parameter, the second state indicates that the network is connected and the network is available, and the electronic device establishes a new connection channel with the server. Specifically, as shown in fig. 7 or fig. 9, in the case that the network connection state is the connected network and the network is available, the first communication module initiates a reconnection request to the server, and the server returns configuration information, so that the electronic device and the server establish a new connection channel. And under the condition that the electronic equipment establishes a new connection channel with the server, the first transmission module sends the cached notification message to the server through the new connection channel. By rapidly determining the network connection state, a new connection channel can be rapidly established with the server, and further, the instantaneity of synchronizing the notification message on the electronic equipment to another terminal can be ensured.
In the above embodiment, the electronic device determines the network connection state of the electronic device through the network quality parameter monitored locally, and because the network quality parameter can reflect the real-time communication capability of the electronic device, the network connection state of the electronic device can be determined more quickly by monitoring the network quality parameter locally without waiting for the response information of the server, compared with the TCP protocol. When the network connection state is a connected network and the network is unavailable state, the electronic device initiates a reconnection request to the server. During the reconnection, the electronic device does not send a notification message to the server. By quickly reconnecting the server, the electronic device can also quickly reestablish connection with the server, thereby improving the instantaneity of the electronic device for sending the notification message.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
By way of example, fig. 11 shows a schematic structural diagram of an electronic device.
The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identity module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the application, the electronic device may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a universal serial bus (universal serial bus, USB) interface, among others.
It should be understood that the connection relationship between the modules illustrated in the embodiments of the present application is only illustrative, and does not limit the structure of the electronic device. In other embodiments of the present application, the electronic device may also use different interfacing manners, or a combination of multiple interfacing manners in the foregoing embodiments.
The wireless communication function of the electronic device may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc. applied on an electronic device.
The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc. for application on an electronic device.
The electronic device implements display functions via a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store computer executable program code including instructions. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device (e.g., audio data, phonebook, etc.), and so forth. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications of the electronic device and data processing by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
The electronic device may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playing, recording, etc.
The SIM card interface 195 is used to connect a SIM card. The SIM card may be inserted into the SIM card interface 195, or removed from the SIM card interface 195 to enable contact and separation with the electronic device. The electronic device may support 1 or N SIM card interfaces, N being a positive integer greater than 1. The SIM card interface 195 may support Nano SIM cards, micro SIM cards, and the like. The same SIM card interface 195 may be used to insert multiple cards simultaneously. The types of the plurality of cards may be the same or different. The SIM card interface 195 may also be compatible with different types of SIM cards. The SIM card interface 195 may also be compatible with external memory cards. The electronic equipment interacts with the network through the SIM card, so that the functions of communication, data communication and the like are realized. In some embodiments, the electronic device employs esims, namely: an embedded SIM card. The eSIM card can be embedded in the electronic device and cannot be separated from the electronic device.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a camera device/electronic apparatus, a recording medium, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a U-disk, removable hard disk, magnetic or optical disk, etc.
The units described as separate units may or may not be physically separate, and units shown 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 may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
Those of ordinary skill in the art will 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 depends upon the particular application and design constraints imposed on the 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 present application.
Finally, it should be noted that: the foregoing is merely illustrative of specific embodiments of the present application, and the scope of the present application is not limited thereto, but any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method of network connection, comprising:
the method comprises the steps that an electronic device determines a network connection state of the electronic device through a network quality parameter monitored locally;
if the network connection state is a first state, the electronic device sends a reconnection request to a server, wherein the first state represents a connected network and network unavailable state.
2. The method of claim 1, wherein the network quality parameter characterizes WIFI connection status.
3. The method of claim 2, wherein the determining, by the electronic device, the network connection status of the electronic device via the locally monitored network quality parameter comprises:
the electronic equipment determines the network connection state by monitoring network quality parameters detected by a WIFI tracker, wherein the WIFI tracker is used for receiving broadcast information of a WIFI module of the electronic equipment, and the broadcast information carries the network quality parameters.
4. The method of claim 1, wherein the determining, by the electronic device, the network connection status of the electronic device via the locally monitored network quality parameter comprises:
the network connection state of the electronic equipment is determined by the electronic equipment through monitoring the network speed of the electronic equipment detected by a system user interface, and the system user interface is used for updating the network speed of the electronic equipment according to a set time interval.
5. The method according to claim 4, wherein the method further comprises:
and when the network quality parameter is the network speed of the electronic equipment, and the network speed is smaller than a preset speed, the network connection state is the first state.
6. The method of claim 4, wherein after the electronic device initiates a reconnection request to a server, the method further comprises:
and setting the reconnection status bit of the electronic equipment to a preset value, wherein the preset value indicates that the electronic equipment is in a state of initiating a reconnection request to the server.
7. The method of any of claims 1-6, wherein after the electronic device initiates a reconnect request to the server, the method further comprises:
If the network connection state is a second state, the electronic device and the server establish a new connection channel, wherein the second state represents a connected network and a network available state, and the new connection channel is used for sending a notification message cached in the electronic device to the server.
8. The method according to any one of claims 1 to 6, wherein the determining, by the electronic device, the network connection status of the electronic device by locally monitored network quality parameters, comprises:
under the condition that a first transmission module of the electronic equipment performs far-field communication with the server through a first communication module, the electronic equipment calls the first transmission module to monitor the local network quality parameter;
correspondingly, the electronic device sends a reconnection request to a server, including:
and the electronic equipment instructs the first communication module to initiate a reconnection request to the server through the first transmission module.
9. An electronic device comprising a processor for executing a computer program stored in a memory to implement the method of any one of claims 1 to 8.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 8.
CN202311400131.4A 2023-10-26 2023-10-26 Network connection method, electronic device, and computer-readable storage medium Active CN117177386B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311400131.4A CN117177386B (en) 2023-10-26 2023-10-26 Network connection method, electronic device, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311400131.4A CN117177386B (en) 2023-10-26 2023-10-26 Network connection method, electronic device, and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN117177386A true CN117177386A (en) 2023-12-05
CN117177386B CN117177386B (en) 2024-04-12

Family

ID=88937736

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311400131.4A Active CN117177386B (en) 2023-10-26 2023-10-26 Network connection method, electronic device, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN117177386B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090271517A1 (en) * 2008-04-25 2009-10-29 Webmessenger, Inc. Method and apparatus for wireless device reconnection handling
US20140095615A1 (en) * 2012-09-28 2014-04-03 Brother Kogyo Kabushiki Kaisha Communication Terminal, Remote Conference System and Control Program for Communication Terminal
CN106254427A (en) * 2016-07-22 2016-12-21 广东美的暖通设备有限公司 The air conditioning unit means of communication and device
CN111385287A (en) * 2020-02-20 2020-07-07 视联动力信息技术股份有限公司 Network reconnection method and device for service system
CN113521727A (en) * 2021-07-22 2021-10-22 网易(杭州)网络有限公司 Game reconnection method, device, equipment and storage medium
CN115278932A (en) * 2022-07-14 2022-11-01 Oppo广东移动通信有限公司 Network reconnection method, device, terminal equipment and storage medium
CN115767649A (en) * 2022-11-15 2023-03-07 上海游密信息科技有限公司 Instant messaging method, instant messaging device, electronic equipment and storage medium
CN116939000A (en) * 2022-03-30 2023-10-24 大金工业株式会社 Network reconnection method, device, terminal equipment and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090271517A1 (en) * 2008-04-25 2009-10-29 Webmessenger, Inc. Method and apparatus for wireless device reconnection handling
US20140095615A1 (en) * 2012-09-28 2014-04-03 Brother Kogyo Kabushiki Kaisha Communication Terminal, Remote Conference System and Control Program for Communication Terminal
CN106254427A (en) * 2016-07-22 2016-12-21 广东美的暖通设备有限公司 The air conditioning unit means of communication and device
CN111385287A (en) * 2020-02-20 2020-07-07 视联动力信息技术股份有限公司 Network reconnection method and device for service system
CN113521727A (en) * 2021-07-22 2021-10-22 网易(杭州)网络有限公司 Game reconnection method, device, equipment and storage medium
CN116939000A (en) * 2022-03-30 2023-10-24 大金工业株式会社 Network reconnection method, device, terminal equipment and storage medium
CN115278932A (en) * 2022-07-14 2022-11-01 Oppo广东移动通信有限公司 Network reconnection method, device, terminal equipment and storage medium
CN115767649A (en) * 2022-11-15 2023-03-07 上海游密信息科技有限公司 Instant messaging method, instant messaging device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN117177386B (en) 2024-04-12

Similar Documents

Publication Publication Date Title
CN111404802A (en) Notification processing system and method and electronic equipment
WO2021017894A1 (en) Method for using remote sim module, and electronic apparatus
CN111818669A (en) Mobile terminal and data transmission method thereof
CN111464689A (en) Audio output method and terminal equipment
WO2023098234A1 (en) Device connection switching method and apparatus, and electronic device and computer-readable storage medium
CN110149491B (en) Video encoding method, video decoding method, terminal and storage medium
CN113395364B (en) Access method of application server and terminal
CN117177386B (en) Network connection method, electronic device, and computer-readable storage medium
CN116033158B (en) Screen projection method and electronic equipment
WO2022001192A1 (en) Method for transmitting application data, and terminal and system
CN116709226A (en) Communication relay method, electronic device, communication system, and storage medium
CN116346975A (en) Method for synchronizing call records, electronic equipment and readable storage medium
CN117348894A (en) Software upgrading method, terminal equipment and system
CN116709582B (en) Method for assisting conversation and electronic equipment
CN114765605B (en) Resource access method and terminal equipment
CN115550391B (en) Equipment control method and electronic equipment
EP4283464A1 (en) Distributed device capability virtualization method, medium, and electronic device
WO2023088106A1 (en) Method for reducing power consumption, and electronic device
CN117479344B (en) Bluetooth connection method, electronic equipment and readable storage medium
CN116669027B (en) Authentication method, authentication system, terminal equipment and Bluetooth equipment
CN116033592B (en) Method and device for using cellular communication function
CN116708533A (en) Connection switching method, server stopping method, terminal equipment and server
CN116709581B (en) Call compensation method, terminal device, communication system and storage medium
CN114173317B (en) Method for transmitting data and electronic equipment
CN117992414A (en) Resource sharing method and electronic equipment

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