Equipment connection method and device, electronic equipment and storage medium
By automatically creating the first network card when the wireless network card state meets the preset conditions, and setting the wireless connection module to the wake-up state before creating the device identity, the problem of WiFi P2P connection is solved, and faster connection establishment is achieved , improves the user experience.
Patent Information
- Application Number
- CN202311002093.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-09
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the total time to establish a WiFi P2P connection is long, which affects the user experience.
When the state of the wireless network card meets the preset conditions, the first network card is automatically created to establish a point-to-point wireless connection channel between devices, and set the wireless connection module to the wake-up state before creating the device identity.
It saves time-consuming to create a network card, reduces the total time-consuming to establish a WiFi P2P connection, effectively shortens the waiting time required for point-to-point wireless connections, and improves the user experience.
Smart Images

Figure CN119485785A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of wireless connection technology, and in particular to a device connection method, apparatus, electronic device and storage medium. Background Art
[0002] WiFi P2P (Wi-Fi Peer-to-Peer, Wireless High Fidelity Point-to-Point) protocol is a wireless connection protocol launched by the Wi-Fi Alliance. It can also be called WiFi Direct, WiFi Direct Connection, WLAN (Wireless Lan, Wireless Local Area Network) Direct Connection, etc. When two electronic devices are wirelessly connected based on the WiFi P2P protocol, they can be connected to each other without using a wireless router. WiFi P2P connection is decentralized, efficient, and scalable, and is widely used in WiFi screen projection, file transfer, point-to-point device communication, etc. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a device connection method, an apparatus, an electronic device and a storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. The device connection method includes:
[0005] When the state of the wireless network card meets a preset condition, creating a first network card, wherein the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0006] Sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device;
[0007] Creating a device identity, where the device identity is a group owner identity or a group client identity;
[0008] Based on the point-to-point wireless connection channel, a communication connection is established with the second device using the device identity.
[0009] In an exemplary embodiment, the method further comprises:
[0010] After creating the first network card, the state of the first network card is set to an inactive state.
[0011] In an exemplary embodiment, the method further comprises:
[0012] After the first network card is created, if a second network card is created, deleting the first network card;
[0013] Among them, the priority of the network card with a later creation time is higher than the network card with an earlier creation time.
[0014] In an exemplary embodiment, the method further comprises:
[0015] After the second network card is deleted, the first network card is recreated.
[0016] In an exemplary embodiment, the state of the wireless network card satisfies a preset condition, including:
[0017] The status of the wireless network card does not satisfy any of the following conditions:
[0018] The primary wireless station network card and the secondary wireless station network card are both activated;
[0019] The main wireless station network card is in an inactive state, and the wireless communication module is in a closed state;
[0020] The main wireless site network card is in a destroyed state;
[0021] The main wireless site network card and the main wireless access point network card are both in an activated state;
[0022] The first network card is in an activated state or an inactivated state.
[0023] In an exemplary embodiment, the method further comprises:
[0024] Before creating the device identity, the state of the wireless connection module is set to an awake state.
[0025] In an exemplary embodiment, the method further comprises:
[0026] When the point-to-point wireless connection with the second device is established, setting the state of the wireless connection module to a preset state; or
[0027] When the point-to-point wireless connection established with the second device is interrupted, setting the state of the wireless connection module to a preset state after a preset time period;
[0028] The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
[0029] In an exemplary embodiment, when the device identity is the group owner identity, the method further includes:
[0030] receiving a query message sent by the second device, wherein the query message is used to determine whether the group owner identity is successfully created;
[0031] Sending a response message to the second device, where the response message is used to indicate that the group owner identity is successfully created.
[0032] In an exemplary embodiment, when the device identity is the group client identity, the method further includes:
[0033] Sending a query message to the second device, where the query message is used to determine whether the group owner identity of the second device is successfully created;
[0034] Receive response information sent by the second device, where the response information is used to indicate that the group owner identity of the second device is successfully created.
[0035] According to a second aspect of an embodiment of the present disclosure, there is provided a device connection apparatus, applied to a first device, the device connection apparatus comprising:
[0036] The acceleration module is configured to create a first network card when the state of the wireless network card meets a preset condition, wherein the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0037] a transceiver module, configured to send a point-to-point wireless connection request to the second device, or to receive a point-to-point wireless connection request sent by the second device;
[0038] A creation module, configured to create a device identity, wherein the device identity is a group owner identity or a group client identity;
[0039] The connection module is configured to establish a communication connection with the second device based on the point-to-point wireless connection channel using the device identity.
[0040] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0041] processor;
[0042] a memory for storing processor-executable instructions;
[0043] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.
[0044] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure.
[0045] The above method disclosed in the present invention has the following beneficial effects: before sending or receiving a point-to-point wireless connection request, the first network card is automatically created, and when a WiFi P2P connection is required, the first network card can be directly used without creating a network card, thereby saving the time spent on creating a network card, thereby reducing the total time spent on establishing a WiFi P2P connection, effectively shortening the waiting time required for a point-to-point wireless connection, and improving the user experience.
[0046] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0048] Figure 1 is a flow chart of a device connection method according to an exemplary embodiment;
[0049] Figure 2 is a schematic diagram of a screen projection interface according to an exemplary embodiment;
[0050] Figure 3 is a flow chart of a device connection method according to an exemplary embodiment;
[0051] Figure 4 is a flow chart of a device connection method according to an exemplary embodiment;
[0052] Figure 5A is a graph showing experimental data results of the time consumption for creating a device identity according to an exemplary embodiment;
[0053] Figure 5B is a graph showing experimental data results of the time consumption of association connection according to an exemplary embodiment;
[0054] Figure 6 is a flow chart of a device connection method according to an exemplary embodiment;
[0055] Figure 7 is a flow chart of a device connection method according to an exemplary embodiment;
[0056] Figure 8 is a flow chart of a device connection method according to an exemplary embodiment;
[0057] Fig. 9 is a flow chart of a device connection method according to an exemplary embodiment;
[0058] Fig.10is a block diagram of a device connection apparatus according to an exemplary embodiment;
[0059] Fig.11 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0060] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0061] The service response speed based on WiFi P2P connection is limited by the speed of WiFi P2P connection establishment. The faster the link is established, the faster the WiFi P2P connection between devices is, the shorter the waiting time for users, and the better the user experience. However, in the related art, the entire process of WiFi P2P connection establishment includes three steps: creating a WiFi P2P network card, creating a device role, and establishing a connection. Each step takes a long time, which leads to a long total time consumption for WiFi P2P connection establishment. Through test statistics, it is found that the total time consumption for WiFi P2P connection establishment in the related art ranges from 1.5 seconds to 3 seconds, which seriously affects the user experience.
[0062] In an exemplary embodiment of the present disclosure, in order to overcome the problem of long time consumption in establishing a WiFi P2P connection in the related art, a device connection method is provided, which is applied to a first device, and the method includes: when the state of the wireless network card meets the preset conditions, creating a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device; sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device; creating a group owner identity, based on the point-to-point wireless connection channel, establishing a communication connection with the second device as a group owner; or creating a group client identity, based on the point-to-point wireless connection channel, establishing a communication connection with the second device as a group client. The method in the embodiment of the present disclosure automatically creates the first network card before sending or receiving the point-to-point wireless connection request, and can directly use the first network card when a WiFi P2P connection is required, without creating a network card, so that the time consumption of creating the network card can be saved, thereby reducing the total time consumption of establishing a WiFi P2P connection, effectively shortening the waiting time required for the point-to-point wireless connection, and improving the user experience.
[0063] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 1 is a flow chart of a device connection method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:
[0064] Step S101, when the state of the wireless network card meets a preset condition, creating a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0065] Step S102, sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device;
[0066] Step S103, creating a device identity, where the device identity is a group owner identity or a group client identity;
[0067] Step S104: establishing a communication connection with the second device as a device based on the point-to-point wireless connection channel.
[0068] In the disclosed embodiment, the first device and the second device are both electronic devices that support WiFi P2P connection (point-to-point wireless connection) function, for example, they can be terminal devices such as smart phones, tablets, computers, etc., or they can be smart systems or smart devices such as smart TVs, smart speakers, car smart systems, projectors, etc., or they can be smart wearable devices such as smart watches and smart glasses. The network card in the disclosed embodiment is a virtual network card, which is a control class corresponding to the hardware network card at the program level for controlling the hardware network card.
[0069] In step S101, WiFi connection (wireless connection) includes multiple connection modes, each of which requires the establishment of a wireless connection channel by creating a corresponding WiFi network card (wireless network card). The wireless connection channel is a radio frequency link established based on the WiFi chip. However, due to the limitation of the WiFi chip on the radio frequency link, a single WiFi chip can only have two radio frequency links working at the same time, that is, a single WiFi chip can only have two WiFi network cards at most. When there are two WiFi network cards, if a third network card is created, the first network card created will be automatically destroyed (i.e. automatically deleted) due to the conflict, and the radio frequency link resources will be released to the third network card to be created.
[0070] WiFi P2P connection is a type of WiFi connection, and it is also necessary to create a corresponding WiFi network card to establish a point-to-point wireless connection channel. The first network card is a WiFi P2P network card (point-to-point wireless connection network card), which is used to establish a point-to-point wireless connection channel between the first device and the second device, that is, to establish a WiFi P2P connection link between the first device and the second device.
[0071] The status of the wireless network card includes inactive state, active state, and destroyed state. Among them, the inactive state is the state after the wireless network card is created and before the wireless connection is established. The active state is the working state of the wireless network card when the wireless connection is established. The inactive state and the active state both indicate that the wireless network card has been created and needs to occupy the radio frequency link resources of the WiFi chip. The destroyed state means that the wireless network card has been deleted and the radio frequency link resources previously occupied will be released.
[0072] Since the first network card is created before the WiFi P2P connection, when the first network card is created, other wireless network cards cannot be destroyed due to conflicts due to the creation of the first network card, thereby affecting the functions of other wireless network cards. The preset condition is: under the current WiFi chip conditions, the state of the wireless network card can indicate that there are idle RF link resources for the first network card to use. For example, when there is only a single WiFi chip in the first device, if there is only one network card in an activated state, that is, only one RF link on the WiFi chip is in a working state, then the state of the wireless network card meets the preset conditions.
[0073] It is understandable that when the number of WiFi chips in the first device changes, the preset conditions will also change accordingly; when the restrictions of the WiFi chip on the radio frequency link change, the preset conditions will also change accordingly.
[0074] The creation of the first network card in this step is that when the state of the wireless network card meets the preset conditions, the first device automatically performs the operation of creating the first network card. The WiFi P2P connection acceleration function can be set in the first device. When the function is enabled, it supports automatic creation of the first network card. When the function is disabled, it does not support automatic creation of the first network card. The function can be enabled by default, or the user can set whether to enable the function.
[0075] In step S102, when the first device receives a connection instruction for a point-to-point wireless connection with the second device, the first device sends a point-to-point wireless connection request to the second device. When the second device receives a connection instruction for a point-to-point wireless connection with the second device, the second device sends a point-to-point wireless connection request to the first device, and the first device receives the point-to-point wireless connection request. The sending or receiving operation of the connection request is performed through the communication interface of the WiFi module and the WiFi driver at the bottom layer, for example, through the Socket communication interface or the NetLink communication interface.
[0076] The above-mentioned connection instruction can be a connection instruction generated based on user operation. For example, when screen projection or file transfer is performed based on WiFi P2P connection, by clicking on the electronic device to which the screen is to be projected on the screen projection interface, a connection instruction for point-to-point wireless connection with the electronic device is generated. The connection instruction can also be a connection instruction generated based on default settings. For example, in the electronic device ecosystem of the same manufacturer, screen transmission, control instruction transmission, or information transmission is performed between electronic devices based on WiFi P2P connection. It is determined when a connection is needed based on the default settings of the electronic device, and a corresponding connection instruction is generated.
[0077] In one example, the first device is a mobile phone and the second device is a tablet; or the first device is a tablet and the second device is a mobile phone. When both the mobile phone and the tablet support the WiFi P2P connection function, if the user wants to project the mobile phone screen to the tablet, the WiFi P2P connection can be used for projection. Figure 2 is a schematic diagram of a screen projection interface according to an exemplary embodiment. Figure 2 As shown, in the projection interface of the mobile phone, electronic devices that can be used for projection and the screens that can be projected in the mobile phone are displayed in the form of cards. For example, electronic devices that can be used for projection include a "tablet", and the screens that can be projected in the mobile phone include "mobile music" and "mobile screen". The user presses and holds the card corresponding to the "mobile screen" and drags it to the tablet, then the mobile phone receives a connection instruction for a point-to-point wireless connection with the tablet, and sends a point-to-point wireless connection request to the tablet. The tablet receives the point-to-point wireless connection request, and subsequently successfully establishes a point-to-point wireless connection between the mobile phone and the tablet, then the mobile phone screen can be projected to the tablet, and the mobile phone screen is displayed on the tablet.
[0078] In step S103, when performing a WiFi P2P connection, all devices participating in the connection form a P2P group (P2P Group). Each device participating in the connection can be called a P2P device and has a device identity, also known as a P2P role. The device identity includes the group owner (Group Owner, GO) identity and the group client (Group Client, GC) identity. A device with a GO identity can also be called a GO device, and a device with a GC identity can also be called a GC device. Device identities can be negotiated between devices participating in the connection. Each device can be a GO identity or a GC identity. However, there is only one GO device in a P2P group, and there can be multiple GC devices.
[0079] The first device can be a GO device or a GC device. After the first device sends a point-to-point connection request to the second device or receives a point-to-point connection request from the second device, the first device negotiates with the second device to determine their respective device identities through negotiation. For example, since the power consumption requirement of a GO device is usually greater than that of a GC device, the device that needs to save power consumption is determined as a GC device during negotiation. In the above example of projecting the screen of a mobile phone to a tablet, out of consideration for saving power consumption of the mobile phone, when the mobile phone and the tablet negotiate, the tablet will be determined as a GO device and the mobile phone will be determined as a GC device.
[0080] When the first device is determined to be a GO device, the second device is a GC device, the first device creates a group owner identity, and the second device creates a group client identity; when the first device is determined to be a GC device, the second device is a GO device, the first device creates a group client identity, and the second device creates a group client identity. When creating a device identity, it is created by the WifiP2pService module in the first device.
[0081] In step S104, after sending or receiving the point-to-point wireless connection request, the first device activates the first network card, and the first network card uses radio frequency resources to establish a point-to-point wireless connection channel. Based on the channel, the first device establishes a communication connection with the second device as a device.
[0082] In an exemplary embodiment of the present disclosure, before sending or receiving a point-to-point wireless connection request, a first network card is automatically created, so that when a WiFi P2P connection is required, the first network card can be directly used without creating a network card. This can save time in creating a network card, thereby reducing the total time required to establish a WiFi P2P connection, effectively shortening the waiting time required for a point-to-point wireless connection, and improving the user experience.
[0083] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 3 is a flow chart of a device connection method according to an exemplary embodiment. Figure 3 As shown, the following steps are included:
[0084] Step S301, when the state of the wireless network card meets a preset condition, create a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0085] Step S302, setting the state of the first network card to an inactive state;
[0086] Step S303: if the second network card is created, the first network card is deleted; wherein the priority of the network card with a later creation time is higher than the network card with an earlier creation time;
[0087] Step S304, after the second network card is deleted, re-create the first network card;
[0088] Step S305, sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device;
[0089] Step S306, creating a device identity, where the device identity is a group owner identity or a group client identity;
[0090] When the device identity is a group owner identity, execute steps S307 to S308; when the device identity is a group client identity, execute steps S309 to S310;
[0091] Step S307, receiving the query information sent by the second device, the query information is used to determine whether the group owner identity is successfully created;
[0092] Step S308, sending a response message to the second device, where the response message is used to indicate that the group owner identity is successfully created;
[0093] Step S309, sending a query message to the second device, the query message is used to determine whether the group owner identity of the second device is successfully created;
[0094] Step S310, receiving response information sent by the second device, where the response information is used to indicate that the group owner identity of the second device is successfully created;
[0095] Step S311: Establish a communication connection with a second device based on a point-to-point wireless connection channel as a device.
[0096] The specific implementation of step S301 refers to the implementation of step S101, and the specific implementation of steps S305 to S307 refers to the implementation of steps S102 to S104, which will not be repeated here.
[0097] In some implementations, in step S301, when at most two radio frequency links can work simultaneously in the first device, the state of the wireless network card satisfies a preset condition, including:
[0098] The status of the wireless network card does not meet any of the following conditions:
[0099] The primary wireless station network card and the secondary wireless station network card are both activated;
[0100] The main wireless station network card is in an inactive state, and the wireless communication module is in a closed state;
[0101] The main wireless station network card is in a destroyed state;
[0102] The main wireless station network card and the main wireless access point network card are both activated;
[0103] The first network card is in an activated state or an inactivated state.
[0104] The types of wireless network cards include wireless station (Wi-Fi Station, WiFi STA) network cards, wireless access point (Wi-Fi Access Point, WiFi SAP) network cards and WiFi P2P network cards. When the main wireless station network card and the auxiliary wireless station network card are both in an activated state, or when the main wireless station network card and the main wireless access point network card are both in an activated state, it means that both radio frequency links are in a working state. If the first network card is created at this time, one of the network cards in the activated state will be destroyed, thereby affecting the function of the network card. Therefore, the first network card is not created at this time. When the main wireless station network card is in an inactive state and the wireless communication module is in a closed state, it means that the electronic device has not turned on the WiFi function and the electronic device does not support WiFi P2P connection. Therefore, the first network card is not created at this time. When the main wireless station network card is in a destroyed state, it means that the WiFi function is occupied by other functions and WiFi P2P connection is not supported at this time. Therefore, the first network card is not created at this time. When the first network card is in an activated state or an inactive state, it means that the first network card has been created in the electronic device and there is no need to create the first network card again at this time.
[0105] Step S302, after creating the first network card, the state of the wireless network card is in an inactive state, and after sending or receiving a point-to-point wireless connection request, the state of the wireless network card is switched from an inactive state to an active state. However, if the network card is not used within a preset time period, that is, it has not been switched to an active state within the preset time period, the first network card will be automatically destroyed after the preset time period, that is, it will be switched to a destroyed state. Therefore, in order to prevent the first network card from being created repeatedly, after the first network card is created and before the first network card is switched to an active state, the first network card needs to be kept in an inactive state to prevent the first network card from being destroyed. The preset time period is an empirical value determined by the communication protocol of the wireless network card.
[0106] In one example, after the first network card is created and before the first network card is switched to an activated state, the state of the first network card is set to an inactivated state to prevent the first network card from being destroyed due to not being activated for a preset period of time.
[0107] In another example, after creating the first network card, the state of the first network card is set to an inactive state at a preset time interval, wherein the preset time interval is less than or equal to a preset duration, to prevent the first network card from being destroyed due to inactivity during the preset duration.
[0108] After the first network card is created, the state of the first network card is set to an inactive state, so as to avoid the first network card being destroyed due to not being activated for a preset period of time, thereby preventing the first network card from being repeatedly created. Meanwhile, the first network card in an inactive state can support initiating a WiFi P2P connection at any time, thereby further shortening the total time consumed in establishing a WiFi P2P connection.
[0109] In step S303, the second network card is another wireless connection network card that conflicts with the first network card, such as an auxiliary WiFi network card or a WiFi hotspot network card. After the first network card is created, if there are two network cards in the electronic device that occupy the radio frequency link resources of the WiFi chip, based on the network card priority principle: the priority of the network card with a later creation time is higher than that of the network card with an earlier creation time. If the second network card is created at this time, and the second network card also needs to occupy the link resources of the WiFi chip, that is, the second network card conflicts with the first network card, since the priority of the two existing network cards is lower than that of the second network card, it is necessary to delete one of the network cards that occupies the radio frequency link resources. Since the WiFi P2P connection has not yet started, the first network card has not yet been activated. In order not to affect the functions of other network cards, after the first network card is created, if the second network card is created, the first network card will be deleted, that is, the first network card will be destroyed to release the radio frequency resources for the second network card to use.
[0110] After the first network card is created, if the second network card is created, deleting the first network card can avoid the problem that other wireless connection functions cannot be used.
[0111] In step S304, when the second network card is no longer used, the second network card is deleted, that is, the second network card is destroyed. After the second network card is destroyed, the radio frequency resources occupied by the second network card are also released, and the first network card is recreated at this time.
[0112] In the exemplary embodiments of the present disclosure, step S301 and step S305-step S306 and step S311 can be implemented as independent embodiments, step S302, step S303, step S304, step S307-step S310 are optional, and one or more of these steps can be omitted or replaced in different embodiments.
[0113] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 4 is a flow chart of a device connection method according to an exemplary embodiment. Figure 4 As shown, the following steps are included:
[0114] Step S401, sending a point-to-point wireless connection request to a second device, or receiving a point-to-point wireless connection request sent by a second device;
[0115] Step S402, creating a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0116] Step S403, setting the state of the wireless connection module to the awake state;
[0117] Step S404, creating a device identity, where the device identity is a group owner identity or a group client identity;
[0118] Step S405, establishing a communication connection with the second device as a device based on the point-to-point wireless connection channel;
[0119] Step S406, when the point-to-point wireless connection with the second device is completed, the wireless connection module is set to a preset state; or when the point-to-point wireless connection with the second device is interrupted, the wireless connection module is set to a preset state after a preset time.
[0120] The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
[0121] The specific implementation of step S401 refers to the implementation of step S102, and the specific implementation of steps S404 to S405 refers to the implementation of steps S103 to S104, which will not be repeated here.
[0122] In step S402, the first network card is a WiFi P2P network card (point-to-point wireless connection network card), and the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device, that is, to establish a WiFi P2P connection link between the first device and the second device.
[0123] The first network card is created after sending or receiving a point-to-point connection request. Therefore, there is no need to determine the status of the wireless network card. If there are currently two wireless network cards occupying radio frequency resources, when the first network card is created, one of the wireless network cards will be destroyed to release radio frequency resources for use by the first network card.
[0124] In step S403, after the first network card is created, before the device identity is created, the state of the wireless connection module is set to the awake state, that is, the WiFi is set to the awake state. At this time, after the determined device identity is negotiated, when a device identity creation request is sent to the WifiP2pService module in the first device, the WifiP2pService module can quickly respond to the device identity creation request to quickly create the device identity and shorten the time to create the device identity. In addition, when the WiFi is in the awake state, it can also quickly respond to the associated connection with the second device when establishing a point-to-point wireless connection with the second device, further shortening the total time to establish the WiFi P2P connection.
[0125] In one example, since the WiFi is in a dormant state and responds slowly when the device identity is created in the related art, it takes a long time to create the device identity; in this embodiment, the WiFi is in an awake state and responds quickly when the device identity is created, so it takes a short time to create the device identity. Figure 5A The experimental data results of the time consumption for creating a device identity are shown. Compared with the related art, the time consumption for creating a device identity can be reduced by 15% by using the solution in this embodiment.
[0126] In another example, in the related art, when the second device is associated and connected, the WiFi needs to be switched from the dormant state to the awake state first, so the association and connection takes a long time; in this embodiment, when the second device is associated and connected, the WiFi is already in the awake state and the association and connection can be directly performed, so the association and connection takes a short time. Figure 5B The experimental data results of the time consumption of the associated connection show that, compared with the related art, the time consumption of the associated connection with the second device can be reduced by 30% by using the solution in this embodiment.
[0127] The WiFi P2P connection acceleration function can be set in the first device. When the function is enabled, it supports setting the WiFi to an awake state before creating a device identity; when the function is disabled, it does not support setting the WiFi to an awake state before creating a device identity. The WiFi P2P connection acceleration function can be enabled by default, or the user can set whether to enable the WiFi P2P connection acceleration function.
[0128] In step S406, when it is detected that the point-to-point wireless connection with the second device is terminated, for example, when it is detected that the connection is established successfully or fails to be established, the wireless connection module is set to a preset state, that is, the WiFi is set to a preset state. When it is detected that the point-to-point wireless connection with the second device is interrupted, for example, when it is detected that the connection is abnormally interrupted, the wireless connection module is set to a preset state after a preset time, that is, the WiFi is set to a preset state after a preset time.
[0129] The preset time is an empirical value, for example, 1.5 seconds. When an abnormal interruption in establishing a connection is detected, the connection may be re-initiated after a period of time, and the WiFi is set to the preset state after the preset time, which can avoid the problem of slow WiFi response when resending the connection.
[0130] The preset state is determined based on the preset battery power consumption strategy, which is used to characterize the mapping relationship between the preset scenario and the preset state. The preset battery power consumption strategy is mainly used to save battery power. WiFi is set to the awake state only in necessary scenarios, and WiFi is in the dormant state in other scenarios. Therefore, setting WiFi to the preset state after the connection ends or is abnormally interrupted is conducive to saving battery power.
[0131] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 6 is a flow chart of a device connection method according to an exemplary embodiment. Figure 6 As shown, the following steps are included:
[0132] Step S601, when the state of the wireless network card meets a preset condition, create a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0133] Step S602, sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device;
[0134] Step S603, setting the state of the wireless connection module to the awake state;
[0135] Step S604, creating a device identity, where the device identity is a group owner identity or a group client identity;
[0136] Step S605, establishing a communication connection with the second device as a device based on the point-to-point wireless connection channel;
[0137] Step S606, when the point-to-point wireless connection with the second device is completed, the wireless connection module is set to a preset state; or when the point-to-point wireless connection with the second device is interrupted, the wireless connection module is set to a preset state after a preset time.
[0138] The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
[0139] The specific implementation of step S601-step S602 refers to the implementation of step S101-step S102, and the specific implementation of step S603-step S606 refers to the implementation of step S403-step S406, which will not be repeated here.
[0140] In an exemplary embodiment of the present disclosure, a WiFi P2P connection acceleration function can be set in the first device. When the function is enabled, it supports automatically creating the first network card before sending or receiving a point-to-point wireless connection request, and setting the WiFi to a wake-up state before creating a device identity. When the function is disabled, it does not support automatically creating the first network card before sending or receiving a point-to-point wireless connection request, and setting the WiFi to a wake-up state before creating a device identity. The WiFi P2P connection acceleration function can be set to be enabled by default, or the user can set whether to enable the WiFi P2P connection acceleration function. In this embodiment, while saving the time spent on creating the first network card, it can quickly respond to device identity creation requests and associated connection requests, further reducing the total time spent on establishing a WiFi P2P connection, effectively shortening the waiting time required for a point-to-point wireless connection, and greatly improving the user experience.
[0141] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 7 is a flow chart of a device connection method according to an exemplary embodiment. Figure 7 As shown, the following steps are included:
[0142] Step S701, when the state of the wireless network card meets a preset condition, create a first network card, the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0143] Step S702, setting the state of the first network card to an inactive state;
[0144] Step S703: If the second network card is created, the first network card is deleted; wherein the priority of the network card with a later creation time is higher than the network card with an earlier creation time;
[0145] Step S704, after the second network card is deleted, re-create the first network card;
[0146] Step S705, sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device;
[0147] Step S706, setting the state of the wireless connection module to the awake state;
[0148] Step S707, creating a device identity, where the device identity is a group owner identity or a group client identity;
[0149] When the device identity is a group owner identity, execute steps S708 to S709; when the device identity is a group client identity, execute steps S710 to S711;
[0150] Step S708, receiving the query information sent by the second device, the query information is used to determine whether the group owner identity is successfully created;
[0151] Step S709, sending a response message to the second device, where the response message is used to indicate that the group owner identity is successfully created;
[0152] Step S710, sending a query message to the second device, the query message is used to determine whether the group owner identity of the second device is successfully created;
[0153] Step S711, receiving response information sent by the second device, where the response information is used to indicate that the group owner identity of the second device is successfully created;
[0154] Step S712, establishing a communication connection with the second device as a device based on the point-to-point wireless connection channel;
[0155] Step S713, when the point-to-point wireless connection with the second device is completed, the wireless connection module is set to a preset state; or when the point-to-point wireless connection with the second device is interrupted, the wireless connection module is set to a preset state after a preset time.
[0156] The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
[0157] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Figure 8 is a flow chart of a device connection method according to an exemplary embodiment. Figure 8 As shown, the following steps are included:
[0158] Step S8-1, creating a P2P network card;
[0159] Step S8-2, determining whether P2P connection acceleration is supported;
[0160] If connection acceleration is supported, execute step S8-3; if connection acceleration is not supported, execute step S8-4 or step S8-7;
[0161] Step S8-3, automatically create a P2P network card;
[0162] Step S8-4, whether the P2P network card is created;
[0163] If yes, go to step S8-5; if no, go to step S8-7;
[0164] Step S8-5, the P2P network card is created successfully;
[0165] Step S8-6, keep the P2P network card in Inactive state;
[0166] Step S8-7, P2P network card creation fails.
[0167] In an exemplary embodiment of the present disclosure, a device connection method is provided, which is applied to a first device. Fig. 9 is a flow chart of a device connection method according to an exemplary embodiment. Fig. 9 As shown, the following steps are included:
[0168] Step S9-1, start creating GO;
[0169] Step S9-2, determining whether to perform P2P connection acceleration;
[0170] If the connection is accelerated, execute step S9-3; if the connection is not accelerated, execute step S9-4;
[0171] Step S9-3, adjust the WiFi power management policy and set the WiFi to wake-up state;
[0172] Step S9-4, whether GO is created successfully;
[0173] If yes, go to step S9-5; if no, go to step S9-6;
[0174] Step S9-5, P2P GO is created successfully;
[0175] Step S9-6, connection failure ends;
[0176] Step S9-7, adjust the WiFi power management policy and set the WiFi to a preset state.
[0177] In an exemplary embodiment of the present disclosure, a device connection apparatus is provided, which is applied to a first device. Fig.10 is a block diagram of a device connection apparatus according to an exemplary embodiment. Fig.10 As shown, including:
[0178] The acceleration module 1001 is configured to create a first network card when the state of the wireless network card meets a preset condition, and the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device;
[0179] The transceiver module 1002 is configured to send a point-to-point wireless connection request to the second device, or receive a point-to-point wireless connection request sent by the second device;
[0180] A creation module 1003 is configured to create a device identity, where the device identity is a group owner identity or a group client identity;
[0181] The connection module 1004 is configured to establish a communication connection with the second device based on the point-to-point wireless connection channel as a device.
[0182] In an exemplary embodiment, the acceleration module 1001 is further configured to:
[0183] After the first network card is created, the state of the first network card is set to an inactive state.
[0184] In an exemplary embodiment, the acceleration module 1001 is further configured to:
[0185] After the first network card is created, if the second network card is created, delete the first network card;
[0186] Among them, the priority of the network card with a later creation time is higher than the network card with an earlier creation time.
[0187] In an exemplary embodiment, the acceleration module 1001 is further configured to:
[0188] After the second network card is deleted, recreate the first network card.
[0189] In an exemplary embodiment, the state of the wireless network card satisfies a preset condition, including:
[0190] The status of the wireless network card does not meet any of the following conditions:
[0191] The primary wireless station network card and the secondary wireless station network card are both activated;
[0192] The main wireless station network card is in an inactive state, and the wireless communication module is in a closed state;
[0193] The main wireless station network card is in a destroyed state;
[0194] The main wireless station network card and the main wireless access point network card are both activated;
[0195] The first network card is in an activated state or an inactivated state.
[0196] In an exemplary embodiment, the acceleration module 1001 is further configured to:
[0197] Before creating the device identity, set the state of the wireless connection module to the awake state.
[0198] In an exemplary embodiment, the acceleration module 1001 is further configured to:
[0199] When the point-to-point wireless connection with the second device is established, setting the state of the wireless connection module to a preset state; or
[0200] When the point-to-point wireless connection established with the second device is interrupted, setting the state of the wireless connection module to a preset state after a preset time period;
[0201] The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
[0202] In an exemplary embodiment, when the device identity is a group owner identity, the transceiver module 1002 is further configured to:
[0203] receiving a query message sent by the second device, where the query message is used to determine whether the group owner identity is successfully created;
[0204] A response message is sent to the second device, where the response message is used to indicate that the group owner identity is successfully created.
[0205] In an exemplary embodiment, when the device identity is a group client identity, the transceiver module 1002 is further configured to:
[0206] Sending a query message to the second device, where the query message is used to determine whether the group owner identity of the second device is successfully created;
[0207] Receive response information sent by the second device, where the response information is used to indicate that the group owner identity of the second device is successfully created.
[0208] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0209] Fig.11 is a block diagram of an electronic device 1100 according to an exemplary embodiment.
[0210] Reference Fig.11 , the electronic device 1100 may include one or more of the following components: a processing component 1102 , a memory 1104 , a power component 1106 , a multimedia component 1108 , an audio component 1110 , an input / output (I / O) interface 1112 , a sensor component 1114 , and a communication component 1116 .
[0211] The processing component 1102 generally controls the overall operation of the electronic device 1100, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1102 may include one or more processors 1120 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1102 may include one or more modules to facilitate the interaction between the processing component 1102 and other components. For example, the processing component 1102 may include a multimedia module to facilitate the interaction between the multimedia component 1108 and the processing component 1102.
[0212] The memory 1104 is configured to store various types of data to support operations on the electronic device 1100. Examples of such data include instructions for any application or method operating on the electronic device 1100, contact data, phone book data, messages, pictures, videos, etc. The memory 1104 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0213] The power supply component 1106 provides power to various components of the electronic device 1100. The power supply component 1106 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1100.
[0214] The multimedia component 1108 includes a screen that provides an output interface between the electronic device 1100 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1108 includes a front camera and / or a rear camera. When the electronic device 1100 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0215] The audio component 1110 is configured to output and / or input audio signals. For example, the audio component 1110 includes a microphone (MIC), and when the electronic device 1100 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1104 or sent via the communication component 1116. In some embodiments, the audio component 1110 also includes a speaker for outputting audio signals.
[0216] I / O interface 1112 provides an interface between processing component 1102 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0217] The sensor assembly 1114 includes one or more sensors for providing various aspects of status assessment for the electronic device 1100. For example, the sensor assembly 1114 can detect the open / closed state of the electronic device 1100, the relative positioning of components, such as the display and keypad of the electronic device 1100, and the sensor assembly 1114 can also detect the position change of the electronic device 1100 or a component of the electronic device 1100, the presence or absence of user contact with the electronic device 1100, the orientation or acceleration / deceleration of the electronic device 1100, and the temperature change of the electronic device 1100. The sensor assembly 1114 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1114 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1114 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0218] The communication component 1116 is configured to facilitate wired or wireless communication between the electronic device 1100 and other devices. The electronic device 1100 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1116 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1116 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0219] In an exemplary embodiment, the electronic device 1100 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0220] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1104 including instructions, and the instructions can be executed by a processor 1120 of the electronic device 1100 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0221] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a device connection method, the method including any of the above methods.
[0222] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0223] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A device connection method, characterized in that: Applied to a first device, the device connection method includes: When the state of the wireless network card meets a preset condition, creating a first network card, wherein the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device; Sending a point-to-point wireless connection request to the second device, or receiving a point-to-point wireless connection request sent by the second device; Creating a device identity, where the device identity is a group owner identity or a group client identity; Based on the point-to-point wireless connection channel, a communication connection is established with the second device using the device identity.
2. The device connection method according to claim 1, characterized in that: The method further comprises: After creating the first network card, the state of the first network card is set to an inactive state.
3. The device connection method according to claim 1, characterized in that: The method further comprises: After the first network card is created, if a second network card is created, deleting the first network card; Among them, the priority of the network card with a later creation time is higher than the network card with an earlier creation time.
4. The device connection method according to claim 3, characterized in that: The method further comprises: After the second network card is deleted, the first network card is recreated.
5. The device connection method according to any one of claims 1 to 4, characterized in that: The state of the wireless network card meets the preset conditions, including: The status of the wireless network card does not satisfy any of the following conditions: The primary wireless station network card and the secondary wireless station network card are both activated; The main wireless station network card is in an inactive state, and the wireless communication module is in a closed state; The main wireless site network card is in a destroyed state; The main wireless site network card and the main wireless access point network card are both in an activated state; The first network card is in an activated state or an inactivated state.
6. The device connection method according to any one of claims 1 to 4, characterized in that: The method further comprises: Before creating the device identity, the state of the wireless connection module is set to an awake state.
7. The device connection method according to claim 6, characterized in that: The method further comprises: When the point-to-point wireless connection with the second device is established, setting the state of the wireless connection module to a preset state; or When the point-to-point wireless connection established with the second device is interrupted, setting the state of the wireless connection module to a preset state after a preset time period; The preset state is determined based on a preset battery power consumption strategy, and the preset battery power consumption strategy is used to characterize a mapping relationship between a preset scenario and a preset state.
8. The device connection method according to any one of claims 1 to 4, characterized in that: When the device identity is the group owner identity, the method further includes: receiving a query message sent by the second device, wherein the query message is used to determine whether the group owner identity is successfully created; Sending a response message to the second device, where the response message is used to indicate that the group owner identity is successfully created.
9. The device connection method according to any one of claims 1 to 4, characterized in that: When the device identity is the group client identity, the method further includes: Sending a query message to the second device, where the query message is used to determine whether the group owner identity of the second device is successfully created; Receive response information sent by the second device, where the response information is used to indicate that the group owner identity of the second device is successfully created.
10. A device connection device, characterized in that: Applied to a first device, the device connection device comprises: The acceleration module is configured to create a first network card when the state of the wireless network card meets a preset condition, wherein the first network card is used to establish a point-to-point wireless connection channel between the first device and the second device; a transceiver module, configured to send a point-to-point wireless connection request to the second device, or to receive a point-to-point wireless connection request sent by the second device; A creation module, configured to create a device identity, wherein the device identity is a group owner identity or a group client identity; The connection module is configured to establish a communication connection with the second device based on the point-to-point wireless connection channel using the device identity.
11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the device connection method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the device connection method as described in any one of claims 1 to 9.